kt_path
stringlengths 35
167
| kt_source
stringlengths 626
28.9k
| classes
listlengths 1
17
|
|---|---|---|
shauryam-exe__DS-Algo-Zone__3a24745/Kotlin/SelectionSort.kt
|
fun main(args: Array<String>) {
//Input the array in the format num1 num2 num3 num4 etc
print("Enter the elements for the Array: ")
var inputArray = readLine()!!.trim().split(" ").map { it -> it.toInt() }.toIntArray()
var sortedArray = selectionSort(inputArray)
println(sortedArray.contentToString())
}
fun selectionSort(arr: IntArray): IntArray {
for (i in arr.lastIndex downTo 0) {
var max = arr[0]
var maxIndex = 0
for (j in 0..i) {
if (arr[maxIndex]<arr[j])
maxIndex = j
}
val temp = arr[maxIndex]
arr[maxIndex] = arr[i]
arr[i] = temp
}
return arr
}
//Sample
//Input: Enter the elements for the Array: 64 23 -12 -5 0 2 89 20 100 32 650 -230 130
//Output: [-230, -12, -5, 0, 2, 20, 23, 32, 64, 89, 100, 130, 650]
//Time Complexity: Worst Case: O(n^2) Best Case: O(n^2)
//Space Complexity: O(1)
|
[
{
"class_path": "shauryam-exe__DS-Algo-Zone__3a24745/SelectionSortKt.class",
"javap": "Compiled from \"SelectionSort.kt\"\npublic final class SelectionSortKt {\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: ldc #17 // String Enter the elements for the Array:\n 8: getstatic #23 // Field java/lang/System.out:Ljava/io/PrintStream;\n 11: swap\n 12: invokevirtual #29 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 15: invokestatic #35 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 18: dup\n 19: invokestatic #38 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 22: checkcast #40 // class java/lang/CharSequence\n 25: invokestatic #46 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 28: invokevirtual #49 // Method java/lang/Object.toString:()Ljava/lang/String;\n 31: checkcast #40 // class java/lang/CharSequence\n 34: iconst_1\n 35: anewarray #51 // class java/lang/String\n 38: astore_2\n 39: aload_2\n 40: iconst_0\n 41: ldc #53 // String\n 43: aastore\n 44: aload_2\n 45: iconst_0\n 46: iconst_0\n 47: bipush 6\n 49: aconst_null\n 50: invokestatic #57 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 53: checkcast #59 // class java/lang/Iterable\n 56: astore_2\n 57: iconst_0\n 58: istore_3\n 59: aload_2\n 60: astore 4\n 62: new #61 // class java/util/ArrayList\n 65: dup\n 66: aload_2\n 67: bipush 10\n 69: invokestatic #67 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 72: invokespecial #71 // Method java/util/ArrayList.\"<init>\":(I)V\n 75: checkcast #73 // class java/util/Collection\n 78: astore 5\n 80: iconst_0\n 81: istore 6\n 83: aload 4\n 85: invokeinterface #77, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 90: astore 7\n 92: aload 7\n 94: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 99: ifeq 146\n 102: aload 7\n 104: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 109: astore 8\n 111: aload 5\n 113: aload 8\n 115: checkcast #51 // class java/lang/String\n 118: astore 9\n 120: astore 11\n 122: iconst_0\n 123: istore 10\n 125: aload 9\n 127: invokestatic #93 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 130: nop\n 131: invokestatic #97 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 134: aload 11\n 136: swap\n 137: invokeinterface #101, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 142: pop\n 143: goto 92\n 146: aload 5\n 148: checkcast #103 // class java/util/List\n 151: nop\n 152: checkcast #73 // class java/util/Collection\n 155: invokestatic #107 // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I\n 158: astore_1\n 159: aload_1\n 160: invokestatic #111 // Method selectionSort:([I)[I\n 163: astore_2\n 164: aload_2\n 165: invokestatic #116 // Method java/util/Arrays.toString:([I)Ljava/lang/String;\n 168: dup\n 169: ldc #118 // String toString(...)\n 171: invokestatic #121 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 174: astore_3\n 175: getstatic #23 // Field java/lang/System.out:Ljava/io/PrintStream;\n 178: aload_3\n 179: invokevirtual #124 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 182: return\n\n public static final int[] selectionSort(int[]);\n Code:\n 0: aload_0\n 1: ldc #144 // String arr\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #150 // Method kotlin/collections/ArraysKt.getLastIndex:([I)I\n 10: istore_1\n 11: iconst_m1\n 12: iload_1\n 13: if_icmpge 78\n 16: aload_0\n 17: iconst_0\n 18: iaload\n 19: istore_2\n 20: iconst_0\n 21: istore_3\n 22: iconst_0\n 23: istore 4\n 25: iload 4\n 27: iload_1\n 28: if_icmpgt 56\n 31: aload_0\n 32: iload_3\n 33: iaload\n 34: aload_0\n 35: iload 4\n 37: iaload\n 38: if_icmpge 44\n 41: iload 4\n 43: istore_3\n 44: iload 4\n 46: iload_1\n 47: if_icmpeq 56\n 50: iinc 4, 1\n 53: goto 31\n 56: aload_0\n 57: iload_3\n 58: iaload\n 59: istore 4\n 61: aload_0\n 62: iload_3\n 63: aload_0\n 64: iload_1\n 65: iaload\n 66: iastore\n 67: aload_0\n 68: iload_1\n 69: iload 4\n 71: iastore\n 72: iinc 1, -1\n 75: goto 11\n 78: aload_0\n 79: areturn\n}\n",
"javap_err": ""
}
] |
romangraef__PatternToFormula__e140a49/src/PatternFinder.kt
|
import java.lang.Math.floor
import java.lang.Math.max
import javax.script.ScriptEngine
import javax.script.ScriptEngineManager
data class Expression(val expression: String)
fun main(args:Array<String>) {
while (true) {
println("---------------------------")
println("Separate numbers by comma.")
print("Enter numbers: ")
val inputNumbers = readLine()!!.split(",").map { it.trim().toDouble() }
val formula = findFormula(inputNumbers)
println("Formula: $formula")
println("Pattern: " + continuePattern(formula))
}
}
private fun findFormula(numbers: List<Double>): String {
// Find difference between numbers
val differences = listOf(
numbers[1] - numbers[0],
numbers[2] - numbers[1]
)
var incrementsByDifference = true
var increment = 0.0
if (differences[0] != differences[1]) // If the pattern doesn't increment by difference
incrementsByDifference = false
else
increment = differences[0]
// Start-value
val nAsExponent = nAsExponent(differences, numbers)
val startValueDifference = when {
incrementsByDifference -> differences[0] // xn
nAsExponent -> getBase(differences) // x^n
else -> 1.0 // n^x
}
val startValue = numbers[0] - startValueDifference
// Exponents
var base = "n"
var exponent = ""
if (nAsExponent(differences, numbers)) {
base = getBase(differences).cleanRedundancy() + "^"
exponent = "n"
} else if (!incrementsByDifference) {
base = "n^"
exponent = getExponent(numbers[1], startValue).cleanRedundancy()
}
// Add the pieces together
var formula = increment.cleanRedundancy()
formula += base + exponent + startValue.cleanRedundancy().addSign()
return formula
}
private fun continuePattern(formula: String): String {
var output = ""
for (i in 1..20) {
val expression = Expression(formula.replace("n", i.toString()))
output += expression.calculate().cleanRedundancy() + ", "
}
return output.cleanRedundancy()
}
fun Double.cleanRedundancy(): String {
return when {
this == 0.0 -> return ""
floor(this) == this -> this.toInt().toString()
else -> return this.toString()
}
}
fun String.cleanRedundancy(): String {
return if (this.endsWith(", "))
this.substring(0, this.length - 3)
else
this
}
fun String.addSign(): String {
return if (!this.startsWith("-"))
"+" + this
else
this
}
fun Expression.calculate(): Double {
val addSubSign = max(expression.indexOf("+"), expression.indexOf("-"))
val addSub = expression.substring(addSubSign + 1, expression.length).toDouble()
val numbers = expression.substring(0, addSubSign)
.split(Regex("[*^]")).map { it.toDouble() }
if (expression.contains("*"))
return numbers[0] * numbers[1] + addSub
else if (expression.contains("^"))
return Math.pow(numbers[0], numbers[1]) + addSub
return 0.0
}
private fun getBase(differences: List<Double>): Double {
return differences[1] / differences[0]
}
private fun getExponent(secondNumber: Double, startValue: Double): Double {
return Math.log(secondNumber - startValue) / Math.log(2.0)
}
private fun nAsExponent(differences: List<Double>, numbers: List<Double>): Boolean {
val base = getBase(differences)
return Math.log(numbers[1] - (base - 1)) / Math.log(base) == 2.0
}
|
[
{
"class_path": "romangraef__PatternToFormula__e140a49/PatternFinderKt.class",
"javap": "Compiled from \"PatternFinder.kt\"\npublic final class PatternFinderKt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String args\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: nop\n 7: ldc #17 // String ---------------------------\n 9: getstatic #23 // Field java/lang/System.out:Ljava/io/PrintStream;\n 12: swap\n 13: invokevirtual #29 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 16: ldc #31 // String Separate numbers by comma.\n 18: getstatic #23 // Field java/lang/System.out:Ljava/io/PrintStream;\n 21: swap\n 22: invokevirtual #29 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 25: ldc #33 // String Enter numbers:\n 27: getstatic #23 // Field java/lang/System.out:Ljava/io/PrintStream;\n 30: swap\n 31: invokevirtual #36 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 34: invokestatic #42 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 37: dup\n 38: invokestatic #45 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 41: checkcast #47 // class java/lang/CharSequence\n 44: iconst_1\n 45: anewarray #49 // class java/lang/String\n 48: astore_2\n 49: aload_2\n 50: iconst_0\n 51: ldc #51 // String ,\n 53: aastore\n 54: aload_2\n 55: iconst_0\n 56: iconst_0\n 57: bipush 6\n 59: aconst_null\n 60: invokestatic #57 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 63: checkcast #59 // class java/lang/Iterable\n 66: astore_2\n 67: iconst_0\n 68: istore_3\n 69: aload_2\n 70: astore 4\n 72: new #61 // class java/util/ArrayList\n 75: dup\n 76: aload_2\n 77: bipush 10\n 79: invokestatic #67 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 82: invokespecial #71 // Method java/util/ArrayList.\"<init>\":(I)V\n 85: checkcast #73 // class java/util/Collection\n 88: astore 5\n 90: iconst_0\n 91: istore 6\n 93: aload 4\n 95: invokeinterface #77, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 100: astore 7\n 102: aload 7\n 104: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 109: ifeq 166\n 112: aload 7\n 114: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 119: astore 8\n 121: aload 5\n 123: aload 8\n 125: checkcast #49 // class java/lang/String\n 128: astore 9\n 130: astore 11\n 132: iconst_0\n 133: istore 10\n 135: nop\n 136: aload 9\n 138: checkcast #47 // class java/lang/CharSequence\n 141: invokestatic #91 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 144: invokevirtual #94 // Method java/lang/Object.toString:()Ljava/lang/String;\n 147: invokestatic #100 // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D\n 150: nop\n 151: invokestatic #104 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 154: aload 11\n 156: swap\n 157: invokeinterface #108, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 162: pop\n 163: goto 102\n 166: aload 5\n 168: checkcast #110 // class java/util/List\n 171: nop\n 172: astore_1\n 173: aload_1\n 174: invokestatic #114 // Method findFormula:(Ljava/util/List;)Ljava/lang/String;\n 177: astore_2\n 178: new #116 // class java/lang/StringBuilder\n 181: dup\n 182: invokespecial #119 // Method java/lang/StringBuilder.\"<init>\":()V\n 185: ldc #121 // String Formula:\n 187: invokevirtual #125 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 190: aload_2\n 191: invokevirtual #125 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 194: invokevirtual #126 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 197: getstatic #23 // Field java/lang/System.out:Ljava/io/PrintStream;\n 200: swap\n 201: invokevirtual #29 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 204: new #116 // class java/lang/StringBuilder\n 207: dup\n 208: invokespecial #119 // Method java/lang/StringBuilder.\"<init>\":()V\n 211: ldc #128 // String Pattern:\n 213: invokevirtual #125 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 216: aload_2\n 217: invokestatic #132 // Method continuePattern:(Ljava/lang/String;)Ljava/lang/String;\n 220: invokevirtual #125 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 223: invokevirtual #126 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 226: getstatic #23 // Field java/lang/System.out:Ljava/io/PrintStream;\n 229: swap\n 230: invokevirtual #29 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 233: goto 6\n\n private static final java.lang.String findFormula(java.util.List<java.lang.Double>);\n Code:\n 0: iconst_2\n 1: anewarray #96 // class java/lang/Double\n 4: astore_2\n 5: aload_2\n 6: iconst_0\n 7: aload_0\n 8: iconst_1\n 9: invokeinterface #155, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 14: checkcast #157 // class java/lang/Number\n 17: invokevirtual #161 // Method java/lang/Number.doubleValue:()D\n 20: aload_0\n 21: iconst_0\n 22: invokeinterface #155, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 27: checkcast #157 // class java/lang/Number\n 30: invokevirtual #161 // Method java/lang/Number.doubleValue:()D\n 33: dsub\n 34: invokestatic #104 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 37: aastore\n 38: aload_2\n 39: iconst_1\n 40: aload_0\n 41: iconst_2\n 42: invokeinterface #155, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 47: checkcast #157 // class java/lang/Number\n 50: invokevirtual #161 // Method java/lang/Number.doubleValue:()D\n 53: aload_0\n 54: iconst_1\n 55: invokeinterface #155, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 60: checkcast #157 // class java/lang/Number\n 63: invokevirtual #161 // Method java/lang/Number.doubleValue:()D\n 66: dsub\n 67: invokestatic #104 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 70: aastore\n 71: aload_2\n 72: invokestatic #165 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 75: astore_1\n 76: iconst_1\n 77: istore_2\n 78: dconst_0\n 79: dstore_3\n 80: aload_1\n 81: iconst_0\n 82: invokeinterface #155, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 87: checkcast #157 // class java/lang/Number\n 90: invokevirtual #161 // Method java/lang/Number.doubleValue:()D\n 93: aload_1\n 94: iconst_1\n 95: invokeinterface #155, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 100: checkcast #157 // class java/lang/Number\n 103: invokevirtual #161 // Method java/lang/Number.doubleValue:()D\n 106: dcmpg\n 107: ifne 114\n 110: iconst_1\n 111: goto 115\n 114: iconst_0\n 115: ifne 123\n 118: iconst_0\n 119: istore_2\n 120: goto 137\n 123: aload_1\n 124: iconst_0\n 125: invokeinterface #155, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 130: checkcast #157 // class java/lang/Number\n 133: invokevirtual #161 // Method java/lang/Number.doubleValue:()D\n 136: dstore_3\n 137: aload_1\n 138: aload_0\n 139: invokestatic #169 // Method nAsExponent:(Ljava/util/List;Ljava/util/List;)Z\n 142: istore 5\n 144: nop\n 145: iload_2\n 146: ifeq 165\n 149: aload_1\n 150: iconst_0\n 151: invokeinterface #155, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 156: checkcast #157 // class java/lang/Number\n 159: invokevirtual #161 // Method java/lang/Number.doubleValue:()D\n 162: goto 178\n 165: iload 5\n 167: ifeq 177\n 170: aload_1\n 171: invokestatic #173 // Method getBase:(Ljava/util/List;)D\n 174: goto 178\n 177: dconst_1\n 178: dstore 6\n 180: aload_0\n 181: iconst_0\n 182: invokeinterface #155, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 187: checkcast #157 // class java/lang/Number\n 190: invokevirtual #161 // Method java/lang/Number.doubleValue:()D\n 193: dload 6\n 195: dsub\n 196: dstore 8\n 198: ldc #175 // String n\n 200: astore 10\n 202: ldc #177 // String\n 204: astore 11\n 206: aload_1\n 207: aload_0\n 208: invokestatic #169 // Method nAsExponent:(Ljava/util/List;Ljava/util/List;)Z\n 211: ifeq 248\n 214: new #116 // class java/lang/StringBuilder\n 217: dup\n 218: invokespecial #119 // Method java/lang/StringBuilder.\"<init>\":()V\n 221: aload_1\n 222: invokestatic #173 // Method getBase:(Ljava/util/List;)D\n 225: invokestatic #181 // Method cleanRedundancy:(D)Ljava/lang/String;\n 228: invokevirtual #125 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 231: bipush 94\n 233: invokevirtual #184 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 236: invokevirtual #126 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 239: astore 10\n 241: ldc #175 // String n\n 243: astore 11\n 245: goto 279\n 248: iload_2\n 249: ifne 279\n 252: ldc #186 // String n^\n 254: astore 10\n 256: aload_0\n 257: iconst_1\n 258: invokeinterface #155, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 263: checkcast #157 // class java/lang/Number\n 266: invokevirtual #161 // Method java/lang/Number.doubleValue:()D\n 269: dload 8\n 271: invokestatic #190 // Method getExponent:(DD)D\n 274: invokestatic #181 // Method cleanRedundancy:(D)Ljava/lang/String;\n 277: astore 11\n 279: dload_3\n 280: invokestatic #181 // Method cleanRedundancy:(D)Ljava/lang/String;\n 283: astore 12\n 285: new #116 // class java/lang/StringBuilder\n 288: dup\n 289: invokespecial #119 // Method java/lang/StringBuilder.\"<init>\":()V\n 292: aload 12\n 294: invokevirtual #125 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 297: aload 10\n 299: invokevirtual #125 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 302: aload 11\n 304: invokevirtual #125 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 307: dload 8\n 309: invokestatic #181 // Method cleanRedundancy:(D)Ljava/lang/String;\n 312: invokestatic #193 // Method addSign:(Ljava/lang/String;)Ljava/lang/String;\n 315: invokevirtual #125 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 318: invokevirtual #126 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 321: astore 12\n 323: aload 12\n 325: areturn\n\n private static final java.lang.String continuePattern(java.lang.String);\n Code:\n 0: ldc #177 // String\n 2: astore_1\n 3: iconst_1\n 4: istore_2\n 5: iload_2\n 6: bipush 21\n 8: if_icmpge 68\n 11: new #205 // class Expression\n 14: dup\n 15: aload_0\n 16: ldc #175 // String n\n 18: iload_2\n 19: invokestatic #208 // Method java/lang/String.valueOf:(I)Ljava/lang/String;\n 22: iconst_0\n 23: iconst_4\n 24: aconst_null\n 25: invokestatic #212 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 28: invokespecial #215 // Method Expression.\"<init>\":(Ljava/lang/String;)V\n 31: astore_3\n 32: new #116 // class java/lang/StringBuilder\n 35: dup\n 36: invokespecial #119 // Method java/lang/StringBuilder.\"<init>\":()V\n 39: aload_1\n 40: invokevirtual #125 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 43: aload_3\n 44: invokestatic #219 // Method calculate:(LExpression;)D\n 47: invokestatic #181 // Method cleanRedundancy:(D)Ljava/lang/String;\n 50: invokevirtual #125 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 53: ldc #221 // String ,\n 55: invokevirtual #125 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 58: invokevirtual #126 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 61: astore_1\n 62: iinc 2, 1\n 65: goto 5\n 68: aload_1\n 69: invokestatic #223 // Method cleanRedundancy:(Ljava/lang/String;)Ljava/lang/String;\n 72: areturn\n\n public static final java.lang.String cleanRedundancy(double);\n Code:\n 0: nop\n 1: dload_0\n 2: dconst_0\n 3: dcmpg\n 4: ifne 11\n 7: iconst_1\n 8: goto 12\n 11: iconst_0\n 12: ifeq 18\n 15: ldc #177 // String\n 17: areturn\n 18: dload_0\n 19: invokestatic #233 // Method java/lang/Math.floor:(D)D\n 22: dload_0\n 23: dcmpg\n 24: ifne 31\n 27: iconst_1\n 28: goto 32\n 31: iconst_0\n 32: ifeq 43\n 35: dload_0\n 36: d2i\n 37: invokestatic #208 // Method java/lang/String.valueOf:(I)Ljava/lang/String;\n 40: goto 48\n 43: dload_0\n 44: invokestatic #235 // Method java/lang/String.valueOf:(D)Ljava/lang/String;\n 47: areturn\n 48: areturn\n\n public static final java.lang.String cleanRedundancy(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #238 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: ldc #221 // String ,\n 9: iconst_0\n 10: iconst_2\n 11: aconst_null\n 12: invokestatic #242 // Method kotlin/text/StringsKt.endsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 15: ifeq 38\n 18: aload_0\n 19: iconst_0\n 20: aload_0\n 21: invokevirtual #246 // Method java/lang/String.length:()I\n 24: iconst_3\n 25: isub\n 26: invokevirtual #250 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 29: dup\n 30: ldc #252 // String substring(...)\n 32: invokestatic #255 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 35: goto 39\n 38: aload_0\n 39: areturn\n\n public static final java.lang.String addSign(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #238 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: ldc_w #257 // String -\n 10: iconst_0\n 11: iconst_2\n 12: aconst_null\n 13: invokestatic #260 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 16: ifne 41\n 19: new #116 // class java/lang/StringBuilder\n 22: dup\n 23: invokespecial #119 // Method java/lang/StringBuilder.\"<init>\":()V\n 26: bipush 43\n 28: invokevirtual #184 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 31: aload_0\n 32: invokevirtual #125 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 35: invokevirtual #126 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 38: goto 42\n 41: aload_0\n 42: areturn\n\n public static final double calculate(Expression);\n Code:\n 0: aload_0\n 1: ldc #238 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokevirtual #264 // Method Expression.getExpression:()Ljava/lang/String;\n 10: checkcast #47 // class java/lang/CharSequence\n 13: ldc_w #266 // String +\n 16: iconst_0\n 17: iconst_0\n 18: bipush 6\n 20: aconst_null\n 21: invokestatic #270 // Method kotlin/text/StringsKt.indexOf$default:(Ljava/lang/CharSequence;Ljava/lang/String;IZILjava/lang/Object;)I\n 24: aload_0\n 25: invokevirtual #264 // Method Expression.getExpression:()Ljava/lang/String;\n 28: checkcast #47 // class java/lang/CharSequence\n 31: ldc_w #257 // String -\n 34: iconst_0\n 35: iconst_0\n 36: bipush 6\n 38: aconst_null\n 39: invokestatic #270 // Method kotlin/text/StringsKt.indexOf$default:(Ljava/lang/CharSequence;Ljava/lang/String;IZILjava/lang/Object;)I\n 42: invokestatic #274 // Method java/lang/Math.max:(II)I\n 45: istore_1\n 46: nop\n 47: aload_0\n 48: invokevirtual #264 // Method Expression.getExpression:()Ljava/lang/String;\n 51: iload_1\n 52: iconst_1\n 53: iadd\n 54: aload_0\n 55: invokevirtual #264 // Method Expression.getExpression:()Ljava/lang/String;\n 58: invokevirtual #246 // Method java/lang/String.length:()I\n 61: invokevirtual #250 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 64: dup\n 65: ldc #252 // String substring(...)\n 67: invokestatic #255 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 70: invokestatic #100 // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D\n 73: dstore_2\n 74: aload_0\n 75: invokevirtual #264 // Method Expression.getExpression:()Ljava/lang/String;\n 78: iconst_0\n 79: iload_1\n 80: invokevirtual #250 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 83: dup\n 84: ldc #252 // String substring(...)\n 86: invokestatic #255 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 89: checkcast #47 // class java/lang/CharSequence\n 92: astore 5\n 94: new #276 // class kotlin/text/Regex\n 97: dup\n 98: ldc_w #278 // String [*^]\n 101: invokespecial #279 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 104: astore 6\n 106: iconst_0\n 107: istore 7\n 109: aload 6\n 111: aload 5\n 113: iload 7\n 115: invokevirtual #283 // Method kotlin/text/Regex.split:(Ljava/lang/CharSequence;I)Ljava/util/List;\n 118: checkcast #59 // class java/lang/Iterable\n 121: astore 5\n 123: nop\n 124: iconst_0\n 125: istore 6\n 127: aload 5\n 129: astore 7\n 131: new #61 // class java/util/ArrayList\n 134: dup\n 135: aload 5\n 137: bipush 10\n 139: invokestatic #67 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 142: invokespecial #71 // Method java/util/ArrayList.\"<init>\":(I)V\n 145: checkcast #73 // class java/util/Collection\n 148: astore 8\n 150: iconst_0\n 151: istore 9\n 153: aload 7\n 155: invokeinterface #77, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 160: astore 10\n 162: aload 10\n 164: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 169: ifeq 216\n 172: aload 10\n 174: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 179: astore 11\n 181: aload 8\n 183: aload 11\n 185: checkcast #49 // class java/lang/String\n 188: astore 12\n 190: astore 14\n 192: iconst_0\n 193: istore 13\n 195: aload 12\n 197: invokestatic #100 // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D\n 200: nop\n 201: invokestatic #104 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 204: aload 14\n 206: swap\n 207: invokeinterface #108, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 212: pop\n 213: goto 162\n 216: aload 8\n 218: checkcast #110 // class java/util/List\n 221: nop\n 222: astore 4\n 224: aload_0\n 225: invokevirtual #264 // Method Expression.getExpression:()Ljava/lang/String;\n 228: checkcast #47 // class java/lang/CharSequence\n 231: ldc_w #285 // String *\n 234: checkcast #47 // class java/lang/CharSequence\n 237: iconst_0\n 238: iconst_2\n 239: aconst_null\n 240: invokestatic #289 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z\n 243: ifeq 278\n 246: aload 4\n 248: iconst_0\n 249: invokeinterface #155, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 254: checkcast #157 // class java/lang/Number\n 257: invokevirtual #161 // Method java/lang/Number.doubleValue:()D\n 260: aload 4\n 262: iconst_1\n 263: invokeinterface #155, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 268: checkcast #157 // class java/lang/Number\n 271: invokevirtual #161 // Method java/lang/Number.doubleValue:()D\n 274: dmul\n 275: dload_2\n 276: dadd\n 277: dreturn\n 278: aload_0\n 279: invokevirtual #264 // Method Expression.getExpression:()Ljava/lang/String;\n 282: checkcast #47 // class java/lang/CharSequence\n 285: ldc_w #291 // String ^\n 288: checkcast #47 // class java/lang/CharSequence\n 291: iconst_0\n 292: iconst_2\n 293: aconst_null\n 294: invokestatic #289 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z\n 297: ifeq 334\n 300: aload 4\n 302: iconst_0\n 303: invokeinterface #155, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 308: checkcast #157 // class java/lang/Number\n 311: invokevirtual #161 // Method java/lang/Number.doubleValue:()D\n 314: aload 4\n 316: iconst_1\n 317: invokeinterface #155, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 322: checkcast #157 // class java/lang/Number\n 325: invokevirtual #161 // Method java/lang/Number.doubleValue:()D\n 328: invokestatic #294 // Method java/lang/Math.pow:(DD)D\n 331: dload_2\n 332: dadd\n 333: dreturn\n 334: dconst_0\n 335: dreturn\n\n private static final double getBase(java.util.List<java.lang.Double>);\n Code:\n 0: aload_0\n 1: iconst_1\n 2: invokeinterface #155, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #157 // class java/lang/Number\n 10: invokevirtual #161 // Method java/lang/Number.doubleValue:()D\n 13: aload_0\n 14: iconst_0\n 15: invokeinterface #155, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 20: checkcast #157 // class java/lang/Number\n 23: invokevirtual #161 // Method java/lang/Number.doubleValue:()D\n 26: ddiv\n 27: dreturn\n\n private static final double getExponent(double, double);\n Code:\n 0: dload_0\n 1: dload_2\n 2: dsub\n 3: invokestatic #302 // Method java/lang/Math.log:(D)D\n 6: ldc2_w #303 // double 2.0d\n 9: invokestatic #302 // Method java/lang/Math.log:(D)D\n 12: ddiv\n 13: dreturn\n\n private static final boolean nAsExponent(java.util.List<java.lang.Double>, java.util.List<java.lang.Double>);\n Code:\n 0: aload_0\n 1: invokestatic #173 // Method getBase:(Ljava/util/List;)D\n 4: dstore_2\n 5: aload_1\n 6: iconst_1\n 7: invokeinterface #155, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 12: checkcast #157 // class java/lang/Number\n 15: invokevirtual #161 // Method java/lang/Number.doubleValue:()D\n 18: dload_2\n 19: iconst_1\n 20: i2d\n 21: dsub\n 22: dsub\n 23: invokestatic #302 // Method java/lang/Math.log:(D)D\n 26: dload_2\n 27: invokestatic #302 // Method java/lang/Math.log:(D)D\n 30: ddiv\n 31: ldc2_w #303 // double 2.0d\n 34: dcmpg\n 35: ifne 42\n 38: iconst_1\n 39: goto 43\n 42: iconst_0\n 43: ireturn\n}\n",
"javap_err": ""
}
] |
MeilCli__StalinSort__b245390/Kotlin/src/main/kotlin/StalinSort.kt
|
fun main(args: Array<String>) {
println("Hello Stalin!")
writeStalinSort(intArrayOf(4))
writeStalinSort(intArrayOf(6, 2, 5, 7, 3, 8, 8, 4))
writeStalinSort(intArrayOf(5, 3, 7, 8, 9, 5, 3, 5, 7))
/**
* Hello Stalin!
* Input: 4
* StalinBy: 4
* StalinByDescending: 4
* Input: 6,2,5,7,3,8,8,4
* StalinBy: 6,7,8,8
* StalinByDescending: 6,2
* Input: 5,3,7,8,9,5,3,5,7
* StalinBy: 5,7,8,9
* StalinByDescending: 5,3,3
*/
}
private fun writeStalinSort(source: IntArray) {
println("Input: ${source.joinToString(",")}")
println("StalinBy: ${source.asSequence().stalinBy().joinToString(",")}")
println("StalinByDescending: ${source.asSequence().stalinByDescending().joinToString(",")}")
}
fun <T> Sequence<T>.stalinBy(): List<T> where T : Comparable<T> {
return stalinSort(this, false)
}
fun <T> Sequence<T>.stalinByDescending(): List<T> where T : Comparable<T> {
return stalinSort(this, true)
}
private fun <T> stalinSort(source: Sequence<T>, descending: Boolean): List<T> where T : Comparable<T> {
val iterator = source.iterator()
val result = mutableListOf<T>()
if (iterator.hasNext()) {
var lastElement = iterator.next()
result.add(lastElement)
while (iterator.hasNext()) {
val element = iterator.next()
val compare = when (descending) {
true -> element <= lastElement
false -> lastElement <= element
}
if (compare) {
result.add(element)
lastElement = element
}
}
}
return result
}
|
[
{
"class_path": "MeilCli__StalinSort__b245390/StalinSortKt.class",
"javap": "Compiled from \"StalinSort.kt\"\npublic final class StalinSortKt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String args\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #17 // String Hello Stalin!\n 8: getstatic #23 // Field java/lang/System.out:Ljava/io/PrintStream;\n 11: swap\n 12: invokevirtual #29 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 15: iconst_1\n 16: newarray int\n 18: astore_1\n 19: aload_1\n 20: iconst_0\n 21: iconst_4\n 22: iastore\n 23: aload_1\n 24: invokestatic #33 // Method writeStalinSort:([I)V\n 27: bipush 8\n 29: newarray int\n 31: astore_1\n 32: aload_1\n 33: iconst_0\n 34: bipush 6\n 36: iastore\n 37: aload_1\n 38: iconst_1\n 39: iconst_2\n 40: iastore\n 41: aload_1\n 42: iconst_2\n 43: iconst_5\n 44: iastore\n 45: aload_1\n 46: iconst_3\n 47: bipush 7\n 49: iastore\n 50: aload_1\n 51: iconst_4\n 52: iconst_3\n 53: iastore\n 54: aload_1\n 55: iconst_5\n 56: bipush 8\n 58: iastore\n 59: aload_1\n 60: bipush 6\n 62: bipush 8\n 64: iastore\n 65: aload_1\n 66: bipush 7\n 68: iconst_4\n 69: iastore\n 70: aload_1\n 71: invokestatic #33 // Method writeStalinSort:([I)V\n 74: bipush 9\n 76: newarray int\n 78: astore_1\n 79: aload_1\n 80: iconst_0\n 81: iconst_5\n 82: iastore\n 83: aload_1\n 84: iconst_1\n 85: iconst_3\n 86: iastore\n 87: aload_1\n 88: iconst_2\n 89: bipush 7\n 91: iastore\n 92: aload_1\n 93: iconst_3\n 94: bipush 8\n 96: iastore\n 97: aload_1\n 98: iconst_4\n 99: bipush 9\n 101: iastore\n 102: aload_1\n 103: iconst_5\n 104: iconst_5\n 105: iastore\n 106: aload_1\n 107: bipush 6\n 109: iconst_3\n 110: iastore\n 111: aload_1\n 112: bipush 7\n 114: iconst_5\n 115: iastore\n 116: aload_1\n 117: bipush 8\n 119: bipush 7\n 121: iastore\n 122: aload_1\n 123: invokestatic #33 // Method writeStalinSort:([I)V\n 126: return\n\n private static final void writeStalinSort(int[]);\n Code:\n 0: new #36 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #40 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #42 // String Input:\n 9: invokevirtual #46 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: ldc #48 // String ,\n 15: checkcast #50 // class java/lang/CharSequence\n 18: aconst_null\n 19: aconst_null\n 20: iconst_0\n 21: aconst_null\n 22: aconst_null\n 23: bipush 62\n 25: aconst_null\n 26: invokestatic #56 // Method kotlin/collections/ArraysKt.joinToString$default:([ILjava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;\n 29: invokevirtual #46 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 32: invokevirtual #60 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 35: getstatic #23 // Field java/lang/System.out:Ljava/io/PrintStream;\n 38: swap\n 39: invokevirtual #29 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 42: new #36 // class java/lang/StringBuilder\n 45: dup\n 46: invokespecial #40 // Method java/lang/StringBuilder.\"<init>\":()V\n 49: ldc #62 // String StalinBy:\n 51: invokevirtual #46 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 54: aload_0\n 55: invokestatic #66 // Method kotlin/collections/ArraysKt.asSequence:([I)Lkotlin/sequences/Sequence;\n 58: invokestatic #70 // Method stalinBy:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 61: checkcast #72 // class java/lang/Iterable\n 64: ldc #48 // String ,\n 66: checkcast #50 // class java/lang/CharSequence\n 69: aconst_null\n 70: aconst_null\n 71: iconst_0\n 72: aconst_null\n 73: aconst_null\n 74: bipush 62\n 76: aconst_null\n 77: invokestatic #77 // 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 80: invokevirtual #46 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 83: invokevirtual #60 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 86: getstatic #23 // Field java/lang/System.out:Ljava/io/PrintStream;\n 89: swap\n 90: invokevirtual #29 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 93: new #36 // class java/lang/StringBuilder\n 96: dup\n 97: invokespecial #40 // Method java/lang/StringBuilder.\"<init>\":()V\n 100: ldc #79 // String StalinByDescending:\n 102: invokevirtual #46 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 105: aload_0\n 106: invokestatic #66 // Method kotlin/collections/ArraysKt.asSequence:([I)Lkotlin/sequences/Sequence;\n 109: invokestatic #82 // Method stalinByDescending:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 112: checkcast #72 // class java/lang/Iterable\n 115: ldc #48 // String ,\n 117: checkcast #50 // class java/lang/CharSequence\n 120: aconst_null\n 121: aconst_null\n 122: iconst_0\n 123: aconst_null\n 124: aconst_null\n 125: bipush 62\n 127: aconst_null\n 128: invokestatic #77 // 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 131: invokevirtual #46 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 134: invokevirtual #60 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 137: getstatic #23 // Field java/lang/System.out:Ljava/io/PrintStream;\n 140: swap\n 141: invokevirtual #29 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 144: return\n\n public static final <T extends java.lang.Comparable<? super T>> java.util.List<T> stalinBy(kotlin.sequences.Sequence<? extends T>);\n Code:\n 0: aload_0\n 1: ldc #87 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iconst_0\n 8: invokestatic #91 // Method stalinSort:(Lkotlin/sequences/Sequence;Z)Ljava/util/List;\n 11: areturn\n\n public static final <T extends java.lang.Comparable<? super T>> java.util.List<T> stalinByDescending(kotlin.sequences.Sequence<? extends T>);\n Code:\n 0: aload_0\n 1: ldc #87 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iconst_1\n 8: invokestatic #91 // Method stalinSort:(Lkotlin/sequences/Sequence;Z)Ljava/util/List;\n 11: areturn\n\n private static final <T extends java.lang.Comparable<? super T>> java.util.List<T> stalinSort(kotlin.sequences.Sequence<? extends T>, boolean);\n Code:\n 0: aload_0\n 1: invokeinterface #101, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 6: astore_2\n 7: new #103 // class java/util/ArrayList\n 10: dup\n 11: invokespecial #104 // Method java/util/ArrayList.\"<init>\":()V\n 14: checkcast #106 // class java/util/List\n 17: astore_3\n 18: aload_2\n 19: invokeinterface #112, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 24: ifeq 152\n 27: aload_2\n 28: invokeinterface #116, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 33: checkcast #118 // class java/lang/Comparable\n 36: astore 4\n 38: aload_3\n 39: aload 4\n 41: invokeinterface #122, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 46: pop\n 47: aload_2\n 48: invokeinterface #112, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 152\n 56: aload_2\n 57: invokeinterface #116, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 62: checkcast #118 // class java/lang/Comparable\n 65: astore 5\n 67: iload_1\n 68: istore 7\n 70: iload 7\n 72: iconst_1\n 73: if_icmpne 96\n 76: aload 5\n 78: aload 4\n 80: invokeinterface #126, 2 // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I\n 85: ifgt 92\n 88: iconst_1\n 89: goto 129\n 92: iconst_0\n 93: goto 129\n 96: iload 7\n 98: ifne 121\n 101: aload 4\n 103: aload 5\n 105: invokeinterface #126, 2 // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I\n 110: ifgt 117\n 113: iconst_1\n 114: goto 129\n 117: iconst_0\n 118: goto 129\n 121: new #128 // class kotlin/NoWhenBranchMatchedException\n 124: dup\n 125: invokespecial #129 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 128: athrow\n 129: istore 6\n 131: iload 6\n 133: ifeq 47\n 136: aload_3\n 137: aload 5\n 139: invokeinterface #122, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 144: pop\n 145: aload 5\n 147: astore 4\n 149: goto 47\n 152: aload_3\n 153: areturn\n}\n",
"javap_err": ""
}
] |
mepants__Advent-Of-Code-2022__3b42381/Day2_02/src/main/kotlin/Main.kt
|
import java.io.File
enum class Move(val value: Int)
{
ROCK(1) {
override fun scoreAgainst(opponentMove: Move): Int {
return when (opponentMove) {
ROCK -> 3
PAPER -> 0
SCISSORS -> 6
}
}
override fun losesAgainst() = PAPER
override fun winsAgainst() = SCISSORS
},
PAPER(2){
override fun scoreAgainst(opponentMove: Move): Int {
return when (opponentMove) {
ROCK -> 6
PAPER -> 3
SCISSORS -> 0
}
}
override fun losesAgainst() = SCISSORS
override fun winsAgainst() = ROCK
},
SCISSORS(3){
override fun scoreAgainst(opponentMove: Move): Int {
return when (opponentMove) {
ROCK -> 0
PAPER -> 6
SCISSORS -> 3
}
}
override fun losesAgainst() = ROCK
override fun winsAgainst() = PAPER
};
abstract fun scoreAgainst(opponentMove: Move) : Int
abstract fun losesAgainst() : Move
abstract fun winsAgainst() : Move
companion object {
fun fromLetter(letter: Char): Move {
return when (letter) {
'A' -> Move.ROCK
'B' -> Move.PAPER
'C' -> Move.SCISSORS
else -> throw Exception("Unknown move $letter")
}
}
}
}
fun main(args: Array<String>) {
val FILENAME = "c:\\Users\\micro\\code\\Advent-Of-Code-2022\\Day2_02\\input.txt"
fun scoreRound(oppLetter: Char, myLetter: Char) : Int {
val opponentMove = Move.fromLetter(oppLetter)
val myMove = when (myLetter) {
'X' -> opponentMove.winsAgainst()
'Z' -> opponentMove.losesAgainst()
else -> opponentMove
}
return myMove.value + myMove.scoreAgainst(opponentMove)
}
var score = 0
val file = File(FILENAME)
file.forEachLine {
score += scoreRound(it[0], it[2])
}
println("My total score is $score")
}
|
[
{
"class_path": "mepants__Advent-Of-Code-2022__3b42381/MainKt.class",
"javap": "Compiled from \"Main.kt\"\npublic final class MainKt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String args\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #17 // String c:\\\\Users\\\\micro\\\\code\\\\Advent-Of-Code-2022\\\\Day2_02\\\\input.txt\n 8: astore_1\n 9: new #19 // class kotlin/jvm/internal/Ref$IntRef\n 12: dup\n 13: invokespecial #23 // Method kotlin/jvm/internal/Ref$IntRef.\"<init>\":()V\n 16: astore_2\n 17: new #25 // class java/io/File\n 20: dup\n 21: aload_1\n 22: invokespecial #28 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 25: astore_3\n 26: aload_3\n 27: aconst_null\n 28: aload_2\n 29: invokedynamic #48, 0 // InvokeDynamic #0:invoke:(Lkotlin/jvm/internal/Ref$IntRef;)Lkotlin/jvm/functions/Function1;\n 34: iconst_1\n 35: aconst_null\n 36: invokestatic #54 // Method kotlin/io/FilesKt.forEachLine$default:(Ljava/io/File;Ljava/nio/charset/Charset;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V\n 39: new #56 // class java/lang/StringBuilder\n 42: dup\n 43: invokespecial #57 // Method java/lang/StringBuilder.\"<init>\":()V\n 46: ldc #59 // String My total score is\n 48: invokevirtual #63 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: aload_2\n 52: getfield #67 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 55: invokevirtual #70 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 58: invokevirtual #74 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 61: getstatic #80 // Field java/lang/System.out:Ljava/io/PrintStream;\n 64: swap\n 65: invokevirtual #86 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 68: return\n\n private static final int main$scoreRound(char, char);\n Code:\n 0: getstatic #101 // Field Move.Companion:LMove$Companion;\n 3: iload_0\n 4: invokevirtual #107 // Method Move$Companion.fromLetter:(C)LMove;\n 7: astore_2\n 8: iload_1\n 9: tableswitch { // 88 to 90\n 88: 36\n 89: 50\n 90: 43\n default: 50\n }\n 36: aload_2\n 37: invokevirtual #111 // Method Move.winsAgainst:()LMove;\n 40: goto 51\n 43: aload_2\n 44: invokevirtual #114 // Method Move.losesAgainst:()LMove;\n 47: goto 51\n 50: aload_2\n 51: astore_3\n 52: aload_3\n 53: invokevirtual #118 // Method Move.getValue:()I\n 56: aload_3\n 57: aload_2\n 58: invokevirtual #122 // Method Move.scoreAgainst:(LMove;)I\n 61: iadd\n 62: ireturn\n\n private static final kotlin.Unit main$lambda$0(kotlin.jvm.internal.Ref$IntRef, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #130 // String it\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_0\n 8: getfield #67 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 11: aload_1\n 12: iconst_0\n 13: invokevirtual #136 // Method java/lang/String.charAt:(I)C\n 16: aload_1\n 17: iconst_2\n 18: invokevirtual #136 // Method java/lang/String.charAt:(I)C\n 21: invokestatic #138 // Method main$scoreRound:(CC)I\n 24: iadd\n 25: putfield #67 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 28: getstatic #144 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 31: areturn\n}\n",
"javap_err": ""
}
] |
dirask__codelibrary__75f5296/kotlin/MaxFlowDinic.kt
|
// https://en.wikipedia.org/wiki/Dinic%27s_algorithm in O(V^2 * E)
object MaxFlowDinic {
data class Edge(val t: Int, val rev: Int, val cap: Int, var f: Int = 0)
fun addEdge(graph: Array<ArrayList<Edge>>, s: Int, t: Int, cap: Int) {
graph[s].add(Edge(t, graph[t].size, cap))
graph[t].add(Edge(s, graph[s].size - 1, 0))
}
fun dinicBfs(graph: Array<out List<Edge>>, src: Int, dest: Int, dist: IntArray): Boolean {
dist.fill(-1)
dist[src] = 0
val Q = IntArray(graph.size)
var sizeQ = 0
Q[sizeQ++] = src
var i = 0
while (i < sizeQ) {
val u = Q[i++]
for (e in graph[u]) {
if (dist[e.t] < 0 && e.f < e.cap) {
dist[e.t] = dist[u] + 1
Q[sizeQ++] = e.t
}
}
}
return dist[dest] >= 0
}
fun dinicDfs(graph: Array<out List<Edge>>, ptr: IntArray, dist: IntArray, dest: Int, u: Int, f: Int): Int {
if (u == dest)
return f
while (ptr[u] < graph[u].size) {
val e = graph[u][ptr[u]]
if (dist[e.t] == dist[u] + 1 && e.f < e.cap) {
val df = dinicDfs(graph, ptr, dist, dest, e.t, Math.min(f, e.cap - e.f))
if (df > 0) {
e.f += df
graph[e.t][e.rev].f -= df
return df
}
}
++ptr[u]
}
return 0
}
fun maxFlow(graph: Array<out List<Edge>>, src: Int, dest: Int): Int {
var flow = 0
val dist = IntArray(graph.size)
while (dinicBfs(graph, src, dest, dist)) {
val ptr = IntArray(graph.size)
while (true) {
val df = dinicDfs(graph, ptr, dist, dest, src, Int.MAX_VALUE)
if (df == 0)
break
flow += df
}
}
return flow
}
// Usage example
@JvmStatic
fun main(args: Array<String>) {
val graph = (1..3).map { arrayListOf<Edge>() }.toTypedArray()
addEdge(graph, 0, 1, 3)
addEdge(graph, 0, 2, 2)
addEdge(graph, 1, 2, 2)
val maxFlow = maxFlow(graph, 0, 2)
println(4 == maxFlow)
}
}
|
[
{
"class_path": "dirask__codelibrary__75f5296/MaxFlowDinic$Edge.class",
"javap": "Compiled from \"MaxFlowDinic.kt\"\npublic final class MaxFlowDinic$Edge {\n private final int t;\n\n private final int rev;\n\n private final int cap;\n\n private int f;\n\n public MaxFlowDinic$Edge(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 t:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field rev:I\n 14: aload_0\n 15: iload_3\n 16: putfield #19 // Field cap:I\n 19: aload_0\n 20: iload 4\n 22: putfield #22 // Field f:I\n 25: return\n\n public MaxFlowDinic$Edge(int, int, int, int, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload 5\n 2: bipush 8\n 4: iand\n 5: ifeq 11\n 8: iconst_0\n 9: istore 4\n 11: aload_0\n 12: iload_1\n 13: iload_2\n 14: iload_3\n 15: iload 4\n 17: invokespecial #27 // Method \"<init>\":(IIII)V\n 20: return\n\n public final int getT();\n Code:\n 0: aload_0\n 1: getfield #13 // Field t:I\n 4: ireturn\n\n public final int getRev();\n Code:\n 0: aload_0\n 1: getfield #16 // Field rev:I\n 4: ireturn\n\n public final int getCap();\n Code:\n 0: aload_0\n 1: getfield #19 // Field cap:I\n 4: ireturn\n\n public final int getF();\n Code:\n 0: aload_0\n 1: getfield #22 // Field f:I\n 4: ireturn\n\n public final void setF(int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: putfield #22 // Field f:I\n 5: return\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field t:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field rev:I\n 4: ireturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #19 // Field cap:I\n 4: ireturn\n\n public final int component4();\n Code:\n 0: aload_0\n 1: getfield #22 // Field f:I\n 4: ireturn\n\n public final MaxFlowDinic$Edge copy(int, int, int, int);\n Code:\n 0: new #2 // class MaxFlowDinic$Edge\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: iload_3\n 7: iload 4\n 9: invokespecial #27 // Method \"<init>\":(IIII)V\n 12: areturn\n\n public static MaxFlowDinic$Edge copy$default(MaxFlowDinic$Edge, 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 t: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 rev: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 cap: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 f: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 #46 // Method copy:(IIII)LMaxFlowDinic$Edge;\n 59: 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 Edge(t=\n 9: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field t:I\n 16: invokevirtual #60 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #62 // String , rev=\n 21: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #16 // Field rev:I\n 28: invokevirtual #60 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #64 // String , cap=\n 33: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #19 // Field cap:I\n 40: invokevirtual #60 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 43: ldc #66 // String , f=\n 45: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: aload_0\n 49: getfield #22 // Field f:I\n 52: invokevirtual #60 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 55: bipush 41\n 57: invokevirtual #69 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 60: invokevirtual #71 // 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 t:I\n 4: invokestatic #77 // 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 rev:I\n 16: invokestatic #77 // 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 cap:I\n 29: invokestatic #77 // 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 f:I\n 42: invokestatic #77 // 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 MaxFlowDinic$Edge\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class MaxFlowDinic$Edge\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field t:I\n 25: aload_2\n 26: getfield #13 // Field t:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field rev:I\n 38: aload_2\n 39: getfield #16 // Field rev:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: aload_0\n 48: getfield #19 // Field cap:I\n 51: aload_2\n 52: getfield #19 // Field cap:I\n 55: if_icmpeq 60\n 58: iconst_0\n 59: ireturn\n 60: aload_0\n 61: getfield #22 // Field f:I\n 64: aload_2\n 65: getfield #22 // Field f: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": "dirask__codelibrary__75f5296/MaxFlowDinic.class",
"javap": "Compiled from \"MaxFlowDinic.kt\"\npublic final class MaxFlowDinic {\n public static final MaxFlowDinic INSTANCE;\n\n private MaxFlowDinic();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final void addEdge(java.util.ArrayList<MaxFlowDinic$Edge>[], int, int, int);\n Code:\n 0: aload_1\n 1: ldc #16 // String graph\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: iload_2\n 8: aaload\n 9: new #24 // class MaxFlowDinic$Edge\n 12: dup\n 13: iload_3\n 14: aload_1\n 15: iload_3\n 16: aaload\n 17: invokevirtual #30 // Method java/util/ArrayList.size:()I\n 20: iload 4\n 22: iconst_0\n 23: bipush 8\n 25: aconst_null\n 26: invokespecial #33 // Method MaxFlowDinic$Edge.\"<init>\":(IIIIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 29: invokevirtual #37 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 32: pop\n 33: aload_1\n 34: iload_3\n 35: aaload\n 36: new #24 // class MaxFlowDinic$Edge\n 39: dup\n 40: iload_2\n 41: aload_1\n 42: iload_2\n 43: aaload\n 44: invokevirtual #30 // Method java/util/ArrayList.size:()I\n 47: iconst_1\n 48: isub\n 49: iconst_0\n 50: iconst_0\n 51: bipush 8\n 53: aconst_null\n 54: invokespecial #33 // Method MaxFlowDinic$Edge.\"<init>\":(IIIIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 57: invokevirtual #37 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 60: pop\n 61: return\n\n public final boolean dinicBfs(java.util.List<MaxFlowDinic$Edge>[], int, int, int[]);\n Code:\n 0: aload_1\n 1: ldc #16 // String graph\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload 4\n 8: ldc #47 // String dist\n 10: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 13: aload 4\n 15: iconst_m1\n 16: iconst_0\n 17: iconst_0\n 18: bipush 6\n 20: aconst_null\n 21: invokestatic #53 // Method kotlin/collections/ArraysKt.fill$default:([IIIIILjava/lang/Object;)V\n 24: aload 4\n 26: iload_2\n 27: iconst_0\n 28: iastore\n 29: aload_1\n 30: arraylength\n 31: newarray int\n 33: astore 5\n 35: iconst_0\n 36: istore 6\n 38: aload 5\n 40: iload 6\n 42: iinc 6, 1\n 45: iload_2\n 46: iastore\n 47: iconst_0\n 48: istore 7\n 50: iload 7\n 52: iload 6\n 54: if_icmpge 155\n 57: aload 5\n 59: iload 7\n 61: iinc 7, 1\n 64: iaload\n 65: istore 8\n 67: aload_1\n 68: iload 8\n 70: aaload\n 71: invokeinterface #59, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 76: astore 9\n 78: aload 9\n 80: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 85: ifeq 50\n 88: aload 9\n 90: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 95: checkcast #24 // class MaxFlowDinic$Edge\n 98: astore 10\n 100: aload 4\n 102: aload 10\n 104: invokevirtual #72 // Method MaxFlowDinic$Edge.getT:()I\n 107: iaload\n 108: ifge 78\n 111: aload 10\n 113: invokevirtual #75 // Method MaxFlowDinic$Edge.getF:()I\n 116: aload 10\n 118: invokevirtual #78 // Method MaxFlowDinic$Edge.getCap:()I\n 121: if_icmpge 78\n 124: aload 4\n 126: aload 10\n 128: invokevirtual #72 // Method MaxFlowDinic$Edge.getT:()I\n 131: aload 4\n 133: iload 8\n 135: iaload\n 136: iconst_1\n 137: iadd\n 138: iastore\n 139: aload 5\n 141: iload 6\n 143: iinc 6, 1\n 146: aload 10\n 148: invokevirtual #72 // Method MaxFlowDinic$Edge.getT:()I\n 151: iastore\n 152: goto 78\n 155: aload 4\n 157: iload_3\n 158: iaload\n 159: iflt 166\n 162: iconst_1\n 163: goto 167\n 166: iconst_0\n 167: ireturn\n\n public final int dinicDfs(java.util.List<MaxFlowDinic$Edge>[], int[], int[], int, int, int);\n Code:\n 0: aload_1\n 1: ldc #16 // String graph\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #94 // String ptr\n 9: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_3\n 13: ldc #47 // String dist\n 15: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: iload 5\n 20: iload 4\n 22: if_icmpne 28\n 25: iload 6\n 27: ireturn\n 28: aload_2\n 29: iload 5\n 31: iaload\n 32: aload_1\n 33: iload 5\n 35: aaload\n 36: invokeinterface #95, 1 // InterfaceMethod java/util/List.size:()I\n 41: if_icmpge 197\n 44: aload_1\n 45: iload 5\n 47: aaload\n 48: aload_2\n 49: iload 5\n 51: iaload\n 52: invokeinterface #99, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 57: checkcast #24 // class MaxFlowDinic$Edge\n 60: astore 7\n 62: aload_3\n 63: aload 7\n 65: invokevirtual #72 // Method MaxFlowDinic$Edge.getT:()I\n 68: iaload\n 69: aload_3\n 70: iload 5\n 72: iaload\n 73: iconst_1\n 74: iadd\n 75: if_icmpne 179\n 78: aload 7\n 80: invokevirtual #75 // Method MaxFlowDinic$Edge.getF:()I\n 83: aload 7\n 85: invokevirtual #78 // Method MaxFlowDinic$Edge.getCap:()I\n 88: if_icmpge 179\n 91: aload_0\n 92: aload_1\n 93: aload_2\n 94: aload_3\n 95: iload 4\n 97: aload 7\n 99: invokevirtual #72 // Method MaxFlowDinic$Edge.getT:()I\n 102: iload 6\n 104: aload 7\n 106: invokevirtual #78 // Method MaxFlowDinic$Edge.getCap:()I\n 109: aload 7\n 111: invokevirtual #75 // Method MaxFlowDinic$Edge.getF:()I\n 114: isub\n 115: invokestatic #105 // Method java/lang/Math.min:(II)I\n 118: invokevirtual #107 // Method dinicDfs:([Ljava/util/List;[I[IIII)I\n 121: istore 8\n 123: iload 8\n 125: ifle 179\n 128: aload 7\n 130: aload 7\n 132: invokevirtual #75 // Method MaxFlowDinic$Edge.getF:()I\n 135: iload 8\n 137: iadd\n 138: invokevirtual #111 // Method MaxFlowDinic$Edge.setF:(I)V\n 141: aload_1\n 142: aload 7\n 144: invokevirtual #72 // Method MaxFlowDinic$Edge.getT:()I\n 147: aaload\n 148: aload 7\n 150: invokevirtual #114 // Method MaxFlowDinic$Edge.getRev:()I\n 153: invokeinterface #99, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 158: checkcast #24 // class MaxFlowDinic$Edge\n 161: astore 9\n 163: aload 9\n 165: aload 9\n 167: invokevirtual #75 // Method MaxFlowDinic$Edge.getF:()I\n 170: iload 8\n 172: isub\n 173: invokevirtual #111 // Method MaxFlowDinic$Edge.setF:(I)V\n 176: iload 8\n 178: ireturn\n 179: aload_2\n 180: iload 5\n 182: aload_2\n 183: iload 5\n 185: iaload\n 186: iconst_1\n 187: iadd\n 188: iastore\n 189: aload_2\n 190: iload 5\n 192: iaload\n 193: pop\n 194: goto 28\n 197: iconst_0\n 198: ireturn\n\n public final int maxFlow(java.util.List<MaxFlowDinic$Edge>[], int, int);\n Code:\n 0: aload_1\n 1: ldc #16 // String graph\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore 4\n 9: aload_1\n 10: arraylength\n 11: newarray int\n 13: astore 5\n 15: aload_0\n 16: aload_1\n 17: iload_2\n 18: iload_3\n 19: aload 5\n 21: invokevirtual #121 // Method dinicBfs:([Ljava/util/List;II[I)Z\n 24: ifeq 67\n 27: aload_1\n 28: arraylength\n 29: newarray int\n 31: astore 6\n 33: nop\n 34: aload_0\n 35: aload_1\n 36: aload 6\n 38: aload 5\n 40: iload_3\n 41: iload_2\n 42: ldc #122 // int 2147483647\n 44: invokevirtual #107 // Method dinicDfs:([Ljava/util/List;[I[IIII)I\n 47: istore 7\n 49: iload 7\n 51: ifne 57\n 54: goto 15\n 57: iload 4\n 59: iload 7\n 61: iadd\n 62: istore 4\n 64: goto 33\n 67: iload 4\n 69: ireturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #128 // String args\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #130 // class kotlin/ranges/IntRange\n 9: dup\n 10: iconst_1\n 11: iconst_3\n 12: invokespecial #133 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 15: checkcast #135 // class java/lang/Iterable\n 18: astore_2\n 19: iconst_0\n 20: istore_3\n 21: aload_2\n 22: astore 4\n 24: new #26 // class java/util/ArrayList\n 27: dup\n 28: aload_2\n 29: bipush 10\n 31: invokestatic #141 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 34: invokespecial #143 // Method java/util/ArrayList.\"<init>\":(I)V\n 37: checkcast #145 // class java/util/Collection\n 40: astore 5\n 42: iconst_0\n 43: istore 6\n 45: aload 4\n 47: invokeinterface #146, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 52: astore 7\n 54: aload 7\n 56: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 61: ifeq 105\n 64: aload 7\n 66: checkcast #148 // class kotlin/collections/IntIterator\n 69: invokevirtual #151 // Method kotlin/collections/IntIterator.nextInt:()I\n 72: istore 8\n 74: aload 5\n 76: iload 8\n 78: istore 9\n 80: astore 11\n 82: iconst_0\n 83: istore 10\n 85: new #26 // class java/util/ArrayList\n 88: dup\n 89: invokespecial #152 // Method java/util/ArrayList.\"<init>\":()V\n 92: nop\n 93: aload 11\n 95: swap\n 96: invokeinterface #153, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 101: pop\n 102: goto 54\n 105: aload 5\n 107: checkcast #55 // class java/util/List\n 110: nop\n 111: checkcast #145 // class java/util/Collection\n 114: astore_2\n 115: nop\n 116: iconst_0\n 117: istore_3\n 118: aload_2\n 119: astore 4\n 121: aload 4\n 123: iconst_0\n 124: anewarray #26 // class java/util/ArrayList\n 127: invokeinterface #157, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 132: checkcast #158 // class \"[Ljava/util/ArrayList;\"\n 135: astore_1\n 136: getstatic #161 // Field INSTANCE:LMaxFlowDinic;\n 139: aload_1\n 140: iconst_0\n 141: iconst_1\n 142: iconst_3\n 143: invokevirtual #163 // Method addEdge:([Ljava/util/ArrayList;III)V\n 146: getstatic #161 // Field INSTANCE:LMaxFlowDinic;\n 149: aload_1\n 150: iconst_0\n 151: iconst_2\n 152: iconst_2\n 153: invokevirtual #163 // Method addEdge:([Ljava/util/ArrayList;III)V\n 156: getstatic #161 // Field INSTANCE:LMaxFlowDinic;\n 159: aload_1\n 160: iconst_1\n 161: iconst_2\n 162: iconst_2\n 163: invokevirtual #163 // Method addEdge:([Ljava/util/ArrayList;III)V\n 166: getstatic #161 // Field INSTANCE:LMaxFlowDinic;\n 169: aload_1\n 170: checkcast #164 // class \"[Ljava/util/List;\"\n 173: iconst_0\n 174: iconst_2\n 175: invokevirtual #166 // Method maxFlow:([Ljava/util/List;II)I\n 178: istore_2\n 179: iconst_4\n 180: iload_2\n 181: if_icmpne 188\n 184: iconst_1\n 185: goto 189\n 188: iconst_0\n 189: istore_3\n 190: getstatic #172 // Field java/lang/System.out:Ljava/io/PrintStream;\n 193: iload_3\n 194: invokevirtual #178 // Method java/io/PrintStream.println:(Z)V\n 197: return\n\n static {};\n Code:\n 0: new #2 // class MaxFlowDinic\n 3: dup\n 4: invokespecial #195 // Method \"<init>\":()V\n 7: putstatic #161 // Field INSTANCE:LMaxFlowDinic;\n 10: return\n}\n",
"javap_err": ""
}
] |
dirask__codelibrary__75f5296/kotlin/Determinant.kt
|
// https://en.wikipedia.org/wiki/Determinant
fun det(matrix: Array<DoubleArray>): Double {
val EPS = 1e-10
val a = matrix.map { it.copyOf() }.toTypedArray()
val n = a.size
var res = 1.0
for (i in 0 until n) {
val p = (i until n).maxBy { Math.abs(a[it][i]) }!!
if (Math.abs(a[p][i]) < EPS)
return 0.0
if (i != p) {
res = -res
a[i] = a[p].also { a[p] = a[i] }
}
res *= a[i][i]
for (j in i + 1 until n)
a[i][j] /= a[i][i]
for (j in 0 until n)
if (j != i && Math.abs(a[j][i]) > EPS /*optimizes overall complexity to O(n^2) for sparse matrices*/)
for (k in i + 1 until n)
a[j][k] -= a[i][k] * a[j][i]
}
return res
}
// Usage example
fun main() {
val d = det(arrayOf(doubleArrayOf(0.0, 1.0), doubleArrayOf(-1.0, 0.0)))
println(Math.abs(d - 1) < 1e-10)
}
|
[
{
"class_path": "dirask__codelibrary__75f5296/DeterminantKt.class",
"javap": "Compiled from \"Determinant.kt\"\npublic final class DeterminantKt {\n public static final double det(double[][]);\n Code:\n 0: aload_0\n 1: ldc #9 // String matrix\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc2_w #16 // double 1.0E-10d\n 9: dstore_1\n 10: aload_0\n 11: checkcast #19 // class \"[Ljava/lang/Object;\"\n 14: astore 4\n 16: iconst_0\n 17: istore 5\n 19: aload 4\n 21: astore 6\n 23: new #21 // class java/util/ArrayList\n 26: dup\n 27: aload 4\n 29: arraylength\n 30: invokespecial #25 // Method java/util/ArrayList.\"<init>\":(I)V\n 33: checkcast #27 // class java/util/Collection\n 36: astore 7\n 38: iconst_0\n 39: istore 8\n 41: iconst_0\n 42: istore 9\n 44: aload 6\n 46: arraylength\n 47: istore 10\n 49: iload 9\n 51: iload 10\n 53: if_icmpge 106\n 56: aload 6\n 58: iload 9\n 60: aaload\n 61: astore 11\n 63: aload 7\n 65: aload 11\n 67: checkcast #29 // class \"[D\"\n 70: astore 12\n 72: astore 19\n 74: iconst_0\n 75: istore 13\n 77: aload 12\n 79: dup\n 80: arraylength\n 81: invokestatic #35 // Method java/util/Arrays.copyOf:([DI)[D\n 84: dup\n 85: ldc #37 // String copyOf(...)\n 87: invokestatic #40 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 90: nop\n 91: aload 19\n 93: swap\n 94: invokeinterface #44, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 99: pop\n 100: iinc 9, 1\n 103: goto 49\n 106: aload 7\n 108: checkcast #46 // class java/util/List\n 111: nop\n 112: checkcast #27 // class java/util/Collection\n 115: astore 4\n 117: nop\n 118: iconst_0\n 119: istore 5\n 121: aload 4\n 123: astore 6\n 125: aload 6\n 127: iconst_0\n 128: anewarray #29 // class \"[D\"\n 131: invokeinterface #50, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 136: checkcast #52 // class \"[[D\"\n 139: astore_3\n 140: aload_3\n 141: checkcast #19 // class \"[Ljava/lang/Object;\"\n 144: arraylength\n 145: istore 4\n 147: dconst_1\n 148: dstore 5\n 150: iconst_0\n 151: istore 7\n 153: iload 7\n 155: iload 4\n 157: if_icmpge 534\n 160: iload 7\n 162: iload 4\n 164: invokestatic #58 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 167: checkcast #60 // class java/lang/Iterable\n 170: astore 9\n 172: iconst_0\n 173: istore 10\n 175: aload 9\n 177: invokeinterface #64, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 182: astore 11\n 184: aload 11\n 186: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 191: ifne 202\n 194: new #72 // class java/util/NoSuchElementException\n 197: dup\n 198: invokespecial #75 // Method java/util/NoSuchElementException.\"<init>\":()V\n 201: athrow\n 202: aload 11\n 204: checkcast #77 // class kotlin/collections/IntIterator\n 207: invokevirtual #81 // Method kotlin/collections/IntIterator.nextInt:()I\n 210: istore 12\n 212: aload 11\n 214: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 219: ifne 227\n 222: iload 12\n 224: goto 305\n 227: iload 12\n 229: istore 13\n 231: iconst_0\n 232: istore 15\n 234: aload_3\n 235: iload 13\n 237: aaload\n 238: iload 7\n 240: daload\n 241: invokestatic #87 // Method java/lang/Math.abs:(D)D\n 244: dstore 13\n 246: aload 11\n 248: checkcast #77 // class kotlin/collections/IntIterator\n 251: invokevirtual #81 // Method kotlin/collections/IntIterator.nextInt:()I\n 254: istore 15\n 256: iload 15\n 258: istore 16\n 260: iconst_0\n 261: istore 18\n 263: aload_3\n 264: iload 16\n 266: aaload\n 267: iload 7\n 269: daload\n 270: invokestatic #87 // Method java/lang/Math.abs:(D)D\n 273: dstore 16\n 275: dload 13\n 277: dload 16\n 279: invokestatic #93 // Method java/lang/Double.compare:(DD)I\n 282: ifge 293\n 285: iload 15\n 287: istore 12\n 289: dload 16\n 291: dstore 13\n 293: aload 11\n 295: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 300: ifne 246\n 303: iload 12\n 305: istore 8\n 307: aload_3\n 308: iload 8\n 310: aaload\n 311: iload 7\n 313: daload\n 314: invokestatic #87 // Method java/lang/Math.abs:(D)D\n 317: dload_1\n 318: dcmpg\n 319: ifge 324\n 322: dconst_0\n 323: dreturn\n 324: iload 7\n 326: iload 8\n 328: if_icmpeq 376\n 331: dload 5\n 333: dneg\n 334: dstore 5\n 336: aload_3\n 337: iload 7\n 339: aload_3\n 340: iload 8\n 342: aaload\n 343: astore 9\n 345: aload 9\n 347: astore 10\n 349: istore 20\n 351: astore 19\n 353: iconst_0\n 354: istore 11\n 356: aload_3\n 357: iload 8\n 359: aload_3\n 360: iload 7\n 362: aaload\n 363: aastore\n 364: getstatic #99 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 367: astore 21\n 369: aload 19\n 371: iload 20\n 373: aload 9\n 375: aastore\n 376: dload 5\n 378: aload_3\n 379: iload 7\n 381: aaload\n 382: iload 7\n 384: daload\n 385: dmul\n 386: dstore 5\n 388: iload 7\n 390: iconst_1\n 391: iadd\n 392: istore 9\n 394: iload 9\n 396: iload 4\n 398: if_icmpge 435\n 401: aload_3\n 402: iload 7\n 404: aaload\n 405: astore 10\n 407: iload 9\n 409: istore 11\n 411: aload 10\n 413: iload 11\n 415: aload 10\n 417: iload 11\n 419: daload\n 420: aload_3\n 421: iload 7\n 423: aaload\n 424: iload 7\n 426: daload\n 427: ddiv\n 428: dastore\n 429: iinc 9, 1\n 432: goto 394\n 435: iconst_0\n 436: istore 9\n 438: iload 9\n 440: iload 4\n 442: if_icmpge 528\n 445: iload 9\n 447: iload 7\n 449: if_icmpeq 522\n 452: aload_3\n 453: iload 9\n 455: aaload\n 456: iload 7\n 458: daload\n 459: invokestatic #87 // Method java/lang/Math.abs:(D)D\n 462: dload_1\n 463: dcmpl\n 464: ifle 522\n 467: iload 7\n 469: iconst_1\n 470: iadd\n 471: istore 10\n 473: iload 10\n 475: iload 4\n 477: if_icmpge 522\n 480: aload_3\n 481: iload 9\n 483: aaload\n 484: astore 11\n 486: iload 10\n 488: istore 12\n 490: aload 11\n 492: iload 12\n 494: aload 11\n 496: iload 12\n 498: daload\n 499: aload_3\n 500: iload 7\n 502: aaload\n 503: iload 10\n 505: daload\n 506: aload_3\n 507: iload 9\n 509: aaload\n 510: iload 7\n 512: daload\n 513: dmul\n 514: dsub\n 515: dastore\n 516: iinc 10, 1\n 519: goto 473\n 522: iinc 9, 1\n 525: goto 438\n 528: iinc 7, 1\n 531: goto 153\n 534: dload 5\n 536: dreturn\n\n public static final void main();\n Code:\n 0: iconst_2\n 1: anewarray #29 // class \"[D\"\n 4: astore_2\n 5: aload_2\n 6: iconst_0\n 7: iconst_2\n 8: newarray double\n 10: astore_3\n 11: aload_3\n 12: iconst_0\n 13: dconst_0\n 14: dastore\n 15: aload_3\n 16: iconst_1\n 17: dconst_1\n 18: dastore\n 19: aload_3\n 20: aastore\n 21: aload_2\n 22: iconst_1\n 23: iconst_2\n 24: newarray double\n 26: astore_3\n 27: aload_3\n 28: iconst_0\n 29: ldc2_w #135 // double -1.0d\n 32: dastore\n 33: aload_3\n 34: iconst_1\n 35: dconst_0\n 36: dastore\n 37: aload_3\n 38: aastore\n 39: aload_2\n 40: invokestatic #138 // Method det:([[D)D\n 43: dstore_0\n 44: dload_0\n 45: iconst_1\n 46: i2d\n 47: dsub\n 48: invokestatic #87 // Method java/lang/Math.abs:(D)D\n 51: ldc2_w #16 // double 1.0E-10d\n 54: dcmpg\n 55: ifge 62\n 58: iconst_1\n 59: goto 63\n 62: iconst_0\n 63: istore_2\n 64: getstatic #144 // Field java/lang/System.out:Ljava/io/PrintStream;\n 67: iload_2\n 68: invokevirtual #150 // Method java/io/PrintStream.println:(Z)V\n 71: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #154 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
akkinoc__atcoder-workspace__e650a9c/atcoder.jp/abc264/abc264_c/Main.kt
|
fun main() {
val (h1, w1) = readLine()!!.split(" ").map { it.toInt() }
val a = List(h1) { readLine()!!.split(" ") }
val (h2, w2) = readLine()!!.split(" ").map { it.toInt() }
val b = List(h2) { readLine()!!.split(" ") }
for (r in (0 until h1).combinations(h1 - h2)) {
val w = a.filterIndexed { i, _ -> i !in r }
for (c in (0 until w1).combinations(w1 - w2))
if (w.map { it.filterIndexed { i, _ -> i !in c } } == b) return print("Yes")
}
print("No")
}
fun <T> Iterable<T>.combinations(r: Int): Sequence<List<T>> = sequence {
if (r < 1) yield(emptyList())
else forEachIndexed { i, e -> drop(i + 1).combinations(r - 1).forEach { yield(listOf(e) + it) } }
}
|
[
{
"class_path": "akkinoc__atcoder-workspace__e650a9c/MainKt$combinations$1.class",
"javap": "Compiled from \"Main.kt\"\nfinal class MainKt$combinations$1 extends kotlin.coroutines.jvm.internal.RestrictedSuspendLambda implements kotlin.jvm.functions.Function2<kotlin.sequences.SequenceScope<? super java.util.List<? extends T>>, kotlin.coroutines.Continuation<? super kotlin.Unit>, java.lang.Object> {\n java.lang.Object L$1;\n\n java.lang.Object L$2;\n\n java.lang.Object L$3;\n\n java.lang.Object L$4;\n\n int I$0;\n\n int I$1;\n\n int label;\n\n private java.lang.Object L$0;\n\n final int $r;\n\n final java.lang.Iterable<T> $this_combinations;\n\n MainKt$combinations$1(int, java.lang.Iterable<? extends T>, kotlin.coroutines.Continuation<? super MainKt$combinations$1>);\n Code:\n 0: aload_0\n 1: iload_1\n 2: putfield #14 // Field $r:I\n 5: aload_0\n 6: aload_2\n 7: putfield #18 // Field $this_combinations:Ljava/lang/Iterable;\n 10: aload_0\n 11: iconst_2\n 12: aload_3\n 13: invokespecial #21 // Method kotlin/coroutines/jvm/internal/RestrictedSuspendLambda.\"<init>\":(ILkotlin/coroutines/Continuation;)V\n 16: return\n\n public final java.lang.Object invokeSuspend(java.lang.Object);\n Code:\n 0: invokestatic #57 // Method kotlin/coroutines/intrinsics/IntrinsicsKt.getCOROUTINE_SUSPENDED:()Ljava/lang/Object;\n 3: astore 20\n 5: aload_0\n 6: getfield #60 // Field label:I\n 9: tableswitch { // 0 to 2\n 0: 36\n 1: 81\n 2: 304\n default: 388\n }\n 36: aload_1\n 37: invokestatic #66 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V\n 40: aload_0\n 41: getfield #68 // Field L$0:Ljava/lang/Object;\n 44: checkcast #70 // class kotlin/sequences/SequenceScope\n 47: astore_2\n 48: aload_0\n 49: getfield #14 // Field $r:I\n 52: iconst_1\n 53: if_icmpge 90\n 56: aload_2\n 57: invokestatic #76 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 60: aload_0\n 61: checkcast #78 // class kotlin/coroutines/Continuation\n 64: aload_0\n 65: iconst_1\n 66: putfield #60 // Field label:I\n 69: invokevirtual #82 // Method kotlin/sequences/SequenceScope.yield:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;\n 72: dup\n 73: aload 20\n 75: if_acmpne 86\n 78: aload 20\n 80: areturn\n 81: aload_1\n 82: invokestatic #66 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V\n 85: aload_1\n 86: pop\n 87: goto 384\n 90: aload_0\n 91: getfield #18 // Field $this_combinations:Ljava/lang/Iterable;\n 94: astore_3\n 95: aload_0\n 96: getfield #18 // Field $this_combinations:Ljava/lang/Iterable;\n 99: astore 4\n 101: aload_0\n 102: getfield #14 // Field $r:I\n 105: istore 5\n 107: iconst_0\n 108: istore 6\n 110: iconst_0\n 111: istore 7\n 113: aload_3\n 114: invokeinterface #88, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 119: astore 8\n 121: aload 8\n 123: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 128: ifeq 383\n 131: aload 8\n 133: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 138: astore 9\n 140: iload 7\n 142: iinc 7, 1\n 145: istore 10\n 147: iload 10\n 149: ifge 155\n 152: invokestatic #101 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 155: iload 10\n 157: aload 9\n 159: astore 11\n 161: istore 12\n 163: iconst_0\n 164: istore 13\n 166: aload 4\n 168: iload 12\n 170: iconst_1\n 171: iadd\n 172: invokestatic #105 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 175: checkcast #84 // class java/lang/Iterable\n 178: iload 5\n 180: iconst_1\n 181: isub\n 182: invokestatic #111 // Method MainKt.combinations:(Ljava/lang/Iterable;I)Lkotlin/sequences/Sequence;\n 185: astore 14\n 187: iconst_0\n 188: istore 15\n 190: aload 14\n 192: invokeinterface #114, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 197: astore 16\n 199: aload 16\n 201: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 206: ifeq 378\n 209: aload 16\n 211: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 216: astore 17\n 218: aload 17\n 220: checkcast #116 // class java/util/List\n 223: astore 18\n 225: iconst_0\n 226: istore 19\n 228: aload_2\n 229: aload 11\n 231: invokestatic #120 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 234: checkcast #122 // class java/util/Collection\n 237: aload 18\n 239: checkcast #84 // class java/lang/Iterable\n 242: invokestatic #126 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 245: aload_0\n 246: aload_0\n 247: aload_2\n 248: putfield #68 // Field L$0:Ljava/lang/Object;\n 251: aload_0\n 252: aload 4\n 254: putfield #128 // Field L$1:Ljava/lang/Object;\n 257: aload_0\n 258: aload 8\n 260: putfield #130 // Field L$2:Ljava/lang/Object;\n 263: aload_0\n 264: aload 11\n 266: putfield #132 // Field L$3:Ljava/lang/Object;\n 269: aload_0\n 270: aload 16\n 272: putfield #134 // Field L$4:Ljava/lang/Object;\n 275: aload_0\n 276: iload 5\n 278: putfield #136 // Field I$0:I\n 281: aload_0\n 282: iload 7\n 284: putfield #138 // Field I$1:I\n 287: aload_0\n 288: iconst_2\n 289: putfield #60 // Field label:I\n 292: invokevirtual #82 // Method kotlin/sequences/SequenceScope.yield:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;\n 295: dup\n 296: aload 20\n 298: if_acmpne 374\n 301: aload 20\n 303: areturn\n 304: iconst_0\n 305: istore 6\n 307: iconst_0\n 308: istore 13\n 310: iconst_0\n 311: istore 15\n 313: iconst_0\n 314: istore 19\n 316: aload_0\n 317: getfield #138 // Field I$1:I\n 320: istore 7\n 322: aload_0\n 323: getfield #136 // Field I$0:I\n 326: istore 5\n 328: aload_0\n 329: getfield #134 // Field L$4:Ljava/lang/Object;\n 332: checkcast #90 // class java/util/Iterator\n 335: astore 16\n 337: aload_0\n 338: getfield #132 // Field L$3:Ljava/lang/Object;\n 341: astore 11\n 343: aload_0\n 344: getfield #130 // Field L$2:Ljava/lang/Object;\n 347: checkcast #90 // class java/util/Iterator\n 350: astore 8\n 352: aload_0\n 353: getfield #128 // Field L$1:Ljava/lang/Object;\n 356: checkcast #84 // class java/lang/Iterable\n 359: astore 4\n 361: aload_0\n 362: getfield #68 // Field L$0:Ljava/lang/Object;\n 365: checkcast #70 // class kotlin/sequences/SequenceScope\n 368: astore_2\n 369: aload_1\n 370: invokestatic #66 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V\n 373: aload_1\n 374: pop\n 375: goto 199\n 378: nop\n 379: nop\n 380: goto 121\n 383: nop\n 384: getstatic #144 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 387: areturn\n 388: new #146 // class java/lang/IllegalStateException\n 391: dup\n 392: ldc #148 // String call to \\'resume\\' before \\'invoke\\' with coroutine\n 394: invokespecial #151 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 397: athrow\n\n public final kotlin.coroutines.Continuation<kotlin.Unit> create(java.lang.Object, kotlin.coroutines.Continuation<?>);\n Code:\n 0: new #2 // class MainKt$combinations$1\n 3: dup\n 4: aload_0\n 5: getfield #14 // Field $r:I\n 8: aload_0\n 9: getfield #18 // Field $this_combinations:Ljava/lang/Iterable;\n 12: aload_2\n 13: invokespecial #171 // Method \"<init>\":(ILjava/lang/Iterable;Lkotlin/coroutines/Continuation;)V\n 16: astore_3\n 17: aload_3\n 18: aload_1\n 19: putfield #68 // Field L$0:Ljava/lang/Object;\n 22: aload_3\n 23: checkcast #78 // class kotlin/coroutines/Continuation\n 26: areturn\n\n public final java.lang.Object invoke(kotlin.sequences.SequenceScope<? super java.util.List<? extends T>>, kotlin.coroutines.Continuation<? super kotlin.Unit>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: aload_2\n 3: invokevirtual #177 // Method create:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Lkotlin/coroutines/Continuation;\n 6: checkcast #2 // class MainKt$combinations$1\n 9: getstatic #144 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 12: invokevirtual #179 // Method invokeSuspend:(Ljava/lang/Object;)Ljava/lang/Object;\n 15: areturn\n\n public java.lang.Object invoke(java.lang.Object, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #70 // class kotlin/sequences/SequenceScope\n 5: aload_2\n 6: checkcast #78 // class kotlin/coroutines/Continuation\n 9: invokevirtual #184 // Method invoke:(Lkotlin/sequences/SequenceScope;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;\n 12: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "akkinoc__atcoder-workspace__e650a9c/MainKt.class",
"javap": "Compiled from \"Main.kt\"\npublic final class MainKt {\n public static final void main();\n Code:\n 0: invokestatic #12 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 3: dup\n 4: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 7: checkcast #20 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #22 // class java/lang/String\n 14: astore_1\n 15: aload_1\n 16: iconst_0\n 17: ldc #24 // String\n 19: aastore\n 20: aload_1\n 21: iconst_0\n 22: iconst_0\n 23: bipush 6\n 25: aconst_null\n 26: invokestatic #30 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: checkcast #32 // class java/lang/Iterable\n 32: astore_1\n 33: iconst_0\n 34: istore_2\n 35: aload_1\n 36: astore_3\n 37: new #34 // class java/util/ArrayList\n 40: dup\n 41: aload_1\n 42: bipush 10\n 44: invokestatic #40 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 47: invokespecial #44 // Method java/util/ArrayList.\"<init>\":(I)V\n 50: checkcast #46 // class java/util/Collection\n 53: astore 4\n 55: iconst_0\n 56: istore 5\n 58: aload_3\n 59: invokeinterface #50, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 64: astore 6\n 66: aload 6\n 68: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 73: ifeq 120\n 76: aload 6\n 78: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 83: astore 7\n 85: aload 4\n 87: aload 7\n 89: checkcast #22 // class java/lang/String\n 92: astore 8\n 94: astore 38\n 96: iconst_0\n 97: istore 9\n 99: aload 8\n 101: invokestatic #66 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 104: nop\n 105: invokestatic #70 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 108: aload 38\n 110: swap\n 111: invokeinterface #74, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 116: pop\n 117: goto 66\n 120: aload 4\n 122: checkcast #76 // class java/util/List\n 125: nop\n 126: astore_0\n 127: aload_0\n 128: iconst_0\n 129: invokeinterface #80, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 134: checkcast #82 // class java/lang/Number\n 137: invokevirtual #86 // Method java/lang/Number.intValue:()I\n 140: istore_1\n 141: aload_0\n 142: iconst_1\n 143: invokeinterface #80, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 148: checkcast #82 // class java/lang/Number\n 151: invokevirtual #86 // Method java/lang/Number.intValue:()I\n 154: istore_2\n 155: new #34 // class java/util/ArrayList\n 158: dup\n 159: iload_1\n 160: invokespecial #44 // Method java/util/ArrayList.\"<init>\":(I)V\n 163: astore 4\n 165: iconst_0\n 166: istore 5\n 168: iload 5\n 170: iload_1\n 171: if_icmpge 234\n 174: iload 5\n 176: istore 6\n 178: aload 4\n 180: iload 6\n 182: istore 7\n 184: astore 38\n 186: iconst_0\n 187: istore 8\n 189: invokestatic #12 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 192: dup\n 193: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 196: checkcast #20 // class java/lang/CharSequence\n 199: iconst_1\n 200: anewarray #22 // class java/lang/String\n 203: astore 9\n 205: aload 9\n 207: iconst_0\n 208: ldc #24 // String\n 210: aastore\n 211: aload 9\n 213: iconst_0\n 214: iconst_0\n 215: bipush 6\n 217: aconst_null\n 218: invokestatic #30 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 221: aload 38\n 223: swap\n 224: invokevirtual #87 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 227: pop\n 228: iinc 5, 1\n 231: goto 168\n 234: aload 4\n 236: checkcast #76 // class java/util/List\n 239: astore_3\n 240: invokestatic #12 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 243: dup\n 244: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 247: checkcast #20 // class java/lang/CharSequence\n 250: iconst_1\n 251: anewarray #22 // class java/lang/String\n 254: astore 5\n 256: aload 5\n 258: iconst_0\n 259: ldc #24 // String\n 261: aastore\n 262: aload 5\n 264: iconst_0\n 265: iconst_0\n 266: bipush 6\n 268: aconst_null\n 269: invokestatic #30 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 272: checkcast #32 // class java/lang/Iterable\n 275: astore 5\n 277: iconst_0\n 278: istore 6\n 280: aload 5\n 282: astore 7\n 284: new #34 // class java/util/ArrayList\n 287: dup\n 288: aload 5\n 290: bipush 10\n 292: invokestatic #40 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 295: invokespecial #44 // Method java/util/ArrayList.\"<init>\":(I)V\n 298: checkcast #46 // class java/util/Collection\n 301: astore 8\n 303: iconst_0\n 304: istore 9\n 306: aload 7\n 308: invokeinterface #50, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 313: astore 10\n 315: aload 10\n 317: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 322: ifeq 369\n 325: aload 10\n 327: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 332: astore 11\n 334: aload 8\n 336: aload 11\n 338: checkcast #22 // class java/lang/String\n 341: astore 12\n 343: astore 38\n 345: iconst_0\n 346: istore 13\n 348: aload 12\n 350: invokestatic #66 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 353: nop\n 354: invokestatic #70 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 357: aload 38\n 359: swap\n 360: invokeinterface #74, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 365: pop\n 366: goto 315\n 369: aload 8\n 371: checkcast #76 // class java/util/List\n 374: nop\n 375: astore 4\n 377: aload 4\n 379: iconst_0\n 380: invokeinterface #80, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 385: checkcast #82 // class java/lang/Number\n 388: invokevirtual #86 // Method java/lang/Number.intValue:()I\n 391: istore 5\n 393: aload 4\n 395: iconst_1\n 396: invokeinterface #80, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 401: checkcast #82 // class java/lang/Number\n 404: invokevirtual #86 // Method java/lang/Number.intValue:()I\n 407: istore 6\n 409: new #34 // class java/util/ArrayList\n 412: dup\n 413: iload 5\n 415: invokespecial #44 // Method java/util/ArrayList.\"<init>\":(I)V\n 418: astore 8\n 420: iconst_0\n 421: istore 9\n 423: iload 9\n 425: iload 5\n 427: if_icmpge 490\n 430: iload 9\n 432: istore 10\n 434: aload 8\n 436: iload 10\n 438: istore 11\n 440: astore 38\n 442: iconst_0\n 443: istore 12\n 445: invokestatic #12 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 448: dup\n 449: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 452: checkcast #20 // class java/lang/CharSequence\n 455: iconst_1\n 456: anewarray #22 // class java/lang/String\n 459: astore 13\n 461: aload 13\n 463: iconst_0\n 464: ldc #24 // String\n 466: aastore\n 467: aload 13\n 469: iconst_0\n 470: iconst_0\n 471: bipush 6\n 473: aconst_null\n 474: invokestatic #30 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 477: aload 38\n 479: swap\n 480: invokevirtual #87 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 483: pop\n 484: iinc 9, 1\n 487: goto 423\n 490: aload 8\n 492: checkcast #76 // class java/util/List\n 495: astore 7\n 497: iconst_0\n 498: iload_1\n 499: invokestatic #93 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 502: checkcast #32 // class java/lang/Iterable\n 505: iload_1\n 506: iload 5\n 508: isub\n 509: invokestatic #97 // Method combinations:(Ljava/lang/Iterable;I)Lkotlin/sequences/Sequence;\n 512: invokeinterface #100, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 517: astore 8\n 519: aload 8\n 521: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 526: ifeq 1003\n 529: aload 8\n 531: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 536: checkcast #76 // class java/util/List\n 539: astore 9\n 541: aload_3\n 542: checkcast #32 // class java/lang/Iterable\n 545: astore 11\n 547: iconst_0\n 548: istore 12\n 550: aload 11\n 552: astore 13\n 554: new #34 // class java/util/ArrayList\n 557: dup\n 558: invokespecial #102 // Method java/util/ArrayList.\"<init>\":()V\n 561: checkcast #46 // class java/util/Collection\n 564: astore 14\n 566: iconst_0\n 567: istore 15\n 569: aload 13\n 571: astore 16\n 573: iconst_0\n 574: istore 17\n 576: iconst_0\n 577: istore 18\n 579: aload 16\n 581: invokeinterface #50, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 586: astore 19\n 588: aload 19\n 590: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 595: ifeq 684\n 598: aload 19\n 600: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 605: astore 20\n 607: iload 18\n 609: iinc 18, 1\n 612: istore 21\n 614: iload 21\n 616: ifge 622\n 619: invokestatic #105 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 622: iload 21\n 624: aload 20\n 626: astore 22\n 628: istore 23\n 630: iconst_0\n 631: istore 24\n 633: iload 23\n 635: aload 22\n 637: checkcast #76 // class java/util/List\n 640: pop\n 641: istore 26\n 643: iconst_0\n 644: istore 27\n 646: aload 9\n 648: iload 26\n 650: invokestatic #70 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 653: invokeinterface #108, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 658: ifne 665\n 661: iconst_1\n 662: goto 666\n 665: iconst_0\n 666: ifeq 679\n 669: aload 14\n 671: aload 22\n 673: invokeinterface #74, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 678: pop\n 679: nop\n 680: nop\n 681: goto 588\n 684: nop\n 685: aload 14\n 687: checkcast #76 // class java/util/List\n 690: nop\n 691: astore 10\n 693: iconst_0\n 694: iload_2\n 695: invokestatic #93 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 698: checkcast #32 // class java/lang/Iterable\n 701: iload_2\n 702: iload 6\n 704: isub\n 705: invokestatic #97 // Method combinations:(Ljava/lang/Iterable;I)Lkotlin/sequences/Sequence;\n 708: invokeinterface #100, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 713: astore 11\n 715: aload 11\n 717: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 722: ifeq 519\n 725: aload 11\n 727: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 732: checkcast #76 // class java/util/List\n 735: astore 12\n 737: aload 10\n 739: checkcast #32 // class java/lang/Iterable\n 742: astore 13\n 744: iconst_0\n 745: istore 14\n 747: aload 13\n 749: astore 15\n 751: new #34 // class java/util/ArrayList\n 754: dup\n 755: aload 13\n 757: bipush 10\n 759: invokestatic #40 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 762: invokespecial #44 // Method java/util/ArrayList.\"<init>\":(I)V\n 765: checkcast #46 // class java/util/Collection\n 768: astore 16\n 770: iconst_0\n 771: istore 17\n 773: aload 15\n 775: invokeinterface #50, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 780: astore 18\n 782: aload 18\n 784: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 789: ifeq 979\n 792: aload 18\n 794: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 799: astore 19\n 801: aload 16\n 803: aload 19\n 805: checkcast #76 // class java/util/List\n 808: astore 20\n 810: astore 38\n 812: iconst_0\n 813: istore 21\n 815: aload 20\n 817: checkcast #32 // class java/lang/Iterable\n 820: astore 22\n 822: iconst_0\n 823: istore 23\n 825: aload 22\n 827: astore 24\n 829: new #34 // class java/util/ArrayList\n 832: dup\n 833: invokespecial #102 // Method java/util/ArrayList.\"<init>\":()V\n 836: checkcast #46 // class java/util/Collection\n 839: astore 25\n 841: iconst_0\n 842: istore 26\n 844: aload 24\n 846: astore 27\n 848: iconst_0\n 849: istore 28\n 851: iconst_0\n 852: istore 29\n 854: aload 27\n 856: invokeinterface #50, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 861: astore 30\n 863: aload 30\n 865: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 870: ifeq 959\n 873: aload 30\n 875: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 880: astore 31\n 882: iload 29\n 884: iinc 29, 1\n 887: istore 32\n 889: iload 32\n 891: ifge 897\n 894: invokestatic #105 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 897: iload 32\n 899: aload 31\n 901: astore 33\n 903: istore 34\n 905: iconst_0\n 906: istore 35\n 908: iload 34\n 910: aload 33\n 912: checkcast #22 // class java/lang/String\n 915: pop\n 916: istore 36\n 918: iconst_0\n 919: istore 37\n 921: aload 12\n 923: iload 36\n 925: invokestatic #70 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 928: invokeinterface #108, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 933: ifne 940\n 936: iconst_1\n 937: goto 941\n 940: iconst_0\n 941: ifeq 954\n 944: aload 25\n 946: aload 33\n 948: invokeinterface #74, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 953: pop\n 954: nop\n 955: nop\n 956: goto 863\n 959: nop\n 960: aload 25\n 962: checkcast #76 // class java/util/List\n 965: nop\n 966: nop\n 967: aload 38\n 969: swap\n 970: invokeinterface #74, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 975: pop\n 976: goto 782\n 979: aload 16\n 981: checkcast #76 // class java/util/List\n 984: nop\n 985: aload 7\n 987: invokestatic #112 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 990: ifeq 715\n 993: ldc #114 // String Yes\n 995: getstatic #120 // Field java/lang/System.out:Ljava/io/PrintStream;\n 998: swap\n 999: invokevirtual #125 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 1002: return\n 1003: ldc #127 // String No\n 1005: getstatic #120 // Field java/lang/System.out:Ljava/io/PrintStream;\n 1008: swap\n 1009: invokevirtual #125 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 1012: return\n\n public static final <T> kotlin.sequences.Sequence<java.util.List<T>> combinations(java.lang.Iterable<? extends T>, int);\n Code:\n 0: aload_0\n 1: ldc #172 // String <this>\n 3: invokestatic #176 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #178 // class MainKt$combinations$1\n 9: dup\n 10: iload_1\n 11: aload_0\n 12: aconst_null\n 13: invokespecial #181 // Method MainKt$combinations$1.\"<init>\":(ILjava/lang/Iterable;Lkotlin/coroutines/Continuation;)V\n 16: checkcast #183 // class kotlin/jvm/functions/Function2\n 19: invokestatic #189 // Method kotlin/sequences/SequencesKt.sequence:(Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;\n 22: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #193 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
buczebar__advent-of-code__cdb6fe3/src/Day02.kt
|
fun main() {
fun gameResult(yourMove: HandShape, opponentMove: HandShape) =
when (yourMove) {
opponentMove.greater() -> GameResult.WIN
opponentMove.lower() -> GameResult.LOSS
else -> GameResult.DRAW
}
fun part1(input: List<Pair<HandShape, HandShape>>): Int {
return input.sumOf { (opponentMove, yourMove) ->
yourMove.score + gameResult(yourMove, opponentMove).score
}
}
fun getMoveForExpectedResult(opponentMove: HandShape, expectedResult: GameResult) =
when (expectedResult) {
GameResult.LOSS -> opponentMove.lower()
GameResult.DRAW -> opponentMove
GameResult.WIN -> opponentMove.greater()
}
fun part2(input: List<Pair<HandShape, GameResult>>) =
input.sumOf {
val (opponentMove, gameResult) = it
gameResult.score + getMoveForExpectedResult(opponentMove, gameResult).score
}
val testInputPart1 = parseInput("Day02_test", String::toHandShape, String::toHandShape)
check(part1(testInputPart1) == 15)
val testInputPart2 = parseInput("Day02_test", String::toHandShape, String::toGameResult)
check(part2(testInputPart2) == 12)
val inputForPart1 = parseInput("Day02", String::toHandShape, String::toHandShape)
println(part1(inputForPart1))
val inputForPart2 = parseInput("Day02", String::toHandShape, String::toGameResult)
println(part2(inputForPart2))
}
private fun <T, U> parseInput(name: String, firstArgParser: (String) -> T, secondArgParser: (String) -> U) =
readInput(name).map { round ->
round.split(" ").let {
Pair(firstArgParser.invoke(it[0]), secondArgParser.invoke(it[1]))
}
}
private fun String.toHandShape(): HandShape {
return when (this) {
"A", "X" -> HandShape.ROCK
"B", "Y" -> HandShape.PAPER
"C", "Z" -> HandShape.SCISSORS
else -> throw IllegalArgumentException()
}
}
private fun String.toGameResult(): GameResult {
return when (this) {
"X" -> GameResult.LOSS
"Y" -> GameResult.DRAW
"Z" -> GameResult.WIN
else -> throw IllegalArgumentException()
}
}
private enum class HandShape(val score: Int) {
ROCK(1) {
override fun greater() = PAPER
override fun lower() = SCISSORS
},
PAPER(2) {
override fun greater() = SCISSORS
override fun lower() = ROCK
},
SCISSORS(3) {
override fun greater() = ROCK
override fun lower() = PAPER
};
abstract fun greater(): HandShape
abstract fun lower(): HandShape
}
private enum class GameResult(val score: Int) {
LOSS(0),
DRAW(3),
WIN(6)
}
|
[
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day02Kt$main$testInputPart2$2.class",
"javap": "Compiled from \"Day02.kt\"\nfinal class Day02Kt$main$testInputPart2$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, GameResult> {\n public static final Day02Kt$main$testInputPart2$2 INSTANCE;\n\n Day02Kt$main$testInputPart2$2();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class Day02Kt\n 4: ldc #13 // String toGameResult\n 6: ldc #15 // String toGameResult(Ljava/lang/String;)LGameResult;\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final GameResult invoke(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #24 // String p0\n 3: invokestatic #30 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokestatic #33 // Method Day02Kt.access$toGameResult:(Ljava/lang/String;)LGameResult;\n 10: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #37 // class java/lang/String\n 5: invokevirtual #39 // Method invoke:(Ljava/lang/String;)LGameResult;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class Day02Kt$main$testInputPart2$2\n 3: dup\n 4: invokespecial #44 // Method \"<init>\":()V\n 7: putstatic #47 // Field INSTANCE:LDay02Kt$main$testInputPart2$2;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day02Kt$main$testInputPart1$1.class",
"javap": "Compiled from \"Day02.kt\"\nfinal class Day02Kt$main$testInputPart1$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, HandShape> {\n public static final Day02Kt$main$testInputPart1$1 INSTANCE;\n\n Day02Kt$main$testInputPart1$1();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class Day02Kt\n 4: ldc #13 // String toHandShape\n 6: ldc #15 // String toHandShape(Ljava/lang/String;)LHandShape;\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final HandShape invoke(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #24 // String p0\n 3: invokestatic #30 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokestatic #33 // Method Day02Kt.access$toHandShape:(Ljava/lang/String;)LHandShape;\n 10: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #37 // class java/lang/String\n 5: invokevirtual #39 // Method invoke:(Ljava/lang/String;)LHandShape;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class Day02Kt$main$testInputPart1$1\n 3: dup\n 4: invokespecial #44 // Method \"<init>\":()V\n 7: putstatic #47 // Field INSTANCE:LDay02Kt$main$testInputPart1$1;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day02Kt$main$inputForPart2$1.class",
"javap": "Compiled from \"Day02.kt\"\nfinal class Day02Kt$main$inputForPart2$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, HandShape> {\n public static final Day02Kt$main$inputForPart2$1 INSTANCE;\n\n Day02Kt$main$inputForPart2$1();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class Day02Kt\n 4: ldc #13 // String toHandShape\n 6: ldc #15 // String toHandShape(Ljava/lang/String;)LHandShape;\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final HandShape invoke(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #24 // String p0\n 3: invokestatic #30 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokestatic #33 // Method Day02Kt.access$toHandShape:(Ljava/lang/String;)LHandShape;\n 10: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #37 // class java/lang/String\n 5: invokevirtual #39 // Method invoke:(Ljava/lang/String;)LHandShape;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class Day02Kt$main$inputForPart2$1\n 3: dup\n 4: invokespecial #44 // Method \"<init>\":()V\n 7: putstatic #47 // Field INSTANCE:LDay02Kt$main$inputForPart2$1;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day02Kt$main$inputForPart1$2.class",
"javap": "Compiled from \"Day02.kt\"\nfinal class Day02Kt$main$inputForPart1$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, HandShape> {\n public static final Day02Kt$main$inputForPart1$2 INSTANCE;\n\n Day02Kt$main$inputForPart1$2();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class Day02Kt\n 4: ldc #13 // String toHandShape\n 6: ldc #15 // String toHandShape(Ljava/lang/String;)LHandShape;\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final HandShape invoke(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #24 // String p0\n 3: invokestatic #30 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokestatic #33 // Method Day02Kt.access$toHandShape:(Ljava/lang/String;)LHandShape;\n 10: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #37 // class java/lang/String\n 5: invokevirtual #39 // Method invoke:(Ljava/lang/String;)LHandShape;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class Day02Kt$main$inputForPart1$2\n 3: dup\n 4: invokespecial #44 // Method \"<init>\":()V\n 7: putstatic #47 // Field INSTANCE:LDay02Kt$main$inputForPart1$2;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day02Kt$main$testInputPart2$1.class",
"javap": "Compiled from \"Day02.kt\"\nfinal class Day02Kt$main$testInputPart2$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, HandShape> {\n public static final Day02Kt$main$testInputPart2$1 INSTANCE;\n\n Day02Kt$main$testInputPart2$1();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class Day02Kt\n 4: ldc #13 // String toHandShape\n 6: ldc #15 // String toHandShape(Ljava/lang/String;)LHandShape;\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final HandShape invoke(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #24 // String p0\n 3: invokestatic #30 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokestatic #33 // Method Day02Kt.access$toHandShape:(Ljava/lang/String;)LHandShape;\n 10: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #37 // class java/lang/String\n 5: invokevirtual #39 // Method invoke:(Ljava/lang/String;)LHandShape;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class Day02Kt$main$testInputPart2$1\n 3: dup\n 4: invokespecial #44 // Method \"<init>\":()V\n 7: putstatic #47 // Field INSTANCE:LDay02Kt$main$testInputPart2$1;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day02Kt$main$testInputPart1$2.class",
"javap": "Compiled from \"Day02.kt\"\nfinal class Day02Kt$main$testInputPart1$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, HandShape> {\n public static final Day02Kt$main$testInputPart1$2 INSTANCE;\n\n Day02Kt$main$testInputPart1$2();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class Day02Kt\n 4: ldc #13 // String toHandShape\n 6: ldc #15 // String toHandShape(Ljava/lang/String;)LHandShape;\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final HandShape invoke(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #24 // String p0\n 3: invokestatic #30 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokestatic #33 // Method Day02Kt.access$toHandShape:(Ljava/lang/String;)LHandShape;\n 10: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #37 // class java/lang/String\n 5: invokevirtual #39 // Method invoke:(Ljava/lang/String;)LHandShape;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class Day02Kt$main$testInputPart1$2\n 3: dup\n 4: invokespecial #44 // Method \"<init>\":()V\n 7: putstatic #47 // Field INSTANCE:LDay02Kt$main$testInputPart1$2;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day02Kt$main$inputForPart2$2.class",
"javap": "Compiled from \"Day02.kt\"\nfinal class Day02Kt$main$inputForPart2$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, GameResult> {\n public static final Day02Kt$main$inputForPart2$2 INSTANCE;\n\n Day02Kt$main$inputForPart2$2();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class Day02Kt\n 4: ldc #13 // String toGameResult\n 6: ldc #15 // String toGameResult(Ljava/lang/String;)LGameResult;\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final GameResult invoke(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #24 // String p0\n 3: invokestatic #30 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokestatic #33 // Method Day02Kt.access$toGameResult:(Ljava/lang/String;)LGameResult;\n 10: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #37 // class java/lang/String\n 5: invokevirtual #39 // Method invoke:(Ljava/lang/String;)LGameResult;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class Day02Kt$main$inputForPart2$2\n 3: dup\n 4: invokespecial #44 // Method \"<init>\":()V\n 7: putstatic #47 // Field INSTANCE:LDay02Kt$main$inputForPart2$2;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day02Kt$main$inputForPart1$1.class",
"javap": "Compiled from \"Day02.kt\"\nfinal class Day02Kt$main$inputForPart1$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, HandShape> {\n public static final Day02Kt$main$inputForPart1$1 INSTANCE;\n\n Day02Kt$main$inputForPart1$1();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class Day02Kt\n 4: ldc #13 // String toHandShape\n 6: ldc #15 // String toHandShape(Ljava/lang/String;)LHandShape;\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final HandShape invoke(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #24 // String p0\n 3: invokestatic #30 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokestatic #33 // Method Day02Kt.access$toHandShape:(Ljava/lang/String;)LHandShape;\n 10: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #37 // class java/lang/String\n 5: invokevirtual #39 // Method invoke:(Ljava/lang/String;)LHandShape;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class Day02Kt$main$inputForPart1$1\n 3: dup\n 4: invokespecial #44 // Method \"<init>\":()V\n 7: putstatic #47 // Field INSTANCE:LDay02Kt$main$inputForPart1$1;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day02Kt.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class Day02Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day02_test\n 2: getstatic #14 // Field Day02Kt$main$testInputPart1$1.INSTANCE:LDay02Kt$main$testInputPart1$1;\n 5: checkcast #16 // class kotlin/jvm/functions/Function1\n 8: getstatic #21 // Field Day02Kt$main$testInputPart1$2.INSTANCE:LDay02Kt$main$testInputPart1$2;\n 11: checkcast #16 // class kotlin/jvm/functions/Function1\n 14: invokestatic #25 // Method parseInput:(Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Ljava/util/List;\n 17: astore_0\n 18: aload_0\n 19: invokestatic #29 // Method main$part1:(Ljava/util/List;)I\n 22: bipush 15\n 24: if_icmpne 31\n 27: iconst_1\n 28: goto 32\n 31: iconst_0\n 32: ifne 45\n 35: new #31 // class java/lang/IllegalStateException\n 38: dup\n 39: ldc #33 // String Check failed.\n 41: invokespecial #37 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 44: athrow\n 45: ldc #8 // String Day02_test\n 47: getstatic #42 // Field Day02Kt$main$testInputPart2$1.INSTANCE:LDay02Kt$main$testInputPart2$1;\n 50: checkcast #16 // class kotlin/jvm/functions/Function1\n 53: getstatic #47 // Field Day02Kt$main$testInputPart2$2.INSTANCE:LDay02Kt$main$testInputPart2$2;\n 56: checkcast #16 // class kotlin/jvm/functions/Function1\n 59: invokestatic #25 // Method parseInput:(Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Ljava/util/List;\n 62: astore_1\n 63: aload_1\n 64: invokestatic #50 // Method main$part2:(Ljava/util/List;)I\n 67: bipush 12\n 69: if_icmpne 76\n 72: iconst_1\n 73: goto 77\n 76: iconst_0\n 77: ifne 90\n 80: new #31 // class java/lang/IllegalStateException\n 83: dup\n 84: ldc #33 // String Check failed.\n 86: invokespecial #37 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 89: athrow\n 90: ldc #52 // String Day02\n 92: getstatic #57 // Field Day02Kt$main$inputForPart1$1.INSTANCE:LDay02Kt$main$inputForPart1$1;\n 95: checkcast #16 // class kotlin/jvm/functions/Function1\n 98: getstatic #62 // Field Day02Kt$main$inputForPart1$2.INSTANCE:LDay02Kt$main$inputForPart1$2;\n 101: checkcast #16 // class kotlin/jvm/functions/Function1\n 104: invokestatic #25 // Method parseInput:(Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Ljava/util/List;\n 107: astore_2\n 108: aload_2\n 109: invokestatic #29 // Method main$part1:(Ljava/util/List;)I\n 112: istore_3\n 113: getstatic #68 // Field java/lang/System.out:Ljava/io/PrintStream;\n 116: iload_3\n 117: invokevirtual #74 // Method java/io/PrintStream.println:(I)V\n 120: ldc #52 // String Day02\n 122: getstatic #79 // Field Day02Kt$main$inputForPart2$1.INSTANCE:LDay02Kt$main$inputForPart2$1;\n 125: checkcast #16 // class kotlin/jvm/functions/Function1\n 128: getstatic #84 // Field Day02Kt$main$inputForPart2$2.INSTANCE:LDay02Kt$main$inputForPart2$2;\n 131: checkcast #16 // class kotlin/jvm/functions/Function1\n 134: invokestatic #25 // Method parseInput:(Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Ljava/util/List;\n 137: astore_3\n 138: aload_3\n 139: invokestatic #50 // Method main$part2:(Ljava/util/List;)I\n 142: istore 4\n 144: getstatic #68 // Field java/lang/System.out:Ljava/io/PrintStream;\n 147: iload 4\n 149: invokevirtual #74 // Method java/io/PrintStream.println:(I)V\n 152: return\n\n private static final <T, U> java.util.List<kotlin.Pair<T, U>> parseInput(java.lang.String, kotlin.jvm.functions.Function1<? super java.lang.String, ? extends T>, kotlin.jvm.functions.Function1<? super java.lang.String, ? extends U>);\n Code:\n 0: aload_0\n 1: invokestatic #98 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 4: checkcast #100 // class java/lang/Iterable\n 7: astore_3\n 8: iconst_0\n 9: istore 4\n 11: aload_3\n 12: astore 5\n 14: new #102 // class java/util/ArrayList\n 17: dup\n 18: aload_3\n 19: bipush 10\n 21: invokestatic #108 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 24: invokespecial #110 // Method java/util/ArrayList.\"<init>\":(I)V\n 27: checkcast #112 // class java/util/Collection\n 30: astore 6\n 32: iconst_0\n 33: istore 7\n 35: aload 5\n 37: invokeinterface #116, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 8\n 44: aload 8\n 46: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 158\n 54: aload 8\n 56: invokeinterface #126, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 9\n 63: aload 6\n 65: aload 9\n 67: checkcast #128 // class java/lang/String\n 70: astore 10\n 72: astore 15\n 74: iconst_0\n 75: istore 11\n 77: aload 10\n 79: checkcast #130 // class java/lang/CharSequence\n 82: iconst_1\n 83: anewarray #128 // class java/lang/String\n 86: astore 12\n 88: aload 12\n 90: iconst_0\n 91: ldc #132 // String\n 93: aastore\n 94: aload 12\n 96: iconst_0\n 97: iconst_0\n 98: bipush 6\n 100: aconst_null\n 101: invokestatic #138 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 104: astore 13\n 106: iconst_0\n 107: istore 14\n 109: new #140 // class kotlin/Pair\n 112: dup\n 113: aload_1\n 114: aload 13\n 116: iconst_0\n 117: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 122: invokeinterface #148, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 127: aload_2\n 128: aload 13\n 130: iconst_1\n 131: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 136: invokeinterface #148, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 141: invokespecial #151 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 144: nop\n 145: nop\n 146: aload 15\n 148: swap\n 149: invokeinterface #155, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 154: pop\n 155: goto 44\n 158: aload 6\n 160: checkcast #91 // class java/util/List\n 163: nop\n 164: areturn\n\n private static final HandShape toHandShape(java.lang.String);\n Code:\n 0: aload_0\n 1: astore_1\n 2: aload_1\n 3: invokevirtual #180 // Method java/lang/String.hashCode:()I\n 6: lookupswitch { // 6\n 65: 64\n 66: 76\n 67: 88\n 88: 100\n 89: 112\n 90: 124\n default: 154\n }\n 64: aload_1\n 65: ldc #182 // String A\n 67: invokevirtual #185 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 70: ifne 136\n 73: goto 154\n 76: aload_1\n 77: ldc #187 // String B\n 79: invokevirtual #185 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 82: ifne 142\n 85: goto 154\n 88: aload_1\n 89: ldc #189 // String C\n 91: invokevirtual #185 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 94: ifne 148\n 97: goto 154\n 100: aload_1\n 101: ldc #191 // String X\n 103: invokevirtual #185 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 106: ifne 136\n 109: goto 154\n 112: aload_1\n 113: ldc #193 // String Y\n 115: invokevirtual #185 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 118: ifne 142\n 121: goto 154\n 124: aload_1\n 125: ldc #195 // String Z\n 127: invokevirtual #185 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 130: ifne 148\n 133: goto 154\n 136: getstatic #201 // Field HandShape.ROCK:LHandShape;\n 139: goto 162\n 142: getstatic #204 // Field HandShape.PAPER:LHandShape;\n 145: goto 162\n 148: getstatic #207 // Field HandShape.SCISSORS:LHandShape;\n 151: goto 162\n 154: new #209 // class java/lang/IllegalArgumentException\n 157: dup\n 158: invokespecial #211 // Method java/lang/IllegalArgumentException.\"<init>\":()V\n 161: athrow\n 162: areturn\n\n private static final GameResult toGameResult(java.lang.String);\n Code:\n 0: aload_0\n 1: astore_1\n 2: aload_1\n 3: invokevirtual #180 // Method java/lang/String.hashCode:()I\n 6: tableswitch { // 88 to 90\n 88: 32\n 89: 44\n 90: 56\n default: 86\n }\n 32: aload_1\n 33: ldc #191 // String X\n 35: invokevirtual #185 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 38: ifne 68\n 41: goto 86\n 44: aload_1\n 45: ldc #193 // String Y\n 47: invokevirtual #185 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 50: ifne 74\n 53: goto 86\n 56: aload_1\n 57: ldc #195 // String Z\n 59: invokevirtual #185 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 62: ifne 80\n 65: goto 86\n 68: getstatic #220 // Field GameResult.LOSS:LGameResult;\n 71: goto 94\n 74: getstatic #223 // Field GameResult.DRAW:LGameResult;\n 77: goto 94\n 80: getstatic #226 // Field GameResult.WIN:LGameResult;\n 83: goto 94\n 86: new #209 // class java/lang/IllegalArgumentException\n 89: dup\n 90: invokespecial #211 // Method java/lang/IllegalArgumentException.\"<init>\":()V\n 93: athrow\n 94: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #230 // Method main:()V\n 3: return\n\n private static final GameResult main$gameResult(HandShape, HandShape);\n Code:\n 0: aload_0\n 1: astore_2\n 2: aload_2\n 3: aload_1\n 4: invokevirtual #238 // Method HandShape.greater:()LHandShape;\n 7: if_acmpne 16\n 10: getstatic #226 // Field GameResult.WIN:LGameResult;\n 13: goto 33\n 16: aload_2\n 17: aload_1\n 18: invokevirtual #241 // Method HandShape.lower:()LHandShape;\n 21: if_acmpne 30\n 24: getstatic #220 // Field GameResult.LOSS:LGameResult;\n 27: goto 33\n 30: getstatic #223 // Field GameResult.DRAW:LGameResult;\n 33: areturn\n\n private static final int main$part1(java.util.List<? extends kotlin.Pair<? extends HandShape, ? extends HandShape>>);\n Code:\n 0: aload_0\n 1: checkcast #100 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: invokeinterface #116, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore_3\n 14: aload_3\n 15: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 20: ifeq 91\n 23: aload_3\n 24: invokeinterface #126, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 29: astore 4\n 31: iload_2\n 32: aload 4\n 34: checkcast #140 // class kotlin/Pair\n 37: astore 5\n 39: istore 9\n 41: iconst_0\n 42: istore 6\n 44: aload 5\n 46: invokevirtual #247 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 49: checkcast #197 // class HandShape\n 52: astore 7\n 54: aload 5\n 56: invokevirtual #250 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 59: checkcast #197 // class HandShape\n 62: astore 8\n 64: aload 8\n 66: invokevirtual #253 // Method HandShape.getScore:()I\n 69: aload 8\n 71: aload 7\n 73: invokestatic #255 // Method main$gameResult:(LHandShape;LHandShape;)LGameResult;\n 76: invokevirtual #256 // Method GameResult.getScore:()I\n 79: iadd\n 80: istore 10\n 82: iload 9\n 84: iload 10\n 86: iadd\n 87: istore_2\n 88: goto 14\n 91: iload_2\n 92: ireturn\n\n private static final HandShape main$getMoveForExpectedResult(HandShape, GameResult);\n Code:\n 0: aload_1\n 1: getstatic #266 // Field Day02Kt$WhenMappings.$EnumSwitchMapping$0:[I\n 4: swap\n 5: invokevirtual #269 // Method GameResult.ordinal:()I\n 8: iaload\n 9: tableswitch { // 1 to 3\n 1: 36\n 2: 43\n 3: 47\n default: 54\n }\n 36: aload_0\n 37: invokevirtual #241 // Method HandShape.lower:()LHandShape;\n 40: goto 62\n 43: aload_0\n 44: goto 62\n 47: aload_0\n 48: invokevirtual #238 // Method HandShape.greater:()LHandShape;\n 51: goto 62\n 54: new #271 // class kotlin/NoWhenBranchMatchedException\n 57: dup\n 58: invokespecial #272 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 61: athrow\n 62: areturn\n\n private static final int main$part2(java.util.List<? extends kotlin.Pair<? extends HandShape, ? extends GameResult>>);\n Code:\n 0: aload_0\n 1: checkcast #100 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: invokeinterface #116, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore_3\n 14: aload_3\n 15: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 20: ifeq 91\n 23: aload_3\n 24: invokeinterface #126, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 29: astore 4\n 31: iload_2\n 32: aload 4\n 34: checkcast #140 // class kotlin/Pair\n 37: astore 5\n 39: istore 9\n 41: iconst_0\n 42: istore 6\n 44: aload 5\n 46: invokevirtual #247 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 49: checkcast #197 // class HandShape\n 52: astore 7\n 54: aload 5\n 56: invokevirtual #250 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 59: checkcast #216 // class GameResult\n 62: astore 8\n 64: aload 8\n 66: invokevirtual #256 // Method GameResult.getScore:()I\n 69: aload 7\n 71: aload 8\n 73: invokestatic #276 // Method main$getMoveForExpectedResult:(LHandShape;LGameResult;)LHandShape;\n 76: invokevirtual #253 // Method HandShape.getScore:()I\n 79: iadd\n 80: istore 10\n 82: iload 9\n 84: iload 10\n 86: iadd\n 87: istore_2\n 88: goto 14\n 91: iload_2\n 92: ireturn\n\n public static final HandShape access$toHandShape(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #282 // Method toHandShape:(Ljava/lang/String;)LHandShape;\n 4: areturn\n\n public static final GameResult access$toGameResult(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #286 // Method toGameResult:(Ljava/lang/String;)LGameResult;\n 4: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day02Kt$WhenMappings.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class Day02Kt$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method GameResult.values:()[LGameResult;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field GameResult.LOSS:LGameResult;\n 12: invokevirtual #22 // Method GameResult.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 GameResult.DRAW:LGameResult;\n 26: invokevirtual #22 // Method GameResult.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 GameResult.WIN:LGameResult;\n 40: invokevirtual #22 // Method GameResult.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": ""
}
] |
buczebar__advent-of-code__cdb6fe3/src/Utils.kt
|
import java.io.File
import java.lang.IllegalArgumentException
import kotlin.math.abs
/**
* Reads lines from the given input txt file.
*/
fun readInput(name: String) = File("src", "$name.txt")
.readLines()
/**
* Reads input separated by empty line
*/
fun readGroupedInput(name: String) = File("src", "$name.txt").readText().split("\n\n")
fun List<String>.splitLinesToInts() = map { it.split("\n").toListOfInts() }
fun List<String>.toListOfInts() = map { it.toInt() }
fun <T> List<T>.allDistinct() = distinct().size == size
fun <T> List<T>.pair(): Pair<T, T> =
if (size == 2) Pair(this[0], this[1]) else throw IllegalArgumentException("Input array has wrong size")
fun String.remove(regex: Regex) = replace(regex, "")
fun String.splitWords() = split(" ")
fun <T> List<List<T>>.transpose(): List<List<T>> {
val desiredSize = maxOf { it.size }
val resultList = List<MutableList<T>>(desiredSize) { mutableListOf() }
forEach { list ->
list.forEachIndexed { index, item ->
resultList[index].add(item)
}
}
return resultList
}
fun <T> List<T>.head() = first()
fun <T> List<T>.dropHead() = drop(1)
fun String.getAllInts() = "(-?\\d+)".toRegex().findAll(this).map { it.value.toInt() }.toList()
fun String.getAllByRegex(regex: Regex) = regex.findAll(this).map { it.value }.toList()
fun List<Long>.factorial() = reduce { acc, it -> acc * it }
fun List<Int>.factorial() = reduce { acc, it -> acc * it }
typealias Position = Pair<Int, Int>
operator fun Position.plus(other: Position) = Position(x + other.x, y + other.y)
operator fun Position.minus(other: Position) = Position(x - other.x, y - other.y)
val Position.x: Int
get() = first
val Position.y: Int
get() = second
fun Position.manhattanDistanceTo(other: Position) = abs(x - other.x) + abs(y - other.y)
fun <T> MutableList<T>.popHead(): T {
val head = head()
removeFirst()
return head
}
fun IntRange.limitValuesInRange(valueRange: IntRange): IntRange {
return first.coerceAtLeast(valueRange.first)..last.coerceAtMost(valueRange.last)
}
fun List<Int>.valueRange(): IntRange {
return min()..max()
}
|
[
{
"class_path": "buczebar__advent-of-code__cdb6fe3/UtilsKt.class",
"javap": "Compiled from \"Utils.kt\"\npublic final class UtilsKt {\n public static final java.util.List<java.lang.String> readInput(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #10 // String name\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #18 // class java/io/File\n 9: dup\n 10: ldc #20 // String src\n 12: new #22 // class java/lang/StringBuilder\n 15: dup\n 16: invokespecial #26 // Method java/lang/StringBuilder.\"<init>\":()V\n 19: aload_0\n 20: invokevirtual #30 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 23: ldc #32 // String .txt\n 25: invokevirtual #30 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 28: invokevirtual #36 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 31: invokespecial #39 // Method java/io/File.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 34: aconst_null\n 35: iconst_1\n 36: aconst_null\n 37: invokestatic #45 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 40: areturn\n\n public static final java.util.List<java.lang.String> readGroupedInput(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #10 // String name\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #18 // class java/io/File\n 9: dup\n 10: ldc #20 // String src\n 12: new #22 // class java/lang/StringBuilder\n 15: dup\n 16: invokespecial #26 // Method java/lang/StringBuilder.\"<init>\":()V\n 19: aload_0\n 20: invokevirtual #30 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 23: ldc #32 // String .txt\n 25: invokevirtual #30 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 28: invokevirtual #36 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 31: invokespecial #39 // Method java/io/File.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 34: aconst_null\n 35: iconst_1\n 36: aconst_null\n 37: invokestatic #51 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;\n 40: checkcast #53 // class java/lang/CharSequence\n 43: iconst_1\n 44: anewarray #55 // class java/lang/String\n 47: astore_1\n 48: aload_1\n 49: iconst_0\n 50: ldc #57 // String \\n\\n\n 52: aastore\n 53: aload_1\n 54: iconst_0\n 55: iconst_0\n 56: bipush 6\n 58: aconst_null\n 59: invokestatic #63 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 62: areturn\n\n public static final java.util.List<java.util.List<java.lang.Integer>> splitLinesToInts(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #68 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #70 // class java/lang/Iterable\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: aload_1\n 14: astore_3\n 15: new #72 // class java/util/ArrayList\n 18: dup\n 19: aload_1\n 20: bipush 10\n 22: invokestatic #78 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 25: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 28: checkcast #83 // class java/util/Collection\n 31: astore 4\n 33: iconst_0\n 34: istore 5\n 36: aload_3\n 37: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 6\n 44: aload 6\n 46: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 119\n 54: aload 6\n 56: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 7\n 63: aload 4\n 65: aload 7\n 67: checkcast #55 // class java/lang/String\n 70: astore 8\n 72: astore 11\n 74: iconst_0\n 75: istore 9\n 77: aload 8\n 79: checkcast #53 // class java/lang/CharSequence\n 82: iconst_1\n 83: anewarray #55 // class java/lang/String\n 86: astore 10\n 88: aload 10\n 90: iconst_0\n 91: ldc #99 // String \\n\n 93: aastore\n 94: aload 10\n 96: iconst_0\n 97: iconst_0\n 98: bipush 6\n 100: aconst_null\n 101: invokestatic #63 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 104: invokestatic #102 // Method toListOfInts:(Ljava/util/List;)Ljava/util/List;\n 107: aload 11\n 109: swap\n 110: invokeinterface #106, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 115: pop\n 116: goto 44\n 119: aload 4\n 121: checkcast #108 // class java/util/List\n 124: nop\n 125: areturn\n\n public static final java.util.List<java.lang.Integer> toListOfInts(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #68 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #70 // class java/lang/Iterable\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: aload_1\n 14: astore_3\n 15: new #72 // class java/util/ArrayList\n 18: dup\n 19: aload_1\n 20: bipush 10\n 22: invokestatic #78 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 25: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 28: checkcast #83 // class java/util/Collection\n 31: astore 4\n 33: iconst_0\n 34: istore 5\n 36: aload_3\n 37: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 6\n 44: aload 6\n 46: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 98\n 54: aload 6\n 56: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 7\n 63: aload 4\n 65: aload 7\n 67: checkcast #55 // class java/lang/String\n 70: astore 8\n 72: astore 10\n 74: iconst_0\n 75: istore 9\n 77: aload 8\n 79: invokestatic #129 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 82: nop\n 83: invokestatic #133 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 86: aload 10\n 88: swap\n 89: invokeinterface #106, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 94: pop\n 95: goto 44\n 98: aload 4\n 100: checkcast #108 // class java/util/List\n 103: nop\n 104: areturn\n\n public static final <T> boolean allDistinct(java.util.List<? extends T>);\n Code:\n 0: aload_0\n 1: ldc #68 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #70 // class java/lang/Iterable\n 10: invokestatic #142 // Method kotlin/collections/CollectionsKt.distinct:(Ljava/lang/Iterable;)Ljava/util/List;\n 13: invokeinterface #146, 1 // InterfaceMethod java/util/List.size:()I\n 18: aload_0\n 19: invokeinterface #146, 1 // InterfaceMethod java/util/List.size:()I\n 24: if_icmpne 31\n 27: iconst_1\n 28: goto 32\n 31: iconst_0\n 32: ireturn\n\n public static final <T> kotlin.Pair<T, T> pair(java.util.List<? extends T>);\n Code:\n 0: aload_0\n 1: ldc #68 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #146, 1 // InterfaceMethod java/util/List.size:()I\n 12: iconst_2\n 13: if_icmpne 40\n 16: new #152 // class kotlin/Pair\n 19: dup\n 20: aload_0\n 21: iconst_0\n 22: invokeinterface #156, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 27: aload_0\n 28: iconst_1\n 29: invokeinterface #156, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 34: invokespecial #159 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 37: goto 50\n 40: new #161 // class java/lang/IllegalArgumentException\n 43: dup\n 44: ldc #163 // String Input array has wrong size\n 46: invokespecial #166 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 49: athrow\n 50: areturn\n\n public static final java.lang.String remove(java.lang.String, kotlin.text.Regex);\n Code:\n 0: aload_0\n 1: ldc #68 // 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 #171 // String regex\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: checkcast #53 // class java/lang/CharSequence\n 16: astore_2\n 17: ldc #173 // String\n 19: astore_3\n 20: aload_1\n 21: aload_2\n 22: aload_3\n 23: invokevirtual #179 // Method kotlin/text/Regex.replace:(Ljava/lang/CharSequence;Ljava/lang/String;)Ljava/lang/String;\n 26: areturn\n\n public static final java.util.List<java.lang.String> splitWords(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #68 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #53 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #55 // class java/lang/String\n 14: astore_1\n 15: aload_1\n 16: iconst_0\n 17: ldc #184 // String\n 19: aastore\n 20: aload_1\n 21: iconst_0\n 22: iconst_0\n 23: bipush 6\n 25: aconst_null\n 26: invokestatic #63 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: areturn\n\n public static final <T> java.util.List<java.util.List<T>> transpose(java.util.List<? extends java.util.List<? extends T>>);\n Code:\n 0: aload_0\n 1: ldc #68 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #70 // class java/lang/Iterable\n 10: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 15: astore_3\n 16: aload_3\n 17: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 22: ifne 33\n 25: new #189 // class java/util/NoSuchElementException\n 28: dup\n 29: invokespecial #190 // Method java/util/NoSuchElementException.\"<init>\":()V\n 32: athrow\n 33: aload_3\n 34: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 39: checkcast #108 // class java/util/List\n 42: astore 4\n 44: iconst_0\n 45: istore 5\n 47: aload 4\n 49: invokeinterface #146, 1 // InterfaceMethod java/util/List.size:()I\n 54: istore 4\n 56: aload_3\n 57: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 62: ifeq 102\n 65: aload_3\n 66: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 71: checkcast #108 // class java/util/List\n 74: astore 5\n 76: iconst_0\n 77: istore 6\n 79: aload 5\n 81: invokeinterface #146, 1 // InterfaceMethod java/util/List.size:()I\n 86: istore 5\n 88: iload 4\n 90: iload 5\n 92: if_icmpge 56\n 95: iload 5\n 97: istore 4\n 99: goto 56\n 102: iload 4\n 104: istore_1\n 105: new #72 // class java/util/ArrayList\n 108: dup\n 109: iload_1\n 110: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 113: astore_3\n 114: iconst_0\n 115: istore 4\n 117: iload 4\n 119: iload_1\n 120: if_icmpge 161\n 123: iload 4\n 125: istore 5\n 127: aload_3\n 128: iload 5\n 130: istore 6\n 132: astore 18\n 134: iconst_0\n 135: istore 7\n 137: new #72 // class java/util/ArrayList\n 140: dup\n 141: invokespecial #191 // Method java/util/ArrayList.\"<init>\":()V\n 144: checkcast #108 // class java/util/List\n 147: nop\n 148: aload 18\n 150: swap\n 151: invokevirtual #192 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 154: pop\n 155: iinc 4, 1\n 158: goto 117\n 161: aload_3\n 162: checkcast #108 // class java/util/List\n 165: astore_2\n 166: aload_0\n 167: checkcast #70 // class java/lang/Iterable\n 170: astore_3\n 171: iconst_0\n 172: istore 4\n 174: aload_3\n 175: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 180: astore 5\n 182: aload 5\n 184: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 189: ifeq 308\n 192: aload 5\n 194: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 199: astore 6\n 201: aload 6\n 203: checkcast #108 // class java/util/List\n 206: astore 7\n 208: iconst_0\n 209: istore 8\n 211: aload 7\n 213: checkcast #70 // class java/lang/Iterable\n 216: astore 9\n 218: iconst_0\n 219: istore 10\n 221: iconst_0\n 222: istore 11\n 224: aload 9\n 226: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 231: astore 12\n 233: aload 12\n 235: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 240: ifeq 302\n 243: aload 12\n 245: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 250: astore 13\n 252: iload 11\n 254: iinc 11, 1\n 257: istore 14\n 259: iload 14\n 261: ifge 267\n 264: invokestatic #195 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 267: iload 14\n 269: aload 13\n 271: astore 15\n 273: istore 16\n 275: iconst_0\n 276: istore 17\n 278: aload_2\n 279: iload 16\n 281: invokeinterface #156, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 286: checkcast #108 // class java/util/List\n 289: aload 15\n 291: invokeinterface #196, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 296: pop\n 297: nop\n 298: nop\n 299: goto 233\n 302: nop\n 303: nop\n 304: nop\n 305: goto 182\n 308: nop\n 309: aload_2\n 310: areturn\n\n public static final <T> T head(java.util.List<? extends T>);\n Code:\n 0: aload_0\n 1: ldc #68 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #219 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 10: areturn\n\n public static final <T> java.util.List<T> dropHead(java.util.List<? extends T>);\n Code:\n 0: aload_0\n 1: ldc #68 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #70 // class java/lang/Iterable\n 10: iconst_1\n 11: invokestatic #226 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 14: areturn\n\n public static final java.util.List<java.lang.Integer> getAllInts(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #68 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #175 // class kotlin/text/Regex\n 9: dup\n 10: ldc #231 // String (-?\\\\d+)\n 12: invokespecial #232 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 15: aload_0\n 16: checkcast #53 // class java/lang/CharSequence\n 19: iconst_0\n 20: iconst_2\n 21: aconst_null\n 22: invokestatic #236 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 25: invokedynamic #256, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 30: invokestatic #262 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 33: invokestatic #266 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 36: areturn\n\n public static final java.util.List<java.lang.String> getAllByRegex(java.lang.String, kotlin.text.Regex);\n Code:\n 0: aload_0\n 1: ldc #68 // 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 #171 // String regex\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: aload_0\n 14: checkcast #53 // class java/lang/CharSequence\n 17: iconst_0\n 18: iconst_2\n 19: aconst_null\n 20: invokestatic #236 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 23: invokedynamic #277, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 28: invokestatic #262 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 31: invokestatic #266 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 34: areturn\n\n public static final long factorial(java.util.List<java.lang.Long>);\n Code:\n 0: aload_0\n 1: ldc #68 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #70 // class java/lang/Iterable\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: aload_1\n 14: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 19: astore_3\n 20: aload_3\n 21: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 26: ifne 40\n 29: new #283 // class java/lang/UnsupportedOperationException\n 32: dup\n 33: ldc_w #285 // String Empty collection can\\'t be reduced.\n 36: invokespecial #286 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 39: athrow\n 40: aload_3\n 41: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 46: astore 4\n 48: aload_3\n 49: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 97\n 57: aload 4\n 59: aload_3\n 60: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 65: checkcast #288 // class java/lang/Number\n 68: invokevirtual #292 // Method java/lang/Number.longValue:()J\n 71: lstore 5\n 73: checkcast #288 // class java/lang/Number\n 76: invokevirtual #292 // Method java/lang/Number.longValue:()J\n 79: lstore 7\n 81: iconst_0\n 82: istore 9\n 84: lload 7\n 86: lload 5\n 88: lmul\n 89: invokestatic #297 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 92: astore 4\n 94: goto 48\n 97: aload 4\n 99: checkcast #288 // class java/lang/Number\n 102: invokevirtual #292 // Method java/lang/Number.longValue:()J\n 105: lreturn\n\n public static final int factorial(java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #68 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #70 // class java/lang/Iterable\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: aload_1\n 14: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 19: astore_3\n 20: aload_3\n 21: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 26: ifne 40\n 29: new #283 // class java/lang/UnsupportedOperationException\n 32: dup\n 33: ldc_w #285 // String Empty collection can\\'t be reduced.\n 36: invokespecial #286 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 39: athrow\n 40: aload_3\n 41: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 46: astore 4\n 48: aload_3\n 49: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 97\n 57: aload 4\n 59: aload_3\n 60: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 65: checkcast #288 // class java/lang/Number\n 68: invokevirtual #311 // Method java/lang/Number.intValue:()I\n 71: istore 5\n 73: checkcast #288 // class java/lang/Number\n 76: invokevirtual #311 // Method java/lang/Number.intValue:()I\n 79: istore 6\n 81: iconst_0\n 82: istore 7\n 84: iload 6\n 86: iload 5\n 88: imul\n 89: invokestatic #133 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 92: astore 4\n 94: goto 48\n 97: aload 4\n 99: checkcast #288 // class java/lang/Number\n 102: invokevirtual #311 // Method java/lang/Number.intValue:()I\n 105: ireturn\n\n public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> plus(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #68 // 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_w #317 // String other\n 10: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 13: new #152 // class kotlin/Pair\n 16: dup\n 17: aload_0\n 18: invokestatic #321 // Method getX:(Lkotlin/Pair;)I\n 21: aload_1\n 22: invokestatic #321 // Method getX:(Lkotlin/Pair;)I\n 25: iadd\n 26: invokestatic #133 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 29: aload_0\n 30: invokestatic #324 // Method getY:(Lkotlin/Pair;)I\n 33: aload_1\n 34: invokestatic #324 // Method getY:(Lkotlin/Pair;)I\n 37: iadd\n 38: invokestatic #133 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 41: invokespecial #159 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 44: areturn\n\n public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> minus(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #68 // 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_w #317 // String other\n 10: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 13: new #152 // class kotlin/Pair\n 16: dup\n 17: aload_0\n 18: invokestatic #321 // Method getX:(Lkotlin/Pair;)I\n 21: aload_1\n 22: invokestatic #321 // Method getX:(Lkotlin/Pair;)I\n 25: isub\n 26: invokestatic #133 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 29: aload_0\n 30: invokestatic #324 // Method getY:(Lkotlin/Pair;)I\n 33: aload_1\n 34: invokestatic #324 // Method getY:(Lkotlin/Pair;)I\n 37: isub\n 38: invokestatic #133 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 41: invokespecial #159 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 44: areturn\n\n public static final int getX(kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #68 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokevirtual #332 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 10: checkcast #288 // class java/lang/Number\n 13: invokevirtual #311 // Method java/lang/Number.intValue:()I\n 16: ireturn\n\n public static final int getY(kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #68 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokevirtual #336 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 10: checkcast #288 // class java/lang/Number\n 13: invokevirtual #311 // Method java/lang/Number.intValue:()I\n 16: ireturn\n\n public static final int manhattanDistanceTo(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #68 // 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_w #317 // String other\n 10: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 13: aload_0\n 14: invokestatic #321 // Method getX:(Lkotlin/Pair;)I\n 17: aload_1\n 18: invokestatic #321 // Method getX:(Lkotlin/Pair;)I\n 21: isub\n 22: invokestatic #346 // Method java/lang/Math.abs:(I)I\n 25: aload_0\n 26: invokestatic #324 // Method getY:(Lkotlin/Pair;)I\n 29: aload_1\n 30: invokestatic #324 // Method getY:(Lkotlin/Pair;)I\n 33: isub\n 34: invokestatic #346 // Method java/lang/Math.abs:(I)I\n 37: iadd\n 38: ireturn\n\n public static final <T> T popHead(java.util.List<T>);\n Code:\n 0: aload_0\n 1: ldc #68 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #351 // Method head:(Ljava/util/List;)Ljava/lang/Object;\n 10: astore_1\n 11: aload_0\n 12: invokeinterface #354, 1 // InterfaceMethod java/util/List.removeFirst:()Ljava/lang/Object;\n 17: pop\n 18: aload_1\n 19: areturn\n\n public static final kotlin.ranges.IntRange limitValuesInRange(kotlin.ranges.IntRange, kotlin.ranges.IntRange);\n Code:\n 0: aload_0\n 1: ldc #68 // 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_w #359 // String valueRange\n 10: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 13: new #361 // class kotlin/ranges/IntRange\n 16: dup\n 17: aload_0\n 18: invokevirtual #363 // Method kotlin/ranges/IntRange.getFirst:()I\n 21: aload_1\n 22: invokevirtual #363 // Method kotlin/ranges/IntRange.getFirst:()I\n 25: invokestatic #369 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 28: aload_0\n 29: invokevirtual #372 // Method kotlin/ranges/IntRange.getLast:()I\n 32: aload_1\n 33: invokevirtual #372 // Method kotlin/ranges/IntRange.getLast:()I\n 36: invokestatic #375 // Method kotlin/ranges/RangesKt.coerceAtMost:(II)I\n 39: invokespecial #378 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 42: areturn\n\n public static final kotlin.ranges.IntRange valueRange(java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #68 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #361 // class kotlin/ranges/IntRange\n 9: dup\n 10: aload_0\n 11: checkcast #70 // class java/lang/Iterable\n 14: invokestatic #386 // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 17: checkcast #288 // class java/lang/Number\n 20: invokevirtual #311 // Method java/lang/Number.intValue:()I\n 23: aload_0\n 24: checkcast #70 // class java/lang/Iterable\n 27: invokestatic #389 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 30: checkcast #288 // class java/lang/Number\n 33: invokevirtual #311 // Method java/lang/Number.intValue:()I\n 36: invokespecial #378 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 39: areturn\n\n private static final int getAllInts$lambda$6(kotlin.text.MatchResult);\n Code:\n 0: aload_0\n 1: ldc_w #391 // String it\n 4: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokeinterface #396, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 13: invokestatic #129 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 16: ireturn\n\n private static final java.lang.String getAllByRegex$lambda$7(kotlin.text.MatchResult);\n Code:\n 0: aload_0\n 1: ldc_w #391 // String it\n 4: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokeinterface #396, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 13: areturn\n}\n",
"javap_err": ""
}
] |
buczebar__advent-of-code__cdb6fe3/src/Day14.kt
|
import java.lang.Integer.max
import java.lang.Integer.min
private typealias Path = List<Position>
private typealias MutableMatrix<T> = MutableList<MutableList<T>>
private val Pair<Int, Int>.depth: Int
get() = second
private fun List<Path>.getMaxValue(selector: (Position) -> Int) =
flatten().maxOf { selector(it) }
private fun List<Path>.toFieldMatrix(): MutableMatrix<FieldType> {
val maxDepth = getMaxValue { it.depth }
val maxWidth = getMaxValue { it.x }
val matrix = MutableList(maxDepth + 1) { MutableList(maxWidth * 2) { FieldType.AIR } }
forEach { path ->
path.windowed(2).forEach { (start, end) ->
val xRange = min(start.x, end.x)..max(start.x, end.x)
val depthRange = min(start.depth, end.depth)..max(start.depth, end.depth)
for (x in xRange) {
for (y in depthRange) {
matrix[y][x] = FieldType.ROCK
}
}
}
}
return matrix
}
private fun MutableList<MutableList<FieldType>>.addRow(type: FieldType) {
add(MutableList(first().size) { type })
}
fun main() {
fun parseInput(name: String) =
readInput(name)
.map { line ->
line.split(" -> ")
.map { path ->
path.split(",")
.toListOfInts()
.pair()
}
}
fun simulate(fieldMatrix: MutableMatrix<FieldType>): Int {
fun nextPosition(position: Position): Position? {
val directionsToCheck = listOf(Position(0, 1), Position(-1, 1), Position(1, 1))
for (direction in directionsToCheck) {
val newPosition = position + direction
if (fieldMatrix[newPosition.depth][newPosition.x] == FieldType.AIR) {
return newPosition
}
}
return null
}
val maxDepth = fieldMatrix.size - 1
val sandStartPosition = Position(500, 0)
var position = sandStartPosition
while (position.depth < maxDepth && fieldMatrix[sandStartPosition.depth][sandStartPosition.x] == FieldType.AIR) {
with(nextPosition(position)) {
if (this == null) {
fieldMatrix[position.depth][position.x] = FieldType.SAND
position = sandStartPosition
} else {
position = this
}
}
}
return fieldMatrix.flatten().count { it == FieldType.SAND }
}
fun part1(fieldMatrix: MutableMatrix<FieldType>) = simulate(fieldMatrix)
fun part2(fieldMatrix: MutableMatrix<FieldType>): Int {
fieldMatrix.apply {
addRow(FieldType.AIR)
addRow(FieldType.ROCK)
}
return simulate(fieldMatrix)
}
val testInput = parseInput("Day14_test").toFieldMatrix()
check(part1(testInput) == 24)
check(part2(testInput) == 93)
val input = parseInput("Day14").toFieldMatrix()
println(part1(input))
println(part2(input))
}
private enum class FieldType {
AIR,
SAND,
ROCK
}
|
[
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day14Kt.class",
"javap": "Compiled from \"Day14.kt\"\npublic final class Day14Kt {\n private static final int getDepth(kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: invokevirtual #13 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 4: checkcast #15 // class java/lang/Number\n 7: invokevirtual #19 // Method java/lang/Number.intValue:()I\n 10: ireturn\n\n private static final int getMaxValue(java.util.List<? extends java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>>>, kotlin.jvm.functions.Function1<? super kotlin.Pair<java.lang.Integer, java.lang.Integer>, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: checkcast #26 // class java/lang/Iterable\n 4: invokestatic #32 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 7: checkcast #26 // class java/lang/Iterable\n 10: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 15: astore_2\n 16: aload_2\n 17: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 22: ifne 33\n 25: new #44 // class java/util/NoSuchElementException\n 28: dup\n 29: invokespecial #48 // Method java/util/NoSuchElementException.\"<init>\":()V\n 32: athrow\n 33: aload_2\n 34: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 39: checkcast #9 // class kotlin/Pair\n 42: astore_3\n 43: iconst_0\n 44: istore 4\n 46: aload_1\n 47: aload_3\n 48: invokeinterface #57, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 53: checkcast #15 // class java/lang/Number\n 56: invokevirtual #19 // Method java/lang/Number.intValue:()I\n 59: istore_3\n 60: aload_2\n 61: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 66: ifeq 111\n 69: aload_2\n 70: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 75: checkcast #9 // class kotlin/Pair\n 78: astore 4\n 80: iconst_0\n 81: istore 5\n 83: aload_1\n 84: aload 4\n 86: invokeinterface #57, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 91: checkcast #15 // class java/lang/Number\n 94: invokevirtual #19 // Method java/lang/Number.intValue:()I\n 97: istore 4\n 99: iload_3\n 100: iload 4\n 102: if_icmpge 60\n 105: iload 4\n 107: istore_3\n 108: goto 60\n 111: iload_3\n 112: ireturn\n\n private static final java.util.List<java.util.List<FieldType>> toFieldMatrix(java.util.List<? extends java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>>>);\n Code:\n 0: aload_0\n 1: invokedynamic #84, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 6: invokestatic #86 // Method getMaxValue:(Ljava/util/List;Lkotlin/jvm/functions/Function1;)I\n 9: istore_1\n 10: aload_0\n 11: invokedynamic #91, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 16: invokestatic #86 // Method getMaxValue:(Ljava/util/List;Lkotlin/jvm/functions/Function1;)I\n 19: istore_2\n 20: iload_1\n 21: iconst_1\n 22: iadd\n 23: istore 4\n 25: new #93 // class java/util/ArrayList\n 28: dup\n 29: iload 4\n 31: invokespecial #96 // Method java/util/ArrayList.\"<init>\":(I)V\n 34: astore 5\n 36: iconst_0\n 37: istore 6\n 39: iload 6\n 41: iload 4\n 43: if_icmpge 137\n 46: iload 6\n 48: istore 7\n 50: aload 5\n 52: iload 7\n 54: istore 8\n 56: astore 24\n 58: iconst_0\n 59: istore 9\n 61: iload_2\n 62: iconst_2\n 63: imul\n 64: istore 10\n 66: new #93 // class java/util/ArrayList\n 69: dup\n 70: iload 10\n 72: invokespecial #96 // Method java/util/ArrayList.\"<init>\":(I)V\n 75: astore 11\n 77: iconst_0\n 78: istore 12\n 80: iload 12\n 82: iload 10\n 84: if_icmpge 118\n 87: iload 12\n 89: istore 13\n 91: aload 11\n 93: iload 13\n 95: istore 14\n 97: astore 15\n 99: iconst_0\n 100: istore 16\n 102: getstatic #102 // Field FieldType.AIR:LFieldType;\n 105: aload 15\n 107: swap\n 108: invokevirtual #106 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 111: pop\n 112: iinc 12, 1\n 115: goto 80\n 118: aload 11\n 120: checkcast #108 // class java/util/List\n 123: nop\n 124: aload 24\n 126: swap\n 127: invokevirtual #106 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 130: pop\n 131: iinc 6, 1\n 134: goto 39\n 137: aload 5\n 139: checkcast #108 // class java/util/List\n 142: astore_3\n 143: aload_0\n 144: checkcast #26 // class java/lang/Iterable\n 147: astore 4\n 149: iconst_0\n 150: istore 5\n 152: aload 4\n 154: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 159: astore 6\n 161: aload 6\n 163: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 168: ifeq 447\n 171: aload 6\n 173: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 178: astore 7\n 180: aload 7\n 182: checkcast #108 // class java/util/List\n 185: astore 8\n 187: iconst_0\n 188: istore 9\n 190: aload 8\n 192: checkcast #26 // class java/lang/Iterable\n 195: iconst_2\n 196: iconst_0\n 197: iconst_0\n 198: bipush 6\n 200: aconst_null\n 201: invokestatic #112 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;\n 204: checkcast #26 // class java/lang/Iterable\n 207: astore 10\n 209: iconst_0\n 210: istore 11\n 212: aload 10\n 214: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 219: astore 12\n 221: aload 12\n 223: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 228: ifeq 441\n 231: aload 12\n 233: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 238: astore 13\n 240: aload 13\n 242: checkcast #108 // class java/util/List\n 245: astore 14\n 247: iconst_0\n 248: istore 15\n 250: aload 14\n 252: iconst_0\n 253: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 258: checkcast #9 // class kotlin/Pair\n 261: astore 16\n 263: aload 14\n 265: iconst_1\n 266: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 271: checkcast #9 // class kotlin/Pair\n 274: astore 17\n 276: new #118 // class kotlin/ranges/IntRange\n 279: dup\n 280: aload 16\n 282: invokestatic #123 // Method UtilsKt.getX:(Lkotlin/Pair;)I\n 285: aload 17\n 287: invokestatic #123 // Method UtilsKt.getX:(Lkotlin/Pair;)I\n 290: invokestatic #129 // Method java/lang/Integer.min:(II)I\n 293: aload 16\n 295: invokestatic #123 // Method UtilsKt.getX:(Lkotlin/Pair;)I\n 298: aload 17\n 300: invokestatic #123 // Method UtilsKt.getX:(Lkotlin/Pair;)I\n 303: invokestatic #132 // Method java/lang/Integer.max:(II)I\n 306: invokespecial #135 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 309: astore 18\n 311: new #118 // class kotlin/ranges/IntRange\n 314: dup\n 315: aload 16\n 317: invokestatic #137 // Method getDepth:(Lkotlin/Pair;)I\n 320: aload 17\n 322: invokestatic #137 // Method getDepth:(Lkotlin/Pair;)I\n 325: invokestatic #129 // Method java/lang/Integer.min:(II)I\n 328: aload 16\n 330: invokestatic #137 // Method getDepth:(Lkotlin/Pair;)I\n 333: aload 17\n 335: invokestatic #137 // Method getDepth:(Lkotlin/Pair;)I\n 338: invokestatic #132 // Method java/lang/Integer.max:(II)I\n 341: invokespecial #135 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 344: astore 19\n 346: aload 18\n 348: invokevirtual #140 // Method kotlin/ranges/IntRange.getFirst:()I\n 351: istore 20\n 353: aload 18\n 355: invokevirtual #143 // Method kotlin/ranges/IntRange.getLast:()I\n 358: istore 21\n 360: iload 20\n 362: iload 21\n 364: if_icmpgt 436\n 367: aload 19\n 369: invokevirtual #140 // Method kotlin/ranges/IntRange.getFirst:()I\n 372: istore 22\n 374: aload 19\n 376: invokevirtual #143 // Method kotlin/ranges/IntRange.getLast:()I\n 379: istore 23\n 381: iload 22\n 383: iload 23\n 385: if_icmpgt 423\n 388: aload_3\n 389: iload 22\n 391: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 396: checkcast #108 // class java/util/List\n 399: iload 20\n 401: getstatic #146 // Field FieldType.ROCK:LFieldType;\n 404: invokeinterface #150, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 409: pop\n 410: iload 22\n 412: iload 23\n 414: if_icmpeq 423\n 417: iinc 22, 1\n 420: goto 388\n 423: iload 20\n 425: iload 21\n 427: if_icmpeq 436\n 430: iinc 20, 1\n 433: goto 367\n 436: nop\n 437: nop\n 438: goto 221\n 441: nop\n 442: nop\n 443: nop\n 444: goto 161\n 447: nop\n 448: aload_3\n 449: areturn\n\n private static final void addRow(java.util.List<java.util.List<FieldType>>, FieldType);\n Code:\n 0: aload_0\n 1: aload_0\n 2: invokestatic #178 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 5: checkcast #108 // class java/util/List\n 8: invokeinterface #181, 1 // InterfaceMethod java/util/List.size:()I\n 13: istore_2\n 14: astore 8\n 16: new #93 // class java/util/ArrayList\n 19: dup\n 20: iload_2\n 21: invokespecial #96 // Method java/util/ArrayList.\"<init>\":(I)V\n 24: astore_3\n 25: iconst_0\n 26: istore 4\n 28: iload 4\n 30: iload_2\n 31: if_icmpge 62\n 34: iload 4\n 36: istore 5\n 38: aload_3\n 39: iload 5\n 41: istore 6\n 43: astore 9\n 45: iconst_0\n 46: istore 7\n 48: aload_1\n 49: aload 9\n 51: swap\n 52: invokevirtual #106 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 55: pop\n 56: iinc 4, 1\n 59: goto 28\n 62: aload_3\n 63: checkcast #108 // class java/util/List\n 66: aload 8\n 68: swap\n 69: invokeinterface #182, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 74: pop\n 75: return\n\n public static final void main();\n Code:\n 0: ldc #188 // String Day14_test\n 2: invokestatic #192 // Method main$parseInput:(Ljava/lang/String;)Ljava/util/List;\n 5: invokestatic #194 // Method toFieldMatrix:(Ljava/util/List;)Ljava/util/List;\n 8: astore_0\n 9: aload_0\n 10: invokestatic #198 // Method main$part1:(Ljava/util/List;)I\n 13: bipush 24\n 15: if_icmpne 22\n 18: iconst_1\n 19: goto 23\n 22: iconst_0\n 23: ifne 36\n 26: new #200 // class java/lang/IllegalStateException\n 29: dup\n 30: ldc #202 // String Check failed.\n 32: invokespecial #205 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 35: athrow\n 36: aload_0\n 37: invokestatic #208 // Method main$part2:(Ljava/util/List;)I\n 40: bipush 93\n 42: if_icmpne 49\n 45: iconst_1\n 46: goto 50\n 49: iconst_0\n 50: ifne 63\n 53: new #200 // class java/lang/IllegalStateException\n 56: dup\n 57: ldc #202 // String Check failed.\n 59: invokespecial #205 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 62: athrow\n 63: ldc #210 // String Day14\n 65: invokestatic #192 // Method main$parseInput:(Ljava/lang/String;)Ljava/util/List;\n 68: invokestatic #194 // Method toFieldMatrix:(Ljava/util/List;)Ljava/util/List;\n 71: astore_1\n 72: aload_1\n 73: invokestatic #198 // Method main$part1:(Ljava/util/List;)I\n 76: istore_2\n 77: getstatic #216 // Field java/lang/System.out:Ljava/io/PrintStream;\n 80: iload_2\n 81: invokevirtual #221 // Method java/io/PrintStream.println:(I)V\n 84: aload_1\n 85: invokestatic #208 // Method main$part2:(Ljava/util/List;)I\n 88: istore_2\n 89: getstatic #216 // Field java/lang/System.out:Ljava/io/PrintStream;\n 92: iload_2\n 93: invokevirtual #221 // Method java/io/PrintStream.println:(I)V\n 96: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #226 // Method main:()V\n 3: return\n\n private static final int toFieldMatrix$lambda$1(kotlin.Pair);\n Code:\n 0: aload_0\n 1: ldc #229 // String it\n 3: invokestatic #235 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #137 // Method getDepth:(Lkotlin/Pair;)I\n 10: ireturn\n\n private static final int toFieldMatrix$lambda$2(kotlin.Pair);\n Code:\n 0: aload_0\n 1: ldc #229 // String it\n 3: invokestatic #235 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #123 // Method UtilsKt.getX:(Lkotlin/Pair;)I\n 10: ireturn\n\n private static final java.util.List<java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>>> main$parseInput(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #239 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 4: checkcast #26 // class java/lang/Iterable\n 7: astore_1\n 8: nop\n 9: iconst_0\n 10: istore_2\n 11: aload_1\n 12: astore_3\n 13: new #93 // class java/util/ArrayList\n 16: dup\n 17: aload_1\n 18: bipush 10\n 20: invokestatic #243 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 23: invokespecial #96 // Method java/util/ArrayList.\"<init>\":(I)V\n 26: checkcast #245 // class java/util/Collection\n 29: astore 4\n 31: iconst_0\n 32: istore 5\n 34: aload_3\n 35: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 40: astore 6\n 42: aload 6\n 44: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 49: ifeq 244\n 52: aload 6\n 54: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 59: astore 7\n 61: aload 4\n 63: aload 7\n 65: checkcast #247 // class java/lang/String\n 68: astore 8\n 70: astore 21\n 72: iconst_0\n 73: istore 9\n 75: aload 8\n 77: checkcast #249 // class java/lang/CharSequence\n 80: iconst_1\n 81: anewarray #247 // class java/lang/String\n 84: astore 10\n 86: aload 10\n 88: iconst_0\n 89: ldc #251 // String ->\n 91: aastore\n 92: aload 10\n 94: iconst_0\n 95: iconst_0\n 96: bipush 6\n 98: aconst_null\n 99: invokestatic #257 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 102: checkcast #26 // class java/lang/Iterable\n 105: astore 10\n 107: nop\n 108: iconst_0\n 109: istore 11\n 111: aload 10\n 113: astore 12\n 115: new #93 // class java/util/ArrayList\n 118: dup\n 119: aload 10\n 121: bipush 10\n 123: invokestatic #243 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 126: invokespecial #96 // Method java/util/ArrayList.\"<init>\":(I)V\n 129: checkcast #245 // class java/util/Collection\n 132: astore 13\n 134: iconst_0\n 135: istore 14\n 137: aload 12\n 139: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 144: astore 15\n 146: aload 15\n 148: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 153: ifeq 225\n 156: aload 15\n 158: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 163: astore 16\n 165: aload 13\n 167: aload 16\n 169: checkcast #247 // class java/lang/String\n 172: astore 17\n 174: astore 18\n 176: iconst_0\n 177: istore 19\n 179: aload 17\n 181: checkcast #249 // class java/lang/CharSequence\n 184: iconst_1\n 185: anewarray #247 // class java/lang/String\n 188: astore 20\n 190: aload 20\n 192: iconst_0\n 193: ldc_w #259 // String ,\n 196: aastore\n 197: aload 20\n 199: iconst_0\n 200: iconst_0\n 201: bipush 6\n 203: aconst_null\n 204: invokestatic #257 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 207: invokestatic #262 // Method UtilsKt.toListOfInts:(Ljava/util/List;)Ljava/util/List;\n 210: invokestatic #266 // Method UtilsKt.pair:(Ljava/util/List;)Lkotlin/Pair;\n 213: aload 18\n 215: swap\n 216: invokeinterface #267, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 221: pop\n 222: goto 146\n 225: aload 13\n 227: checkcast #108 // class java/util/List\n 230: nop\n 231: nop\n 232: aload 21\n 234: swap\n 235: invokeinterface #267, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 240: pop\n 241: goto 42\n 244: aload 4\n 246: checkcast #108 // class java/util/List\n 249: nop\n 250: areturn\n\n private static final kotlin.Pair<java.lang.Integer, java.lang.Integer> main$simulate$nextPosition(java.util.List<java.util.List<FieldType>>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: iconst_3\n 1: anewarray #9 // class kotlin/Pair\n 4: astore_3\n 5: aload_3\n 6: iconst_0\n 7: new #9 // class kotlin/Pair\n 10: dup\n 11: iconst_0\n 12: invokestatic #286 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 15: iconst_1\n 16: invokestatic #286 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 19: invokespecial #289 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 22: aastore\n 23: aload_3\n 24: iconst_1\n 25: new #9 // class kotlin/Pair\n 28: dup\n 29: iconst_m1\n 30: invokestatic #286 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 33: iconst_1\n 34: invokestatic #286 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 37: invokespecial #289 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 40: aastore\n 41: aload_3\n 42: iconst_2\n 43: new #9 // class kotlin/Pair\n 46: dup\n 47: iconst_1\n 48: invokestatic #286 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 51: iconst_1\n 52: invokestatic #286 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 55: invokespecial #289 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 58: aastore\n 59: aload_3\n 60: invokestatic #293 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 63: astore_2\n 64: aload_2\n 65: invokeinterface #294, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 70: astore_3\n 71: aload_3\n 72: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 77: ifeq 132\n 80: aload_3\n 81: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 86: checkcast #9 // class kotlin/Pair\n 89: astore 4\n 91: aload_1\n 92: aload 4\n 94: invokestatic #298 // Method UtilsKt.plus:(Lkotlin/Pair;Lkotlin/Pair;)Lkotlin/Pair;\n 97: astore 5\n 99: aload_0\n 100: aload 5\n 102: invokestatic #137 // Method getDepth:(Lkotlin/Pair;)I\n 105: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 110: checkcast #108 // class java/util/List\n 113: aload 5\n 115: invokestatic #123 // Method UtilsKt.getX:(Lkotlin/Pair;)I\n 118: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 123: getstatic #102 // Field FieldType.AIR:LFieldType;\n 126: if_acmpne 71\n 129: aload 5\n 131: areturn\n 132: aconst_null\n 133: areturn\n\n private static final int main$simulate(java.util.List<java.util.List<FieldType>>);\n Code:\n 0: aload_0\n 1: invokeinterface #181, 1 // InterfaceMethod java/util/List.size:()I\n 6: iconst_1\n 7: isub\n 8: istore_1\n 9: new #9 // class kotlin/Pair\n 12: dup\n 13: sipush 500\n 16: invokestatic #286 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 19: iconst_0\n 20: invokestatic #286 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 23: invokespecial #289 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 26: astore_2\n 27: aconst_null\n 28: astore_3\n 29: aload_2\n 30: astore_3\n 31: aload_3\n 32: invokestatic #137 // Method getDepth:(Lkotlin/Pair;)I\n 35: iload_1\n 36: if_icmpge 120\n 39: aload_0\n 40: aload_2\n 41: invokestatic #137 // Method getDepth:(Lkotlin/Pair;)I\n 44: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 49: checkcast #108 // class java/util/List\n 52: aload_2\n 53: invokestatic #123 // Method UtilsKt.getX:(Lkotlin/Pair;)I\n 56: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 61: getstatic #102 // Field FieldType.AIR:LFieldType;\n 64: if_acmpne 120\n 67: aload_0\n 68: aload_3\n 69: invokestatic #307 // Method main$simulate$nextPosition:(Ljava/util/List;Lkotlin/Pair;)Lkotlin/Pair;\n 72: astore 5\n 74: iconst_0\n 75: istore 6\n 77: aload 5\n 79: ifnonnull 113\n 82: aload_0\n 83: aload_3\n 84: invokestatic #137 // Method getDepth:(Lkotlin/Pair;)I\n 87: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 92: checkcast #108 // class java/util/List\n 95: aload_3\n 96: invokestatic #123 // Method UtilsKt.getX:(Lkotlin/Pair;)I\n 99: getstatic #310 // Field FieldType.SAND:LFieldType;\n 102: invokeinterface #150, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 107: pop\n 108: aload_2\n 109: astore_3\n 110: goto 116\n 113: aload 5\n 115: astore_3\n 116: nop\n 117: goto 31\n 120: aload_0\n 121: checkcast #26 // class java/lang/Iterable\n 124: invokestatic #32 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 127: checkcast #26 // class java/lang/Iterable\n 130: astore 4\n 132: iconst_0\n 133: istore 5\n 135: aload 4\n 137: instanceof #245 // class java/util/Collection\n 140: ifeq 160\n 143: aload 4\n 145: checkcast #245 // class java/util/Collection\n 148: invokeinterface #313, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 153: ifeq 160\n 156: iconst_0\n 157: goto 233\n 160: iconst_0\n 161: istore 6\n 163: aload 4\n 165: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 170: astore 7\n 172: aload 7\n 174: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 179: ifeq 231\n 182: aload 7\n 184: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 189: astore 8\n 191: aload 8\n 193: checkcast #98 // class FieldType\n 196: astore 9\n 198: iconst_0\n 199: istore 10\n 201: aload 9\n 203: getstatic #310 // Field FieldType.SAND:LFieldType;\n 206: if_acmpne 213\n 209: iconst_1\n 210: goto 214\n 213: iconst_0\n 214: ifeq 172\n 217: iinc 6, 1\n 220: iload 6\n 222: ifge 172\n 225: invokestatic #316 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 228: goto 172\n 231: iload 6\n 233: ireturn\n\n private static final int main$part1(java.util.List<java.util.List<FieldType>>);\n Code:\n 0: aload_0\n 1: invokestatic #326 // Method main$simulate:(Ljava/util/List;)I\n 4: ireturn\n\n private static final int main$part2(java.util.List<java.util.List<FieldType>>);\n Code:\n 0: aload_0\n 1: astore_1\n 2: aload_1\n 3: astore_2\n 4: iconst_0\n 5: istore_3\n 6: aload_2\n 7: getstatic #102 // Field FieldType.AIR:LFieldType;\n 10: invokestatic #328 // Method addRow:(Ljava/util/List;LFieldType;)V\n 13: aload_2\n 14: getstatic #146 // Field FieldType.ROCK:LFieldType;\n 17: invokestatic #328 // Method addRow:(Ljava/util/List;LFieldType;)V\n 20: nop\n 21: nop\n 22: aload_0\n 23: invokestatic #326 // Method main$simulate:(Ljava/util/List;)I\n 26: ireturn\n}\n",
"javap_err": ""
}
] |
buczebar__advent-of-code__cdb6fe3/src/Day04.kt
|
typealias SectionRange = Pair<Int, Int>
fun main() {
infix fun SectionRange.contains(range: SectionRange): Boolean {
return first <= range.first && this.second >= range.second
}
infix fun SectionRange.overlap(range: SectionRange): Boolean {
return first <= range.second && range.first <= second
}
fun part1(input: List<Pair<SectionRange, SectionRange>>) =
input.count { it.first contains it.second || it.second contains it.first }
fun part2(input: List<Pair<SectionRange, SectionRange>>) =
input.count { it.first overlap it.second || it.second overlap it.first }
fun parseInput(name: String): List<Pair<SectionRange, SectionRange>> {
fun parseSectionRange(input: String) =
input.split("-").map { it.toInt() }.pair()
return readInput(name)
.map {
it.split(",").pair()
.let { ranges ->
Pair(parseSectionRange(ranges.first), parseSectionRange(ranges.second))
}
}
}
val testInput = parseInput("Day04_test")
check(part1(testInput) == 2)
check(part2(testInput) == 4)
val input = parseInput("Day04")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day04Kt.class",
"javap": "Compiled from \"Day04.kt\"\npublic final class Day04Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day04_test\n 2: invokestatic #12 // Method main$parseInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #16 // Method main$part1:(Ljava/util/List;)I\n 10: iconst_2\n 11: if_icmpne 18\n 14: iconst_1\n 15: goto 19\n 18: iconst_0\n 19: ifne 32\n 22: new #18 // class java/lang/IllegalStateException\n 25: dup\n 26: ldc #20 // String Check failed.\n 28: invokespecial #24 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 31: athrow\n 32: aload_0\n 33: invokestatic #27 // Method main$part2:(Ljava/util/List;)I\n 36: iconst_4\n 37: if_icmpne 44\n 40: iconst_1\n 41: goto 45\n 44: iconst_0\n 45: ifne 58\n 48: new #18 // class java/lang/IllegalStateException\n 51: dup\n 52: ldc #20 // String Check failed.\n 54: invokespecial #24 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 57: athrow\n 58: ldc #29 // String Day04\n 60: invokestatic #12 // Method main$parseInput:(Ljava/lang/String;)Ljava/util/List;\n 63: astore_1\n 64: aload_1\n 65: invokestatic #16 // Method main$part1:(Ljava/util/List;)I\n 68: istore_2\n 69: getstatic #35 // Field java/lang/System.out:Ljava/io/PrintStream;\n 72: iload_2\n 73: invokevirtual #41 // Method java/io/PrintStream.println:(I)V\n 76: aload_1\n 77: invokestatic #27 // Method main$part2:(Ljava/util/List;)I\n 80: istore_2\n 81: getstatic #35 // Field java/lang/System.out:Ljava/io/PrintStream;\n 84: iload_2\n 85: invokevirtual #41 // Method java/io/PrintStream.println:(I)V\n 88: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #49 // Method main:()V\n 3: return\n\n private static final boolean main$contains(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: invokevirtual #60 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 4: checkcast #62 // class java/lang/Number\n 7: invokevirtual #66 // Method java/lang/Number.intValue:()I\n 10: aload_1\n 11: invokevirtual #60 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 14: checkcast #62 // class java/lang/Number\n 17: invokevirtual #66 // Method java/lang/Number.intValue:()I\n 20: if_icmpgt 50\n 23: aload_0\n 24: invokevirtual #69 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 27: checkcast #62 // class java/lang/Number\n 30: invokevirtual #66 // Method java/lang/Number.intValue:()I\n 33: aload_1\n 34: invokevirtual #69 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 37: checkcast #62 // class java/lang/Number\n 40: invokevirtual #66 // Method java/lang/Number.intValue:()I\n 43: if_icmplt 50\n 46: iconst_1\n 47: goto 51\n 50: iconst_0\n 51: ireturn\n\n private static final boolean main$overlap(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: invokevirtual #60 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 4: checkcast #62 // class java/lang/Number\n 7: invokevirtual #66 // Method java/lang/Number.intValue:()I\n 10: aload_1\n 11: invokevirtual #69 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 14: checkcast #62 // class java/lang/Number\n 17: invokevirtual #66 // Method java/lang/Number.intValue:()I\n 20: if_icmpgt 50\n 23: aload_1\n 24: invokevirtual #60 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 27: checkcast #62 // class java/lang/Number\n 30: invokevirtual #66 // Method java/lang/Number.intValue:()I\n 33: aload_0\n 34: invokevirtual #69 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 37: checkcast #62 // class java/lang/Number\n 40: invokevirtual #66 // Method java/lang/Number.intValue:()I\n 43: if_icmpgt 50\n 46: iconst_1\n 47: goto 51\n 50: iconst_0\n 51: ireturn\n\n private static final int main$part1(java.util.List<kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>>);\n Code:\n 0: aload_0\n 1: checkcast #77 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: instanceof #79 // class java/util/Collection\n 11: ifeq 30\n 14: aload_1\n 15: checkcast #79 // class java/util/Collection\n 18: invokeinterface #83, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 23: ifeq 30\n 26: iconst_0\n 27: goto 135\n 30: iconst_0\n 31: istore_3\n 32: aload_1\n 33: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 4\n 40: aload 4\n 42: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 134\n 50: aload 4\n 52: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 5\n 59: aload 5\n 61: checkcast #56 // class kotlin/Pair\n 64: astore 6\n 66: iconst_0\n 67: istore 7\n 69: aload 6\n 71: invokevirtual #60 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 74: checkcast #56 // class kotlin/Pair\n 77: aload 6\n 79: invokevirtual #69 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 82: checkcast #56 // class kotlin/Pair\n 85: invokestatic #97 // Method main$contains:(Lkotlin/Pair;Lkotlin/Pair;)Z\n 88: ifne 113\n 91: aload 6\n 93: invokevirtual #69 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 96: checkcast #56 // class kotlin/Pair\n 99: aload 6\n 101: invokevirtual #60 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 104: checkcast #56 // class kotlin/Pair\n 107: invokestatic #97 // Method main$contains:(Lkotlin/Pair;Lkotlin/Pair;)Z\n 110: ifeq 117\n 113: iconst_1\n 114: goto 118\n 117: iconst_0\n 118: ifeq 40\n 121: iinc 3, 1\n 124: iload_3\n 125: ifge 40\n 128: invokestatic #102 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 131: goto 40\n 134: iload_3\n 135: ireturn\n\n private static final int main$part2(java.util.List<kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>>);\n Code:\n 0: aload_0\n 1: checkcast #77 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: instanceof #79 // class java/util/Collection\n 11: ifeq 30\n 14: aload_1\n 15: checkcast #79 // class java/util/Collection\n 18: invokeinterface #83, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 23: ifeq 30\n 26: iconst_0\n 27: goto 135\n 30: iconst_0\n 31: istore_3\n 32: aload_1\n 33: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 4\n 40: aload 4\n 42: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 134\n 50: aload 4\n 52: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 5\n 59: aload 5\n 61: checkcast #56 // class kotlin/Pair\n 64: astore 6\n 66: iconst_0\n 67: istore 7\n 69: aload 6\n 71: invokevirtual #60 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 74: checkcast #56 // class kotlin/Pair\n 77: aload 6\n 79: invokevirtual #69 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 82: checkcast #56 // class kotlin/Pair\n 85: invokestatic #113 // Method main$overlap:(Lkotlin/Pair;Lkotlin/Pair;)Z\n 88: ifne 113\n 91: aload 6\n 93: invokevirtual #69 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 96: checkcast #56 // class kotlin/Pair\n 99: aload 6\n 101: invokevirtual #60 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 104: checkcast #56 // class kotlin/Pair\n 107: invokestatic #113 // Method main$overlap:(Lkotlin/Pair;Lkotlin/Pair;)Z\n 110: ifeq 117\n 113: iconst_1\n 114: goto 118\n 117: iconst_0\n 118: ifeq 40\n 121: iinc 3, 1\n 124: iload_3\n 125: ifge 40\n 128: invokestatic #102 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 131: goto 40\n 134: iload_3\n 135: ireturn\n\n private static final kotlin.Pair<java.lang.Integer, java.lang.Integer> main$parseInput$parseSectionRange(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #119 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #121 // class java/lang/String\n 8: astore_1\n 9: aload_1\n 10: iconst_0\n 11: ldc #123 // 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 #129 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 23: checkcast #77 // 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 #131 // class java/util/ArrayList\n 34: dup\n 35: aload_1\n 36: bipush 10\n 38: invokestatic #135 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 41: invokespecial #137 // Method java/util/ArrayList.\"<init>\":(I)V\n 44: checkcast #79 // class java/util/Collection\n 47: astore 4\n 49: iconst_0\n 50: istore 5\n 52: aload_3\n 53: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 58: astore 6\n 60: aload 6\n 62: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 67: ifeq 114\n 70: aload 6\n 72: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 77: astore 7\n 79: aload 4\n 81: aload 7\n 83: checkcast #121 // 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 #143 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 98: nop\n 99: invokestatic #147 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 102: aload 10\n 104: swap\n 105: invokeinterface #151, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 110: pop\n 111: goto 60\n 114: aload 4\n 116: checkcast #46 // class java/util/List\n 119: nop\n 120: invokestatic #157 // Method UtilsKt.pair:(Ljava/util/List;)Lkotlin/Pair;\n 123: areturn\n\n private static final java.util.List<kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>> main$parseInput(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #170 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 4: checkcast #77 // class java/lang/Iterable\n 7: astore_1\n 8: nop\n 9: iconst_0\n 10: istore_2\n 11: aload_1\n 12: astore_3\n 13: new #131 // class java/util/ArrayList\n 16: dup\n 17: aload_1\n 18: bipush 10\n 20: invokestatic #135 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 23: invokespecial #137 // Method java/util/ArrayList.\"<init>\":(I)V\n 26: checkcast #79 // class java/util/Collection\n 29: astore 4\n 31: iconst_0\n 32: istore 5\n 34: aload_3\n 35: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 40: astore 6\n 42: aload 6\n 44: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 49: ifeq 153\n 52: aload 6\n 54: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 59: astore 7\n 61: aload 4\n 63: aload 7\n 65: checkcast #121 // class java/lang/String\n 68: astore 8\n 70: astore 13\n 72: iconst_0\n 73: istore 9\n 75: aload 8\n 77: checkcast #119 // class java/lang/CharSequence\n 80: iconst_1\n 81: anewarray #121 // class java/lang/String\n 84: astore 10\n 86: aload 10\n 88: iconst_0\n 89: ldc #172 // String ,\n 91: aastore\n 92: aload 10\n 94: iconst_0\n 95: iconst_0\n 96: bipush 6\n 98: aconst_null\n 99: invokestatic #129 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 102: invokestatic #157 // Method UtilsKt.pair:(Ljava/util/List;)Lkotlin/Pair;\n 105: astore 11\n 107: iconst_0\n 108: istore 12\n 110: new #56 // class kotlin/Pair\n 113: dup\n 114: aload 11\n 116: invokevirtual #60 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 119: checkcast #121 // class java/lang/String\n 122: invokestatic #174 // Method main$parseInput$parseSectionRange:(Ljava/lang/String;)Lkotlin/Pair;\n 125: aload 11\n 127: invokevirtual #69 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 130: checkcast #121 // class java/lang/String\n 133: invokestatic #174 // Method main$parseInput$parseSectionRange:(Ljava/lang/String;)Lkotlin/Pair;\n 136: invokespecial #177 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 139: nop\n 140: nop\n 141: aload 13\n 143: swap\n 144: invokeinterface #151, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 149: pop\n 150: goto 42\n 153: aload 4\n 155: checkcast #46 // class java/util/List\n 158: nop\n 159: areturn\n}\n",
"javap_err": ""
}
] |
buczebar__advent-of-code__cdb6fe3/src/Day07.kt
|
private const val TOTAL_DISK_SPACE = 70000000L
private const val SPACE_NEEDED_FOR_UPDATE = 30000000L
fun main() {
fun part1(fileTree: TreeNode): Long {
return fileTree.getAllSubdirectories().filter { it.totalSize <= 100_000 }.sumOf { it.totalSize }
}
fun part2(fileTree: TreeNode): Long {
val spaceAvailable = TOTAL_DISK_SPACE - fileTree.totalSize
val spaceToBeFreed = SPACE_NEEDED_FOR_UPDATE - spaceAvailable
return fileTree.getAllSubdirectories().sortedBy { it.totalSize }
.firstOrNull { it.totalSize > spaceToBeFreed }?.totalSize ?: 0L
}
val testInput = readInput("Day07_test")
val testInputFileTree = buildFileTree(testInput)
check(part1(testInputFileTree) == 95_437L)
check(part2(testInputFileTree) == 24_933_642L)
val input = readInput("Day07")
val inputFileTree = buildFileTree(input)
println(part1(inputFileTree))
println(part2(inputFileTree))
}
private fun buildFileTree(consoleLog: List<String>): TreeNode {
val rootNode = DirNode("/", null)
var currentNode = rootNode as TreeNode
consoleLog.forEach { line ->
when {
line.isCdCommand() -> {
val (_, _, name) = line.splitWords()
currentNode = when (name) {
".." -> currentNode.parent ?: return@forEach
"/" -> rootNode
else -> currentNode.getChildByName(name)
}
}
line.isDir() -> {
val (_, name) = line.splitWords()
currentNode.addChild(DirNode(name))
}
line.isFile() -> {
val (size, name) = line.splitWords()
currentNode.addChild(FileNode(name, size.toLong()))
}
}
}
return rootNode
}
private fun String.isDir() = startsWith("dir")
private fun String.isFile() = "\\d+ [\\w.]+".toRegex().matches(this)
private fun String.isCdCommand() = startsWith("$ cd")
private abstract class TreeNode(private val name: String, var parent: TreeNode?, val children: MutableList<TreeNode>?) {
open val totalSize: Long
get() {
return children?.sumOf { it.totalSize } ?: 0
}
fun addChild(node: TreeNode) {
node.parent = this
children?.add(node)
}
fun getChildByName(name: String): TreeNode {
return children?.firstOrNull { it.name == name } ?: this
}
fun getAllSubdirectories(): List<DirNode> {
return getAllSubNodes().filterIsInstance<DirNode>()
}
private fun getAllSubNodes(): List<TreeNode> {
val result = mutableListOf<TreeNode>()
if (children != null) {
for (child in children) {
result.addAll(child.getAllSubNodes())
result.add(child)
}
}
return result
}
}
private class DirNode(name: String, parent: TreeNode? = null, children: MutableList<TreeNode> = mutableListOf()) :
TreeNode(name, parent, children)
private class FileNode(name: String, override val totalSize: Long, parent: DirNode? = null) :
TreeNode(name, parent, null)
|
[
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day07Kt$main$part2$$inlined$sortedBy$1.class",
"javap": "Compiled from \"Comparisons.kt\"\npublic final class Day07Kt$main$part2$$inlined$sortedBy$1<T> implements java.util.Comparator {\n public Day07Kt$main$part2$$inlined$sortedBy$1();\n Code:\n 0: aload_0\n 1: invokespecial #16 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int compare(T, T);\n Code:\n 0: aload_1\n 1: checkcast #23 // class DirNode\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method DirNode.getTotalSize:()J\n 12: invokestatic #33 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 15: checkcast #35 // class java/lang/Comparable\n 18: aload_2\n 19: checkcast #23 // class DirNode\n 22: astore_3\n 23: astore 5\n 25: iconst_0\n 26: istore 4\n 28: aload_3\n 29: invokevirtual #27 // Method DirNode.getTotalSize:()J\n 32: invokestatic #33 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 35: aload 5\n 37: swap\n 38: checkcast #35 // class java/lang/Comparable\n 41: invokestatic #41 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I\n 44: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day07Kt.class",
"javap": "Compiled from \"Day07.kt\"\npublic final class Day07Kt {\n private static final long TOTAL_DISK_SPACE;\n\n private static final long SPACE_NEEDED_FOR_UPDATE;\n\n public static final void main();\n Code:\n 0: ldc #8 // String Day07_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method buildFileTree:(Ljava/util/List;)LTreeNode;\n 10: astore_1\n 11: aload_1\n 12: invokestatic #22 // Method main$part1:(LTreeNode;)J\n 15: ldc2_w #23 // long 95437l\n 18: lcmp\n 19: ifne 26\n 22: iconst_1\n 23: goto 27\n 26: iconst_0\n 27: ifne 40\n 30: new #26 // class java/lang/IllegalStateException\n 33: dup\n 34: ldc #28 // String Check failed.\n 36: invokespecial #32 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 39: athrow\n 40: aload_1\n 41: invokestatic #35 // Method main$part2:(LTreeNode;)J\n 44: ldc2_w #36 // long 24933642l\n 47: lcmp\n 48: ifne 55\n 51: iconst_1\n 52: goto 56\n 55: iconst_0\n 56: ifne 69\n 59: new #26 // class java/lang/IllegalStateException\n 62: dup\n 63: ldc #28 // String Check failed.\n 65: invokespecial #32 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 68: athrow\n 69: ldc #39 // String Day07\n 71: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 74: astore_2\n 75: aload_2\n 76: invokestatic #18 // Method buildFileTree:(Ljava/util/List;)LTreeNode;\n 79: astore_3\n 80: aload_3\n 81: invokestatic #22 // Method main$part1:(LTreeNode;)J\n 84: lstore 4\n 86: getstatic #45 // Field java/lang/System.out:Ljava/io/PrintStream;\n 89: lload 4\n 91: invokevirtual #51 // Method java/io/PrintStream.println:(J)V\n 94: aload_3\n 95: invokestatic #35 // Method main$part2:(LTreeNode;)J\n 98: lstore 4\n 100: getstatic #45 // Field java/lang/System.out:Ljava/io/PrintStream;\n 103: lload 4\n 105: invokevirtual #51 // Method java/io/PrintStream.println:(J)V\n 108: return\n\n private static final TreeNode buildFileTree(java.util.List<java.lang.String>);\n Code:\n 0: new #64 // class DirNode\n 3: dup\n 4: ldc #66 // String /\n 6: aconst_null\n 7: aconst_null\n 8: iconst_4\n 9: aconst_null\n 10: invokespecial #69 // Method DirNode.\"<init>\":(Ljava/lang/String;LTreeNode;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 13: astore_1\n 14: aconst_null\n 15: astore_2\n 16: aload_1\n 17: checkcast #61 // class TreeNode\n 20: astore_2\n 21: aload_0\n 22: checkcast #71 // class java/lang/Iterable\n 25: astore_3\n 26: iconst_0\n 27: istore 4\n 29: aload_3\n 30: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 35: astore 5\n 37: aload 5\n 39: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 44: ifeq 262\n 47: aload 5\n 49: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 54: astore 6\n 56: aload 6\n 58: checkcast #87 // class java/lang/String\n 61: astore 7\n 63: iconst_0\n 64: istore 8\n 66: nop\n 67: aload 7\n 69: invokestatic #91 // Method isCdCommand:(Ljava/lang/String;)Z\n 72: ifeq 144\n 75: aload 7\n 77: invokestatic #94 // Method UtilsKt.splitWords:(Ljava/lang/String;)Ljava/util/List;\n 80: iconst_2\n 81: invokeinterface #98, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 86: checkcast #87 // class java/lang/String\n 89: astore 9\n 91: aload 9\n 93: astore 10\n 95: aload 10\n 97: ldc #100 // String ..\n 99: invokestatic #106 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 102: ifeq 117\n 105: aload_2\n 106: invokevirtual #110 // Method TreeNode.getParent:()LTreeNode;\n 109: dup\n 110: ifnonnull 140\n 113: pop\n 114: goto 258\n 117: aload 10\n 119: ldc #66 // String /\n 121: invokestatic #106 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 124: ifeq 134\n 127: aload_1\n 128: checkcast #61 // class TreeNode\n 131: goto 140\n 134: aload_2\n 135: aload 9\n 137: invokevirtual #114 // Method TreeNode.getChildByName:(Ljava/lang/String;)LTreeNode;\n 140: astore_2\n 141: goto 257\n 144: aload 7\n 146: invokestatic #117 // Method isDir:(Ljava/lang/String;)Z\n 149: ifeq 192\n 152: aload 7\n 154: invokestatic #94 // Method UtilsKt.splitWords:(Ljava/lang/String;)Ljava/util/List;\n 157: iconst_1\n 158: invokeinterface #98, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 163: checkcast #87 // class java/lang/String\n 166: astore 9\n 168: aload_2\n 169: new #64 // class DirNode\n 172: dup\n 173: aload 9\n 175: aconst_null\n 176: aconst_null\n 177: bipush 6\n 179: aconst_null\n 180: invokespecial #69 // Method DirNode.\"<init>\":(Ljava/lang/String;LTreeNode;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 183: checkcast #61 // class TreeNode\n 186: invokevirtual #121 // Method TreeNode.addChild:(LTreeNode;)V\n 189: goto 257\n 192: aload 7\n 194: invokestatic #124 // Method isFile:(Ljava/lang/String;)Z\n 197: ifeq 257\n 200: aload 7\n 202: invokestatic #94 // Method UtilsKt.splitWords:(Ljava/lang/String;)Ljava/util/List;\n 205: astore 11\n 207: aload 11\n 209: iconst_0\n 210: invokeinterface #98, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 215: checkcast #87 // class java/lang/String\n 218: astore 9\n 220: aload 11\n 222: iconst_1\n 223: invokeinterface #98, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 228: checkcast #87 // class java/lang/String\n 231: astore 10\n 233: aload_2\n 234: new #126 // class FileNode\n 237: dup\n 238: aload 10\n 240: aload 9\n 242: invokestatic #132 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 245: aconst_null\n 246: iconst_4\n 247: aconst_null\n 248: invokespecial #135 // Method FileNode.\"<init>\":(Ljava/lang/String;JLDirNode;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 251: checkcast #61 // class TreeNode\n 254: invokevirtual #121 // Method TreeNode.addChild:(LTreeNode;)V\n 257: nop\n 258: nop\n 259: goto 37\n 262: nop\n 263: aload_1\n 264: checkcast #61 // class TreeNode\n 267: areturn\n\n private static final boolean isDir(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #152 // String dir\n 3: iconst_0\n 4: iconst_2\n 5: aconst_null\n 6: invokestatic #158 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 9: ireturn\n\n private static final boolean isFile(java.lang.String);\n Code:\n 0: new #161 // class kotlin/text/Regex\n 3: dup\n 4: ldc #163 // String \\\\d+ [\\\\w.]+\n 6: invokespecial #164 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 9: aload_0\n 10: checkcast #166 // class java/lang/CharSequence\n 13: invokevirtual #170 // Method kotlin/text/Regex.matches:(Ljava/lang/CharSequence;)Z\n 16: ireturn\n\n private static final boolean isCdCommand(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #173 // String $ cd\n 3: iconst_0\n 4: iconst_2\n 5: aconst_null\n 6: invokestatic #158 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 9: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #177 // Method main:()V\n 3: return\n\n private static final long main$part1(TreeNode);\n Code:\n 0: aload_0\n 1: invokevirtual #183 // Method TreeNode.getAllSubdirectories:()Ljava/util/List;\n 4: checkcast #71 // class java/lang/Iterable\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: astore_3\n 12: new #185 // class java/util/ArrayList\n 15: dup\n 16: invokespecial #187 // Method java/util/ArrayList.\"<init>\":()V\n 19: checkcast #189 // class java/util/Collection\n 22: astore 4\n 24: iconst_0\n 25: istore 5\n 27: aload_3\n 28: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 33: astore 6\n 35: aload 6\n 37: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 42: ifeq 97\n 45: aload 6\n 47: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 52: astore 7\n 54: aload 7\n 56: checkcast #64 // class DirNode\n 59: astore 8\n 61: iconst_0\n 62: istore 9\n 64: aload 8\n 66: invokevirtual #193 // Method DirNode.getTotalSize:()J\n 69: ldc2_w #194 // long 100000l\n 72: lcmp\n 73: ifgt 80\n 76: iconst_1\n 77: goto 81\n 80: iconst_0\n 81: ifeq 35\n 84: aload 4\n 86: aload 7\n 88: invokeinterface #199, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 93: pop\n 94: goto 35\n 97: aload 4\n 99: checkcast #59 // class java/util/List\n 102: nop\n 103: checkcast #71 // class java/lang/Iterable\n 106: astore_1\n 107: lconst_0\n 108: lstore_2\n 109: aload_1\n 110: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 115: astore 4\n 117: aload 4\n 119: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 124: ifeq 165\n 127: aload 4\n 129: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 134: astore 5\n 136: lload_2\n 137: aload 5\n 139: checkcast #64 // class DirNode\n 142: astore 6\n 144: lstore 10\n 146: iconst_0\n 147: istore 7\n 149: aload 6\n 151: invokevirtual #193 // Method DirNode.getTotalSize:()J\n 154: lstore 12\n 156: lload 10\n 158: lload 12\n 160: ladd\n 161: lstore_2\n 162: goto 117\n 165: lload_2\n 166: lreturn\n\n private static final long main$part2(TreeNode);\n Code:\n 0: ldc2_w #211 // long 70000000l\n 3: aload_0\n 4: invokevirtual #213 // Method TreeNode.getTotalSize:()J\n 7: lsub\n 8: lstore_1\n 9: ldc2_w #214 // long 30000000l\n 12: lload_1\n 13: lsub\n 14: lstore_3\n 15: aload_0\n 16: invokevirtual #183 // Method TreeNode.getAllSubdirectories:()Ljava/util/List;\n 19: checkcast #71 // class java/lang/Iterable\n 22: astore 6\n 24: iconst_0\n 25: istore 7\n 27: aload 6\n 29: new #217 // class Day07Kt$main$part2$$inlined$sortedBy$1\n 32: dup\n 33: invokespecial #218 // Method Day07Kt$main$part2$$inlined$sortedBy$1.\"<init>\":()V\n 36: checkcast #220 // class java/util/Comparator\n 39: invokestatic #226 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 42: checkcast #71 // class java/lang/Iterable\n 45: astore 6\n 47: nop\n 48: iconst_0\n 49: istore 7\n 51: aload 6\n 53: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 58: astore 8\n 60: aload 8\n 62: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 67: ifeq 112\n 70: aload 8\n 72: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 77: astore 9\n 79: aload 9\n 81: checkcast #64 // class DirNode\n 84: astore 10\n 86: iconst_0\n 87: istore 11\n 89: aload 10\n 91: invokevirtual #193 // Method DirNode.getTotalSize:()J\n 94: lload_3\n 95: lcmp\n 96: ifle 103\n 99: iconst_1\n 100: goto 104\n 103: iconst_0\n 104: ifeq 60\n 107: aload 9\n 109: goto 113\n 112: aconst_null\n 113: checkcast #64 // class DirNode\n 116: astore 5\n 118: aload 5\n 120: ifnull 131\n 123: aload 5\n 125: invokevirtual #193 // Method DirNode.getTotalSize:()J\n 128: goto 132\n 131: lconst_0\n 132: lreturn\n}\n",
"javap_err": ""
}
] |
buczebar__advent-of-code__cdb6fe3/src/Day05.kt
|
typealias Stack = List<Char>
fun main() {
fun solve(input: Pair<MutableList<Stack>, List<StackMove>>, inputModifier: (List<Char>) -> List<Char>): String {
val (stacks, moves) = input
moves.forEach { move ->
stacks[move.to] = stacks[move.from].take(move.amount).let { inputModifier.invoke(it) } + stacks[move.to]
stacks[move.from] = stacks[move.from].drop(move.amount)
}
return stacks.filter { it.isNotEmpty() }.map { it.first() }.joinToString("")
}
fun part1(input: Pair<MutableList<Stack>, List<StackMove>>) = solve(input) { it.reversed() }
fun part2(input: Pair<MutableList<Stack>, List<StackMove>>) = solve(input) { it }
check(part1(parseInput("Day05_test")) == "CMZ")
check(part2(parseInput("Day05_test")) == "MCD")
println(part1(parseInput("Day05")))
println(part2(parseInput("Day05")))
}
private fun parseInput(name: String): Pair<MutableList<Stack>, List<StackMove>> {
fun parseStacks(inputString: String): MutableList<Stack> {
val stackValues = inputString.lines().dropLast(1)
.map { line ->
line.replace(" ", "[-]")
.remove("[^\\w-]".toRegex())
.toList()
}
.transpose()
.map { stack -> stack.filter { it != '-' }.toMutableList() }
return stackValues.toMutableList()
}
fun parseMoves(inputString: String): List<StackMove> {
val lineRegex = "(\\d+)".toRegex()
return inputString.lines()
.map { line -> lineRegex.findAll(line).map { it.value.toInt() }.toList() }
.map { (amount, from, to) -> StackMove(amount, from - 1, to - 1) }
}
val (stacks, moves) = readGroupedInput(name)
return Pair(parseStacks(stacks), parseMoves(moves))
}
private data class StackMove(
val amount: Int,
val from: Int,
val to: Int
)
|
[
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day05Kt.class",
"javap": "Compiled from \"Day05.kt\"\npublic final class Day05Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day05_test\n 2: invokestatic #12 // Method parseInput:(Ljava/lang/String;)Lkotlin/Pair;\n 5: invokestatic #16 // Method main$part1:(Lkotlin/Pair;)Ljava/lang/String;\n 8: ldc #18 // String CMZ\n 10: invokestatic #24 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 13: ifne 26\n 16: new #26 // class java/lang/IllegalStateException\n 19: dup\n 20: ldc #28 // String Check failed.\n 22: invokespecial #32 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 25: athrow\n 26: ldc #8 // String Day05_test\n 28: invokestatic #12 // Method parseInput:(Ljava/lang/String;)Lkotlin/Pair;\n 31: invokestatic #35 // Method main$part2:(Lkotlin/Pair;)Ljava/lang/String;\n 34: ldc #37 // String MCD\n 36: invokestatic #24 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 39: ifne 52\n 42: new #26 // class java/lang/IllegalStateException\n 45: dup\n 46: ldc #28 // String Check failed.\n 48: invokespecial #32 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 51: athrow\n 52: ldc #39 // String Day05\n 54: invokestatic #12 // Method parseInput:(Ljava/lang/String;)Lkotlin/Pair;\n 57: invokestatic #16 // Method main$part1:(Lkotlin/Pair;)Ljava/lang/String;\n 60: getstatic #45 // Field java/lang/System.out:Ljava/io/PrintStream;\n 63: swap\n 64: invokevirtual #51 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 67: ldc #39 // String Day05\n 69: invokestatic #12 // Method parseInput:(Ljava/lang/String;)Lkotlin/Pair;\n 72: invokestatic #35 // Method main$part2:(Lkotlin/Pair;)Ljava/lang/String;\n 75: getstatic #45 // Field java/lang/System.out:Ljava/io/PrintStream;\n 78: swap\n 79: invokevirtual #51 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 82: return\n\n private static final kotlin.Pair<java.util.List<java.util.List<java.lang.Character>>, java.util.List<StackMove>> parseInput(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #58 // Method UtilsKt.readGroupedInput:(Ljava/lang/String;)Ljava/util/List;\n 4: astore_1\n 5: aload_1\n 6: iconst_0\n 7: invokeinterface #64, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 12: checkcast #66 // class java/lang/String\n 15: astore_2\n 16: aload_1\n 17: iconst_1\n 18: invokeinterface #64, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 23: checkcast #66 // class java/lang/String\n 26: astore_3\n 27: new #68 // class kotlin/Pair\n 30: dup\n 31: aload_2\n 32: invokestatic #71 // Method parseInput$parseStacks:(Ljava/lang/String;)Ljava/util/List;\n 35: aload_3\n 36: invokestatic #74 // Method parseInput$parseMoves:(Ljava/lang/String;)Ljava/util/List;\n 39: invokespecial #77 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 42: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #84 // Method main:()V\n 3: return\n\n private static final java.lang.String main$solve(kotlin.Pair<? extends java.util.List<java.util.List<java.lang.Character>>, ? extends java.util.List<StackMove>>, kotlin.jvm.functions.Function1<? super java.util.List<java.lang.Character>, ? extends java.util.List<java.lang.Character>>);\n Code:\n 0: aload_0\n 1: invokevirtual #93 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 4: checkcast #60 // class java/util/List\n 7: astore_2\n 8: aload_0\n 9: invokevirtual #96 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 12: checkcast #60 // class java/util/List\n 15: astore_3\n 16: aload_3\n 17: checkcast #98 // class java/lang/Iterable\n 20: astore 4\n 22: iconst_0\n 23: istore 5\n 25: aload 4\n 27: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 32: astore 6\n 34: aload 6\n 36: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 41: ifeq 184\n 44: aload 6\n 46: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 51: astore 7\n 53: aload 7\n 55: checkcast #113 // class StackMove\n 58: astore 8\n 60: iconst_0\n 61: istore 9\n 63: aload_2\n 64: aload 8\n 66: invokevirtual #117 // Method StackMove.getTo:()I\n 69: aload_2\n 70: aload 8\n 72: invokevirtual #120 // Method StackMove.getFrom:()I\n 75: invokeinterface #64, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 80: checkcast #98 // class java/lang/Iterable\n 83: aload 8\n 85: invokevirtual #123 // Method StackMove.getAmount:()I\n 88: invokestatic #129 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 91: astore 10\n 93: istore 11\n 95: astore 12\n 97: iconst_0\n 98: istore 13\n 100: aload_1\n 101: aload 10\n 103: invokeinterface #135, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 108: checkcast #60 // class java/util/List\n 111: astore 14\n 113: aload 12\n 115: iload 11\n 117: aload 14\n 119: checkcast #137 // class java/util/Collection\n 122: aload_2\n 123: aload 8\n 125: invokevirtual #117 // Method StackMove.getTo:()I\n 128: invokeinterface #64, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 133: checkcast #98 // class java/lang/Iterable\n 136: invokestatic #141 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 139: invokeinterface #145, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 144: pop\n 145: aload_2\n 146: aload 8\n 148: invokevirtual #120 // Method StackMove.getFrom:()I\n 151: aload_2\n 152: aload 8\n 154: invokevirtual #120 // Method StackMove.getFrom:()I\n 157: invokeinterface #64, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 162: checkcast #98 // class java/lang/Iterable\n 165: aload 8\n 167: invokevirtual #123 // Method StackMove.getAmount:()I\n 170: invokestatic #148 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 173: invokeinterface #145, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 178: pop\n 179: nop\n 180: nop\n 181: goto 34\n 184: nop\n 185: aload_2\n 186: checkcast #98 // class java/lang/Iterable\n 189: astore 4\n 191: iconst_0\n 192: istore 5\n 194: aload 4\n 196: astore 6\n 198: new #150 // class java/util/ArrayList\n 201: dup\n 202: invokespecial #152 // Method java/util/ArrayList.\"<init>\":()V\n 205: checkcast #137 // class java/util/Collection\n 208: astore 7\n 210: iconst_0\n 211: istore 8\n 213: aload 6\n 215: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 220: astore 9\n 222: aload 9\n 224: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 229: ifeq 286\n 232: aload 9\n 234: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 239: astore 10\n 241: aload 10\n 243: checkcast #60 // class java/util/List\n 246: astore 11\n 248: iconst_0\n 249: istore 12\n 251: aload 11\n 253: checkcast #137 // class java/util/Collection\n 256: invokeinterface #155, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 261: ifne 268\n 264: iconst_1\n 265: goto 269\n 268: iconst_0\n 269: nop\n 270: ifeq 222\n 273: aload 7\n 275: aload 10\n 277: invokeinterface #159, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 282: pop\n 283: goto 222\n 286: aload 7\n 288: checkcast #60 // class java/util/List\n 291: nop\n 292: checkcast #98 // class java/lang/Iterable\n 295: astore 4\n 297: nop\n 298: iconst_0\n 299: istore 5\n 301: aload 4\n 303: astore 6\n 305: new #150 // class java/util/ArrayList\n 308: dup\n 309: aload 4\n 311: bipush 10\n 313: invokestatic #163 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 316: invokespecial #166 // Method java/util/ArrayList.\"<init>\":(I)V\n 319: checkcast #137 // class java/util/Collection\n 322: astore 7\n 324: iconst_0\n 325: istore 8\n 327: aload 6\n 329: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 334: astore 9\n 336: aload 9\n 338: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 343: ifeq 395\n 346: aload 9\n 348: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 353: astore 10\n 355: aload 7\n 357: aload 10\n 359: checkcast #60 // class java/util/List\n 362: astore 11\n 364: astore 15\n 366: iconst_0\n 367: istore 12\n 369: aload 11\n 371: invokestatic #170 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 374: checkcast #172 // class java/lang/Character\n 377: invokevirtual #176 // Method java/lang/Character.charValue:()C\n 380: invokestatic #180 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 383: aload 15\n 385: swap\n 386: invokeinterface #159, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 391: pop\n 392: goto 336\n 395: aload 7\n 397: checkcast #60 // class java/util/List\n 400: nop\n 401: checkcast #98 // class java/lang/Iterable\n 404: ldc #182 // String\n 406: checkcast #184 // class java/lang/CharSequence\n 409: aconst_null\n 410: aconst_null\n 411: iconst_0\n 412: aconst_null\n 413: aconst_null\n 414: bipush 62\n 416: aconst_null\n 417: invokestatic #188 // 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 420: areturn\n\n private static final java.util.List main$part1$lambda$4(java.util.List);\n Code:\n 0: aload_0\n 1: ldc #221 // String it\n 3: invokestatic #225 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #98 // class java/lang/Iterable\n 10: invokestatic #229 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 13: areturn\n\n private static final java.lang.String main$part1(kotlin.Pair<? extends java.util.List<java.util.List<java.lang.Character>>, ? extends java.util.List<StackMove>>);\n Code:\n 0: aload_0\n 1: invokedynamic #245, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 6: invokestatic #247 // Method main$solve:(Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ljava/lang/String;\n 9: areturn\n\n private static final java.util.List main$part2$lambda$5(java.util.List);\n Code:\n 0: aload_0\n 1: ldc #221 // String it\n 3: invokestatic #225 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: areturn\n\n private static final java.lang.String main$part2(kotlin.Pair<? extends java.util.List<java.util.List<java.lang.Character>>, ? extends java.util.List<StackMove>>);\n Code:\n 0: aload_0\n 1: invokedynamic #252, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 6: invokestatic #247 // Method main$solve:(Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ljava/lang/String;\n 9: areturn\n\n private static final java.util.List<java.util.List<java.lang.Character>> parseInput$parseStacks(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #184 // class java/lang/CharSequence\n 4: invokestatic #259 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 7: iconst_1\n 8: invokestatic #263 // Method kotlin/collections/CollectionsKt.dropLast:(Ljava/util/List;I)Ljava/util/List;\n 11: checkcast #98 // class java/lang/Iterable\n 14: astore_2\n 15: nop\n 16: iconst_0\n 17: istore_3\n 18: aload_2\n 19: astore 4\n 21: new #150 // class java/util/ArrayList\n 24: dup\n 25: aload_2\n 26: bipush 10\n 28: invokestatic #163 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 31: invokespecial #166 // Method java/util/ArrayList.\"<init>\":(I)V\n 34: checkcast #137 // class java/util/Collection\n 37: astore 5\n 39: iconst_0\n 40: istore 6\n 42: aload 4\n 44: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 49: astore 7\n 51: aload 7\n 53: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 58: ifeq 129\n 61: aload 7\n 63: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 68: astore 8\n 70: aload 5\n 72: aload 8\n 74: checkcast #66 // class java/lang/String\n 77: astore 9\n 79: astore 20\n 81: iconst_0\n 82: istore 10\n 84: aload 9\n 86: ldc_w #265 // String\n 89: ldc_w #267 // String [-]\n 92: iconst_0\n 93: iconst_4\n 94: aconst_null\n 95: invokestatic #271 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 98: new #273 // class kotlin/text/Regex\n 101: dup\n 102: ldc_w #275 // String [^\\\\w-]\n 105: invokespecial #276 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 108: invokestatic #280 // Method UtilsKt.remove:(Ljava/lang/String;Lkotlin/text/Regex;)Ljava/lang/String;\n 111: checkcast #184 // class java/lang/CharSequence\n 114: invokestatic #283 // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;\n 117: aload 20\n 119: swap\n 120: invokeinterface #159, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 125: pop\n 126: goto 51\n 129: aload 5\n 131: checkcast #60 // class java/util/List\n 134: nop\n 135: invokestatic #286 // Method UtilsKt.transpose:(Ljava/util/List;)Ljava/util/List;\n 138: checkcast #98 // class java/lang/Iterable\n 141: astore_2\n 142: nop\n 143: iconst_0\n 144: istore_3\n 145: aload_2\n 146: astore 4\n 148: new #150 // class java/util/ArrayList\n 151: dup\n 152: aload_2\n 153: bipush 10\n 155: invokestatic #163 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 158: invokespecial #166 // Method java/util/ArrayList.\"<init>\":(I)V\n 161: checkcast #137 // class java/util/Collection\n 164: astore 5\n 166: iconst_0\n 167: istore 6\n 169: aload 4\n 171: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 176: astore 7\n 178: aload 7\n 180: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 185: ifeq 333\n 188: aload 7\n 190: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 195: astore 8\n 197: aload 5\n 199: aload 8\n 201: checkcast #60 // class java/util/List\n 204: astore 9\n 206: astore 20\n 208: iconst_0\n 209: istore 10\n 211: aload 9\n 213: checkcast #98 // class java/lang/Iterable\n 216: astore 11\n 218: iconst_0\n 219: istore 12\n 221: aload 11\n 223: astore 13\n 225: new #150 // class java/util/ArrayList\n 228: dup\n 229: invokespecial #152 // Method java/util/ArrayList.\"<init>\":()V\n 232: checkcast #137 // class java/util/Collection\n 235: astore 14\n 237: iconst_0\n 238: istore 15\n 240: aload 13\n 242: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 247: astore 16\n 249: aload 16\n 251: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 256: ifeq 309\n 259: aload 16\n 261: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 266: astore 17\n 268: aload 17\n 270: checkcast #172 // class java/lang/Character\n 273: invokevirtual #176 // Method java/lang/Character.charValue:()C\n 276: istore 18\n 278: iconst_0\n 279: istore 19\n 281: iload 18\n 283: bipush 45\n 285: if_icmpeq 292\n 288: iconst_1\n 289: goto 293\n 292: iconst_0\n 293: ifeq 249\n 296: aload 14\n 298: aload 17\n 300: invokeinterface #159, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 305: pop\n 306: goto 249\n 309: aload 14\n 311: checkcast #60 // class java/util/List\n 314: nop\n 315: checkcast #137 // class java/util/Collection\n 318: invokestatic #290 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 321: aload 20\n 323: swap\n 324: invokeinterface #159, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 329: pop\n 330: goto 178\n 333: aload 5\n 335: checkcast #60 // class java/util/List\n 338: nop\n 339: astore_1\n 340: aload_1\n 341: checkcast #137 // class java/util/Collection\n 344: invokestatic #290 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 347: areturn\n\n private static final int parseInput$parseMoves$lambda$10$lambda$9(kotlin.text.MatchResult);\n Code:\n 0: aload_0\n 1: ldc #221 // String it\n 3: invokestatic #225 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #306, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 12: invokestatic #312 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 15: ireturn\n\n private static final java.util.List<StackMove> parseInput$parseMoves(java.lang.String);\n Code:\n 0: new #273 // class kotlin/text/Regex\n 3: dup\n 4: ldc_w #316 // String (\\\\d+)\n 7: invokespecial #276 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 10: astore_1\n 11: aload_0\n 12: checkcast #184 // class java/lang/CharSequence\n 15: invokestatic #259 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 18: checkcast #98 // class java/lang/Iterable\n 21: astore_2\n 22: nop\n 23: iconst_0\n 24: istore_3\n 25: aload_2\n 26: astore 4\n 28: new #150 // class java/util/ArrayList\n 31: dup\n 32: aload_2\n 33: bipush 10\n 35: invokestatic #163 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 38: invokespecial #166 // Method java/util/ArrayList.\"<init>\":(I)V\n 41: checkcast #137 // class java/util/Collection\n 44: astore 5\n 46: iconst_0\n 47: istore 6\n 49: aload 4\n 51: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 56: astore 7\n 58: aload 7\n 60: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 65: ifeq 126\n 68: aload 7\n 70: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 75: astore 8\n 77: aload 5\n 79: aload 8\n 81: checkcast #66 // class java/lang/String\n 84: astore 9\n 86: astore 14\n 88: iconst_0\n 89: istore 10\n 91: aload_1\n 92: aload 9\n 94: checkcast #184 // class java/lang/CharSequence\n 97: iconst_0\n 98: iconst_2\n 99: aconst_null\n 100: invokestatic #320 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 103: invokedynamic #326, 0 // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;\n 108: invokestatic #332 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 111: invokestatic #335 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 114: aload 14\n 116: swap\n 117: invokeinterface #159, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 122: pop\n 123: goto 58\n 126: aload 5\n 128: checkcast #60 // class java/util/List\n 131: nop\n 132: checkcast #98 // class java/lang/Iterable\n 135: astore_2\n 136: nop\n 137: iconst_0\n 138: istore_3\n 139: aload_2\n 140: astore 4\n 142: new #150 // class java/util/ArrayList\n 145: dup\n 146: aload_2\n 147: bipush 10\n 149: invokestatic #163 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 152: invokespecial #166 // Method java/util/ArrayList.\"<init>\":(I)V\n 155: checkcast #137 // class java/util/Collection\n 158: astore 5\n 160: iconst_0\n 161: istore 6\n 163: aload 4\n 165: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 170: astore 7\n 172: aload 7\n 174: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 179: ifeq 282\n 182: aload 7\n 184: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 189: astore 8\n 191: aload 5\n 193: aload 8\n 195: checkcast #60 // class java/util/List\n 198: astore 9\n 200: astore 14\n 202: iconst_0\n 203: istore 10\n 205: aload 9\n 207: iconst_0\n 208: invokeinterface #64, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 213: checkcast #337 // class java/lang/Number\n 216: invokevirtual #340 // Method java/lang/Number.intValue:()I\n 219: istore 11\n 221: aload 9\n 223: iconst_1\n 224: invokeinterface #64, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 229: checkcast #337 // class java/lang/Number\n 232: invokevirtual #340 // Method java/lang/Number.intValue:()I\n 235: istore 12\n 237: aload 9\n 239: iconst_2\n 240: invokeinterface #64, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 245: checkcast #337 // class java/lang/Number\n 248: invokevirtual #340 // Method java/lang/Number.intValue:()I\n 251: istore 13\n 253: new #113 // class StackMove\n 256: dup\n 257: iload 11\n 259: iload 12\n 261: iconst_1\n 262: isub\n 263: iload 13\n 265: iconst_1\n 266: isub\n 267: invokespecial #343 // Method StackMove.\"<init>\":(III)V\n 270: aload 14\n 272: swap\n 273: invokeinterface #159, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 278: pop\n 279: goto 172\n 282: aload 5\n 284: checkcast #60 // class java/util/List\n 287: nop\n 288: areturn\n}\n",
"javap_err": ""
}
] |
buczebar__advent-of-code__cdb6fe3/src/Day15.kt
|
import kotlin.math.abs
private fun parseInput(name: String) =
readInput(name).map { line ->
line.split(":").map { it.getAllInts().pair() }
}.map { (sensorXY, beaconXY) -> Sensor(sensorXY, beaconXY) }
fun main() {
fun Position.tuningFrequency() = 4000000L * x + y
fun coverageRangesForY(y: Int, sensors: List<Sensor>, valueRange: IntRange): List<IntRange> {
val ranges = mutableListOf<IntRange>()
sensors.forEach { sensor ->
val distanceToY = abs(sensor.y - y)
val radiusForY = (sensor.distanceToClosestBeacon - distanceToY).coerceAtLeast(0)
if (radiusForY > 0) {
ranges.add(((sensor.x - radiusForY)..(sensor.x + radiusForY)).limitValuesInRange(valueRange))
}
}
return ranges
}
fun part1(sensors: List<Sensor>, y: Int): Int {
val xPositionsWithSensorsOrBeacons = sensors
.flatMap { listOf(it.position, it.closestBeacon) }
.filter { it.y == y }
.map { it.x }
.toSet()
val valueRange = sensors.map { it.closestBeacon.x }.valueRange()
val xPositionsWithoutBeacon = coverageRangesForY(y, sensors, valueRange)
.flatMap { it.toList() }
.toSet()
.minus(xPositionsWithSensorsOrBeacons)
return xPositionsWithoutBeacon.size
}
fun part2(sensors: List<Sensor>, valueRange: IntRange): Long {
valueRange.forEach { y ->
val coverageRanges = coverageRangesForY(y, sensors, valueRange).sortedBy { it.first }
var rightBoundary = coverageRanges.first().last
for (i in 1 until coverageRanges.size) {
val range = coverageRanges[i]
if (rightBoundary < range.first) {
return Position(rightBoundary + 1, y).tuningFrequency()
}
rightBoundary = range.last.coerceAtLeast(rightBoundary)
}
}
return 0L
}
val testInput = parseInput("Day15_test")
check(part1(testInput, 10) == 26)
check(part2(testInput, 0..20) == 56000011L)
val input = parseInput("Day15")
println(part1(input, 2000000))
println(part2(input, 0..4000000))
}
private data class Sensor(val position: Position, val closestBeacon: Position) {
val x: Int
get() = position.x
val y: Int
get() = position.y
val distanceToClosestBeacon: Int
get() = position.manhattanDistanceTo(closestBeacon)
}
|
[
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day15Kt.class",
"javap": "Compiled from \"Day15.kt\"\npublic final class Day15Kt {\n private static final java.util.List<Sensor> parseInput(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #12 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 4: checkcast #14 // class java/lang/Iterable\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: astore_3\n 12: new #16 // class java/util/ArrayList\n 15: dup\n 16: aload_1\n 17: bipush 10\n 19: invokestatic #22 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 22: invokespecial #26 // Method java/util/ArrayList.\"<init>\":(I)V\n 25: checkcast #28 // class java/util/Collection\n 28: astore 4\n 30: iconst_0\n 31: istore 5\n 33: aload_3\n 34: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 6\n 41: aload 6\n 43: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 216\n 51: aload 6\n 53: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 7\n 60: aload 4\n 62: aload 7\n 64: checkcast #44 // class java/lang/String\n 67: astore 8\n 69: astore 20\n 71: iconst_0\n 72: istore 9\n 74: aload 8\n 76: checkcast #46 // class java/lang/CharSequence\n 79: iconst_1\n 80: anewarray #44 // class java/lang/String\n 83: astore 10\n 85: aload 10\n 87: iconst_0\n 88: ldc #48 // String :\n 90: aastore\n 91: aload 10\n 93: iconst_0\n 94: iconst_0\n 95: bipush 6\n 97: aconst_null\n 98: invokestatic #54 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 101: checkcast #14 // class java/lang/Iterable\n 104: astore 10\n 106: iconst_0\n 107: istore 11\n 109: aload 10\n 111: astore 12\n 113: new #16 // class java/util/ArrayList\n 116: dup\n 117: aload 10\n 119: bipush 10\n 121: invokestatic #22 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 124: invokespecial #26 // Method java/util/ArrayList.\"<init>\":(I)V\n 127: checkcast #28 // class java/util/Collection\n 130: astore 13\n 132: iconst_0\n 133: istore 14\n 135: aload 12\n 137: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 142: astore 15\n 144: aload 15\n 146: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 151: ifeq 197\n 154: aload 15\n 156: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 161: astore 16\n 163: aload 13\n 165: aload 16\n 167: checkcast #44 // class java/lang/String\n 170: astore 17\n 172: astore 18\n 174: iconst_0\n 175: istore 19\n 177: aload 17\n 179: invokestatic #57 // Method UtilsKt.getAllInts:(Ljava/lang/String;)Ljava/util/List;\n 182: invokestatic #61 // Method UtilsKt.pair:(Ljava/util/List;)Lkotlin/Pair;\n 185: aload 18\n 187: swap\n 188: invokeinterface #65, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 193: pop\n 194: goto 144\n 197: aload 13\n 199: checkcast #67 // class java/util/List\n 202: nop\n 203: nop\n 204: aload 20\n 206: swap\n 207: invokeinterface #65, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 212: pop\n 213: goto 41\n 216: aload 4\n 218: checkcast #67 // class java/util/List\n 221: nop\n 222: checkcast #14 // class java/lang/Iterable\n 225: astore_1\n 226: nop\n 227: iconst_0\n 228: istore_2\n 229: aload_1\n 230: astore_3\n 231: new #16 // class java/util/ArrayList\n 234: dup\n 235: aload_1\n 236: bipush 10\n 238: invokestatic #22 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 241: invokespecial #26 // Method java/util/ArrayList.\"<init>\":(I)V\n 244: checkcast #28 // class java/util/Collection\n 247: astore 4\n 249: iconst_0\n 250: istore 5\n 252: aload_3\n 253: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 258: astore 6\n 260: aload 6\n 262: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 267: ifeq 342\n 270: aload 6\n 272: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 277: astore 7\n 279: aload 4\n 281: aload 7\n 283: checkcast #67 // class java/util/List\n 286: astore 8\n 288: astore 20\n 290: iconst_0\n 291: istore 9\n 293: aload 8\n 295: iconst_0\n 296: invokeinterface #71, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 301: checkcast #73 // class kotlin/Pair\n 304: astore 10\n 306: aload 8\n 308: iconst_1\n 309: invokeinterface #71, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 314: checkcast #73 // class kotlin/Pair\n 317: astore 11\n 319: new #75 // class Sensor\n 322: dup\n 323: aload 10\n 325: aload 11\n 327: invokespecial #78 // Method Sensor.\"<init>\":(Lkotlin/Pair;Lkotlin/Pair;)V\n 330: aload 20\n 332: swap\n 333: invokeinterface #65, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 338: pop\n 339: goto 260\n 342: aload 4\n 344: checkcast #67 // class java/util/List\n 347: nop\n 348: areturn\n\n public static final void main();\n Code:\n 0: ldc #102 // String Day15_test\n 2: invokestatic #104 // Method parseInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: bipush 10\n 9: invokestatic #108 // Method main$part1:(Ljava/util/List;I)I\n 12: bipush 26\n 14: if_icmpne 21\n 17: iconst_1\n 18: goto 22\n 21: iconst_0\n 22: ifne 35\n 25: new #110 // class java/lang/IllegalStateException\n 28: dup\n 29: ldc #112 // String Check failed.\n 31: invokespecial #115 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 34: athrow\n 35: aload_0\n 36: new #117 // class kotlin/ranges/IntRange\n 39: dup\n 40: iconst_0\n 41: bipush 20\n 43: invokespecial #120 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 46: invokestatic #124 // Method main$part2:(Ljava/util/List;Lkotlin/ranges/IntRange;)J\n 49: ldc2_w #125 // long 56000011l\n 52: lcmp\n 53: ifne 60\n 56: iconst_1\n 57: goto 61\n 60: iconst_0\n 61: ifne 74\n 64: new #110 // class java/lang/IllegalStateException\n 67: dup\n 68: ldc #112 // String Check failed.\n 70: invokespecial #115 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 73: athrow\n 74: ldc #128 // String Day15\n 76: invokestatic #104 // Method parseInput:(Ljava/lang/String;)Ljava/util/List;\n 79: astore_1\n 80: aload_1\n 81: ldc #129 // int 2000000\n 83: invokestatic #108 // Method main$part1:(Ljava/util/List;I)I\n 86: istore_2\n 87: getstatic #135 // Field java/lang/System.out:Ljava/io/PrintStream;\n 90: iload_2\n 91: invokevirtual #140 // Method java/io/PrintStream.println:(I)V\n 94: aload_1\n 95: new #117 // class kotlin/ranges/IntRange\n 98: dup\n 99: iconst_0\n 100: ldc #141 // int 4000000\n 102: invokespecial #120 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 105: invokestatic #124 // Method main$part2:(Ljava/util/List;Lkotlin/ranges/IntRange;)J\n 108: lstore_2\n 109: getstatic #135 // Field java/lang/System.out:Ljava/io/PrintStream;\n 112: lload_2\n 113: invokevirtual #144 // Method java/io/PrintStream.println:(J)V\n 116: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #150 // Method main:()V\n 3: return\n\n private static final long main$tuningFrequency(kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: ldc2_w #156 // long 4000000l\n 3: aload_0\n 4: invokestatic #161 // Method UtilsKt.getX:(Lkotlin/Pair;)I\n 7: i2l\n 8: lmul\n 9: aload_0\n 10: invokestatic #164 // Method UtilsKt.getY:(Lkotlin/Pair;)I\n 13: i2l\n 14: ladd\n 15: lreturn\n\n private static final java.util.List<kotlin.ranges.IntRange> main$coverageRangesForY(int, java.util.List<Sensor>, kotlin.ranges.IntRange);\n Code:\n 0: new #16 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #170 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #67 // class java/util/List\n 10: astore_3\n 11: aload_1\n 12: checkcast #14 // class java/lang/Iterable\n 15: astore 4\n 17: iconst_0\n 18: istore 5\n 20: aload 4\n 22: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 27: astore 6\n 29: aload 6\n 31: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 36: ifeq 128\n 39: aload 6\n 41: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 46: astore 7\n 48: aload 7\n 50: checkcast #75 // class Sensor\n 53: astore 8\n 55: iconst_0\n 56: istore 9\n 58: aload 8\n 60: invokevirtual #173 // Method Sensor.getY:()I\n 63: iload_0\n 64: isub\n 65: invokestatic #179 // Method java/lang/Math.abs:(I)I\n 68: istore 10\n 70: aload 8\n 72: invokevirtual #182 // Method Sensor.getDistanceToClosestBeacon:()I\n 75: iload 10\n 77: isub\n 78: iconst_0\n 79: invokestatic #188 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 82: istore 11\n 84: iload 11\n 86: ifle 123\n 89: aload_3\n 90: new #117 // class kotlin/ranges/IntRange\n 93: dup\n 94: aload 8\n 96: invokevirtual #190 // Method Sensor.getX:()I\n 99: iload 11\n 101: isub\n 102: aload 8\n 104: invokevirtual #190 // Method Sensor.getX:()I\n 107: iload 11\n 109: iadd\n 110: invokespecial #120 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 113: aload_2\n 114: invokestatic #194 // Method UtilsKt.limitValuesInRange:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Lkotlin/ranges/IntRange;\n 117: invokeinterface #195, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 122: pop\n 123: nop\n 124: nop\n 125: goto 29\n 128: nop\n 129: aload_3\n 130: areturn\n\n private static final int main$part1(java.util.List<Sensor>, int);\n Code:\n 0: aload_0\n 1: checkcast #14 // class java/lang/Iterable\n 4: astore_3\n 5: nop\n 6: iconst_0\n 7: istore 4\n 9: aload_3\n 10: astore 5\n 12: new #16 // class java/util/ArrayList\n 15: dup\n 16: invokespecial #170 // Method java/util/ArrayList.\"<init>\":()V\n 19: checkcast #28 // class java/util/Collection\n 22: astore 6\n 24: iconst_0\n 25: istore 7\n 27: aload 5\n 29: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 34: astore 8\n 36: aload 8\n 38: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 43: ifeq 110\n 46: aload 8\n 48: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 53: astore 9\n 55: aload 9\n 57: checkcast #75 // class Sensor\n 60: astore 10\n 62: iconst_0\n 63: istore 11\n 65: iconst_2\n 66: anewarray #73 // class kotlin/Pair\n 69: astore 12\n 71: aload 12\n 73: iconst_0\n 74: aload 10\n 76: invokevirtual #213 // Method Sensor.getPosition:()Lkotlin/Pair;\n 79: aastore\n 80: aload 12\n 82: iconst_1\n 83: aload 10\n 85: invokevirtual #216 // Method Sensor.getClosestBeacon:()Lkotlin/Pair;\n 88: aastore\n 89: aload 12\n 91: invokestatic #220 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 94: checkcast #14 // class java/lang/Iterable\n 97: astore 10\n 99: aload 6\n 101: aload 10\n 103: invokestatic #224 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 106: pop\n 107: goto 36\n 110: aload 6\n 112: checkcast #67 // class java/util/List\n 115: nop\n 116: checkcast #14 // class java/lang/Iterable\n 119: astore_3\n 120: nop\n 121: iconst_0\n 122: istore 4\n 124: aload_3\n 125: astore 5\n 127: new #16 // class java/util/ArrayList\n 130: dup\n 131: invokespecial #170 // Method java/util/ArrayList.\"<init>\":()V\n 134: checkcast #28 // class java/util/Collection\n 137: astore 6\n 139: iconst_0\n 140: istore 7\n 142: aload 5\n 144: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 149: astore 8\n 151: aload 8\n 153: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 158: ifeq 210\n 161: aload 8\n 163: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 168: astore 9\n 170: aload 9\n 172: checkcast #73 // class kotlin/Pair\n 175: astore 10\n 177: iconst_0\n 178: istore 11\n 180: aload 10\n 182: invokestatic #164 // Method UtilsKt.getY:(Lkotlin/Pair;)I\n 185: iload_1\n 186: if_icmpne 193\n 189: iconst_1\n 190: goto 194\n 193: iconst_0\n 194: ifeq 151\n 197: aload 6\n 199: aload 9\n 201: invokeinterface #65, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 206: pop\n 207: goto 151\n 210: aload 6\n 212: checkcast #67 // class java/util/List\n 215: nop\n 216: checkcast #14 // class java/lang/Iterable\n 219: astore_3\n 220: nop\n 221: iconst_0\n 222: istore 4\n 224: aload_3\n 225: astore 5\n 227: new #16 // class java/util/ArrayList\n 230: dup\n 231: aload_3\n 232: bipush 10\n 234: invokestatic #22 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 237: invokespecial #26 // Method java/util/ArrayList.\"<init>\":(I)V\n 240: checkcast #28 // class java/util/Collection\n 243: astore 6\n 245: iconst_0\n 246: istore 7\n 248: aload 5\n 250: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 255: astore 8\n 257: aload 8\n 259: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 264: ifeq 310\n 267: aload 8\n 269: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 274: astore 9\n 276: aload 6\n 278: aload 9\n 280: checkcast #73 // class kotlin/Pair\n 283: astore 10\n 285: astore 14\n 287: iconst_0\n 288: istore 11\n 290: aload 10\n 292: invokestatic #161 // Method UtilsKt.getX:(Lkotlin/Pair;)I\n 295: invokestatic #230 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 298: aload 14\n 300: swap\n 301: invokeinterface #65, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 306: pop\n 307: goto 257\n 310: aload 6\n 312: checkcast #67 // class java/util/List\n 315: nop\n 316: checkcast #14 // class java/lang/Iterable\n 319: invokestatic #234 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 322: astore_2\n 323: aload_0\n 324: checkcast #14 // class java/lang/Iterable\n 327: astore 4\n 329: iconst_0\n 330: istore 5\n 332: aload 4\n 334: astore 6\n 336: new #16 // class java/util/ArrayList\n 339: dup\n 340: aload 4\n 342: bipush 10\n 344: invokestatic #22 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 347: invokespecial #26 // Method java/util/ArrayList.\"<init>\":(I)V\n 350: checkcast #28 // class java/util/Collection\n 353: astore 7\n 355: iconst_0\n 356: istore 8\n 358: aload 6\n 360: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 365: astore 9\n 367: aload 9\n 369: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 374: ifeq 423\n 377: aload 9\n 379: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 384: astore 10\n 386: aload 7\n 388: aload 10\n 390: checkcast #75 // class Sensor\n 393: astore 11\n 395: astore 14\n 397: iconst_0\n 398: istore 12\n 400: aload 11\n 402: invokevirtual #216 // Method Sensor.getClosestBeacon:()Lkotlin/Pair;\n 405: invokestatic #161 // Method UtilsKt.getX:(Lkotlin/Pair;)I\n 408: invokestatic #230 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 411: aload 14\n 413: swap\n 414: invokeinterface #65, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 419: pop\n 420: goto 367\n 423: aload 7\n 425: checkcast #67 // class java/util/List\n 428: nop\n 429: invokestatic #237 // Method UtilsKt.valueRange:(Ljava/util/List;)Lkotlin/ranges/IntRange;\n 432: astore_3\n 433: iload_1\n 434: aload_0\n 435: aload_3\n 436: invokestatic #239 // Method main$coverageRangesForY:(ILjava/util/List;Lkotlin/ranges/IntRange;)Ljava/util/List;\n 439: checkcast #14 // class java/lang/Iterable\n 442: astore 5\n 444: nop\n 445: iconst_0\n 446: istore 6\n 448: aload 5\n 450: astore 7\n 452: new #16 // class java/util/ArrayList\n 455: dup\n 456: invokespecial #170 // Method java/util/ArrayList.\"<init>\":()V\n 459: checkcast #28 // class java/util/Collection\n 462: astore 8\n 464: iconst_0\n 465: istore 9\n 467: aload 7\n 469: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 474: astore 10\n 476: aload 10\n 478: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 483: ifeq 529\n 486: aload 10\n 488: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 493: astore 11\n 495: aload 11\n 497: checkcast #117 // class kotlin/ranges/IntRange\n 500: astore 12\n 502: iconst_0\n 503: istore 13\n 505: aload 12\n 507: checkcast #14 // class java/lang/Iterable\n 510: invokestatic #243 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 513: checkcast #14 // class java/lang/Iterable\n 516: astore 12\n 518: aload 8\n 520: aload 12\n 522: invokestatic #224 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 525: pop\n 526: goto 476\n 529: aload 8\n 531: checkcast #67 // class java/util/List\n 534: nop\n 535: checkcast #14 // class java/lang/Iterable\n 538: invokestatic #234 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 541: aload_2\n 542: checkcast #14 // class java/lang/Iterable\n 545: invokestatic #249 // Method kotlin/collections/SetsKt.minus:(Ljava/util/Set;Ljava/lang/Iterable;)Ljava/util/Set;\n 548: astore 4\n 550: aload 4\n 552: invokeinterface #254, 1 // InterfaceMethod java/util/Set.size:()I\n 557: ireturn\n\n private static final long main$part2(java.util.List<Sensor>, kotlin.ranges.IntRange);\n Code:\n 0: aload_1\n 1: checkcast #14 // class java/lang/Iterable\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: aload_2\n 8: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore 4\n 15: aload 4\n 17: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 22: ifeq 176\n 25: aload 4\n 27: checkcast #275 // class kotlin/collections/IntIterator\n 30: invokevirtual #278 // Method kotlin/collections/IntIterator.nextInt:()I\n 33: istore 5\n 35: iload 5\n 37: istore 6\n 39: iconst_0\n 40: istore 7\n 42: iload 6\n 44: aload_0\n 45: aload_1\n 46: invokestatic #239 // Method main$coverageRangesForY:(ILjava/util/List;Lkotlin/ranges/IntRange;)Ljava/util/List;\n 49: checkcast #14 // class java/lang/Iterable\n 52: astore 8\n 54: iconst_0\n 55: istore 9\n 57: aload 8\n 59: new #280 // class Day15Kt$main$part2$lambda$10$$inlined$sortedBy$1\n 62: dup\n 63: invokespecial #281 // Method Day15Kt$main$part2$lambda$10$$inlined$sortedBy$1.\"<init>\":()V\n 66: checkcast #283 // class java/util/Comparator\n 69: invokestatic #287 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 72: astore 10\n 74: aload 10\n 76: invokestatic #291 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 79: checkcast #117 // class kotlin/ranges/IntRange\n 82: invokevirtual #294 // Method kotlin/ranges/IntRange.getLast:()I\n 85: istore 8\n 87: iconst_1\n 88: istore 9\n 90: aload 10\n 92: invokeinterface #295, 1 // InterfaceMethod java/util/List.size:()I\n 97: istore 11\n 99: iload 9\n 101: iload 11\n 103: if_icmpge 171\n 106: aload 10\n 108: iload 9\n 110: invokeinterface #71, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 115: checkcast #117 // class kotlin/ranges/IntRange\n 118: astore 12\n 120: iload 8\n 122: aload 12\n 124: invokevirtual #298 // Method kotlin/ranges/IntRange.getFirst:()I\n 127: if_icmpge 153\n 130: new #73 // class kotlin/Pair\n 133: dup\n 134: iload 8\n 136: iconst_1\n 137: iadd\n 138: invokestatic #230 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 141: iload 6\n 143: invokestatic #230 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 146: invokespecial #301 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 149: invokestatic #303 // Method main$tuningFrequency:(Lkotlin/Pair;)J\n 152: lreturn\n 153: aload 12\n 155: invokevirtual #294 // Method kotlin/ranges/IntRange.getLast:()I\n 158: iload 8\n 160: invokestatic #188 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 163: istore 8\n 165: iinc 9, 1\n 168: goto 99\n 171: nop\n 172: nop\n 173: goto 15\n 176: nop\n 177: lconst_0\n 178: lreturn\n}\n",
"javap_err": ""
},
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day15Kt$main$part2$lambda$10$$inlined$sortedBy$1.class",
"javap": "Compiled from \"Comparisons.kt\"\npublic final class Day15Kt$main$part2$lambda$10$$inlined$sortedBy$1<T> implements java.util.Comparator {\n public Day15Kt$main$part2$lambda$10$$inlined$sortedBy$1();\n Code:\n 0: aload_0\n 1: invokespecial #16 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int compare(T, T);\n Code:\n 0: aload_1\n 1: checkcast #23 // class kotlin/ranges/IntRange\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method kotlin/ranges/IntRange.getFirst:()I\n 12: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 15: checkcast #35 // class java/lang/Comparable\n 18: aload_2\n 19: checkcast #23 // class kotlin/ranges/IntRange\n 22: astore_3\n 23: astore 5\n 25: iconst_0\n 26: istore 4\n 28: aload_3\n 29: invokevirtual #27 // Method kotlin/ranges/IntRange.getFirst:()I\n 32: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 35: aload 5\n 37: swap\n 38: checkcast #35 // class java/lang/Comparable\n 41: invokestatic #41 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I\n 44: ireturn\n}\n",
"javap_err": ""
}
] |
buczebar__advent-of-code__cdb6fe3/src/Day06.kt
|
fun main() {
fun solve(input: String, distLength: Int) =
input.indexOf(input.windowed(distLength).first { it.toList().allDistinct()}) + distLength
fun part1(input: String) = solve(input, 4)
fun part2(input: String) = solve(input, 14)
val testInput = readInput("Day06_test")
val testResults = listOf(
7 to 19, // mjqjpqmgbljsphdztnvjfqwrcgsmlb
5 to 23, // bvwbjplbgvbhsrlpgdmjqwftvncz
6 to 23, // nppdvjthqldpwncqszvftbrmjlhg
10 to 29, // nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg
11 to 26 // zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw
)
testInput.zip(testResults).forEach { (input, results) ->
check(part1(input) == results.first)
check(part2(input) == results.second)
}
val input = readInput("Day06").first()
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day06Kt.class",
"javap": "Compiled from \"Day06.kt\"\npublic final class Day06Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day06_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: iconst_5\n 7: anewarray #16 // class kotlin/Pair\n 10: astore_2\n 11: aload_2\n 12: iconst_0\n 13: bipush 7\n 15: invokestatic #22 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 18: bipush 19\n 20: invokestatic #22 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 23: invokestatic #28 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 26: aastore\n 27: aload_2\n 28: iconst_1\n 29: iconst_5\n 30: invokestatic #22 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 33: bipush 23\n 35: invokestatic #22 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 38: invokestatic #28 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 41: aastore\n 42: aload_2\n 43: iconst_2\n 44: bipush 6\n 46: invokestatic #22 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 49: bipush 23\n 51: invokestatic #22 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 54: invokestatic #28 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 57: aastore\n 58: aload_2\n 59: iconst_3\n 60: bipush 10\n 62: invokestatic #22 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 65: bipush 29\n 67: invokestatic #22 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 70: invokestatic #28 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 73: aastore\n 74: aload_2\n 75: iconst_4\n 76: bipush 11\n 78: invokestatic #22 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 81: bipush 26\n 83: invokestatic #22 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 86: invokestatic #28 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 89: aastore\n 90: aload_2\n 91: invokestatic #34 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 94: astore_1\n 95: aload_0\n 96: checkcast #36 // class java/lang/Iterable\n 99: aload_1\n 100: checkcast #36 // class java/lang/Iterable\n 103: invokestatic #40 // Method kotlin/collections/CollectionsKt.zip:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;\n 106: checkcast #36 // class java/lang/Iterable\n 109: astore_2\n 110: iconst_0\n 111: istore_3\n 112: aload_2\n 113: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 118: astore 4\n 120: aload 4\n 122: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 127: ifeq 248\n 130: aload 4\n 132: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 137: astore 5\n 139: aload 5\n 141: checkcast #16 // class kotlin/Pair\n 144: astore 6\n 146: iconst_0\n 147: istore 7\n 149: aload 6\n 151: invokevirtual #57 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 154: checkcast #59 // class java/lang/String\n 157: astore 8\n 159: aload 6\n 161: invokevirtual #62 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 164: checkcast #16 // class kotlin/Pair\n 167: astore 9\n 169: aload 8\n 171: invokestatic #66 // Method main$part1:(Ljava/lang/String;)I\n 174: aload 9\n 176: invokevirtual #69 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 179: checkcast #71 // class java/lang/Number\n 182: invokevirtual #75 // Method java/lang/Number.intValue:()I\n 185: if_icmpne 192\n 188: iconst_1\n 189: goto 193\n 192: iconst_0\n 193: ifne 206\n 196: new #77 // class java/lang/IllegalStateException\n 199: dup\n 200: ldc #79 // String Check failed.\n 202: invokespecial #83 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 205: athrow\n 206: aload 8\n 208: invokestatic #86 // Method main$part2:(Ljava/lang/String;)I\n 211: aload 9\n 213: invokevirtual #89 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 216: checkcast #71 // class java/lang/Number\n 219: invokevirtual #75 // Method java/lang/Number.intValue:()I\n 222: if_icmpne 229\n 225: iconst_1\n 226: goto 230\n 229: iconst_0\n 230: ifne 243\n 233: new #77 // class java/lang/IllegalStateException\n 236: dup\n 237: ldc #79 // String Check failed.\n 239: invokespecial #83 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 242: athrow\n 243: nop\n 244: nop\n 245: goto 120\n 248: nop\n 249: ldc #91 // String Day06\n 251: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 254: invokestatic #95 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 257: checkcast #59 // class java/lang/String\n 260: astore_2\n 261: aload_2\n 262: invokestatic #66 // Method main$part1:(Ljava/lang/String;)I\n 265: istore_3\n 266: getstatic #101 // Field java/lang/System.out:Ljava/io/PrintStream;\n 269: iload_3\n 270: invokevirtual #107 // Method java/io/PrintStream.println:(I)V\n 273: aload_2\n 274: invokestatic #86 // Method main$part2:(Ljava/lang/String;)I\n 277: istore_3\n 278: getstatic #101 // Field java/lang/System.out:Ljava/io/PrintStream;\n 281: iload_3\n 282: invokevirtual #107 // Method java/io/PrintStream.println:(I)V\n 285: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #126 // Method main:()V\n 3: return\n\n private static final int main$solve(java.lang.String, int);\n Code:\n 0: aload_0\n 1: checkcast #132 // class java/lang/CharSequence\n 4: aload_0\n 5: checkcast #132 // class java/lang/CharSequence\n 8: iload_1\n 9: iconst_0\n 10: iconst_0\n 11: bipush 6\n 13: aconst_null\n 14: invokestatic #138 // Method kotlin/text/StringsKt.windowed$default:(Ljava/lang/CharSequence;IIZILjava/lang/Object;)Ljava/util/List;\n 17: checkcast #36 // class java/lang/Iterable\n 20: astore_2\n 21: astore 8\n 23: iconst_0\n 24: istore_3\n 25: aload_2\n 26: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 31: astore 4\n 33: aload 4\n 35: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 40: ifeq 81\n 43: aload 4\n 45: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 50: astore 5\n 52: aload 5\n 54: checkcast #59 // class java/lang/String\n 57: astore 6\n 59: iconst_0\n 60: istore 7\n 62: aload 6\n 64: checkcast #132 // class java/lang/CharSequence\n 67: invokestatic #142 // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;\n 70: invokestatic #146 // Method UtilsKt.allDistinct:(Ljava/util/List;)Z\n 73: ifeq 33\n 76: aload 5\n 78: goto 91\n 81: new #148 // class java/util/NoSuchElementException\n 84: dup\n 85: ldc #150 // String Collection contains no element matching the predicate.\n 87: invokespecial #151 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 90: athrow\n 91: aload 8\n 93: swap\n 94: checkcast #59 // class java/lang/String\n 97: iconst_0\n 98: iconst_0\n 99: bipush 6\n 101: aconst_null\n 102: invokestatic #155 // Method kotlin/text/StringsKt.indexOf$default:(Ljava/lang/CharSequence;Ljava/lang/String;IZILjava/lang/Object;)I\n 105: iload_1\n 106: iadd\n 107: ireturn\n\n private static final int main$part1(java.lang.String);\n Code:\n 0: aload_0\n 1: iconst_4\n 2: invokestatic #162 // Method main$solve:(Ljava/lang/String;I)I\n 5: ireturn\n\n private static final int main$part2(java.lang.String);\n Code:\n 0: aload_0\n 1: bipush 14\n 3: invokestatic #162 // Method main$solve:(Ljava/lang/String;I)I\n 6: ireturn\n}\n",
"javap_err": ""
}
] |
buczebar__advent-of-code__cdb6fe3/src/Day16.kt
|
fun main() {
lateinit var flowRates: Map<String, Int>
lateinit var connections: Map<String, List<String>>
lateinit var workingValves: List<String>
lateinit var distances: Map<Pair<String, String>, Int>
fun getDistanceToValve(
current: String,
destination: String,
visited: List<String> = emptyList(),
depth: Int = 1
): Int {
val nextValves =
(connections[current]!!).filter { !visited.contains(it) }.takeIf { it.isNotEmpty() }
?: return Int.MAX_VALUE
return if (nextValves.contains(destination)) {
depth
} else {
val newVisited = visited + current
nextValves.minOf { getDistanceToValve(it, destination, newVisited, depth + 1) }
}
}
fun parseInput(fileName: String) {
val valves = mutableMapOf<String, Int>()
val tunnels = mutableMapOf<String, List<String>>()
readInput(fileName)
.map { it.split(";") }
.forEach { (valveRaw, tunnelsRaw) ->
val label = valveRaw.getAllByRegex("[A-Z][A-Z]".toRegex()).single()
val flowRate = valveRaw.getAllInts().single()
val accessibleValves = tunnelsRaw.getAllByRegex("[A-Z][A-Z]".toRegex())
valves[label] = flowRate
tunnels[label] = accessibleValves
}
flowRates = valves
connections = tunnels
workingValves = flowRates.keys.filter { flowRates[it]!! > 0 }
}
fun calculateDistancesBetweenValves(valves: List<String>): Map<Pair<String, String>, Int> {
val resultDistances = mutableMapOf<Pair<String, String>, Int>()
for (start in valves) {
for (end in valves) {
resultDistances[start to end] = getDistanceToValve(start, end)
}
}
return resultDistances
}
fun maxPath(node: String, countDown: Int, opened: Set<String> = emptySet(), pressure: Int = 0): Int {
val nextOpened = opened + node
val openedFlowRate = nextOpened.sumOf { flowRates[it]!! }
return distances
.filter { (path, distance) -> path.first == node && !opened.contains(path.second) && distance <= countDown - 1 }
.map { (path, distance) -> Pair(path.second, distance) }
.map { (nextNode, distance) ->
val nextCountDown = countDown - distance - 1
val nextPressure = pressure + (distance + 1) * openedFlowRate
maxPath(nextNode, nextCountDown, nextOpened, nextPressure)
}.plus(pressure + countDown * openedFlowRate)
.max()
}
fun part1(): Int {
val startingValve = "AA"
distances = calculateDistancesBetweenValves(workingValves + startingValve)
return maxPath(startingValve, 30)
}
parseInput("Day16_test")
check(part1() == 1651)
parseInput("Day16")
println(part1())
}
|
[
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day16Kt.class",
"javap": "Compiled from \"Day16.kt\"\npublic final class Day16Kt {\n public static final void main();\n Code:\n 0: new #8 // class kotlin/jvm/internal/Ref$ObjectRef\n 3: dup\n 4: invokespecial #11 // Method kotlin/jvm/internal/Ref$ObjectRef.\"<init>\":()V\n 7: astore_0\n 8: new #8 // class kotlin/jvm/internal/Ref$ObjectRef\n 11: dup\n 12: invokespecial #11 // Method kotlin/jvm/internal/Ref$ObjectRef.\"<init>\":()V\n 15: astore_1\n 16: new #8 // class kotlin/jvm/internal/Ref$ObjectRef\n 19: dup\n 20: invokespecial #11 // Method kotlin/jvm/internal/Ref$ObjectRef.\"<init>\":()V\n 23: astore_2\n 24: new #8 // class kotlin/jvm/internal/Ref$ObjectRef\n 27: dup\n 28: invokespecial #11 // Method kotlin/jvm/internal/Ref$ObjectRef.\"<init>\":()V\n 31: astore_3\n 32: aload_0\n 33: aload_1\n 34: aload_2\n 35: ldc #13 // String Day16_test\n 37: invokestatic #17 // Method main$parseInput:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;)V\n 40: aload_3\n 41: aload_2\n 42: aload_1\n 43: aload_0\n 44: invokestatic #21 // Method main$part1:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;)I\n 47: sipush 1651\n 50: if_icmpne 57\n 53: iconst_1\n 54: goto 58\n 57: iconst_0\n 58: ifne 71\n 61: new #23 // class java/lang/IllegalStateException\n 64: dup\n 65: ldc #25 // String Check failed.\n 67: invokespecial #28 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 70: athrow\n 71: aload_0\n 72: aload_1\n 73: aload_2\n 74: ldc #30 // String Day16\n 76: invokestatic #17 // Method main$parseInput:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;)V\n 79: aload_3\n 80: aload_2\n 81: aload_1\n 82: aload_0\n 83: invokestatic #21 // Method main$part1:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;)I\n 86: istore 4\n 88: getstatic #36 // Field java/lang/System.out:Ljava/io/PrintStream;\n 91: iload 4\n 93: invokevirtual #42 // Method java/io/PrintStream.println:(I)V\n 96: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #50 // Method main:()V\n 3: return\n\n private static final int main$getDistanceToValve(kotlin.jvm.internal.Ref$ObjectRef<java.util.Map<java.lang.String, java.util.List<java.lang.String>>>, java.lang.String, java.lang.String, java.util.List<java.lang.String>, int);\n Code:\n 0: aload_0\n 1: getfield #59 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 4: ifnonnull 16\n 7: ldc #60 // String connections\n 9: invokestatic #65 // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V\n 12: aconst_null\n 13: goto 23\n 16: aload_0\n 17: getfield #59 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 20: checkcast #67 // class java/util/Map\n 23: aload_1\n 24: invokeinterface #71, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 29: dup\n 30: invokestatic #75 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 33: checkcast #77 // class java/lang/Iterable\n 36: astore 7\n 38: iconst_0\n 39: istore 8\n 41: aload 7\n 43: astore 9\n 45: new #79 // class java/util/ArrayList\n 48: dup\n 49: invokespecial #80 // Method java/util/ArrayList.\"<init>\":()V\n 52: checkcast #82 // class java/util/Collection\n 55: astore 10\n 57: iconst_0\n 58: istore 11\n 60: aload 9\n 62: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 67: astore 12\n 69: aload 12\n 71: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 76: ifeq 130\n 79: aload 12\n 81: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 86: astore 13\n 88: aload 13\n 90: checkcast #98 // class java/lang/String\n 93: astore 14\n 95: iconst_0\n 96: istore 15\n 98: aload_3\n 99: aload 14\n 101: invokeinterface #104, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 106: ifne 113\n 109: iconst_1\n 110: goto 114\n 113: iconst_0\n 114: ifeq 69\n 117: aload 10\n 119: aload 13\n 121: invokeinterface #107, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 126: pop\n 127: goto 69\n 130: aload 10\n 132: checkcast #100 // class java/util/List\n 135: nop\n 136: astore 7\n 138: aload 7\n 140: astore 8\n 142: iconst_0\n 143: istore 9\n 145: aload 8\n 147: checkcast #82 // class java/util/Collection\n 150: invokeinterface #110, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 155: ifne 162\n 158: iconst_1\n 159: goto 163\n 162: iconst_0\n 163: nop\n 164: ifeq 172\n 167: aload 7\n 169: goto 173\n 172: aconst_null\n 173: dup\n 174: ifnonnull 181\n 177: pop\n 178: ldc #111 // int 2147483647\n 180: ireturn\n 181: astore 5\n 183: aload 5\n 185: aload_2\n 186: invokeinterface #104, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 191: ifeq 199\n 194: iload 4\n 196: goto 325\n 199: aload_3\n 200: checkcast #82 // class java/util/Collection\n 203: aload_1\n 204: invokestatic #117 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 207: astore 6\n 209: aload 5\n 211: checkcast #77 // class java/lang/Iterable\n 214: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 219: astore 8\n 221: aload 8\n 223: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 228: ifne 239\n 231: new #119 // class java/util/NoSuchElementException\n 234: dup\n 235: invokespecial #120 // Method java/util/NoSuchElementException.\"<init>\":()V\n 238: athrow\n 239: aload 8\n 241: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 246: checkcast #98 // class java/lang/String\n 249: astore 9\n 251: iconst_0\n 252: istore 10\n 254: aload_0\n 255: aload 9\n 257: aload_2\n 258: aload 6\n 260: iload 4\n 262: iconst_1\n 263: iadd\n 264: invokestatic #122 // Method main$getDistanceToValve:(Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;I)I\n 267: istore 9\n 269: aload 8\n 271: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 276: ifeq 323\n 279: aload 8\n 281: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 286: checkcast #98 // class java/lang/String\n 289: astore 10\n 291: iconst_0\n 292: istore 11\n 294: aload_0\n 295: aload 10\n 297: aload_2\n 298: aload 6\n 300: iload 4\n 302: iconst_1\n 303: iadd\n 304: invokestatic #122 // Method main$getDistanceToValve:(Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;I)I\n 307: istore 10\n 309: iload 9\n 311: iload 10\n 313: if_icmple 269\n 316: iload 10\n 318: istore 9\n 320: goto 269\n 323: iload 9\n 325: ireturn\n\n static int main$getDistanceToValve$default(kotlin.jvm.internal.Ref$ObjectRef, java.lang.String, java.lang.String, java.util.List, int, int, java.lang.Object);\n Code:\n 0: iload 5\n 2: bipush 8\n 4: iand\n 5: ifeq 12\n 8: invokestatic #149 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 11: astore_3\n 12: iload 5\n 14: bipush 16\n 16: iand\n 17: ifeq 23\n 20: iconst_1\n 21: istore 4\n 23: aload_0\n 24: aload_1\n 25: aload_2\n 26: aload_3\n 27: iload 4\n 29: invokestatic #122 // Method main$getDistanceToValve:(Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;I)I\n 32: ireturn\n\n private static final void main$parseInput(kotlin.jvm.internal.Ref$ObjectRef<java.util.Map<java.lang.String, java.lang.Integer>>, kotlin.jvm.internal.Ref$ObjectRef<java.util.Map<java.lang.String, java.util.List<java.lang.String>>>, kotlin.jvm.internal.Ref$ObjectRef<java.util.List<java.lang.String>>, java.lang.String);\n Code:\n 0: new #152 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #153 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #67 // class java/util/Map\n 10: astore 4\n 12: new #152 // class java/util/LinkedHashMap\n 15: dup\n 16: invokespecial #153 // Method java/util/LinkedHashMap.\"<init>\":()V\n 19: checkcast #67 // class java/util/Map\n 22: astore 5\n 24: aload_3\n 25: invokestatic #159 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 28: checkcast #77 // class java/lang/Iterable\n 31: astore 6\n 33: nop\n 34: iconst_0\n 35: istore 7\n 37: aload 6\n 39: astore 8\n 41: new #79 // class java/util/ArrayList\n 44: dup\n 45: aload 6\n 47: bipush 10\n 49: invokestatic #163 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 52: invokespecial #165 // Method java/util/ArrayList.\"<init>\":(I)V\n 55: checkcast #82 // class java/util/Collection\n 58: astore 9\n 60: iconst_0\n 61: istore 10\n 63: aload 8\n 65: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 70: astore 11\n 72: aload 11\n 74: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 79: ifeq 144\n 82: aload 11\n 84: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 89: astore 12\n 91: aload 9\n 93: aload 12\n 95: checkcast #98 // class java/lang/String\n 98: astore 13\n 100: astore 18\n 102: iconst_0\n 103: istore 14\n 105: aload 13\n 107: checkcast #167 // class java/lang/CharSequence\n 110: iconst_1\n 111: anewarray #98 // class java/lang/String\n 114: astore 15\n 116: aload 15\n 118: iconst_0\n 119: ldc #169 // String ;\n 121: aastore\n 122: aload 15\n 124: iconst_0\n 125: iconst_0\n 126: bipush 6\n 128: aconst_null\n 129: invokestatic #175 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 132: aload 18\n 134: swap\n 135: invokeinterface #107, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 140: pop\n 141: goto 72\n 144: aload 9\n 146: checkcast #100 // class java/util/List\n 149: nop\n 150: checkcast #77 // class java/lang/Iterable\n 153: astore 6\n 155: nop\n 156: iconst_0\n 157: istore 7\n 159: aload 6\n 161: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 166: astore 8\n 168: aload 8\n 170: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 175: ifeq 313\n 178: aload 8\n 180: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 185: astore 9\n 187: aload 9\n 189: checkcast #100 // class java/util/List\n 192: astore 10\n 194: iconst_0\n 195: istore 11\n 197: aload 10\n 199: iconst_0\n 200: invokeinterface #178, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 205: checkcast #98 // class java/lang/String\n 208: astore 12\n 210: aload 10\n 212: iconst_1\n 213: invokeinterface #178, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 218: checkcast #98 // class java/lang/String\n 221: astore 13\n 223: aload 12\n 225: new #180 // class kotlin/text/Regex\n 228: dup\n 229: ldc #182 // String [A-Z][A-Z]\n 231: invokespecial #183 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 234: invokestatic #187 // Method UtilsKt.getAllByRegex:(Ljava/lang/String;Lkotlin/text/Regex;)Ljava/util/List;\n 237: invokestatic #191 // Method kotlin/collections/CollectionsKt.single:(Ljava/util/List;)Ljava/lang/Object;\n 240: checkcast #98 // class java/lang/String\n 243: astore 14\n 245: aload 12\n 247: invokestatic #194 // Method UtilsKt.getAllInts:(Ljava/lang/String;)Ljava/util/List;\n 250: invokestatic #191 // Method kotlin/collections/CollectionsKt.single:(Ljava/util/List;)Ljava/lang/Object;\n 253: checkcast #196 // class java/lang/Number\n 256: invokevirtual #200 // Method java/lang/Number.intValue:()I\n 259: istore 15\n 261: aload 13\n 263: new #180 // class kotlin/text/Regex\n 266: dup\n 267: ldc #182 // String [A-Z][A-Z]\n 269: invokespecial #183 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 272: invokestatic #187 // Method UtilsKt.getAllByRegex:(Ljava/lang/String;Lkotlin/text/Regex;)Ljava/util/List;\n 275: astore 16\n 277: iload 15\n 279: invokestatic #206 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 282: astore 17\n 284: aload 4\n 286: aload 14\n 288: aload 17\n 290: invokeinterface #210, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 295: pop\n 296: aload 5\n 298: aload 14\n 300: aload 16\n 302: invokeinterface #210, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 307: pop\n 308: nop\n 309: nop\n 310: goto 168\n 313: nop\n 314: aload_0\n 315: aload 4\n 317: putfield #59 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 320: aload_1\n 321: aload 5\n 323: putfield #59 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 326: aload_2\n 327: aload_0\n 328: getfield #59 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 331: ifnonnull 343\n 334: ldc #211 // String flowRates\n 336: invokestatic #65 // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V\n 339: aconst_null\n 340: goto 350\n 343: aload_0\n 344: getfield #59 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 347: checkcast #67 // class java/util/Map\n 350: invokeinterface #215, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 355: checkcast #77 // class java/lang/Iterable\n 358: astore 6\n 360: astore 18\n 362: iconst_0\n 363: istore 7\n 365: aload 6\n 367: astore 8\n 369: new #79 // class java/util/ArrayList\n 372: dup\n 373: invokespecial #80 // Method java/util/ArrayList.\"<init>\":()V\n 376: checkcast #82 // class java/util/Collection\n 379: astore 9\n 381: iconst_0\n 382: istore 10\n 384: aload 8\n 386: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 391: astore 11\n 393: aload 11\n 395: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 400: ifeq 486\n 403: aload 11\n 405: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 410: astore 12\n 412: aload 12\n 414: checkcast #98 // class java/lang/String\n 417: astore 13\n 419: iconst_0\n 420: istore 14\n 422: aload_0\n 423: getfield #59 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 426: ifnonnull 438\n 429: ldc #211 // String flowRates\n 431: invokestatic #65 // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V\n 434: aconst_null\n 435: goto 445\n 438: aload_0\n 439: getfield #59 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 442: checkcast #67 // class java/util/Map\n 445: aload 13\n 447: invokeinterface #71, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 452: dup\n 453: invokestatic #75 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 456: checkcast #196 // class java/lang/Number\n 459: invokevirtual #200 // Method java/lang/Number.intValue:()I\n 462: ifle 469\n 465: iconst_1\n 466: goto 470\n 469: iconst_0\n 470: ifeq 393\n 473: aload 9\n 475: aload 12\n 477: invokeinterface #107, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 482: pop\n 483: goto 393\n 486: aload 9\n 488: checkcast #100 // class java/util/List\n 491: nop\n 492: aload 18\n 494: swap\n 495: putfield #59 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 498: return\n\n private static final java.util.Map<kotlin.Pair<java.lang.String, java.lang.String>, java.lang.Integer> main$calculateDistancesBetweenValves(kotlin.jvm.internal.Ref$ObjectRef<java.util.Map<java.lang.String, java.util.List<java.lang.String>>>, java.util.List<java.lang.String>);\n Code:\n 0: new #152 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #153 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #67 // class java/util/Map\n 10: astore_2\n 11: aload_1\n 12: invokeinterface #239, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 17: astore_3\n 18: aload_3\n 19: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 24: ifeq 101\n 27: aload_3\n 28: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 33: checkcast #98 // class java/lang/String\n 36: astore 4\n 38: aload_1\n 39: invokeinterface #239, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 44: astore 5\n 46: aload 5\n 48: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 18\n 56: aload 5\n 58: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: checkcast #98 // class java/lang/String\n 66: astore 6\n 68: aload_2\n 69: aload 4\n 71: aload 6\n 73: invokestatic #245 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 76: aload_0\n 77: aload 4\n 79: aload 6\n 81: aconst_null\n 82: iconst_0\n 83: bipush 24\n 85: aconst_null\n 86: invokestatic #247 // Method main$getDistanceToValve$default:(Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;IILjava/lang/Object;)I\n 89: invokestatic #206 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 92: invokeinterface #210, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 97: pop\n 98: goto 46\n 101: aload_2\n 102: areturn\n\n private static final int main$maxPath(kotlin.jvm.internal.Ref$ObjectRef<java.util.Map<kotlin.Pair<java.lang.String, java.lang.String>, java.lang.Integer>>, kotlin.jvm.internal.Ref$ObjectRef<java.util.Map<java.lang.String, java.lang.Integer>>, java.lang.String, int, java.util.Set<java.lang.String>, int);\n Code:\n 0: aload 4\n 2: aload_2\n 3: invokestatic #258 // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Object;)Ljava/util/Set;\n 6: astore 6\n 8: aload 6\n 10: checkcast #77 // class java/lang/Iterable\n 13: astore 8\n 15: iconst_0\n 16: istore 9\n 18: aload 8\n 20: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 25: astore 10\n 27: aload 10\n 29: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 34: ifeq 112\n 37: aload 10\n 39: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 44: astore 11\n 46: iload 9\n 48: aload 11\n 50: checkcast #98 // class java/lang/String\n 53: astore 12\n 55: istore 21\n 57: iconst_0\n 58: istore 13\n 60: aload_1\n 61: getfield #59 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 64: ifnonnull 76\n 67: ldc #211 // String flowRates\n 69: invokestatic #65 // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V\n 72: aconst_null\n 73: goto 83\n 76: aload_1\n 77: getfield #59 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 80: checkcast #67 // class java/util/Map\n 83: aload 12\n 85: invokeinterface #71, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 90: dup\n 91: invokestatic #75 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 94: checkcast #196 // class java/lang/Number\n 97: invokevirtual #200 // Method java/lang/Number.intValue:()I\n 100: istore 22\n 102: iload 21\n 104: iload 22\n 106: iadd\n 107: istore 9\n 109: goto 27\n 112: iload 9\n 114: istore 7\n 116: aload_0\n 117: getfield #59 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 120: ifnonnull 133\n 123: ldc_w #259 // String distances\n 126: invokestatic #65 // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V\n 129: aconst_null\n 130: goto 140\n 133: aload_0\n 134: getfield #59 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 137: checkcast #67 // class java/util/Map\n 140: astore 8\n 142: nop\n 143: iconst_0\n 144: istore 9\n 146: aload 8\n 148: astore 10\n 150: new #152 // class java/util/LinkedHashMap\n 153: dup\n 154: invokespecial #153 // Method java/util/LinkedHashMap.\"<init>\":()V\n 157: checkcast #67 // class java/util/Map\n 160: astore 11\n 162: iconst_0\n 163: istore 12\n 165: aload 10\n 167: invokeinterface #262, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 172: invokeinterface #265, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 177: astore 13\n 179: aload 13\n 181: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 186: ifeq 303\n 189: aload 13\n 191: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 196: checkcast #267 // class java/util/Map$Entry\n 199: astore 14\n 201: aload 14\n 203: astore 15\n 205: iconst_0\n 206: istore 16\n 208: aload 15\n 210: invokeinterface #270, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 215: checkcast #272 // class kotlin/Pair\n 218: astore 17\n 220: aload 15\n 222: invokeinterface #275, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 227: checkcast #196 // class java/lang/Number\n 230: invokevirtual #200 // Method java/lang/Number.intValue:()I\n 233: istore 18\n 235: aload 17\n 237: invokevirtual #278 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 240: aload_2\n 241: invokestatic #282 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 244: ifeq 274\n 247: aload 4\n 249: aload 17\n 251: invokevirtual #285 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 254: invokeinterface #286, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 259: ifne 274\n 262: iload 18\n 264: iload_3\n 265: iconst_1\n 266: isub\n 267: if_icmpgt 274\n 270: iconst_1\n 271: goto 275\n 274: iconst_0\n 275: ifeq 179\n 278: aload 11\n 280: aload 14\n 282: invokeinterface #270, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 287: aload 14\n 289: invokeinterface #275, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 294: invokeinterface #210, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 299: pop\n 300: goto 179\n 303: aload 11\n 305: nop\n 306: astore 8\n 308: nop\n 309: iconst_0\n 310: istore 9\n 312: aload 8\n 314: astore 10\n 316: new #79 // class java/util/ArrayList\n 319: dup\n 320: aload 8\n 322: invokeinterface #289, 1 // InterfaceMethod java/util/Map.size:()I\n 327: invokespecial #165 // Method java/util/ArrayList.\"<init>\":(I)V\n 330: checkcast #82 // class java/util/Collection\n 333: astore 11\n 335: iconst_0\n 336: istore 12\n 338: aload 10\n 340: invokeinterface #262, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 345: invokeinterface #265, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 350: astore 13\n 352: aload 13\n 354: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 359: ifeq 441\n 362: aload 13\n 364: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 369: checkcast #267 // class java/util/Map$Entry\n 372: astore 14\n 374: aload 11\n 376: aload 14\n 378: astore 15\n 380: astore 21\n 382: iconst_0\n 383: istore 16\n 385: aload 15\n 387: invokeinterface #270, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 392: checkcast #272 // class kotlin/Pair\n 395: astore 17\n 397: aload 15\n 399: invokeinterface #275, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 404: checkcast #196 // class java/lang/Number\n 407: invokevirtual #200 // Method java/lang/Number.intValue:()I\n 410: istore 18\n 412: new #272 // class kotlin/Pair\n 415: dup\n 416: aload 17\n 418: invokevirtual #285 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 421: iload 18\n 423: invokestatic #206 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 426: invokespecial #292 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 429: aload 21\n 431: swap\n 432: invokeinterface #107, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 437: pop\n 438: goto 352\n 441: aload 11\n 443: checkcast #100 // class java/util/List\n 446: nop\n 447: checkcast #77 // class java/lang/Iterable\n 450: astore 8\n 452: nop\n 453: iconst_0\n 454: istore 9\n 456: aload 8\n 458: astore 10\n 460: new #79 // class java/util/ArrayList\n 463: dup\n 464: aload 8\n 466: bipush 10\n 468: invokestatic #163 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 471: invokespecial #165 // Method java/util/ArrayList.\"<init>\":(I)V\n 474: checkcast #82 // class java/util/Collection\n 477: astore 11\n 479: iconst_0\n 480: istore 12\n 482: aload 10\n 484: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 489: astore 13\n 491: aload 13\n 493: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 498: ifeq 595\n 501: aload 13\n 503: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 508: astore 14\n 510: aload 11\n 512: aload 14\n 514: checkcast #272 // class kotlin/Pair\n 517: astore 15\n 519: astore 21\n 521: iconst_0\n 522: istore 16\n 524: aload 15\n 526: invokevirtual #295 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 529: checkcast #98 // class java/lang/String\n 532: astore 17\n 534: aload 15\n 536: invokevirtual #298 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 539: checkcast #196 // class java/lang/Number\n 542: invokevirtual #200 // Method java/lang/Number.intValue:()I\n 545: istore 18\n 547: iload_3\n 548: iload 18\n 550: isub\n 551: iconst_1\n 552: isub\n 553: istore 19\n 555: iload 5\n 557: iload 18\n 559: iconst_1\n 560: iadd\n 561: iload 7\n 563: imul\n 564: iadd\n 565: istore 20\n 567: aload_0\n 568: aload_1\n 569: aload 17\n 571: iload 19\n 573: aload 6\n 575: iload 20\n 577: invokestatic #300 // Method main$maxPath:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;ILjava/util/Set;I)I\n 580: invokestatic #206 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 583: aload 21\n 585: swap\n 586: invokeinterface #107, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 591: pop\n 592: goto 491\n 595: aload 11\n 597: checkcast #100 // class java/util/List\n 600: nop\n 601: checkcast #82 // class java/util/Collection\n 604: iload 5\n 606: iload_3\n 607: iload 7\n 609: imul\n 610: iadd\n 611: invokestatic #206 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 614: invokestatic #117 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 617: checkcast #77 // class java/lang/Iterable\n 620: invokestatic #304 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 623: checkcast #196 // class java/lang/Number\n 626: invokevirtual #200 // Method java/lang/Number.intValue:()I\n 629: ireturn\n\n static int main$maxPath$default(kotlin.jvm.internal.Ref$ObjectRef, kotlin.jvm.internal.Ref$ObjectRef, java.lang.String, int, java.util.Set, int, int, java.lang.Object);\n Code:\n 0: iload 6\n 2: bipush 16\n 4: iand\n 5: ifeq 13\n 8: invokestatic #327 // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;\n 11: astore 4\n 13: iload 6\n 15: bipush 32\n 17: iand\n 18: ifeq 24\n 21: iconst_0\n 22: istore 5\n 24: aload_0\n 25: aload_1\n 26: aload_2\n 27: iload_3\n 28: aload 4\n 30: iload 5\n 32: invokestatic #300 // Method main$maxPath:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;ILjava/util/Set;I)I\n 35: ireturn\n\n private static final int main$part1(kotlin.jvm.internal.Ref$ObjectRef<java.util.Map<kotlin.Pair<java.lang.String, java.lang.String>, java.lang.Integer>>, kotlin.jvm.internal.Ref$ObjectRef<java.util.List<java.lang.String>>, kotlin.jvm.internal.Ref$ObjectRef<java.util.Map<java.lang.String, java.util.List<java.lang.String>>>, kotlin.jvm.internal.Ref$ObjectRef<java.util.Map<java.lang.String, java.lang.Integer>>);\n Code:\n 0: ldc_w #330 // String AA\n 3: astore 4\n 5: aload_0\n 6: aload_2\n 7: aload_1\n 8: getfield #59 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 11: ifnonnull 24\n 14: ldc_w #331 // String workingValves\n 17: invokestatic #65 // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V\n 20: aconst_null\n 21: goto 31\n 24: aload_1\n 25: getfield #59 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 28: checkcast #100 // class java/util/List\n 31: checkcast #82 // class java/util/Collection\n 34: aload 4\n 36: invokestatic #117 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 39: invokestatic #333 // Method main$calculateDistancesBetweenValves:(Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/util/List;)Ljava/util/Map;\n 42: putfield #59 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 45: aload_0\n 46: aload_3\n 47: aload 4\n 49: bipush 30\n 51: aconst_null\n 52: iconst_0\n 53: bipush 48\n 55: aconst_null\n 56: invokestatic #335 // Method main$maxPath$default:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;ILjava/util/Set;IILjava/lang/Object;)I\n 59: ireturn\n}\n",
"javap_err": ""
}
] |
buczebar__advent-of-code__cdb6fe3/src/Day13.kt
|
fun main() {
fun parseArray(arrayText: String): List<Any> {
fun nodeToList(node: Node): List<Any> {
return node.children.map { child ->
if (child is Leaf) {
child.value ?: emptyList<Any>()
} else {
nodeToList(child)
}
}
}
fun addLeaf(builder: StringBuilder, node: Node?) {
if (builder.isNotEmpty()) {
node?.addChild(Leaf(node, builder.toString().toInt()))
builder.clear()
}
}
var node: Node? = null
val numberBuilder = StringBuilder()
arrayText.forEach {
when {
it == '[' -> {
val newNode = Node(node)
node?.addChild(newNode)
node = newNode
}
it.isDigit() -> {
numberBuilder.append(it)
}
it == ',' -> {
addLeaf(numberBuilder, node)
}
it == ']' -> {
addLeaf(numberBuilder, node)
node = node?.parent ?: node
}
}
}
return node?.let { nodeToList(it) } ?: emptyList()
}
fun compare(first: Any?, second: Any?): Int {
if (first is Int && second is Int) {
return first.compareTo(second)
} else if (first is Int && second is List<*>) {
return compare(listOf(first), second)
} else if (first is List<*> && second is Int) {
return compare(first, listOf(second))
} else if (first is List<*> && second is List<*>) {
val pairs = first.zip(second)
for (pair in pairs) {
val result = compare(pair.first, pair.second)
if (result != 0) {
return result
}
}
return first.size.compareTo(second.size)
} else {
return 0
}
}
fun part1(inputName: String) =
readGroupedInput(inputName)
.map { group ->
group.split("\n").map { parseArray(it) }.pair()
}.map {
compare(it.first, it.second)
}.mapIndexed { index, it ->
if (it < 0) index + 1 else 0
}.sum()
fun part2(inputName: String): Int {
val dividerPackets = listOf(listOf(listOf(2)), listOf(listOf(6)))
val packets = readInput(inputName)
.filter { it.isNotBlank() }
.map { parseArray(it) }
.toMutableList()
.also { it.addAll(dividerPackets) }
val sortedPackets = packets.sortedWith { o1, o2 -> compare(o1, o2) }
return dividerPackets.map { sortedPackets.indexOf(it) + 1 }.factorial()
}
val testInputName = "Day13_test"
check(part1(testInputName) == 13)
check(part2(testInputName) == 140)
val inputName = "Day13"
println(part1(inputName))
println(part2(inputName))
}
private open class Node(parent: Node?) {
var parent: Node? = parent
private set
private val _children: MutableList<Node> = mutableListOf()
val children: List<Node>
get() = _children.toList()
fun addChild(child: Node) {
child.parent = this
_children.add(child)
}
}
private class Leaf(parent: Node?, val value: Int?) : Node(parent)
|
[
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day13Kt.class",
"javap": "Compiled from \"Day13.kt\"\npublic final class Day13Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day13_test\n 2: astore_0\n 3: aload_0\n 4: invokestatic #12 // Method main$part1:(Ljava/lang/String;)I\n 7: bipush 13\n 9: if_icmpne 16\n 12: iconst_1\n 13: goto 17\n 16: iconst_0\n 17: ifne 30\n 20: new #14 // class java/lang/IllegalStateException\n 23: dup\n 24: ldc #16 // String Check failed.\n 26: invokespecial #20 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 29: athrow\n 30: aload_0\n 31: invokestatic #23 // Method main$part2:(Ljava/lang/String;)I\n 34: sipush 140\n 37: if_icmpne 44\n 40: iconst_1\n 41: goto 45\n 44: iconst_0\n 45: ifne 58\n 48: new #14 // class java/lang/IllegalStateException\n 51: dup\n 52: ldc #16 // String Check failed.\n 54: invokespecial #20 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 57: athrow\n 58: ldc #25 // String Day13\n 60: astore_1\n 61: aload_1\n 62: invokestatic #12 // Method main$part1:(Ljava/lang/String;)I\n 65: istore_2\n 66: getstatic #31 // Field java/lang/System.out:Ljava/io/PrintStream;\n 69: iload_2\n 70: invokevirtual #37 // Method java/io/PrintStream.println:(I)V\n 73: aload_1\n 74: invokestatic #23 // Method main$part2:(Ljava/lang/String;)I\n 77: istore_2\n 78: getstatic #31 // Field java/lang/System.out:Ljava/io/PrintStream;\n 81: iload_2\n 82: invokevirtual #37 // Method java/io/PrintStream.println:(I)V\n 85: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #45 // Method main:()V\n 3: return\n\n private static final java.util.List<java.lang.Object> main$parseArray$nodeToList(Node);\n Code:\n 0: aload_0\n 1: invokevirtual #56 // Method Node.getChildren:()Ljava/util/List;\n 4: checkcast #58 // class java/lang/Iterable\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: astore_3\n 12: new #60 // class java/util/ArrayList\n 15: dup\n 16: aload_1\n 17: bipush 10\n 19: invokestatic #66 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 22: invokespecial #68 // Method java/util/ArrayList.\"<init>\":(I)V\n 25: checkcast #70 // class java/util/Collection\n 28: astore 4\n 30: iconst_0\n 31: istore 5\n 33: aload_3\n 34: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 6\n 41: aload 6\n 43: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 119\n 51: aload 6\n 53: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 7\n 60: aload 4\n 62: aload 7\n 64: checkcast #52 // class Node\n 67: astore 8\n 69: astore 10\n 71: iconst_0\n 72: istore 9\n 74: aload 8\n 76: instanceof #86 // class Leaf\n 79: ifeq 101\n 82: aload 8\n 84: checkcast #86 // class Leaf\n 87: invokevirtual #90 // Method Leaf.getValue:()Ljava/lang/Integer;\n 90: dup\n 91: ifnonnull 106\n 94: pop\n 95: invokestatic #93 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 98: goto 106\n 101: aload 8\n 103: invokestatic #95 // Method main$parseArray$nodeToList:(LNode;)Ljava/util/List;\n 106: nop\n 107: aload 10\n 109: swap\n 110: invokeinterface #99, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 115: pop\n 116: goto 41\n 119: aload 4\n 121: checkcast #101 // class java/util/List\n 124: nop\n 125: areturn\n\n private static final void main$parseArray$addLeaf(java.lang.StringBuilder, Node);\n Code:\n 0: aload_0\n 1: checkcast #119 // class java/lang/CharSequence\n 4: invokeinterface #123, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 9: ifle 16\n 12: iconst_1\n 13: goto 17\n 16: iconst_0\n 17: ifeq 64\n 20: aload_1\n 21: dup\n 22: ifnull 58\n 25: new #86 // class Leaf\n 28: dup\n 29: aload_1\n 30: aload_0\n 31: invokevirtual #129 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 34: dup\n 35: ldc #131 // String toString(...)\n 37: invokestatic #137 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 40: invokestatic #142 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 43: invokestatic #146 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 46: invokespecial #149 // Method Leaf.\"<init>\":(LNode;Ljava/lang/Integer;)V\n 49: checkcast #52 // class Node\n 52: invokevirtual #153 // Method Node.addChild:(LNode;)V\n 55: goto 59\n 58: pop\n 59: aload_0\n 60: invokestatic #159 // Method kotlin/text/StringsKt.clear:(Ljava/lang/StringBuilder;)Ljava/lang/StringBuilder;\n 63: pop\n 64: return\n\n private static final java.util.List<java.lang.Object> main$parseArray(java.lang.String);\n Code:\n 0: aconst_null\n 1: astore_1\n 2: new #125 // class java/lang/StringBuilder\n 5: dup\n 6: invokespecial #166 // Method java/lang/StringBuilder.\"<init>\":()V\n 9: astore_2\n 10: aload_0\n 11: checkcast #119 // class java/lang/CharSequence\n 14: astore_3\n 15: iconst_0\n 16: istore 4\n 18: iconst_0\n 19: istore 5\n 21: iload 5\n 23: aload_3\n 24: invokeinterface #123, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 29: if_icmpge 155\n 32: aload_3\n 33: iload 5\n 35: invokeinterface #170, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 40: istore 6\n 42: iload 6\n 44: istore 7\n 46: iconst_0\n 47: istore 8\n 49: nop\n 50: iload 7\n 52: bipush 91\n 54: if_icmpne 87\n 57: new #52 // class Node\n 60: dup\n 61: aload_1\n 62: invokespecial #172 // Method Node.\"<init>\":(LNode;)V\n 65: astore 9\n 67: aload_1\n 68: dup\n 69: ifnull 80\n 72: aload 9\n 74: invokevirtual #153 // Method Node.addChild:(LNode;)V\n 77: goto 81\n 80: pop\n 81: aload 9\n 83: astore_1\n 84: goto 147\n 87: iload 7\n 89: invokestatic #178 // Method java/lang/Character.isDigit:(C)Z\n 92: ifeq 105\n 95: aload_2\n 96: iload 7\n 98: invokevirtual #182 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 101: pop\n 102: goto 147\n 105: iload 7\n 107: bipush 44\n 109: if_icmpne 120\n 112: aload_2\n 113: aload_1\n 114: invokestatic #184 // Method main$parseArray$addLeaf:(Ljava/lang/StringBuilder;LNode;)V\n 117: goto 147\n 120: iload 7\n 122: bipush 93\n 124: if_icmpne 147\n 127: aload_2\n 128: aload_1\n 129: invokestatic #184 // Method main$parseArray$addLeaf:(Ljava/lang/StringBuilder;LNode;)V\n 132: aload_1\n 133: dup\n 134: ifnull 144\n 137: invokevirtual #188 // Method Node.getParent:()LNode;\n 140: dup\n 141: ifnonnull 146\n 144: pop\n 145: aload_1\n 146: astore_1\n 147: nop\n 148: nop\n 149: iinc 5, 1\n 152: goto 21\n 155: nop\n 156: aload_1\n 157: dup\n 158: ifnull 176\n 161: astore 6\n 163: iconst_0\n 164: istore 7\n 166: aload 6\n 168: invokestatic #95 // Method main$parseArray$nodeToList:(LNode;)Ljava/util/List;\n 171: nop\n 172: dup\n 173: ifnonnull 180\n 176: pop\n 177: invokestatic #93 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 180: areturn\n\n private static final int main$compare(java.lang.Object, java.lang.Object);\n Code:\n 0: aload_0\n 1: instanceof #139 // class java/lang/Integer\n 4: ifeq 32\n 7: aload_1\n 8: instanceof #139 // class java/lang/Integer\n 11: ifeq 32\n 14: aload_0\n 15: checkcast #203 // class java/lang/Number\n 18: invokevirtual #206 // Method java/lang/Number.intValue:()I\n 21: aload_1\n 22: checkcast #203 // class java/lang/Number\n 25: invokevirtual #206 // Method java/lang/Number.intValue:()I\n 28: invokestatic #210 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 31: ireturn\n 32: aload_0\n 33: instanceof #139 // class java/lang/Integer\n 36: ifeq 55\n 39: aload_1\n 40: instanceof #101 // class java/util/List\n 43: ifeq 55\n 46: aload_0\n 47: invokestatic #214 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 50: aload_1\n 51: invokestatic #216 // Method main$compare:(Ljava/lang/Object;Ljava/lang/Object;)I\n 54: ireturn\n 55: aload_0\n 56: instanceof #101 // class java/util/List\n 59: ifeq 78\n 62: aload_1\n 63: instanceof #139 // class java/lang/Integer\n 66: ifeq 78\n 69: aload_0\n 70: aload_1\n 71: invokestatic #214 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 74: invokestatic #216 // Method main$compare:(Ljava/lang/Object;Ljava/lang/Object;)I\n 77: ireturn\n 78: aload_0\n 79: instanceof #101 // class java/util/List\n 82: ifeq 176\n 85: aload_1\n 86: instanceof #101 // class java/util/List\n 89: ifeq 176\n 92: aload_0\n 93: checkcast #58 // class java/lang/Iterable\n 96: aload_1\n 97: checkcast #58 // class java/lang/Iterable\n 100: invokestatic #220 // Method kotlin/collections/CollectionsKt.zip:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;\n 103: astore_2\n 104: aload_2\n 105: invokeinterface #221, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 110: astore_3\n 111: aload_3\n 112: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 117: ifeq 154\n 120: aload_3\n 121: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 126: checkcast #223 // class kotlin/Pair\n 129: astore 4\n 131: aload 4\n 133: invokevirtual #226 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 136: aload 4\n 138: invokevirtual #229 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 141: invokestatic #216 // Method main$compare:(Ljava/lang/Object;Ljava/lang/Object;)I\n 144: istore 5\n 146: iload 5\n 148: ifeq 111\n 151: iload 5\n 153: ireturn\n 154: aload_0\n 155: checkcast #101 // class java/util/List\n 158: invokeinterface #232, 1 // InterfaceMethod java/util/List.size:()I\n 163: aload_1\n 164: checkcast #101 // class java/util/List\n 167: invokeinterface #232, 1 // InterfaceMethod java/util/List.size:()I\n 172: invokestatic #210 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 175: ireturn\n 176: iconst_0\n 177: ireturn\n\n private static final int main$part1(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #244 // Method UtilsKt.readGroupedInput:(Ljava/lang/String;)Ljava/util/List;\n 4: checkcast #58 // class java/lang/Iterable\n 7: astore_1\n 8: nop\n 9: iconst_0\n 10: istore_2\n 11: aload_1\n 12: astore_3\n 13: new #60 // class java/util/ArrayList\n 16: dup\n 17: aload_1\n 18: bipush 10\n 20: invokestatic #66 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 23: invokespecial #68 // Method java/util/ArrayList.\"<init>\":(I)V\n 26: checkcast #70 // class java/util/Collection\n 29: astore 4\n 31: iconst_0\n 32: istore 5\n 34: aload_3\n 35: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 40: astore 6\n 42: aload 6\n 44: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 49: ifeq 216\n 52: aload 6\n 54: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 59: astore 7\n 61: aload 4\n 63: aload 7\n 65: checkcast #42 // class java/lang/String\n 68: astore 8\n 70: astore 20\n 72: iconst_0\n 73: istore 9\n 75: aload 8\n 77: checkcast #119 // class java/lang/CharSequence\n 80: iconst_1\n 81: anewarray #42 // class java/lang/String\n 84: astore 10\n 86: aload 10\n 88: iconst_0\n 89: ldc #246 // String \\n\n 91: aastore\n 92: aload 10\n 94: iconst_0\n 95: iconst_0\n 96: bipush 6\n 98: aconst_null\n 99: invokestatic #250 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 102: checkcast #58 // class java/lang/Iterable\n 105: astore 10\n 107: iconst_0\n 108: istore 11\n 110: aload 10\n 112: astore 12\n 114: new #60 // class java/util/ArrayList\n 117: dup\n 118: aload 10\n 120: bipush 10\n 122: invokestatic #66 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 125: invokespecial #68 // Method java/util/ArrayList.\"<init>\":(I)V\n 128: checkcast #70 // class java/util/Collection\n 131: astore 13\n 133: iconst_0\n 134: istore 14\n 136: aload 12\n 138: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 143: astore 15\n 145: aload 15\n 147: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 152: ifeq 195\n 155: aload 15\n 157: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 162: astore 16\n 164: aload 13\n 166: aload 16\n 168: checkcast #42 // class java/lang/String\n 171: astore 17\n 173: astore 18\n 175: iconst_0\n 176: istore 19\n 178: aload 17\n 180: invokestatic #252 // Method main$parseArray:(Ljava/lang/String;)Ljava/util/List;\n 183: aload 18\n 185: swap\n 186: invokeinterface #99, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 191: pop\n 192: goto 145\n 195: aload 13\n 197: checkcast #101 // class java/util/List\n 200: nop\n 201: invokestatic #255 // Method UtilsKt.pair:(Ljava/util/List;)Lkotlin/Pair;\n 204: aload 20\n 206: swap\n 207: invokeinterface #99, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 212: pop\n 213: goto 42\n 216: aload 4\n 218: checkcast #101 // class java/util/List\n 221: nop\n 222: checkcast #58 // class java/lang/Iterable\n 225: astore_1\n 226: nop\n 227: iconst_0\n 228: istore_2\n 229: aload_1\n 230: astore_3\n 231: new #60 // class java/util/ArrayList\n 234: dup\n 235: aload_1\n 236: bipush 10\n 238: invokestatic #66 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 241: invokespecial #68 // Method java/util/ArrayList.\"<init>\":(I)V\n 244: checkcast #70 // class java/util/Collection\n 247: astore 4\n 249: iconst_0\n 250: istore 5\n 252: aload_3\n 253: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 258: astore 6\n 260: aload 6\n 262: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 267: ifeq 321\n 270: aload 6\n 272: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 277: astore 7\n 279: aload 4\n 281: aload 7\n 283: checkcast #223 // class kotlin/Pair\n 286: astore 8\n 288: astore 20\n 290: iconst_0\n 291: istore 9\n 293: aload 8\n 295: invokevirtual #226 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 298: aload 8\n 300: invokevirtual #229 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 303: invokestatic #216 // Method main$compare:(Ljava/lang/Object;Ljava/lang/Object;)I\n 306: invokestatic #146 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 309: aload 20\n 311: swap\n 312: invokeinterface #99, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 317: pop\n 318: goto 260\n 321: aload 4\n 323: checkcast #101 // class java/util/List\n 326: nop\n 327: checkcast #58 // class java/lang/Iterable\n 330: astore_1\n 331: nop\n 332: iconst_0\n 333: istore_2\n 334: aload_1\n 335: astore_3\n 336: new #60 // class java/util/ArrayList\n 339: dup\n 340: aload_1\n 341: bipush 10\n 343: invokestatic #66 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 346: invokespecial #68 // Method java/util/ArrayList.\"<init>\":(I)V\n 349: checkcast #70 // class java/util/Collection\n 352: astore 4\n 354: iconst_0\n 355: istore 5\n 357: iconst_0\n 358: istore 6\n 360: aload_3\n 361: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 366: astore 7\n 368: aload 7\n 370: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 375: ifeq 451\n 378: aload 7\n 380: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 385: astore 8\n 387: aload 4\n 389: iload 6\n 391: iinc 6, 1\n 394: istore 9\n 396: iload 9\n 398: ifge 404\n 401: invokestatic #258 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 404: iload 9\n 406: aload 8\n 408: checkcast #203 // class java/lang/Number\n 411: invokevirtual #206 // Method java/lang/Number.intValue:()I\n 414: istore 10\n 416: istore 11\n 418: astore 20\n 420: iconst_0\n 421: istore 12\n 423: iload 10\n 425: ifge 435\n 428: iload 11\n 430: iconst_1\n 431: iadd\n 432: goto 436\n 435: iconst_0\n 436: invokestatic #146 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 439: aload 20\n 441: swap\n 442: invokeinterface #99, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 447: pop\n 448: goto 368\n 451: aload 4\n 453: checkcast #101 // class java/util/List\n 456: nop\n 457: checkcast #58 // class java/lang/Iterable\n 460: invokestatic #262 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 463: ireturn\n\n private static final int main$part2$lambda$10(java.util.List, java.util.List);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #216 // Method main$compare:(Ljava/lang/Object;Ljava/lang/Object;)I\n 5: ireturn\n\n private static final int main$part2$lambda$11(kotlin.jvm.functions.Function2, java.lang.Object, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: aload_2\n 3: invokeinterface #285, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 8: checkcast #203 // class java/lang/Number\n 11: invokevirtual #206 // Method java/lang/Number.intValue:()I\n 14: ireturn\n\n private static final int main$part2(java.lang.String);\n Code:\n 0: iconst_2\n 1: anewarray #101 // class java/util/List\n 4: astore_2\n 5: aload_2\n 6: iconst_0\n 7: iconst_2\n 8: invokestatic #146 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 11: invokestatic #214 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 14: invokestatic #214 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 17: aastore\n 18: aload_2\n 19: iconst_1\n 20: bipush 6\n 22: invokestatic #146 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 25: invokestatic #214 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 28: invokestatic #214 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 31: aastore\n 32: aload_2\n 33: invokestatic #292 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 36: astore_1\n 37: aload_0\n 38: invokestatic #295 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 41: checkcast #58 // class java/lang/Iterable\n 44: astore_3\n 45: nop\n 46: iconst_0\n 47: istore 4\n 49: aload_3\n 50: astore 5\n 52: new #60 // class java/util/ArrayList\n 55: dup\n 56: invokespecial #296 // Method java/util/ArrayList.\"<init>\":()V\n 59: checkcast #70 // class java/util/Collection\n 62: astore 6\n 64: iconst_0\n 65: istore 7\n 67: aload 5\n 69: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 74: astore 8\n 76: aload 8\n 78: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 83: ifeq 138\n 86: aload 8\n 88: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 93: astore 9\n 95: aload 9\n 97: checkcast #42 // class java/lang/String\n 100: astore 10\n 102: iconst_0\n 103: istore 11\n 105: aload 10\n 107: checkcast #119 // class java/lang/CharSequence\n 110: invokestatic #300 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 113: ifne 120\n 116: iconst_1\n 117: goto 121\n 120: iconst_0\n 121: nop\n 122: ifeq 76\n 125: aload 6\n 127: aload 9\n 129: invokeinterface #99, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 134: pop\n 135: goto 76\n 138: aload 6\n 140: checkcast #101 // class java/util/List\n 143: nop\n 144: checkcast #58 // class java/lang/Iterable\n 147: astore_3\n 148: nop\n 149: iconst_0\n 150: istore 4\n 152: aload_3\n 153: astore 5\n 155: new #60 // class java/util/ArrayList\n 158: dup\n 159: aload_3\n 160: bipush 10\n 162: invokestatic #66 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 165: invokespecial #68 // Method java/util/ArrayList.\"<init>\":(I)V\n 168: checkcast #70 // class java/util/Collection\n 171: astore 6\n 173: iconst_0\n 174: istore 7\n 176: aload 5\n 178: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 183: astore 8\n 185: aload 8\n 187: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 192: ifeq 235\n 195: aload 8\n 197: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 202: astore 9\n 204: aload 6\n 206: aload 9\n 208: checkcast #42 // class java/lang/String\n 211: astore 10\n 213: astore 13\n 215: iconst_0\n 216: istore 11\n 218: aload 10\n 220: invokestatic #252 // Method main$parseArray:(Ljava/lang/String;)Ljava/util/List;\n 223: aload 13\n 225: swap\n 226: invokeinterface #99, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 231: pop\n 232: goto 185\n 235: aload 6\n 237: checkcast #101 // class java/util/List\n 240: nop\n 241: checkcast #70 // class java/util/Collection\n 244: invokestatic #304 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 247: astore_3\n 248: aload_3\n 249: astore 4\n 251: iconst_0\n 252: istore 5\n 254: aload 4\n 256: aload_1\n 257: checkcast #70 // class java/util/Collection\n 260: invokeinterface #308, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 265: pop\n 266: aload_3\n 267: astore_2\n 268: aload_2\n 269: checkcast #58 // class java/lang/Iterable\n 272: invokedynamic #324, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;\n 277: invokedynamic #331, 0 // InvokeDynamic #1:compare:(Lkotlin/jvm/functions/Function2;)Ljava/util/Comparator;\n 282: invokestatic #335 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 285: astore_3\n 286: aload_1\n 287: checkcast #58 // class java/lang/Iterable\n 290: astore 4\n 292: iconst_0\n 293: istore 5\n 295: aload 4\n 297: astore 6\n 299: new #60 // class java/util/ArrayList\n 302: dup\n 303: aload 4\n 305: bipush 10\n 307: invokestatic #66 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 310: invokespecial #68 // Method java/util/ArrayList.\"<init>\":(I)V\n 313: checkcast #70 // class java/util/Collection\n 316: astore 7\n 318: iconst_0\n 319: istore 8\n 321: aload 6\n 323: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 328: astore 9\n 330: aload 9\n 332: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 337: ifeq 388\n 340: aload 9\n 342: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 347: astore 10\n 349: aload 7\n 351: aload 10\n 353: checkcast #101 // class java/util/List\n 356: astore 11\n 358: astore 13\n 360: iconst_0\n 361: istore 12\n 363: aload_3\n 364: aload 11\n 366: invokeinterface #339, 2 // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I\n 371: iconst_1\n 372: iadd\n 373: invokestatic #146 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 376: aload 13\n 378: swap\n 379: invokeinterface #99, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 384: pop\n 385: goto 330\n 388: aload 7\n 390: checkcast #101 // class java/util/List\n 393: nop\n 394: invokestatic #343 // Method UtilsKt.factorial:(Ljava/util/List;)I\n 397: ireturn\n}\n",
"javap_err": ""
}
] |
buczebar__advent-of-code__cdb6fe3/src/Day03.kt
|
fun main() {
fun Char.getPriority() =
(('a'..'z') + ('A'..'Z')).indexOf(this) + 1
fun part1(input: List<String>) =
input.map { sack -> sack.chunked(sack.length / 2).map { comp -> comp.toList() } }
.map { (comp1, comp2) -> (comp1 intersect comp2.toSet()).single() }
.sumOf { it.getPriority() }
fun part2(input: List<String>) =
input.chunked(3)
.map { (a, b, c) -> (a.toSet() intersect b.toSet() intersect c.toSet()).single() }
.sumOf { it.getPriority() }
val testInput = readInput("Day03_test")
check(part1(testInput) == 157)
check(part2(testInput) == 70)
val input = readInput("Day03")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day03Kt.class",
"javap": "Compiled from \"Day03.kt\"\npublic final class Day03Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day03_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 10: sipush 157\n 13: if_icmpne 20\n 16: iconst_1\n 17: goto 21\n 20: iconst_0\n 21: ifne 34\n 24: new #20 // class java/lang/IllegalStateException\n 27: dup\n 28: ldc #22 // String Check failed.\n 30: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 33: athrow\n 34: aload_0\n 35: invokestatic #29 // Method main$part2:(Ljava/util/List;)I\n 38: bipush 70\n 40: if_icmpne 47\n 43: iconst_1\n 44: goto 48\n 47: iconst_0\n 48: ifne 61\n 51: new #20 // class java/lang/IllegalStateException\n 54: dup\n 55: ldc #22 // String Check failed.\n 57: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 60: athrow\n 61: ldc #31 // String Day03\n 63: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 66: astore_1\n 67: aload_1\n 68: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 71: istore_2\n 72: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 75: iload_2\n 76: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 79: aload_1\n 80: invokestatic #29 // Method main$part2:(Ljava/util/List;)I\n 83: istore_2\n 84: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 87: iload_2\n 88: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 91: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #51 // Method main:()V\n 3: return\n\n private static final int main$getPriority(char);\n Code:\n 0: new #57 // class kotlin/ranges/CharRange\n 3: dup\n 4: bipush 97\n 6: bipush 122\n 8: invokespecial #60 // Method kotlin/ranges/CharRange.\"<init>\":(CC)V\n 11: checkcast #62 // class java/lang/Iterable\n 14: new #57 // class kotlin/ranges/CharRange\n 17: dup\n 18: bipush 65\n 20: bipush 90\n 22: invokespecial #60 // Method kotlin/ranges/CharRange.\"<init>\":(CC)V\n 25: checkcast #62 // class java/lang/Iterable\n 28: invokestatic #68 // Method kotlin/collections/CollectionsKt.plus:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;\n 31: iload_0\n 32: invokestatic #74 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 35: invokeinterface #78, 2 // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I\n 40: iconst_1\n 41: iadd\n 42: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #62 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: astore_3\n 9: new #83 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #87 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #89 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #91 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 201\n 48: aload 6\n 50: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #107 // class java/lang/String\n 64: astore 8\n 66: astore 20\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: checkcast #109 // class java/lang/CharSequence\n 76: aload 8\n 78: invokevirtual #113 // Method java/lang/String.length:()I\n 81: iconst_2\n 82: idiv\n 83: invokestatic #119 // Method kotlin/text/StringsKt.chunked:(Ljava/lang/CharSequence;I)Ljava/util/List;\n 86: checkcast #62 // class java/lang/Iterable\n 89: astore 10\n 91: iconst_0\n 92: istore 11\n 94: aload 10\n 96: astore 12\n 98: new #83 // class java/util/ArrayList\n 101: dup\n 102: aload 10\n 104: bipush 10\n 106: invokestatic #87 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 109: invokespecial #89 // Method java/util/ArrayList.\"<init>\":(I)V\n 112: checkcast #91 // class java/util/Collection\n 115: astore 13\n 117: iconst_0\n 118: istore 14\n 120: aload 12\n 122: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 127: astore 15\n 129: aload 15\n 131: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 136: ifeq 182\n 139: aload 15\n 141: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 146: astore 16\n 148: aload 13\n 150: aload 16\n 152: checkcast #107 // class java/lang/String\n 155: astore 17\n 157: astore 18\n 159: iconst_0\n 160: istore 19\n 162: aload 17\n 164: checkcast #109 // class java/lang/CharSequence\n 167: invokestatic #123 // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;\n 170: aload 18\n 172: swap\n 173: invokeinterface #127, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 178: pop\n 179: goto 129\n 182: aload 13\n 184: checkcast #48 // class java/util/List\n 187: nop\n 188: nop\n 189: aload 20\n 191: swap\n 192: invokeinterface #127, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 197: pop\n 198: goto 38\n 201: aload 4\n 203: checkcast #48 // class java/util/List\n 206: nop\n 207: checkcast #62 // class java/lang/Iterable\n 210: astore_1\n 211: nop\n 212: iconst_0\n 213: istore_2\n 214: aload_1\n 215: astore_3\n 216: new #83 // class java/util/ArrayList\n 219: dup\n 220: aload_1\n 221: bipush 10\n 223: invokestatic #87 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 226: invokespecial #89 // Method java/util/ArrayList.\"<init>\":(I)V\n 229: checkcast #91 // class java/util/Collection\n 232: astore 4\n 234: iconst_0\n 235: istore 5\n 237: aload_3\n 238: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 243: astore 6\n 245: aload 6\n 247: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 252: ifeq 350\n 255: aload 6\n 257: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 262: astore 7\n 264: aload 4\n 266: aload 7\n 268: checkcast #48 // class java/util/List\n 271: astore 8\n 273: astore 20\n 275: iconst_0\n 276: istore 9\n 278: aload 8\n 280: iconst_0\n 281: invokeinterface #131, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 286: checkcast #48 // class java/util/List\n 289: astore 10\n 291: aload 8\n 293: iconst_1\n 294: invokeinterface #131, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 299: checkcast #48 // class java/util/List\n 302: astore 11\n 304: aload 10\n 306: checkcast #62 // class java/lang/Iterable\n 309: aload 11\n 311: checkcast #62 // class java/lang/Iterable\n 314: invokestatic #135 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 317: checkcast #62 // class java/lang/Iterable\n 320: invokestatic #139 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 323: checkcast #62 // class java/lang/Iterable\n 326: invokestatic #143 // Method kotlin/collections/CollectionsKt.single:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 329: checkcast #70 // class java/lang/Character\n 332: invokevirtual #147 // Method java/lang/Character.charValue:()C\n 335: invokestatic #74 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 338: aload 20\n 340: swap\n 341: invokeinterface #127, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 346: pop\n 347: goto 245\n 350: aload 4\n 352: checkcast #48 // class java/util/List\n 355: nop\n 356: checkcast #62 // class java/lang/Iterable\n 359: astore_1\n 360: iconst_0\n 361: istore_2\n 362: aload_1\n 363: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 368: astore_3\n 369: aload_3\n 370: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 375: ifeq 418\n 378: aload_3\n 379: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 384: astore 4\n 386: iload_2\n 387: aload 4\n 389: checkcast #70 // class java/lang/Character\n 392: invokevirtual #147 // Method java/lang/Character.charValue:()C\n 395: istore 5\n 397: istore 20\n 399: iconst_0\n 400: istore 6\n 402: iload 5\n 404: invokestatic #149 // Method main$getPriority:(C)I\n 407: istore 21\n 409: iload 20\n 411: iload 21\n 413: iadd\n 414: istore_2\n 415: goto 369\n 418: iload_2\n 419: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #62 // class java/lang/Iterable\n 4: iconst_3\n 5: invokestatic #172 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;\n 8: checkcast #62 // class java/lang/Iterable\n 11: astore_1\n 12: nop\n 13: iconst_0\n 14: istore_2\n 15: aload_1\n 16: astore_3\n 17: new #83 // class java/util/ArrayList\n 20: dup\n 21: aload_1\n 22: bipush 10\n 24: invokestatic #87 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 27: invokespecial #89 // Method java/util/ArrayList.\"<init>\":(I)V\n 30: checkcast #91 // class java/util/Collection\n 33: astore 4\n 35: iconst_0\n 36: istore 5\n 38: aload_3\n 39: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 6\n 46: aload 6\n 48: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 187\n 56: aload 6\n 58: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 7\n 65: aload 4\n 67: aload 7\n 69: checkcast #48 // class java/util/List\n 72: astore 8\n 74: astore 13\n 76: iconst_0\n 77: istore 9\n 79: aload 8\n 81: iconst_0\n 82: invokeinterface #131, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 87: checkcast #107 // class java/lang/String\n 90: astore 10\n 92: aload 8\n 94: iconst_1\n 95: invokeinterface #131, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 100: checkcast #107 // class java/lang/String\n 103: astore 11\n 105: aload 8\n 107: iconst_2\n 108: invokeinterface #131, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 113: checkcast #107 // class java/lang/String\n 116: astore 12\n 118: aload 10\n 120: checkcast #109 // class java/lang/CharSequence\n 123: invokestatic #175 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 126: checkcast #62 // class java/lang/Iterable\n 129: aload 11\n 131: checkcast #109 // class java/lang/CharSequence\n 134: invokestatic #175 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 137: checkcast #62 // class java/lang/Iterable\n 140: invokestatic #139 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 143: checkcast #62 // class java/lang/Iterable\n 146: aload 12\n 148: checkcast #109 // class java/lang/CharSequence\n 151: invokestatic #175 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 154: checkcast #62 // class java/lang/Iterable\n 157: invokestatic #139 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 160: checkcast #62 // class java/lang/Iterable\n 163: invokestatic #143 // Method kotlin/collections/CollectionsKt.single:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 166: checkcast #70 // class java/lang/Character\n 169: invokevirtual #147 // Method java/lang/Character.charValue:()C\n 172: invokestatic #74 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 175: aload 13\n 177: swap\n 178: invokeinterface #127, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 183: pop\n 184: goto 46\n 187: aload 4\n 189: checkcast #48 // class java/util/List\n 192: nop\n 193: checkcast #62 // class java/lang/Iterable\n 196: astore_1\n 197: iconst_0\n 198: istore_2\n 199: aload_1\n 200: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 205: astore_3\n 206: aload_3\n 207: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 212: ifeq 255\n 215: aload_3\n 216: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 221: astore 4\n 223: iload_2\n 224: aload 4\n 226: checkcast #70 // class java/lang/Character\n 229: invokevirtual #147 // Method java/lang/Character.charValue:()C\n 232: istore 5\n 234: istore 13\n 236: iconst_0\n 237: istore 6\n 239: iload 5\n 241: invokestatic #149 // Method main$getPriority:(C)I\n 244: istore 14\n 246: iload 13\n 248: iload 14\n 250: iadd\n 251: istore_2\n 252: goto 206\n 255: iload_2\n 256: ireturn\n}\n",
"javap_err": ""
}
] |
buczebar__advent-of-code__cdb6fe3/src/Day12.kt
|
private typealias MapOfHeights = List<List<Char>>
private fun Char.elevation() =
when (this) {
'S' -> 0 // a
'E' -> 25 // z
else ->
('a'..'z').indexOf(this)
}
private fun MapOfHeights.getFirstPositionOf(mark: Char): Position {
forEachIndexed { index, row ->
if (row.contains(mark)) {
return row.indexOf(mark) to index
}
}
return -1 to -1
}
private fun MapOfHeights.getAllPositionsWithElevation(elevation: Int): List<Position> {
val positions = mutableListOf<Position>()
forEachIndexed { colIndex, items ->
items.forEachIndexed { rowIndex, item ->
if (item.elevation() == elevation) {
positions.add(rowIndex to colIndex)
}
}
}
return positions
}
private fun MapOfHeights.getPossibleMoves(position: Position): List<Position> {
val currentHeight = this[position.y][position.x].elevation()
val directions = listOf(-1 to 0, 0 to -1, 1 to 0, 0 to 1)
return directions
.map { direction -> position + direction }
.filter { it.x in first().indices && it.y in indices }
.filter { this[it.y][it.x].elevation() - currentHeight <= 1 }
}
private fun MapOfHeights.findShortestPathLength(
start: Position,
destination: Position
): Int {
val queue = mutableListOf(start)
val visited = mutableSetOf(start)
val predecessors = mutableMapOf<Position, Position>()
while (queue.isNotEmpty()) {
val currentItem = queue.popHead()
val availableMoves = getPossibleMoves(currentItem)
availableMoves.forEach { next ->
if (!visited.contains(next)) {
visited.add(next)
predecessors[next] = currentItem
queue.add(next)
if (next == destination) {
queue.clear()
return@forEach
}
}
}
}
var lenth = 0
var crawl: Position? = destination
while (predecessors[crawl] != null) {
crawl = predecessors[crawl]
lenth++
}
return lenth
}
fun main() {
fun part1(mapOfHeights: MapOfHeights): Int {
val (start, destination) = mapOfHeights.getFirstPositionOf('S') to mapOfHeights.getFirstPositionOf('E')
return mapOfHeights.findShortestPathLength(start, destination)
}
fun part2(mapOfHeights: MapOfHeights): Int {
val allStartingPoints = mapOfHeights.getAllPositionsWithElevation(0)
val destination = mapOfHeights.getFirstPositionOf('E')
val allPaths = allStartingPoints.map { startingPoint ->
mapOfHeights.findShortestPathLength(
startingPoint, destination
)
}
return allPaths.filter { it != 0 }.min()
}
val testInput = readInput("Day12_test").map { it.toList() }
check(part1(testInput) == 31)
check(part2(testInput) == 29)
val input = readInput("Day12").map { it.toList() }
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day12Kt.class",
"javap": "Compiled from \"Day12.kt\"\npublic final class Day12Kt {\n private static final int elevation(char);\n Code:\n 0: iload_0\n 1: lookupswitch { // 2\n 69: 32\n 83: 28\n default: 37\n }\n 28: iconst_0\n 29: goto 58\n 32: bipush 25\n 34: goto 58\n 37: new #8 // class kotlin/ranges/CharRange\n 40: dup\n 41: bipush 97\n 43: bipush 122\n 45: invokespecial #12 // Method kotlin/ranges/CharRange.\"<init>\":(CC)V\n 48: checkcast #14 // class java/lang/Iterable\n 51: iload_0\n 52: invokestatic #20 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 55: invokestatic #26 // Method kotlin/collections/CollectionsKt.indexOf:(Ljava/lang/Iterable;Ljava/lang/Object;)I\n 58: ireturn\n\n private static final kotlin.Pair<java.lang.Integer, java.lang.Integer> getFirstPositionOf(java.util.List<? extends java.util.List<java.lang.Character>>, char);\n Code:\n 0: aload_0\n 1: checkcast #14 // class java/lang/Iterable\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: iconst_0\n 8: istore 4\n 10: aload_2\n 11: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 16: astore 5\n 18: aload 5\n 20: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 25: ifeq 108\n 28: aload 5\n 30: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 35: astore 6\n 37: iload 4\n 39: iinc 4, 1\n 42: istore 7\n 44: iload 7\n 46: ifge 52\n 49: invokestatic #49 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 52: iload 7\n 54: aload 6\n 56: checkcast #51 // class java/util/List\n 59: astore 8\n 61: istore 9\n 63: iconst_0\n 64: istore 10\n 66: aload 8\n 68: iload_1\n 69: invokestatic #20 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 72: invokeinterface #55, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 77: ifeq 103\n 80: aload 8\n 82: iload_1\n 83: invokestatic #20 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 86: invokeinterface #58, 2 // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I\n 91: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 94: iload 9\n 96: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 99: invokestatic #69 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 102: areturn\n 103: nop\n 104: nop\n 105: goto 18\n 108: nop\n 109: iconst_m1\n 110: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 113: iconst_m1\n 114: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 117: invokestatic #69 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 120: areturn\n\n private static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> getAllPositionsWithElevation(java.util.List<? extends java.util.List<java.lang.Character>>, int);\n Code:\n 0: new #87 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #89 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #51 // class java/util/List\n 10: astore_2\n 11: aload_0\n 12: checkcast #14 // 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 #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 28: astore 6\n 30: aload 6\n 32: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 37: ifeq 191\n 40: aload 6\n 42: invokeinterface #45, 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 #49 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 64: iload 8\n 66: aload 7\n 68: checkcast #51 // class java/util/List\n 71: astore 9\n 73: istore 10\n 75: iconst_0\n 76: istore 11\n 78: aload 9\n 80: checkcast #14 // class java/lang/Iterable\n 83: astore 12\n 85: iconst_0\n 86: istore 13\n 88: iconst_0\n 89: istore 14\n 91: aload 12\n 93: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 98: astore 15\n 100: aload 15\n 102: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 107: ifeq 185\n 110: aload 15\n 112: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 117: astore 16\n 119: iload 14\n 121: iinc 14, 1\n 124: istore 17\n 126: iload 17\n 128: ifge 134\n 131: invokestatic #49 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 134: iload 17\n 136: aload 16\n 138: checkcast #16 // class java/lang/Character\n 141: invokevirtual #93 // Method java/lang/Character.charValue:()C\n 144: istore 18\n 146: istore 19\n 148: iconst_0\n 149: istore 20\n 151: iload 18\n 153: invokestatic #95 // Method elevation:(C)I\n 156: iload_1\n 157: if_icmpne 180\n 160: aload_2\n 161: iload 19\n 163: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 166: iload 10\n 168: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 171: invokestatic #69 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 174: invokeinterface #98, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 179: pop\n 180: nop\n 181: nop\n 182: goto 100\n 185: nop\n 186: nop\n 187: nop\n 188: goto 30\n 191: nop\n 192: aload_2\n 193: areturn\n\n private static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> getPossibleMoves(java.util.List<? extends java.util.List<java.lang.Character>>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #115 // Method UtilsKt.getY:(Lkotlin/Pair;)I\n 5: invokeinterface #119, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 10: checkcast #51 // class java/util/List\n 13: aload_1\n 14: invokestatic #122 // Method UtilsKt.getX:(Lkotlin/Pair;)I\n 17: invokeinterface #119, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 22: checkcast #16 // class java/lang/Character\n 25: invokevirtual #93 // Method java/lang/Character.charValue:()C\n 28: invokestatic #95 // Method elevation:(C)I\n 31: istore_2\n 32: iconst_4\n 33: anewarray #124 // class kotlin/Pair\n 36: astore 4\n 38: aload 4\n 40: iconst_0\n 41: iconst_m1\n 42: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 45: iconst_0\n 46: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 49: invokestatic #69 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 52: aastore\n 53: aload 4\n 55: iconst_1\n 56: iconst_0\n 57: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 60: iconst_m1\n 61: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 64: invokestatic #69 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 67: aastore\n 68: aload 4\n 70: iconst_2\n 71: iconst_1\n 72: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 75: iconst_0\n 76: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 79: invokestatic #69 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 82: aastore\n 83: aload 4\n 85: iconst_3\n 86: iconst_0\n 87: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 90: iconst_1\n 91: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 94: invokestatic #69 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 97: aastore\n 98: aload 4\n 100: invokestatic #128 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 103: astore_3\n 104: aload_3\n 105: checkcast #14 // class java/lang/Iterable\n 108: astore 4\n 110: nop\n 111: iconst_0\n 112: istore 5\n 114: aload 4\n 116: astore 6\n 118: new #87 // class java/util/ArrayList\n 121: dup\n 122: aload 4\n 124: bipush 10\n 126: invokestatic #132 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 129: invokespecial #135 // Method java/util/ArrayList.\"<init>\":(I)V\n 132: checkcast #137 // class java/util/Collection\n 135: astore 7\n 137: iconst_0\n 138: istore 8\n 140: aload 6\n 142: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 147: astore 9\n 149: aload 9\n 151: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 156: ifeq 200\n 159: aload 9\n 161: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 166: astore 10\n 168: aload 7\n 170: aload 10\n 172: checkcast #124 // class kotlin/Pair\n 175: astore 11\n 177: astore 15\n 179: iconst_0\n 180: istore 12\n 182: aload_1\n 183: aload 11\n 185: invokestatic #141 // Method UtilsKt.plus:(Lkotlin/Pair;Lkotlin/Pair;)Lkotlin/Pair;\n 188: aload 15\n 190: swap\n 191: invokeinterface #142, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 196: pop\n 197: goto 149\n 200: aload 7\n 202: checkcast #51 // class java/util/List\n 205: nop\n 206: checkcast #14 // class java/lang/Iterable\n 209: astore 4\n 211: nop\n 212: iconst_0\n 213: istore 5\n 215: aload 4\n 217: astore 6\n 219: new #87 // class java/util/ArrayList\n 222: dup\n 223: invokespecial #89 // Method java/util/ArrayList.\"<init>\":()V\n 226: checkcast #137 // class java/util/Collection\n 229: astore 7\n 231: iconst_0\n 232: istore 8\n 234: aload 6\n 236: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 241: astore 9\n 243: aload 9\n 245: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 250: ifeq 382\n 253: aload 9\n 255: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 260: astore 10\n 262: aload 10\n 264: checkcast #124 // class kotlin/Pair\n 267: astore 11\n 269: iconst_0\n 270: istore 12\n 272: aload_0\n 273: invokestatic #146 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 276: checkcast #137 // class java/util/Collection\n 279: invokeinterface #150, 1 // InterfaceMethod java/util/Collection.size:()I\n 284: istore 13\n 286: aload 11\n 288: invokestatic #122 // Method UtilsKt.getX:(Lkotlin/Pair;)I\n 291: istore 14\n 293: iconst_0\n 294: iload 14\n 296: if_icmpgt 314\n 299: iload 14\n 301: iload 13\n 303: if_icmpge 310\n 306: iconst_1\n 307: goto 315\n 310: iconst_0\n 311: goto 315\n 314: iconst_0\n 315: ifeq 365\n 318: aload_0\n 319: checkcast #137 // class java/util/Collection\n 322: invokeinterface #150, 1 // InterfaceMethod java/util/Collection.size:()I\n 327: istore 13\n 329: aload 11\n 331: invokestatic #115 // Method UtilsKt.getY:(Lkotlin/Pair;)I\n 334: istore 14\n 336: iconst_0\n 337: iload 14\n 339: if_icmpgt 357\n 342: iload 14\n 344: iload 13\n 346: if_icmpge 353\n 349: iconst_1\n 350: goto 358\n 353: iconst_0\n 354: goto 358\n 357: iconst_0\n 358: ifeq 365\n 361: iconst_1\n 362: goto 366\n 365: iconst_0\n 366: ifeq 243\n 369: aload 7\n 371: aload 10\n 373: invokeinterface #142, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 378: pop\n 379: goto 243\n 382: aload 7\n 384: checkcast #51 // class java/util/List\n 387: nop\n 388: checkcast #14 // class java/lang/Iterable\n 391: astore 4\n 393: nop\n 394: iconst_0\n 395: istore 5\n 397: aload 4\n 399: astore 6\n 401: new #87 // class java/util/ArrayList\n 404: dup\n 405: invokespecial #89 // Method java/util/ArrayList.\"<init>\":()V\n 408: checkcast #137 // class java/util/Collection\n 411: astore 7\n 413: iconst_0\n 414: istore 8\n 416: aload 6\n 418: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 423: astore 9\n 425: aload 9\n 427: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 432: ifeq 514\n 435: aload 9\n 437: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 442: astore 10\n 444: aload 10\n 446: checkcast #124 // class kotlin/Pair\n 449: astore 11\n 451: iconst_0\n 452: istore 12\n 454: aload_0\n 455: aload 11\n 457: invokestatic #115 // Method UtilsKt.getY:(Lkotlin/Pair;)I\n 460: invokeinterface #119, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 465: checkcast #51 // class java/util/List\n 468: aload 11\n 470: invokestatic #122 // Method UtilsKt.getX:(Lkotlin/Pair;)I\n 473: invokeinterface #119, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 478: checkcast #16 // class java/lang/Character\n 481: invokevirtual #93 // Method java/lang/Character.charValue:()C\n 484: invokestatic #95 // Method elevation:(C)I\n 487: iload_2\n 488: isub\n 489: iconst_1\n 490: if_icmpgt 497\n 493: iconst_1\n 494: goto 498\n 497: iconst_0\n 498: ifeq 425\n 501: aload 7\n 503: aload 10\n 505: invokeinterface #142, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 510: pop\n 511: goto 425\n 514: aload 7\n 516: checkcast #51 // class java/util/List\n 519: nop\n 520: areturn\n\n private static final int findShortestPathLength(java.util.List<? extends java.util.List<java.lang.Character>>, kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: iconst_1\n 1: anewarray #124 // class kotlin/Pair\n 4: astore 4\n 6: aload 4\n 8: iconst_0\n 9: aload_1\n 10: aastore\n 11: aload 4\n 13: invokestatic #178 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 16: astore_3\n 17: iconst_1\n 18: anewarray #124 // class kotlin/Pair\n 21: astore 5\n 23: aload 5\n 25: iconst_0\n 26: aload_1\n 27: aastore\n 28: aload 5\n 30: invokestatic #184 // Method kotlin/collections/SetsKt.mutableSetOf:([Ljava/lang/Object;)Ljava/util/Set;\n 33: astore 4\n 35: new #186 // class java/util/LinkedHashMap\n 38: dup\n 39: invokespecial #187 // Method java/util/LinkedHashMap.\"<init>\":()V\n 42: checkcast #189 // class java/util/Map\n 45: astore 5\n 47: aload_3\n 48: checkcast #137 // class java/util/Collection\n 51: invokeinterface #192, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 56: ifne 63\n 59: iconst_1\n 60: goto 64\n 63: iconst_0\n 64: ifeq 202\n 67: aload_3\n 68: invokestatic #195 // Method UtilsKt.popHead:(Ljava/util/List;)Ljava/lang/Object;\n 71: checkcast #124 // class kotlin/Pair\n 74: astore 6\n 76: aload_0\n 77: aload 6\n 79: invokestatic #197 // Method getPossibleMoves:(Ljava/util/List;Lkotlin/Pair;)Ljava/util/List;\n 82: astore 7\n 84: aload 7\n 86: checkcast #14 // class java/lang/Iterable\n 89: astore 8\n 91: iconst_0\n 92: istore 9\n 94: aload 8\n 96: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 101: astore 10\n 103: aload 10\n 105: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 110: ifeq 198\n 113: aload 10\n 115: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 120: astore 11\n 122: aload 11\n 124: checkcast #124 // class kotlin/Pair\n 127: astore 12\n 129: iconst_0\n 130: istore 13\n 132: aload 4\n 134: aload 12\n 136: invokeinterface #200, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 141: ifne 193\n 144: aload 4\n 146: aload 12\n 148: invokeinterface #201, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 153: pop\n 154: aload 5\n 156: aload 12\n 158: aload 6\n 160: invokeinterface #205, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 165: pop\n 166: aload_3\n 167: aload 12\n 169: invokeinterface #98, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 174: pop\n 175: aload 12\n 177: aload_2\n 178: invokestatic #211 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 181: ifeq 193\n 184: aload_3\n 185: invokeinterface #214, 1 // InterfaceMethod java/util/List.clear:()V\n 190: goto 194\n 193: nop\n 194: nop\n 195: goto 103\n 198: nop\n 199: goto 47\n 202: iconst_0\n 203: istore 6\n 205: aload_2\n 206: astore 7\n 208: aload 5\n 210: aload 7\n 212: invokeinterface #217, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 217: ifnull 240\n 220: aload 5\n 222: aload 7\n 224: invokeinterface #217, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 229: checkcast #124 // class kotlin/Pair\n 232: astore 7\n 234: iinc 6, 1\n 237: goto 208\n 240: iload 6\n 242: ireturn\n\n public static final void main();\n Code:\n 0: ldc #236 // String Day12_test\n 2: invokestatic #240 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: checkcast #14 // class java/lang/Iterable\n 8: astore_1\n 9: iconst_0\n 10: istore_2\n 11: aload_1\n 12: astore_3\n 13: new #87 // class java/util/ArrayList\n 16: dup\n 17: aload_1\n 18: bipush 10\n 20: invokestatic #132 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 23: invokespecial #135 // Method java/util/ArrayList.\"<init>\":(I)V\n 26: checkcast #137 // class java/util/Collection\n 29: astore 4\n 31: iconst_0\n 32: istore 5\n 34: aload_3\n 35: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 40: astore 6\n 42: aload 6\n 44: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 49: ifeq 95\n 52: aload 6\n 54: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 59: astore 7\n 61: aload 4\n 63: aload 7\n 65: checkcast #242 // class java/lang/String\n 68: astore 8\n 70: astore 11\n 72: iconst_0\n 73: istore 9\n 75: aload 8\n 77: checkcast #244 // class java/lang/CharSequence\n 80: invokestatic #250 // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;\n 83: aload 11\n 85: swap\n 86: invokeinterface #142, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 91: pop\n 92: goto 42\n 95: aload 4\n 97: checkcast #51 // class java/util/List\n 100: nop\n 101: astore_0\n 102: aload_0\n 103: invokestatic #254 // Method main$part1:(Ljava/util/List;)I\n 106: bipush 31\n 108: if_icmpne 115\n 111: iconst_1\n 112: goto 116\n 115: iconst_0\n 116: ifne 130\n 119: new #256 // class java/lang/IllegalStateException\n 122: dup\n 123: ldc_w #258 // String Check failed.\n 126: invokespecial #261 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 129: athrow\n 130: aload_0\n 131: invokestatic #264 // Method main$part2:(Ljava/util/List;)I\n 134: bipush 29\n 136: if_icmpne 143\n 139: iconst_1\n 140: goto 144\n 143: iconst_0\n 144: ifne 158\n 147: new #256 // class java/lang/IllegalStateException\n 150: dup\n 151: ldc_w #258 // String Check failed.\n 154: invokespecial #261 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 157: athrow\n 158: ldc_w #266 // String Day12\n 161: invokestatic #240 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 164: checkcast #14 // class java/lang/Iterable\n 167: astore_2\n 168: iconst_0\n 169: istore_3\n 170: aload_2\n 171: astore 4\n 173: new #87 // class java/util/ArrayList\n 176: dup\n 177: aload_2\n 178: bipush 10\n 180: invokestatic #132 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 183: invokespecial #135 // Method java/util/ArrayList.\"<init>\":(I)V\n 186: checkcast #137 // class java/util/Collection\n 189: astore 5\n 191: iconst_0\n 192: istore 6\n 194: aload 4\n 196: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 201: astore 7\n 203: aload 7\n 205: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 210: ifeq 256\n 213: aload 7\n 215: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 220: astore 8\n 222: aload 5\n 224: aload 8\n 226: checkcast #242 // class java/lang/String\n 229: astore 9\n 231: astore 11\n 233: iconst_0\n 234: istore 10\n 236: aload 9\n 238: checkcast #244 // class java/lang/CharSequence\n 241: invokestatic #250 // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;\n 244: aload 11\n 246: swap\n 247: invokeinterface #142, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 252: pop\n 253: goto 203\n 256: aload 5\n 258: checkcast #51 // class java/util/List\n 261: nop\n 262: astore_1\n 263: aload_1\n 264: invokestatic #254 // Method main$part1:(Ljava/util/List;)I\n 267: istore_2\n 268: getstatic #272 // Field java/lang/System.out:Ljava/io/PrintStream;\n 271: iload_2\n 272: invokevirtual #277 // Method java/io/PrintStream.println:(I)V\n 275: aload_1\n 276: invokestatic #264 // Method main$part2:(Ljava/util/List;)I\n 279: istore_2\n 280: getstatic #272 // Field java/lang/System.out:Ljava/io/PrintStream;\n 283: iload_2\n 284: invokevirtual #277 // Method java/io/PrintStream.println:(I)V\n 287: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #285 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<? extends java.util.List<java.lang.Character>>);\n Code:\n 0: aload_0\n 1: bipush 83\n 3: invokestatic #290 // Method getFirstPositionOf:(Ljava/util/List;C)Lkotlin/Pair;\n 6: aload_0\n 7: bipush 69\n 9: invokestatic #290 // Method getFirstPositionOf:(Ljava/util/List;C)Lkotlin/Pair;\n 12: invokestatic #69 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 15: astore_1\n 16: aload_1\n 17: invokevirtual #293 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 20: checkcast #124 // class kotlin/Pair\n 23: astore_2\n 24: aload_1\n 25: invokevirtual #296 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 28: checkcast #124 // class kotlin/Pair\n 31: astore_3\n 32: aload_0\n 33: aload_2\n 34: aload_3\n 35: invokestatic #298 // Method findShortestPathLength:(Ljava/util/List;Lkotlin/Pair;Lkotlin/Pair;)I\n 38: ireturn\n\n private static final int main$part2(java.util.List<? extends java.util.List<java.lang.Character>>);\n Code:\n 0: aload_0\n 1: iconst_0\n 2: invokestatic #301 // Method getAllPositionsWithElevation:(Ljava/util/List;I)Ljava/util/List;\n 5: astore_1\n 6: aload_0\n 7: bipush 69\n 9: invokestatic #290 // Method getFirstPositionOf:(Ljava/util/List;C)Lkotlin/Pair;\n 12: astore_2\n 13: aload_1\n 14: checkcast #14 // class java/lang/Iterable\n 17: astore 4\n 19: iconst_0\n 20: istore 5\n 22: aload 4\n 24: astore 6\n 26: new #87 // class java/util/ArrayList\n 29: dup\n 30: aload 4\n 32: bipush 10\n 34: invokestatic #132 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 37: invokespecial #135 // Method java/util/ArrayList.\"<init>\":(I)V\n 40: checkcast #137 // class java/util/Collection\n 43: astore 7\n 45: iconst_0\n 46: istore 8\n 48: aload 6\n 50: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 55: astore 9\n 57: aload 9\n 59: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 64: ifeq 113\n 67: aload 9\n 69: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 74: astore 10\n 76: aload 7\n 78: aload 10\n 80: checkcast #124 // class kotlin/Pair\n 83: astore 11\n 85: astore 13\n 87: iconst_0\n 88: istore 12\n 90: aload_0\n 91: aload 11\n 93: aload_2\n 94: invokestatic #298 // Method findShortestPathLength:(Ljava/util/List;Lkotlin/Pair;Lkotlin/Pair;)I\n 97: nop\n 98: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 101: aload 13\n 103: swap\n 104: invokeinterface #142, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 109: pop\n 110: goto 57\n 113: aload 7\n 115: checkcast #51 // class java/util/List\n 118: nop\n 119: astore_3\n 120: aload_3\n 121: checkcast #14 // class java/lang/Iterable\n 124: astore 4\n 126: iconst_0\n 127: istore 5\n 129: aload 4\n 131: astore 6\n 133: new #87 // class java/util/ArrayList\n 136: dup\n 137: invokespecial #89 // Method java/util/ArrayList.\"<init>\":()V\n 140: checkcast #137 // class java/util/Collection\n 143: astore 7\n 145: iconst_0\n 146: istore 8\n 148: aload 6\n 150: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 155: astore 9\n 157: aload 9\n 159: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 164: ifeq 215\n 167: aload 9\n 169: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 174: astore 10\n 176: aload 10\n 178: checkcast #303 // class java/lang/Number\n 181: invokevirtual #306 // Method java/lang/Number.intValue:()I\n 184: istore 11\n 186: iconst_0\n 187: istore 12\n 189: iload 11\n 191: ifeq 198\n 194: iconst_1\n 195: goto 199\n 198: iconst_0\n 199: ifeq 157\n 202: aload 7\n 204: aload 10\n 206: invokeinterface #142, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 211: pop\n 212: goto 157\n 215: aload 7\n 217: checkcast #51 // class java/util/List\n 220: nop\n 221: checkcast #14 // class java/lang/Iterable\n 224: invokestatic #310 // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 227: checkcast #303 // class java/lang/Number\n 230: invokevirtual #306 // Method java/lang/Number.intValue:()I\n 233: ireturn\n}\n",
"javap_err": ""
}
] |
buczebar__advent-of-code__cdb6fe3/src/Day10.kt
|
import kotlin.math.abs
fun main() {
fun getValuesInEachCycle(input: List<String>): List<Int> {
val valuesInCycles = mutableListOf(1)
var valueAfterLastCycle = valuesInCycles.first()
input.forEach { instruction ->
when {
instruction.startsWith("noop") -> {
valuesInCycles.add(valueAfterLastCycle)
}
instruction.startsWith("addx") -> {
val (_, value) = instruction.splitWords()
repeat(2) { valuesInCycles.add((valueAfterLastCycle)) }
valueAfterLastCycle += value.toInt()
}
}
}
return valuesInCycles
}
fun part1(input: List<String>): Int {
val indexes = listOf(20, 60, 100, 140, 180, 220)
val cycles = getValuesInEachCycle(input)
return indexes.sumOf { if (it < cycles.size) cycles[it] * it else 0 }
}
fun part2(input: List<String>) {
getValuesInEachCycle(input)
.dropHead()
.chunked(40)
.map { row ->
row.forEachIndexed { index, x ->
print(
when {
abs(x - index) <= 1 -> "#"
else -> "."
}
)
}
println()
}
}
val testInput = readInput("Day10_test")
check(part1(testInput) == 13_140)
part2(testInput)
val input = readInput("Day10")
println(part1(input))
part2(input)
}
|
[
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day10Kt.class",
"javap": "Compiled from \"Day10.kt\"\npublic final class Day10Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day10_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 10: sipush 13140\n 13: if_icmpne 20\n 16: iconst_1\n 17: goto 21\n 20: iconst_0\n 21: ifne 34\n 24: new #20 // class java/lang/IllegalStateException\n 27: dup\n 28: ldc #22 // String Check failed.\n 30: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 33: athrow\n 34: aload_0\n 35: invokestatic #30 // Method main$part2:(Ljava/util/List;)V\n 38: ldc #32 // String Day10\n 40: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 43: astore_1\n 44: aload_1\n 45: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 48: istore_2\n 49: getstatic #38 // Field java/lang/System.out:Ljava/io/PrintStream;\n 52: iload_2\n 53: invokevirtual #44 // Method java/io/PrintStream.println:(I)V\n 56: aload_1\n 57: invokestatic #30 // Method main$part2:(Ljava/util/List;)V\n 60: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #52 // Method main:()V\n 3: return\n\n private static final java.util.List<java.lang.Integer> main$getValuesInEachCycle(java.util.List<java.lang.String>);\n Code:\n 0: iconst_1\n 1: anewarray #59 // class java/lang/Integer\n 4: astore_2\n 5: aload_2\n 6: iconst_0\n 7: iconst_1\n 8: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 11: aastore\n 12: aload_2\n 13: invokestatic #69 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 16: astore_1\n 17: iconst_0\n 18: istore_2\n 19: aload_1\n 20: invokestatic #73 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 23: checkcast #75 // class java/lang/Number\n 26: invokevirtual #79 // Method java/lang/Number.intValue:()I\n 29: istore_2\n 30: aload_0\n 31: checkcast #81 // class java/lang/Iterable\n 34: astore_3\n 35: iconst_0\n 36: istore 4\n 38: aload_3\n 39: invokeinterface #85, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 5\n 46: aload 5\n 48: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 182\n 56: aload 5\n 58: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 6\n 65: aload 6\n 67: checkcast #97 // class java/lang/String\n 70: astore 7\n 72: iconst_0\n 73: istore 8\n 75: nop\n 76: aload 7\n 78: ldc #99 // String noop\n 80: iconst_0\n 81: iconst_2\n 82: aconst_null\n 83: invokestatic #105 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 86: ifeq 103\n 89: aload_1\n 90: iload_2\n 91: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 94: invokeinterface #109, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 99: pop\n 100: goto 177\n 103: aload 7\n 105: ldc #111 // String addx\n 107: iconst_0\n 108: iconst_2\n 109: aconst_null\n 110: invokestatic #105 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 113: ifeq 177\n 116: aload 7\n 118: invokestatic #114 // Method UtilsKt.splitWords:(Ljava/lang/String;)Ljava/util/List;\n 121: iconst_1\n 122: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 127: checkcast #97 // class java/lang/String\n 130: astore 9\n 132: iconst_2\n 133: istore 10\n 135: iconst_0\n 136: istore 11\n 138: iload 11\n 140: iload 10\n 142: if_icmpge 169\n 145: iload 11\n 147: istore 12\n 149: iconst_0\n 150: istore 13\n 152: aload_1\n 153: iload_2\n 154: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 157: invokeinterface #109, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 162: pop\n 163: iinc 11, 1\n 166: goto 138\n 169: iload_2\n 170: aload 9\n 172: invokestatic #122 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 175: iadd\n 176: istore_2\n 177: nop\n 178: nop\n 179: goto 46\n 182: nop\n 183: aload_1\n 184: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: bipush 6\n 2: anewarray #59 // class java/lang/Integer\n 5: astore_2\n 6: aload_2\n 7: iconst_0\n 8: bipush 20\n 10: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 13: aastore\n 14: aload_2\n 15: iconst_1\n 16: bipush 60\n 18: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 21: aastore\n 22: aload_2\n 23: iconst_2\n 24: bipush 100\n 26: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 29: aastore\n 30: aload_2\n 31: iconst_3\n 32: sipush 140\n 35: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 38: aastore\n 39: aload_2\n 40: iconst_4\n 41: sipush 180\n 44: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 47: aastore\n 48: aload_2\n 49: iconst_5\n 50: sipush 220\n 53: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 56: aastore\n 57: aload_2\n 58: invokestatic #140 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 61: astore_1\n 62: aload_0\n 63: invokestatic #142 // Method main$getValuesInEachCycle:(Ljava/util/List;)Ljava/util/List;\n 66: astore_2\n 67: aload_1\n 68: checkcast #81 // class java/lang/Iterable\n 71: astore_3\n 72: iconst_0\n 73: istore 4\n 75: aload_3\n 76: invokeinterface #85, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 81: astore 5\n 83: aload 5\n 85: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 90: ifeq 163\n 93: aload 5\n 95: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 100: astore 6\n 102: iload 4\n 104: aload 6\n 106: checkcast #75 // class java/lang/Number\n 109: invokevirtual #79 // Method java/lang/Number.intValue:()I\n 112: istore 7\n 114: istore 9\n 116: iconst_0\n 117: istore 8\n 119: iload 7\n 121: aload_2\n 122: invokeinterface #145, 1 // InterfaceMethod java/util/List.size:()I\n 127: if_icmpge 150\n 130: aload_2\n 131: iload 7\n 133: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 138: checkcast #75 // class java/lang/Number\n 141: invokevirtual #79 // Method java/lang/Number.intValue:()I\n 144: iload 7\n 146: imul\n 147: goto 151\n 150: iconst_0\n 151: istore 10\n 153: iload 9\n 155: iload 10\n 157: iadd\n 158: istore 4\n 160: goto 83\n 163: iload 4\n 165: ireturn\n\n private static final void main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #142 // Method main$getValuesInEachCycle:(Ljava/util/List;)Ljava/util/List;\n 4: invokestatic #152 // Method UtilsKt.dropHead:(Ljava/util/List;)Ljava/util/List;\n 7: checkcast #81 // class java/lang/Iterable\n 10: bipush 40\n 12: invokestatic #156 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;\n 15: checkcast #81 // class java/lang/Iterable\n 18: astore_1\n 19: nop\n 20: iconst_0\n 21: istore_2\n 22: aload_1\n 23: astore_3\n 24: new #158 // class java/util/ArrayList\n 27: dup\n 28: aload_1\n 29: bipush 10\n 31: invokestatic #162 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 34: invokespecial #164 // Method java/util/ArrayList.\"<init>\":(I)V\n 37: checkcast #166 // class java/util/Collection\n 40: astore 4\n 42: iconst_0\n 43: istore 5\n 45: aload_3\n 46: invokeinterface #85, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 51: astore 6\n 53: aload 6\n 55: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 60: ifeq 216\n 63: aload 6\n 65: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 70: astore 7\n 72: aload 4\n 74: aload 7\n 76: checkcast #49 // class java/util/List\n 79: astore 8\n 81: astore 20\n 83: iconst_0\n 84: istore 9\n 86: aload 8\n 88: checkcast #81 // class java/lang/Iterable\n 91: astore 10\n 93: iconst_0\n 94: istore 11\n 96: iconst_0\n 97: istore 12\n 99: aload 10\n 101: invokeinterface #85, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 106: astore 13\n 108: aload 13\n 110: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 115: ifeq 194\n 118: aload 13\n 120: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 125: astore 14\n 127: iload 12\n 129: iinc 12, 1\n 132: istore 15\n 134: iload 15\n 136: ifge 142\n 139: invokestatic #169 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 142: iload 15\n 144: aload 14\n 146: checkcast #75 // class java/lang/Number\n 149: invokevirtual #79 // Method java/lang/Number.intValue:()I\n 152: istore 16\n 154: istore 17\n 156: iconst_0\n 157: istore 18\n 159: nop\n 160: iload 16\n 162: iload 17\n 164: isub\n 165: invokestatic #175 // Method java/lang/Math.abs:(I)I\n 168: iconst_1\n 169: if_icmpgt 177\n 172: ldc #177 // String #\n 174: goto 179\n 177: ldc #179 // String .\n 179: astore 19\n 181: getstatic #38 // Field java/lang/System.out:Ljava/io/PrintStream;\n 184: aload 19\n 186: invokevirtual #183 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 189: nop\n 190: nop\n 191: goto 108\n 194: nop\n 195: getstatic #38 // Field java/lang/System.out:Ljava/io/PrintStream;\n 198: invokevirtual #185 // Method java/io/PrintStream.println:()V\n 201: nop\n 202: aload 20\n 204: getstatic #191 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 207: invokeinterface #192, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 212: pop\n 213: goto 53\n 216: aload 4\n 218: checkcast #49 // class java/util/List\n 221: nop\n 222: pop\n 223: return\n}\n",
"javap_err": ""
}
] |
buczebar__advent-of-code__cdb6fe3/src/Day09.kt
|
import java.lang.IllegalArgumentException
import kotlin.math.abs
typealias Point = Pair<Int, Int>
private fun Point.isTouching(point: Point) = abs(first - point.first) < 2 && abs(second - point.second) < 2
fun main() {
fun parseInput(name: String) = readInput(name).map { it.splitWords() }
.map { (direction, steps) -> direction to steps.toInt() }
fun getAllKnotsPositions(moves: List<Pair<String, Int>>, numOfKnots: Int): List<List<Point>> {
fun getNextHeadPosition(position: Point, direction: String) = when (direction) {
"L" -> Pair(position.first - 1, position.second)
"R" -> Pair(position.first + 1, position.second)
"U" -> Pair(position.first, position.second + 1)
"D" -> Pair(position.first, position.second - 1)
else -> throw IllegalArgumentException("Wrong direction $direction")
}
fun followingPosition(currentPosition: Point, leaderPosition: Point) = Point(
currentPosition.first + leaderPosition.first.compareTo(currentPosition.first),
currentPosition.second + leaderPosition.second.compareTo(currentPosition.second)
)
val startingPoint = 0 to 0
val knotsPositions = List(numOfKnots) { mutableListOf(startingPoint) }
moves.forEach { (direction, steps) ->
repeat(steps) {
val headPositions = knotsPositions.head()
headPositions.add(getNextHeadPosition(headPositions.last(), direction))
knotsPositions.forEachIndexed { index, currentKnotPositions ->
if (index == 0) return@forEachIndexed
val previousKnotPosition = knotsPositions[index - 1].last()
val currentKnotPosition = currentKnotPositions.last()
if (!previousKnotPosition.isTouching(currentKnotPosition)) {
currentKnotPositions.add(followingPosition(currentKnotPosition, previousKnotPosition))
} else {
currentKnotPositions.add(currentKnotPosition)
}
}
}
}
return knotsPositions
}
fun part1(input: List<Pair<String, Int>>): Int {
return getAllKnotsPositions(input, 2).last().distinct().size
}
fun part2(input: List<Pair<String, Int>>): Int {
return getAllKnotsPositions(input, 10).last().distinct().size
}
val testInput = parseInput("Day09_test")
val testInputPart2 = parseInput("Day09_test2")
check(part1(testInput) == 13)
check(part2(testInput) == 1)
check(part2(testInputPart2) == 36)
val input = parseInput("Day09")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day09Kt.class",
"javap": "Compiled from \"Day09.kt\"\npublic final class Day09Kt {\n private static final boolean isTouching(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: invokevirtual #13 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 4: checkcast #15 // class java/lang/Number\n 7: invokevirtual #19 // Method java/lang/Number.intValue:()I\n 10: aload_1\n 11: invokevirtual #13 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 14: checkcast #15 // class java/lang/Number\n 17: invokevirtual #19 // Method java/lang/Number.intValue:()I\n 20: isub\n 21: invokestatic #25 // Method java/lang/Math.abs:(I)I\n 24: iconst_2\n 25: if_icmpge 60\n 28: aload_0\n 29: invokevirtual #28 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 32: checkcast #15 // class java/lang/Number\n 35: invokevirtual #19 // Method java/lang/Number.intValue:()I\n 38: aload_1\n 39: invokevirtual #28 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 42: checkcast #15 // class java/lang/Number\n 45: invokevirtual #19 // Method java/lang/Number.intValue:()I\n 48: isub\n 49: invokestatic #25 // Method java/lang/Math.abs:(I)I\n 52: iconst_2\n 53: if_icmpge 60\n 56: iconst_1\n 57: goto 61\n 60: iconst_0\n 61: ireturn\n\n public static final void main();\n Code:\n 0: ldc #35 // String Day09_test\n 2: invokestatic #39 // Method main$parseInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: ldc #41 // String Day09_test2\n 8: invokestatic #39 // Method main$parseInput:(Ljava/lang/String;)Ljava/util/List;\n 11: astore_1\n 12: aload_0\n 13: invokestatic #45 // Method main$part1:(Ljava/util/List;)I\n 16: bipush 13\n 18: if_icmpne 25\n 21: iconst_1\n 22: goto 26\n 25: iconst_0\n 26: ifne 39\n 29: new #47 // class java/lang/IllegalStateException\n 32: dup\n 33: ldc #49 // String Check failed.\n 35: invokespecial #53 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 38: athrow\n 39: aload_0\n 40: invokestatic #56 // Method main$part2:(Ljava/util/List;)I\n 43: iconst_1\n 44: if_icmpne 51\n 47: iconst_1\n 48: goto 52\n 51: iconst_0\n 52: ifne 65\n 55: new #47 // class java/lang/IllegalStateException\n 58: dup\n 59: ldc #49 // String Check failed.\n 61: invokespecial #53 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 64: athrow\n 65: aload_1\n 66: invokestatic #56 // Method main$part2:(Ljava/util/List;)I\n 69: bipush 36\n 71: if_icmpne 78\n 74: iconst_1\n 75: goto 79\n 78: iconst_0\n 79: ifne 92\n 82: new #47 // class java/lang/IllegalStateException\n 85: dup\n 86: ldc #49 // String Check failed.\n 88: invokespecial #53 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 91: athrow\n 92: ldc #58 // String Day09\n 94: invokestatic #39 // Method main$parseInput:(Ljava/lang/String;)Ljava/util/List;\n 97: astore_2\n 98: aload_2\n 99: invokestatic #45 // Method main$part1:(Ljava/util/List;)I\n 102: istore_3\n 103: getstatic #64 // Field java/lang/System.out:Ljava/io/PrintStream;\n 106: iload_3\n 107: invokevirtual #70 // Method java/io/PrintStream.println:(I)V\n 110: aload_2\n 111: invokestatic #56 // Method main$part2:(Ljava/util/List;)I\n 114: istore_3\n 115: getstatic #64 // Field java/lang/System.out:Ljava/io/PrintStream;\n 118: iload_3\n 119: invokevirtual #70 // Method java/io/PrintStream.println:(I)V\n 122: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #79 // Method main:()V\n 3: return\n\n private static final java.util.List<kotlin.Pair<java.lang.String, java.lang.Integer>> main$parseInput(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #87 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 4: checkcast #89 // class java/lang/Iterable\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: astore_3\n 12: new #91 // class java/util/ArrayList\n 15: dup\n 16: aload_1\n 17: bipush 10\n 19: invokestatic #97 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 22: invokespecial #99 // Method java/util/ArrayList.\"<init>\":(I)V\n 25: checkcast #101 // class java/util/Collection\n 28: astore 4\n 30: iconst_0\n 31: istore 5\n 33: aload_3\n 34: invokeinterface #105, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 6\n 41: aload 6\n 43: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 91\n 51: aload 6\n 53: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 7\n 60: aload 4\n 62: aload 7\n 64: checkcast #116 // class java/lang/String\n 67: astore 8\n 69: astore 12\n 71: iconst_0\n 72: istore 9\n 74: aload 8\n 76: invokestatic #119 // Method UtilsKt.splitWords:(Ljava/lang/String;)Ljava/util/List;\n 79: aload 12\n 81: swap\n 82: invokeinterface #123, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 87: pop\n 88: goto 41\n 91: aload 4\n 93: checkcast #76 // class java/util/List\n 96: nop\n 97: checkcast #89 // class java/lang/Iterable\n 100: astore_1\n 101: nop\n 102: iconst_0\n 103: istore_2\n 104: aload_1\n 105: astore_3\n 106: new #91 // class java/util/ArrayList\n 109: dup\n 110: aload_1\n 111: bipush 10\n 113: invokestatic #97 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 116: invokespecial #99 // Method java/util/ArrayList.\"<init>\":(I)V\n 119: checkcast #101 // class java/util/Collection\n 122: astore 4\n 124: iconst_0\n 125: istore 5\n 127: aload_3\n 128: invokeinterface #105, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 133: astore 6\n 135: aload 6\n 137: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 142: ifeq 219\n 145: aload 6\n 147: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 152: astore 7\n 154: aload 4\n 156: aload 7\n 158: checkcast #76 // class java/util/List\n 161: astore 8\n 163: astore 12\n 165: iconst_0\n 166: istore 9\n 168: aload 8\n 170: iconst_0\n 171: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 176: checkcast #116 // class java/lang/String\n 179: astore 10\n 181: aload 8\n 183: iconst_1\n 184: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 189: checkcast #116 // class java/lang/String\n 192: astore 11\n 194: aload 10\n 196: aload 11\n 198: invokestatic #133 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 201: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 204: invokestatic #143 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 207: aload 12\n 209: swap\n 210: invokeinterface #123, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 215: pop\n 216: goto 135\n 219: aload 4\n 221: checkcast #76 // class java/util/List\n 224: nop\n 225: areturn\n\n private static final kotlin.Pair<java.lang.Integer, java.lang.Integer> main$getAllKnotsPositions$getNextHeadPosition(kotlin.Pair<java.lang.Integer, java.lang.Integer>, java.lang.String);\n Code:\n 0: aload_1\n 1: astore_2\n 2: aload_2\n 3: invokevirtual #166 // Method java/lang/String.hashCode:()I\n 6: lookupswitch { // 4\n 68: 60\n 76: 84\n 82: 48\n 85: 72\n default: 209\n }\n 48: aload_2\n 49: ldc #168 // String R\n 51: invokevirtual #171 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 54: ifne 122\n 57: goto 209\n 60: aload_2\n 61: ldc #173 // String D\n 63: invokevirtual #171 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 66: ifne 180\n 69: goto 209\n 72: aload_2\n 73: ldc #175 // String U\n 75: invokevirtual #171 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 78: ifne 151\n 81: goto 209\n 84: aload_2\n 85: ldc #177 // String L\n 87: invokevirtual #171 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 90: ifeq 209\n 93: new #9 // class kotlin/Pair\n 96: dup\n 97: aload_0\n 98: invokevirtual #13 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 101: checkcast #15 // class java/lang/Number\n 104: invokevirtual #19 // Method java/lang/Number.intValue:()I\n 107: iconst_1\n 108: isub\n 109: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 112: aload_0\n 113: invokevirtual #28 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 116: invokespecial #180 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 119: goto 236\n 122: new #9 // class kotlin/Pair\n 125: dup\n 126: aload_0\n 127: invokevirtual #13 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 130: checkcast #15 // class java/lang/Number\n 133: invokevirtual #19 // Method java/lang/Number.intValue:()I\n 136: iconst_1\n 137: iadd\n 138: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 141: aload_0\n 142: invokevirtual #28 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 145: invokespecial #180 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 148: goto 236\n 151: new #9 // class kotlin/Pair\n 154: dup\n 155: aload_0\n 156: invokevirtual #13 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 159: aload_0\n 160: invokevirtual #28 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 163: checkcast #15 // class java/lang/Number\n 166: invokevirtual #19 // Method java/lang/Number.intValue:()I\n 169: iconst_1\n 170: iadd\n 171: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 174: invokespecial #180 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 177: goto 236\n 180: new #9 // class kotlin/Pair\n 183: dup\n 184: aload_0\n 185: invokevirtual #13 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 188: aload_0\n 189: invokevirtual #28 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 192: checkcast #15 // class java/lang/Number\n 195: invokevirtual #19 // Method java/lang/Number.intValue:()I\n 198: iconst_1\n 199: isub\n 200: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 203: invokespecial #180 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 206: goto 236\n 209: new #182 // class java/lang/IllegalArgumentException\n 212: dup\n 213: new #184 // class java/lang/StringBuilder\n 216: dup\n 217: invokespecial #186 // Method java/lang/StringBuilder.\"<init>\":()V\n 220: ldc #188 // String Wrong direction\n 222: invokevirtual #192 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 225: aload_1\n 226: invokevirtual #192 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 229: invokevirtual #196 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 232: invokespecial #197 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 235: athrow\n 236: areturn\n\n private static final kotlin.Pair<java.lang.Integer, java.lang.Integer> main$getAllKnotsPositions$followingPosition(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: new #9 // class kotlin/Pair\n 3: dup\n 4: aload_0\n 5: invokevirtual #13 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 8: checkcast #15 // class java/lang/Number\n 11: invokevirtual #19 // Method java/lang/Number.intValue:()I\n 14: aload_1\n 15: invokevirtual #13 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 18: checkcast #15 // class java/lang/Number\n 21: invokevirtual #19 // Method java/lang/Number.intValue:()I\n 24: aload_0\n 25: invokevirtual #13 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 28: checkcast #15 // class java/lang/Number\n 31: invokevirtual #19 // Method java/lang/Number.intValue:()I\n 34: invokestatic #207 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 37: iadd\n 38: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 41: aload_0\n 42: invokevirtual #28 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 45: checkcast #15 // class java/lang/Number\n 48: invokevirtual #19 // Method java/lang/Number.intValue:()I\n 51: aload_1\n 52: invokevirtual #28 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 55: checkcast #15 // class java/lang/Number\n 58: invokevirtual #19 // Method java/lang/Number.intValue:()I\n 61: aload_0\n 62: invokevirtual #28 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 65: checkcast #15 // class java/lang/Number\n 68: invokevirtual #19 // Method java/lang/Number.intValue:()I\n 71: invokestatic #207 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 74: iadd\n 75: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 78: invokespecial #180 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 81: areturn\n\n private static final java.util.List<java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>>> main$getAllKnotsPositions(java.util.List<kotlin.Pair<java.lang.String, java.lang.Integer>>, int);\n Code:\n 0: iconst_0\n 1: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 4: iconst_0\n 5: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 8: invokestatic #143 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 11: astore_2\n 12: new #91 // class java/util/ArrayList\n 15: dup\n 16: iload_1\n 17: invokespecial #99 // Method java/util/ArrayList.\"<init>\":(I)V\n 20: astore 4\n 22: iconst_0\n 23: istore 5\n 25: iload 5\n 27: iload_1\n 28: if_icmpge 75\n 31: iload 5\n 33: istore 6\n 35: aload 4\n 37: iload 6\n 39: istore 7\n 41: astore 27\n 43: iconst_0\n 44: istore 8\n 46: iconst_1\n 47: anewarray #9 // class kotlin/Pair\n 50: astore 9\n 52: aload 9\n 54: iconst_0\n 55: aload_2\n 56: aastore\n 57: aload 9\n 59: invokestatic #216 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 62: aload 27\n 64: swap\n 65: invokevirtual #217 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 68: pop\n 69: iinc 5, 1\n 72: goto 25\n 75: aload 4\n 77: checkcast #76 // class java/util/List\n 80: astore_3\n 81: aload_0\n 82: checkcast #89 // class java/lang/Iterable\n 85: astore 4\n 87: iconst_0\n 88: istore 5\n 90: aload 4\n 92: invokeinterface #105, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 97: astore 6\n 99: aload 6\n 101: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 106: ifeq 358\n 109: aload 6\n 111: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 116: astore 7\n 118: aload 7\n 120: checkcast #9 // class kotlin/Pair\n 123: astore 8\n 125: iconst_0\n 126: istore 9\n 128: aload 8\n 130: invokevirtual #220 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 133: checkcast #116 // class java/lang/String\n 136: astore 10\n 138: aload 8\n 140: invokevirtual #223 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 143: checkcast #15 // class java/lang/Number\n 146: invokevirtual #19 // Method java/lang/Number.intValue:()I\n 149: istore 11\n 151: iconst_0\n 152: istore 12\n 154: iload 12\n 156: iload 11\n 158: if_icmpge 353\n 161: iload 12\n 163: istore 13\n 165: iconst_0\n 166: istore 14\n 168: aload_3\n 169: invokestatic #227 // Method UtilsKt.head:(Ljava/util/List;)Ljava/lang/Object;\n 172: checkcast #76 // class java/util/List\n 175: astore 15\n 177: aload 15\n 179: aload 15\n 181: invokestatic #230 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 184: checkcast #9 // class kotlin/Pair\n 187: aload 10\n 189: invokestatic #232 // Method main$getAllKnotsPositions$getNextHeadPosition:(Lkotlin/Pair;Ljava/lang/String;)Lkotlin/Pair;\n 192: invokeinterface #233, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 197: pop\n 198: aload_3\n 199: checkcast #89 // class java/lang/Iterable\n 202: astore 16\n 204: iconst_0\n 205: istore 17\n 207: iconst_0\n 208: istore 18\n 210: aload 16\n 212: invokeinterface #105, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 217: astore 19\n 219: aload 19\n 221: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 226: ifeq 345\n 229: aload 19\n 231: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 236: astore 20\n 238: iload 18\n 240: iinc 18, 1\n 243: istore 21\n 245: iload 21\n 247: ifge 253\n 250: invokestatic #236 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 253: iload 21\n 255: aload 20\n 257: checkcast #76 // class java/util/List\n 260: astore 22\n 262: istore 23\n 264: iconst_0\n 265: istore 24\n 267: iload 23\n 269: ifeq 341\n 272: aload_3\n 273: iload 23\n 275: iconst_1\n 276: isub\n 277: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 282: checkcast #76 // class java/util/List\n 285: invokestatic #230 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 288: checkcast #9 // class kotlin/Pair\n 291: astore 25\n 293: aload 22\n 295: invokestatic #230 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 298: checkcast #9 // class kotlin/Pair\n 301: astore 26\n 303: aload 25\n 305: aload 26\n 307: invokestatic #238 // Method isTouching:(Lkotlin/Pair;Lkotlin/Pair;)Z\n 310: ifne 330\n 313: aload 22\n 315: aload 26\n 317: aload 25\n 319: invokestatic #240 // Method main$getAllKnotsPositions$followingPosition:(Lkotlin/Pair;Lkotlin/Pair;)Lkotlin/Pair;\n 322: invokeinterface #233, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 327: goto 339\n 330: aload 22\n 332: aload 26\n 334: invokeinterface #233, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 339: pop\n 340: nop\n 341: nop\n 342: goto 219\n 345: nop\n 346: nop\n 347: iinc 12, 1\n 350: goto 154\n 353: nop\n 354: nop\n 355: goto 99\n 358: nop\n 359: aload_3\n 360: areturn\n\n private static final int main$part1(java.util.List<kotlin.Pair<java.lang.String, java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: iconst_2\n 2: invokestatic #263 // Method main$getAllKnotsPositions:(Ljava/util/List;I)Ljava/util/List;\n 5: invokestatic #230 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 8: checkcast #89 // class java/lang/Iterable\n 11: invokestatic #267 // Method kotlin/collections/CollectionsKt.distinct:(Ljava/lang/Iterable;)Ljava/util/List;\n 14: invokeinterface #270, 1 // InterfaceMethod java/util/List.size:()I\n 19: ireturn\n\n private static final int main$part2(java.util.List<kotlin.Pair<java.lang.String, java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: bipush 10\n 3: invokestatic #263 // Method main$getAllKnotsPositions:(Ljava/util/List;I)Ljava/util/List;\n 6: invokestatic #230 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 9: checkcast #89 // class java/lang/Iterable\n 12: invokestatic #267 // Method kotlin/collections/CollectionsKt.distinct:(Ljava/lang/Iterable;)Ljava/util/List;\n 15: invokeinterface #270, 1 // InterfaceMethod java/util/List.size:()I\n 20: ireturn\n}\n",
"javap_err": ""
}
] |
buczebar__advent-of-code__cdb6fe3/src/Day08.kt
|
fun main() {
fun parseInput(name: String) =
readInput(name).map { it.toList() }.map { row -> row.map { height -> height.digitToInt() } }
fun getListOfTrees(input: List<List<Int>>): List<Tree> {
val columns = input.transpose()
val (width, height) = columns.size to input.size
val resultList = mutableListOf<Tree>()
input.forEachIndexed { rowIndex, row ->
columns.forEachIndexed { colIndex, column ->
resultList.add(Tree(
height = input[rowIndex][colIndex],
allOnLeft = row.subList(0, colIndex).reversed(),
allOnRight = colIndex.takeIf { it < width - 1 }?.let { row.subList(it + 1, width) } ?: emptyList(),
allOnTop = column.subList(0, rowIndex).reversed(),
allOnBottom = rowIndex.takeIf { it < height - 1 }?.let { column.subList(it + 1, height) }
?: emptyList()
))
}
}
return resultList
}
fun part1(input: List<Tree>) = input.count { it.isVisible }
fun part2(input: List<Tree>) = input.maxOfOrNull { it.scenicScore }
val testInput = getListOfTrees(parseInput("Day08_test"))
check(part1((testInput)) == 21)
check(part2(testInput) == 8)
val input = getListOfTrees(parseInput("Day08"))
println(part1(input))
println(part2(input))
}
private data class Tree(
val height: Int,
val allOnLeft: List<Int>,
val allOnRight: List<Int>,
val allOnTop: List<Int>,
val allOnBottom: List<Int>
) {
private val maxInAllDirections: List<Int>
get() = allDirections.map { it.takeIf { it.isNotEmpty() }?.max() ?: 0 }
private val allDirections: List<List<Int>>
get() = listOf(allOnLeft, allOnRight, allOnTop, allOnBottom)
private val visibleTreesInAllDirection: List<Int>
get() = allDirections.map { it.numberOfVisibleTrees() }
val isVisible: Boolean
get() = allDirections.any { it.isEmpty() }.or(maxInAllDirections.min() < height)
val scenicScore: Int
get() = visibleTreesInAllDirection.reduce { acc, numOfTrees -> acc * numOfTrees }
private fun List<Int>.numberOfVisibleTrees(): Int =
indexOfFirst { it >= height }.takeIf { it >= 0 }?.plus(1) ?: size
}
|
[
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day08Kt.class",
"javap": "Compiled from \"Day08.kt\"\npublic final class Day08Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day08_test\n 2: invokestatic #12 // Method main$parseInput:(Ljava/lang/String;)Ljava/util/List;\n 5: invokestatic #16 // Method main$getListOfTrees:(Ljava/util/List;)Ljava/util/List;\n 8: astore_0\n 9: aload_0\n 10: invokestatic #20 // Method main$part1:(Ljava/util/List;)I\n 13: bipush 21\n 15: if_icmpne 22\n 18: iconst_1\n 19: goto 23\n 22: iconst_0\n 23: ifne 36\n 26: new #22 // class java/lang/IllegalStateException\n 29: dup\n 30: ldc #24 // String Check failed.\n 32: invokespecial #28 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 35: athrow\n 36: aload_0\n 37: invokestatic #32 // Method main$part2:(Ljava/util/List;)Ljava/lang/Integer;\n 40: bipush 8\n 42: istore_1\n 43: dup\n 44: ifnonnull 51\n 47: pop\n 48: goto 62\n 51: invokevirtual #38 // Method java/lang/Integer.intValue:()I\n 54: iload_1\n 55: if_icmpne 62\n 58: iconst_1\n 59: goto 63\n 62: iconst_0\n 63: ifne 76\n 66: new #22 // class java/lang/IllegalStateException\n 69: dup\n 70: ldc #24 // String Check failed.\n 72: invokespecial #28 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 75: athrow\n 76: ldc #40 // String Day08\n 78: invokestatic #12 // Method main$parseInput:(Ljava/lang/String;)Ljava/util/List;\n 81: invokestatic #16 // Method main$getListOfTrees:(Ljava/util/List;)Ljava/util/List;\n 84: astore_1\n 85: aload_1\n 86: invokestatic #20 // Method main$part1:(Ljava/util/List;)I\n 89: istore_2\n 90: getstatic #46 // Field java/lang/System.out:Ljava/io/PrintStream;\n 93: iload_2\n 94: invokevirtual #52 // Method java/io/PrintStream.println:(I)V\n 97: aload_1\n 98: invokestatic #32 // Method main$part2:(Ljava/util/List;)Ljava/lang/Integer;\n 101: getstatic #46 // Field java/lang/System.out:Ljava/io/PrintStream;\n 104: swap\n 105: invokevirtual #55 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 108: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #63 // Method main:()V\n 3: return\n\n private static final java.util.List<java.util.List<java.lang.Integer>> main$parseInput(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #71 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 4: checkcast #73 // class java/lang/Iterable\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: astore_3\n 12: new #75 // class java/util/ArrayList\n 15: dup\n 16: aload_1\n 17: bipush 10\n 19: invokestatic #81 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 22: invokespecial #83 // Method java/util/ArrayList.\"<init>\":(I)V\n 25: checkcast #85 // class java/util/Collection\n 28: astore 4\n 30: iconst_0\n 31: istore 5\n 33: aload_3\n 34: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 6\n 41: aload 6\n 43: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 94\n 51: aload 6\n 53: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 7\n 60: aload 4\n 62: aload 7\n 64: checkcast #101 // class java/lang/String\n 67: astore 8\n 69: astore 20\n 71: iconst_0\n 72: istore 9\n 74: aload 8\n 76: checkcast #103 // class java/lang/CharSequence\n 79: invokestatic #109 // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;\n 82: aload 20\n 84: swap\n 85: invokeinterface #113, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 90: pop\n 91: goto 41\n 94: aload 4\n 96: checkcast #60 // class java/util/List\n 99: nop\n 100: checkcast #73 // class java/lang/Iterable\n 103: astore_1\n 104: nop\n 105: iconst_0\n 106: istore_2\n 107: aload_1\n 108: astore_3\n 109: new #75 // class java/util/ArrayList\n 112: dup\n 113: aload_1\n 114: bipush 10\n 116: invokestatic #81 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 119: invokespecial #83 // Method java/util/ArrayList.\"<init>\":(I)V\n 122: checkcast #85 // class java/util/Collection\n 125: astore 4\n 127: iconst_0\n 128: istore 5\n 130: aload_3\n 131: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 136: astore 6\n 138: aload 6\n 140: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 145: ifeq 291\n 148: aload 6\n 150: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 155: astore 7\n 157: aload 4\n 159: aload 7\n 161: checkcast #60 // class java/util/List\n 164: astore 8\n 166: astore 20\n 168: iconst_0\n 169: istore 9\n 171: aload 8\n 173: checkcast #73 // class java/lang/Iterable\n 176: astore 10\n 178: iconst_0\n 179: istore 11\n 181: aload 10\n 183: astore 12\n 185: new #75 // class java/util/ArrayList\n 188: dup\n 189: aload 10\n 191: bipush 10\n 193: invokestatic #81 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 196: invokespecial #83 // Method java/util/ArrayList.\"<init>\":(I)V\n 199: checkcast #85 // class java/util/Collection\n 202: astore 13\n 204: iconst_0\n 205: istore 14\n 207: aload 12\n 209: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 214: astore 15\n 216: aload 15\n 218: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 223: ifeq 272\n 226: aload 15\n 228: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 233: astore 16\n 235: aload 13\n 237: aload 16\n 239: checkcast #115 // class java/lang/Character\n 242: invokevirtual #119 // Method java/lang/Character.charValue:()C\n 245: istore 17\n 247: astore 18\n 249: iconst_0\n 250: istore 19\n 252: iload 17\n 254: invokestatic #125 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 257: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 260: aload 18\n 262: swap\n 263: invokeinterface #113, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 268: pop\n 269: goto 216\n 272: aload 13\n 274: checkcast #60 // class java/util/List\n 277: nop\n 278: nop\n 279: aload 20\n 281: swap\n 282: invokeinterface #113, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 287: pop\n 288: goto 138\n 291: aload 4\n 293: checkcast #60 // class java/util/List\n 296: nop\n 297: areturn\n\n private static final java.util.List<Tree> main$getListOfTrees(java.util.List<? extends java.util.List<java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: invokestatic #152 // Method UtilsKt.transpose:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: aload_1\n 6: invokeinterface #155, 1 // InterfaceMethod java/util/List.size:()I\n 11: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 14: aload_0\n 15: invokeinterface #155, 1 // InterfaceMethod java/util/List.size:()I\n 20: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 23: invokestatic #161 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 26: astore_2\n 27: aload_2\n 28: invokevirtual #166 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 31: checkcast #168 // class java/lang/Number\n 34: invokevirtual #169 // Method java/lang/Number.intValue:()I\n 37: istore_3\n 38: aload_2\n 39: invokevirtual #172 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 42: checkcast #168 // class java/lang/Number\n 45: invokevirtual #169 // Method java/lang/Number.intValue:()I\n 48: istore 4\n 50: new #75 // class java/util/ArrayList\n 53: dup\n 54: invokespecial #174 // Method java/util/ArrayList.\"<init>\":()V\n 57: checkcast #60 // class java/util/List\n 60: astore 5\n 62: aload_0\n 63: checkcast #73 // class java/lang/Iterable\n 66: astore 6\n 68: iconst_0\n 69: istore 7\n 71: iconst_0\n 72: istore 8\n 74: aload 6\n 76: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 81: astore 9\n 83: aload 9\n 85: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 90: ifeq 540\n 93: aload 9\n 95: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 100: astore 10\n 102: iload 8\n 104: iinc 8, 1\n 107: istore 11\n 109: iload 11\n 111: ifge 117\n 114: invokestatic #177 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 117: iload 11\n 119: aload 10\n 121: checkcast #60 // class java/util/List\n 124: astore 12\n 126: istore 13\n 128: iconst_0\n 129: istore 14\n 131: aload_1\n 132: checkcast #73 // class java/lang/Iterable\n 135: astore 15\n 137: iconst_0\n 138: istore 16\n 140: iconst_0\n 141: istore 17\n 143: aload 15\n 145: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 150: astore 18\n 152: aload 18\n 154: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 159: ifeq 534\n 162: aload 18\n 164: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 169: astore 19\n 171: iload 17\n 173: iinc 17, 1\n 176: istore 20\n 178: iload 20\n 180: ifge 186\n 183: invokestatic #177 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 186: iload 20\n 188: aload 19\n 190: checkcast #60 // class java/util/List\n 193: astore 21\n 195: istore 22\n 197: iconst_0\n 198: istore 23\n 200: aload 5\n 202: aload_0\n 203: iload 13\n 205: invokeinterface #181, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 210: checkcast #60 // class java/util/List\n 213: iload 22\n 215: invokeinterface #181, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 220: checkcast #168 // class java/lang/Number\n 223: invokevirtual #169 // Method java/lang/Number.intValue:()I\n 226: aload 12\n 228: iconst_0\n 229: iload 22\n 231: invokeinterface #185, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 236: checkcast #73 // class java/lang/Iterable\n 239: invokestatic #189 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 242: iload 22\n 244: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 247: astore 24\n 249: aload 24\n 251: checkcast #168 // class java/lang/Number\n 254: invokevirtual #169 // Method java/lang/Number.intValue:()I\n 257: istore 25\n 259: astore 26\n 261: istore 27\n 263: astore 28\n 265: iconst_0\n 266: istore 29\n 268: iload 25\n 270: iload_3\n 271: iconst_1\n 272: isub\n 273: if_icmpge 280\n 276: iconst_1\n 277: goto 281\n 280: iconst_0\n 281: istore 30\n 283: aload 28\n 285: iload 27\n 287: aload 26\n 289: iload 30\n 291: ifeq 299\n 294: aload 24\n 296: goto 300\n 299: aconst_null\n 300: dup\n 301: ifnull 348\n 304: checkcast #168 // class java/lang/Number\n 307: invokevirtual #169 // Method java/lang/Number.intValue:()I\n 310: istore 29\n 312: astore 26\n 314: istore 27\n 316: astore 28\n 318: iconst_0\n 319: istore 31\n 321: aload 12\n 323: iload 29\n 325: iconst_1\n 326: iadd\n 327: iload_3\n 328: invokeinterface #185, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 333: astore 30\n 335: aload 28\n 337: iload 27\n 339: aload 26\n 341: aload 30\n 343: nop\n 344: dup\n 345: ifnonnull 352\n 348: pop\n 349: invokestatic #193 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 352: aload 21\n 354: iconst_0\n 355: iload 13\n 357: invokeinterface #185, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 362: checkcast #73 // class java/lang/Iterable\n 365: invokestatic #189 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 368: iload 13\n 370: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 373: astore 24\n 375: aload 24\n 377: checkcast #168 // class java/lang/Number\n 380: invokevirtual #169 // Method java/lang/Number.intValue:()I\n 383: istore 25\n 385: astore 32\n 387: astore 30\n 389: astore 26\n 391: istore 27\n 393: astore 28\n 395: iconst_0\n 396: istore 29\n 398: iload 25\n 400: iload 4\n 402: iconst_1\n 403: isub\n 404: if_icmpge 411\n 407: iconst_1\n 408: goto 412\n 411: iconst_0\n 412: istore 33\n 414: aload 28\n 416: iload 27\n 418: aload 26\n 420: aload 30\n 422: aload 32\n 424: iload 33\n 426: ifeq 434\n 429: aload 24\n 431: goto 435\n 434: aconst_null\n 435: dup\n 436: ifnull 492\n 439: checkcast #168 // class java/lang/Number\n 442: invokevirtual #169 // Method java/lang/Number.intValue:()I\n 445: istore 29\n 447: astore 32\n 449: astore 30\n 451: astore 26\n 453: istore 27\n 455: astore 28\n 457: iconst_0\n 458: istore 31\n 460: aload 21\n 462: iload 29\n 464: iconst_1\n 465: iadd\n 466: iload 4\n 468: invokeinterface #185, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 473: astore 33\n 475: aload 28\n 477: iload 27\n 479: aload 26\n 481: aload 30\n 483: aload 32\n 485: aload 33\n 487: nop\n 488: dup\n 489: ifnonnull 496\n 492: pop\n 493: invokestatic #193 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 496: astore 34\n 498: astore 35\n 500: astore 36\n 502: astore 37\n 504: istore 38\n 506: new #195 // class Tree\n 509: dup\n 510: iload 38\n 512: aload 37\n 514: aload 36\n 516: aload 35\n 518: aload 34\n 520: invokespecial #198 // Method Tree.\"<init>\":(ILjava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;)V\n 523: invokeinterface #199, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 528: pop\n 529: nop\n 530: nop\n 531: goto 152\n 534: nop\n 535: nop\n 536: nop\n 537: goto 83\n 540: nop\n 541: aload 5\n 543: areturn\n\n private static final int main$part1(java.util.List<Tree>);\n Code:\n 0: aload_0\n 1: checkcast #73 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: instanceof #85 // class java/util/Collection\n 11: ifeq 30\n 14: aload_1\n 15: checkcast #85 // class java/util/Collection\n 18: invokeinterface #219, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 23: ifeq 30\n 26: iconst_0\n 27: goto 91\n 30: iconst_0\n 31: istore_3\n 32: aload_1\n 33: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 4\n 40: aload 4\n 42: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 90\n 50: aload 4\n 52: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 5\n 59: aload 5\n 61: checkcast #195 // class Tree\n 64: astore 6\n 66: iconst_0\n 67: istore 7\n 69: aload 6\n 71: invokevirtual #222 // Method Tree.isVisible:()Z\n 74: ifeq 40\n 77: iinc 3, 1\n 80: iload_3\n 81: ifge 40\n 84: invokestatic #225 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 87: goto 40\n 90: iload_3\n 91: ireturn\n\n private static final java.lang.Integer main$part2(java.util.List<Tree>);\n Code:\n 0: aload_0\n 1: checkcast #73 // class java/lang/Iterable\n 4: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 9: astore_1\n 10: aload_1\n 11: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 16: ifne 23\n 19: aconst_null\n 20: goto 95\n 23: aload_1\n 24: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 29: checkcast #195 // class Tree\n 32: astore_2\n 33: iconst_0\n 34: istore_3\n 35: aload_2\n 36: invokevirtual #235 // Method Tree.getScenicScore:()I\n 39: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 42: checkcast #237 // class java/lang/Comparable\n 45: astore_2\n 46: aload_1\n 47: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 52: ifeq 94\n 55: aload_1\n 56: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: checkcast #195 // class Tree\n 64: astore_3\n 65: iconst_0\n 66: istore 4\n 68: aload_3\n 69: invokevirtual #235 // Method Tree.getScenicScore:()I\n 72: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 75: checkcast #237 // class java/lang/Comparable\n 78: astore_3\n 79: aload_2\n 80: aload_3\n 81: invokeinterface #241, 2 // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I\n 86: ifge 46\n 89: aload_3\n 90: astore_2\n 91: goto 46\n 94: aload_2\n 95: checkcast #34 // class java/lang/Integer\n 98: areturn\n}\n",
"javap_err": ""
}
] |
buczebar__advent-of-code__cdb6fe3/src/Day11.kt
|
import java.lang.IllegalArgumentException
private fun parseMonkey(monkeyData: String): Monkey {
return Monkey.build {
monkeyData.lines().forEach { line ->
with(line.trim()) {
when {
startsWith("Monkey") -> {
id = getAllInts().first()
}
startsWith("Starting items:") -> {
items = getAllInts().map { it.toLong() }.toMutableList()
}
startsWith("Operation") -> {
operation = "\\w+ [*+-/]? \\w+".toRegex().find(this)?.value.orEmpty()
}
startsWith("Test:") -> {
testDivisor = getAllInts().first().toLong()
}
startsWith("If true:") -> {
idIfTrue = getAllInts().first()
}
startsWith("If false:") -> {
idIfFalse = getAllInts().first()
}
}
}
}
}
}
private fun parseInput(name: String) = readGroupedInput(name).map { parseMonkey(it) }
fun main() {
fun simulate(monkeys: List<Monkey>, rounds: Int, reduceOperation: (Long) -> Long): List<Long> {
val inspectionCounters = MutableList(monkeys.size) { 0L }
repeat(rounds) {
monkeys.forEach { monkey ->
monkey.items.forEach { item ->
val newItemValue = reduceOperation(monkey.calculate(item))
monkeys[monkey.getMonkeyIdToPass(newItemValue)].items.add(newItemValue)
inspectionCounters[monkey.id]++
}
monkey.items.clear()
}
}
return inspectionCounters
}
fun monkeyBusiness(inspections: List<Long>) =
inspections
.sortedDescending()
.take(2)
.factorial()
fun part1(monkeys: List<Monkey>) = monkeyBusiness(simulate(monkeys, 20) { it / 3 })
fun part2(monkeys: List<Monkey>) =
monkeyBusiness(
simulate(monkeys, 10_000) {
it % monkeys.map { monkey -> monkey.testDivisor }.factorial()
}
)
check(part1(parseInput("Day11_test")) == 10605L)
check(part2(parseInput("Day11_test")) == 2713310158L)
println(part1(parseInput("Day11")))
println(part2(parseInput("Day11")))
}
private data class Monkey(
val id: Int,
val items: MutableList<Long> = mutableListOf(),
private val operation: String,
val testDivisor: Long,
private val idIfTrue: Int,
private val idIfFalse: Int
) {
private constructor(builder: Builder) : this(
builder.id,
builder.items,
builder.operation,
builder.testDivisor,
builder.idIfTrue,
builder.idIfFalse
)
fun getMonkeyIdToPass(value: Long) =
idIfTrue.takeIf { value % testDivisor == 0L } ?: idIfFalse
fun calculate(value: Long): Long {
val (_, type, second) = operation.takeIf { it.isNotEmpty() }?.splitWords() ?: return -1L
val arg = if (second == "old") value else second.toLong()
return when (type) {
"+" -> value + arg
"-" -> value - arg
"*" -> value * arg
"/" -> value / arg
else -> throw IllegalArgumentException("wrong operation type $operation")
}
}
companion object {
inline fun build(block: Builder.() -> Unit) = Builder().apply(block).build()
}
class Builder {
var id = 0
var items: MutableList<Long> = mutableListOf()
var operation: String = ""
var testDivisor: Long = 0L
var idIfTrue: Int = 0
var idIfFalse: Int = 0
fun build() = Monkey(this)
}
}
|
[
{
"class_path": "buczebar__advent-of-code__cdb6fe3/Day11Kt.class",
"javap": "Compiled from \"Day11.kt\"\npublic final class Day11Kt {\n private static final Monkey parseMonkey(java.lang.String);\n Code:\n 0: getstatic #12 // Field Monkey.Companion:LMonkey$Companion;\n 3: astore_1\n 4: iconst_0\n 5: istore_2\n 6: new #14 // class Monkey$Builder\n 9: dup\n 10: invokespecial #18 // Method Monkey$Builder.\"<init>\":()V\n 13: astore_3\n 14: aload_3\n 15: astore 4\n 17: iconst_0\n 18: istore 5\n 20: aload_0\n 21: checkcast #20 // class java/lang/CharSequence\n 24: invokestatic #26 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 27: checkcast #28 // class java/lang/Iterable\n 30: astore 6\n 32: iconst_0\n 33: istore 7\n 35: aload 6\n 37: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 8\n 44: aload 8\n 46: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 437\n 54: aload 8\n 56: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 9\n 63: aload 9\n 65: checkcast #44 // class java/lang/String\n 68: astore 10\n 70: iconst_0\n 71: istore 11\n 73: aload 10\n 75: checkcast #20 // class java/lang/CharSequence\n 78: invokestatic #48 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 81: invokevirtual #52 // Method java/lang/Object.toString:()Ljava/lang/String;\n 84: astore 12\n 86: iconst_0\n 87: istore 13\n 89: nop\n 90: aload 12\n 92: ldc #53 // String Monkey\n 94: iconst_0\n 95: iconst_2\n 96: aconst_null\n 97: invokestatic #57 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 100: ifeq 125\n 103: aload 4\n 105: aload 12\n 107: invokestatic #63 // Method UtilsKt.getAllInts:(Ljava/lang/String;)Ljava/util/List;\n 110: invokestatic #69 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 113: checkcast #71 // class java/lang/Number\n 116: invokevirtual #75 // Method java/lang/Number.intValue:()I\n 119: invokevirtual #79 // Method Monkey$Builder.setId:(I)V\n 122: goto 430\n 125: aload 12\n 127: ldc #81 // String Starting items:\n 129: iconst_0\n 130: iconst_2\n 131: aconst_null\n 132: invokestatic #57 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 135: ifeq 265\n 138: aload 4\n 140: aload 12\n 142: invokestatic #63 // Method UtilsKt.getAllInts:(Ljava/lang/String;)Ljava/util/List;\n 145: checkcast #28 // class java/lang/Iterable\n 148: astore 14\n 150: astore 15\n 152: iconst_0\n 153: istore 16\n 155: aload 14\n 157: astore 17\n 159: new #83 // class java/util/ArrayList\n 162: dup\n 163: aload 14\n 165: bipush 10\n 167: invokestatic #87 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 170: invokespecial #89 // Method java/util/ArrayList.\"<init>\":(I)V\n 173: checkcast #91 // class java/util/Collection\n 176: astore 18\n 178: iconst_0\n 179: istore 19\n 181: aload 17\n 183: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 188: astore 20\n 190: aload 20\n 192: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 197: ifeq 244\n 200: aload 20\n 202: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 207: astore 21\n 209: aload 18\n 211: aload 21\n 213: checkcast #71 // class java/lang/Number\n 216: invokevirtual #75 // Method java/lang/Number.intValue:()I\n 219: istore 22\n 221: astore 23\n 223: iconst_0\n 224: istore 24\n 226: iload 22\n 228: i2l\n 229: invokestatic #97 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 232: aload 23\n 234: swap\n 235: invokeinterface #101, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 240: pop\n 241: goto 190\n 244: aload 18\n 246: checkcast #103 // class java/util/List\n 249: nop\n 250: aload 15\n 252: swap\n 253: checkcast #91 // class java/util/Collection\n 256: invokestatic #107 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 259: invokevirtual #111 // Method Monkey$Builder.setItems:(Ljava/util/List;)V\n 262: goto 430\n 265: aload 12\n 267: ldc #113 // String Operation\n 269: iconst_0\n 270: iconst_2\n 271: aconst_null\n 272: invokestatic #57 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 275: ifeq 327\n 278: aload 4\n 280: new #115 // class kotlin/text/Regex\n 283: dup\n 284: ldc #117 // String \\\\w+ [*+-/]? \\\\w+\n 286: invokespecial #120 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 289: aload 12\n 291: checkcast #20 // class java/lang/CharSequence\n 294: iconst_0\n 295: iconst_2\n 296: aconst_null\n 297: invokestatic #124 // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;\n 300: dup\n 301: ifnull 312\n 304: invokeinterface #129, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 309: goto 314\n 312: pop\n 313: aconst_null\n 314: dup\n 315: ifnonnull 321\n 318: pop\n 319: ldc #131 // String\n 321: invokevirtual #134 // Method Monkey$Builder.setOperation:(Ljava/lang/String;)V\n 324: goto 430\n 327: aload 12\n 329: ldc #136 // String Test:\n 331: iconst_0\n 332: iconst_2\n 333: aconst_null\n 334: invokestatic #57 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 337: ifeq 363\n 340: aload 4\n 342: aload 12\n 344: invokestatic #63 // Method UtilsKt.getAllInts:(Ljava/lang/String;)Ljava/util/List;\n 347: invokestatic #69 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 350: checkcast #71 // class java/lang/Number\n 353: invokevirtual #75 // Method java/lang/Number.intValue:()I\n 356: i2l\n 357: invokevirtual #140 // Method Monkey$Builder.setTestDivisor:(J)V\n 360: goto 430\n 363: aload 12\n 365: ldc #142 // String If true:\n 367: iconst_0\n 368: iconst_2\n 369: aconst_null\n 370: invokestatic #57 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 373: ifeq 398\n 376: aload 4\n 378: aload 12\n 380: invokestatic #63 // Method UtilsKt.getAllInts:(Ljava/lang/String;)Ljava/util/List;\n 383: invokestatic #69 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 386: checkcast #71 // class java/lang/Number\n 389: invokevirtual #75 // Method java/lang/Number.intValue:()I\n 392: invokevirtual #145 // Method Monkey$Builder.setIdIfTrue:(I)V\n 395: goto 430\n 398: aload 12\n 400: ldc #147 // String If false:\n 402: iconst_0\n 403: iconst_2\n 404: aconst_null\n 405: invokestatic #57 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 408: ifeq 430\n 411: aload 4\n 413: aload 12\n 415: invokestatic #63 // Method UtilsKt.getAllInts:(Ljava/lang/String;)Ljava/util/List;\n 418: invokestatic #69 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 421: checkcast #71 // class java/lang/Number\n 424: invokevirtual #75 // Method java/lang/Number.intValue:()I\n 427: invokevirtual #150 // Method Monkey$Builder.setIdIfFalse:(I)V\n 430: nop\n 431: nop\n 432: nop\n 433: nop\n 434: goto 44\n 437: nop\n 438: nop\n 439: aload_3\n 440: invokevirtual #154 // Method Monkey$Builder.build:()LMonkey;\n 443: areturn\n\n private static final java.util.List<Monkey> parseInput(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #187 // Method UtilsKt.readGroupedInput:(Ljava/lang/String;)Ljava/util/List;\n 4: checkcast #28 // class java/lang/Iterable\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: astore_3\n 12: new #83 // class java/util/ArrayList\n 15: dup\n 16: aload_1\n 17: bipush 10\n 19: invokestatic #87 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 22: invokespecial #89 // Method java/util/ArrayList.\"<init>\":(I)V\n 25: checkcast #91 // class java/util/Collection\n 28: astore 4\n 30: iconst_0\n 31: istore 5\n 33: aload_3\n 34: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 6\n 41: aload 6\n 43: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 91\n 51: aload 6\n 53: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 7\n 60: aload 4\n 62: aload 7\n 64: checkcast #44 // class java/lang/String\n 67: astore 8\n 69: astore 10\n 71: iconst_0\n 72: istore 9\n 74: aload 8\n 76: invokestatic #189 // Method parseMonkey:(Ljava/lang/String;)LMonkey;\n 79: aload 10\n 81: swap\n 82: invokeinterface #101, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 87: pop\n 88: goto 41\n 91: aload 4\n 93: checkcast #103 // class java/util/List\n 96: nop\n 97: areturn\n\n public static final void main();\n Code:\n 0: ldc #194 // String Day11_test\n 2: invokestatic #196 // Method parseInput:(Ljava/lang/String;)Ljava/util/List;\n 5: invokestatic #200 // Method main$part1:(Ljava/util/List;)J\n 8: ldc2_w #201 // long 10605l\n 11: lcmp\n 12: ifne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 33\n 23: new #204 // class java/lang/IllegalStateException\n 26: dup\n 27: ldc #206 // String Check failed.\n 29: invokespecial #207 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 32: athrow\n 33: ldc #194 // String Day11_test\n 35: invokestatic #196 // Method parseInput:(Ljava/lang/String;)Ljava/util/List;\n 38: invokestatic #210 // Method main$part2:(Ljava/util/List;)J\n 41: ldc2_w #211 // long 2713310158l\n 44: lcmp\n 45: ifne 52\n 48: iconst_1\n 49: goto 53\n 52: iconst_0\n 53: ifne 66\n 56: new #204 // class java/lang/IllegalStateException\n 59: dup\n 60: ldc #206 // String Check failed.\n 62: invokespecial #207 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 65: athrow\n 66: ldc #214 // String Day11\n 68: invokestatic #196 // Method parseInput:(Ljava/lang/String;)Ljava/util/List;\n 71: invokestatic #200 // Method main$part1:(Ljava/util/List;)J\n 74: lstore_0\n 75: getstatic #220 // Field java/lang/System.out:Ljava/io/PrintStream;\n 78: lload_0\n 79: invokevirtual #225 // Method java/io/PrintStream.println:(J)V\n 82: ldc #214 // String Day11\n 84: invokestatic #196 // Method parseInput:(Ljava/lang/String;)Ljava/util/List;\n 87: invokestatic #210 // Method main$part2:(Ljava/util/List;)J\n 90: lstore_0\n 91: getstatic #220 // Field java/lang/System.out:Ljava/io/PrintStream;\n 94: lload_0\n 95: invokevirtual #225 // Method java/io/PrintStream.println:(J)V\n 98: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #228 // Method main:()V\n 3: return\n\n private static final java.util.List<java.lang.Long> main$simulate(java.util.List<Monkey>, int, kotlin.jvm.functions.Function1<? super java.lang.Long, java.lang.Long>);\n Code:\n 0: aload_0\n 1: invokeinterface #236, 1 // InterfaceMethod java/util/List.size:()I\n 6: istore 4\n 8: new #83 // class java/util/ArrayList\n 11: dup\n 12: iload 4\n 14: invokespecial #89 // Method java/util/ArrayList.\"<init>\":(I)V\n 17: astore 5\n 19: iconst_0\n 20: istore 6\n 22: iload 6\n 24: iload 4\n 26: if_icmpge 61\n 29: iload 6\n 31: istore 7\n 33: aload 5\n 35: iload 7\n 37: istore 8\n 39: astore 25\n 41: iconst_0\n 42: istore 9\n 44: lconst_0\n 45: invokestatic #97 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 48: aload 25\n 50: swap\n 51: invokevirtual #237 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 54: pop\n 55: iinc 6, 1\n 58: goto 22\n 61: aload 5\n 63: checkcast #103 // class java/util/List\n 66: astore_3\n 67: iconst_0\n 68: istore 4\n 70: iload 4\n 72: iload_1\n 73: if_icmpge 306\n 76: iload 4\n 78: istore 5\n 80: iconst_0\n 81: istore 6\n 83: aload_0\n 84: checkcast #28 // class java/lang/Iterable\n 87: astore 7\n 89: iconst_0\n 90: istore 8\n 92: aload 7\n 94: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 99: astore 9\n 101: aload 9\n 103: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 108: ifeq 298\n 111: aload 9\n 113: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 118: astore 10\n 120: aload 10\n 122: checkcast #8 // class Monkey\n 125: astore 11\n 127: iconst_0\n 128: istore 12\n 130: aload 11\n 132: invokevirtual #241 // Method Monkey.getItems:()Ljava/util/List;\n 135: checkcast #28 // class java/lang/Iterable\n 138: astore 13\n 140: iconst_0\n 141: istore 14\n 143: aload 13\n 145: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 150: astore 15\n 152: aload 15\n 154: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 159: ifeq 282\n 162: aload 15\n 164: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 169: astore 16\n 171: aload 16\n 173: checkcast #71 // class java/lang/Number\n 176: invokevirtual #245 // Method java/lang/Number.longValue:()J\n 179: lstore 17\n 181: iconst_0\n 182: istore 19\n 184: aload_2\n 185: aload 11\n 187: lload 17\n 189: invokevirtual #249 // Method Monkey.calculate:(J)J\n 192: invokestatic #97 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 195: invokeinterface #255, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 200: checkcast #71 // class java/lang/Number\n 203: invokevirtual #245 // Method java/lang/Number.longValue:()J\n 206: lstore 20\n 208: aload_0\n 209: aload 11\n 211: lload 20\n 213: invokevirtual #259 // Method Monkey.getMonkeyIdToPass:(J)I\n 216: invokeinterface #263, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 221: checkcast #8 // class Monkey\n 224: invokevirtual #241 // Method Monkey.getItems:()Ljava/util/List;\n 227: lload 20\n 229: invokestatic #97 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 232: invokeinterface #264, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 237: pop\n 238: aload 11\n 240: invokevirtual #267 // Method Monkey.getId:()I\n 243: istore 22\n 245: aload_3\n 246: iload 22\n 248: invokeinterface #263, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 253: checkcast #71 // class java/lang/Number\n 256: invokevirtual #245 // Method java/lang/Number.longValue:()J\n 259: lstore 23\n 261: aload_3\n 262: iload 22\n 264: lload 23\n 266: lconst_1\n 267: ladd\n 268: invokestatic #97 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 271: invokeinterface #271, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 276: pop\n 277: nop\n 278: nop\n 279: goto 152\n 282: nop\n 283: aload 11\n 285: invokevirtual #241 // Method Monkey.getItems:()Ljava/util/List;\n 288: invokeinterface #274, 1 // InterfaceMethod java/util/List.clear:()V\n 293: nop\n 294: nop\n 295: goto 101\n 298: nop\n 299: nop\n 300: iinc 4, 1\n 303: goto 70\n 306: aload_3\n 307: areturn\n\n private static final long main$monkeyBusiness(java.util.List<java.lang.Long>);\n Code:\n 0: aload_0\n 1: checkcast #28 // class java/lang/Iterable\n 4: invokestatic #295 // Method kotlin/collections/CollectionsKt.sortedDescending:(Ljava/lang/Iterable;)Ljava/util/List;\n 7: checkcast #28 // class java/lang/Iterable\n 10: iconst_2\n 11: invokestatic #299 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 14: invokestatic #302 // Method UtilsKt.factorial:(Ljava/util/List;)J\n 17: lreturn\n\n private static final long main$part1$lambda$9(long);\n Code:\n 0: lload_0\n 1: iconst_3\n 2: i2l\n 3: ldiv\n 4: lreturn\n\n private static final long main$part1(java.util.List<Monkey>);\n Code:\n 0: aload_0\n 1: bipush 20\n 3: invokedynamic #321, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 8: invokestatic #323 // Method main$simulate:(Ljava/util/List;ILkotlin/jvm/functions/Function1;)Ljava/util/List;\n 11: invokestatic #325 // Method main$monkeyBusiness:(Ljava/util/List;)J\n 14: lreturn\n\n private static final long main$part2$lambda$11(java.util.List, long);\n Code:\n 0: lload_1\n 1: aload_0\n 2: checkcast #28 // class java/lang/Iterable\n 5: astore_3\n 6: lstore 12\n 8: iconst_0\n 9: istore 4\n 11: aload_3\n 12: astore 5\n 14: new #83 // class java/util/ArrayList\n 17: dup\n 18: aload_3\n 19: bipush 10\n 21: invokestatic #87 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 24: invokespecial #89 // Method java/util/ArrayList.\"<init>\":(I)V\n 27: checkcast #91 // class java/util/Collection\n 30: astore 6\n 32: iconst_0\n 33: istore 7\n 35: aload 5\n 37: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 8\n 44: aload 8\n 46: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 97\n 54: aload 8\n 56: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 9\n 63: aload 6\n 65: aload 9\n 67: checkcast #8 // class Monkey\n 70: astore 10\n 72: astore 14\n 74: iconst_0\n 75: istore 11\n 77: aload 10\n 79: invokevirtual #330 // Method Monkey.getTestDivisor:()J\n 82: invokestatic #97 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 85: aload 14\n 87: swap\n 88: invokeinterface #101, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 93: pop\n 94: goto 44\n 97: aload 6\n 99: checkcast #103 // class java/util/List\n 102: nop\n 103: astore 14\n 105: lload 12\n 107: aload 14\n 109: invokestatic #302 // Method UtilsKt.factorial:(Ljava/util/List;)J\n 112: lrem\n 113: lreturn\n\n private static final long main$part2(java.util.List<Monkey>);\n Code:\n 0: aload_0\n 1: sipush 10000\n 4: aload_0\n 5: invokedynamic #338, 0 // InvokeDynamic #1:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function1;\n 10: invokestatic #323 // Method main$simulate:(Ljava/util/List;ILkotlin/jvm/functions/Function1;)Ljava/util/List;\n 13: invokestatic #325 // Method main$monkeyBusiness:(Ljava/util/List;)J\n 16: lreturn\n}\n",
"javap_err": ""
}
] |
davidcurrie__advent-of-code-2021__dd37372/src/day24/result.kt
|
import java.io.File
fun main() {
val programs = File("src/day24/input.txt").readText().split("inp w\n").drop(1)
.map { it.split("\n").dropLast(1).map { it.split(" ") } }
val variables = programs.map { Variables(it[3][2].toInt(), it[4][2].toInt(), it[14][2].toInt()) }
val solutions = solve(variables)
println(solutions.maxOf { it })
println(solutions.minOf { it })
}
data class Variables(val zDiv: Int, val xAdd: Int, val yAdd: Int) {
fun execute(input: Int, zReg: Int): Int {
val x = if (((zReg % 26) + xAdd) != input) 1 else 0
return ((zReg / zDiv) * ((25 * x) + 1)) + ((input + yAdd) * x)
}
}
fun solve(variablesList: List<Variables>): List<String> {
var validZOutputs = setOf(0)
val validZsByIndex = variablesList.reversed().map { variables ->
(1..9).associateWith { input ->
(0..10000000).filter { z -> variables.execute(input, z) in validZOutputs }.toSet()
}.also { validZs ->
validZOutputs = validZs.values.flatten().toSet()
}
}.reversed()
fun findModelNumbers(index: Int, z: Int): List<String> {
val inputs = validZsByIndex[index].entries.filter { z in it.value }.map { it.key }
return if (index == 13) inputs.map { it.toString() } else inputs.flatMap { input ->
val nextZ = variablesList[index].execute(input, z)
findModelNumbers(index + 1, nextZ).map { input.toString() + it }
}
}
return findModelNumbers(0, 0)
}
|
[
{
"class_path": "davidcurrie__advent-of-code-2021__dd37372/ResultKt.class",
"javap": "Compiled from \"result.kt\"\npublic final class ResultKt {\n public static final void main();\n Code:\n 0: new #8 // class java/io/File\n 3: dup\n 4: ldc #10 // String src/day24/input.txt\n 6: invokespecial #14 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: aconst_null\n 10: iconst_1\n 11: aconst_null\n 12: invokestatic #20 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;\n 15: checkcast #22 // class java/lang/CharSequence\n 18: iconst_1\n 19: anewarray #24 // class java/lang/String\n 22: astore_1\n 23: aload_1\n 24: iconst_0\n 25: ldc #26 // String inp w\\n\n 27: aastore\n 28: aload_1\n 29: iconst_0\n 30: iconst_0\n 31: bipush 6\n 33: aconst_null\n 34: invokestatic #32 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 37: checkcast #34 // class java/lang/Iterable\n 40: iconst_1\n 41: invokestatic #40 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 44: checkcast #34 // class java/lang/Iterable\n 47: astore_1\n 48: nop\n 49: iconst_0\n 50: istore_2\n 51: aload_1\n 52: astore_3\n 53: new #42 // class java/util/ArrayList\n 56: dup\n 57: aload_1\n 58: bipush 10\n 60: invokestatic #46 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 63: invokespecial #49 // Method java/util/ArrayList.\"<init>\":(I)V\n 66: checkcast #51 // class java/util/Collection\n 69: astore 4\n 71: iconst_0\n 72: istore 5\n 74: aload_3\n 75: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 80: astore 6\n 82: aload 6\n 84: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 89: ifeq 280\n 92: aload 6\n 94: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 99: astore 7\n 101: aload 4\n 103: aload 7\n 105: checkcast #24 // class java/lang/String\n 108: astore 8\n 110: astore 21\n 112: iconst_0\n 113: istore 9\n 115: aload 8\n 117: checkcast #22 // class java/lang/CharSequence\n 120: iconst_1\n 121: anewarray #24 // class java/lang/String\n 124: astore 10\n 126: aload 10\n 128: iconst_0\n 129: ldc #67 // String \\n\n 131: aastore\n 132: aload 10\n 134: iconst_0\n 135: iconst_0\n 136: bipush 6\n 138: aconst_null\n 139: invokestatic #32 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 142: iconst_1\n 143: invokestatic #71 // Method kotlin/collections/CollectionsKt.dropLast:(Ljava/util/List;I)Ljava/util/List;\n 146: checkcast #34 // class java/lang/Iterable\n 149: astore 10\n 151: iconst_0\n 152: istore 11\n 154: aload 10\n 156: astore 12\n 158: new #42 // class java/util/ArrayList\n 161: dup\n 162: aload 10\n 164: bipush 10\n 166: invokestatic #46 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 169: invokespecial #49 // Method java/util/ArrayList.\"<init>\":(I)V\n 172: checkcast #51 // class java/util/Collection\n 175: astore 13\n 177: iconst_0\n 178: istore 14\n 180: aload 12\n 182: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 187: astore 15\n 189: aload 15\n 191: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 196: ifeq 261\n 199: aload 15\n 201: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 206: astore 16\n 208: aload 13\n 210: aload 16\n 212: checkcast #24 // class java/lang/String\n 215: astore 17\n 217: astore 18\n 219: iconst_0\n 220: istore 19\n 222: aload 17\n 224: checkcast #22 // class java/lang/CharSequence\n 227: iconst_1\n 228: anewarray #24 // class java/lang/String\n 231: astore 20\n 233: aload 20\n 235: iconst_0\n 236: ldc #73 // String\n 238: aastore\n 239: aload 20\n 241: iconst_0\n 242: iconst_0\n 243: bipush 6\n 245: aconst_null\n 246: invokestatic #32 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 249: aload 18\n 251: swap\n 252: invokeinterface #77, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 257: pop\n 258: goto 189\n 261: aload 13\n 263: checkcast #79 // class java/util/List\n 266: nop\n 267: nop\n 268: aload 21\n 270: swap\n 271: invokeinterface #77, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 276: pop\n 277: goto 82\n 280: aload 4\n 282: checkcast #79 // class java/util/List\n 285: nop\n 286: astore_0\n 287: aload_0\n 288: checkcast #34 // class java/lang/Iterable\n 291: astore_2\n 292: iconst_0\n 293: istore_3\n 294: aload_2\n 295: astore 4\n 297: new #42 // class java/util/ArrayList\n 300: dup\n 301: aload_2\n 302: bipush 10\n 304: invokestatic #46 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 307: invokespecial #49 // Method java/util/ArrayList.\"<init>\":(I)V\n 310: checkcast #51 // class java/util/Collection\n 313: astore 5\n 315: iconst_0\n 316: istore 6\n 318: aload 4\n 320: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 325: astore 7\n 327: aload 7\n 329: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 334: ifeq 449\n 337: aload 7\n 339: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 344: astore 8\n 346: aload 5\n 348: aload 8\n 350: checkcast #79 // class java/util/List\n 353: astore 9\n 355: astore 21\n 357: iconst_0\n 358: istore 10\n 360: new #81 // class Variables\n 363: dup\n 364: aload 9\n 366: iconst_3\n 367: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 372: checkcast #79 // class java/util/List\n 375: iconst_2\n 376: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 381: checkcast #24 // class java/lang/String\n 384: invokestatic #91 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 387: aload 9\n 389: iconst_4\n 390: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 395: checkcast #79 // class java/util/List\n 398: iconst_2\n 399: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 404: checkcast #24 // class java/lang/String\n 407: invokestatic #91 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 410: aload 9\n 412: bipush 14\n 414: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 419: checkcast #79 // class java/util/List\n 422: iconst_2\n 423: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 428: checkcast #24 // class java/lang/String\n 431: invokestatic #91 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 434: invokespecial #94 // Method Variables.\"<init>\":(III)V\n 437: aload 21\n 439: swap\n 440: invokeinterface #77, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 445: pop\n 446: goto 327\n 449: aload 5\n 451: checkcast #79 // class java/util/List\n 454: nop\n 455: astore_1\n 456: aload_1\n 457: invokestatic #98 // Method solve:(Ljava/util/List;)Ljava/util/List;\n 460: astore_2\n 461: aload_2\n 462: checkcast #34 // class java/lang/Iterable\n 465: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 470: astore 4\n 472: aload 4\n 474: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 479: ifne 490\n 482: new #100 // class java/util/NoSuchElementException\n 485: dup\n 486: invokespecial #102 // Method java/util/NoSuchElementException.\"<init>\":()V\n 489: athrow\n 490: aload 4\n 492: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 497: checkcast #24 // class java/lang/String\n 500: astore 5\n 502: iconst_0\n 503: istore 6\n 505: aload 5\n 507: checkcast #104 // class java/lang/Comparable\n 510: astore 5\n 512: aload 4\n 514: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 519: ifeq 563\n 522: aload 4\n 524: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 529: checkcast #24 // class java/lang/String\n 532: astore 6\n 534: iconst_0\n 535: istore 7\n 537: aload 6\n 539: checkcast #104 // class java/lang/Comparable\n 542: astore 6\n 544: aload 5\n 546: aload 6\n 548: invokeinterface #108, 2 // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I\n 553: ifge 512\n 556: aload 6\n 558: astore 5\n 560: goto 512\n 563: aload 5\n 565: astore_3\n 566: getstatic #114 // Field java/lang/System.out:Ljava/io/PrintStream;\n 569: aload_3\n 570: invokevirtual #120 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 573: aload_2\n 574: checkcast #34 // class java/lang/Iterable\n 577: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 582: astore 4\n 584: aload 4\n 586: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 591: ifne 602\n 594: new #100 // class java/util/NoSuchElementException\n 597: dup\n 598: invokespecial #102 // Method java/util/NoSuchElementException.\"<init>\":()V\n 601: athrow\n 602: aload 4\n 604: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 609: checkcast #24 // class java/lang/String\n 612: astore 5\n 614: iconst_0\n 615: istore 6\n 617: aload 5\n 619: checkcast #104 // class java/lang/Comparable\n 622: astore 5\n 624: aload 4\n 626: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 631: ifeq 675\n 634: aload 4\n 636: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 641: checkcast #24 // class java/lang/String\n 644: astore 6\n 646: iconst_0\n 647: istore 7\n 649: aload 6\n 651: checkcast #104 // class java/lang/Comparable\n 654: astore 6\n 656: aload 5\n 658: aload 6\n 660: invokeinterface #108, 2 // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I\n 665: ifle 624\n 668: aload 6\n 670: astore 5\n 672: goto 624\n 675: aload 5\n 677: astore_3\n 678: getstatic #114 // Field java/lang/System.out:Ljava/io/PrintStream;\n 681: aload_3\n 682: invokevirtual #120 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 685: return\n\n public static final java.util.List<java.lang.String> solve(java.util.List<Variables>);\n Code:\n 0: aload_0\n 1: ldc #145 // String variablesList\n 3: invokestatic #151 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aconst_null\n 7: astore_1\n 8: iconst_0\n 9: invokestatic #155 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 12: invokestatic #161 // Method kotlin/collections/SetsKt.setOf:(Ljava/lang/Object;)Ljava/util/Set;\n 15: astore_1\n 16: aload_0\n 17: checkcast #34 // class java/lang/Iterable\n 20: invokestatic #165 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 23: checkcast #34 // class java/lang/Iterable\n 26: astore_3\n 27: iconst_0\n 28: istore 4\n 30: aload_3\n 31: astore 5\n 33: new #42 // class java/util/ArrayList\n 36: dup\n 37: aload_3\n 38: bipush 10\n 40: invokestatic #46 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 43: invokespecial #49 // Method java/util/ArrayList.\"<init>\":(I)V\n 46: checkcast #51 // class java/util/Collection\n 49: astore 6\n 51: iconst_0\n 52: istore 7\n 54: aload 5\n 56: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 61: astore 8\n 63: aload 8\n 65: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 70: ifeq 389\n 73: aload 8\n 75: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 80: astore 9\n 82: aload 6\n 84: aload 9\n 86: checkcast #81 // class Variables\n 89: astore 10\n 91: astore 33\n 93: iconst_0\n 94: istore 11\n 96: new #167 // class kotlin/ranges/IntRange\n 99: dup\n 100: iconst_1\n 101: bipush 9\n 103: invokespecial #170 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 106: checkcast #34 // class java/lang/Iterable\n 109: astore 12\n 111: iconst_0\n 112: istore 13\n 114: new #172 // class java/util/LinkedHashMap\n 117: dup\n 118: aload 12\n 120: bipush 10\n 122: invokestatic #46 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 125: invokestatic #178 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 128: bipush 16\n 130: invokestatic #184 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 133: invokespecial #185 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 136: astore 14\n 138: aload 12\n 140: astore 15\n 142: iconst_0\n 143: istore 16\n 145: aload 15\n 147: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 152: astore 17\n 154: aload 17\n 156: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 161: ifeq 338\n 164: aload 17\n 166: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 171: astore 18\n 173: aload 14\n 175: checkcast #187 // class java/util/Map\n 178: aload 18\n 180: aload 18\n 182: checkcast #189 // class java/lang/Number\n 185: invokevirtual #193 // Method java/lang/Number.intValue:()I\n 188: istore 19\n 190: astore 20\n 192: astore 21\n 194: iconst_0\n 195: istore 22\n 197: new #167 // class kotlin/ranges/IntRange\n 200: dup\n 201: iconst_0\n 202: ldc #194 // int 10000000\n 204: invokespecial #170 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 207: checkcast #34 // class java/lang/Iterable\n 210: astore 23\n 212: iconst_0\n 213: istore 24\n 215: aload 23\n 217: astore 25\n 219: new #42 // class java/util/ArrayList\n 222: dup\n 223: invokespecial #195 // Method java/util/ArrayList.\"<init>\":()V\n 226: checkcast #51 // class java/util/Collection\n 229: astore 26\n 231: iconst_0\n 232: istore 27\n 234: aload 25\n 236: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 241: astore 28\n 243: aload 28\n 245: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 250: ifeq 309\n 253: aload 28\n 255: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 260: astore 29\n 262: aload 29\n 264: checkcast #189 // class java/lang/Number\n 267: invokevirtual #193 // Method java/lang/Number.intValue:()I\n 270: istore 30\n 272: iconst_0\n 273: istore 31\n 275: aload_1\n 276: aload 10\n 278: iload 19\n 280: iload 30\n 282: invokevirtual #198 // Method Variables.execute:(II)I\n 285: invokestatic #155 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 288: invokeinterface #203, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 293: ifeq 243\n 296: aload 26\n 298: aload 29\n 300: invokeinterface #77, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 305: pop\n 306: goto 243\n 309: aload 26\n 311: checkcast #79 // class java/util/List\n 314: nop\n 315: checkcast #34 // class java/lang/Iterable\n 318: invokestatic #207 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 321: astore 32\n 323: aload 21\n 325: aload 20\n 327: aload 32\n 329: invokeinterface #211, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 334: pop\n 335: goto 154\n 338: aload 14\n 340: checkcast #187 // class java/util/Map\n 343: nop\n 344: astore 12\n 346: aload 12\n 348: astore 13\n 350: iconst_0\n 351: istore 14\n 353: aload 13\n 355: invokeinterface #215, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 360: checkcast #34 // class java/lang/Iterable\n 363: invokestatic #218 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 366: checkcast #34 // class java/lang/Iterable\n 369: invokestatic #207 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 372: astore_1\n 373: nop\n 374: aload 12\n 376: nop\n 377: aload 33\n 379: swap\n 380: invokeinterface #77, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 385: pop\n 386: goto 63\n 389: aload 6\n 391: checkcast #79 // class java/util/List\n 394: nop\n 395: checkcast #34 // class java/lang/Iterable\n 398: invokestatic #165 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 401: astore_2\n 402: aload_2\n 403: aload_0\n 404: iconst_0\n 405: iconst_0\n 406: invokestatic #222 // Method solve$findModelNumbers:(Ljava/util/List;Ljava/util/List;II)Ljava/util/List;\n 409: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #247 // Method main:()V\n 3: return\n\n private static final java.util.List<java.lang.String> solve$findModelNumbers(java.util.List<? extends java.util.Map<java.lang.Integer, ? extends java.util.Set<java.lang.Integer>>>, java.util.List<Variables>, int, int);\n Code:\n 0: aload_0\n 1: iload_2\n 2: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #187 // class java/util/Map\n 10: invokeinterface #254, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 15: checkcast #34 // class java/lang/Iterable\n 18: astore 5\n 20: iconst_0\n 21: istore 6\n 23: aload 5\n 25: astore 7\n 27: new #42 // class java/util/ArrayList\n 30: dup\n 31: invokespecial #195 // Method java/util/ArrayList.\"<init>\":()V\n 34: checkcast #51 // class java/util/Collection\n 37: astore 8\n 39: iconst_0\n 40: istore 9\n 42: aload 7\n 44: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 49: astore 10\n 51: aload 10\n 53: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 58: ifeq 115\n 61: aload 10\n 63: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 68: astore 11\n 70: aload 11\n 72: checkcast #256 // class java/util/Map$Entry\n 75: astore 12\n 77: iconst_0\n 78: istore 13\n 80: aload 12\n 82: invokeinterface #259, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 87: checkcast #200 // class java/util/Set\n 90: iload_3\n 91: invokestatic #155 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 94: invokeinterface #203, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 99: ifeq 51\n 102: aload 8\n 104: aload 11\n 106: invokeinterface #77, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 111: pop\n 112: goto 51\n 115: aload 8\n 117: checkcast #79 // class java/util/List\n 120: nop\n 121: checkcast #34 // class java/lang/Iterable\n 124: astore 5\n 126: nop\n 127: iconst_0\n 128: istore 6\n 130: aload 5\n 132: astore 7\n 134: new #42 // class java/util/ArrayList\n 137: dup\n 138: aload 5\n 140: bipush 10\n 142: invokestatic #46 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 145: invokespecial #49 // Method java/util/ArrayList.\"<init>\":(I)V\n 148: checkcast #51 // class java/util/Collection\n 151: astore 8\n 153: iconst_0\n 154: istore 9\n 156: aload 7\n 158: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 163: astore 10\n 165: aload 10\n 167: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 172: ifeq 226\n 175: aload 10\n 177: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 182: astore 11\n 184: aload 8\n 186: aload 11\n 188: checkcast #256 // class java/util/Map$Entry\n 191: astore 12\n 193: astore 26\n 195: iconst_0\n 196: istore 13\n 198: aload 12\n 200: invokeinterface #262, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 205: checkcast #189 // class java/lang/Number\n 208: invokevirtual #193 // Method java/lang/Number.intValue:()I\n 211: invokestatic #155 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 214: aload 26\n 216: swap\n 217: invokeinterface #77, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 222: pop\n 223: goto 165\n 226: aload 8\n 228: checkcast #79 // class java/util/List\n 231: nop\n 232: astore 4\n 234: iload_2\n 235: bipush 13\n 237: if_icmpne 347\n 240: aload 4\n 242: checkcast #34 // class java/lang/Iterable\n 245: astore 5\n 247: iconst_0\n 248: istore 6\n 250: aload 5\n 252: astore 7\n 254: new #42 // class java/util/ArrayList\n 257: dup\n 258: aload 5\n 260: bipush 10\n 262: invokestatic #46 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 265: invokespecial #49 // Method java/util/ArrayList.\"<init>\":(I)V\n 268: checkcast #51 // class java/util/Collection\n 271: astore 8\n 273: iconst_0\n 274: istore 9\n 276: aload 7\n 278: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 283: astore 10\n 285: aload 10\n 287: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 292: ifeq 338\n 295: aload 10\n 297: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 302: astore 11\n 304: aload 8\n 306: aload 11\n 308: checkcast #189 // class java/lang/Number\n 311: invokevirtual #193 // Method java/lang/Number.intValue:()I\n 314: istore 12\n 316: astore 26\n 318: iconst_0\n 319: istore 13\n 321: iload 12\n 323: invokestatic #265 // Method java/lang/String.valueOf:(I)Ljava/lang/String;\n 326: aload 26\n 328: swap\n 329: invokeinterface #77, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 334: pop\n 335: goto 285\n 338: aload 8\n 340: checkcast #79 // class java/util/List\n 343: nop\n 344: goto 582\n 347: aload 4\n 349: checkcast #34 // class java/lang/Iterable\n 352: astore 5\n 354: iconst_0\n 355: istore 6\n 357: aload 5\n 359: astore 7\n 361: new #42 // class java/util/ArrayList\n 364: dup\n 365: invokespecial #195 // Method java/util/ArrayList.\"<init>\":()V\n 368: checkcast #51 // class java/util/Collection\n 371: astore 8\n 373: iconst_0\n 374: istore 9\n 376: aload 7\n 378: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 383: astore 10\n 385: aload 10\n 387: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 392: ifeq 576\n 395: aload 10\n 397: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 402: astore 11\n 404: aload 11\n 406: checkcast #189 // class java/lang/Number\n 409: invokevirtual #193 // Method java/lang/Number.intValue:()I\n 412: istore 12\n 414: iconst_0\n 415: istore 13\n 417: aload_1\n 418: iload_2\n 419: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 424: checkcast #81 // class Variables\n 427: iload 12\n 429: iload_3\n 430: invokevirtual #198 // Method Variables.execute:(II)I\n 433: istore 14\n 435: aload_0\n 436: aload_1\n 437: iload_2\n 438: iconst_1\n 439: iadd\n 440: iload 14\n 442: invokestatic #222 // Method solve$findModelNumbers:(Ljava/util/List;Ljava/util/List;II)Ljava/util/List;\n 445: checkcast #34 // class java/lang/Iterable\n 448: astore 15\n 450: iconst_0\n 451: istore 16\n 453: aload 15\n 455: astore 17\n 457: new #42 // class java/util/ArrayList\n 460: dup\n 461: aload 15\n 463: bipush 10\n 465: invokestatic #46 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 468: invokespecial #49 // Method java/util/ArrayList.\"<init>\":(I)V\n 471: checkcast #51 // class java/util/Collection\n 474: astore 18\n 476: iconst_0\n 477: istore 19\n 479: aload 17\n 481: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 486: astore 20\n 488: aload 20\n 490: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 495: ifeq 553\n 498: aload 20\n 500: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 505: astore 21\n 507: aload 18\n 509: aload 21\n 511: checkcast #24 // class java/lang/String\n 514: astore 22\n 516: astore 23\n 518: iconst_0\n 519: istore 24\n 521: new #267 // class java/lang/StringBuilder\n 524: dup\n 525: invokespecial #268 // Method java/lang/StringBuilder.\"<init>\":()V\n 528: iload 12\n 530: invokevirtual #272 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 533: aload 22\n 535: invokevirtual #275 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 538: invokevirtual #279 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 541: aload 23\n 543: swap\n 544: invokeinterface #77, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 549: pop\n 550: goto 488\n 553: aload 18\n 555: checkcast #79 // class java/util/List\n 558: nop\n 559: checkcast #34 // class java/lang/Iterable\n 562: nop\n 563: astore 25\n 565: aload 8\n 567: aload 25\n 569: invokestatic #283 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 572: pop\n 573: goto 385\n 576: aload 8\n 578: checkcast #79 // class java/util/List\n 581: nop\n 582: areturn\n}\n",
"javap_err": ""
}
] |
dcbertelsen__advent-of-code-2022-kotlin__9d22341/src/Day04.kt
|
import java.io.File
fun main() {
fun stringToPair(data: String) : IntRange {
val nums = data.split("-")
return IntRange(nums[0].toInt(), nums[1].toInt())
}
fun processInput(pair: String): Pair<IntRange, IntRange> {
val areas = pair.split(",")
.map { stringToPair(it) }
return Pair(areas.first(), areas.last())
}
fun part1(input: List<String>): Int {
return input.map { processInput(it) }
.count { pair ->
pair.first.subsumes(pair.second) || pair.second.subsumes(pair.first) }
}
fun part2(input: List<String>): Int {
return input.map { processInput(it) }
.count { pair ->
pair.first.intersect(pair.second).any() }
}
val testInput = listOf(
"2-4,6-8",
"2-3,4-5",
"5-7,7-9",
"2-8,3-7",
"6-6,4-6",
"2-6,4-8"
)
// test if implementation meets criteria from the description, like:
check(part1(testInput) == 2)
check(part2(testInput) == 4)
val input = File("./src/resources/Day04.txt").readLines()
println(part1(input))
println(part2(input))
}
fun IntRange.subsumes(other: IntRange): Boolean =
contains(other.first) && contains(other.last)
|
[
{
"class_path": "dcbertelsen__advent-of-code-2022-kotlin__9d22341/Day04Kt.class",
"javap": "Compiled from \"Day04.kt\"\npublic final class Day04Kt {\n public static final void main();\n Code:\n 0: bipush 6\n 2: anewarray #8 // class java/lang/String\n 5: astore_1\n 6: aload_1\n 7: iconst_0\n 8: ldc #10 // String 2-4,6-8\n 10: aastore\n 11: aload_1\n 12: iconst_1\n 13: ldc #12 // String 2-3,4-5\n 15: aastore\n 16: aload_1\n 17: iconst_2\n 18: ldc #14 // String 5-7,7-9\n 20: aastore\n 21: aload_1\n 22: iconst_3\n 23: ldc #16 // String 2-8,3-7\n 25: aastore\n 26: aload_1\n 27: iconst_4\n 28: ldc #18 // String 6-6,4-6\n 30: aastore\n 31: aload_1\n 32: iconst_5\n 33: ldc #20 // String 2-6,4-8\n 35: aastore\n 36: aload_1\n 37: invokestatic #26 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 40: astore_0\n 41: aload_0\n 42: invokestatic #30 // Method main$part1:(Ljava/util/List;)I\n 45: iconst_2\n 46: if_icmpne 53\n 49: iconst_1\n 50: goto 54\n 53: iconst_0\n 54: ifne 67\n 57: new #32 // class java/lang/IllegalStateException\n 60: dup\n 61: ldc #34 // String Check failed.\n 63: invokespecial #38 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 66: athrow\n 67: aload_0\n 68: invokestatic #41 // Method main$part2:(Ljava/util/List;)I\n 71: iconst_4\n 72: if_icmpne 79\n 75: iconst_1\n 76: goto 80\n 79: iconst_0\n 80: ifne 93\n 83: new #32 // class java/lang/IllegalStateException\n 86: dup\n 87: ldc #34 // String Check failed.\n 89: invokespecial #38 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 92: athrow\n 93: new #43 // class java/io/File\n 96: dup\n 97: ldc #45 // String ./src/resources/Day04.txt\n 99: invokespecial #46 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 102: aconst_null\n 103: iconst_1\n 104: aconst_null\n 105: invokestatic #52 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 108: astore_1\n 109: aload_1\n 110: invokestatic #30 // Method main$part1:(Ljava/util/List;)I\n 113: istore_2\n 114: getstatic #58 // Field java/lang/System.out:Ljava/io/PrintStream;\n 117: iload_2\n 118: invokevirtual #64 // Method java/io/PrintStream.println:(I)V\n 121: aload_1\n 122: invokestatic #41 // Method main$part2:(Ljava/util/List;)I\n 125: istore_2\n 126: getstatic #58 // Field java/lang/System.out:Ljava/io/PrintStream;\n 129: iload_2\n 130: invokevirtual #64 // Method java/io/PrintStream.println:(I)V\n 133: return\n\n public static final boolean subsumes(kotlin.ranges.IntRange, kotlin.ranges.IntRange);\n Code:\n 0: aload_0\n 1: ldc #76 // String <this>\n 3: invokestatic #82 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #84 // String other\n 9: invokestatic #82 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: aload_1\n 14: invokevirtual #90 // Method kotlin/ranges/IntRange.getFirst:()I\n 17: invokevirtual #94 // Method kotlin/ranges/IntRange.contains:(I)Z\n 20: ifeq 38\n 23: aload_0\n 24: aload_1\n 25: invokevirtual #97 // Method kotlin/ranges/IntRange.getLast:()I\n 28: invokevirtual #94 // Method kotlin/ranges/IntRange.contains:(I)Z\n 31: ifeq 38\n 34: iconst_1\n 35: goto 39\n 38: iconst_0\n 39: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #102 // Method main:()V\n 3: return\n\n private static final kotlin.ranges.IntRange main$stringToPair(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #107 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #8 // class java/lang/String\n 8: astore_2\n 9: aload_2\n 10: iconst_0\n 11: ldc #109 // String -\n 13: aastore\n 14: aload_2\n 15: iconst_0\n 16: iconst_0\n 17: bipush 6\n 19: aconst_null\n 20: invokestatic #115 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 23: astore_1\n 24: new #86 // class kotlin/ranges/IntRange\n 27: dup\n 28: aload_1\n 29: iconst_0\n 30: invokeinterface #119, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 35: checkcast #8 // class java/lang/String\n 38: invokestatic #125 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 41: aload_1\n 42: iconst_1\n 43: invokeinterface #119, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 48: checkcast #8 // class java/lang/String\n 51: invokestatic #125 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 54: invokespecial #128 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 57: areturn\n\n private static final kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange> main$processInput(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #107 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #8 // class java/lang/String\n 8: astore_2\n 9: aload_2\n 10: iconst_0\n 11: ldc #136 // String ,\n 13: aastore\n 14: aload_2\n 15: iconst_0\n 16: iconst_0\n 17: bipush 6\n 19: aconst_null\n 20: invokestatic #115 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 23: checkcast #138 // class java/lang/Iterable\n 26: astore_2\n 27: nop\n 28: iconst_0\n 29: istore_3\n 30: aload_2\n 31: astore 4\n 33: new #140 // class java/util/ArrayList\n 36: dup\n 37: aload_2\n 38: bipush 10\n 40: invokestatic #144 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 43: invokespecial #146 // Method java/util/ArrayList.\"<init>\":(I)V\n 46: checkcast #148 // class java/util/Collection\n 49: astore 5\n 51: iconst_0\n 52: istore 6\n 54: aload 4\n 56: invokeinterface #152, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 61: astore 7\n 63: aload 7\n 65: invokeinterface #158, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 70: ifeq 113\n 73: aload 7\n 75: invokeinterface #162, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 80: astore 8\n 82: aload 5\n 84: aload 8\n 86: checkcast #8 // class java/lang/String\n 89: astore 9\n 91: astore 11\n 93: iconst_0\n 94: istore 10\n 96: aload 9\n 98: invokestatic #164 // Method main$stringToPair:(Ljava/lang/String;)Lkotlin/ranges/IntRange;\n 101: aload 11\n 103: swap\n 104: invokeinterface #168, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 109: pop\n 110: goto 63\n 113: aload 5\n 115: checkcast #69 // class java/util/List\n 118: nop\n 119: astore_1\n 120: new #170 // class kotlin/Pair\n 123: dup\n 124: aload_1\n 125: invokestatic #174 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 128: aload_1\n 129: invokestatic #177 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 132: invokespecial #180 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 135: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #138 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: astore_3\n 9: new #140 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #144 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #146 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #148 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #152, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #158, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 88\n 48: aload 6\n 50: invokeinterface #162, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #8 // class java/lang/String\n 64: astore 8\n 66: astore 10\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: invokestatic #197 // Method main$processInput:(Ljava/lang/String;)Lkotlin/Pair;\n 76: aload 10\n 78: swap\n 79: invokeinterface #168, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 84: pop\n 85: goto 38\n 88: aload 4\n 90: checkcast #69 // class java/util/List\n 93: nop\n 94: checkcast #138 // class java/lang/Iterable\n 97: astore_1\n 98: nop\n 99: iconst_0\n 100: istore_2\n 101: aload_1\n 102: instanceof #148 // class java/util/Collection\n 105: ifeq 124\n 108: aload_1\n 109: checkcast #148 // class java/util/Collection\n 112: invokeinterface #200, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 117: ifeq 124\n 120: iconst_0\n 121: goto 229\n 124: iconst_0\n 125: istore_3\n 126: aload_1\n 127: invokeinterface #152, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 132: astore 4\n 134: aload 4\n 136: invokeinterface #158, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 141: ifeq 228\n 144: aload 4\n 146: invokeinterface #162, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 151: astore 5\n 153: aload 5\n 155: checkcast #170 // class kotlin/Pair\n 158: astore 6\n 160: iconst_0\n 161: istore 7\n 163: aload 6\n 165: invokevirtual #202 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 168: checkcast #86 // class kotlin/ranges/IntRange\n 171: aload 6\n 173: invokevirtual #205 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 176: checkcast #86 // class kotlin/ranges/IntRange\n 179: invokestatic #207 // Method subsumes:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z\n 182: ifne 207\n 185: aload 6\n 187: invokevirtual #205 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 190: checkcast #86 // class kotlin/ranges/IntRange\n 193: aload 6\n 195: invokevirtual #202 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 198: checkcast #86 // class kotlin/ranges/IntRange\n 201: invokestatic #207 // Method subsumes:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z\n 204: ifeq 211\n 207: iconst_1\n 208: goto 212\n 211: iconst_0\n 212: ifeq 134\n 215: iinc 3, 1\n 218: iload_3\n 219: ifge 134\n 222: invokestatic #210 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 225: goto 134\n 228: iload_3\n 229: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #138 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: astore_3\n 9: new #140 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #144 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #146 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #148 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #152, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #158, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 88\n 48: aload 6\n 50: invokeinterface #162, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #8 // class java/lang/String\n 64: astore 8\n 66: astore 10\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: invokestatic #197 // Method main$processInput:(Ljava/lang/String;)Lkotlin/Pair;\n 76: aload 10\n 78: swap\n 79: invokeinterface #168, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 84: pop\n 85: goto 38\n 88: aload 4\n 90: checkcast #69 // class java/util/List\n 93: nop\n 94: checkcast #138 // class java/lang/Iterable\n 97: astore_1\n 98: nop\n 99: iconst_0\n 100: istore_2\n 101: aload_1\n 102: instanceof #148 // class java/util/Collection\n 105: ifeq 124\n 108: aload_1\n 109: checkcast #148 // class java/util/Collection\n 112: invokeinterface #200, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 117: ifeq 124\n 120: iconst_0\n 121: goto 205\n 124: iconst_0\n 125: istore_3\n 126: aload_1\n 127: invokeinterface #152, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 132: astore 4\n 134: aload 4\n 136: invokeinterface #158, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 141: ifeq 204\n 144: aload 4\n 146: invokeinterface #162, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 151: astore 5\n 153: aload 5\n 155: checkcast #170 // class kotlin/Pair\n 158: astore 6\n 160: iconst_0\n 161: istore 7\n 163: aload 6\n 165: invokevirtual #202 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 168: checkcast #138 // class java/lang/Iterable\n 171: aload 6\n 173: invokevirtual #205 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 176: checkcast #138 // class java/lang/Iterable\n 179: invokestatic #221 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 182: checkcast #138 // class java/lang/Iterable\n 185: invokestatic #225 // Method kotlin/collections/CollectionsKt.any:(Ljava/lang/Iterable;)Z\n 188: ifeq 134\n 191: iinc 3, 1\n 194: iload_3\n 195: ifge 134\n 198: invokestatic #210 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 201: goto 134\n 204: iload_3\n 205: ireturn\n}\n",
"javap_err": ""
}
] |
dcbertelsen__advent-of-code-2022-kotlin__9d22341/src/Day05.kt
|
import java.io.File
fun main() {
fun dataToParts(input: String): Pair<String, String> {
val parts = input.split("\n\n")
return parts[0] to parts[1]
}
fun initStacks(input: String): Map<Int, MutableList<Char>>{
val lines = input.split("\n").reversed()
val stacks = lines[0].filter { it != ' ' }.map { c -> c.digitToInt() to mutableListOf<Char>() }.toMap()
lines.drop(1).forEach { line -> line.chunked(4).forEachIndexed { i, s ->
if (s[1] != ' ') stacks[i+1]?.add(s[1])
} }
return stacks
}
fun readMoves(input: String): List<Triple<Int, Int, Int>> {
return input.lines().map { line -> line.split(" ")}
.map { Triple(it[1].toInt(), it[3].toInt(), it[5].toInt())}
}
fun part1(input: String): String {
val (stackData, moveData) = dataToParts(input)
val stacks = initStacks(stackData)
val moves = readMoves(moveData)
moves.forEach { move ->
repeat (move.first) {
stacks[move.third]?.add(stacks[move.second]?.removeLast() ?: ' ')
}
}
return stacks.map {
it.value.last() }.joinToString("")
}
fun part2(input: String): String {
val (stackData, moveData) = dataToParts(input)
val stacks = initStacks(stackData)
val moves = readMoves(moveData)
moves.forEach { move ->
val crates = stacks[move.second]?.takeLast(move.first) ?: listOf()
repeat(move.first) { stacks[move.second]?.removeLast() }
stacks[move.third]?.addAll(crates)
}
return stacks.map {
it.value.last() }.joinToString("")
}
val testInput = listOf<String>(
" [D]",
"[N] [C]",
"[Z] [M] [P]",
" 1 2 3",
"",
"move 1 from 2 to 1",
"move 3 from 1 to 3",
"move 2 from 2 to 1",
"move 1 from 1 to 2"
).joinToString("\n")
// test if implementation meets criteria from the description, like:
val test = part1(testInput)
println(test)
check(test == "CMZ")
// check(part2(testInput) == 42)
val input = File("./src/resources/Day05.txt").readText()
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "dcbertelsen__advent-of-code-2022-kotlin__9d22341/Day05Kt.class",
"javap": "Compiled from \"Day05.kt\"\npublic final class Day05Kt {\n public static final void main();\n Code:\n 0: bipush 9\n 2: anewarray #8 // class java/lang/String\n 5: astore_1\n 6: aload_1\n 7: iconst_0\n 8: ldc #10 // String [D]\n 10: aastore\n 11: aload_1\n 12: iconst_1\n 13: ldc #12 // String [N] [C]\n 15: aastore\n 16: aload_1\n 17: iconst_2\n 18: ldc #14 // String [Z] [M] [P]\n 20: aastore\n 21: aload_1\n 22: iconst_3\n 23: ldc #16 // String 1 2 3\n 25: aastore\n 26: aload_1\n 27: iconst_4\n 28: ldc #18 // String\n 30: aastore\n 31: aload_1\n 32: iconst_5\n 33: ldc #20 // String move 1 from 2 to 1\n 35: aastore\n 36: aload_1\n 37: bipush 6\n 39: ldc #22 // String move 3 from 1 to 3\n 41: aastore\n 42: aload_1\n 43: bipush 7\n 45: ldc #24 // String move 2 from 2 to 1\n 47: aastore\n 48: aload_1\n 49: bipush 8\n 51: ldc #26 // String move 1 from 1 to 2\n 53: aastore\n 54: aload_1\n 55: invokestatic #32 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 58: checkcast #34 // class java/lang/Iterable\n 61: ldc #36 // String \\n\n 63: checkcast #38 // class java/lang/CharSequence\n 66: aconst_null\n 67: aconst_null\n 68: iconst_0\n 69: aconst_null\n 70: aconst_null\n 71: bipush 62\n 73: aconst_null\n 74: invokestatic #42 // 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 77: astore_0\n 78: aload_0\n 79: invokestatic #46 // Method main$part1:(Ljava/lang/String;)Ljava/lang/String;\n 82: astore_1\n 83: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 86: aload_1\n 87: invokevirtual #58 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 90: aload_1\n 91: ldc #60 // String CMZ\n 93: invokestatic #66 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 96: ifne 109\n 99: new #68 // class java/lang/IllegalStateException\n 102: dup\n 103: ldc #70 // String Check failed.\n 105: invokespecial #74 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 108: athrow\n 109: new #76 // class java/io/File\n 112: dup\n 113: ldc #78 // String ./src/resources/Day05.txt\n 115: invokespecial #79 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 118: aconst_null\n 119: iconst_1\n 120: aconst_null\n 121: invokestatic #85 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;\n 124: astore_2\n 125: aload_2\n 126: invokestatic #46 // Method main$part1:(Ljava/lang/String;)Ljava/lang/String;\n 129: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 132: swap\n 133: invokevirtual #58 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 136: aload_2\n 137: invokestatic #88 // Method main$part2:(Ljava/lang/String;)Ljava/lang/String;\n 140: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 143: swap\n 144: invokevirtual #58 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 147: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #95 // Method main:()V\n 3: return\n\n private static final kotlin.Pair<java.lang.String, java.lang.String> main$dataToParts(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #38 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #8 // class java/lang/String\n 8: astore_2\n 9: aload_2\n 10: iconst_0\n 11: ldc #102 // String \\n\\n\n 13: aastore\n 14: aload_2\n 15: iconst_0\n 16: iconst_0\n 17: bipush 6\n 19: aconst_null\n 20: invokestatic #108 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 23: astore_1\n 24: aload_1\n 25: iconst_0\n 26: invokeinterface #114, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 31: aload_1\n 32: iconst_1\n 33: invokeinterface #114, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 38: invokestatic #120 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 41: areturn\n\n private static final java.util.Map<java.lang.Integer, java.util.List<java.lang.Character>> main$initStacks(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #38 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #8 // class java/lang/String\n 8: astore_2\n 9: aload_2\n 10: iconst_0\n 11: ldc #36 // String \\n\n 13: aastore\n 14: aload_2\n 15: iconst_0\n 16: iconst_0\n 17: bipush 6\n 19: aconst_null\n 20: invokestatic #108 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 23: checkcast #34 // class java/lang/Iterable\n 26: invokestatic #129 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 29: astore_1\n 30: aload_1\n 31: iconst_0\n 32: invokeinterface #114, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 37: checkcast #8 // class java/lang/String\n 40: astore_3\n 41: iconst_0\n 42: istore 4\n 44: aload_3\n 45: checkcast #38 // class java/lang/CharSequence\n 48: astore 5\n 50: new #131 // class java/lang/StringBuilder\n 53: dup\n 54: invokespecial #133 // Method java/lang/StringBuilder.\"<init>\":()V\n 57: checkcast #135 // class java/lang/Appendable\n 60: astore 6\n 62: iconst_0\n 63: istore 7\n 65: iconst_0\n 66: istore 8\n 68: aload 5\n 70: invokeinterface #139, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 75: istore 9\n 77: iload 8\n 79: iload 9\n 81: if_icmpge 133\n 84: aload 5\n 86: iload 8\n 88: invokeinterface #143, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 93: istore 10\n 95: iload 10\n 97: istore 11\n 99: iconst_0\n 100: istore 12\n 102: iload 11\n 104: bipush 32\n 106: if_icmpeq 113\n 109: iconst_1\n 110: goto 114\n 113: iconst_0\n 114: ifeq 127\n 117: aload 6\n 119: iload 10\n 121: invokeinterface #147, 2 // InterfaceMethod java/lang/Appendable.append:(C)Ljava/lang/Appendable;\n 126: pop\n 127: iinc 8, 1\n 130: goto 77\n 133: aload 6\n 135: checkcast #131 // class java/lang/StringBuilder\n 138: invokevirtual #151 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 141: checkcast #38 // class java/lang/CharSequence\n 144: astore_3\n 145: nop\n 146: iconst_0\n 147: istore 4\n 149: aload_3\n 150: astore 5\n 152: new #153 // class java/util/ArrayList\n 155: dup\n 156: aload_3\n 157: invokeinterface #139, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 162: invokespecial #156 // Method java/util/ArrayList.\"<init>\":(I)V\n 165: checkcast #158 // class java/util/Collection\n 168: astore 6\n 170: iconst_0\n 171: istore 7\n 173: iconst_0\n 174: istore 8\n 176: iload 8\n 178: aload 5\n 180: invokeinterface #139, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 185: if_icmpge 246\n 188: aload 5\n 190: iload 8\n 192: invokeinterface #143, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 197: istore 9\n 199: aload 6\n 201: iload 9\n 203: istore 10\n 205: astore 18\n 207: iconst_0\n 208: istore 11\n 210: iload 10\n 212: invokestatic #164 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 215: invokestatic #170 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 218: new #153 // class java/util/ArrayList\n 221: dup\n 222: invokespecial #171 // Method java/util/ArrayList.\"<init>\":()V\n 225: checkcast #110 // class java/util/List\n 228: invokestatic #120 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 231: aload 18\n 233: swap\n 234: invokeinterface #175, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 239: pop\n 240: iinc 8, 1\n 243: goto 176\n 246: aload 6\n 248: checkcast #110 // class java/util/List\n 251: nop\n 252: checkcast #34 // class java/lang/Iterable\n 255: invokestatic #181 // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;\n 258: astore_2\n 259: aload_1\n 260: checkcast #34 // class java/lang/Iterable\n 263: iconst_1\n 264: invokestatic #185 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 267: checkcast #34 // class java/lang/Iterable\n 270: astore_3\n 271: iconst_0\n 272: istore 4\n 274: aload_3\n 275: invokeinterface #189, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 280: astore 5\n 282: aload 5\n 284: invokeinterface #195, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 289: ifeq 449\n 292: aload 5\n 294: invokeinterface #199, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 299: astore 6\n 301: aload 6\n 303: checkcast #8 // class java/lang/String\n 306: astore 7\n 308: iconst_0\n 309: istore 8\n 311: aload 7\n 313: checkcast #38 // class java/lang/CharSequence\n 316: iconst_4\n 317: invokestatic #203 // Method kotlin/text/StringsKt.chunked:(Ljava/lang/CharSequence;I)Ljava/util/List;\n 320: checkcast #34 // class java/lang/Iterable\n 323: astore 9\n 325: iconst_0\n 326: istore 10\n 328: iconst_0\n 329: istore 11\n 331: aload 9\n 333: invokeinterface #189, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 338: astore 12\n 340: aload 12\n 342: invokeinterface #195, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 347: ifeq 443\n 350: aload 12\n 352: invokeinterface #199, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 357: astore 13\n 359: iload 11\n 361: iinc 11, 1\n 364: istore 14\n 366: iload 14\n 368: ifge 374\n 371: invokestatic #206 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 374: iload 14\n 376: aload 13\n 378: checkcast #8 // class java/lang/String\n 381: astore 15\n 383: istore 16\n 385: iconst_0\n 386: istore 17\n 388: aload 15\n 390: iconst_1\n 391: invokevirtual #207 // Method java/lang/String.charAt:(I)C\n 394: bipush 32\n 396: if_icmpeq 438\n 399: aload_2\n 400: iload 16\n 402: iconst_1\n 403: iadd\n 404: invokestatic #170 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 407: invokeinterface #212, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 412: checkcast #110 // class java/util/List\n 415: dup\n 416: ifnull 437\n 419: aload 15\n 421: iconst_1\n 422: invokevirtual #207 // Method java/lang/String.charAt:(I)C\n 425: invokestatic #217 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 428: invokeinterface #218, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 433: pop\n 434: goto 438\n 437: pop\n 438: nop\n 439: nop\n 440: goto 340\n 443: nop\n 444: nop\n 445: nop\n 446: goto 282\n 449: nop\n 450: aload_2\n 451: areturn\n\n private static final java.util.List<kotlin.Triple<java.lang.Integer, java.lang.Integer, java.lang.Integer>> main$readMoves(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #38 // class java/lang/CharSequence\n 4: invokestatic #263 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 7: checkcast #34 // class java/lang/Iterable\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: aload_1\n 14: astore_3\n 15: new #153 // class java/util/ArrayList\n 18: dup\n 19: aload_1\n 20: bipush 10\n 22: invokestatic #267 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 25: invokespecial #156 // Method java/util/ArrayList.\"<init>\":(I)V\n 28: checkcast #158 // class java/util/Collection\n 31: astore 4\n 33: iconst_0\n 34: istore 5\n 36: aload_3\n 37: invokeinterface #189, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 6\n 44: aload 6\n 46: invokeinterface #195, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 117\n 54: aload 6\n 56: invokeinterface #199, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 7\n 63: aload 4\n 65: aload 7\n 67: checkcast #8 // class java/lang/String\n 70: astore 8\n 72: astore 11\n 74: iconst_0\n 75: istore 9\n 77: aload 8\n 79: checkcast #38 // class java/lang/CharSequence\n 82: iconst_1\n 83: anewarray #8 // class java/lang/String\n 86: astore 10\n 88: aload 10\n 90: iconst_0\n 91: ldc_w #269 // String\n 94: aastore\n 95: aload 10\n 97: iconst_0\n 98: iconst_0\n 99: bipush 6\n 101: aconst_null\n 102: invokestatic #108 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 105: aload 11\n 107: swap\n 108: invokeinterface #175, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 113: pop\n 114: goto 44\n 117: aload 4\n 119: checkcast #110 // class java/util/List\n 122: nop\n 123: checkcast #34 // class java/lang/Iterable\n 126: astore_1\n 127: nop\n 128: iconst_0\n 129: istore_2\n 130: aload_1\n 131: astore_3\n 132: new #153 // class java/util/ArrayList\n 135: dup\n 136: aload_1\n 137: bipush 10\n 139: invokestatic #267 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 142: invokespecial #156 // Method java/util/ArrayList.\"<init>\":(I)V\n 145: checkcast #158 // class java/util/Collection\n 148: astore 4\n 150: iconst_0\n 151: istore 5\n 153: aload_3\n 154: invokeinterface #189, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 159: astore 6\n 161: aload 6\n 163: invokeinterface #195, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 168: ifeq 264\n 171: aload 6\n 173: invokeinterface #199, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 178: astore 7\n 180: aload 4\n 182: aload 7\n 184: checkcast #110 // class java/util/List\n 187: astore 8\n 189: astore 11\n 191: iconst_0\n 192: istore 9\n 194: new #271 // class kotlin/Triple\n 197: dup\n 198: aload 8\n 200: iconst_1\n 201: invokeinterface #114, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 206: checkcast #8 // class java/lang/String\n 209: invokestatic #275 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 212: invokestatic #170 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 215: aload 8\n 217: iconst_3\n 218: invokeinterface #114, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 223: checkcast #8 // class java/lang/String\n 226: invokestatic #275 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 229: invokestatic #170 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 232: aload 8\n 234: iconst_5\n 235: invokeinterface #114, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 240: checkcast #8 // class java/lang/String\n 243: invokestatic #275 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 246: invokestatic #170 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 249: invokespecial #278 // Method kotlin/Triple.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V\n 252: aload 11\n 254: swap\n 255: invokeinterface #175, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 260: pop\n 261: goto 161\n 264: aload 4\n 266: checkcast #110 // class java/util/List\n 269: nop\n 270: areturn\n\n private static final java.lang.String main$part1(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #282 // Method main$dataToParts:(Ljava/lang/String;)Lkotlin/Pair;\n 4: astore_1\n 5: aload_1\n 6: invokevirtual #287 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 9: checkcast #8 // class java/lang/String\n 12: astore_2\n 13: aload_1\n 14: invokevirtual #290 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 17: checkcast #8 // class java/lang/String\n 20: astore_3\n 21: aload_2\n 22: invokestatic #292 // Method main$initStacks:(Ljava/lang/String;)Ljava/util/Map;\n 25: astore 4\n 27: aload_3\n 28: invokestatic #294 // Method main$readMoves:(Ljava/lang/String;)Ljava/util/List;\n 31: astore 5\n 33: aload 5\n 35: checkcast #34 // class java/lang/Iterable\n 38: astore 6\n 40: iconst_0\n 41: istore 7\n 43: aload 6\n 45: invokeinterface #189, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 50: astore 8\n 52: aload 8\n 54: invokeinterface #195, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 195\n 62: aload 8\n 64: invokeinterface #199, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 69: astore 9\n 71: aload 9\n 73: checkcast #271 // class kotlin/Triple\n 76: astore 10\n 78: iconst_0\n 79: istore 11\n 81: aload 10\n 83: invokevirtual #297 // Method kotlin/Triple.getFirst:()Ljava/lang/Object;\n 86: checkcast #299 // class java/lang/Number\n 89: invokevirtual #302 // Method java/lang/Number.intValue:()I\n 92: istore 12\n 94: iconst_0\n 95: istore 13\n 97: iload 13\n 99: iload 12\n 101: if_icmpge 190\n 104: iload 13\n 106: istore 14\n 108: iconst_0\n 109: istore 15\n 111: aload 4\n 113: aload 10\n 115: invokevirtual #305 // Method kotlin/Triple.getThird:()Ljava/lang/Object;\n 118: invokeinterface #212, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 123: checkcast #110 // class java/util/List\n 126: dup\n 127: ifnull 182\n 130: aload 4\n 132: aload 10\n 134: invokevirtual #308 // Method kotlin/Triple.getSecond:()Ljava/lang/Object;\n 137: invokeinterface #212, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 142: checkcast #110 // class java/util/List\n 145: dup\n 146: ifnull 167\n 149: invokeinterface #311, 1 // InterfaceMethod java/util/List.removeLast:()Ljava/lang/Object;\n 154: checkcast #214 // class java/lang/Character\n 157: dup\n 158: ifnull 167\n 161: invokevirtual #315 // Method java/lang/Character.charValue:()C\n 164: goto 170\n 167: pop\n 168: bipush 32\n 170: invokestatic #217 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 173: invokeinterface #218, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 178: pop\n 179: goto 183\n 182: pop\n 183: nop\n 184: iinc 13, 1\n 187: goto 97\n 190: nop\n 191: nop\n 192: goto 52\n 195: nop\n 196: aload 4\n 198: astore 6\n 200: iconst_0\n 201: istore 7\n 203: aload 6\n 205: astore 8\n 207: new #153 // class java/util/ArrayList\n 210: dup\n 211: aload 6\n 213: invokeinterface #318, 1 // InterfaceMethod java/util/Map.size:()I\n 218: invokespecial #156 // Method java/util/ArrayList.\"<init>\":(I)V\n 221: checkcast #158 // class java/util/Collection\n 224: astore 9\n 226: iconst_0\n 227: istore 10\n 229: aload 8\n 231: invokeinterface #322, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 236: invokeinterface #325, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 241: astore 11\n 243: aload 11\n 245: invokeinterface #195, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 250: ifeq 310\n 253: aload 11\n 255: invokeinterface #199, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 260: checkcast #327 // class java/util/Map$Entry\n 263: astore 12\n 265: aload 9\n 267: aload 12\n 269: astore 13\n 271: astore 16\n 273: iconst_0\n 274: istore 14\n 276: aload 13\n 278: invokeinterface #330, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 283: checkcast #110 // class java/util/List\n 286: invokestatic #334 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 289: checkcast #214 // class java/lang/Character\n 292: invokevirtual #315 // Method java/lang/Character.charValue:()C\n 295: invokestatic #217 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 298: aload 16\n 300: swap\n 301: invokeinterface #175, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 306: pop\n 307: goto 243\n 310: aload 9\n 312: checkcast #110 // class java/util/List\n 315: nop\n 316: checkcast #34 // class java/lang/Iterable\n 319: ldc #18 // String\n 321: checkcast #38 // class java/lang/CharSequence\n 324: aconst_null\n 325: aconst_null\n 326: iconst_0\n 327: aconst_null\n 328: aconst_null\n 329: bipush 62\n 331: aconst_null\n 332: invokestatic #42 // 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 335: areturn\n\n private static final java.lang.String main$part2(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #282 // Method main$dataToParts:(Ljava/lang/String;)Lkotlin/Pair;\n 4: astore_1\n 5: aload_1\n 6: invokevirtual #287 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 9: checkcast #8 // class java/lang/String\n 12: astore_2\n 13: aload_1\n 14: invokevirtual #290 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 17: checkcast #8 // class java/lang/String\n 20: astore_3\n 21: aload_2\n 22: invokestatic #292 // Method main$initStacks:(Ljava/lang/String;)Ljava/util/Map;\n 25: astore 4\n 27: aload_3\n 28: invokestatic #294 // Method main$readMoves:(Ljava/lang/String;)Ljava/util/List;\n 31: astore 5\n 33: aload 5\n 35: checkcast #34 // class java/lang/Iterable\n 38: astore 6\n 40: iconst_0\n 41: istore 7\n 43: aload 6\n 45: invokeinterface #189, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 50: astore 8\n 52: aload 8\n 54: invokeinterface #195, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 231\n 62: aload 8\n 64: invokeinterface #199, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 69: astore 9\n 71: aload 9\n 73: checkcast #271 // class kotlin/Triple\n 76: astore 10\n 78: iconst_0\n 79: istore 11\n 81: aload 4\n 83: aload 10\n 85: invokevirtual #308 // Method kotlin/Triple.getSecond:()Ljava/lang/Object;\n 88: invokeinterface #212, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 93: checkcast #110 // class java/util/List\n 96: dup\n 97: ifnull 118\n 100: aload 10\n 102: invokevirtual #297 // Method kotlin/Triple.getFirst:()Ljava/lang/Object;\n 105: checkcast #299 // class java/lang/Number\n 108: invokevirtual #302 // Method java/lang/Number.intValue:()I\n 111: invokestatic #347 // Method kotlin/collections/CollectionsKt.takeLast:(Ljava/util/List;I)Ljava/util/List;\n 114: dup\n 115: ifnonnull 122\n 118: pop\n 119: invokestatic #351 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 122: astore 12\n 124: aload 10\n 126: invokevirtual #297 // Method kotlin/Triple.getFirst:()Ljava/lang/Object;\n 129: checkcast #299 // class java/lang/Number\n 132: invokevirtual #302 // Method java/lang/Number.intValue:()I\n 135: istore 13\n 137: iconst_0\n 138: istore 14\n 140: iload 14\n 142: iload 13\n 144: if_icmpge 192\n 147: iload 14\n 149: istore 15\n 151: iconst_0\n 152: istore 16\n 154: aload 4\n 156: aload 10\n 158: invokevirtual #308 // Method kotlin/Triple.getSecond:()Ljava/lang/Object;\n 161: invokeinterface #212, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 166: checkcast #110 // class java/util/List\n 169: dup\n 170: ifnull 185\n 173: invokeinterface #311, 1 // InterfaceMethod java/util/List.removeLast:()Ljava/lang/Object;\n 178: checkcast #214 // class java/lang/Character\n 181: pop\n 182: goto 186\n 185: pop\n 186: iinc 14, 1\n 189: goto 140\n 192: aload 4\n 194: aload 10\n 196: invokevirtual #305 // Method kotlin/Triple.getThird:()Ljava/lang/Object;\n 199: invokeinterface #212, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 204: checkcast #110 // class java/util/List\n 207: dup\n 208: ifnull 225\n 211: aload 12\n 213: checkcast #158 // class java/util/Collection\n 216: invokeinterface #355, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 221: pop\n 222: goto 226\n 225: pop\n 226: nop\n 227: nop\n 228: goto 52\n 231: nop\n 232: aload 4\n 234: astore 6\n 236: iconst_0\n 237: istore 7\n 239: aload 6\n 241: astore 8\n 243: new #153 // class java/util/ArrayList\n 246: dup\n 247: aload 6\n 249: invokeinterface #318, 1 // InterfaceMethod java/util/Map.size:()I\n 254: invokespecial #156 // Method java/util/ArrayList.\"<init>\":(I)V\n 257: checkcast #158 // class java/util/Collection\n 260: astore 9\n 262: iconst_0\n 263: istore 10\n 265: aload 8\n 267: invokeinterface #322, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 272: invokeinterface #325, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 277: astore 11\n 279: aload 11\n 281: invokeinterface #195, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 286: ifeq 346\n 289: aload 11\n 291: invokeinterface #199, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 296: checkcast #327 // class java/util/Map$Entry\n 299: astore 12\n 301: aload 9\n 303: aload 12\n 305: astore 13\n 307: astore 17\n 309: iconst_0\n 310: istore 14\n 312: aload 13\n 314: invokeinterface #330, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 319: checkcast #110 // class java/util/List\n 322: invokestatic #334 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 325: checkcast #214 // class java/lang/Character\n 328: invokevirtual #315 // Method java/lang/Character.charValue:()C\n 331: invokestatic #217 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 334: aload 17\n 336: swap\n 337: invokeinterface #175, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 342: pop\n 343: goto 279\n 346: aload 9\n 348: checkcast #110 // class java/util/List\n 351: nop\n 352: checkcast #34 // class java/lang/Iterable\n 355: ldc #18 // String\n 357: checkcast #38 // class java/lang/CharSequence\n 360: aconst_null\n 361: aconst_null\n 362: iconst_0\n 363: aconst_null\n 364: aconst_null\n 365: bipush 62\n 367: aconst_null\n 368: invokestatic #42 // 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 371: areturn\n}\n",
"javap_err": ""
}
] |
dcbertelsen__advent-of-code-2022-kotlin__9d22341/src/Day07.kt
|
import java.io.File
import java.util.Dictionary
fun main() {
fun buildFilesystem(data: List<String>): Directory {
val root = Directory("/", null)
var cwd = root
data.forEachIndexed { i, line ->
val curr = line.split(" ")
when {
curr[1] == "cd" -> cwd = if (curr[2] == "/") root
else if (curr[2] == "..") cwd.parent ?: cwd
else cwd.contents.firstOrNull { it.name == curr[2] } as? Directory ?: Directory(curr[2], cwd).also { cwd.contents.add(it) }
curr[0] == "dir" -> cwd.contents.firstOrNull { it.name == curr[1] } ?: cwd.contents.add(Directory(curr[1], cwd))
curr[1] == "ls" -> {}
curr[0].matches(Regex("\\d+")) -> cwd.contents.firstOrNull { it.name == curr[1] } ?: cwd.contents.add(Data(curr[1], curr[0].toInt(), cwd))
}
}
return root
}
fun part1(input: List<String>): Int {
val fs = buildFilesystem(input)
// fs.filetree().forEach { println(it) }
val bigdirs = fs.listAll().filter { it is Directory && it.size <= 100000 }
return bigdirs.sumOf { it.size }
}
fun part2(input: List<String>): Int {
val fs = buildFilesystem(input)
val dirs = fs.listAll().filterIsInstance<Directory>()
val target = fs.size - 4e7
return dirs.filter { it.size >= target }.minBy { it.size }.size
}
val testInput = listOf<String>(
"$ cd /",
"$ ls",
"dir a",
"14848514 b.txt",
"8504156 c.dat",
"dir d",
"$ cd a",
"$ ls",
"dir e",
"29116 f",
"2557 g",
"62596 h.lst",
"$ cd e",
"$ ls",
"584 i",
"$ cd ..",
"$ cd ..",
"$ cd d",
"$ ls",
"4060174 j",
"8033020 d.log",
"5626152 d.ext",
"7214296 k",
)
// test if implementation meets criteria from the description, like:
check(part1(testInput) == 95437)
// check(part2(testInput) == 42)
val input = File("./src/resources/Day07.txt").readLines()
println(part1(input))
println(part2(input))
}
sealed class FsNode(val name: String, val parent: Directory?) {
abstract val size: Int
abstract fun listAll() : List<FsNode>
}
class Directory(
name: String,
parent: Directory?,
val contents: MutableList<FsNode> = mutableListOf()
) : FsNode(name, parent) {
override val size
get() = contents.sumOf { it.size }
override fun toString(): String {
return "- $name (dir, size = $size)" //\n " + contents.sortedBy { it.name }.joinToString("\n ")
}
fun filetree() : List<String> {
return listOf("$this") + contents.flatMap { (it as? Directory)?.filetree() ?: listOf("$it") }.map { " $it" }
}
override fun listAll() : List<FsNode> = listOf(this) + contents.flatMap { it.listAll() }
}
class Data(name: String, override val size: Int, parent: Directory) : FsNode(name, parent) {
override fun toString(): String {
return "- $name (file, size = $size)"
}
override fun listAll() : List<FsNode> = listOf(this)
}
|
[
{
"class_path": "dcbertelsen__advent-of-code-2022-kotlin__9d22341/Day07Kt.class",
"javap": "Compiled from \"Day07.kt\"\npublic final class Day07Kt {\n public static final void main();\n Code:\n 0: bipush 23\n 2: anewarray #8 // class java/lang/String\n 5: astore_1\n 6: aload_1\n 7: iconst_0\n 8: ldc #10 // String $ cd /\n 10: aastore\n 11: aload_1\n 12: iconst_1\n 13: ldc #12 // String $ ls\n 15: aastore\n 16: aload_1\n 17: iconst_2\n 18: ldc #14 // String dir a\n 20: aastore\n 21: aload_1\n 22: iconst_3\n 23: ldc #16 // String 14848514 b.txt\n 25: aastore\n 26: aload_1\n 27: iconst_4\n 28: ldc #18 // String 8504156 c.dat\n 30: aastore\n 31: aload_1\n 32: iconst_5\n 33: ldc #20 // String dir d\n 35: aastore\n 36: aload_1\n 37: bipush 6\n 39: ldc #22 // String $ cd a\n 41: aastore\n 42: aload_1\n 43: bipush 7\n 45: ldc #12 // String $ ls\n 47: aastore\n 48: aload_1\n 49: bipush 8\n 51: ldc #24 // String dir e\n 53: aastore\n 54: aload_1\n 55: bipush 9\n 57: ldc #26 // String 29116 f\n 59: aastore\n 60: aload_1\n 61: bipush 10\n 63: ldc #28 // String 2557 g\n 65: aastore\n 66: aload_1\n 67: bipush 11\n 69: ldc #30 // String 62596 h.lst\n 71: aastore\n 72: aload_1\n 73: bipush 12\n 75: ldc #32 // String $ cd e\n 77: aastore\n 78: aload_1\n 79: bipush 13\n 81: ldc #12 // String $ ls\n 83: aastore\n 84: aload_1\n 85: bipush 14\n 87: ldc #34 // String 584 i\n 89: aastore\n 90: aload_1\n 91: bipush 15\n 93: ldc #36 // String $ cd ..\n 95: aastore\n 96: aload_1\n 97: bipush 16\n 99: ldc #36 // String $ cd ..\n 101: aastore\n 102: aload_1\n 103: bipush 17\n 105: ldc #38 // String $ cd d\n 107: aastore\n 108: aload_1\n 109: bipush 18\n 111: ldc #12 // String $ ls\n 113: aastore\n 114: aload_1\n 115: bipush 19\n 117: ldc #40 // String 4060174 j\n 119: aastore\n 120: aload_1\n 121: bipush 20\n 123: ldc #42 // String 8033020 d.log\n 125: aastore\n 126: aload_1\n 127: bipush 21\n 129: ldc #44 // String 5626152 d.ext\n 131: aastore\n 132: aload_1\n 133: bipush 22\n 135: ldc #46 // String 7214296 k\n 137: aastore\n 138: aload_1\n 139: invokestatic #52 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 142: astore_0\n 143: aload_0\n 144: invokestatic #56 // Method main$part1:(Ljava/util/List;)I\n 147: ldc #57 // int 95437\n 149: if_icmpne 156\n 152: iconst_1\n 153: goto 157\n 156: iconst_0\n 157: ifne 170\n 160: new #59 // class java/lang/IllegalStateException\n 163: dup\n 164: ldc #61 // String Check failed.\n 166: invokespecial #65 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 169: athrow\n 170: new #67 // class java/io/File\n 173: dup\n 174: ldc #69 // String ./src/resources/Day07.txt\n 176: invokespecial #70 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 179: aconst_null\n 180: iconst_1\n 181: aconst_null\n 182: invokestatic #76 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 185: astore_1\n 186: aload_1\n 187: invokestatic #56 // Method main$part1:(Ljava/util/List;)I\n 190: istore_2\n 191: getstatic #82 // Field java/lang/System.out:Ljava/io/PrintStream;\n 194: iload_2\n 195: invokevirtual #88 // Method java/io/PrintStream.println:(I)V\n 198: aload_1\n 199: invokestatic #91 // Method main$part2:(Ljava/util/List;)I\n 202: istore_2\n 203: getstatic #82 // Field java/lang/System.out:Ljava/io/PrintStream;\n 206: iload_2\n 207: invokevirtual #88 // Method java/io/PrintStream.println:(I)V\n 210: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #101 // Method main:()V\n 3: return\n\n private static final Directory main$buildFilesystem(java.util.List<java.lang.String>);\n Code:\n 0: new #107 // class Directory\n 3: dup\n 4: ldc #109 // String /\n 6: aconst_null\n 7: aconst_null\n 8: iconst_4\n 9: aconst_null\n 10: invokespecial #112 // Method Directory.\"<init>\":(Ljava/lang/String;LDirectory;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 13: astore_1\n 14: new #114 // class kotlin/jvm/internal/Ref$ObjectRef\n 17: dup\n 18: invokespecial #116 // Method kotlin/jvm/internal/Ref$ObjectRef.\"<init>\":()V\n 21: astore_2\n 22: aload_2\n 23: aload_1\n 24: putfield #120 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 27: aload_0\n 28: checkcast #122 // class java/lang/Iterable\n 31: astore_3\n 32: iconst_0\n 33: istore 4\n 35: iconst_0\n 36: istore 5\n 38: aload_3\n 39: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 6\n 46: aload 6\n 48: invokeinterface #132, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 732\n 56: aload 6\n 58: invokeinterface #136, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 7\n 65: iload 5\n 67: iinc 5, 1\n 70: istore 8\n 72: iload 8\n 74: ifge 80\n 77: invokestatic #139 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 80: iload 8\n 82: aload 7\n 84: checkcast #8 // class java/lang/String\n 87: astore 9\n 89: istore 10\n 91: iconst_0\n 92: istore 11\n 94: aload 9\n 96: checkcast #141 // class java/lang/CharSequence\n 99: iconst_1\n 100: anewarray #8 // class java/lang/String\n 103: astore 12\n 105: aload 12\n 107: iconst_0\n 108: ldc #143 // String\n 110: aastore\n 111: aload 12\n 113: iconst_0\n 114: iconst_0\n 115: bipush 6\n 117: aconst_null\n 118: invokestatic #149 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 121: astore 13\n 123: nop\n 124: aload 13\n 126: iconst_1\n 127: invokeinterface #153, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 132: ldc #155 // String cd\n 134: invokestatic #161 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 137: ifeq 379\n 140: aload_2\n 141: aload 13\n 143: iconst_2\n 144: invokeinterface #153, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 149: ldc #109 // String /\n 151: invokestatic #161 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 154: ifeq 161\n 157: aload_1\n 158: goto 373\n 161: aload 13\n 163: iconst_2\n 164: invokeinterface #153, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 169: ldc #163 // String ..\n 171: invokestatic #161 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 174: ifeq 202\n 177: aload_2\n 178: getfield #120 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 181: checkcast #107 // class Directory\n 184: invokevirtual #167 // Method Directory.getParent:()LDirectory;\n 187: dup\n 188: ifnonnull 373\n 191: pop\n 192: aload_2\n 193: getfield #120 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 196: checkcast #107 // class Directory\n 199: goto 373\n 202: aload_2\n 203: getfield #120 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 206: checkcast #107 // class Directory\n 209: invokevirtual #171 // Method Directory.getContents:()Ljava/util/List;\n 212: checkcast #122 // class java/lang/Iterable\n 215: astore 14\n 217: astore 15\n 219: iconst_0\n 220: istore 16\n 222: aload 14\n 224: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 229: astore 17\n 231: aload 17\n 233: invokeinterface #132, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 238: ifeq 284\n 241: aload 17\n 243: invokeinterface #136, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 248: astore 18\n 250: aload 18\n 252: checkcast #173 // class FsNode\n 255: astore 19\n 257: iconst_0\n 258: istore 20\n 260: aload 19\n 262: invokevirtual #177 // Method FsNode.getName:()Ljava/lang/String;\n 265: aload 13\n 267: iconst_2\n 268: invokeinterface #153, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 273: invokestatic #161 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 276: ifeq 231\n 279: aload 18\n 281: goto 285\n 284: aconst_null\n 285: aload 15\n 287: swap\n 288: astore 21\n 290: aload 21\n 292: instanceof #107 // class Directory\n 295: ifeq 306\n 298: aload 21\n 300: checkcast #107 // class Directory\n 303: goto 307\n 306: aconst_null\n 307: dup\n 308: ifnonnull 373\n 311: pop\n 312: new #107 // class Directory\n 315: dup\n 316: aload 13\n 318: iconst_2\n 319: invokeinterface #153, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 324: checkcast #8 // class java/lang/String\n 327: aload_2\n 328: getfield #120 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 331: checkcast #107 // class Directory\n 334: aconst_null\n 335: iconst_4\n 336: aconst_null\n 337: invokespecial #112 // Method Directory.\"<init>\":(Ljava/lang/String;LDirectory;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 340: astore 21\n 342: aload 21\n 344: astore 14\n 346: astore 15\n 348: iconst_0\n 349: istore 16\n 351: aload_2\n 352: getfield #120 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 355: checkcast #107 // class Directory\n 358: invokevirtual #171 // Method Directory.getContents:()Ljava/util/List;\n 361: aload 14\n 363: invokeinterface #181, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 368: pop\n 369: aload 15\n 371: aload 21\n 373: putfield #120 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 376: goto 727\n 379: aload 13\n 381: iconst_0\n 382: invokeinterface #153, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 387: ldc #183 // String dir\n 389: invokestatic #161 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 392: ifeq 534\n 395: aload_2\n 396: getfield #120 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 399: checkcast #107 // class Directory\n 402: invokevirtual #171 // Method Directory.getContents:()Ljava/util/List;\n 405: checkcast #122 // class java/lang/Iterable\n 408: astore 21\n 410: iconst_0\n 411: istore 14\n 413: aload 21\n 415: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 420: astore 16\n 422: aload 16\n 424: invokeinterface #132, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 429: ifeq 475\n 432: aload 16\n 434: invokeinterface #136, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 439: astore 17\n 441: aload 17\n 443: checkcast #173 // class FsNode\n 446: astore 18\n 448: iconst_0\n 449: istore 19\n 451: aload 18\n 453: invokevirtual #177 // Method FsNode.getName:()Ljava/lang/String;\n 456: aload 13\n 458: iconst_1\n 459: invokeinterface #153, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 464: invokestatic #161 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 467: ifeq 422\n 470: aload 17\n 472: goto 476\n 475: aconst_null\n 476: checkcast #173 // class FsNode\n 479: dup\n 480: ifnonnull 530\n 483: pop\n 484: aload_2\n 485: getfield #120 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 488: checkcast #107 // class Directory\n 491: invokevirtual #171 // Method Directory.getContents:()Ljava/util/List;\n 494: new #107 // class Directory\n 497: dup\n 498: aload 13\n 500: iconst_1\n 501: invokeinterface #153, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 506: checkcast #8 // class java/lang/String\n 509: aload_2\n 510: getfield #120 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 513: checkcast #107 // class Directory\n 516: aconst_null\n 517: iconst_4\n 518: aconst_null\n 519: invokespecial #112 // Method Directory.\"<init>\":(Ljava/lang/String;LDirectory;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 522: invokeinterface #181, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 527: invokestatic #189 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 530: pop\n 531: goto 727\n 534: aload 13\n 536: iconst_1\n 537: invokeinterface #153, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 542: ldc #191 // String ls\n 544: invokestatic #161 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 547: ifne 727\n 550: aload 13\n 552: iconst_0\n 553: invokeinterface #153, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 558: checkcast #141 // class java/lang/CharSequence\n 561: astore 12\n 563: new #193 // class kotlin/text/Regex\n 566: dup\n 567: ldc #195 // String \\\\d+\n 569: invokespecial #196 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 572: aload 12\n 574: invokevirtual #200 // Method kotlin/text/Regex.matches:(Ljava/lang/CharSequence;)Z\n 577: ifeq 727\n 580: aload_2\n 581: getfield #120 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 584: checkcast #107 // class Directory\n 587: invokevirtual #171 // Method Directory.getContents:()Ljava/util/List;\n 590: checkcast #122 // class java/lang/Iterable\n 593: astore 21\n 595: iconst_0\n 596: istore 14\n 598: aload 21\n 600: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 605: astore 16\n 607: aload 16\n 609: invokeinterface #132, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 614: ifeq 660\n 617: aload 16\n 619: invokeinterface #136, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 624: astore 17\n 626: aload 17\n 628: checkcast #173 // class FsNode\n 631: astore 18\n 633: iconst_0\n 634: istore 19\n 636: aload 18\n 638: invokevirtual #177 // Method FsNode.getName:()Ljava/lang/String;\n 641: aload 13\n 643: iconst_1\n 644: invokeinterface #153, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 649: invokestatic #161 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 652: ifeq 607\n 655: aload 17\n 657: goto 661\n 660: aconst_null\n 661: checkcast #173 // class FsNode\n 664: dup\n 665: ifnonnull 726\n 668: pop\n 669: aload_2\n 670: getfield #120 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 673: checkcast #107 // class Directory\n 676: invokevirtual #171 // Method Directory.getContents:()Ljava/util/List;\n 679: new #202 // class Data\n 682: dup\n 683: aload 13\n 685: iconst_1\n 686: invokeinterface #153, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 691: checkcast #8 // class java/lang/String\n 694: aload 13\n 696: iconst_0\n 697: invokeinterface #153, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 702: checkcast #8 // class java/lang/String\n 705: invokestatic #208 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 708: aload_2\n 709: getfield #120 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 712: checkcast #107 // class Directory\n 715: invokespecial #211 // Method Data.\"<init>\":(Ljava/lang/String;ILDirectory;)V\n 718: invokeinterface #181, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 723: invokestatic #189 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 726: pop\n 727: nop\n 728: nop\n 729: goto 46\n 732: nop\n 733: aload_1\n 734: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #239 // Method main$buildFilesystem:(Ljava/util/List;)LDirectory;\n 4: astore_1\n 5: aload_1\n 6: invokevirtual #242 // Method Directory.listAll:()Ljava/util/List;\n 9: checkcast #122 // class java/lang/Iterable\n 12: astore_3\n 13: iconst_0\n 14: istore 4\n 16: aload_3\n 17: astore 5\n 19: new #244 // class java/util/ArrayList\n 22: dup\n 23: invokespecial #245 // Method java/util/ArrayList.\"<init>\":()V\n 26: checkcast #247 // class java/util/Collection\n 29: astore 6\n 31: iconst_0\n 32: istore 7\n 34: aload 5\n 36: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 41: astore 8\n 43: aload 8\n 45: invokeinterface #132, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 50: ifeq 114\n 53: aload 8\n 55: invokeinterface #136, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 60: astore 9\n 62: aload 9\n 64: checkcast #173 // class FsNode\n 67: astore 10\n 69: iconst_0\n 70: istore 11\n 72: aload 10\n 74: instanceof #107 // class Directory\n 77: ifeq 97\n 80: aload 10\n 82: checkcast #107 // class Directory\n 85: invokevirtual #251 // Method Directory.getSize:()I\n 88: ldc #252 // int 100000\n 90: if_icmpgt 97\n 93: iconst_1\n 94: goto 98\n 97: iconst_0\n 98: ifeq 43\n 101: aload 6\n 103: aload 9\n 105: invokeinterface #253, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 110: pop\n 111: goto 43\n 114: aload 6\n 116: checkcast #96 // class java/util/List\n 119: nop\n 120: astore_2\n 121: aload_2\n 122: checkcast #122 // class java/lang/Iterable\n 125: astore_3\n 126: iconst_0\n 127: istore 4\n 129: aload_3\n 130: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 135: astore 5\n 137: aload 5\n 139: invokeinterface #132, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 144: ifeq 187\n 147: aload 5\n 149: invokeinterface #136, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 154: astore 6\n 156: iload 4\n 158: aload 6\n 160: checkcast #173 // class FsNode\n 163: astore 7\n 165: istore 12\n 167: iconst_0\n 168: istore 8\n 170: aload 7\n 172: invokevirtual #254 // Method FsNode.getSize:()I\n 175: istore 13\n 177: iload 12\n 179: iload 13\n 181: iadd\n 182: istore 4\n 184: goto 137\n 187: iload 4\n 189: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #239 // Method main$buildFilesystem:(Ljava/util/List;)LDirectory;\n 4: astore_1\n 5: aload_1\n 6: invokevirtual #242 // Method Directory.listAll:()Ljava/util/List;\n 9: checkcast #122 // class java/lang/Iterable\n 12: astore_3\n 13: iconst_0\n 14: istore 4\n 16: aload_3\n 17: astore 5\n 19: new #244 // class java/util/ArrayList\n 22: dup\n 23: invokespecial #245 // Method java/util/ArrayList.\"<init>\":()V\n 26: checkcast #247 // class java/util/Collection\n 29: astore 6\n 31: iconst_0\n 32: istore 7\n 34: aload 5\n 36: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 41: astore 8\n 43: aload 8\n 45: invokeinterface #132, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 50: ifeq 83\n 53: aload 8\n 55: invokeinterface #136, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 60: astore 9\n 62: aload 9\n 64: instanceof #107 // class Directory\n 67: ifeq 43\n 70: aload 6\n 72: aload 9\n 74: invokeinterface #253, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 79: pop\n 80: goto 43\n 83: aload 6\n 85: checkcast #96 // class java/util/List\n 88: nop\n 89: astore_2\n 90: aload_1\n 91: invokevirtual #251 // Method Directory.getSize:()I\n 94: i2d\n 95: ldc2_w #266 // double 4.0E7d\n 98: dsub\n 99: dstore_3\n 100: aload_2\n 101: checkcast #122 // class java/lang/Iterable\n 104: astore 5\n 106: iconst_0\n 107: istore 6\n 109: aload 5\n 111: astore 7\n 113: new #244 // class java/util/ArrayList\n 116: dup\n 117: invokespecial #245 // Method java/util/ArrayList.\"<init>\":()V\n 120: checkcast #247 // class java/util/Collection\n 123: astore 8\n 125: iconst_0\n 126: istore 9\n 128: aload 7\n 130: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 135: astore 10\n 137: aload 10\n 139: invokeinterface #132, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 144: ifeq 198\n 147: aload 10\n 149: invokeinterface #136, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 154: astore 11\n 156: aload 11\n 158: checkcast #107 // class Directory\n 161: astore 12\n 163: iconst_0\n 164: istore 13\n 166: aload 12\n 168: invokevirtual #251 // Method Directory.getSize:()I\n 171: i2d\n 172: dload_3\n 173: dcmpl\n 174: iflt 181\n 177: iconst_1\n 178: goto 182\n 181: iconst_0\n 182: ifeq 137\n 185: aload 8\n 187: aload 11\n 189: invokeinterface #253, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 194: pop\n 195: goto 137\n 198: aload 8\n 200: checkcast #96 // class java/util/List\n 203: nop\n 204: checkcast #122 // class java/lang/Iterable\n 207: astore 5\n 209: nop\n 210: iconst_0\n 211: istore 6\n 213: aload 5\n 215: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 220: astore 7\n 222: aload 7\n 224: invokeinterface #132, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 229: ifne 240\n 232: new #269 // class java/util/NoSuchElementException\n 235: dup\n 236: invokespecial #270 // Method java/util/NoSuchElementException.\"<init>\":()V\n 239: athrow\n 240: aload 7\n 242: invokeinterface #136, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 247: astore 8\n 249: aload 7\n 251: invokeinterface #132, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 256: ifne 264\n 259: aload 8\n 261: goto 334\n 264: aload 8\n 266: checkcast #107 // class Directory\n 269: astore 9\n 271: iconst_0\n 272: istore 10\n 274: aload 9\n 276: invokevirtual #251 // Method Directory.getSize:()I\n 279: istore 9\n 281: aload 7\n 283: invokeinterface #136, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 288: astore 10\n 290: aload 10\n 292: checkcast #107 // class Directory\n 295: astore 11\n 297: iconst_0\n 298: istore 12\n 300: aload 11\n 302: invokevirtual #251 // Method Directory.getSize:()I\n 305: istore 11\n 307: iload 9\n 309: iload 11\n 311: if_icmple 322\n 314: aload 10\n 316: astore 8\n 318: iload 11\n 320: istore 9\n 322: aload 7\n 324: invokeinterface #132, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 329: ifne 281\n 332: aload 8\n 334: checkcast #107 // class Directory\n 337: invokevirtual #251 // Method Directory.getSize:()I\n 340: ireturn\n}\n",
"javap_err": ""
}
] |
dcbertelsen__advent-of-code-2022-kotlin__9d22341/src/Day03.kt
|
import java.io.File
fun main() {
fun part1(input: List<String>): Int {
return input.map { sack -> sack.bisect() }
.map { parts -> parts.first.intersect(parts.second).first() }
.sumOf { it.toScore() }
}
fun part2(input: List<String>): Int {
return input.chunked(3)
.map { sacks ->
sacks[0].intersect(sacks[1]).toString().intersect(sacks[2]).firstOrNull()
}
.sumOf { it?.toScore() ?: 0 }
}
val testInput = listOf<String>(
"vJrwpWtwJgWrhcsFMMfFFhFp",
"jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL",
"PmmdzqPrVvPwwTWBwg",
"wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn",
"ttgJtRGJQctTZtZT",
"CrZsJsPPZsGzwwsLwLmpwMDw"
)
// test if implementation meets criteria from the description, like:
println(part1(testInput))
check(part1(testInput) == 157)
check(part2(testInput) == 70)
val input = File("./src/resources/Day03a.txt").readLines()
println(part1(input))
println(part2(input))
}
fun Char.toScore() : Int =
(if (this.isLowerCase()) this - 'a' else this - 'A' + 26) + 1
fun CharSequence.intersect(list2: CharSequence) : List<Char> {
return this.filter { list2.contains(it) }.toList()
}
fun String.bisect() : Pair<String, String> =
Pair(this.substring(0, this.length/2), this.substring(this.length/2, this.length))
|
[
{
"class_path": "dcbertelsen__advent-of-code-2022-kotlin__9d22341/Day03Kt.class",
"javap": "Compiled from \"Day03.kt\"\npublic final class Day03Kt {\n public static final void main();\n Code:\n 0: bipush 6\n 2: anewarray #8 // class java/lang/String\n 5: astore_1\n 6: aload_1\n 7: iconst_0\n 8: ldc #10 // String vJrwpWtwJgWrhcsFMMfFFhFp\n 10: aastore\n 11: aload_1\n 12: iconst_1\n 13: ldc #12 // String jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL\n 15: aastore\n 16: aload_1\n 17: iconst_2\n 18: ldc #14 // String PmmdzqPrVvPwwTWBwg\n 20: aastore\n 21: aload_1\n 22: iconst_3\n 23: ldc #16 // String wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn\n 25: aastore\n 26: aload_1\n 27: iconst_4\n 28: ldc #18 // String ttgJtRGJQctTZtZT\n 30: aastore\n 31: aload_1\n 32: iconst_5\n 33: ldc #20 // String CrZsJsPPZsGzwwsLwLmpwMDw\n 35: aastore\n 36: aload_1\n 37: invokestatic #26 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 40: astore_0\n 41: aload_0\n 42: invokestatic #30 // Method main$part1:(Ljava/util/List;)I\n 45: istore_1\n 46: getstatic #36 // Field java/lang/System.out:Ljava/io/PrintStream;\n 49: iload_1\n 50: invokevirtual #42 // Method java/io/PrintStream.println:(I)V\n 53: aload_0\n 54: invokestatic #30 // Method main$part1:(Ljava/util/List;)I\n 57: sipush 157\n 60: if_icmpne 67\n 63: iconst_1\n 64: goto 68\n 67: iconst_0\n 68: ifne 81\n 71: new #44 // class java/lang/IllegalStateException\n 74: dup\n 75: ldc #46 // String Check failed.\n 77: invokespecial #50 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 80: athrow\n 81: aload_0\n 82: invokestatic #53 // Method main$part2:(Ljava/util/List;)I\n 85: bipush 70\n 87: if_icmpne 94\n 90: iconst_1\n 91: goto 95\n 94: iconst_0\n 95: ifne 108\n 98: new #44 // class java/lang/IllegalStateException\n 101: dup\n 102: ldc #46 // String Check failed.\n 104: invokespecial #50 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 107: athrow\n 108: new #55 // class java/io/File\n 111: dup\n 112: ldc #57 // String ./src/resources/Day03a.txt\n 114: invokespecial #58 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 117: aconst_null\n 118: iconst_1\n 119: aconst_null\n 120: invokestatic #64 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 123: astore_1\n 124: aload_1\n 125: invokestatic #30 // Method main$part1:(Ljava/util/List;)I\n 128: istore_2\n 129: getstatic #36 // Field java/lang/System.out:Ljava/io/PrintStream;\n 132: iload_2\n 133: invokevirtual #42 // Method java/io/PrintStream.println:(I)V\n 136: aload_1\n 137: invokestatic #53 // Method main$part2:(Ljava/util/List;)I\n 140: istore_2\n 141: getstatic #36 // Field java/lang/System.out:Ljava/io/PrintStream;\n 144: iload_2\n 145: invokevirtual #42 // Method java/io/PrintStream.println:(I)V\n 148: return\n\n public static final int toScore(char);\n Code:\n 0: iload_0\n 1: invokestatic #77 // Method java/lang/Character.isLowerCase:(C)Z\n 4: ifeq 14\n 7: iload_0\n 8: bipush 97\n 10: isub\n 11: goto 21\n 14: iload_0\n 15: bipush 65\n 17: isub\n 18: bipush 26\n 20: iadd\n 21: iconst_1\n 22: iadd\n 23: ireturn\n\n public static final java.util.List<java.lang.Character> intersect(java.lang.CharSequence, java.lang.CharSequence);\n Code:\n 0: aload_0\n 1: ldc #85 // String <this>\n 3: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #93 // String list2\n 9: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: astore_2\n 14: iconst_0\n 15: istore_3\n 16: aload_2\n 17: astore 4\n 19: new #95 // class java/lang/StringBuilder\n 22: dup\n 23: invokespecial #97 // Method java/lang/StringBuilder.\"<init>\":()V\n 26: checkcast #99 // class java/lang/Appendable\n 29: astore 5\n 31: iconst_0\n 32: istore 6\n 34: iconst_0\n 35: istore 7\n 37: aload 4\n 39: invokeinterface #105, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 44: istore 8\n 46: iload 7\n 48: iload 8\n 50: if_icmpge 99\n 53: aload 4\n 55: iload 7\n 57: invokeinterface #109, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 62: istore 9\n 64: iload 9\n 66: istore 10\n 68: iconst_0\n 69: istore 11\n 71: aload_1\n 72: iload 10\n 74: iconst_0\n 75: iconst_2\n 76: aconst_null\n 77: invokestatic #115 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;CZILjava/lang/Object;)Z\n 80: ifeq 93\n 83: aload 5\n 85: iload 9\n 87: invokeinterface #119, 2 // InterfaceMethod java/lang/Appendable.append:(C)Ljava/lang/Appendable;\n 92: pop\n 93: iinc 7, 1\n 96: goto 46\n 99: aload 5\n 101: checkcast #101 // class java/lang/CharSequence\n 104: nop\n 105: invokestatic #123 // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;\n 108: areturn\n\n public static final kotlin.Pair<java.lang.String, java.lang.String> bisect(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #85 // String <this>\n 3: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #141 // class kotlin/Pair\n 9: dup\n 10: aload_0\n 11: iconst_0\n 12: aload_0\n 13: invokevirtual #142 // Method java/lang/String.length:()I\n 16: iconst_2\n 17: idiv\n 18: invokevirtual #146 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 21: dup\n 22: ldc #148 // String substring(...)\n 24: invokestatic #151 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 27: aload_0\n 28: aload_0\n 29: invokevirtual #142 // Method java/lang/String.length:()I\n 32: iconst_2\n 33: idiv\n 34: aload_0\n 35: invokevirtual #142 // Method java/lang/String.length:()I\n 38: invokevirtual #146 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 41: dup\n 42: ldc #148 // String substring(...)\n 44: invokestatic #151 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 47: invokespecial #154 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 50: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #159 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #164 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: astore_3\n 9: new #166 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #170 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #172 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #174 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #178, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #184, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 88\n 48: aload 6\n 50: invokeinterface #188, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #8 // class java/lang/String\n 64: astore 8\n 66: astore 10\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: invokestatic #190 // Method bisect:(Ljava/lang/String;)Lkotlin/Pair;\n 76: aload 10\n 78: swap\n 79: invokeinterface #194, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 84: pop\n 85: goto 38\n 88: aload 4\n 90: checkcast #69 // class java/util/List\n 93: nop\n 94: checkcast #164 // class java/lang/Iterable\n 97: astore_1\n 98: nop\n 99: iconst_0\n 100: istore_2\n 101: aload_1\n 102: astore_3\n 103: new #166 // class java/util/ArrayList\n 106: dup\n 107: aload_1\n 108: bipush 10\n 110: invokestatic #170 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 113: invokespecial #172 // Method java/util/ArrayList.\"<init>\":(I)V\n 116: checkcast #174 // class java/util/Collection\n 119: astore 4\n 121: iconst_0\n 122: istore 5\n 124: aload_3\n 125: invokeinterface #178, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 130: astore 6\n 132: aload 6\n 134: invokeinterface #184, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 139: ifeq 208\n 142: aload 6\n 144: invokeinterface #188, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 149: astore 7\n 151: aload 4\n 153: aload 7\n 155: checkcast #141 // class kotlin/Pair\n 158: astore 8\n 160: astore 10\n 162: iconst_0\n 163: istore 9\n 165: aload 8\n 167: invokevirtual #197 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 170: checkcast #101 // class java/lang/CharSequence\n 173: aload 8\n 175: invokevirtual #200 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 178: checkcast #101 // class java/lang/CharSequence\n 181: invokestatic #202 // Method intersect:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/util/List;\n 184: invokestatic #206 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 187: checkcast #73 // class java/lang/Character\n 190: invokevirtual #210 // Method java/lang/Character.charValue:()C\n 193: invokestatic #214 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 196: aload 10\n 198: swap\n 199: invokeinterface #194, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 204: pop\n 205: goto 132\n 208: aload 4\n 210: checkcast #69 // class java/util/List\n 213: nop\n 214: checkcast #164 // class java/lang/Iterable\n 217: astore_1\n 218: iconst_0\n 219: istore_2\n 220: aload_1\n 221: invokeinterface #178, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 226: astore_3\n 227: aload_3\n 228: invokeinterface #184, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 233: ifeq 276\n 236: aload_3\n 237: invokeinterface #188, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 242: astore 4\n 244: iload_2\n 245: aload 4\n 247: checkcast #73 // class java/lang/Character\n 250: invokevirtual #210 // Method java/lang/Character.charValue:()C\n 253: istore 5\n 255: istore 10\n 257: iconst_0\n 258: istore 6\n 260: iload 5\n 262: invokestatic #216 // Method toScore:(C)I\n 265: istore 11\n 267: iload 10\n 269: iload 11\n 271: iadd\n 272: istore_2\n 273: goto 227\n 276: iload_2\n 277: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #164 // class java/lang/Iterable\n 4: iconst_3\n 5: invokestatic #234 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;\n 8: checkcast #164 // class java/lang/Iterable\n 11: astore_1\n 12: nop\n 13: iconst_0\n 14: istore_2\n 15: aload_1\n 16: astore_3\n 17: new #166 // class java/util/ArrayList\n 20: dup\n 21: aload_1\n 22: bipush 10\n 24: invokestatic #170 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 27: invokespecial #172 // Method java/util/ArrayList.\"<init>\":(I)V\n 30: checkcast #174 // class java/util/Collection\n 33: astore 4\n 35: iconst_0\n 36: istore 5\n 38: aload_3\n 39: invokeinterface #178, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 6\n 46: aload 6\n 48: invokeinterface #184, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 142\n 56: aload 6\n 58: invokeinterface #188, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 7\n 65: aload 4\n 67: aload 7\n 69: checkcast #69 // class java/util/List\n 72: astore 8\n 74: astore 10\n 76: iconst_0\n 77: istore 9\n 79: aload 8\n 81: iconst_0\n 82: invokeinterface #238, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 87: checkcast #101 // class java/lang/CharSequence\n 90: aload 8\n 92: iconst_1\n 93: invokeinterface #238, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 98: checkcast #101 // class java/lang/CharSequence\n 101: invokestatic #202 // Method intersect:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/util/List;\n 104: invokevirtual #242 // Method java/lang/Object.toString:()Ljava/lang/String;\n 107: checkcast #101 // class java/lang/CharSequence\n 110: aload 8\n 112: iconst_2\n 113: invokeinterface #238, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 118: checkcast #101 // class java/lang/CharSequence\n 121: invokestatic #202 // Method intersect:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/util/List;\n 124: invokestatic #245 // Method kotlin/collections/CollectionsKt.firstOrNull:(Ljava/util/List;)Ljava/lang/Object;\n 127: checkcast #73 // class java/lang/Character\n 130: aload 10\n 132: swap\n 133: invokeinterface #194, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 138: pop\n 139: goto 46\n 142: aload 4\n 144: checkcast #69 // class java/util/List\n 147: nop\n 148: checkcast #164 // class java/lang/Iterable\n 151: astore_1\n 152: iconst_0\n 153: istore_2\n 154: aload_1\n 155: invokeinterface #178, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 160: astore_3\n 161: aload_3\n 162: invokeinterface #184, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 167: ifeq 219\n 170: aload_3\n 171: invokeinterface #188, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 176: astore 4\n 178: iload_2\n 179: aload 4\n 181: checkcast #73 // class java/lang/Character\n 184: astore 5\n 186: istore 10\n 188: iconst_0\n 189: istore 6\n 191: aload 5\n 193: dup\n 194: ifnull 206\n 197: invokevirtual #210 // Method java/lang/Character.charValue:()C\n 200: invokestatic #216 // Method toScore:(C)I\n 203: goto 208\n 206: pop\n 207: iconst_0\n 208: istore 11\n 210: iload 10\n 212: iload 11\n 214: iadd\n 215: istore_2\n 216: goto 161\n 219: iload_2\n 220: ireturn\n}\n",
"javap_err": ""
}
] |
dcbertelsen__advent-of-code-2022-kotlin__9d22341/src/Day02.kt
|
import java.io.File
fun main() {
fun part1(input: List<String>): Int {
return input.sumOf { getScore(it) }
}
fun part2(input: List<String>): Int {
return input.sumOf { getScore(getGame(it)) }
}
val testInput = listOf(
"A Y",
"B X",
"C Z"
)
// test if implementation meets criteria from the description, like:
check(part1(testInput) == 15)
check(part2(testInput) == 12)
val input = File("./src/resources/Day02a.txt").readLines()
println(part1(input))
println(part2(input))
}
fun getScore(game: String) : Int =
game[2] - 'W' +
when {
game[0] == (game[2] - 23) -> 3
wins.contains(game) -> 6
else -> 0
}
fun getGame(code: String) : String =
when (code[2]) {
'Y' -> ties
'X' -> losses
'Z' -> wins
else -> listOf()
}.first { code[0] == it[0] }
val wins = listOf("A Y", "B Z", "C X")
val losses = listOf("A Z", "B X", "C Y")
val ties = listOf("A X", "B Y", "C Z")
|
[
{
"class_path": "dcbertelsen__advent-of-code-2022-kotlin__9d22341/Day02Kt.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class Day02Kt {\n private static final java.util.List<java.lang.String> wins;\n\n private static final java.util.List<java.lang.String> losses;\n\n private static final java.util.List<java.lang.String> ties;\n\n public static final void main();\n Code:\n 0: iconst_3\n 1: anewarray #8 // class java/lang/String\n 4: astore_1\n 5: aload_1\n 6: iconst_0\n 7: ldc #10 // String A Y\n 9: aastore\n 10: aload_1\n 11: iconst_1\n 12: ldc #12 // String B X\n 14: aastore\n 15: aload_1\n 16: iconst_2\n 17: ldc #14 // String C Z\n 19: aastore\n 20: aload_1\n 21: invokestatic #20 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 24: astore_0\n 25: aload_0\n 26: invokestatic #24 // Method main$part1:(Ljava/util/List;)I\n 29: bipush 15\n 31: if_icmpne 38\n 34: iconst_1\n 35: goto 39\n 38: iconst_0\n 39: ifne 52\n 42: new #26 // class java/lang/IllegalStateException\n 45: dup\n 46: ldc #28 // String Check failed.\n 48: invokespecial #32 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 51: athrow\n 52: aload_0\n 53: invokestatic #35 // Method main$part2:(Ljava/util/List;)I\n 56: bipush 12\n 58: if_icmpne 65\n 61: iconst_1\n 62: goto 66\n 65: iconst_0\n 66: ifne 79\n 69: new #26 // class java/lang/IllegalStateException\n 72: dup\n 73: ldc #28 // String Check failed.\n 75: invokespecial #32 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 78: athrow\n 79: new #37 // class java/io/File\n 82: dup\n 83: ldc #39 // String ./src/resources/Day02a.txt\n 85: invokespecial #40 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 88: aconst_null\n 89: iconst_1\n 90: aconst_null\n 91: invokestatic #46 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 94: astore_1\n 95: aload_1\n 96: invokestatic #24 // Method main$part1:(Ljava/util/List;)I\n 99: istore_2\n 100: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 103: iload_2\n 104: invokevirtual #58 // Method java/io/PrintStream.println:(I)V\n 107: aload_1\n 108: invokestatic #35 // Method main$part2:(Ljava/util/List;)I\n 111: istore_2\n 112: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 115: iload_2\n 116: invokevirtual #58 // Method java/io/PrintStream.println:(I)V\n 119: return\n\n public static final int getScore(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #70 // String game\n 3: invokestatic #76 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iconst_2\n 8: invokevirtual #80 // Method java/lang/String.charAt:(I)C\n 11: bipush 87\n 13: isub\n 14: nop\n 15: aload_0\n 16: iconst_0\n 17: invokevirtual #80 // Method java/lang/String.charAt:(I)C\n 20: aload_0\n 21: iconst_2\n 22: invokevirtual #80 // Method java/lang/String.charAt:(I)C\n 25: bipush 23\n 27: isub\n 28: i2c\n 29: if_icmpne 36\n 32: iconst_3\n 33: goto 54\n 36: getstatic #83 // Field wins:Ljava/util/List;\n 39: aload_0\n 40: invokeinterface #87, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 45: ifeq 53\n 48: bipush 6\n 50: goto 54\n 53: iconst_0\n 54: iadd\n 55: ireturn\n\n public static final java.lang.String getGame(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #92 // String code\n 3: invokestatic #76 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iconst_2\n 8: invokevirtual #80 // Method java/lang/String.charAt:(I)C\n 11: tableswitch { // 88 to 90\n 88: 42\n 89: 36\n 90: 48\n default: 54\n }\n 36: getstatic #95 // Field ties:Ljava/util/List;\n 39: goto 57\n 42: getstatic #98 // Field losses:Ljava/util/List;\n 45: goto 57\n 48: getstatic #83 // Field wins:Ljava/util/List;\n 51: goto 57\n 54: invokestatic #102 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 57: checkcast #104 // class java/lang/Iterable\n 60: astore_1\n 61: nop\n 62: iconst_0\n 63: istore_2\n 64: aload_1\n 65: invokeinterface #108, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 70: astore_3\n 71: aload_3\n 72: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 77: ifeq 125\n 80: aload_3\n 81: invokeinterface #118, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 86: astore 4\n 88: aload 4\n 90: checkcast #8 // class java/lang/String\n 93: astore 5\n 95: iconst_0\n 96: istore 6\n 98: aload_0\n 99: iconst_0\n 100: invokevirtual #80 // Method java/lang/String.charAt:(I)C\n 103: aload 5\n 105: iconst_0\n 106: invokevirtual #80 // Method java/lang/String.charAt:(I)C\n 109: if_icmpne 116\n 112: iconst_1\n 113: goto 117\n 116: iconst_0\n 117: ifeq 71\n 120: aload 4\n 122: goto 135\n 125: new #120 // class java/util/NoSuchElementException\n 128: dup\n 129: ldc #122 // String Collection contains no element matching the predicate.\n 131: invokespecial #123 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 134: athrow\n 135: checkcast #8 // class java/lang/String\n 138: areturn\n\n public static final java.util.List<java.lang.String> getWins();\n Code:\n 0: getstatic #83 // Field wins:Ljava/util/List;\n 3: areturn\n\n public static final java.util.List<java.lang.String> getLosses();\n Code:\n 0: getstatic #98 // Field losses:Ljava/util/List;\n 3: areturn\n\n public static final java.util.List<java.lang.String> getTies();\n Code:\n 0: getstatic #95 // Field ties:Ljava/util/List;\n 3: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #138 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #104 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: invokeinterface #108, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore_3\n 14: aload_3\n 15: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 20: ifeq 60\n 23: aload_3\n 24: invokeinterface #118, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 29: astore 4\n 31: iload_2\n 32: aload 4\n 34: checkcast #8 // class java/lang/String\n 37: astore 5\n 39: istore 7\n 41: iconst_0\n 42: istore 6\n 44: aload 5\n 46: invokestatic #142 // Method getScore:(Ljava/lang/String;)I\n 49: istore 8\n 51: iload 7\n 53: iload 8\n 55: iadd\n 56: istore_2\n 57: goto 14\n 60: iload_2\n 61: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #104 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: invokeinterface #108, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore_3\n 14: aload_3\n 15: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 20: ifeq 63\n 23: aload_3\n 24: invokeinterface #118, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 29: astore 4\n 31: iload_2\n 32: aload 4\n 34: checkcast #8 // class java/lang/String\n 37: astore 5\n 39: istore 7\n 41: iconst_0\n 42: istore 6\n 44: aload 5\n 46: invokestatic #145 // Method getGame:(Ljava/lang/String;)Ljava/lang/String;\n 49: invokestatic #142 // Method getScore:(Ljava/lang/String;)I\n 52: istore 8\n 54: iload 7\n 56: iload 8\n 58: iadd\n 59: istore_2\n 60: goto 14\n 63: iload_2\n 64: ireturn\n\n static {};\n Code:\n 0: iconst_3\n 1: anewarray #8 // class java/lang/String\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: ldc #10 // String A Y\n 9: aastore\n 10: aload_0\n 11: iconst_1\n 12: ldc #149 // String B Z\n 14: aastore\n 15: aload_0\n 16: iconst_2\n 17: ldc #151 // String C X\n 19: aastore\n 20: aload_0\n 21: invokestatic #20 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 24: putstatic #83 // Field wins:Ljava/util/List;\n 27: iconst_3\n 28: anewarray #8 // class java/lang/String\n 31: astore_0\n 32: aload_0\n 33: iconst_0\n 34: ldc #153 // String A Z\n 36: aastore\n 37: aload_0\n 38: iconst_1\n 39: ldc #12 // String B X\n 41: aastore\n 42: aload_0\n 43: iconst_2\n 44: ldc #155 // String C Y\n 46: aastore\n 47: aload_0\n 48: invokestatic #20 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 51: putstatic #98 // Field losses:Ljava/util/List;\n 54: iconst_3\n 55: anewarray #8 // class java/lang/String\n 58: astore_0\n 59: aload_0\n 60: iconst_0\n 61: ldc #157 // String A X\n 63: aastore\n 64: aload_0\n 65: iconst_1\n 66: ldc #159 // String B Y\n 68: aastore\n 69: aload_0\n 70: iconst_2\n 71: ldc #14 // String C Z\n 73: aastore\n 74: aload_0\n 75: invokestatic #20 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 78: putstatic #95 // Field ties:Ljava/util/List;\n 81: return\n}\n",
"javap_err": ""
}
] |
dcbertelsen__advent-of-code-2022-kotlin__9d22341/src/Day12.kt
|
import java.io.File
import kotlin.math.min
fun main() {
val c0 = '`'
fun getNodes(input: List<String>): List<List<Node>> =
input.map { row ->
row.map { c ->
val height = when (c) { 'S' -> 0; 'E' -> 'z' - c0; else -> c - c0 }
Node(height, isStart = c == 'S', isEnd = c == 'E')
}
}
fun buildNeighbors(nodes: List<List<Node>>) {
nodes.forEachIndexed { y, row ->
row.forEachIndexed { x, node ->
listOf(x to y-1, x to y+1, x+1 to y, x-1 to y).forEach {
if (it.first in row.indices && it.second in nodes.indices && nodes[it.second][it.first].height <= node.height + 1)
node.neighbors.add(nodes[it.second][it.first])
}
}
}
}
fun dijkstra(data: MutableList<Node>) {
while(data.any()) {
val v = data.removeFirst()
v.neighbors.forEach {
if (v.distance + 1 < it.distance) {
it.distance = v.distance + 1
data.add(it)
}
data.sortBy { n -> n.distance }
}
}
}
fun part1(input: List<String>): Int {
val nodes = getNodes(input)
val start = nodes.flatten().first { it.isStart }
buildNeighbors(nodes)
start.distance = 0
val toProcess = mutableListOf(start)
dijkstra(toProcess)
// nodes.forEach {row ->
// row.forEach { print(if (it.distance == Int.MAX_VALUE) " . " else String.format("%3d", it.distance) + if (it.isEnd) "*" else " ")}
// println()
// }
// println()
return nodes.flatten().firstOrNull { it.isEnd }?.distance ?: 0
}
fun part2(input: List<String>): Int {
val nodes = getNodes(input)
val start = nodes.flatten().first { it.isStart }
val end = nodes.flatten().first { it.isEnd }
buildNeighbors(nodes)
start.distance = 0
val toProcess = mutableListOf(start)
dijkstra(toProcess)
val starts = nodes.flatten().filter { it.height == 'a' - c0 && it.distance < Int.MAX_VALUE }.sortedByDescending { it.distance }.toMutableList()
var shortest = Int.MAX_VALUE
starts.forEach { newStart ->
nodes.flatten().forEach { it.distance = Int.MAX_VALUE }
newStart.distance = 0
toProcess.add(newStart)
dijkstra(toProcess)
shortest = min(shortest, end.distance)
}
return shortest
}
val testInput = listOf(
"Sabqponm",
"abcryxxl",
"accszExk",
"acctuvwj",
"abdefghi"
)
// test if implementation meets criteria from the description, like:
check(part1(testInput) == 31)
check(part2(testInput) == 29)
val input = File("./src/resources/Day12.txt").readLines()
println(part1(input))
println(part2(input))
}
data class Node(
val height: Int,
var distance: Int = Int.MAX_VALUE,
val neighbors: MutableList<Node> = mutableListOf(),
val isStart: Boolean = false,
val isEnd: Boolean = false)
|
[
{
"class_path": "dcbertelsen__advent-of-code-2022-kotlin__9d22341/Day12Kt.class",
"javap": "Compiled from \"Day12.kt\"\npublic final class Day12Kt {\n public static final void main();\n Code:\n 0: bipush 96\n 2: istore_0\n 3: iconst_5\n 4: anewarray #8 // class java/lang/String\n 7: astore_2\n 8: aload_2\n 9: iconst_0\n 10: ldc #10 // String Sabqponm\n 12: aastore\n 13: aload_2\n 14: iconst_1\n 15: ldc #12 // String abcryxxl\n 17: aastore\n 18: aload_2\n 19: iconst_2\n 20: ldc #14 // String accszExk\n 22: aastore\n 23: aload_2\n 24: iconst_3\n 25: ldc #16 // String acctuvwj\n 27: aastore\n 28: aload_2\n 29: iconst_4\n 30: ldc #18 // String abdefghi\n 32: aastore\n 33: aload_2\n 34: invokestatic #24 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 37: astore_1\n 38: iload_0\n 39: aload_1\n 40: invokestatic #28 // Method main$part1:(CLjava/util/List;)I\n 43: bipush 31\n 45: if_icmpne 52\n 48: iconst_1\n 49: goto 53\n 52: iconst_0\n 53: ifne 66\n 56: new #30 // class java/lang/IllegalStateException\n 59: dup\n 60: ldc #32 // String Check failed.\n 62: invokespecial #36 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 65: athrow\n 66: iload_0\n 67: aload_1\n 68: invokestatic #39 // Method main$part2:(CLjava/util/List;)I\n 71: bipush 29\n 73: if_icmpne 80\n 76: iconst_1\n 77: goto 81\n 80: iconst_0\n 81: ifne 94\n 84: new #30 // class java/lang/IllegalStateException\n 87: dup\n 88: ldc #32 // String Check failed.\n 90: invokespecial #36 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 93: athrow\n 94: new #41 // class java/io/File\n 97: dup\n 98: ldc #43 // String ./src/resources/Day12.txt\n 100: invokespecial #44 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 103: aconst_null\n 104: iconst_1\n 105: aconst_null\n 106: invokestatic #50 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 109: astore_2\n 110: iload_0\n 111: aload_2\n 112: invokestatic #28 // Method main$part1:(CLjava/util/List;)I\n 115: istore_3\n 116: getstatic #56 // Field java/lang/System.out:Ljava/io/PrintStream;\n 119: iload_3\n 120: invokevirtual #62 // Method java/io/PrintStream.println:(I)V\n 123: iload_0\n 124: aload_2\n 125: invokestatic #39 // Method main$part2:(CLjava/util/List;)I\n 128: istore_3\n 129: getstatic #56 // Field java/lang/System.out:Ljava/io/PrintStream;\n 132: iload_3\n 133: invokevirtual #62 // Method java/io/PrintStream.println:(I)V\n 136: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #74 // Method main:()V\n 3: return\n\n private static final java.util.List<java.util.List<Node>> main$getNodes(char, java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #80 // 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 #82 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: bipush 10\n 17: invokestatic #86 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #88 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #90 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 4\n 33: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 7\n 40: aload 7\n 42: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 265\n 50: aload 7\n 52: invokeinterface #104, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 8\n 59: aload 5\n 61: aload 8\n 63: checkcast #8 // class java/lang/String\n 66: astore 9\n 68: astore 22\n 70: iconst_0\n 71: istore 10\n 73: aload 9\n 75: checkcast #106 // 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 #82 // class java/util/ArrayList\n 90: dup\n 91: aload 11\n 93: invokeinterface #110, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 98: invokespecial #88 // Method java/util/ArrayList.\"<init>\":(I)V\n 101: checkcast #90 // 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 #110, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 121: if_icmpge 246\n 124: aload 13\n 126: iload 16\n 128: invokeinterface #114, 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: lookupswitch { // 2\n 69: 180\n 83: 176\n default: 187\n }\n 176: iconst_0\n 177: goto 191\n 180: bipush 122\n 182: iload_0\n 183: isub\n 184: goto 191\n 187: iload 18\n 189: iload_0\n 190: isub\n 191: istore 21\n 193: new #116 // class Node\n 196: dup\n 197: iload 21\n 199: iconst_0\n 200: aconst_null\n 201: iload 18\n 203: bipush 83\n 205: if_icmpne 212\n 208: iconst_1\n 209: goto 213\n 212: iconst_0\n 213: iload 18\n 215: bipush 69\n 217: if_icmpne 224\n 220: iconst_1\n 221: goto 225\n 224: iconst_0\n 225: bipush 6\n 227: aconst_null\n 228: invokespecial #119 // Method Node.\"<init>\":(IILjava/util/List;ZZILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 231: aload 19\n 233: swap\n 234: invokeinterface #123, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 239: pop\n 240: iinc 16, 1\n 243: goto 112\n 246: aload 14\n 248: checkcast #69 // class java/util/List\n 251: nop\n 252: nop\n 253: aload 22\n 255: swap\n 256: invokeinterface #123, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 261: pop\n 262: goto 40\n 265: aload 5\n 267: checkcast #69 // class java/util/List\n 270: nop\n 271: areturn\n\n private static final void main$buildNeighbors(java.util.List<? extends java.util.List<Node>>);\n Code:\n 0: aload_0\n 1: checkcast #80 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: iconst_0\n 8: istore_3\n 9: aload_1\n 10: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 15: astore 4\n 17: aload 4\n 19: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 24: ifeq 482\n 27: aload 4\n 29: invokeinterface #104, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 34: astore 5\n 36: iload_3\n 37: iinc 3, 1\n 40: istore 6\n 42: iload 6\n 44: ifge 50\n 47: invokestatic #146 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 50: iload 6\n 52: aload 5\n 54: checkcast #69 // class java/util/List\n 57: astore 7\n 59: istore 8\n 61: iconst_0\n 62: istore 9\n 64: aload 7\n 66: checkcast #80 // class java/lang/Iterable\n 69: astore 10\n 71: iconst_0\n 72: istore 11\n 74: iconst_0\n 75: istore 12\n 77: aload 10\n 79: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 84: astore 13\n 86: aload 13\n 88: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 93: ifeq 476\n 96: aload 13\n 98: invokeinterface #104, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 103: astore 14\n 105: iload 12\n 107: iinc 12, 1\n 110: istore 15\n 112: iload 15\n 114: ifge 120\n 117: invokestatic #146 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 120: iload 15\n 122: aload 14\n 124: checkcast #116 // class Node\n 127: astore 16\n 129: istore 17\n 131: iconst_0\n 132: istore 18\n 134: iconst_4\n 135: anewarray #148 // class kotlin/Pair\n 138: astore 19\n 140: aload 19\n 142: iconst_0\n 143: iload 17\n 145: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 148: iload 8\n 150: iconst_1\n 151: isub\n 152: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 155: invokestatic #160 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 158: aastore\n 159: aload 19\n 161: iconst_1\n 162: iload 17\n 164: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 167: iload 8\n 169: iconst_1\n 170: iadd\n 171: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 174: invokestatic #160 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 177: aastore\n 178: aload 19\n 180: iconst_2\n 181: iload 17\n 183: iconst_1\n 184: iadd\n 185: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 188: iload 8\n 190: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 193: invokestatic #160 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 196: aastore\n 197: aload 19\n 199: iconst_3\n 200: iload 17\n 202: iconst_1\n 203: isub\n 204: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 207: iload 8\n 209: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 212: invokestatic #160 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 215: aastore\n 216: aload 19\n 218: invokestatic #24 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 221: checkcast #80 // class java/lang/Iterable\n 224: astore 19\n 226: iconst_0\n 227: istore 20\n 229: aload 19\n 231: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 236: astore 21\n 238: aload 21\n 240: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 245: ifeq 470\n 248: aload 21\n 250: invokeinterface #104, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 255: astore 22\n 257: aload 22\n 259: checkcast #148 // class kotlin/Pair\n 262: astore 23\n 264: iconst_0\n 265: istore 24\n 267: aload 7\n 269: checkcast #90 // class java/util/Collection\n 272: invokeinterface #163, 1 // InterfaceMethod java/util/Collection.size:()I\n 277: istore 25\n 279: aload 23\n 281: invokevirtual #166 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 284: checkcast #168 // class java/lang/Number\n 287: invokevirtual #171 // Method java/lang/Number.intValue:()I\n 290: istore 26\n 292: iconst_0\n 293: iload 26\n 295: if_icmpgt 313\n 298: iload 26\n 300: iload 25\n 302: if_icmpge 309\n 305: iconst_1\n 306: goto 314\n 309: iconst_0\n 310: goto 314\n 313: iconst_0\n 314: ifeq 465\n 317: aload_0\n 318: checkcast #90 // class java/util/Collection\n 321: invokeinterface #163, 1 // InterfaceMethod java/util/Collection.size:()I\n 326: istore 25\n 328: aload 23\n 330: invokevirtual #174 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 333: checkcast #168 // class java/lang/Number\n 336: invokevirtual #171 // Method java/lang/Number.intValue:()I\n 339: istore 26\n 341: iconst_0\n 342: iload 26\n 344: if_icmpgt 362\n 347: iload 26\n 349: iload 25\n 351: if_icmpge 358\n 354: iconst_1\n 355: goto 363\n 358: iconst_0\n 359: goto 363\n 362: iconst_0\n 363: ifeq 465\n 366: aload_0\n 367: aload 23\n 369: invokevirtual #174 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 372: checkcast #168 // class java/lang/Number\n 375: invokevirtual #171 // Method java/lang/Number.intValue:()I\n 378: invokeinterface #178, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 383: checkcast #69 // class java/util/List\n 386: aload 23\n 388: invokevirtual #166 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 391: checkcast #168 // class java/lang/Number\n 394: invokevirtual #171 // Method java/lang/Number.intValue:()I\n 397: invokeinterface #178, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 402: checkcast #116 // class Node\n 405: invokevirtual #181 // Method Node.getHeight:()I\n 408: aload 16\n 410: invokevirtual #181 // Method Node.getHeight:()I\n 413: iconst_1\n 414: iadd\n 415: if_icmpgt 465\n 418: aload 16\n 420: invokevirtual #185 // Method Node.getNeighbors:()Ljava/util/List;\n 423: aload_0\n 424: aload 23\n 426: invokevirtual #174 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 429: checkcast #168 // class java/lang/Number\n 432: invokevirtual #171 // Method java/lang/Number.intValue:()I\n 435: invokeinterface #178, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 440: checkcast #69 // class java/util/List\n 443: aload 23\n 445: invokevirtual #166 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 448: checkcast #168 // class java/lang/Number\n 451: invokevirtual #171 // Method java/lang/Number.intValue:()I\n 454: invokeinterface #178, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 459: invokeinterface #186, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 464: pop\n 465: nop\n 466: nop\n 467: goto 238\n 470: nop\n 471: nop\n 472: nop\n 473: goto 86\n 476: nop\n 477: nop\n 478: nop\n 479: goto 17\n 482: nop\n 483: return\n\n private static final void main$dijkstra(java.util.List<Node>);\n Code:\n 0: aload_0\n 1: checkcast #80 // class java/lang/Iterable\n 4: invokestatic #209 // Method kotlin/collections/CollectionsKt.any:(Ljava/lang/Iterable;)Z\n 7: ifeq 149\n 10: aload_0\n 11: invokeinterface #212, 1 // InterfaceMethod java/util/List.removeFirst:()Ljava/lang/Object;\n 16: dup\n 17: ldc #214 // String removeFirst(...)\n 19: invokestatic #220 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 22: checkcast #116 // class Node\n 25: astore_1\n 26: aload_1\n 27: invokevirtual #185 // Method Node.getNeighbors:()Ljava/util/List;\n 30: checkcast #80 // class java/lang/Iterable\n 33: astore_2\n 34: iconst_0\n 35: istore_3\n 36: aload_2\n 37: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 4\n 44: aload 4\n 46: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 145\n 54: aload 4\n 56: invokeinterface #104, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 5\n 63: aload 5\n 65: checkcast #116 // class Node\n 68: astore 6\n 70: iconst_0\n 71: istore 7\n 73: aload_1\n 74: invokevirtual #223 // Method Node.getDistance:()I\n 77: iconst_1\n 78: iadd\n 79: aload 6\n 81: invokevirtual #223 // Method Node.getDistance:()I\n 84: if_icmpge 107\n 87: aload 6\n 89: aload_1\n 90: invokevirtual #223 // Method Node.getDistance:()I\n 93: iconst_1\n 94: iadd\n 95: invokevirtual #226 // Method Node.setDistance:(I)V\n 98: aload_0\n 99: aload 6\n 101: invokeinterface #186, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 106: pop\n 107: aload_0\n 108: astore 8\n 110: iconst_0\n 111: istore 9\n 113: aload 8\n 115: invokeinterface #227, 1 // InterfaceMethod java/util/List.size:()I\n 120: iconst_1\n 121: if_icmple 139\n 124: aload 8\n 126: new #229 // class Day12Kt$main$dijkstra$lambda$6$$inlined$sortBy$1\n 129: dup\n 130: invokespecial #231 // Method Day12Kt$main$dijkstra$lambda$6$$inlined$sortBy$1.\"<init>\":()V\n 133: checkcast #233 // class java/util/Comparator\n 136: invokestatic #237 // Method kotlin/collections/CollectionsKt.sortWith:(Ljava/util/List;Ljava/util/Comparator;)V\n 139: nop\n 140: nop\n 141: nop\n 142: goto 44\n 145: nop\n 146: goto 0\n 149: return\n\n private static final int main$part1(char, java.util.List<java.lang.String>);\n Code:\n 0: iload_0\n 1: aload_1\n 2: invokestatic #245 // Method main$getNodes:(CLjava/util/List;)Ljava/util/List;\n 5: astore_2\n 6: aload_2\n 7: checkcast #80 // class java/lang/Iterable\n 10: invokestatic #249 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 13: checkcast #80 // class java/lang/Iterable\n 16: astore 4\n 18: iconst_0\n 19: istore 5\n 21: aload 4\n 23: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 28: astore 6\n 30: aload 6\n 32: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 37: ifeq 72\n 40: aload 6\n 42: invokeinterface #104, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 47: astore 7\n 49: aload 7\n 51: checkcast #116 // class Node\n 54: astore 8\n 56: iconst_0\n 57: istore 9\n 59: aload 8\n 61: invokevirtual #252 // Method Node.isStart:()Z\n 64: ifeq 30\n 67: aload 7\n 69: goto 83\n 72: new #254 // class java/util/NoSuchElementException\n 75: dup\n 76: ldc_w #256 // String Collection contains no element matching the predicate.\n 79: invokespecial #257 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 82: athrow\n 83: checkcast #116 // class Node\n 86: astore_3\n 87: aload_2\n 88: invokestatic #259 // Method main$buildNeighbors:(Ljava/util/List;)V\n 91: aload_3\n 92: iconst_0\n 93: invokevirtual #226 // Method Node.setDistance:(I)V\n 96: iconst_1\n 97: anewarray #116 // class Node\n 100: astore 5\n 102: aload 5\n 104: iconst_0\n 105: aload_3\n 106: aastore\n 107: aload 5\n 109: invokestatic #262 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 112: astore 4\n 114: aload 4\n 116: invokestatic #264 // Method main$dijkstra:(Ljava/util/List;)V\n 119: aload_2\n 120: checkcast #80 // class java/lang/Iterable\n 123: invokestatic #249 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 126: checkcast #80 // class java/lang/Iterable\n 129: astore 6\n 131: iconst_0\n 132: istore 7\n 134: aload 6\n 136: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 141: astore 8\n 143: aload 8\n 145: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 150: ifeq 185\n 153: aload 8\n 155: invokeinterface #104, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 160: astore 9\n 162: aload 9\n 164: checkcast #116 // class Node\n 167: astore 10\n 169: iconst_0\n 170: istore 11\n 172: aload 10\n 174: invokevirtual #267 // Method Node.isEnd:()Z\n 177: ifeq 143\n 180: aload 9\n 182: goto 186\n 185: aconst_null\n 186: checkcast #116 // class Node\n 189: dup\n 190: ifnull 199\n 193: invokevirtual #223 // Method Node.getDistance:()I\n 196: goto 201\n 199: pop\n 200: iconst_0\n 201: ireturn\n\n private static final int main$part2(char, java.util.List<java.lang.String>);\n Code:\n 0: iload_0\n 1: aload_1\n 2: invokestatic #245 // Method main$getNodes:(CLjava/util/List;)Ljava/util/List;\n 5: astore_2\n 6: aload_2\n 7: checkcast #80 // class java/lang/Iterable\n 10: invokestatic #249 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 13: checkcast #80 // class java/lang/Iterable\n 16: astore 4\n 18: iconst_0\n 19: istore 5\n 21: aload 4\n 23: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 28: astore 6\n 30: aload 6\n 32: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 37: ifeq 72\n 40: aload 6\n 42: invokeinterface #104, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 47: astore 7\n 49: aload 7\n 51: checkcast #116 // class Node\n 54: astore 8\n 56: iconst_0\n 57: istore 9\n 59: aload 8\n 61: invokevirtual #252 // Method Node.isStart:()Z\n 64: ifeq 30\n 67: aload 7\n 69: goto 83\n 72: new #254 // class java/util/NoSuchElementException\n 75: dup\n 76: ldc_w #256 // String Collection contains no element matching the predicate.\n 79: invokespecial #257 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 82: athrow\n 83: checkcast #116 // class Node\n 86: astore_3\n 87: aload_2\n 88: checkcast #80 // class java/lang/Iterable\n 91: invokestatic #249 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 94: checkcast #80 // class java/lang/Iterable\n 97: astore 5\n 99: iconst_0\n 100: istore 6\n 102: aload 5\n 104: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 109: astore 7\n 111: aload 7\n 113: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 118: ifeq 153\n 121: aload 7\n 123: invokeinterface #104, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 128: astore 8\n 130: aload 8\n 132: checkcast #116 // class Node\n 135: astore 9\n 137: iconst_0\n 138: istore 10\n 140: aload 9\n 142: invokevirtual #267 // Method Node.isEnd:()Z\n 145: ifeq 111\n 148: aload 8\n 150: goto 164\n 153: new #254 // class java/util/NoSuchElementException\n 156: dup\n 157: ldc_w #256 // String Collection contains no element matching the predicate.\n 160: invokespecial #257 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 163: athrow\n 164: checkcast #116 // class Node\n 167: astore 4\n 169: aload_2\n 170: invokestatic #259 // Method main$buildNeighbors:(Ljava/util/List;)V\n 173: aload_3\n 174: iconst_0\n 175: invokevirtual #226 // Method Node.setDistance:(I)V\n 178: iconst_1\n 179: anewarray #116 // class Node\n 182: astore 6\n 184: aload 6\n 186: iconst_0\n 187: aload_3\n 188: aastore\n 189: aload 6\n 191: invokestatic #262 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 194: astore 5\n 196: aload 5\n 198: invokestatic #264 // Method main$dijkstra:(Ljava/util/List;)V\n 201: aload_2\n 202: checkcast #80 // class java/lang/Iterable\n 205: invokestatic #249 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 208: checkcast #80 // class java/lang/Iterable\n 211: astore 7\n 213: iconst_0\n 214: istore 8\n 216: aload 7\n 218: astore 9\n 220: new #82 // class java/util/ArrayList\n 223: dup\n 224: invokespecial #278 // Method java/util/ArrayList.\"<init>\":()V\n 227: checkcast #90 // class java/util/Collection\n 230: astore 10\n 232: iconst_0\n 233: istore 11\n 235: aload 9\n 237: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 242: astore 12\n 244: aload 12\n 246: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 251: ifeq 317\n 254: aload 12\n 256: invokeinterface #104, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 261: astore 13\n 263: aload 13\n 265: checkcast #116 // class Node\n 268: astore 14\n 270: iconst_0\n 271: istore 15\n 273: aload 14\n 275: invokevirtual #181 // Method Node.getHeight:()I\n 278: bipush 97\n 280: iload_0\n 281: isub\n 282: if_icmpne 300\n 285: aload 14\n 287: invokevirtual #223 // Method Node.getDistance:()I\n 290: ldc_w #279 // int 2147483647\n 293: if_icmpge 300\n 296: iconst_1\n 297: goto 301\n 300: iconst_0\n 301: ifeq 244\n 304: aload 10\n 306: aload 13\n 308: invokeinterface #123, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 313: pop\n 314: goto 244\n 317: aload 10\n 319: checkcast #69 // class java/util/List\n 322: nop\n 323: checkcast #80 // class java/lang/Iterable\n 326: astore 7\n 328: nop\n 329: iconst_0\n 330: istore 8\n 332: aload 7\n 334: new #281 // class Day12Kt$main$part2$$inlined$sortedByDescending$1\n 337: dup\n 338: invokespecial #282 // Method Day12Kt$main$part2$$inlined$sortedByDescending$1.\"<init>\":()V\n 341: checkcast #233 // class java/util/Comparator\n 344: invokestatic #286 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 347: checkcast #90 // class java/util/Collection\n 350: invokestatic #290 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 353: astore 6\n 355: iconst_0\n 356: istore 7\n 358: ldc_w #279 // int 2147483647\n 361: istore 7\n 363: aload 6\n 365: checkcast #80 // class java/lang/Iterable\n 368: astore 8\n 370: iconst_0\n 371: istore 9\n 373: aload 8\n 375: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 380: astore 10\n 382: aload 10\n 384: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 389: ifeq 515\n 392: aload 10\n 394: invokeinterface #104, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 399: astore 11\n 401: aload 11\n 403: checkcast #116 // class Node\n 406: astore 12\n 408: iconst_0\n 409: istore 13\n 411: aload_2\n 412: checkcast #80 // class java/lang/Iterable\n 415: invokestatic #249 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 418: checkcast #80 // class java/lang/Iterable\n 421: astore 14\n 423: iconst_0\n 424: istore 15\n 426: aload 14\n 428: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 433: astore 16\n 435: aload 16\n 437: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 442: ifeq 476\n 445: aload 16\n 447: invokeinterface #104, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 452: astore 17\n 454: aload 17\n 456: checkcast #116 // class Node\n 459: astore 18\n 461: iconst_0\n 462: istore 19\n 464: aload 18\n 466: ldc_w #279 // int 2147483647\n 469: invokevirtual #226 // Method Node.setDistance:(I)V\n 472: nop\n 473: goto 435\n 476: nop\n 477: aload 12\n 479: iconst_0\n 480: invokevirtual #226 // Method Node.setDistance:(I)V\n 483: aload 5\n 485: aload 12\n 487: invokeinterface #186, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 492: pop\n 493: aload 5\n 495: invokestatic #264 // Method main$dijkstra:(Ljava/util/List;)V\n 498: iload 7\n 500: aload 4\n 502: invokevirtual #223 // Method Node.getDistance:()I\n 505: invokestatic #296 // Method java/lang/Math.min:(II)I\n 508: istore 7\n 510: nop\n 511: nop\n 512: goto 382\n 515: nop\n 516: iload 7\n 518: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dcbertelsen__advent-of-code-2022-kotlin__9d22341/Day12Kt$main$dijkstra$lambda$6$$inlined$sortBy$1.class",
"javap": "Compiled from \"Comparisons.kt\"\npublic final class Day12Kt$main$dijkstra$lambda$6$$inlined$sortBy$1<T> implements java.util.Comparator {\n public Day12Kt$main$dijkstra$lambda$6$$inlined$sortBy$1();\n Code:\n 0: aload_0\n 1: invokespecial #16 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int compare(T, T);\n Code:\n 0: aload_1\n 1: checkcast #23 // class Node\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method Node.getDistance:()I\n 12: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 15: checkcast #35 // class java/lang/Comparable\n 18: aload_2\n 19: checkcast #23 // class Node\n 22: astore_3\n 23: astore 5\n 25: iconst_0\n 26: istore 4\n 28: aload_3\n 29: invokevirtual #27 // Method Node.getDistance:()I\n 32: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 35: aload 5\n 37: swap\n 38: checkcast #35 // class java/lang/Comparable\n 41: invokestatic #41 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I\n 44: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dcbertelsen__advent-of-code-2022-kotlin__9d22341/Day12Kt$main$part2$$inlined$sortedByDescending$1.class",
"javap": "Compiled from \"Comparisons.kt\"\npublic final class Day12Kt$main$part2$$inlined$sortedByDescending$1<T> implements java.util.Comparator {\n public Day12Kt$main$part2$$inlined$sortedByDescending$1();\n Code:\n 0: aload_0\n 1: invokespecial #16 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int compare(T, T);\n Code:\n 0: aload_2\n 1: checkcast #23 // class Node\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method Node.getDistance:()I\n 12: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 15: checkcast #35 // class java/lang/Comparable\n 18: aload_1\n 19: checkcast #23 // class Node\n 22: astore_3\n 23: astore 5\n 25: iconst_0\n 26: istore 4\n 28: aload_3\n 29: invokevirtual #27 // Method Node.getDistance:()I\n 32: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 35: aload 5\n 37: swap\n 38: checkcast #35 // class java/lang/Comparable\n 41: invokestatic #41 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I\n 44: ireturn\n}\n",
"javap_err": ""
}
] |
dcbertelsen__advent-of-code-2022-kotlin__9d22341/src/Day11.kt
|
import java.io.File
import kotlin.collections.ArrayDeque
fun main() {
fun readMonkeys(input: List<String>) =
input.map { data ->
val lines = data.split("\n")
Monkey(
ArrayDeque(lines[1].split(": ")[1].split(", ").map { it -> it.toLong() }),
lines[2].split("=")[1].toFunction(),
lines[3].split(" ").last().toInt(),
lines[4].split(" ").last().toInt(),
lines[5].split(" ").last().toInt()
)
}
fun part1(input: List<String>): Int {
val monkeys = readMonkeys(input)
repeat(20) {
monkeys.forEach { monkey ->
while (monkey.hasItems()) {
val (newItem, target) = monkey.inspectNextPt1()
monkeys[target].catch(newItem)
}
}
}
return monkeys.sortedBy { it.inspectionCount }.takeLast(2).fold(1) { acc, m -> acc * m.inspectionCount}
}
fun part2(input: List<String>): Long {
val monkeys = readMonkeys(input)
val checkProduct = monkeys.fold(1) { acc, m -> acc * m.testDiv }
repeat(10000) {
monkeys.forEach { monkey ->
while (monkey.hasItems()) {
val (newItem, target) = monkey.inspectNextPt2()
monkeys[target].catch(newItem % checkProduct)
}
}
}
val topTwo = monkeys.map { it.inspectionCount }.sorted().takeLast(2)
return 1L * topTwo[0] * topTwo[1]
}
val testInput =
"""Monkey 0:
Starting items: 79, 98
Operation: new = old * 19
Test: divisible by 23
If true: throw to monkey 2
If false: throw to monkey 3
Monkey 1:
Starting items: 54, 65, 75, 74
Operation: new = old + 6
Test: divisible by 19
If true: throw to monkey 2
If false: throw to monkey 0
Monkey 2:
Starting items: 79, 60, 97
Operation: new = old * old
Test: divisible by 13
If true: throw to monkey 1
If false: throw to monkey 3
Monkey 3:
Starting items: 74
Operation: new = old + 3
Test: divisible by 17
If true: throw to monkey 0
If false: throw to monkey 1
""".split("\n\n")
// test if implementation meets criteria from the description, like:
check(part1(testInput) == 10605)
check(part2(testInput) == 2713310158L)
val input = File("./src/resources/Day11.txt").readText().split("\n\n")
println(part1(input))
println(part2(input))
}
class Monkey(val items: ArrayDeque<Long>, val op: (Long) -> Long, val testDiv: Int, val ifTrue: Int, val ifFalse: Int) {
var inspectionCount = 0
private set
fun catch(item: Long) {
items.add(item)
}
fun hasItems() = items.any()
private fun inspectNext(divisor: Int): Pair<Long, Int> {
inspectionCount++
val newWorry = op(items.removeFirst()) / divisor
return newWorry to if (newWorry % testDiv == 0L ) ifTrue else ifFalse
}
fun inspectNextPt1(): Pair<Long, Int> = inspectNext(3)
fun inspectNextPt2(): Pair<Long, Int> = inspectNext(1)
}
fun String.toFunction(): (Long) -> Long {
if (this.trim() == "old * old")
return { old -> old * old }
val tokens = this.trim().split(" ")
if (tokens[1] == "+")
return { old: Long -> old + tokens[2].toInt() }
if (tokens[1] == "*")
return { old: Long -> old * tokens[2].toInt() }
return { old: Long -> old * tokens[2].toInt() }
}
|
[
{
"class_path": "dcbertelsen__advent-of-code-2022-kotlin__9d22341/Day11Kt$main$part1$$inlined$sortedBy$1.class",
"javap": "Compiled from \"Comparisons.kt\"\npublic final class Day11Kt$main$part1$$inlined$sortedBy$1<T> implements java.util.Comparator {\n public Day11Kt$main$part1$$inlined$sortedBy$1();\n Code:\n 0: aload_0\n 1: invokespecial #16 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int compare(T, T);\n Code:\n 0: aload_1\n 1: checkcast #23 // class Monkey\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method Monkey.getInspectionCount:()I\n 12: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 15: checkcast #35 // class java/lang/Comparable\n 18: aload_2\n 19: checkcast #23 // class Monkey\n 22: astore_3\n 23: astore 5\n 25: iconst_0\n 26: istore 4\n 28: aload_3\n 29: invokevirtual #27 // Method Monkey.getInspectionCount:()I\n 32: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 35: aload 5\n 37: swap\n 38: checkcast #35 // class java/lang/Comparable\n 41: invokestatic #41 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I\n 44: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dcbertelsen__advent-of-code-2022-kotlin__9d22341/Day11Kt.class",
"javap": "Compiled from \"Day11.kt\"\npublic final class Day11Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Monkey 0:\\n Starting items: 79, 98\\n Operation: new = old * 19\\n Test: divisible by 23\\n If true: throw to monkey 2\\n If false: throw to monkey 3\\n\\nMonkey 1:\\n Starting items: 54, 65, 75, 74\\n Operation: new = old + 6\\n Test: divisible by 19\\n If true: throw to monkey 2\\n If false: throw to monkey 0\\n\\nMonkey 2:\\n Starting items: 79, 60, 97\\n Operation: new = old * old\\n Test: divisible by 13\\n If true: throw to monkey 1\\n If false: throw to monkey 3\\n\\nMonkey 3:\\n Starting items: 74\\n Operation: new = old + 3\\n Test: divisible by 17\\n If true: throw to monkey 0\\n If false: throw to monkey 1\\n\n 2: checkcast #10 // class java/lang/CharSequence\n 5: iconst_1\n 6: anewarray #12 // class java/lang/String\n 9: astore_1\n 10: aload_1\n 11: iconst_0\n 12: ldc #14 // String \\n\\n\n 14: aastore\n 15: aload_1\n 16: iconst_0\n 17: iconst_0\n 18: bipush 6\n 20: aconst_null\n 21: invokestatic #20 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 24: astore_0\n 25: aload_0\n 26: invokestatic #24 // Method main$part1:(Ljava/util/List;)I\n 29: sipush 10605\n 32: if_icmpne 39\n 35: iconst_1\n 36: goto 40\n 39: iconst_0\n 40: ifne 53\n 43: new #26 // class java/lang/IllegalStateException\n 46: dup\n 47: ldc #28 // String Check failed.\n 49: invokespecial #32 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 52: athrow\n 53: aload_0\n 54: invokestatic #36 // Method main$part2:(Ljava/util/List;)J\n 57: ldc2_w #37 // long 2713310158l\n 60: lcmp\n 61: ifne 68\n 64: iconst_1\n 65: goto 69\n 68: iconst_0\n 69: ifne 82\n 72: new #26 // class java/lang/IllegalStateException\n 75: dup\n 76: ldc #28 // String Check failed.\n 78: invokespecial #32 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 81: athrow\n 82: new #40 // class java/io/File\n 85: dup\n 86: ldc #42 // String ./src/resources/Day11.txt\n 88: invokespecial #43 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 91: aconst_null\n 92: iconst_1\n 93: aconst_null\n 94: invokestatic #49 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;\n 97: checkcast #10 // class java/lang/CharSequence\n 100: iconst_1\n 101: anewarray #12 // class java/lang/String\n 104: astore_2\n 105: aload_2\n 106: iconst_0\n 107: ldc #14 // String \\n\\n\n 109: aastore\n 110: aload_2\n 111: iconst_0\n 112: iconst_0\n 113: bipush 6\n 115: aconst_null\n 116: invokestatic #20 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 119: astore_1\n 120: aload_1\n 121: invokestatic #24 // Method main$part1:(Ljava/util/List;)I\n 124: istore_2\n 125: getstatic #55 // Field java/lang/System.out:Ljava/io/PrintStream;\n 128: iload_2\n 129: invokevirtual #61 // Method java/io/PrintStream.println:(I)V\n 132: aload_1\n 133: invokestatic #36 // Method main$part2:(Ljava/util/List;)J\n 136: lstore_2\n 137: getstatic #55 // Field java/lang/System.out:Ljava/io/PrintStream;\n 140: lload_2\n 141: invokevirtual #64 // Method java/io/PrintStream.println:(J)V\n 144: return\n\n public static final kotlin.jvm.functions.Function1<java.lang.Long, java.lang.Long> toFunction(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #77 // String <this>\n 3: invokestatic #83 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #10 // class java/lang/CharSequence\n 10: invokestatic #87 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 13: invokevirtual #91 // Method java/lang/Object.toString:()Ljava/lang/String;\n 16: ldc #93 // String old * old\n 18: invokestatic #97 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 21: ifeq 30\n 24: invokedynamic #117, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 29: areturn\n 30: aload_0\n 31: checkcast #10 // class java/lang/CharSequence\n 34: invokestatic #87 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 37: invokevirtual #91 // Method java/lang/Object.toString:()Ljava/lang/String;\n 40: checkcast #10 // class java/lang/CharSequence\n 43: iconst_1\n 44: anewarray #12 // class java/lang/String\n 47: astore_2\n 48: aload_2\n 49: iconst_0\n 50: ldc #119 // String\n 52: aastore\n 53: aload_2\n 54: iconst_0\n 55: iconst_0\n 56: bipush 6\n 58: aconst_null\n 59: invokestatic #20 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 62: astore_1\n 63: aload_1\n 64: iconst_1\n 65: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 70: ldc #125 // String +\n 72: invokestatic #97 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 75: ifeq 85\n 78: aload_1\n 79: invokedynamic #133, 0 // InvokeDynamic #1:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function1;\n 84: areturn\n 85: aload_1\n 86: iconst_1\n 87: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 92: ldc #135 // String *\n 94: invokestatic #97 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 97: ifeq 107\n 100: aload_1\n 101: invokedynamic #140, 0 // InvokeDynamic #2:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function1;\n 106: areturn\n 107: aload_1\n 108: invokedynamic #145, 0 // InvokeDynamic #3:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function1;\n 113: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #151 // Method main:()V\n 3: return\n\n private static final java.util.List<Monkey> main$readMonkeys(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #157 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: astore_3\n 9: new #159 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #165 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #167 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #169 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #173, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #179, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 492\n 48: aload 6\n 50: invokeinterface #183, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #12 // class java/lang/String\n 64: astore 8\n 66: astore 21\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: checkcast #10 // class java/lang/CharSequence\n 76: iconst_1\n 77: anewarray #12 // class java/lang/String\n 80: astore 10\n 82: aload 10\n 84: iconst_0\n 85: ldc #185 // String \\n\n 87: aastore\n 88: aload 10\n 90: iconst_0\n 91: iconst_0\n 92: bipush 6\n 94: aconst_null\n 95: invokestatic #20 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 98: astore 11\n 100: aload 11\n 102: iconst_1\n 103: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 108: checkcast #10 // class java/lang/CharSequence\n 111: iconst_1\n 112: anewarray #12 // class java/lang/String\n 115: astore 10\n 117: aload 10\n 119: iconst_0\n 120: ldc #187 // String :\n 122: aastore\n 123: aload 10\n 125: iconst_0\n 126: iconst_0\n 127: bipush 6\n 129: aconst_null\n 130: invokestatic #20 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 133: iconst_1\n 134: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 139: checkcast #10 // class java/lang/CharSequence\n 142: iconst_1\n 143: anewarray #12 // class java/lang/String\n 146: astore 10\n 148: aload 10\n 150: iconst_0\n 151: ldc #189 // String ,\n 153: aastore\n 154: aload 10\n 156: iconst_0\n 157: iconst_0\n 158: bipush 6\n 160: aconst_null\n 161: invokestatic #20 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 164: checkcast #157 // class java/lang/Iterable\n 167: astore 10\n 169: iconst_0\n 170: istore 12\n 172: aload 10\n 174: astore 13\n 176: new #159 // class java/util/ArrayList\n 179: dup\n 180: aload 10\n 182: bipush 10\n 184: invokestatic #165 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 187: invokespecial #167 // Method java/util/ArrayList.\"<init>\":(I)V\n 190: checkcast #169 // class java/util/Collection\n 193: astore 14\n 195: iconst_0\n 196: istore 15\n 198: aload 13\n 200: invokeinterface #173, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 205: astore 16\n 207: aload 16\n 209: invokeinterface #179, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 214: ifeq 261\n 217: aload 16\n 219: invokeinterface #183, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 224: astore 17\n 226: aload 14\n 228: aload 17\n 230: checkcast #12 // class java/lang/String\n 233: astore 18\n 235: astore 19\n 237: iconst_0\n 238: istore 20\n 240: aload 18\n 242: invokestatic #195 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 245: nop\n 246: invokestatic #199 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 249: aload 19\n 251: swap\n 252: invokeinterface #203, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 257: pop\n 258: goto 207\n 261: aload 14\n 263: checkcast #69 // class java/util/List\n 266: nop\n 267: checkcast #169 // class java/util/Collection\n 270: astore 22\n 272: new #205 // class kotlin/collections/ArrayDeque\n 275: dup\n 276: aload 22\n 278: invokespecial #208 // Method kotlin/collections/ArrayDeque.\"<init>\":(Ljava/util/Collection;)V\n 281: aload 11\n 283: iconst_2\n 284: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 289: checkcast #10 // class java/lang/CharSequence\n 292: iconst_1\n 293: anewarray #12 // class java/lang/String\n 296: astore 10\n 298: aload 10\n 300: iconst_0\n 301: ldc #210 // String =\n 303: aastore\n 304: aload 10\n 306: iconst_0\n 307: iconst_0\n 308: bipush 6\n 310: aconst_null\n 311: invokestatic #20 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 314: iconst_1\n 315: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 320: checkcast #12 // class java/lang/String\n 323: invokestatic #212 // Method toFunction:(Ljava/lang/String;)Lkotlin/jvm/functions/Function1;\n 326: aload 11\n 328: iconst_3\n 329: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 334: checkcast #10 // class java/lang/CharSequence\n 337: iconst_1\n 338: anewarray #12 // class java/lang/String\n 341: astore 10\n 343: aload 10\n 345: iconst_0\n 346: ldc #119 // String\n 348: aastore\n 349: aload 10\n 351: iconst_0\n 352: iconst_0\n 353: bipush 6\n 355: aconst_null\n 356: invokestatic #20 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 359: invokestatic #216 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 362: checkcast #12 // class java/lang/String\n 365: invokestatic #222 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 368: aload 11\n 370: iconst_4\n 371: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 376: checkcast #10 // class java/lang/CharSequence\n 379: iconst_1\n 380: anewarray #12 // class java/lang/String\n 383: astore 10\n 385: aload 10\n 387: iconst_0\n 388: ldc #119 // String\n 390: aastore\n 391: aload 10\n 393: iconst_0\n 394: iconst_0\n 395: bipush 6\n 397: aconst_null\n 398: invokestatic #20 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 401: invokestatic #216 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 404: checkcast #12 // class java/lang/String\n 407: invokestatic #222 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 410: aload 11\n 412: iconst_5\n 413: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 418: checkcast #10 // class java/lang/CharSequence\n 421: iconst_1\n 422: anewarray #12 // class java/lang/String\n 425: astore 10\n 427: aload 10\n 429: iconst_0\n 430: ldc #119 // String\n 432: aastore\n 433: aload 10\n 435: iconst_0\n 436: iconst_0\n 437: bipush 6\n 439: aconst_null\n 440: invokestatic #20 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 443: invokestatic #216 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 446: checkcast #12 // class java/lang/String\n 449: invokestatic #222 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 452: istore 23\n 454: istore 24\n 456: istore 25\n 458: astore 26\n 460: astore 27\n 462: new #224 // class Monkey\n 465: dup\n 466: aload 27\n 468: aload 26\n 470: iload 25\n 472: iload 24\n 474: iload 23\n 476: invokespecial #227 // Method Monkey.\"<init>\":(Lkotlin/collections/ArrayDeque;Lkotlin/jvm/functions/Function1;III)V\n 479: nop\n 480: aload 21\n 482: swap\n 483: invokeinterface #203, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 488: pop\n 489: goto 38\n 492: aload 4\n 494: checkcast #69 // class java/util/List\n 497: nop\n 498: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #245 // Method main$readMonkeys:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: bipush 20\n 7: istore_2\n 8: iconst_0\n 9: istore_3\n 10: iload_3\n 11: iload_2\n 12: if_icmpge 141\n 15: iload_3\n 16: istore 4\n 18: iconst_0\n 19: istore 5\n 21: aload_1\n 22: checkcast #157 // class java/lang/Iterable\n 25: astore 6\n 27: iconst_0\n 28: istore 7\n 30: aload 6\n 32: invokeinterface #173, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 37: astore 8\n 39: aload 8\n 41: invokeinterface #179, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 46: ifeq 133\n 49: aload 8\n 51: invokeinterface #183, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 56: astore 9\n 58: aload 9\n 60: checkcast #224 // class Monkey\n 63: astore 10\n 65: iconst_0\n 66: istore 11\n 68: aload 10\n 70: invokevirtual #248 // Method Monkey.hasItems:()Z\n 73: ifeq 128\n 76: aload 10\n 78: invokevirtual #252 // Method Monkey.inspectNextPt1:()Lkotlin/Pair;\n 81: astore 12\n 83: aload 12\n 85: invokevirtual #257 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 88: checkcast #259 // class java/lang/Number\n 91: invokevirtual #263 // Method java/lang/Number.longValue:()J\n 94: lstore 13\n 96: aload 12\n 98: invokevirtual #266 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 101: checkcast #259 // class java/lang/Number\n 104: invokevirtual #270 // Method java/lang/Number.intValue:()I\n 107: istore 15\n 109: aload_1\n 110: iload 15\n 112: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 117: checkcast #224 // class Monkey\n 120: lload 13\n 122: invokevirtual #273 // Method Monkey.catch:(J)V\n 125: goto 68\n 128: nop\n 129: nop\n 130: goto 39\n 133: nop\n 134: nop\n 135: iinc 3, 1\n 138: goto 10\n 141: aload_1\n 142: checkcast #157 // class java/lang/Iterable\n 145: astore_2\n 146: iconst_0\n 147: istore_3\n 148: aload_2\n 149: new #275 // class Day11Kt$main$part1$$inlined$sortedBy$1\n 152: dup\n 153: invokespecial #277 // Method Day11Kt$main$part1$$inlined$sortedBy$1.\"<init>\":()V\n 156: checkcast #279 // class java/util/Comparator\n 159: invokestatic #283 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 162: iconst_2\n 163: invokestatic #287 // Method kotlin/collections/CollectionsKt.takeLast:(Ljava/util/List;I)Ljava/util/List;\n 166: checkcast #157 // class java/lang/Iterable\n 169: astore_2\n 170: iconst_1\n 171: istore_3\n 172: iconst_0\n 173: istore 4\n 175: iload_3\n 176: istore 5\n 178: aload_2\n 179: invokeinterface #173, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 184: astore 6\n 186: aload 6\n 188: invokeinterface #179, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 193: ifeq 232\n 196: aload 6\n 198: invokeinterface #183, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 203: astore 7\n 205: iload 5\n 207: aload 7\n 209: checkcast #224 // class Monkey\n 212: astore 8\n 214: istore 9\n 216: iconst_0\n 217: istore 10\n 219: iload 9\n 221: aload 8\n 223: invokevirtual #290 // Method Monkey.getInspectionCount:()I\n 226: imul\n 227: istore 5\n 229: goto 186\n 232: iload 5\n 234: ireturn\n\n private static final long main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #245 // Method main$readMonkeys:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: aload_1\n 6: checkcast #157 // class java/lang/Iterable\n 9: astore_3\n 10: iconst_1\n 11: istore 4\n 13: iconst_0\n 14: istore 5\n 16: iload 4\n 18: istore 6\n 20: aload_3\n 21: invokeinterface #173, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 26: astore 7\n 28: aload 7\n 30: invokeinterface #179, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 35: ifeq 74\n 38: aload 7\n 40: invokeinterface #183, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 45: astore 8\n 47: iload 6\n 49: aload 8\n 51: checkcast #224 // class Monkey\n 54: astore 9\n 56: istore 10\n 58: iconst_0\n 59: istore 11\n 61: iload 10\n 63: aload 9\n 65: invokevirtual #314 // Method Monkey.getTestDiv:()I\n 68: imul\n 69: istore 6\n 71: goto 28\n 74: iload 6\n 76: istore_2\n 77: sipush 10000\n 80: istore_3\n 81: iconst_0\n 82: istore 4\n 84: iload 4\n 86: iload_3\n 87: if_icmpge 220\n 90: iload 4\n 92: istore 5\n 94: iconst_0\n 95: istore 6\n 97: aload_1\n 98: checkcast #157 // class java/lang/Iterable\n 101: astore 7\n 103: iconst_0\n 104: istore 8\n 106: aload 7\n 108: invokeinterface #173, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 113: astore 9\n 115: aload 9\n 117: invokeinterface #179, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 122: ifeq 212\n 125: aload 9\n 127: invokeinterface #183, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 132: astore 10\n 134: aload 10\n 136: checkcast #224 // class Monkey\n 139: astore 11\n 141: iconst_0\n 142: istore 12\n 144: aload 11\n 146: invokevirtual #248 // Method Monkey.hasItems:()Z\n 149: ifeq 207\n 152: aload 11\n 154: invokevirtual #317 // Method Monkey.inspectNextPt2:()Lkotlin/Pair;\n 157: astore 13\n 159: aload 13\n 161: invokevirtual #257 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 164: checkcast #259 // class java/lang/Number\n 167: invokevirtual #263 // Method java/lang/Number.longValue:()J\n 170: lstore 14\n 172: aload 13\n 174: invokevirtual #266 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 177: checkcast #259 // class java/lang/Number\n 180: invokevirtual #270 // Method java/lang/Number.intValue:()I\n 183: istore 16\n 185: aload_1\n 186: iload 16\n 188: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 193: checkcast #224 // class Monkey\n 196: lload 14\n 198: iload_2\n 199: i2l\n 200: lrem\n 201: invokevirtual #273 // Method Monkey.catch:(J)V\n 204: goto 144\n 207: nop\n 208: nop\n 209: goto 115\n 212: nop\n 213: nop\n 214: iinc 4, 1\n 217: goto 84\n 220: aload_1\n 221: checkcast #157 // class java/lang/Iterable\n 224: astore 4\n 226: iconst_0\n 227: istore 5\n 229: aload 4\n 231: astore 6\n 233: new #159 // class java/util/ArrayList\n 236: dup\n 237: aload 4\n 239: bipush 10\n 241: invokestatic #165 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 244: invokespecial #167 // Method java/util/ArrayList.\"<init>\":(I)V\n 247: checkcast #169 // class java/util/Collection\n 250: astore 7\n 252: iconst_0\n 253: istore 8\n 255: aload 6\n 257: invokeinterface #173, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 262: astore 9\n 264: aload 9\n 266: invokeinterface #179, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 271: ifeq 317\n 274: aload 9\n 276: invokeinterface #183, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 281: astore 10\n 283: aload 7\n 285: aload 10\n 287: checkcast #224 // class Monkey\n 290: astore 11\n 292: astore 17\n 294: iconst_0\n 295: istore 12\n 297: aload 11\n 299: invokevirtual #290 // Method Monkey.getInspectionCount:()I\n 302: invokestatic #320 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 305: aload 17\n 307: swap\n 308: invokeinterface #203, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 313: pop\n 314: goto 264\n 317: aload 7\n 319: checkcast #69 // class java/util/List\n 322: nop\n 323: checkcast #157 // class java/lang/Iterable\n 326: invokestatic #324 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;\n 329: iconst_2\n 330: invokestatic #287 // Method kotlin/collections/CollectionsKt.takeLast:(Ljava/util/List;I)Ljava/util/List;\n 333: astore_3\n 334: lconst_1\n 335: aload_3\n 336: iconst_0\n 337: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 342: checkcast #259 // class java/lang/Number\n 345: invokevirtual #263 // Method java/lang/Number.longValue:()J\n 348: lmul\n 349: aload_3\n 350: iconst_1\n 351: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 356: checkcast #259 // class java/lang/Number\n 359: invokevirtual #263 // Method java/lang/Number.longValue:()J\n 362: lmul\n 363: lreturn\n\n private static final long toFunction$lambda$10(long);\n Code:\n 0: lload_0\n 1: lload_0\n 2: lmul\n 3: lreturn\n\n private static final long toFunction$lambda$11(java.util.List, long);\n Code:\n 0: lload_1\n 1: aload_0\n 2: iconst_2\n 3: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 8: checkcast #12 // class java/lang/String\n 11: invokestatic #222 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 14: i2l\n 15: ladd\n 16: lreturn\n\n private static final long toFunction$lambda$12(java.util.List, long);\n Code:\n 0: lload_1\n 1: aload_0\n 2: iconst_2\n 3: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 8: checkcast #12 // class java/lang/String\n 11: invokestatic #222 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 14: i2l\n 15: lmul\n 16: lreturn\n\n private static final long toFunction$lambda$13(java.util.List, long);\n Code:\n 0: lload_1\n 1: aload_0\n 2: iconst_2\n 3: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 8: checkcast #12 // class java/lang/String\n 11: invokestatic #222 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 14: i2l\n 15: lmul\n 16: lreturn\n}\n",
"javap_err": ""
}
] |
dcbertelsen__advent-of-code-2022-kotlin__9d22341/src/Day09.kt
|
import java.io.File
import kotlin.math.abs
import kotlin.math.round
import kotlin.math.roundToInt
fun main() {
fun part1(input: List<String>): Int {
val rope = Rope()
input.forEach { moveData ->
val move = moveData.split(" ")
repeat(move[1].toInt()) {
rope.move(Direction.valueOf(move[0]))
}
}
return rope.tailPositions.size
}
fun part2(input: List<String>): Int {
val rope = Rope(10)
input.forEach { moveData ->
val move = moveData.split(" ")
repeat(move[1].toInt()) {
rope.move(Direction.valueOf(move[0]))
}
}
return rope.tailPositions.size
}
val testInput = listOf<String>(
"R 4",
"U 4",
"L 3",
"D 1",
"R 4",
"D 1",
"L 5",
"R 2",
)
val testInput2 = listOf(
"R 5",
"U 8",
"L 8",
"D 3",
"R 17",
"D 10",
"L 25",
"U 20",
)
// test if implementation meets criteria from the description, like:
println(part1(testInput))
check(part1(testInput) == 13)
println(part2(testInput2))
check(part2(testInput2) == 36)
val input = File("./src/resources/Day09.txt").readLines()
println(part1(input))
println(part2(input))
}
class Rope(val length: Int = 2) {
val knots = List(length) { _ -> Knot() }
val tailPositions = mutableSetOf("0,0")
private val head = knots[0]
private fun isTouchingPrevious(index: Int) = abs(knots[index].x-knots[index-1].x) < 2
&& abs(knots[index].y-knots[index-1].y) < 2
infix fun move(direction: Direction) {
when (direction) {
Direction.U -> head.y++
Direction.D -> head.y--
Direction.L -> head.x--
Direction.R -> head.x++
}
(1 until knots.size).forEach { i ->
if (!isTouchingPrevious(i)) {
if (knots[i-1].x == knots[i].x || knots[i-1].y == knots[i].y) {
knots[i].x = (knots[i-1].x + knots[i].x) / 2
knots[i].y = (knots[i-1].y + knots[i].y) / 2
} else {
knots[i].x += if (knots[i-1].x > knots[i].x) 1 else -1
knots[i].y += if (knots[i-1].y > knots[i].y) 1 else -1
}
}
}
tailPositions.add("${knots.last().x},${knots.last().y}")
// println ("H -> ($headX, $headY), T -> ($tailX, $tailY)")
// (0 .. 5).map { r ->
// (0 .. 5).joinToString("") { c ->
// if (headX == c && headY == r) "H" else if (tailX == c && tailY == r) "T" else "."
// }
// }.reversed().forEach { println(it) }
// println()
}
}
enum class Direction {
U,D,L,R
}
data class Knot(var x: Int = 0, var y: Int = 0)
|
[
{
"class_path": "dcbertelsen__advent-of-code-2022-kotlin__9d22341/Day09Kt.class",
"javap": "Compiled from \"Day09.kt\"\npublic final class Day09Kt {\n public static final void main();\n Code:\n 0: bipush 8\n 2: anewarray #8 // class java/lang/String\n 5: astore_1\n 6: aload_1\n 7: iconst_0\n 8: ldc #10 // String R 4\n 10: aastore\n 11: aload_1\n 12: iconst_1\n 13: ldc #12 // String U 4\n 15: aastore\n 16: aload_1\n 17: iconst_2\n 18: ldc #14 // String L 3\n 20: aastore\n 21: aload_1\n 22: iconst_3\n 23: ldc #16 // String D 1\n 25: aastore\n 26: aload_1\n 27: iconst_4\n 28: ldc #10 // String R 4\n 30: aastore\n 31: aload_1\n 32: iconst_5\n 33: ldc #16 // String D 1\n 35: aastore\n 36: aload_1\n 37: bipush 6\n 39: ldc #18 // String L 5\n 41: aastore\n 42: aload_1\n 43: bipush 7\n 45: ldc #20 // String R 2\n 47: aastore\n 48: aload_1\n 49: invokestatic #26 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 52: astore_0\n 53: bipush 8\n 55: anewarray #8 // class java/lang/String\n 58: astore_2\n 59: aload_2\n 60: iconst_0\n 61: ldc #28 // String R 5\n 63: aastore\n 64: aload_2\n 65: iconst_1\n 66: ldc #30 // String U 8\n 68: aastore\n 69: aload_2\n 70: iconst_2\n 71: ldc #32 // String L 8\n 73: aastore\n 74: aload_2\n 75: iconst_3\n 76: ldc #34 // String D 3\n 78: aastore\n 79: aload_2\n 80: iconst_4\n 81: ldc #36 // String R 17\n 83: aastore\n 84: aload_2\n 85: iconst_5\n 86: ldc #38 // String D 10\n 88: aastore\n 89: aload_2\n 90: bipush 6\n 92: ldc #40 // String L 25\n 94: aastore\n 95: aload_2\n 96: bipush 7\n 98: ldc #42 // String U 20\n 100: aastore\n 101: aload_2\n 102: invokestatic #26 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 105: astore_1\n 106: aload_0\n 107: invokestatic #46 // Method main$part1:(Ljava/util/List;)I\n 110: istore_2\n 111: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 114: iload_2\n 115: invokevirtual #58 // Method java/io/PrintStream.println:(I)V\n 118: aload_0\n 119: invokestatic #46 // Method main$part1:(Ljava/util/List;)I\n 122: bipush 13\n 124: if_icmpne 131\n 127: iconst_1\n 128: goto 132\n 131: iconst_0\n 132: ifne 145\n 135: new #60 // class java/lang/IllegalStateException\n 138: dup\n 139: ldc #62 // String Check failed.\n 141: invokespecial #66 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 144: athrow\n 145: aload_1\n 146: invokestatic #69 // Method main$part2:(Ljava/util/List;)I\n 149: istore_2\n 150: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 153: iload_2\n 154: invokevirtual #58 // Method java/io/PrintStream.println:(I)V\n 157: aload_1\n 158: invokestatic #69 // Method main$part2:(Ljava/util/List;)I\n 161: bipush 36\n 163: if_icmpne 170\n 166: iconst_1\n 167: goto 171\n 170: iconst_0\n 171: ifne 184\n 174: new #60 // class java/lang/IllegalStateException\n 177: dup\n 178: ldc #62 // String Check failed.\n 180: invokespecial #66 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 183: athrow\n 184: new #71 // class java/io/File\n 187: dup\n 188: ldc #73 // String ./src/resources/Day09.txt\n 190: invokespecial #74 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 193: aconst_null\n 194: iconst_1\n 195: aconst_null\n 196: invokestatic #80 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 199: astore_2\n 200: aload_2\n 201: invokestatic #46 // Method main$part1:(Ljava/util/List;)I\n 204: istore_3\n 205: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 208: iload_3\n 209: invokevirtual #58 // Method java/io/PrintStream.println:(I)V\n 212: aload_2\n 213: invokestatic #69 // Method main$part2:(Ljava/util/List;)I\n 216: istore_3\n 217: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 220: iload_3\n 221: invokevirtual #58 // Method java/io/PrintStream.println:(I)V\n 224: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #89 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: new #94 // class Rope\n 3: dup\n 4: iconst_0\n 5: iconst_1\n 6: aconst_null\n 7: invokespecial #97 // Method Rope.\"<init>\":(IILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 10: astore_1\n 11: aload_0\n 12: checkcast #99 // class java/lang/Iterable\n 15: astore_2\n 16: iconst_0\n 17: istore_3\n 18: aload_2\n 19: invokeinterface #103, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 24: astore 4\n 26: aload 4\n 28: invokeinterface #109, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 33: ifeq 147\n 36: aload 4\n 38: invokeinterface #113, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 43: astore 5\n 45: aload 5\n 47: checkcast #8 // class java/lang/String\n 50: astore 6\n 52: iconst_0\n 53: istore 7\n 55: aload 6\n 57: checkcast #115 // class java/lang/CharSequence\n 60: iconst_1\n 61: anewarray #8 // class java/lang/String\n 64: astore 8\n 66: aload 8\n 68: iconst_0\n 69: ldc #117 // String\n 71: aastore\n 72: aload 8\n 74: iconst_0\n 75: iconst_0\n 76: bipush 6\n 78: aconst_null\n 79: invokestatic #123 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 82: astore 9\n 84: aload 9\n 86: iconst_1\n 87: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 92: checkcast #8 // class java/lang/String\n 95: invokestatic #133 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 98: istore 8\n 100: iconst_0\n 101: istore 10\n 103: iload 10\n 105: iload 8\n 107: if_icmpge 142\n 110: iload 10\n 112: istore 11\n 114: iconst_0\n 115: istore 12\n 117: aload_1\n 118: aload 9\n 120: iconst_0\n 121: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 126: checkcast #8 // class java/lang/String\n 129: invokestatic #139 // Method Direction.valueOf:(Ljava/lang/String;)LDirection;\n 132: invokevirtual #143 // Method Rope.move:(LDirection;)V\n 135: nop\n 136: iinc 10, 1\n 139: goto 103\n 142: nop\n 143: nop\n 144: goto 26\n 147: nop\n 148: aload_1\n 149: invokevirtual #147 // Method Rope.getTailPositions:()Ljava/util/Set;\n 152: invokeinterface #153, 1 // InterfaceMethod java/util/Set.size:()I\n 157: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: new #94 // class Rope\n 3: dup\n 4: bipush 10\n 6: invokespecial #168 // Method Rope.\"<init>\":(I)V\n 9: astore_1\n 10: aload_0\n 11: checkcast #99 // class java/lang/Iterable\n 14: astore_2\n 15: iconst_0\n 16: istore_3\n 17: aload_2\n 18: invokeinterface #103, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 23: astore 4\n 25: aload 4\n 27: invokeinterface #109, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 32: ifeq 146\n 35: aload 4\n 37: invokeinterface #113, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 42: astore 5\n 44: aload 5\n 46: checkcast #8 // class java/lang/String\n 49: astore 6\n 51: iconst_0\n 52: istore 7\n 54: aload 6\n 56: checkcast #115 // class java/lang/CharSequence\n 59: iconst_1\n 60: anewarray #8 // class java/lang/String\n 63: astore 8\n 65: aload 8\n 67: iconst_0\n 68: ldc #117 // String\n 70: aastore\n 71: aload 8\n 73: iconst_0\n 74: iconst_0\n 75: bipush 6\n 77: aconst_null\n 78: invokestatic #123 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 81: astore 9\n 83: aload 9\n 85: iconst_1\n 86: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 91: checkcast #8 // class java/lang/String\n 94: invokestatic #133 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 97: istore 8\n 99: iconst_0\n 100: istore 10\n 102: iload 10\n 104: iload 8\n 106: if_icmpge 141\n 109: iload 10\n 111: istore 11\n 113: iconst_0\n 114: istore 12\n 116: aload_1\n 117: aload 9\n 119: iconst_0\n 120: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 125: checkcast #8 // class java/lang/String\n 128: invokestatic #139 // Method Direction.valueOf:(Ljava/lang/String;)LDirection;\n 131: invokevirtual #143 // Method Rope.move:(LDirection;)V\n 134: nop\n 135: iinc 10, 1\n 138: goto 102\n 141: nop\n 142: nop\n 143: goto 25\n 146: nop\n 147: aload_1\n 148: invokevirtual #147 // Method Rope.getTailPositions:()Ljava/util/Set;\n 151: invokeinterface #153, 1 // InterfaceMethod java/util/Set.size:()I\n 156: ireturn\n}\n",
"javap_err": ""
}
] |
dcbertelsen__advent-of-code-2022-kotlin__9d22341/src/Day08.kt
|
import java.io.File
fun main() {
fun sightAlongAndMark(trees: List<Tree>) {
var max = -1
trees.forEach { t -> if (t.height > max) { t.canSee(); max = t.height }}
}
fun getVisibleTrees(trees: List<Tree>): Int {
var count = 0
var max = 0
for (tree in trees.subList(1, trees.size)) {
count++
max = maxOf(max, tree.height)
if (tree.height >= trees[0].height) {
break
}
}
return count
}
fun <T> getColumns(ts: List<List<T>>): List<List<T>> {
return (0 until ts[0].size).map { i ->
ts.map { r -> r[i] }.toList()
}.toList()
}
fun getDirectionLists(trees: List<List<Tree>>, row: Int, col: Int): List<List<Tree>> {
val directions = mutableListOf<List<Tree>>()
directions.add(trees[row].subList(0, col+1).reversed()) // left
directions.add(trees[row].subList(col, trees[row].size)) // right
val column = getColumns(trees)[col]
directions.add(column.subList(0, row+1).reversed()) // top
directions.add(column.subList(row, column.size)) // bottom
return directions.toList()
}
fun part1(input: List<String>): Int {
val forest = input.map { r -> r.map { Tree(it.digitToInt()) }}
forest.forEach { sightAlongAndMark(it) }
forest.forEach { sightAlongAndMark(it.reversed()) }
val columns = getColumns(forest)
columns.forEach { sightAlongAndMark(it) }
columns.forEach { sightAlongAndMark(it.reversed()) }
// forest.forEach { r -> println(r.joinToString("") { t -> "${t}" }) }
println()
return forest.flatten().count { it.isVisible }
}
fun part2(input: List<String>): Int {
val forest = input.map { r -> r.map { Tree(it.digitToInt()) }}
forest.forEachIndexed { i, row -> row.forEachIndexed { j, tree ->
val lists = getDirectionLists(forest, i, j)
tree.scenicScore = lists.map {
getVisibleTrees(it)
}.fold(1) { acc, it -> it * acc }
} }
// forest.forEach { r -> println(r.joinToString(" ") { t -> "${t.scenicScore}" }) }
println()
return forest.flatten().maxOf { it.scenicScore }
}
val testInput = listOf<String>(
"30373",
"25512",
"65332",
"33549",
"35390"
)
// test if implementation meets criteria from the description, like:
check(part1(testInput) == 21)
check(part2(testInput) == 8)
val input = File("./src/resources/Day08.txt").readLines()
println(part1(input))
println(part2(input))
}
class Tree(val height: Int, var isVisible: Boolean = false) {
fun canSee() { isVisible = true }
override fun toString(): String = if (isVisible) "*" else " "
var scenicScore = -1
}
|
[
{
"class_path": "dcbertelsen__advent-of-code-2022-kotlin__9d22341/Day08Kt.class",
"javap": "Compiled from \"Day08.kt\"\npublic final class Day08Kt {\n public static final void main();\n Code:\n 0: iconst_5\n 1: anewarray #8 // class java/lang/String\n 4: astore_1\n 5: aload_1\n 6: iconst_0\n 7: ldc #10 // String 30373\n 9: aastore\n 10: aload_1\n 11: iconst_1\n 12: ldc #12 // String 25512\n 14: aastore\n 15: aload_1\n 16: iconst_2\n 17: ldc #14 // String 65332\n 19: aastore\n 20: aload_1\n 21: iconst_3\n 22: ldc #16 // String 33549\n 24: aastore\n 25: aload_1\n 26: iconst_4\n 27: ldc #18 // String 35390\n 29: aastore\n 30: aload_1\n 31: invokestatic #24 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 34: astore_0\n 35: aload_0\n 36: invokestatic #28 // Method main$part1:(Ljava/util/List;)I\n 39: bipush 21\n 41: if_icmpne 48\n 44: iconst_1\n 45: goto 49\n 48: iconst_0\n 49: ifne 62\n 52: new #30 // class java/lang/IllegalStateException\n 55: dup\n 56: ldc #32 // String Check failed.\n 58: invokespecial #36 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 61: athrow\n 62: aload_0\n 63: invokestatic #39 // Method main$part2:(Ljava/util/List;)I\n 66: bipush 8\n 68: if_icmpne 75\n 71: iconst_1\n 72: goto 76\n 75: iconst_0\n 76: ifne 89\n 79: new #30 // class java/lang/IllegalStateException\n 82: dup\n 83: ldc #32 // String Check failed.\n 85: invokespecial #36 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 88: athrow\n 89: new #41 // class java/io/File\n 92: dup\n 93: ldc #43 // String ./src/resources/Day08.txt\n 95: invokespecial #44 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 98: aconst_null\n 99: iconst_1\n 100: aconst_null\n 101: invokestatic #50 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 104: astore_1\n 105: aload_1\n 106: invokestatic #28 // Method main$part1:(Ljava/util/List;)I\n 109: istore_2\n 110: getstatic #56 // Field java/lang/System.out:Ljava/io/PrintStream;\n 113: iload_2\n 114: invokevirtual #62 // Method java/io/PrintStream.println:(I)V\n 117: aload_1\n 118: invokestatic #39 // Method main$part2:(Ljava/util/List;)I\n 121: istore_2\n 122: getstatic #56 // Field java/lang/System.out:Ljava/io/PrintStream;\n 125: iload_2\n 126: invokevirtual #62 // Method java/io/PrintStream.println:(I)V\n 129: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #72 // Method main:()V\n 3: return\n\n private static final void main$sightAlongAndMark(java.util.List<Tree>);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: iconst_m1\n 3: istore_1\n 4: aload_0\n 5: checkcast #78 // class java/lang/Iterable\n 8: astore_2\n 9: iconst_0\n 10: istore_3\n 11: aload_2\n 12: invokeinterface #82, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 17: astore 4\n 19: aload 4\n 21: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 26: ifeq 72\n 29: aload 4\n 31: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 36: astore 5\n 38: aload 5\n 40: checkcast #94 // class Tree\n 43: astore 6\n 45: iconst_0\n 46: istore 7\n 48: aload 6\n 50: invokevirtual #98 // Method Tree.getHeight:()I\n 53: iload_1\n 54: if_icmple 68\n 57: aload 6\n 59: invokevirtual #101 // Method Tree.canSee:()V\n 62: aload 6\n 64: invokevirtual #98 // Method Tree.getHeight:()I\n 67: istore_1\n 68: nop\n 69: goto 19\n 72: nop\n 73: return\n\n private static final int main$getVisibleTrees(java.util.List<Tree>);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: iconst_0\n 3: istore_2\n 4: aload_0\n 5: iconst_1\n 6: aload_0\n 7: invokeinterface #117, 1 // InterfaceMethod java/util/List.size:()I\n 12: invokeinterface #121, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 17: invokeinterface #122, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 22: astore_3\n 23: aload_3\n 24: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 29: ifeq 80\n 32: aload_3\n 33: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 38: checkcast #94 // class Tree\n 41: astore 4\n 43: iinc 1, 1\n 46: iload_2\n 47: aload 4\n 49: invokevirtual #98 // Method Tree.getHeight:()I\n 52: invokestatic #127 // Method java/lang/Math.max:(II)I\n 55: istore_2\n 56: aload 4\n 58: invokevirtual #98 // Method Tree.getHeight:()I\n 61: aload_0\n 62: iconst_0\n 63: invokeinterface #131, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 68: checkcast #94 // class Tree\n 71: invokevirtual #98 // Method Tree.getHeight:()I\n 74: if_icmplt 23\n 77: goto 80\n 80: iload_1\n 81: ireturn\n\n private static final <T> java.util.List<java.util.List<T>> main$getColumns(java.util.List<? extends java.util.List<? extends T>>);\n Code:\n 0: iconst_0\n 1: aload_0\n 2: iconst_0\n 3: invokeinterface #131, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 8: checkcast #67 // class java/util/List\n 11: invokeinterface #117, 1 // InterfaceMethod java/util/List.size:()I\n 16: invokestatic #142 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 19: checkcast #78 // class java/lang/Iterable\n 22: astore_1\n 23: iconst_0\n 24: istore_2\n 25: aload_1\n 26: astore_3\n 27: new #144 // class java/util/ArrayList\n 30: dup\n 31: aload_1\n 32: bipush 10\n 34: invokestatic #148 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 37: invokespecial #150 // Method java/util/ArrayList.\"<init>\":(I)V\n 40: checkcast #152 // class java/util/Collection\n 43: astore 4\n 45: iconst_0\n 46: istore 5\n 48: aload_3\n 49: invokeinterface #82, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 54: astore 6\n 56: aload 6\n 58: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 63: ifeq 209\n 66: aload 6\n 68: checkcast #154 // class kotlin/collections/IntIterator\n 71: invokevirtual #157 // Method kotlin/collections/IntIterator.nextInt:()I\n 74: istore 7\n 76: aload 4\n 78: iload 7\n 80: istore 8\n 82: astore 20\n 84: iconst_0\n 85: istore 9\n 87: aload_0\n 88: checkcast #78 // class java/lang/Iterable\n 91: astore 10\n 93: iconst_0\n 94: istore 11\n 96: aload 10\n 98: astore 12\n 100: new #144 // class java/util/ArrayList\n 103: dup\n 104: aload 10\n 106: bipush 10\n 108: invokestatic #148 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 111: invokespecial #150 // Method java/util/ArrayList.\"<init>\":(I)V\n 114: checkcast #152 // class java/util/Collection\n 117: astore 13\n 119: iconst_0\n 120: istore 14\n 122: aload 12\n 124: invokeinterface #82, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 129: astore 15\n 131: aload 15\n 133: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 138: ifeq 185\n 141: aload 15\n 143: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 148: astore 16\n 150: aload 13\n 152: aload 16\n 154: checkcast #67 // class java/util/List\n 157: astore 17\n 159: astore 18\n 161: iconst_0\n 162: istore 19\n 164: aload 17\n 166: iload 8\n 168: invokeinterface #131, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 173: aload 18\n 175: swap\n 176: invokeinterface #161, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 181: pop\n 182: goto 131\n 185: aload 13\n 187: checkcast #67 // class java/util/List\n 190: nop\n 191: checkcast #78 // class java/lang/Iterable\n 194: invokestatic #165 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 197: aload 20\n 199: swap\n 200: invokeinterface #161, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 205: pop\n 206: goto 56\n 209: aload 4\n 211: checkcast #67 // class java/util/List\n 214: nop\n 215: checkcast #78 // class java/lang/Iterable\n 218: invokestatic #165 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 221: areturn\n\n private static final java.util.List<java.util.List<Tree>> main$getDirectionLists(java.util.List<? extends java.util.List<Tree>>, int, int);\n Code:\n 0: new #144 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #182 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #67 // class java/util/List\n 10: astore_3\n 11: aload_3\n 12: aload_0\n 13: iload_1\n 14: invokeinterface #131, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 19: checkcast #67 // class java/util/List\n 22: iconst_0\n 23: iload_2\n 24: iconst_1\n 25: iadd\n 26: invokeinterface #121, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 31: checkcast #78 // class java/lang/Iterable\n 34: invokestatic #185 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 37: invokeinterface #186, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 42: pop\n 43: aload_3\n 44: aload_0\n 45: iload_1\n 46: invokeinterface #131, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 51: checkcast #67 // class java/util/List\n 54: iload_2\n 55: aload_0\n 56: iload_1\n 57: invokeinterface #131, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 62: checkcast #67 // class java/util/List\n 65: invokeinterface #117, 1 // InterfaceMethod java/util/List.size:()I\n 70: invokeinterface #121, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 75: invokeinterface #186, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 80: pop\n 81: aload_0\n 82: invokestatic #188 // Method main$getColumns:(Ljava/util/List;)Ljava/util/List;\n 85: iload_2\n 86: invokeinterface #131, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 91: checkcast #67 // class java/util/List\n 94: astore 4\n 96: aload_3\n 97: aload 4\n 99: iconst_0\n 100: iload_1\n 101: iconst_1\n 102: iadd\n 103: invokeinterface #121, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 108: checkcast #78 // class java/lang/Iterable\n 111: invokestatic #185 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 114: invokeinterface #186, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 119: pop\n 120: aload_3\n 121: aload 4\n 123: iload_1\n 124: aload 4\n 126: invokeinterface #117, 1 // InterfaceMethod java/util/List.size:()I\n 131: invokeinterface #121, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 136: invokeinterface #186, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 141: pop\n 142: aload_3\n 143: checkcast #78 // class java/lang/Iterable\n 146: invokestatic #165 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 149: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #78 // class java/lang/Iterable\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: aload_2\n 8: astore 4\n 10: new #144 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: bipush 10\n 17: invokestatic #148 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #150 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #152 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 4\n 33: invokeinterface #82, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 7\n 40: aload 7\n 42: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 195\n 50: aload 7\n 52: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 8\n 59: aload 5\n 61: aload 8\n 63: checkcast #8 // 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 #195 // 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 #144 // class java/util/ArrayList\n 90: dup\n 91: aload 11\n 93: invokeinterface #198, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 98: invokespecial #150 // Method java/util/ArrayList.\"<init>\":(I)V\n 101: checkcast #152 // 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 #198, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 121: if_icmpge 176\n 124: aload 13\n 126: iload 16\n 128: invokeinterface #202, 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: new #94 // class Tree\n 149: dup\n 150: iload 18\n 152: invokestatic #208 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 155: iconst_0\n 156: iconst_2\n 157: aconst_null\n 158: invokespecial #211 // Method Tree.\"<init>\":(IZILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 161: aload 19\n 163: swap\n 164: invokeinterface #161, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 169: pop\n 170: iinc 16, 1\n 173: goto 112\n 176: aload 14\n 178: checkcast #67 // class java/util/List\n 181: nop\n 182: nop\n 183: aload 21\n 185: swap\n 186: invokeinterface #161, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 191: pop\n 192: goto 40\n 195: aload 5\n 197: checkcast #67 // class java/util/List\n 200: nop\n 201: astore_1\n 202: aload_1\n 203: checkcast #78 // class java/lang/Iterable\n 206: astore_2\n 207: iconst_0\n 208: istore_3\n 209: aload_2\n 210: invokeinterface #82, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 215: astore 4\n 217: aload 4\n 219: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 224: ifeq 255\n 227: aload 4\n 229: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 234: astore 5\n 236: aload 5\n 238: checkcast #67 // class java/util/List\n 241: astore 6\n 243: iconst_0\n 244: istore 7\n 246: aload 6\n 248: invokestatic #213 // Method main$sightAlongAndMark:(Ljava/util/List;)V\n 251: nop\n 252: goto 217\n 255: nop\n 256: aload_1\n 257: checkcast #78 // class java/lang/Iterable\n 260: astore_2\n 261: iconst_0\n 262: istore_3\n 263: aload_2\n 264: invokeinterface #82, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 269: astore 4\n 271: aload 4\n 273: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 278: ifeq 315\n 281: aload 4\n 283: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 288: astore 5\n 290: aload 5\n 292: checkcast #67 // class java/util/List\n 295: astore 6\n 297: iconst_0\n 298: istore 7\n 300: aload 6\n 302: checkcast #78 // class java/lang/Iterable\n 305: invokestatic #185 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 308: invokestatic #213 // Method main$sightAlongAndMark:(Ljava/util/List;)V\n 311: nop\n 312: goto 271\n 315: nop\n 316: aload_1\n 317: invokestatic #188 // Method main$getColumns:(Ljava/util/List;)Ljava/util/List;\n 320: astore_2\n 321: aload_2\n 322: checkcast #78 // class java/lang/Iterable\n 325: astore_3\n 326: iconst_0\n 327: istore 4\n 329: aload_3\n 330: invokeinterface #82, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 335: astore 5\n 337: aload 5\n 339: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 344: ifeq 375\n 347: aload 5\n 349: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 354: astore 6\n 356: aload 6\n 358: checkcast #67 // class java/util/List\n 361: astore 7\n 363: iconst_0\n 364: istore 8\n 366: aload 7\n 368: invokestatic #213 // Method main$sightAlongAndMark:(Ljava/util/List;)V\n 371: nop\n 372: goto 337\n 375: nop\n 376: aload_2\n 377: checkcast #78 // class java/lang/Iterable\n 380: astore_3\n 381: iconst_0\n 382: istore 4\n 384: aload_3\n 385: invokeinterface #82, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 390: astore 5\n 392: aload 5\n 394: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 399: ifeq 436\n 402: aload 5\n 404: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 409: astore 6\n 411: aload 6\n 413: checkcast #67 // class java/util/List\n 416: astore 7\n 418: iconst_0\n 419: istore 8\n 421: aload 7\n 423: checkcast #78 // class java/lang/Iterable\n 426: invokestatic #185 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 429: invokestatic #213 // Method main$sightAlongAndMark:(Ljava/util/List;)V\n 432: nop\n 433: goto 392\n 436: nop\n 437: getstatic #56 // Field java/lang/System.out:Ljava/io/PrintStream;\n 440: invokevirtual #215 // Method java/io/PrintStream.println:()V\n 443: aload_1\n 444: checkcast #78 // class java/lang/Iterable\n 447: invokestatic #218 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 450: checkcast #78 // class java/lang/Iterable\n 453: astore_3\n 454: iconst_0\n 455: istore 4\n 457: aload_3\n 458: instanceof #152 // class java/util/Collection\n 461: ifeq 480\n 464: aload_3\n 465: checkcast #152 // class java/util/Collection\n 468: invokeinterface #221, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 473: ifeq 480\n 476: iconst_0\n 477: goto 544\n 480: iconst_0\n 481: istore 5\n 483: aload_3\n 484: invokeinterface #82, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 489: astore 6\n 491: aload 6\n 493: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 498: ifeq 542\n 501: aload 6\n 503: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 508: astore 7\n 510: aload 7\n 512: checkcast #94 // class Tree\n 515: astore 8\n 517: iconst_0\n 518: istore 9\n 520: aload 8\n 522: invokevirtual #224 // Method Tree.isVisible:()Z\n 525: ifeq 491\n 528: iinc 5, 1\n 531: iload 5\n 533: ifge 491\n 536: invokestatic #227 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 539: goto 491\n 542: iload 5\n 544: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #78 // class java/lang/Iterable\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: aload_2\n 8: astore 4\n 10: new #144 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: bipush 10\n 17: invokestatic #148 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #150 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #152 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 4\n 33: invokeinterface #82, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 7\n 40: aload 7\n 42: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 195\n 50: aload 7\n 52: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 8\n 59: aload 5\n 61: aload 8\n 63: checkcast #8 // class java/lang/String\n 66: astore 9\n 68: astore 32\n 70: iconst_0\n 71: istore 10\n 73: aload 9\n 75: checkcast #195 // 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 #144 // class java/util/ArrayList\n 90: dup\n 91: aload 11\n 93: invokeinterface #198, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 98: invokespecial #150 // Method java/util/ArrayList.\"<init>\":(I)V\n 101: checkcast #152 // 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 #198, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 121: if_icmpge 176\n 124: aload 13\n 126: iload 16\n 128: invokeinterface #202, 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: new #94 // class Tree\n 149: dup\n 150: iload 18\n 152: invokestatic #208 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 155: iconst_0\n 156: iconst_2\n 157: aconst_null\n 158: invokespecial #211 // Method Tree.\"<init>\":(IZILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 161: aload 19\n 163: swap\n 164: invokeinterface #161, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 169: pop\n 170: iinc 16, 1\n 173: goto 112\n 176: aload 14\n 178: checkcast #67 // class java/util/List\n 181: nop\n 182: nop\n 183: aload 32\n 185: swap\n 186: invokeinterface #161, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 191: pop\n 192: goto 40\n 195: aload 5\n 197: checkcast #67 // class java/util/List\n 200: nop\n 201: astore_1\n 202: aload_1\n 203: checkcast #78 // class java/lang/Iterable\n 206: astore_2\n 207: iconst_0\n 208: istore_3\n 209: iconst_0\n 210: istore 4\n 212: aload_2\n 213: invokeinterface #82, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 218: astore 5\n 220: aload 5\n 222: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 227: ifeq 568\n 230: aload 5\n 232: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 237: astore 6\n 239: iload 4\n 241: iinc 4, 1\n 244: istore 7\n 246: iload 7\n 248: ifge 254\n 251: invokestatic #246 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 254: iload 7\n 256: aload 6\n 258: checkcast #67 // class java/util/List\n 261: astore 8\n 263: istore 9\n 265: iconst_0\n 266: istore 10\n 268: aload 8\n 270: checkcast #78 // class java/lang/Iterable\n 273: astore 11\n 275: iconst_0\n 276: istore 12\n 278: iconst_0\n 279: istore 13\n 281: aload 11\n 283: invokeinterface #82, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 288: astore 14\n 290: aload 14\n 292: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 297: ifeq 562\n 300: aload 14\n 302: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 307: astore 15\n 309: iload 13\n 311: iinc 13, 1\n 314: istore 16\n 316: iload 16\n 318: ifge 324\n 321: invokestatic #246 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 324: iload 16\n 326: aload 15\n 328: checkcast #94 // class Tree\n 331: astore 17\n 333: istore 18\n 335: iconst_0\n 336: istore 19\n 338: aload_1\n 339: iload 9\n 341: iload 18\n 343: invokestatic #248 // Method main$getDirectionLists:(Ljava/util/List;II)Ljava/util/List;\n 346: astore 20\n 348: aload 17\n 350: aload 20\n 352: checkcast #78 // class java/lang/Iterable\n 355: astore 21\n 357: astore 22\n 359: iconst_0\n 360: istore 23\n 362: aload 21\n 364: astore 24\n 366: new #144 // class java/util/ArrayList\n 369: dup\n 370: aload 21\n 372: bipush 10\n 374: invokestatic #148 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 377: invokespecial #150 // Method java/util/ArrayList.\"<init>\":(I)V\n 380: checkcast #152 // class java/util/Collection\n 383: astore 25\n 385: iconst_0\n 386: istore 26\n 388: aload 24\n 390: invokeinterface #82, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 395: astore 27\n 397: aload 27\n 399: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 404: ifeq 450\n 407: aload 27\n 409: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 414: astore 28\n 416: aload 25\n 418: aload 28\n 420: checkcast #67 // class java/util/List\n 423: astore 29\n 425: astore 30\n 427: iconst_0\n 428: istore 31\n 430: aload 29\n 432: invokestatic #250 // Method main$getVisibleTrees:(Ljava/util/List;)I\n 435: invokestatic #256 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 438: aload 30\n 440: swap\n 441: invokeinterface #161, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 446: pop\n 447: goto 397\n 450: aload 25\n 452: checkcast #67 // class java/util/List\n 455: nop\n 456: aload 22\n 458: swap\n 459: checkcast #78 // class java/lang/Iterable\n 462: astore 21\n 464: iconst_1\n 465: invokestatic #256 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 468: astore 23\n 470: astore 22\n 472: iconst_0\n 473: istore 24\n 475: aload 23\n 477: astore 25\n 479: aload 21\n 481: invokeinterface #82, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 486: astore 26\n 488: aload 26\n 490: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 495: ifeq 543\n 498: aload 26\n 500: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 505: astore 27\n 507: aload 25\n 509: aload 27\n 511: checkcast #258 // class java/lang/Number\n 514: invokevirtual #261 // Method java/lang/Number.intValue:()I\n 517: istore 28\n 519: checkcast #258 // class java/lang/Number\n 522: invokevirtual #261 // Method java/lang/Number.intValue:()I\n 525: istore 29\n 527: iconst_0\n 528: istore 31\n 530: iload 28\n 532: iload 29\n 534: imul\n 535: invokestatic #256 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 538: astore 25\n 540: goto 488\n 543: aload 25\n 545: aload 22\n 547: swap\n 548: checkcast #258 // class java/lang/Number\n 551: invokevirtual #261 // Method java/lang/Number.intValue:()I\n 554: invokevirtual #264 // Method Tree.setScenicScore:(I)V\n 557: nop\n 558: nop\n 559: goto 290\n 562: nop\n 563: nop\n 564: nop\n 565: goto 220\n 568: nop\n 569: getstatic #56 // Field java/lang/System.out:Ljava/io/PrintStream;\n 572: invokevirtual #215 // Method java/io/PrintStream.println:()V\n 575: aload_1\n 576: checkcast #78 // class java/lang/Iterable\n 579: invokestatic #218 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 582: checkcast #78 // class java/lang/Iterable\n 585: invokeinterface #82, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 590: astore_3\n 591: aload_3\n 592: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 597: ifne 608\n 600: new #266 // class java/util/NoSuchElementException\n 603: dup\n 604: invokespecial #267 // Method java/util/NoSuchElementException.\"<init>\":()V\n 607: athrow\n 608: aload_3\n 609: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 614: checkcast #94 // class Tree\n 617: astore 4\n 619: iconst_0\n 620: istore 5\n 622: aload 4\n 624: invokevirtual #270 // Method Tree.getScenicScore:()I\n 627: istore 4\n 629: aload_3\n 630: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 635: ifeq 673\n 638: aload_3\n 639: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 644: checkcast #94 // class Tree\n 647: astore 5\n 649: iconst_0\n 650: istore 6\n 652: aload 5\n 654: invokevirtual #270 // Method Tree.getScenicScore:()I\n 657: istore 5\n 659: iload 4\n 661: iload 5\n 663: if_icmpge 629\n 666: iload 5\n 668: istore 4\n 670: goto 629\n 673: iload 4\n 675: ireturn\n}\n",
"javap_err": ""
}
] |
mrwhoknows55__advent-of-code-2022__f307e52/src/Day05.kt
|
import java.io.File
import java.util.Stack
fun main() {
val inputPair = getInputPair("src/day05_input.txt")
part1(inputPair)
}
fun part1(inputPair: Pair<List<Stack<Char>>, List<Triple<Int, Int, Int>>>) {
val stacks = inputPair.first
val inputs = inputPair.second
inputs.forEach {
for (i in 0 until it.first) {
if (stacks.size >= it.second) {
val selected = stacks[it.second - 1]
if (stacks.size >= it.third && selected.isNotEmpty()) {
stacks[it.third - 1].push(selected.peek())
selected.pop()
}
}
}
}
val ans = stacks.joinToString(separator = "") {
it.peek().toString()
}
println(ans)
}
fun getInputPair(fileName: String): Pair<List<Stack<Char>>, List<Triple<Int, Int, Int>>> {
val fileInput = File(fileName).readText().split("\n\n")
val other = fileInput[1].split("\n")
val inputs = other.map {
val words = it.split(" ")
Triple(words[1].toInt(), words[3].toInt(), words[5].toInt())
}
val matrix = fileInput.first()
var str = ""
matrix.forEachIndexed { i, c ->
if (i % 4 == 0) {
str += "["
} else if (i % 2 == 0) {
str += "]"
} else {
str += c
}
}
val lets = str.replace("[ ]", "-").replace("[", "").replace("]", "").replace(" ", "").split("\n").map {
it.split("").filter { it.isNotBlank() }
}
val length = lets.last().size
val letters = lets.dropLast(1)
val stacks = mutableListOf<Stack<Char>>()
for (i in 0 until length) {
stacks.add(Stack())
for (j in 0 until length) {
if (letters.size > j && letters[j].size > i) letters[j][i].let {
if (it != "-") stacks[i].add(it.first())
}
}
stacks[i].reverse()
}
return Pair(stacks.toList(), inputs)
}
|
[
{
"class_path": "mrwhoknows55__advent-of-code-2022__f307e52/Day05Kt.class",
"javap": "Compiled from \"Day05.kt\"\npublic final class Day05Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String src/day05_input.txt\n 2: invokestatic #12 // Method getInputPair:(Ljava/lang/String;)Lkotlin/Pair;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #16 // Method part1:(Lkotlin/Pair;)V\n 10: return\n\n public static final void part1(kotlin.Pair<? extends java.util.List<? extends java.util.Stack<java.lang.Character>>, ? extends java.util.List<kotlin.Triple<java.lang.Integer, java.lang.Integer, java.lang.Integer>>>);\n Code:\n 0: aload_0\n 1: ldc #21 // String inputPair\n 3: invokestatic #27 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokevirtual #33 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 10: checkcast #35 // class java/util/List\n 13: astore_1\n 14: aload_0\n 15: invokevirtual #38 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 18: checkcast #35 // class java/util/List\n 21: astore_2\n 22: aload_2\n 23: checkcast #40 // class java/lang/Iterable\n 26: astore_3\n 27: iconst_0\n 28: istore 4\n 30: aload_3\n 31: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 5\n 38: aload 5\n 40: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 223\n 48: aload 5\n 50: invokeinterface #53, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 6\n 57: aload 6\n 59: checkcast #55 // class kotlin/Triple\n 62: astore 7\n 64: iconst_0\n 65: istore 8\n 67: iconst_0\n 68: istore 9\n 70: aload 7\n 72: invokevirtual #56 // Method kotlin/Triple.getFirst:()Ljava/lang/Object;\n 75: checkcast #58 // class java/lang/Number\n 78: invokevirtual #62 // Method java/lang/Number.intValue:()I\n 81: istore 10\n 83: iload 9\n 85: iload 10\n 87: if_icmpge 218\n 90: aload_1\n 91: invokeinterface #65, 1 // InterfaceMethod java/util/List.size:()I\n 96: aload 7\n 98: invokevirtual #66 // Method kotlin/Triple.getSecond:()Ljava/lang/Object;\n 101: checkcast #58 // class java/lang/Number\n 104: invokevirtual #62 // Method java/lang/Number.intValue:()I\n 107: if_icmplt 212\n 110: aload_1\n 111: aload 7\n 113: invokevirtual #66 // Method kotlin/Triple.getSecond:()Ljava/lang/Object;\n 116: checkcast #58 // class java/lang/Number\n 119: invokevirtual #62 // Method java/lang/Number.intValue:()I\n 122: iconst_1\n 123: isub\n 124: invokeinterface #70, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 129: checkcast #72 // class java/util/Stack\n 132: astore 11\n 134: aload_1\n 135: invokeinterface #65, 1 // InterfaceMethod java/util/List.size:()I\n 140: aload 7\n 142: invokevirtual #75 // Method kotlin/Triple.getThird:()Ljava/lang/Object;\n 145: checkcast #58 // class java/lang/Number\n 148: invokevirtual #62 // Method java/lang/Number.intValue:()I\n 151: if_icmplt 212\n 154: aload 11\n 156: checkcast #77 // class java/util/Collection\n 159: invokeinterface #80, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 164: ifne 171\n 167: iconst_1\n 168: goto 172\n 171: iconst_0\n 172: ifeq 212\n 175: aload_1\n 176: aload 7\n 178: invokevirtual #75 // Method kotlin/Triple.getThird:()Ljava/lang/Object;\n 181: checkcast #58 // class java/lang/Number\n 184: invokevirtual #62 // Method java/lang/Number.intValue:()I\n 187: iconst_1\n 188: isub\n 189: invokeinterface #70, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 194: checkcast #72 // class java/util/Stack\n 197: aload 11\n 199: invokevirtual #83 // Method java/util/Stack.peek:()Ljava/lang/Object;\n 202: invokevirtual #87 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 205: pop\n 206: aload 11\n 208: invokevirtual #90 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 211: pop\n 212: iinc 9, 1\n 215: goto 83\n 218: nop\n 219: nop\n 220: goto 38\n 223: nop\n 224: aload_1\n 225: checkcast #40 // class java/lang/Iterable\n 228: ldc #92 // String\n 230: checkcast #94 // class java/lang/CharSequence\n 233: aconst_null\n 234: aconst_null\n 235: iconst_0\n 236: aconst_null\n 237: invokedynamic #112, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 242: bipush 30\n 244: aconst_null\n 245: invokestatic #118 // 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 248: astore_3\n 249: getstatic #124 // Field java/lang/System.out:Ljava/io/PrintStream;\n 252: aload_3\n 253: invokevirtual #130 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 256: return\n\n public static final kotlin.Pair<java.util.List<java.util.Stack<java.lang.Character>>, java.util.List<kotlin.Triple<java.lang.Integer, java.lang.Integer, java.lang.Integer>>> getInputPair(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #150 // String fileName\n 3: invokestatic #27 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #152 // class java/io/File\n 9: dup\n 10: aload_0\n 11: invokespecial #156 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 14: aconst_null\n 15: iconst_1\n 16: aconst_null\n 17: invokestatic #162 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;\n 20: checkcast #94 // class java/lang/CharSequence\n 23: iconst_1\n 24: anewarray #164 // class java/lang/String\n 27: astore_2\n 28: aload_2\n 29: iconst_0\n 30: ldc #166 // String \\n\\n\n 32: aastore\n 33: aload_2\n 34: iconst_0\n 35: iconst_0\n 36: bipush 6\n 38: aconst_null\n 39: invokestatic #172 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 42: astore_1\n 43: aload_1\n 44: iconst_1\n 45: invokeinterface #70, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 50: checkcast #94 // class java/lang/CharSequence\n 53: iconst_1\n 54: anewarray #164 // class java/lang/String\n 57: astore_3\n 58: aload_3\n 59: iconst_0\n 60: ldc #174 // String \\n\n 62: aastore\n 63: aload_3\n 64: iconst_0\n 65: iconst_0\n 66: bipush 6\n 68: aconst_null\n 69: invokestatic #172 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 72: astore_2\n 73: aload_2\n 74: checkcast #40 // class java/lang/Iterable\n 77: astore 4\n 79: iconst_0\n 80: istore 5\n 82: aload 4\n 84: astore 6\n 86: new #176 // class java/util/ArrayList\n 89: dup\n 90: aload 4\n 92: bipush 10\n 94: invokestatic #180 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 97: invokespecial #183 // Method java/util/ArrayList.\"<init>\":(I)V\n 100: checkcast #77 // class java/util/Collection\n 103: astore 7\n 105: iconst_0\n 106: istore 8\n 108: aload 6\n 110: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 115: astore 9\n 117: aload 9\n 119: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 124: ifeq 249\n 127: aload 9\n 129: invokeinterface #53, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 134: astore 10\n 136: aload 7\n 138: aload 10\n 140: checkcast #164 // class java/lang/String\n 143: astore 11\n 145: astore 25\n 147: iconst_0\n 148: istore 12\n 150: aload 11\n 152: checkcast #94 // class java/lang/CharSequence\n 155: iconst_1\n 156: anewarray #164 // class java/lang/String\n 159: astore 13\n 161: aload 13\n 163: iconst_0\n 164: ldc #185 // String\n 166: aastore\n 167: aload 13\n 169: iconst_0\n 170: iconst_0\n 171: bipush 6\n 173: aconst_null\n 174: invokestatic #172 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 177: astore 14\n 179: new #55 // class kotlin/Triple\n 182: dup\n 183: aload 14\n 185: iconst_1\n 186: invokeinterface #70, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 191: checkcast #164 // class java/lang/String\n 194: invokestatic #191 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 197: invokestatic #195 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 200: aload 14\n 202: iconst_3\n 203: invokeinterface #70, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 208: checkcast #164 // class java/lang/String\n 211: invokestatic #191 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 214: invokestatic #195 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 217: aload 14\n 219: iconst_5\n 220: invokeinterface #70, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 225: checkcast #164 // class java/lang/String\n 228: invokestatic #191 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 231: invokestatic #195 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 234: invokespecial #198 // Method kotlin/Triple.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V\n 237: aload 25\n 239: swap\n 240: invokeinterface #202, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 245: pop\n 246: goto 117\n 249: aload 7\n 251: checkcast #35 // class java/util/List\n 254: nop\n 255: astore_3\n 256: aload_1\n 257: invokestatic #206 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 260: checkcast #164 // class java/lang/String\n 263: astore 4\n 265: aconst_null\n 266: astore 5\n 268: ldc #92 // String\n 270: astore 5\n 272: aload 4\n 274: checkcast #94 // class java/lang/CharSequence\n 277: astore 6\n 279: iconst_0\n 280: istore 7\n 282: iconst_0\n 283: istore 8\n 285: iconst_0\n 286: istore 9\n 288: iload 9\n 290: aload 6\n 292: invokeinterface #209, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 297: if_icmpge 419\n 300: aload 6\n 302: iload 9\n 304: invokeinterface #213, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 309: istore 10\n 311: iload 8\n 313: iinc 8, 1\n 316: iload 10\n 318: istore 11\n 320: istore 12\n 322: iconst_0\n 323: istore 13\n 325: iload 12\n 327: iconst_4\n 328: irem\n 329: ifne 357\n 332: new #215 // class java/lang/StringBuilder\n 335: dup\n 336: invokespecial #217 // Method java/lang/StringBuilder.\"<init>\":()V\n 339: aload 5\n 341: invokevirtual #221 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 344: bipush 91\n 346: invokevirtual #224 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 349: invokevirtual #228 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 352: astore 5\n 354: goto 411\n 357: iload 12\n 359: iconst_2\n 360: irem\n 361: ifne 389\n 364: new #215 // class java/lang/StringBuilder\n 367: dup\n 368: invokespecial #217 // Method java/lang/StringBuilder.\"<init>\":()V\n 371: aload 5\n 373: invokevirtual #221 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 376: bipush 93\n 378: invokevirtual #224 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 381: invokevirtual #228 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 384: astore 5\n 386: goto 411\n 389: new #215 // class java/lang/StringBuilder\n 392: dup\n 393: invokespecial #217 // Method java/lang/StringBuilder.\"<init>\":()V\n 396: aload 5\n 398: invokevirtual #221 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 401: iload 11\n 403: invokevirtual #224 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 406: invokevirtual #228 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 409: astore 5\n 411: nop\n 412: nop\n 413: iinc 9, 1\n 416: goto 288\n 419: nop\n 420: aload 5\n 422: ldc #230 // String [ ]\n 424: ldc #232 // String -\n 426: iconst_0\n 427: iconst_4\n 428: aconst_null\n 429: invokestatic #236 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 432: ldc #238 // String [\n 434: ldc #92 // String\n 436: iconst_0\n 437: iconst_4\n 438: aconst_null\n 439: invokestatic #236 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 442: ldc #240 // String ]\n 444: ldc #92 // String\n 446: iconst_0\n 447: iconst_4\n 448: aconst_null\n 449: invokestatic #236 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 452: ldc #185 // String\n 454: ldc #92 // String\n 456: iconst_0\n 457: iconst_4\n 458: aconst_null\n 459: invokestatic #236 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 462: checkcast #94 // class java/lang/CharSequence\n 465: iconst_1\n 466: anewarray #164 // class java/lang/String\n 469: astore 7\n 471: aload 7\n 473: iconst_0\n 474: ldc #174 // String \\n\n 476: aastore\n 477: aload 7\n 479: iconst_0\n 480: iconst_0\n 481: bipush 6\n 483: aconst_null\n 484: invokestatic #172 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 487: checkcast #40 // class java/lang/Iterable\n 490: astore 7\n 492: iconst_0\n 493: istore 8\n 495: aload 7\n 497: astore 9\n 499: new #176 // class java/util/ArrayList\n 502: dup\n 503: aload 7\n 505: bipush 10\n 507: invokestatic #180 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 510: invokespecial #183 // Method java/util/ArrayList.\"<init>\":(I)V\n 513: checkcast #77 // class java/util/Collection\n 516: astore 10\n 518: iconst_0\n 519: istore 11\n 521: aload 9\n 523: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 528: astore 12\n 530: aload 12\n 532: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 537: ifeq 707\n 540: aload 12\n 542: invokeinterface #53, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 547: astore 13\n 549: aload 10\n 551: aload 13\n 553: checkcast #164 // class java/lang/String\n 556: astore 14\n 558: astore 25\n 560: iconst_0\n 561: istore 15\n 563: aload 14\n 565: checkcast #94 // class java/lang/CharSequence\n 568: iconst_1\n 569: anewarray #164 // class java/lang/String\n 572: astore 16\n 574: aload 16\n 576: iconst_0\n 577: ldc #92 // String\n 579: aastore\n 580: aload 16\n 582: iconst_0\n 583: iconst_0\n 584: bipush 6\n 586: aconst_null\n 587: invokestatic #172 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 590: checkcast #40 // class java/lang/Iterable\n 593: astore 16\n 595: iconst_0\n 596: istore 17\n 598: aload 16\n 600: astore 18\n 602: new #176 // class java/util/ArrayList\n 605: dup\n 606: invokespecial #241 // Method java/util/ArrayList.\"<init>\":()V\n 609: checkcast #77 // class java/util/Collection\n 612: astore 19\n 614: iconst_0\n 615: istore 20\n 617: aload 18\n 619: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 624: astore 21\n 626: aload 21\n 628: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 633: ifeq 688\n 636: aload 21\n 638: invokeinterface #53, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 643: astore 22\n 645: aload 22\n 647: checkcast #164 // class java/lang/String\n 650: astore 23\n 652: iconst_0\n 653: istore 24\n 655: aload 23\n 657: checkcast #94 // class java/lang/CharSequence\n 660: invokestatic #245 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 663: ifne 670\n 666: iconst_1\n 667: goto 671\n 670: iconst_0\n 671: nop\n 672: ifeq 626\n 675: aload 19\n 677: aload 22\n 679: invokeinterface #202, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 684: pop\n 685: goto 626\n 688: aload 19\n 690: checkcast #35 // class java/util/List\n 693: nop\n 694: nop\n 695: aload 25\n 697: swap\n 698: invokeinterface #202, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 703: pop\n 704: goto 530\n 707: aload 10\n 709: checkcast #35 // class java/util/List\n 712: nop\n 713: astore 6\n 715: aload 6\n 717: invokestatic #248 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 720: checkcast #35 // class java/util/List\n 723: invokeinterface #65, 1 // InterfaceMethod java/util/List.size:()I\n 728: istore 7\n 730: aload 6\n 732: iconst_1\n 733: invokestatic #252 // Method kotlin/collections/CollectionsKt.dropLast:(Ljava/util/List;I)Ljava/util/List;\n 736: astore 8\n 738: new #176 // class java/util/ArrayList\n 741: dup\n 742: invokespecial #241 // Method java/util/ArrayList.\"<init>\":()V\n 745: checkcast #35 // class java/util/List\n 748: astore 9\n 750: iconst_0\n 751: istore 10\n 753: iload 10\n 755: iload 7\n 757: if_icmpge 912\n 760: aload 9\n 762: new #72 // class java/util/Stack\n 765: dup\n 766: invokespecial #253 // Method java/util/Stack.\"<init>\":()V\n 769: invokeinterface #254, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 774: pop\n 775: iconst_0\n 776: istore 11\n 778: iload 11\n 780: iload 7\n 782: if_icmpge 891\n 785: aload 8\n 787: invokeinterface #65, 1 // InterfaceMethod java/util/List.size:()I\n 792: iload 11\n 794: if_icmple 885\n 797: aload 8\n 799: iload 11\n 801: invokeinterface #70, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 806: checkcast #35 // class java/util/List\n 809: invokeinterface #65, 1 // InterfaceMethod java/util/List.size:()I\n 814: iload 10\n 816: if_icmple 885\n 819: aload 8\n 821: iload 11\n 823: invokeinterface #70, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 828: checkcast #35 // class java/util/List\n 831: iload 10\n 833: invokeinterface #70, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 838: checkcast #164 // class java/lang/String\n 841: astore 13\n 843: iconst_0\n 844: istore 14\n 846: aload 13\n 848: ldc #232 // String -\n 850: invokestatic #258 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 853: ifne 883\n 856: aload 9\n 858: iload 10\n 860: invokeinterface #70, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 865: checkcast #72 // class java/util/Stack\n 868: aload 13\n 870: checkcast #94 // class java/lang/CharSequence\n 873: invokestatic #261 // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C\n 876: invokestatic #266 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 879: invokevirtual #267 // Method java/util/Stack.add:(Ljava/lang/Object;)Z\n 882: pop\n 883: nop\n 884: nop\n 885: iinc 11, 1\n 888: goto 778\n 891: aload 9\n 893: iload 10\n 895: invokeinterface #70, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 900: checkcast #35 // class java/util/List\n 903: invokestatic #271 // Method kotlin/collections/CollectionsKt.reverse:(Ljava/util/List;)V\n 906: iinc 10, 1\n 909: goto 753\n 912: new #29 // class kotlin/Pair\n 915: dup\n 916: aload 9\n 918: checkcast #40 // class java/lang/Iterable\n 921: invokestatic #275 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 924: aload_3\n 925: invokespecial #278 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 928: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #315 // Method main:()V\n 3: return\n\n private static final java.lang.CharSequence part1$lambda$1(java.util.Stack);\n Code:\n 0: aload_0\n 1: ldc_w #317 // String it\n 4: invokestatic #27 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokevirtual #83 // Method java/util/Stack.peek:()Ljava/lang/Object;\n 11: checkcast #263 // class java/lang/Character\n 14: invokevirtual #318 // Method java/lang/Character.toString:()Ljava/lang/String;\n 17: checkcast #94 // class java/lang/CharSequence\n 20: areturn\n}\n",
"javap_err": ""
}
] |
mrwhoknows55__advent-of-code-2022__f307e52/src/Day02.kt
|
import java.io.File
fun main() {
val input = File("src/day02_input.txt").readText().split("\n")
println(part1(input))
println(part2(input))
}
fun part1(input: List<String>): Int {
var score = 0
input.forEach {
val oppMove = Move.getMoveObj(it[0]) ?: return@part1 (score)
val myMove = Move.getMoveObj(it[2]) ?: return@part1 (score)
score += myMove.score
when {
myMove.winsTo == oppMove.score -> score += 6
myMove.score == oppMove.score -> score += 3
myMove.losesTo == oppMove.score -> score += 0
}
}
return score
}
fun part2(input: List<String>): Int {
var score = 0
input.forEach {
val oppMove = Move.getMoveObj(it[0]) ?: return@part2 (score)
val myMove = Move.getMoveObj(it[2]) ?: return@part2 (score)
when (myMove) {
is Move.Rock -> {
score += oppMove.winsTo
score += 0
}
is Move.Paper -> {
score += oppMove.score
score += 3
}
is Move.Scissors -> {
score += oppMove.losesTo
score += 6
}
}
}
return score
}
sealed class Move(
val score: Int,
val winsTo: Int,
val losesTo: Int,
) {
object Rock : Move(1, 3, 2)
object Paper : Move(2, 1, 3)
object Scissors : Move(3, 2, 1)
companion object {
fun getMoveObj(moveChar: Char): Move? {
return when (moveChar) {
'A' -> Rock
'X' -> Rock
'B' -> Paper
'Y' -> Paper
'C' -> Scissors
'Z' -> Scissors
else -> null
}
}
}
}
|
[
{
"class_path": "mrwhoknows55__advent-of-code-2022__f307e52/Day02Kt.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class Day02Kt {\n public static final void main();\n Code:\n 0: new #8 // class java/io/File\n 3: dup\n 4: ldc #10 // String src/day02_input.txt\n 6: invokespecial #14 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: aconst_null\n 10: iconst_1\n 11: aconst_null\n 12: invokestatic #20 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;\n 15: checkcast #22 // class java/lang/CharSequence\n 18: iconst_1\n 19: anewarray #24 // class java/lang/String\n 22: astore_1\n 23: aload_1\n 24: iconst_0\n 25: ldc #26 // String \\n\n 27: aastore\n 28: aload_1\n 29: iconst_0\n 30: iconst_0\n 31: bipush 6\n 33: aconst_null\n 34: invokestatic #32 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 37: astore_0\n 38: aload_0\n 39: invokestatic #36 // Method part1:(Ljava/util/List;)I\n 42: istore_1\n 43: getstatic #42 // Field java/lang/System.out:Ljava/io/PrintStream;\n 46: iload_1\n 47: invokevirtual #48 // Method java/io/PrintStream.println:(I)V\n 50: aload_0\n 51: invokestatic #51 // Method part2:(Ljava/util/List;)I\n 54: istore_1\n 55: getstatic #42 // Field java/lang/System.out:Ljava/io/PrintStream;\n 58: iload_1\n 59: invokevirtual #48 // Method java/io/PrintStream.println:(I)V\n 62: return\n\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #56 // String input\n 3: invokestatic #62 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_1\n 8: aload_0\n 9: checkcast #64 // class java/lang/Iterable\n 12: astore_2\n 13: iconst_0\n 14: istore_3\n 15: aload_2\n 16: invokeinterface #68, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 21: astore 4\n 23: aload 4\n 25: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 30: ifeq 166\n 33: aload 4\n 35: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 40: astore 5\n 42: aload 5\n 44: checkcast #24 // class java/lang/String\n 47: astore 6\n 49: iconst_0\n 50: istore 7\n 52: getstatic #84 // Field Move.Companion:LMove$Companion;\n 55: aload 6\n 57: iconst_0\n 58: invokevirtual #88 // Method java/lang/String.charAt:(I)C\n 61: invokevirtual #94 // Method Move$Companion.getMoveObj:(C)LMove;\n 64: dup\n 65: ifnonnull 71\n 68: pop\n 69: iload_1\n 70: ireturn\n 71: astore 8\n 73: getstatic #84 // Field Move.Companion:LMove$Companion;\n 76: aload 6\n 78: iconst_2\n 79: invokevirtual #88 // Method java/lang/String.charAt:(I)C\n 82: invokevirtual #94 // Method Move$Companion.getMoveObj:(C)LMove;\n 85: dup\n 86: ifnonnull 92\n 89: pop\n 90: iload_1\n 91: ireturn\n 92: astore 9\n 94: iload_1\n 95: aload 9\n 97: invokevirtual #98 // Method Move.getScore:()I\n 100: iadd\n 101: istore_1\n 102: nop\n 103: aload 9\n 105: invokevirtual #101 // Method Move.getWinsTo:()I\n 108: aload 8\n 110: invokevirtual #98 // Method Move.getScore:()I\n 113: if_icmpne 124\n 116: iload_1\n 117: bipush 6\n 119: iadd\n 120: istore_1\n 121: goto 161\n 124: aload 9\n 126: invokevirtual #98 // Method Move.getScore:()I\n 129: aload 8\n 131: invokevirtual #98 // Method Move.getScore:()I\n 134: if_icmpne 144\n 137: iload_1\n 138: iconst_3\n 139: iadd\n 140: istore_1\n 141: goto 161\n 144: aload 9\n 146: invokevirtual #104 // Method Move.getLosesTo:()I\n 149: aload 8\n 151: invokevirtual #98 // Method Move.getScore:()I\n 154: if_icmpne 161\n 157: iload_1\n 158: iconst_0\n 159: iadd\n 160: istore_1\n 161: nop\n 162: nop\n 163: goto 23\n 166: nop\n 167: iload_1\n 168: ireturn\n\n public static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #56 // String input\n 3: invokestatic #62 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_1\n 8: aload_0\n 9: checkcast #64 // class java/lang/Iterable\n 12: astore_2\n 13: iconst_0\n 14: istore_3\n 15: aload_2\n 16: invokeinterface #68, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 21: astore 4\n 23: aload 4\n 25: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 30: ifeq 181\n 33: aload 4\n 35: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 40: astore 5\n 42: aload 5\n 44: checkcast #24 // class java/lang/String\n 47: astore 6\n 49: iconst_0\n 50: istore 7\n 52: getstatic #84 // Field Move.Companion:LMove$Companion;\n 55: aload 6\n 57: iconst_0\n 58: invokevirtual #88 // Method java/lang/String.charAt:(I)C\n 61: invokevirtual #94 // Method Move$Companion.getMoveObj:(C)LMove;\n 64: dup\n 65: ifnonnull 71\n 68: pop\n 69: iload_1\n 70: ireturn\n 71: astore 8\n 73: getstatic #84 // Field Move.Companion:LMove$Companion;\n 76: aload 6\n 78: iconst_2\n 79: invokevirtual #88 // Method java/lang/String.charAt:(I)C\n 82: invokevirtual #94 // Method Move$Companion.getMoveObj:(C)LMove;\n 85: dup\n 86: ifnonnull 92\n 89: pop\n 90: iload_1\n 91: ireturn\n 92: astore 9\n 94: aload 9\n 96: astore 10\n 98: aload 10\n 100: instanceof #121 // class Move$Rock\n 103: ifeq 121\n 106: iload_1\n 107: aload 8\n 109: invokevirtual #101 // Method Move.getWinsTo:()I\n 112: iadd\n 113: istore_1\n 114: iload_1\n 115: iconst_0\n 116: iadd\n 117: istore_1\n 118: goto 176\n 121: aload 10\n 123: instanceof #123 // class Move$Paper\n 126: ifeq 144\n 129: iload_1\n 130: aload 8\n 132: invokevirtual #98 // Method Move.getScore:()I\n 135: iadd\n 136: istore_1\n 137: iload_1\n 138: iconst_3\n 139: iadd\n 140: istore_1\n 141: goto 176\n 144: aload 10\n 146: instanceof #125 // class Move$Scissors\n 149: ifeq 168\n 152: iload_1\n 153: aload 8\n 155: invokevirtual #104 // Method Move.getLosesTo:()I\n 158: iadd\n 159: istore_1\n 160: iload_1\n 161: bipush 6\n 163: iadd\n 164: istore_1\n 165: goto 176\n 168: new #127 // class kotlin/NoWhenBranchMatchedException\n 171: dup\n 172: invokespecial #129 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 175: athrow\n 176: nop\n 177: nop\n 178: goto 23\n 181: nop\n 182: iload_1\n 183: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #133 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
BjornvdLaan__KotlinTestApproachExamples__c6d895d/src/main/kotlin/SimplifySquareRootBigDecimal.kt
|
import java.math.BigInteger
/**
* Square root with its coefficient.
*
* Definitions: a square root is of form 'coefficient * sqrt(radicand)'.
* In other words, the coefficient is outside the square root
* and the radicand in inside the square root.
*
* @property coefficient number in front of the radical ('root') sign.
* @property radicand number inside the radical ('root') sign.
*/
data class SquareRootBI(val coefficient: BigInteger, val radicand: BigInteger)
/**
* Simplifies the square root and makes radicand as small as possible.
*
*
* @param squareRoot the square root to simplify.
* @return the simplified square root.
*/
fun simplifySquareRoot(squareRoot: SquareRootBI): SquareRootBI =
if (squareRoot.radicand < BigInteger.ZERO) throw IllegalArgumentException("Radicand cannot be negative")
else if (squareRoot.radicand == BigInteger.ZERO) SquareRootBI(BigInteger.ZERO, BigInteger.ZERO)
else if (squareRoot.radicand == BigInteger.ONE) SquareRootBI(squareRoot.coefficient, BigInteger.ONE)
else {
val decreasingSequence = sequence {
// We can start at sqrt(radicand) because radicand is
// never divisible without remainder by anything greater than i = sqrt(radicand)
// This optimization is applied because tests are otherwise very very slow.
var bi = squareRoot.radicand.sqrt()
while (bi > BigInteger.ONE) {
yield(bi)
bi = bi.subtract(BigInteger.ONE)
}
}
decreasingSequence
.fold(squareRoot) { simplifiedSquareRoot, i ->
run {
if (simplifiedSquareRoot.radicand.mod(i.pow(2)) == BigInteger.ZERO) {
SquareRootBI(
simplifiedSquareRoot.coefficient.times(i),
simplifiedSquareRoot.radicand.div(i.pow(2))
)
} else {
simplifiedSquareRoot
}
}
}
}
|
[
{
"class_path": "BjornvdLaan__KotlinTestApproachExamples__c6d895d/SimplifySquareRootBigDecimalKt$simplifySquareRoot$decreasingSequence$1.class",
"javap": "Compiled from \"SimplifySquareRootBigDecimal.kt\"\nfinal class SimplifySquareRootBigDecimalKt$simplifySquareRoot$decreasingSequence$1 extends kotlin.coroutines.jvm.internal.RestrictedSuspendLambda implements kotlin.jvm.functions.Function2<kotlin.sequences.SequenceScope<? super java.math.BigInteger>, kotlin.coroutines.Continuation<? super kotlin.Unit>, java.lang.Object> {\n java.lang.Object L$1;\n\n int label;\n\n private java.lang.Object L$0;\n\n final SquareRootBI $squareRoot;\n\n SimplifySquareRootBigDecimalKt$simplifySquareRoot$decreasingSequence$1(SquareRootBI, kotlin.coroutines.Continuation<? super SimplifySquareRootBigDecimalKt$simplifySquareRoot$decreasingSequence$1>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: putfield #14 // Field $squareRoot:LSquareRootBI;\n 5: aload_0\n 6: iconst_2\n 7: aload_2\n 8: invokespecial #17 // Method kotlin/coroutines/jvm/internal/RestrictedSuspendLambda.\"<init>\":(ILkotlin/coroutines/Continuation;)V\n 11: return\n\n public final java.lang.Object invokeSuspend(java.lang.Object);\n Code:\n 0: invokestatic #45 // Method kotlin/coroutines/intrinsics/IntrinsicsKt.getCOROUTINE_SUSPENDED:()Ljava/lang/Object;\n 3: astore 4\n 5: aload_0\n 6: getfield #49 // Field label:I\n 9: tableswitch { // 0 to 1\n 0: 32\n 1: 98\n default: 135\n }\n 32: aload_1\n 33: invokestatic #55 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V\n 36: aload_0\n 37: getfield #57 // Field L$0:Ljava/lang/Object;\n 40: checkcast #59 // class kotlin/sequences/SequenceScope\n 43: astore_2\n 44: aload_0\n 45: getfield #14 // Field $squareRoot:LSquareRootBI;\n 48: invokevirtual #65 // Method SquareRootBI.getRadicand:()Ljava/math/BigInteger;\n 51: invokevirtual #70 // Method java/math/BigInteger.sqrt:()Ljava/math/BigInteger;\n 54: astore_3\n 55: aload_3\n 56: getstatic #74 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;\n 59: invokevirtual #78 // Method java/math/BigInteger.compareTo:(Ljava/math/BigInteger;)I\n 62: ifle 131\n 65: aload_2\n 66: aload_3\n 67: aload_0\n 68: checkcast #80 // class kotlin/coroutines/Continuation\n 71: aload_0\n 72: aload_2\n 73: putfield #57 // Field L$0:Ljava/lang/Object;\n 76: aload_0\n 77: aload_3\n 78: putfield #82 // Field L$1:Ljava/lang/Object;\n 81: aload_0\n 82: iconst_1\n 83: putfield #49 // Field label:I\n 86: invokevirtual #86 // Method kotlin/sequences/SequenceScope.yield:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;\n 89: dup\n 90: aload 4\n 92: if_acmpne 119\n 95: aload 4\n 97: areturn\n 98: aload_0\n 99: getfield #82 // Field L$1:Ljava/lang/Object;\n 102: checkcast #67 // class java/math/BigInteger\n 105: astore_3\n 106: aload_0\n 107: getfield #57 // Field L$0:Ljava/lang/Object;\n 110: checkcast #59 // class kotlin/sequences/SequenceScope\n 113: astore_2\n 114: aload_1\n 115: invokestatic #55 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V\n 118: aload_1\n 119: pop\n 120: aload_3\n 121: getstatic #74 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;\n 124: invokevirtual #90 // Method java/math/BigInteger.subtract:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 127: astore_3\n 128: goto 55\n 131: getstatic #96 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 134: areturn\n 135: new #98 // class java/lang/IllegalStateException\n 138: dup\n 139: ldc #100 // String call to \\'resume\\' before \\'invoke\\' with coroutine\n 141: invokespecial #103 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 144: athrow\n\n public final kotlin.coroutines.Continuation<kotlin.Unit> create(java.lang.Object, kotlin.coroutines.Continuation<?>);\n Code:\n 0: new #2 // class SimplifySquareRootBigDecimalKt$simplifySquareRoot$decreasingSequence$1\n 3: dup\n 4: aload_0\n 5: getfield #14 // Field $squareRoot:LSquareRootBI;\n 8: aload_2\n 9: invokespecial #112 // Method \"<init>\":(LSquareRootBI;Lkotlin/coroutines/Continuation;)V\n 12: astore_3\n 13: aload_3\n 14: aload_1\n 15: putfield #57 // Field L$0:Ljava/lang/Object;\n 18: aload_3\n 19: checkcast #80 // class kotlin/coroutines/Continuation\n 22: areturn\n\n public final java.lang.Object invoke(kotlin.sequences.SequenceScope<? super java.math.BigInteger>, kotlin.coroutines.Continuation<? super kotlin.Unit>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: aload_2\n 3: invokevirtual #118 // Method create:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Lkotlin/coroutines/Continuation;\n 6: checkcast #2 // class SimplifySquareRootBigDecimalKt$simplifySquareRoot$decreasingSequence$1\n 9: getstatic #96 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 12: invokevirtual #120 // Method invokeSuspend:(Ljava/lang/Object;)Ljava/lang/Object;\n 15: areturn\n\n public java.lang.Object invoke(java.lang.Object, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #59 // class kotlin/sequences/SequenceScope\n 5: aload_2\n 6: checkcast #80 // class kotlin/coroutines/Continuation\n 9: invokevirtual #125 // Method invoke:(Lkotlin/sequences/SequenceScope;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;\n 12: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "BjornvdLaan__KotlinTestApproachExamples__c6d895d/SimplifySquareRootBigDecimalKt.class",
"javap": "Compiled from \"SimplifySquareRootBigDecimal.kt\"\npublic final class SimplifySquareRootBigDecimalKt {\n public static final SquareRootBI simplifySquareRoot(SquareRootBI);\n Code:\n 0: aload_0\n 1: ldc #9 // String squareRoot\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokevirtual #21 // Method SquareRootBI.getRadicand:()Ljava/math/BigInteger;\n 10: getstatic #27 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;\n 13: invokevirtual #31 // Method java/math/BigInteger.compareTo:(Ljava/math/BigInteger;)I\n 16: ifge 29\n 19: new #33 // class java/lang/IllegalArgumentException\n 22: dup\n 23: ldc #35 // String Radicand cannot be negative\n 25: invokespecial #39 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 28: athrow\n 29: aload_0\n 30: invokevirtual #21 // Method SquareRootBI.getRadicand:()Ljava/math/BigInteger;\n 33: getstatic #27 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;\n 36: invokestatic #43 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 39: ifeq 70\n 42: new #17 // class SquareRootBI\n 45: dup\n 46: getstatic #27 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;\n 49: dup\n 50: ldc #44 // String ZERO\n 52: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 55: getstatic #27 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;\n 58: dup\n 59: ldc #44 // String ZERO\n 61: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 64: invokespecial #50 // Method SquareRootBI.\"<init>\":(Ljava/math/BigInteger;Ljava/math/BigInteger;)V\n 67: goto 271\n 70: aload_0\n 71: invokevirtual #21 // Method SquareRootBI.getRadicand:()Ljava/math/BigInteger;\n 74: getstatic #53 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;\n 77: invokestatic #43 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 80: ifeq 106\n 83: new #17 // class SquareRootBI\n 86: dup\n 87: aload_0\n 88: invokevirtual #56 // Method SquareRootBI.getCoefficient:()Ljava/math/BigInteger;\n 91: getstatic #53 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;\n 94: dup\n 95: ldc #57 // String ONE\n 97: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 100: invokespecial #50 // Method SquareRootBI.\"<init>\":(Ljava/math/BigInteger;Ljava/math/BigInteger;)V\n 103: goto 271\n 106: new #59 // class SimplifySquareRootBigDecimalKt$simplifySquareRoot$decreasingSequence$1\n 109: dup\n 110: aload_0\n 111: aconst_null\n 112: invokespecial #62 // Method SimplifySquareRootBigDecimalKt$simplifySquareRoot$decreasingSequence$1.\"<init>\":(LSquareRootBI;Lkotlin/coroutines/Continuation;)V\n 115: checkcast #64 // class kotlin/jvm/functions/Function2\n 118: invokestatic #70 // Method kotlin/sequences/SequencesKt.sequence:(Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;\n 121: astore_1\n 122: aload_1\n 123: astore_2\n 124: nop\n 125: iconst_0\n 126: istore_3\n 127: aload_0\n 128: astore 4\n 130: aload_2\n 131: invokeinterface #76, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 136: astore 5\n 138: aload 5\n 140: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 145: ifeq 269\n 148: aload 5\n 150: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 155: astore 6\n 157: aload 4\n 159: aload 6\n 161: checkcast #23 // class java/math/BigInteger\n 164: astore 7\n 166: astore 8\n 168: iconst_0\n 169: istore 9\n 171: iconst_0\n 172: istore 10\n 174: aload 8\n 176: invokevirtual #21 // Method SquareRootBI.getRadicand:()Ljava/math/BigInteger;\n 179: aload 7\n 181: iconst_2\n 182: invokevirtual #90 // Method java/math/BigInteger.pow:(I)Ljava/math/BigInteger;\n 185: invokevirtual #94 // Method java/math/BigInteger.mod:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 188: getstatic #27 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;\n 191: invokestatic #43 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 194: ifeq 259\n 197: new #17 // class SquareRootBI\n 200: dup\n 201: aload 8\n 203: invokevirtual #56 // Method SquareRootBI.getCoefficient:()Ljava/math/BigInteger;\n 206: aload 7\n 208: invokestatic #98 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 211: aload 7\n 213: invokevirtual #101 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 216: dup\n 217: ldc #103 // String multiply(...)\n 219: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 222: aload 8\n 224: invokevirtual #21 // Method SquareRootBI.getRadicand:()Ljava/math/BigInteger;\n 227: astore 11\n 229: aload 7\n 231: iconst_2\n 232: invokevirtual #90 // Method java/math/BigInteger.pow:(I)Ljava/math/BigInteger;\n 235: dup\n 236: ldc #105 // String pow(...)\n 238: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 241: aload 11\n 243: swap\n 244: invokevirtual #108 // Method java/math/BigInteger.divide:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 247: dup\n 248: ldc #110 // String divide(...)\n 250: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 253: invokespecial #50 // Method SquareRootBI.\"<init>\":(Ljava/math/BigInteger;Ljava/math/BigInteger;)V\n 256: goto 261\n 259: aload 8\n 261: nop\n 262: nop\n 263: nop\n 264: astore 4\n 266: goto 138\n 269: aload 4\n 271: areturn\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem7.kt
|
import kotlin.math.floor
import kotlin.math.sqrt
import kotlin.system.measureNanoTime
/**
* 10001st prime
*
* By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
*
* What is the 10001st prime number?
*
* https://projecteuler.net/problem=7
*/
fun main() {
println(findPrime1(6))
println(findPrime(6))
val time1 = measureNanoTime {
println(findPrime1(10_001))
}
val time2 = measureNanoTime {
println(findPrime(10_001))
}
println(time1)
println(time2)
}
private fun findPrime1(n: Int): Long {
var prime = 2L
val primes = mutableListOf(prime)
while (primes.size != n) {
prime++
if (!primes.any { prime % it == 0L }) {
primes.add(prime)
}
}
return prime
}
fun findPrime(n: Int): Long {
if (n == 1) return 2
var count = 1
var candidate = 1L
do {
candidate += 2
if (isPrime(candidate)) count++
} while (count != n)
return candidate
}
fun isPrime(n: Long): Boolean {
return when {
n < 2 -> false // 1 is not prime
n < 4 -> true // 2 and 3 are prime
n % 2 == 0L -> false // all primes except 2 are odd
n < 9 -> true // we have already excluded 4. 6 and 8
n % 3 == 0L -> false
else -> { // All primes greater than 3 can be written in the form 6k+/-1.
val r = floor(sqrt(n.toDouble())).toLong()
for (f in 5L .. r step 6) {
if (n % f == 0L) return false
if (n % (f + 2) == 0L) return false
}
true
}
}
}
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem7Kt.class",
"javap": "Compiled from \"Problem7.kt\"\npublic final class Problem7Kt {\n public static final void main();\n Code:\n 0: bipush 6\n 2: invokestatic #10 // Method findPrime1:(I)J\n 5: lstore_0\n 6: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: lload_0\n 10: invokevirtual #22 // Method java/io/PrintStream.println:(J)V\n 13: bipush 6\n 15: invokestatic #25 // Method findPrime:(I)J\n 18: lstore_0\n 19: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 22: lload_0\n 23: invokevirtual #22 // Method java/io/PrintStream.println:(J)V\n 26: iconst_0\n 27: istore_2\n 28: invokestatic #29 // Method java/lang/System.nanoTime:()J\n 31: lstore_3\n 32: iconst_0\n 33: istore 5\n 35: sipush 10001\n 38: invokestatic #10 // Method findPrime1:(I)J\n 41: lstore 6\n 43: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 46: lload 6\n 48: invokevirtual #22 // Method java/io/PrintStream.println:(J)V\n 51: nop\n 52: nop\n 53: invokestatic #29 // Method java/lang/System.nanoTime:()J\n 56: lload_3\n 57: lsub\n 58: lstore_0\n 59: iconst_0\n 60: istore 4\n 62: invokestatic #29 // Method java/lang/System.nanoTime:()J\n 65: lstore 5\n 67: iconst_0\n 68: istore 7\n 70: sipush 10001\n 73: invokestatic #25 // Method findPrime:(I)J\n 76: lstore 8\n 78: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 81: lload 8\n 83: invokevirtual #22 // Method java/io/PrintStream.println:(J)V\n 86: nop\n 87: nop\n 88: invokestatic #29 // Method java/lang/System.nanoTime:()J\n 91: lload 5\n 93: lsub\n 94: lstore_2\n 95: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 98: lload_0\n 99: invokevirtual #22 // Method java/io/PrintStream.println:(J)V\n 102: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 105: lload_2\n 106: invokevirtual #22 // Method java/io/PrintStream.println:(J)V\n 109: return\n\n private static final long findPrime1(int);\n Code:\n 0: lconst_0\n 1: lstore 9\n 3: ldc2_w #38 // long 2l\n 6: lstore 9\n 8: iconst_1\n 9: anewarray #41 // class java/lang/Long\n 12: astore_2\n 13: aload_2\n 14: iconst_0\n 15: lload 9\n 17: invokestatic #45 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 20: aastore\n 21: aload_2\n 22: invokestatic #51 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 25: astore_1\n 26: aload_1\n 27: invokeinterface #57, 1 // InterfaceMethod java/util/List.size:()I\n 32: iload_0\n 33: if_icmpeq 155\n 36: lload 9\n 38: lstore_2\n 39: lload_2\n 40: lconst_1\n 41: ladd\n 42: lstore 9\n 44: aload_1\n 45: checkcast #59 // class java/lang/Iterable\n 48: astore_2\n 49: iconst_0\n 50: istore_3\n 51: aload_2\n 52: instanceof #61 // class java/util/Collection\n 55: ifeq 74\n 58: aload_2\n 59: checkcast #61 // class java/util/Collection\n 62: invokeinterface #65, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 67: ifeq 74\n 70: iconst_0\n 71: goto 137\n 74: aload_2\n 75: invokeinterface #69, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 80: astore 4\n 82: aload 4\n 84: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 89: ifeq 136\n 92: aload 4\n 94: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 99: astore 5\n 101: aload 5\n 103: checkcast #80 // class java/lang/Number\n 106: invokevirtual #83 // Method java/lang/Number.longValue:()J\n 109: lstore 6\n 111: iconst_0\n 112: istore 8\n 114: lload 9\n 116: lload 6\n 118: lrem\n 119: lconst_0\n 120: lcmp\n 121: ifne 128\n 124: iconst_1\n 125: goto 129\n 128: iconst_0\n 129: ifeq 82\n 132: iconst_1\n 133: goto 137\n 136: iconst_0\n 137: ifne 26\n 140: aload_1\n 141: lload 9\n 143: invokestatic #45 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 146: invokeinterface #87, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 151: pop\n 152: goto 26\n 155: lload 9\n 157: lreturn\n\n public static final long findPrime(int);\n Code:\n 0: iload_0\n 1: iconst_1\n 2: if_icmpne 9\n 5: ldc2_w #38 // long 2l\n 8: lreturn\n 9: iconst_1\n 10: istore_1\n 11: lconst_1\n 12: lstore_2\n 13: lload_2\n 14: iconst_2\n 15: i2l\n 16: ladd\n 17: lstore_2\n 18: lload_2\n 19: invokestatic #102 // Method isPrime:(J)Z\n 22: ifeq 28\n 25: iinc 1, 1\n 28: iload_1\n 29: iload_0\n 30: if_icmpne 13\n 33: lload_2\n 34: lreturn\n\n public static final boolean isPrime(long);\n Code:\n 0: nop\n 1: lload_0\n 2: ldc2_w #38 // long 2l\n 5: lcmp\n 6: ifge 13\n 9: iconst_0\n 10: goto 143\n 13: lload_0\n 14: ldc2_w #105 // long 4l\n 17: lcmp\n 18: ifge 25\n 21: iconst_1\n 22: goto 143\n 25: lload_0\n 26: iconst_2\n 27: i2l\n 28: lrem\n 29: lconst_0\n 30: lcmp\n 31: ifne 38\n 34: iconst_0\n 35: goto 143\n 38: lload_0\n 39: ldc2_w #107 // long 9l\n 42: lcmp\n 43: ifge 50\n 46: iconst_1\n 47: goto 143\n 50: lload_0\n 51: iconst_3\n 52: i2l\n 53: lrem\n 54: lconst_0\n 55: lcmp\n 56: ifne 63\n 59: iconst_0\n 60: goto 143\n 63: lload_0\n 64: l2d\n 65: invokestatic #114 // Method java/lang/Math.sqrt:(D)D\n 68: invokestatic #117 // Method java/lang/Math.floor:(D)D\n 71: d2l\n 72: lstore_2\n 73: ldc2_w #118 // long 5l\n 76: lstore 4\n 78: ldc2_w #118 // long 5l\n 81: lload_2\n 82: ldc2_w #120 // long 6l\n 85: invokestatic #127 // Method kotlin/internal/ProgressionUtilKt.getProgressionLastElement:(JJJ)J\n 88: lstore 6\n 90: lload 4\n 92: lload 6\n 94: lcmp\n 95: ifgt 142\n 98: lload_0\n 99: lload 4\n 101: lrem\n 102: lconst_0\n 103: lcmp\n 104: ifne 109\n 107: iconst_0\n 108: ireturn\n 109: lload_0\n 110: lload 4\n 112: iconst_2\n 113: i2l\n 114: ladd\n 115: lrem\n 116: lconst_0\n 117: lcmp\n 118: ifne 123\n 121: iconst_0\n 122: ireturn\n 123: lload 4\n 125: lload 6\n 127: lcmp\n 128: ifeq 142\n 131: lload 4\n 133: ldc2_w #120 // long 6l\n 136: ladd\n 137: lstore 4\n 139: goto 98\n 142: iconst_1\n 143: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #132 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem21.kt
|
import kotlin.math.floor
import kotlin.math.sqrt
/**
* Amicable numbers
*
* Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
* If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable
* numbers.
*
* For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284. The
* proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220.
*
* Evaluate the sum of all the amicable numbers under 10000.
*
* https://projecteuler.net/problem=21
*/
fun main() {
println(220.sumOfProperDivisors())
println(284.sumOfProperDivisors())
println(sumOfAmicables(10_000))
}
private fun sumOfAmicables(n: Int): Int {
var sum = 0
val amicables = mutableSetOf<Int>()
for (a in 2 until n) {
if (a in amicables) continue
val b = a.sumOfProperDivisors()
if (b > a && a == b.sumOfProperDivisors()) {
sum += a + b
amicables.add(b)
}
}
return sum
}
fun Int.sumOfProperDivisors(): Int {
var sum = 1
var start = 2
var step = 1
var r = floor(sqrt(toDouble())).toInt()
if (r * r == this) {
sum += r
r--
}
if (this % 2 != 0) {
start = 3
step = 2
}
for (i in start..r step step) {
if (this % i == 0) {
sum += i + (this / i)
}
}
return sum
}
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem21Kt.class",
"javap": "Compiled from \"Problem21.kt\"\npublic final class Problem21Kt {\n public static final void main();\n Code:\n 0: sipush 220\n 3: invokestatic #10 // Method sumOfProperDivisors:(I)I\n 6: istore_0\n 7: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 10: iload_0\n 11: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 14: sipush 284\n 17: invokestatic #10 // Method sumOfProperDivisors:(I)I\n 20: istore_0\n 21: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 24: iload_0\n 25: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 28: sipush 10000\n 31: invokestatic #25 // Method sumOfAmicables:(I)I\n 34: istore_0\n 35: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 38: iload_0\n 39: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 42: return\n\n private static final int sumOfAmicables(int);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: new #27 // class java/util/LinkedHashSet\n 5: dup\n 6: invokespecial #30 // Method java/util/LinkedHashSet.\"<init>\":()V\n 9: checkcast #32 // class java/util/Set\n 12: astore_2\n 13: iconst_2\n 14: istore_3\n 15: iload_3\n 16: iload_0\n 17: if_icmpge 79\n 20: aload_2\n 21: iload_3\n 22: invokestatic #38 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 25: invokeinterface #42, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 30: ifne 73\n 33: iload_3\n 34: invokestatic #10 // Method sumOfProperDivisors:(I)I\n 37: istore 4\n 39: iload 4\n 41: iload_3\n 42: if_icmple 73\n 45: iload_3\n 46: iload 4\n 48: invokestatic #10 // Method sumOfProperDivisors:(I)I\n 51: if_icmpne 73\n 54: iload_1\n 55: iload_3\n 56: iload 4\n 58: iadd\n 59: iadd\n 60: istore_1\n 61: aload_2\n 62: iload 4\n 64: invokestatic #38 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 67: invokeinterface #45, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 72: pop\n 73: iinc 3, 1\n 76: goto 15\n 79: iload_1\n 80: ireturn\n\n public static final int sumOfProperDivisors(int);\n Code:\n 0: iconst_1\n 1: istore_1\n 2: iconst_2\n 3: istore_2\n 4: iconst_1\n 5: istore_3\n 6: iload_0\n 7: i2d\n 8: invokestatic #58 // Method java/lang/Math.sqrt:(D)D\n 11: invokestatic #61 // Method java/lang/Math.floor:(D)D\n 14: d2i\n 15: istore 4\n 17: iload 4\n 19: iload 4\n 21: imul\n 22: iload_0\n 23: if_icmpne 34\n 26: iload_1\n 27: iload 4\n 29: iadd\n 30: istore_1\n 31: iinc 4, -1\n 34: iload_0\n 35: iconst_2\n 36: irem\n 37: ifeq 44\n 40: iconst_3\n 41: istore_2\n 42: iconst_2\n 43: istore_3\n 44: iload_2\n 45: istore 5\n 47: iload 4\n 49: istore 6\n 51: iload_3\n 52: istore 7\n 54: iload 7\n 56: ifgt 92\n 59: new #63 // class java/lang/IllegalArgumentException\n 62: dup\n 63: new #65 // class java/lang/StringBuilder\n 66: dup\n 67: invokespecial #66 // Method java/lang/StringBuilder.\"<init>\":()V\n 70: ldc #68 // String Step must be positive, was:\n 72: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 75: iload 7\n 77: invokevirtual #75 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 80: bipush 46\n 82: invokevirtual #78 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 85: invokevirtual #82 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 88: invokespecial #85 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 91: athrow\n 92: iload 5\n 94: istore 8\n 96: iload 5\n 98: iload 6\n 100: iload 7\n 102: invokestatic #91 // Method kotlin/internal/ProgressionUtilKt.getProgressionLastElement:(III)I\n 105: istore 9\n 107: iload 7\n 109: istore 10\n 111: iload 8\n 113: iload 9\n 115: if_icmpgt 152\n 118: iload_0\n 119: iload 8\n 121: irem\n 122: ifne 135\n 125: iload_1\n 126: iload 8\n 128: iload_0\n 129: iload 8\n 131: idiv\n 132: iadd\n 133: iadd\n 134: istore_1\n 135: iload 8\n 137: iload 9\n 139: if_icmpeq 152\n 142: iload 8\n 144: iload 10\n 146: iadd\n 147: istore 8\n 149: goto 118\n 152: iload_1\n 153: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #99 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem10.kt
|
import kotlin.math.floor
import kotlin.math.sqrt
import kotlin.system.measureNanoTime
/**
* Summation of primes
*
* The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
* Find the sum of all the primes below two million.
*
* https://projecteuler.net/problem=10
*/
fun main() {
println(sumOfPrimes(10))
println(sumOfPrimesSieve(10))
val time1 = measureNanoTime { println(sumOfPrimes(2_000_000)) }
val time2 = measureNanoTime { println(sumOfPrimesSieve(2_000_000)) }
println(time1)
println(time2)
}
private fun sumOfPrimes(n: Long): Long {
if (n < 2) return 0
return (3..n step 2).asSequence()
.filter(::isPrime)
.sum() + 2
}
private fun sumOfPrimesSieve(n: Long): Long {
return primes(n).sumOf(Int::toLong)
}
// The sieve of Eratosthenes optimized
fun primes(n: Long): List<Int> {
val sieveBound = ((n - 1) / 2).toInt()
val sieve = Array(sieveBound) { true }
val crosslimit = (floor(sqrt(n.toDouble())).toInt() - 1) / 2
for (i in 1..crosslimit) {
if (!sieve[i-1]) continue
for (j in (2 * i * (i + 1)) .. sieveBound step 2 * i + 1) {
sieve[j-1] = false
}
}
return listOf(2) + sieve.mapIndexedNotNull { i, isPrime -> if (isPrime) 2 * (i + 1) + 1 else null }
}
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem10Kt$sumOfPrimes$1.class",
"javap": "Compiled from \"Problem10.kt\"\nfinal class Problem10Kt$sumOfPrimes$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.Long, java.lang.Boolean> {\n public static final Problem10Kt$sumOfPrimes$1 INSTANCE;\n\n Problem10Kt$sumOfPrimes$1();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class Problem7Kt\n 4: ldc #13 // String isPrime\n 6: ldc #15 // String isPrime(J)Z\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final java.lang.Boolean invoke(long);\n Code:\n 0: lload_1\n 1: invokestatic #25 // Method Problem7Kt.isPrime:(J)Z\n 4: invokestatic #31 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 7: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #36 // class java/lang/Number\n 5: invokevirtual #40 // Method java/lang/Number.longValue:()J\n 8: invokevirtual #42 // Method invoke:(J)Ljava/lang/Boolean;\n 11: areturn\n\n static {};\n Code:\n 0: new #2 // class Problem10Kt$sumOfPrimes$1\n 3: dup\n 4: invokespecial #47 // Method \"<init>\":()V\n 7: putstatic #50 // Field INSTANCE:LProblem10Kt$sumOfPrimes$1;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "jimmymorales__project-euler__e881cad/Problem10Kt.class",
"javap": "Compiled from \"Problem10.kt\"\npublic final class Problem10Kt {\n public static final void main();\n Code:\n 0: ldc2_w #7 // long 10l\n 3: invokestatic #12 // Method sumOfPrimes:(J)J\n 6: lstore_0\n 7: getstatic #18 // Field java/lang/System.out:Ljava/io/PrintStream;\n 10: lload_0\n 11: invokevirtual #24 // Method java/io/PrintStream.println:(J)V\n 14: ldc2_w #7 // long 10l\n 17: invokestatic #27 // Method sumOfPrimesSieve:(J)J\n 20: lstore_0\n 21: getstatic #18 // Field java/lang/System.out:Ljava/io/PrintStream;\n 24: lload_0\n 25: invokevirtual #24 // Method java/io/PrintStream.println:(J)V\n 28: iconst_0\n 29: istore_2\n 30: invokestatic #31 // Method java/lang/System.nanoTime:()J\n 33: lstore_3\n 34: iconst_0\n 35: istore 5\n 37: ldc2_w #32 // long 2000000l\n 40: invokestatic #12 // Method sumOfPrimes:(J)J\n 43: lstore 6\n 45: getstatic #18 // Field java/lang/System.out:Ljava/io/PrintStream;\n 48: lload 6\n 50: invokevirtual #24 // Method java/io/PrintStream.println:(J)V\n 53: nop\n 54: nop\n 55: invokestatic #31 // Method java/lang/System.nanoTime:()J\n 58: lload_3\n 59: lsub\n 60: lstore_0\n 61: iconst_0\n 62: istore 4\n 64: invokestatic #31 // Method java/lang/System.nanoTime:()J\n 67: lstore 5\n 69: iconst_0\n 70: istore 7\n 72: ldc2_w #32 // long 2000000l\n 75: invokestatic #27 // Method sumOfPrimesSieve:(J)J\n 78: lstore 8\n 80: getstatic #18 // Field java/lang/System.out:Ljava/io/PrintStream;\n 83: lload 8\n 85: invokevirtual #24 // Method java/io/PrintStream.println:(J)V\n 88: nop\n 89: nop\n 90: invokestatic #31 // Method java/lang/System.nanoTime:()J\n 93: lload 5\n 95: lsub\n 96: lstore_2\n 97: getstatic #18 // Field java/lang/System.out:Ljava/io/PrintStream;\n 100: lload_0\n 101: invokevirtual #24 // Method java/io/PrintStream.println:(J)V\n 104: getstatic #18 // Field java/lang/System.out:Ljava/io/PrintStream;\n 107: lload_2\n 108: invokevirtual #24 // Method java/io/PrintStream.println:(J)V\n 111: return\n\n private static final long sumOfPrimes(long);\n Code:\n 0: lload_0\n 1: ldc2_w #42 // long 2l\n 4: lcmp\n 5: ifge 10\n 8: lconst_0\n 9: lreturn\n 10: new #45 // class kotlin/ranges/LongRange\n 13: dup\n 14: iconst_3\n 15: i2l\n 16: lload_0\n 17: invokespecial #49 // Method kotlin/ranges/LongRange.\"<init>\":(JJ)V\n 20: checkcast #51 // class kotlin/ranges/LongProgression\n 23: ldc2_w #42 // long 2l\n 26: invokestatic #57 // Method kotlin/ranges/RangesKt.step:(Lkotlin/ranges/LongProgression;J)Lkotlin/ranges/LongProgression;\n 29: checkcast #59 // class java/lang/Iterable\n 32: invokestatic #65 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 35: getstatic #71 // Field Problem10Kt$sumOfPrimes$1.INSTANCE:LProblem10Kt$sumOfPrimes$1;\n 38: checkcast #73 // class kotlin/jvm/functions/Function1\n 41: invokestatic #79 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 44: invokestatic #83 // Method kotlin/sequences/SequencesKt.sumOfLong:(Lkotlin/sequences/Sequence;)J\n 47: iconst_2\n 48: i2l\n 49: ladd\n 50: lreturn\n\n private static final long sumOfPrimesSieve(long);\n Code:\n 0: lload_0\n 1: invokestatic #88 // Method primes:(J)Ljava/util/List;\n 4: checkcast #59 // class java/lang/Iterable\n 7: astore_2\n 8: lconst_0\n 9: lstore_3\n 10: aload_2\n 11: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 16: astore 5\n 18: aload 5\n 20: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 25: ifeq 67\n 28: aload 5\n 30: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 35: astore 6\n 37: lload_3\n 38: aload 6\n 40: checkcast #104 // class java/lang/Number\n 43: invokevirtual #108 // Method java/lang/Number.intValue:()I\n 46: istore 7\n 48: lstore 9\n 50: iconst_0\n 51: istore 8\n 53: iload 7\n 55: i2l\n 56: lstore 11\n 58: lload 9\n 60: lload 11\n 62: ladd\n 63: lstore_3\n 64: goto 18\n 67: lload_3\n 68: lreturn\n\n public static final java.util.List<java.lang.Integer> primes(long);\n Code:\n 0: lload_0\n 1: lconst_1\n 2: lsub\n 3: iconst_2\n 4: i2l\n 5: ldiv\n 6: l2i\n 7: istore_2\n 8: iconst_0\n 9: istore 4\n 11: iload_2\n 12: anewarray #114 // class java/lang/Boolean\n 15: astore 5\n 17: iload 4\n 19: iload_2\n 20: if_icmpge 42\n 23: iload 4\n 25: istore 6\n 27: aload 5\n 29: iload 6\n 31: iconst_1\n 32: invokestatic #118 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 35: aastore\n 36: iinc 4, 1\n 39: goto 17\n 42: aload 5\n 44: astore_3\n 45: lload_0\n 46: l2d\n 47: invokestatic #124 // Method java/lang/Math.sqrt:(D)D\n 50: invokestatic #127 // Method java/lang/Math.floor:(D)D\n 53: d2i\n 54: iconst_1\n 55: isub\n 56: iconst_2\n 57: idiv\n 58: istore 4\n 60: iconst_1\n 61: istore 5\n 63: iload 5\n 65: iload 4\n 67: if_icmpgt 204\n 70: aload_3\n 71: iload 5\n 73: iconst_1\n 74: isub\n 75: aaload\n 76: invokevirtual #130 // Method java/lang/Boolean.booleanValue:()Z\n 79: ifeq 191\n 82: iconst_2\n 83: iload 5\n 85: imul\n 86: iload 5\n 88: iconst_1\n 89: iadd\n 90: imul\n 91: istore 6\n 93: iconst_2\n 94: iload 5\n 96: imul\n 97: iconst_1\n 98: iadd\n 99: istore 7\n 101: iload 7\n 103: ifgt 139\n 106: new #132 // class java/lang/IllegalArgumentException\n 109: dup\n 110: new #134 // class java/lang/StringBuilder\n 113: dup\n 114: invokespecial #136 // Method java/lang/StringBuilder.\"<init>\":()V\n 117: ldc #138 // String Step must be positive, was:\n 119: invokevirtual #142 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 122: iload 7\n 124: invokevirtual #145 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 127: bipush 46\n 129: invokevirtual #148 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 132: invokevirtual #152 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 135: invokespecial #155 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 138: athrow\n 139: iload 6\n 141: istore 8\n 143: iload 6\n 145: iload_2\n 146: iload 7\n 148: invokestatic #161 // Method kotlin/internal/ProgressionUtilKt.getProgressionLastElement:(III)I\n 151: istore 9\n 153: iload 7\n 155: istore 10\n 157: iload 8\n 159: iload 9\n 161: if_icmpgt 191\n 164: aload_3\n 165: iload 8\n 167: iconst_1\n 168: isub\n 169: iconst_0\n 170: invokestatic #118 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 173: aastore\n 174: iload 8\n 176: iload 9\n 178: if_icmpeq 191\n 181: iload 8\n 183: iload 10\n 185: iadd\n 186: istore 8\n 188: goto 164\n 191: iload 5\n 193: iload 4\n 195: if_icmpeq 204\n 198: iinc 5, 1\n 201: goto 70\n 204: iconst_2\n 205: invokestatic #166 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 208: invokestatic #170 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 211: checkcast #172 // class java/util/Collection\n 214: aload_3\n 215: astore 5\n 217: astore 24\n 219: iconst_0\n 220: istore 6\n 222: aload 5\n 224: astore 7\n 226: new #174 // class java/util/ArrayList\n 229: dup\n 230: invokespecial #175 // Method java/util/ArrayList.\"<init>\":()V\n 233: checkcast #172 // class java/util/Collection\n 236: astore 8\n 238: iconst_0\n 239: istore 9\n 241: aload 7\n 243: astore 10\n 245: iconst_0\n 246: istore 11\n 248: iconst_0\n 249: istore 12\n 251: iconst_0\n 252: istore 13\n 254: aload 10\n 256: arraylength\n 257: istore 14\n 259: iload 13\n 261: iload 14\n 263: if_icmpge 351\n 266: aload 10\n 268: iload 13\n 270: aaload\n 271: astore 15\n 273: iload 12\n 275: iinc 12, 1\n 278: aload 15\n 280: astore 16\n 282: istore 17\n 284: iconst_0\n 285: istore 18\n 287: iload 17\n 289: aload 16\n 291: invokevirtual #130 // Method java/lang/Boolean.booleanValue:()Z\n 294: istore 19\n 296: istore 20\n 298: iconst_0\n 299: istore 21\n 301: iload 19\n 303: ifeq 320\n 306: iconst_2\n 307: iload 20\n 309: iconst_1\n 310: iadd\n 311: imul\n 312: iconst_1\n 313: iadd\n 314: invokestatic #166 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 317: goto 321\n 320: aconst_null\n 321: dup\n 322: ifnull 343\n 325: astore 22\n 327: iconst_0\n 328: istore 23\n 330: aload 8\n 332: aload 22\n 334: invokeinterface #179, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 339: pop\n 340: goto 344\n 343: pop\n 344: nop\n 345: iinc 13, 1\n 348: goto 259\n 351: nop\n 352: aload 8\n 354: checkcast #181 // class java/util/List\n 357: nop\n 358: aload 24\n 360: swap\n 361: checkcast #59 // class java/lang/Iterable\n 364: invokestatic #185 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 367: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #215 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem17.kt
|
import kotlin.math.floor
/**
* Number letter counts
*
* If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19
* letters used in total.
*
* If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?
*
* NOTE: Do not count spaces or hyphens. For example, 342 (three hundred and forty-two) contains 23 letters and 115 (one
* hundred and fifteen) contains 20 letters. The use of "and" when writing out numbers is in compliance with British
* usage.
*
* https://projecteuler.net/problem=17
*/
fun main() {
println(numberLetterCount(115))
println(numberLetterCount(342))
println(sumNumberLetterCounts(5))
println(sumNumberLetterCounts(1_000))
}
private fun sumNumberLetterCounts(max: Int): Int = (1..max).sumOf(::numberLetterCount)
private fun numberLetterCount(number: Int): Int {
if (number < 100)
return below100(number)
var res = 0;
val h = floor(number / 100f) % 10
val t = floor(number / 1000f).toInt()
val s = number % 100
if (number > 999) {
res += below100(t) + "thousand".length
}
if (h != 0f) {
res += proper[h.toInt()] + "hundred".length
}
if (s != 0) {
res += "and".length + below100(s)
}
return res
}
// Returns the length of the numbers between 0 and 99
private fun below100(n: Int): Int = if (n < 20) proper[n] else tenth[n / 10 - 2] + proper[n % 10]
// proper nouns
private val proper = arrayOf(
0,
"one".length,
"two".length,
"three".length,
"four".length,
"five".length,
"six".length,
"seven".length,
"eight".length,
"nine".length,
"ten".length,
"eleven".length,
"twelve".length,
"thirteen".length,
"fourteen".length,
"fifteen".length,
"sixteen".length,
"seventeen".length,
"eighteen".length,
"nineteen".length,
)
// tenth prefixes
private val tenth = arrayOf(
"twenty".length,
"thirty".length,
"forty".length,
"fifty".length,
"sixty".length,
"seventy".length,
"eighty".length,
"ninety".length,
)
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem17Kt.class",
"javap": "Compiled from \"Problem17.kt\"\npublic final class Problem17Kt {\n private static final java.lang.Integer[] proper;\n\n private static final java.lang.Integer[] tenth;\n\n public static final void main();\n Code:\n 0: bipush 115\n 2: invokestatic #10 // Method numberLetterCount:(I)I\n 5: istore_0\n 6: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: iload_0\n 10: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 13: sipush 342\n 16: invokestatic #10 // Method numberLetterCount:(I)I\n 19: istore_0\n 20: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 23: iload_0\n 24: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 27: iconst_5\n 28: invokestatic #25 // Method sumNumberLetterCounts:(I)I\n 31: istore_0\n 32: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 35: iload_0\n 36: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 39: sipush 1000\n 42: invokestatic #25 // Method sumNumberLetterCounts:(I)I\n 45: istore_0\n 46: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 49: iload_0\n 50: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 53: return\n\n private static final int sumNumberLetterCounts(int);\n Code:\n 0: new #27 // class kotlin/ranges/IntRange\n 3: dup\n 4: iconst_1\n 5: iload_0\n 6: invokespecial #31 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 9: checkcast #33 // class java/lang/Iterable\n 12: astore_1\n 13: iconst_0\n 14: istore_2\n 15: aload_1\n 16: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 21: astore_3\n 22: aload_3\n 23: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 28: ifeq 66\n 31: aload_3\n 32: checkcast #45 // class kotlin/collections/IntIterator\n 35: invokevirtual #49 // Method kotlin/collections/IntIterator.nextInt:()I\n 38: istore 4\n 40: iload_2\n 41: iload 4\n 43: istore 5\n 45: istore 7\n 47: iconst_0\n 48: istore 6\n 50: iload 5\n 52: invokestatic #10 // Method numberLetterCount:(I)I\n 55: istore 8\n 57: iload 7\n 59: iload 8\n 61: iadd\n 62: istore_2\n 63: goto 22\n 66: iload_2\n 67: ireturn\n\n private static final int numberLetterCount(int);\n Code:\n 0: iload_0\n 1: bipush 100\n 3: if_icmpge 11\n 6: iload_0\n 7: invokestatic #56 // Method below100:(I)I\n 10: ireturn\n 11: iconst_0\n 12: istore_1\n 13: iload_0\n 14: i2f\n 15: ldc #57 // float 100.0f\n 17: fdiv\n 18: f2d\n 19: invokestatic #63 // Method java/lang/Math.floor:(D)D\n 22: d2f\n 23: bipush 10\n 25: i2f\n 26: frem\n 27: fstore_2\n 28: iload_0\n 29: i2f\n 30: ldc #64 // float 1000.0f\n 32: fdiv\n 33: f2d\n 34: invokestatic #63 // Method java/lang/Math.floor:(D)D\n 37: d2f\n 38: f2i\n 39: istore_3\n 40: iload_0\n 41: bipush 100\n 43: irem\n 44: istore 4\n 46: iload_0\n 47: sipush 999\n 50: if_icmple 63\n 53: iload_1\n 54: iload_3\n 55: invokestatic #56 // Method below100:(I)I\n 58: bipush 8\n 60: iadd\n 61: iadd\n 62: istore_1\n 63: fload_2\n 64: fconst_0\n 65: fcmpg\n 66: ifne 73\n 69: iconst_1\n 70: goto 74\n 73: iconst_0\n 74: ifne 92\n 77: iload_1\n 78: getstatic #68 // Field proper:[Ljava/lang/Integer;\n 81: fload_2\n 82: f2i\n 83: aaload\n 84: invokevirtual #73 // Method java/lang/Integer.intValue:()I\n 87: bipush 7\n 89: iadd\n 90: iadd\n 91: istore_1\n 92: iload 4\n 94: ifeq 107\n 97: iload_1\n 98: iconst_3\n 99: iload 4\n 101: invokestatic #56 // Method below100:(I)I\n 104: iadd\n 105: iadd\n 106: istore_1\n 107: iload_1\n 108: ireturn\n\n private static final int below100(int);\n Code:\n 0: iload_0\n 1: bipush 20\n 3: if_icmpge 17\n 6: getstatic #68 // Field proper:[Ljava/lang/Integer;\n 9: iload_0\n 10: aaload\n 11: invokevirtual #73 // Method java/lang/Integer.intValue:()I\n 14: goto 42\n 17: getstatic #82 // Field tenth:[Ljava/lang/Integer;\n 20: iload_0\n 21: bipush 10\n 23: idiv\n 24: iconst_2\n 25: isub\n 26: aaload\n 27: invokevirtual #73 // Method java/lang/Integer.intValue:()I\n 30: getstatic #68 // Field proper:[Ljava/lang/Integer;\n 33: iload_0\n 34: bipush 10\n 36: irem\n 37: aaload\n 38: invokevirtual #73 // Method java/lang/Integer.intValue:()I\n 41: iadd\n 42: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #86 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: bipush 20\n 2: anewarray #70 // class java/lang/Integer\n 5: astore_0\n 6: aload_0\n 7: iconst_0\n 8: iconst_0\n 9: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 12: aastore\n 13: aload_0\n 14: iconst_1\n 15: iconst_3\n 16: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 19: aastore\n 20: aload_0\n 21: iconst_2\n 22: iconst_3\n 23: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 26: aastore\n 27: aload_0\n 28: iconst_3\n 29: iconst_5\n 30: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 33: aastore\n 34: aload_0\n 35: iconst_4\n 36: iconst_4\n 37: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 40: aastore\n 41: aload_0\n 42: iconst_5\n 43: iconst_4\n 44: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 47: aastore\n 48: aload_0\n 49: bipush 6\n 51: iconst_3\n 52: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 55: aastore\n 56: aload_0\n 57: bipush 7\n 59: iconst_5\n 60: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 63: aastore\n 64: aload_0\n 65: bipush 8\n 67: iconst_5\n 68: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 71: aastore\n 72: aload_0\n 73: bipush 9\n 75: iconst_4\n 76: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 79: aastore\n 80: aload_0\n 81: bipush 10\n 83: iconst_3\n 84: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 87: aastore\n 88: aload_0\n 89: bipush 11\n 91: bipush 6\n 93: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 96: aastore\n 97: aload_0\n 98: bipush 12\n 100: bipush 6\n 102: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 105: aastore\n 106: aload_0\n 107: bipush 13\n 109: bipush 8\n 111: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 114: aastore\n 115: aload_0\n 116: bipush 14\n 118: bipush 8\n 120: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 123: aastore\n 124: aload_0\n 125: bipush 15\n 127: bipush 7\n 129: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 132: aastore\n 133: aload_0\n 134: bipush 16\n 136: bipush 7\n 138: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 141: aastore\n 142: aload_0\n 143: bipush 17\n 145: bipush 9\n 147: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 150: aastore\n 151: aload_0\n 152: bipush 18\n 154: bipush 8\n 156: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 159: aastore\n 160: aload_0\n 161: bipush 19\n 163: bipush 8\n 165: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 168: aastore\n 169: aload_0\n 170: putstatic #68 // Field proper:[Ljava/lang/Integer;\n 173: bipush 8\n 175: anewarray #70 // class java/lang/Integer\n 178: astore_0\n 179: aload_0\n 180: iconst_0\n 181: bipush 6\n 183: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 186: aastore\n 187: aload_0\n 188: iconst_1\n 189: bipush 6\n 191: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 194: aastore\n 195: aload_0\n 196: iconst_2\n 197: iconst_5\n 198: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 201: aastore\n 202: aload_0\n 203: iconst_3\n 204: iconst_5\n 205: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 208: aastore\n 209: aload_0\n 210: iconst_4\n 211: iconst_5\n 212: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 215: aastore\n 216: aload_0\n 217: iconst_5\n 218: bipush 7\n 220: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 223: aastore\n 224: aload_0\n 225: bipush 6\n 227: bipush 6\n 229: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 232: aastore\n 233: aload_0\n 234: bipush 7\n 236: bipush 6\n 238: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 241: aastore\n 242: aload_0\n 243: putstatic #82 // Field tenth:[Ljava/lang/Integer;\n 246: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem29.kt
|
import kotlin.math.pow
/**
* Distinct powers
*
* Consider all integer combinations of ab for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5:
*
* 2^2=4, 2^3=8, 2^4=16, 2^5=32
* 3^2=9, 3^3=27, 3^4=81, 3^5=243
* 4^2=16, 4^3=64, 4^4=256, 4^5=1024
* 5^2=25, 5^3=125, 5^4=625, 55^=3125
* If they are then placed in numerical order, with any repeats removed, we get the following sequence of 15 distinct
* terms:
*
* 4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125
*
* How many distinct terms are in the sequence generated by ab for 2 ≤ a ≤ 100 and 2 ≤ b ≤ 100?
*
* https://projecteuler.net/problem=29
*/
fun main() {
println(distinctPowers(limit = 5))
println(distinctPowers(limit = 100))
}
private fun distinctPowers(limit: Int): Int = sequence {
for (a in 2..limit) {
for (b in 2..limit) {
yield(a.toDouble().pow(b))
}
}
}.distinct().count()
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem29Kt.class",
"javap": "Compiled from \"Problem29.kt\"\npublic final class Problem29Kt {\n public static final void main();\n Code:\n 0: iconst_5\n 1: invokestatic #10 // Method distinctPowers:(I)I\n 4: istore_0\n 5: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 8: iload_0\n 9: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 12: bipush 100\n 14: invokestatic #10 // Method distinctPowers:(I)I\n 17: istore_0\n 18: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 21: iload_0\n 22: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 25: return\n\n private static final int distinctPowers(int);\n Code:\n 0: new #24 // class Problem29Kt$distinctPowers$1\n 3: dup\n 4: iload_0\n 5: aconst_null\n 6: invokespecial #28 // Method Problem29Kt$distinctPowers$1.\"<init>\":(ILkotlin/coroutines/Continuation;)V\n 9: checkcast #30 // class kotlin/jvm/functions/Function2\n 12: invokestatic #36 // Method kotlin/sequences/SequencesKt.sequence:(Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;\n 15: invokestatic #40 // Method kotlin/sequences/SequencesKt.distinct:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;\n 18: invokestatic #44 // Method kotlin/sequences/SequencesKt.count:(Lkotlin/sequences/Sequence;)I\n 21: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #49 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
},
{
"class_path": "jimmymorales__project-euler__e881cad/Problem29Kt$distinctPowers$1.class",
"javap": "Compiled from \"Problem29.kt\"\nfinal class Problem29Kt$distinctPowers$1 extends kotlin.coroutines.jvm.internal.RestrictedSuspendLambda implements kotlin.jvm.functions.Function2<kotlin.sequences.SequenceScope<? super java.lang.Double>, kotlin.coroutines.Continuation<? super kotlin.Unit>, java.lang.Object> {\n int I$0;\n\n int I$1;\n\n int label;\n\n private java.lang.Object L$0;\n\n final int $limit;\n\n Problem29Kt$distinctPowers$1(int, kotlin.coroutines.Continuation<? super Problem29Kt$distinctPowers$1>);\n Code:\n 0: aload_0\n 1: iload_1\n 2: putfield #14 // Field $limit:I\n 5: aload_0\n 6: iconst_2\n 7: aload_2\n 8: invokespecial #16 // Method kotlin/coroutines/jvm/internal/RestrictedSuspendLambda.\"<init>\":(ILkotlin/coroutines/Continuation;)V\n 11: return\n\n public final java.lang.Object invokeSuspend(java.lang.Object);\n Code:\n 0: invokestatic #45 // Method kotlin/coroutines/intrinsics/IntrinsicsKt.getCOROUTINE_SUSPENDED:()Ljava/lang/Object;\n 3: astore 5\n 5: aload_0\n 6: getfield #48 // Field label:I\n 9: tableswitch { // 0 to 1\n 0: 32\n 1: 115\n default: 173\n }\n 32: aload_1\n 33: invokestatic #54 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V\n 36: aload_0\n 37: getfield #57 // Field L$0:Ljava/lang/Object;\n 40: checkcast #59 // class kotlin/sequences/SequenceScope\n 43: astore_2\n 44: iconst_2\n 45: istore_3\n 46: iload_3\n 47: aload_0\n 48: getfield #14 // Field $limit:I\n 51: if_icmpgt 169\n 54: iconst_2\n 55: istore 4\n 57: iload 4\n 59: aload_0\n 60: getfield #14 // Field $limit:I\n 63: if_icmpgt 155\n 66: aload_2\n 67: iload_3\n 68: i2d\n 69: iload 4\n 71: i2d\n 72: invokestatic #65 // Method java/lang/Math.pow:(DD)D\n 75: invokestatic #71 // Method kotlin/coroutines/jvm/internal/Boxing.boxDouble:(D)Ljava/lang/Double;\n 78: aload_0\n 79: checkcast #73 // class kotlin/coroutines/Continuation\n 82: aload_0\n 83: aload_2\n 84: putfield #57 // Field L$0:Ljava/lang/Object;\n 87: aload_0\n 88: iload_3\n 89: putfield #75 // Field I$0:I\n 92: aload_0\n 93: iload 4\n 95: putfield #77 // Field I$1:I\n 98: aload_0\n 99: iconst_1\n 100: putfield #48 // Field label:I\n 103: invokevirtual #81 // Method kotlin/sequences/SequenceScope.yield:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;\n 106: dup\n 107: aload 5\n 109: if_acmpne 139\n 112: aload 5\n 114: areturn\n 115: aload_0\n 116: getfield #77 // Field I$1:I\n 119: istore 4\n 121: aload_0\n 122: getfield #75 // Field I$0:I\n 125: istore_3\n 126: aload_0\n 127: getfield #57 // Field L$0:Ljava/lang/Object;\n 130: checkcast #59 // class kotlin/sequences/SequenceScope\n 133: astore_2\n 134: aload_1\n 135: invokestatic #54 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V\n 138: aload_1\n 139: pop\n 140: iload 4\n 142: aload_0\n 143: getfield #14 // Field $limit:I\n 146: if_icmpeq 155\n 149: iinc 4, 1\n 152: goto 66\n 155: iload_3\n 156: aload_0\n 157: getfield #14 // Field $limit:I\n 160: if_icmpeq 169\n 163: iinc 3, 1\n 166: goto 54\n 169: getstatic #87 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 172: areturn\n 173: new #89 // class java/lang/IllegalStateException\n 176: dup\n 177: ldc #91 // String call to \\'resume\\' before \\'invoke\\' with coroutine\n 179: invokespecial #94 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 182: athrow\n\n public final kotlin.coroutines.Continuation<kotlin.Unit> create(java.lang.Object, kotlin.coroutines.Continuation<?>);\n Code:\n 0: new #2 // class Problem29Kt$distinctPowers$1\n 3: dup\n 4: aload_0\n 5: getfield #14 // Field $limit:I\n 8: aload_2\n 9: invokespecial #102 // Method \"<init>\":(ILkotlin/coroutines/Continuation;)V\n 12: astore_3\n 13: aload_3\n 14: aload_1\n 15: putfield #57 // Field L$0:Ljava/lang/Object;\n 18: aload_3\n 19: checkcast #73 // class kotlin/coroutines/Continuation\n 22: areturn\n\n public final java.lang.Object invoke(kotlin.sequences.SequenceScope<? super java.lang.Double>, kotlin.coroutines.Continuation<? super kotlin.Unit>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: aload_2\n 3: invokevirtual #108 // Method create:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Lkotlin/coroutines/Continuation;\n 6: checkcast #2 // class Problem29Kt$distinctPowers$1\n 9: getstatic #87 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 12: invokevirtual #110 // Method invokeSuspend:(Ljava/lang/Object;)Ljava/lang/Object;\n 15: areturn\n\n public java.lang.Object invoke(java.lang.Object, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #59 // class kotlin/sequences/SequenceScope\n 5: aload_2\n 6: checkcast #73 // class kotlin/coroutines/Continuation\n 9: invokevirtual #115 // Method invoke:(Lkotlin/sequences/SequenceScope;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;\n 12: areturn\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem20.kt
|
import java.math.BigInteger
/**
* Factorial digit sum
*
* n! means n × (n − 1) × ... × 3 × 2 × 1
*
* For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
* and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
*
* Find the sum of the digits in the number 100!
*
* https://projecteuler.net/problem=20
*/
fun main() {
println(factorialDigitSum(10))
println(factorialDigitSum(100))
}
private fun factorialDigitSum(n: Int): Int {
val result = mutableListOf<Int>().apply {
var num = n
while (num != 0) {
add(num % 10)
num /= 10
}
}
for (factor in (n - 1) downTo 2) {
var acc = 0
for ((i, num) in result.withIndex()) {
val res = (num * factor) + acc
result[i] = res % 10
acc = res / 10
}
while (acc != 0) {
result.add(acc % 10)
acc /= 10
}
}
return result.sum()
}
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem20Kt.class",
"javap": "Compiled from \"Problem20.kt\"\npublic final class Problem20Kt {\n public static final void main();\n Code:\n 0: bipush 10\n 2: invokestatic #10 // Method factorialDigitSum:(I)I\n 5: istore_0\n 6: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: iload_0\n 10: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 13: bipush 100\n 15: invokestatic #10 // Method factorialDigitSum:(I)I\n 18: istore_0\n 19: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 22: iload_0\n 23: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 26: return\n\n private static final int factorialDigitSum(int);\n Code:\n 0: new #24 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #27 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #29 // class java/util/List\n 10: astore_2\n 11: aload_2\n 12: astore_3\n 13: iconst_0\n 14: istore 4\n 16: iload_0\n 17: istore 5\n 19: iload 5\n 21: ifeq 49\n 24: aload_3\n 25: iload 5\n 27: bipush 10\n 29: irem\n 30: invokestatic #35 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 33: invokeinterface #39, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 38: pop\n 39: iload 5\n 41: bipush 10\n 43: idiv\n 44: istore 5\n 46: goto 19\n 49: nop\n 50: aload_2\n 51: astore_1\n 52: iload_0\n 53: iconst_1\n 54: isub\n 55: istore_2\n 56: iconst_1\n 57: iload_2\n 58: if_icmpge 178\n 61: iconst_0\n 62: istore_3\n 63: aload_1\n 64: checkcast #41 // class java/lang/Iterable\n 67: invokeinterface #45, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 72: astore 4\n 74: iconst_0\n 75: istore 5\n 77: aload 4\n 79: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 84: ifeq 146\n 87: iload 5\n 89: istore 6\n 91: iload 5\n 93: iconst_1\n 94: iadd\n 95: istore 5\n 97: aload 4\n 99: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 104: checkcast #57 // class java/lang/Number\n 107: invokevirtual #61 // Method java/lang/Number.intValue:()I\n 110: istore 7\n 112: iload 7\n 114: iload_2\n 115: imul\n 116: iload_3\n 117: iadd\n 118: istore 8\n 120: aload_1\n 121: iload 6\n 123: iload 8\n 125: bipush 10\n 127: irem\n 128: invokestatic #35 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 131: invokeinterface #65, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 136: pop\n 137: iload 8\n 139: bipush 10\n 141: idiv\n 142: istore_3\n 143: goto 77\n 146: iload_3\n 147: ifeq 172\n 150: aload_1\n 151: iload_3\n 152: bipush 10\n 154: irem\n 155: invokestatic #35 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 158: invokeinterface #39, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 163: pop\n 164: iload_3\n 165: bipush 10\n 167: idiv\n 168: istore_3\n 169: goto 146\n 172: iinc 2, -1\n 175: goto 56\n 178: aload_1\n 179: checkcast #41 // class java/lang/Iterable\n 182: invokestatic #71 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 185: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #85 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem30.kt
|
import kotlin.math.pow
/**
* Digit fifth powers
*
* Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:
*
* 1634 = 1^4 + 6^4 + 3^4 + 4^4
* 8208 = 8^4 + 2^4 + 0^4 + 8^4
* 9474 = 9^4 + 4^4 + 7^4 + 4^4
*
* As 1 = 14 is not a sum it is not included.
*
* The sum of these numbers is 1634 + 8208 + 9474 = 19316.
*
* Find the sum of all the numbers that can be written as the sum of fifth powers of their digits.
*
* https://projecteuler.net/problem=30
*/
fun main() {
println(1634.isDigitPower(4))
println(8208.isDigitPower(4))
println(9474.isDigitPower(4))
println(sumOfDigitPowersOf(4))
println(sumOfDigitPowersOf(5))
}
private fun sumOfDigitPowersOf(n: Int): Int {
var sum = 0
val limit = 9.0.pow(n).times(n).toInt()
for (i in 10..limit) {
if (i.isDigitPower(n)) {
sum += i
}
}
return sum
}
private fun Int.isDigitPower(n: Int): Boolean {
var sum = 0
var num = this
while (num != 0) {
val d = num % 10
sum += d.toDouble().pow(n).toInt()
num /= 10
}
return sum == this
}
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem30Kt.class",
"javap": "Compiled from \"Problem30.kt\"\npublic final class Problem30Kt {\n public static final void main();\n Code:\n 0: sipush 1634\n 3: iconst_4\n 4: invokestatic #10 // Method isDigitPower:(II)Z\n 7: istore_0\n 8: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 11: iload_0\n 12: invokevirtual #22 // Method java/io/PrintStream.println:(Z)V\n 15: sipush 8208\n 18: iconst_4\n 19: invokestatic #10 // Method isDigitPower:(II)Z\n 22: istore_0\n 23: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_0\n 27: invokevirtual #22 // Method java/io/PrintStream.println:(Z)V\n 30: sipush 9474\n 33: iconst_4\n 34: invokestatic #10 // Method isDigitPower:(II)Z\n 37: istore_0\n 38: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 41: iload_0\n 42: invokevirtual #22 // Method java/io/PrintStream.println:(Z)V\n 45: iconst_4\n 46: invokestatic #26 // Method sumOfDigitPowersOf:(I)I\n 49: istore_0\n 50: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 53: iload_0\n 54: invokevirtual #29 // Method java/io/PrintStream.println:(I)V\n 57: iconst_5\n 58: invokestatic #26 // Method sumOfDigitPowersOf:(I)I\n 61: istore_0\n 62: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 65: iload_0\n 66: invokevirtual #29 // Method java/io/PrintStream.println:(I)V\n 69: return\n\n private static final int sumOfDigitPowersOf(int);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: ldc2_w #30 // double 9.0d\n 5: iload_0\n 6: i2d\n 7: invokestatic #37 // Method java/lang/Math.pow:(DD)D\n 10: iload_0\n 11: i2d\n 12: dmul\n 13: d2i\n 14: istore_2\n 15: bipush 10\n 17: istore_3\n 18: iload_3\n 19: iload_2\n 20: if_icmpgt 46\n 23: iload_3\n 24: iload_0\n 25: invokestatic #10 // Method isDigitPower:(II)Z\n 28: ifeq 35\n 31: iload_1\n 32: iload_3\n 33: iadd\n 34: istore_1\n 35: iload_3\n 36: iload_2\n 37: if_icmpeq 46\n 40: iinc 3, 1\n 43: goto 23\n 46: iload_1\n 47: ireturn\n\n private static final boolean isDigitPower(int, int);\n Code:\n 0: iconst_0\n 1: istore_2\n 2: iload_0\n 3: istore_3\n 4: iload_3\n 5: ifeq 34\n 8: iload_3\n 9: bipush 10\n 11: irem\n 12: istore 4\n 14: iload_2\n 15: iload 4\n 17: i2d\n 18: iload_1\n 19: i2d\n 20: invokestatic #37 // Method java/lang/Math.pow:(DD)D\n 23: d2i\n 24: iadd\n 25: istore_2\n 26: iload_3\n 27: bipush 10\n 29: idiv\n 30: istore_3\n 31: goto 4\n 34: iload_2\n 35: iload_0\n 36: if_icmpne 43\n 39: iconst_1\n 40: goto 44\n 43: iconst_0\n 44: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #48 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem14.kt
|
/**
* Longest Collatz sequence
*
* The following iterative sequence is defined for the set of positive integers:
*
* n → n/2 (n is even)
* n → 3n + 1 (n is odd)
*
* Using the rule above and starting with 13, we generate the following sequence:
*
* 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
* It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. Although it has not been
* proved yet (Collatz Problem), it is thought that all starting numbers finish at 1.
*
* Which starting number, under one million, produces the longest chain?
*
* NOTE: Once the chain starts the terms are allowed to go above one million.
*
* https://projecteuler.net/problem=14
*/
fun main() {
println(longestCollatzSequence(1_000_000))
}
private fun longestCollatzSequence(max: Int): Int {
var longest = 0
var answer = 0
for (n in (max / 2) until max) {
val count = collatzSequenceSize(n)
if (count > longest) {
longest = count
answer = n
}
}
max.countLeadingZeroBits()
return answer
}
private val cache = mutableMapOf(1 to 1)
private fun collatzSequenceSize(n: Int): Int {
val cached = cache[n]
if (cached != null) {
return cached
}
val next = if (n % 2 == 0) {
collatzSequenceSize(n / 2) + 1
} else {
collatzSequenceSize((3 * n + 1) / 2) + 2
}
if (cache.size <= 1 shl 30) {
cache[n] = next
}
return next
}
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem14Kt.class",
"javap": "Compiled from \"Problem14.kt\"\npublic final class Problem14Kt {\n private static final java.util.Map<java.lang.Integer, java.lang.Integer> cache;\n\n public static final void main();\n Code:\n 0: ldc #7 // int 1000000\n 2: invokestatic #11 // Method longestCollatzSequence:(I)I\n 5: istore_0\n 6: getstatic #17 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: iload_0\n 10: invokevirtual #23 // Method java/io/PrintStream.println:(I)V\n 13: return\n\n private static final int longestCollatzSequence(int);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: iconst_0\n 3: istore_2\n 4: iload_0\n 5: iconst_2\n 6: idiv\n 7: istore_3\n 8: iload_3\n 9: iload_0\n 10: if_icmpge 36\n 13: iload_3\n 14: invokestatic #26 // Method collatzSequenceSize:(I)I\n 17: istore 4\n 19: iload 4\n 21: iload_1\n 22: if_icmple 30\n 25: iload 4\n 27: istore_1\n 28: iload_3\n 29: istore_2\n 30: iinc 3, 1\n 33: goto 8\n 36: iload_0\n 37: invokestatic #31 // Method java/lang/Integer.numberOfLeadingZeros:(I)I\n 40: pop\n 41: iload_2\n 42: ireturn\n\n private static final int collatzSequenceSize(int);\n Code:\n 0: getstatic #41 // Field cache:Ljava/util/Map;\n 3: iload_0\n 4: invokestatic #45 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 7: invokeinterface #51, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 12: checkcast #28 // class java/lang/Integer\n 15: astore_1\n 16: aload_1\n 17: ifnull 25\n 20: aload_1\n 21: invokevirtual #55 // Method java/lang/Integer.intValue:()I\n 24: ireturn\n 25: iload_0\n 26: iconst_2\n 27: irem\n 28: ifne 42\n 31: iload_0\n 32: iconst_2\n 33: idiv\n 34: invokestatic #26 // Method collatzSequenceSize:(I)I\n 37: iconst_1\n 38: iadd\n 39: goto 54\n 42: iconst_3\n 43: iload_0\n 44: imul\n 45: iconst_1\n 46: iadd\n 47: iconst_2\n 48: idiv\n 49: invokestatic #26 // Method collatzSequenceSize:(I)I\n 52: iconst_2\n 53: iadd\n 54: istore_2\n 55: getstatic #41 // Field cache:Ljava/util/Map;\n 58: invokeinterface #58, 1 // InterfaceMethod java/util/Map.size:()I\n 63: ldc #59 // int 1073741824\n 65: if_icmpgt 91\n 68: iload_0\n 69: invokestatic #45 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 72: astore_3\n 73: iload_2\n 74: invokestatic #45 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 77: astore 4\n 79: getstatic #41 // Field cache:Ljava/util/Map;\n 82: aload_3\n 83: aload 4\n 85: invokeinterface #63, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 90: pop\n 91: iload_2\n 92: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #69 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: iconst_1\n 1: anewarray #74 // class kotlin/Pair\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: iconst_1\n 8: invokestatic #45 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 11: iconst_1\n 12: invokestatic #45 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 15: invokestatic #80 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 18: aastore\n 19: aload_0\n 20: invokestatic #86 // Method kotlin/collections/MapsKt.mutableMapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 23: putstatic #41 // Field cache:Ljava/util/Map;\n 26: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem4.kt
|
/**
* Largest palindrome product
*
* A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is
* 9009 = 91 × 99.
*
* Find the largest palindrome made from the product of two 3-digit numbers.
*
* https://projecteuler.net/problem=4
*/
fun main() {
println(largestPalindrome())
}
fun largestPalindrome(): Int {
var largestPalindrome = 0
for (a in 999 downTo 100) {
var b = 999
while (b >= a) {
val p = a * b
if (p <= largestPalindrome) {
break // since p is always going to be small
}
if (p.isPalindrome) {
largestPalindrome = p
}
b--
}
}
return largestPalindrome
}
val Int.isPalindrome: Boolean get() = this == reverse()
fun Int.reverse(): Int {
var num = this
var reversed = 0
while (num > 0) {
reversed = (10 * reversed) + (num % 10)
num /= 10
}
return reversed
}
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem4Kt.class",
"javap": "Compiled from \"Problem4.kt\"\npublic final class Problem4Kt {\n public static final void main();\n Code:\n 0: invokestatic #10 // Method largestPalindrome:()I\n 3: istore_0\n 4: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 7: iload_0\n 8: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 11: return\n\n public static final int largestPalindrome();\n Code:\n 0: iconst_0\n 1: istore_0\n 2: sipush 999\n 5: istore_1\n 6: bipush 99\n 8: iload_1\n 9: if_icmpge 54\n 12: sipush 999\n 15: istore_2\n 16: iload_2\n 17: iload_1\n 18: if_icmplt 48\n 21: iload_1\n 22: iload_2\n 23: imul\n 24: istore_3\n 25: iload_3\n 26: iload_0\n 27: if_icmpgt 33\n 30: goto 48\n 33: iload_3\n 34: invokestatic #26 // Method isPalindrome:(I)Z\n 37: ifeq 42\n 40: iload_3\n 41: istore_0\n 42: iinc 2, -1\n 45: goto 16\n 48: iinc 1, -1\n 51: goto 6\n 54: iload_0\n 55: ireturn\n\n public static final boolean isPalindrome(int);\n Code:\n 0: iload_0\n 1: iload_0\n 2: invokestatic #34 // Method reverse:(I)I\n 5: if_icmpne 12\n 8: iconst_1\n 9: goto 13\n 12: iconst_0\n 13: ireturn\n\n public static final int reverse(int);\n Code:\n 0: iload_0\n 1: istore_1\n 2: iconst_0\n 3: istore_2\n 4: iload_1\n 5: ifle 26\n 8: bipush 10\n 10: iload_2\n 11: imul\n 12: iload_1\n 13: bipush 10\n 15: irem\n 16: iadd\n 17: istore_2\n 18: iload_1\n 19: bipush 10\n 21: idiv\n 22: istore_1\n 23: goto 4\n 26: iload_2\n 27: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #41 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem32.kt
|
@file:Suppress("MagicNumber")
/**
* Pandigital products
*
* We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example,
* the 5-digit number, 15234, is 1 through 5 pandigital.
*
* The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing multiplicand, multiplier, and product is 1
* through 9 pandigital.
*
* Find the sum of all products whose multiplicand/multiplier/product identity can be written as a 1 through 9
* pandigital.
*
* HINT: Some products can be obtained in more than one way so be sure to only include it once in your sum.
*
* https://projecteuler.net/problem=32
*/
fun main() {
println(isMultiplicationPandigital(multiplicand = 39, multiplier = 186, product = 7254))
println(checkPandigitalsMultiplications())
}
private fun checkPandigitalsMultiplications(): Int = buildSet {
for (i in 2 until 100) {
for (j in (i + 1) until 2_000) {
val p = i * j
if (isMultiplicationPandigital(multiplicand = i, multiplier = j, product = p)) {
add(p)
}
}
}
}.sum()
private fun isMultiplicationPandigital(multiplicand: Int, multiplier: Int, product: Int): Boolean {
check(multiplicand * multiplier == product)
var digitsFlags = 0
val digits = multiplicand.digits() + multiplier.digits() + product.digits()
if (digits.size != 9) {
return false
}
digits.forEach {
digitsFlags = digitsFlags or (1 shl (it - 1))
}
return digitsFlags == 511
}
fun Int.digits(): List<Int> = buildList {
var num = this@digits
while (num != 0) {
add(num % 10)
num /= 10
}
reverse()
}
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem32Kt.class",
"javap": "Compiled from \"Problem32.kt\"\npublic final class Problem32Kt {\n public static final void main();\n Code:\n 0: bipush 39\n 2: sipush 186\n 5: sipush 7254\n 8: invokestatic #10 // Method isMultiplicationPandigital:(III)Z\n 11: istore_0\n 12: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 15: iload_0\n 16: invokevirtual #22 // Method java/io/PrintStream.println:(Z)V\n 19: invokestatic #26 // Method checkPandigitalsMultiplications:()I\n 22: istore_0\n 23: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_0\n 27: invokevirtual #29 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n private static final int checkPandigitalsMultiplications();\n Code:\n 0: invokestatic #35 // Method kotlin/collections/SetsKt.createSetBuilder:()Ljava/util/Set;\n 3: astore_0\n 4: aload_0\n 5: astore_1\n 6: iconst_0\n 7: istore_2\n 8: iconst_2\n 9: istore_3\n 10: iload_3\n 11: bipush 100\n 13: if_icmpge 70\n 16: iload_3\n 17: iconst_1\n 18: iadd\n 19: istore 4\n 21: iload 4\n 23: sipush 2000\n 26: if_icmpge 64\n 29: iload_3\n 30: iload 4\n 32: imul\n 33: istore 5\n 35: iload_3\n 36: iload 4\n 38: iload 5\n 40: invokestatic #10 // Method isMultiplicationPandigital:(III)Z\n 43: ifeq 58\n 46: aload_1\n 47: iload 5\n 49: invokestatic #41 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 52: invokeinterface #47, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 57: pop\n 58: iinc 4, 1\n 61: goto 21\n 64: iinc 3, 1\n 67: goto 10\n 70: nop\n 71: aload_0\n 72: invokestatic #51 // Method kotlin/collections/SetsKt.build:(Ljava/util/Set;)Ljava/util/Set;\n 75: checkcast #53 // class java/lang/Iterable\n 78: invokestatic #59 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 81: ireturn\n\n private static final boolean isMultiplicationPandigital(int, int, int);\n Code:\n 0: iload_0\n 1: iload_1\n 2: imul\n 3: iload_2\n 4: if_icmpne 11\n 7: iconst_1\n 8: goto 12\n 11: iconst_0\n 12: ifne 25\n 15: new #68 // class java/lang/IllegalStateException\n 18: dup\n 19: ldc #70 // String Check failed.\n 21: invokespecial #74 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 24: athrow\n 25: iconst_0\n 26: istore_3\n 27: iload_0\n 28: invokestatic #78 // Method digits:(I)Ljava/util/List;\n 31: checkcast #80 // class java/util/Collection\n 34: iload_1\n 35: invokestatic #78 // Method digits:(I)Ljava/util/List;\n 38: checkcast #53 // class java/lang/Iterable\n 41: invokestatic #84 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 44: checkcast #80 // class java/util/Collection\n 47: iload_2\n 48: invokestatic #78 // Method digits:(I)Ljava/util/List;\n 51: checkcast #53 // class java/lang/Iterable\n 54: invokestatic #84 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 57: astore 4\n 59: aload 4\n 61: invokeinterface #89, 1 // InterfaceMethod java/util/List.size:()I\n 66: bipush 9\n 68: if_icmpeq 73\n 71: iconst_0\n 72: ireturn\n 73: aload 4\n 75: checkcast #53 // class java/lang/Iterable\n 78: astore 5\n 80: iconst_0\n 81: istore 6\n 83: aload 5\n 85: invokeinterface #93, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 90: astore 7\n 92: aload 7\n 94: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 99: ifeq 138\n 102: aload 7\n 104: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 109: astore 8\n 111: aload 8\n 113: checkcast #105 // class java/lang/Number\n 116: invokevirtual #108 // Method java/lang/Number.intValue:()I\n 119: istore 9\n 121: iconst_0\n 122: istore 10\n 124: iload_3\n 125: iconst_1\n 126: iload 9\n 128: iconst_1\n 129: isub\n 130: ishl\n 131: ior\n 132: istore_3\n 133: nop\n 134: nop\n 135: goto 92\n 138: nop\n 139: iload_3\n 140: sipush 511\n 143: if_icmpne 150\n 146: iconst_1\n 147: goto 151\n 150: iconst_0\n 151: ireturn\n\n public static final java.util.List<java.lang.Integer> digits(int);\n Code:\n 0: invokestatic #126 // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;\n 3: astore_1\n 4: aload_1\n 5: astore_2\n 6: iconst_0\n 7: istore_3\n 8: iload_0\n 9: istore 4\n 11: iload 4\n 13: ifeq 41\n 16: aload_2\n 17: iload 4\n 19: bipush 10\n 21: irem\n 22: invokestatic #41 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 25: invokeinterface #127, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 30: pop\n 31: iload 4\n 33: bipush 10\n 35: idiv\n 36: istore 4\n 38: goto 11\n 41: aload_2\n 42: invokestatic #131 // Method kotlin/collections/CollectionsKt.reverse:(Ljava/util/List;)V\n 45: nop\n 46: aload_1\n 47: invokestatic #134 // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;\n 50: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #141 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem5.kt
|
import kotlin.math.floor
import kotlin.math.log10
import kotlin.math.pow
import kotlin.math.sqrt
/**
* Smallest multiple
*
* 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
*
* What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
*
* https://projecteuler.net/problem=5
*/
fun main() {
println(smallestNumberDivisibleBy(20))
}
// Initial answer
/*fun smallestNumberDivisibleBy(k : Int): Long {
for (n in (k..Long.MAX_VALUE)) {
if ((2..k).all { n % it == 0L }) {
return n
}
}
return 0
}*/
private fun smallestNumberDivisibleBy(k: Int): Long {
val p = primes(k)
val a = Array(p.size) { 0 }
val limit = sqrt(k.toDouble())
var n = 1L
var check = true
for (i in 1 until p.size) {
a[i] = 1
if (check) {
if (p[i] <= limit) {
a[i] = floor(log10(k.toDouble())/ log10(p[i].toDouble())).toInt()
} else {
check = false
}
}
n *= p[i].toDouble().pow(a[i]).toLong()
}
return n
}
// Generating a List of Primes: The Sieve of Eratosthenes
fun primes(n: Int): List<Int> {
val flags = Array(n) { true }
var prime = 2
while (prime <= sqrt(n.toDouble())) {
flags.crossOff(prime)
prime = flags.indexOfFirst(from = prime + 1) { it }
}
return flags.mapIndexedNotNull { index, isPrime -> if (isPrime) index else null }
}
private fun Array<Boolean>.crossOff(prime: Int) {
for (i in (prime * prime) until size step prime) {
this[i] = false
}
}
inline fun <T> Array<out T>.indexOfFirst(from: Int, predicate: (T) -> Boolean): Int {
for (index in from until size) {
if (predicate(this[index])) {
return index
}
}
return -1
}
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem5Kt.class",
"javap": "Compiled from \"Problem5.kt\"\npublic final class Problem5Kt {\n public static final void main();\n Code:\n 0: bipush 20\n 2: invokestatic #10 // Method smallestNumberDivisibleBy:(I)J\n 5: lstore_0\n 6: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: lload_0\n 10: invokevirtual #22 // Method java/io/PrintStream.println:(J)V\n 13: return\n\n private static final long smallestNumberDivisibleBy(int);\n Code:\n 0: iload_0\n 1: invokestatic #26 // Method primes:(I)Ljava/util/List;\n 4: astore_1\n 5: iconst_0\n 6: istore_3\n 7: aload_1\n 8: invokeinterface #32, 1 // InterfaceMethod java/util/List.size:()I\n 13: istore 4\n 15: iload 4\n 17: anewarray #34 // class java/lang/Integer\n 20: astore 5\n 22: iload_3\n 23: iload 4\n 25: if_icmpge 46\n 28: iload_3\n 29: istore 6\n 31: aload 5\n 33: iload 6\n 35: iconst_0\n 36: invokestatic #38 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 39: aastore\n 40: iinc 3, 1\n 43: goto 22\n 46: aload 5\n 48: astore_2\n 49: iload_0\n 50: i2d\n 51: invokestatic #44 // Method java/lang/Math.sqrt:(D)D\n 54: dstore_3\n 55: lconst_1\n 56: lstore 5\n 58: iconst_1\n 59: istore 7\n 61: iconst_1\n 62: istore 8\n 64: aload_1\n 65: invokeinterface #32, 1 // InterfaceMethod java/util/List.size:()I\n 70: istore 9\n 72: iload 8\n 74: iload 9\n 76: if_icmpge 191\n 79: aload_2\n 80: iload 8\n 82: iconst_1\n 83: invokestatic #38 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 86: aastore\n 87: iload 7\n 89: ifeq 153\n 92: aload_1\n 93: iload 8\n 95: invokeinterface #48, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 100: checkcast #50 // class java/lang/Number\n 103: invokevirtual #53 // Method java/lang/Number.intValue:()I\n 106: i2d\n 107: dload_3\n 108: dcmpg\n 109: ifgt 150\n 112: aload_2\n 113: iload 8\n 115: iload_0\n 116: i2d\n 117: invokestatic #56 // Method java/lang/Math.log10:(D)D\n 120: aload_1\n 121: iload 8\n 123: invokeinterface #48, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 128: checkcast #50 // class java/lang/Number\n 131: invokevirtual #53 // Method java/lang/Number.intValue:()I\n 134: i2d\n 135: invokestatic #56 // Method java/lang/Math.log10:(D)D\n 138: ddiv\n 139: invokestatic #59 // Method java/lang/Math.floor:(D)D\n 142: d2i\n 143: invokestatic #38 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 146: aastore\n 147: goto 153\n 150: iconst_0\n 151: istore 7\n 153: lload 5\n 155: aload_1\n 156: iload 8\n 158: invokeinterface #48, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 163: checkcast #50 // class java/lang/Number\n 166: invokevirtual #53 // Method java/lang/Number.intValue:()I\n 169: i2d\n 170: aload_2\n 171: iload 8\n 173: aaload\n 174: invokevirtual #60 // Method java/lang/Integer.intValue:()I\n 177: i2d\n 178: invokestatic #64 // Method java/lang/Math.pow:(DD)D\n 181: d2l\n 182: lmul\n 183: lstore 5\n 185: iinc 8, 1\n 188: goto 72\n 191: lload 5\n 193: lreturn\n\n public static final java.util.List<java.lang.Integer> primes(int);\n Code:\n 0: iconst_0\n 1: istore_2\n 2: iload_0\n 3: anewarray #82 // class java/lang/Boolean\n 6: astore_3\n 7: iload_2\n 8: iload_0\n 9: if_icmpge 29\n 12: iload_2\n 13: istore 4\n 15: aload_3\n 16: iload 4\n 18: iconst_1\n 19: invokestatic #85 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 22: aastore\n 23: iinc 2, 1\n 26: goto 7\n 29: aload_3\n 30: astore_1\n 31: iconst_2\n 32: istore_2\n 33: iload_2\n 34: i2d\n 35: iload_0\n 36: i2d\n 37: invokestatic #44 // Method java/lang/Math.sqrt:(D)D\n 40: dcmpg\n 41: ifgt 107\n 44: aload_1\n 45: iload_2\n 46: invokestatic #89 // Method crossOff:([Ljava/lang/Boolean;I)V\n 49: aload_1\n 50: astore_3\n 51: iload_2\n 52: iconst_1\n 53: iadd\n 54: istore 4\n 56: iconst_0\n 57: istore 5\n 59: iload 4\n 61: istore 6\n 63: aload_3\n 64: arraylength\n 65: istore 7\n 67: iload 6\n 69: iload 7\n 71: if_icmpge 102\n 74: aload_3\n 75: iload 6\n 77: aaload\n 78: invokevirtual #93 // Method java/lang/Boolean.booleanValue:()Z\n 81: istore 8\n 83: iconst_0\n 84: istore 9\n 86: iload 8\n 88: ifeq 96\n 91: iload 6\n 93: goto 103\n 96: iinc 6, 1\n 99: goto 67\n 102: iconst_m1\n 103: istore_2\n 104: goto 33\n 107: aload_1\n 108: astore_3\n 109: iconst_0\n 110: istore 4\n 112: aload_3\n 113: astore 5\n 115: new #95 // class java/util/ArrayList\n 118: dup\n 119: invokespecial #98 // Method java/util/ArrayList.\"<init>\":()V\n 122: checkcast #100 // class java/util/Collection\n 125: astore 6\n 127: iconst_0\n 128: istore 7\n 130: aload 5\n 132: astore 8\n 134: iconst_0\n 135: istore 9\n 137: iconst_0\n 138: istore 10\n 140: iconst_0\n 141: istore 11\n 143: aload 8\n 145: arraylength\n 146: istore 12\n 148: iload 11\n 150: iload 12\n 152: if_icmpge 234\n 155: aload 8\n 157: iload 11\n 159: aaload\n 160: astore 13\n 162: iload 10\n 164: iinc 10, 1\n 167: aload 13\n 169: astore 14\n 171: istore 15\n 173: iconst_0\n 174: istore 16\n 176: iload 15\n 178: aload 14\n 180: invokevirtual #93 // Method java/lang/Boolean.booleanValue:()Z\n 183: istore 17\n 185: istore 18\n 187: iconst_0\n 188: istore 19\n 190: iload 17\n 192: ifeq 203\n 195: iload 18\n 197: invokestatic #38 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 200: goto 204\n 203: aconst_null\n 204: dup\n 205: ifnull 226\n 208: astore 20\n 210: iconst_0\n 211: istore 21\n 213: aload 6\n 215: aload 20\n 217: invokeinterface #104, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 222: pop\n 223: goto 227\n 226: pop\n 227: nop\n 228: iinc 11, 1\n 231: goto 148\n 234: nop\n 235: aload 6\n 237: checkcast #28 // class java/util/List\n 240: nop\n 241: areturn\n\n private static final void crossOff(java.lang.Boolean[], int);\n Code:\n 0: iload_1\n 1: iload_1\n 2: imul\n 3: aload_0\n 4: arraylength\n 5: invokestatic #140 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 8: checkcast #142 // class kotlin/ranges/IntProgression\n 11: iload_1\n 12: invokestatic #146 // Method kotlin/ranges/RangesKt.step:(Lkotlin/ranges/IntProgression;I)Lkotlin/ranges/IntProgression;\n 15: astore_2\n 16: aload_2\n 17: invokevirtual #149 // Method kotlin/ranges/IntProgression.getFirst:()I\n 20: istore_3\n 21: aload_2\n 22: invokevirtual #152 // Method kotlin/ranges/IntProgression.getLast:()I\n 25: istore 4\n 27: aload_2\n 28: invokevirtual #155 // Method kotlin/ranges/IntProgression.getStep:()I\n 31: istore 5\n 33: iload 5\n 35: ifle 44\n 38: iload_3\n 39: iload 4\n 41: if_icmple 55\n 44: iload 5\n 46: ifge 76\n 49: iload 4\n 51: iload_3\n 52: if_icmpgt 76\n 55: aload_0\n 56: iload_3\n 57: iconst_0\n 58: invokestatic #85 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 61: aastore\n 62: iload_3\n 63: iload 4\n 65: if_icmpeq 76\n 68: iload_3\n 69: iload 5\n 71: iadd\n 72: istore_3\n 73: goto 55\n 76: return\n\n public static final <T> int indexOfFirst(T[], int, kotlin.jvm.functions.Function1<? super T, java.lang.Boolean>);\n Code:\n 0: aload_0\n 1: ldc #161 // String <this>\n 3: invokestatic #167 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #169 // String predicate\n 9: invokestatic #167 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: iconst_0\n 13: istore_3\n 14: iload_1\n 15: istore 4\n 17: aload_0\n 18: arraylength\n 19: istore 5\n 21: iload 4\n 23: iload 5\n 25: if_icmpge 56\n 28: aload_2\n 29: aload_0\n 30: iload 4\n 32: aaload\n 33: invokeinterface #175, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 38: checkcast #82 // class java/lang/Boolean\n 41: invokevirtual #93 // Method java/lang/Boolean.booleanValue:()Z\n 44: ifeq 50\n 47: iload 4\n 49: ireturn\n 50: iinc 4, 1\n 53: goto 21\n 56: iconst_m1\n 57: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #181 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem23.kt
|
/**
* Non-abundant sums
*
* A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example,
* the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number.
*
* A number n is called deficient if the sum of its proper divisors is less than n and it is called abundant if this sum
* exceeds n.
*
* As 12 is the smallest abundant number, 1 + 2 + 3 + 4 + 6 = 16, the smallest number that can be written as the sum of
* two abundant numbers is 24. By mathematical analysis, it can be shown that all integers greater than 28123 can be
* written as the sum of two abundant numbers. However, this upper limit cannot be reduced any further by analysis even
* though it is known that the greatest number that cannot be expressed as the sum of two abundant numbers is less than
* this limit.
*
* Find the sum of all the positive integers which cannot be written as the sum of two abundant numbers.
*
* https://projecteuler.net/problem=23
*/
fun main() {
println(nonAbundantSums())
}
private fun nonAbundantSums(): Int {
val limit = 28123
val totalSum = (1..limit).sum()
val abundants = buildList {
for (n in 12..limit) {
if (n.sumOfProperDivisors() > n) {
add(n)
}
}
}
val abundantsSums = buildSet {
for (i in abundants.indices) {
for (j in i..abundants.lastIndex) {
val sum = abundants[i] + abundants[j]
if (sum <= limit) {
add(abundants[i] + abundants[j])
}
}
}
}
return totalSum - abundantsSums.sum()
}
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem23Kt.class",
"javap": "Compiled from \"Problem23.kt\"\npublic final class Problem23Kt {\n public static final void main();\n Code:\n 0: invokestatic #10 // Method nonAbundantSums:()I\n 3: istore_0\n 4: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 7: iload_0\n 8: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 11: return\n\n private static final int nonAbundantSums();\n Code:\n 0: sipush 28123\n 3: istore_0\n 4: new #24 // class kotlin/ranges/IntRange\n 7: dup\n 8: iconst_1\n 9: iload_0\n 10: invokespecial #28 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 13: checkcast #30 // class java/lang/Iterable\n 16: invokestatic #36 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 19: istore_1\n 20: invokestatic #40 // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;\n 23: astore_3\n 24: aload_3\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: bipush 12\n 32: istore 6\n 34: iload 6\n 36: invokestatic #46 // Method Problem21Kt.sumOfProperDivisors:(I)I\n 39: iload 6\n 41: if_icmple 57\n 44: aload 4\n 46: iload 6\n 48: invokestatic #52 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 51: invokeinterface #58, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 56: pop\n 57: iload 6\n 59: iload_0\n 60: if_icmpeq 69\n 63: iinc 6, 1\n 66: goto 34\n 69: nop\n 70: aload_3\n 71: invokestatic #62 // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;\n 74: astore_2\n 75: invokestatic #68 // Method kotlin/collections/SetsKt.createSetBuilder:()Ljava/util/Set;\n 78: astore 4\n 80: aload 4\n 82: astore 5\n 84: iconst_0\n 85: istore 6\n 87: iconst_0\n 88: istore 7\n 90: aload_2\n 91: checkcast #70 // class java/util/Collection\n 94: invokeinterface #73, 1 // InterfaceMethod java/util/Collection.size:()I\n 99: istore 8\n 101: iload 7\n 103: iload 8\n 105: if_icmpge 221\n 108: iload 7\n 110: istore 9\n 112: aload_2\n 113: invokestatic #77 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I\n 116: istore 10\n 118: iload 9\n 120: iload 10\n 122: if_icmpgt 215\n 125: aload_2\n 126: iload 7\n 128: invokeinterface #81, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 133: checkcast #83 // class java/lang/Number\n 136: invokevirtual #86 // Method java/lang/Number.intValue:()I\n 139: aload_2\n 140: iload 9\n 142: invokeinterface #81, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 147: checkcast #83 // class java/lang/Number\n 150: invokevirtual #86 // Method java/lang/Number.intValue:()I\n 153: iadd\n 154: istore 11\n 156: iload 11\n 158: iload_0\n 159: if_icmpgt 202\n 162: aload 5\n 164: aload_2\n 165: iload 7\n 167: invokeinterface #81, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 172: checkcast #83 // class java/lang/Number\n 175: invokevirtual #86 // Method java/lang/Number.intValue:()I\n 178: aload_2\n 179: iload 9\n 181: invokeinterface #81, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 186: checkcast #83 // class java/lang/Number\n 189: invokevirtual #86 // Method java/lang/Number.intValue:()I\n 192: iadd\n 193: invokestatic #52 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 196: invokeinterface #89, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 201: pop\n 202: iload 9\n 204: iload 10\n 206: if_icmpeq 215\n 209: iinc 9, 1\n 212: goto 125\n 215: iinc 7, 1\n 218: goto 101\n 221: nop\n 222: aload 4\n 224: invokestatic #92 // Method kotlin/collections/SetsKt.build:(Ljava/util/Set;)Ljava/util/Set;\n 227: astore_3\n 228: iload_1\n 229: aload_3\n 230: checkcast #30 // class java/lang/Iterable\n 233: invokestatic #36 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 236: isub\n 237: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #110 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem33.kt
|
@file:Suppress("MagicNumber")
/**
* Digit cancelling fractions
*
* The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may
* incorrectly believe that 49/98 = 4/8, which is correct, is obtained by cancelling the 9s.
*
* We shall consider fractions like, 30/50 = 3/5, to be trivial examples.
*
* There are exactly four non-trivial examples of this type of fraction, less than one in value, and containing two
* digits in the numerator and denominator.
*
* If the product of these four fractions is given in its lowest common terms, find the value of the denominator.
*
* https://projecteuler.net/problem=33
*/
fun main() {
println(isDigitCancellingFractions(numerator = 49, denominator = 98))
println(findDigitCancellingFractionsProductDenominator())
}
private fun findDigitCancellingFractionsProductDenominator(): Int = buildList {
// From 10 to 99, since we only support two digits.
for (i in 11 until 100) {
for (j in 10 until i) {
if (isDigitCancellingFractions(numerator = j, denominator = i)) {
add(j to i)
}
}
}
}.reduce { (n1, d1), (n2, d2) ->
(n1 * n2) to (d1 * d2)
}.let { (numerator, denominator) ->
val denBI = denominator.toBigInteger()
val gcd = numerator.toBigInteger().gcd(denominator.toBigInteger())
(denBI / gcd).toInt()
}
private fun isDigitCancellingFractions(numerator: Int, denominator: Int): Boolean {
check(numerator in 10..99)
check(denominator in 10..99)
check(numerator < denominator)
val numDigits = numerator.digits().toSet()
val denDigits = denominator.digits().toSet()
val repeatedDigits = numDigits intersect denDigits
if (numDigits.size == 1 || denDigits.size == 1 || repeatedDigits.size != 1) {
return false
}
val digit = repeatedDigits.first()
val newNumerator = numDigits.first { it != digit }.toDouble()
val newDenominator = denDigits.first { it != digit }.toDouble()
// ignore trivial fractions were common digit is zero
return digit != 0 &&
newDenominator != 0.0 &&
(numerator.toDouble() / denominator.toDouble()) == (newNumerator / newDenominator)
}
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem33Kt.class",
"javap": "Compiled from \"Problem33.kt\"\npublic final class Problem33Kt {\n public static final void main();\n Code:\n 0: bipush 49\n 2: bipush 98\n 4: invokestatic #10 // Method isDigitCancellingFractions:(II)Z\n 7: istore_0\n 8: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 11: iload_0\n 12: invokevirtual #22 // Method java/io/PrintStream.println:(Z)V\n 15: invokestatic #26 // Method findDigitCancellingFractionsProductDenominator:()I\n 18: istore_0\n 19: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 22: iload_0\n 23: invokevirtual #29 // Method java/io/PrintStream.println:(I)V\n 26: return\n\n private static final int findDigitCancellingFractionsProductDenominator();\n Code:\n 0: invokestatic #35 // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;\n 3: astore_0\n 4: aload_0\n 5: astore_1\n 6: iconst_0\n 7: istore_2\n 8: bipush 11\n 10: istore_3\n 11: iload_3\n 12: bipush 100\n 14: if_icmpge 67\n 17: bipush 10\n 19: istore 4\n 21: iload 4\n 23: iload_3\n 24: if_icmpge 61\n 27: iload 4\n 29: iload_3\n 30: invokestatic #10 // Method isDigitCancellingFractions:(II)Z\n 33: ifeq 55\n 36: aload_1\n 37: iload 4\n 39: invokestatic #41 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 42: iload_3\n 43: invokestatic #41 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 46: invokestatic #47 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 49: invokeinterface #53, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 54: pop\n 55: iinc 4, 1\n 58: goto 21\n 61: iinc 3, 1\n 64: goto 11\n 67: nop\n 68: aload_0\n 69: invokestatic #57 // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;\n 72: checkcast #59 // class java/lang/Iterable\n 75: astore_0\n 76: nop\n 77: iconst_0\n 78: istore_1\n 79: aload_0\n 80: invokeinterface #63, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 85: astore_2\n 86: aload_2\n 87: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 92: ifne 105\n 95: new #71 // class java/lang/UnsupportedOperationException\n 98: dup\n 99: ldc #73 // String Empty collection can\\'t be reduced.\n 101: invokespecial #77 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 104: athrow\n 105: aload_2\n 106: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 111: astore_3\n 112: aload_2\n 113: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 118: ifeq 216\n 121: aload_3\n 122: aload_2\n 123: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 128: checkcast #83 // class kotlin/Pair\n 131: astore 4\n 133: checkcast #83 // class kotlin/Pair\n 136: astore 5\n 138: iconst_0\n 139: istore 6\n 141: aload 5\n 143: invokevirtual #86 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 146: checkcast #88 // class java/lang/Number\n 149: invokevirtual #91 // Method java/lang/Number.intValue:()I\n 152: istore 7\n 154: aload 5\n 156: invokevirtual #94 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 159: checkcast #88 // class java/lang/Number\n 162: invokevirtual #91 // Method java/lang/Number.intValue:()I\n 165: istore 8\n 167: aload 4\n 169: invokevirtual #86 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 172: checkcast #88 // class java/lang/Number\n 175: invokevirtual #91 // Method java/lang/Number.intValue:()I\n 178: istore 9\n 180: aload 4\n 182: invokevirtual #94 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 185: checkcast #88 // class java/lang/Number\n 188: invokevirtual #91 // Method java/lang/Number.intValue:()I\n 191: istore 10\n 193: iload 7\n 195: iload 9\n 197: imul\n 198: invokestatic #41 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 201: iload 8\n 203: iload 10\n 205: imul\n 206: invokestatic #41 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 209: invokestatic #47 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 212: astore_3\n 213: goto 112\n 216: aload_3\n 217: checkcast #83 // class kotlin/Pair\n 220: astore_1\n 221: iconst_0\n 222: istore_2\n 223: aload_1\n 224: invokevirtual #86 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 227: checkcast #88 // class java/lang/Number\n 230: invokevirtual #91 // Method java/lang/Number.intValue:()I\n 233: istore_3\n 234: aload_1\n 235: invokevirtual #94 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 238: checkcast #88 // class java/lang/Number\n 241: invokevirtual #91 // Method java/lang/Number.intValue:()I\n 244: istore 4\n 246: iload 4\n 248: i2l\n 249: invokestatic #99 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 252: dup\n 253: ldc #101 // String valueOf(...)\n 255: invokestatic #107 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 258: astore 5\n 260: iload_3\n 261: i2l\n 262: invokestatic #99 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 265: dup\n 266: ldc #101 // String valueOf(...)\n 268: invokestatic #107 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 271: iload 4\n 273: i2l\n 274: invokestatic #99 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 277: dup\n 278: ldc #101 // String valueOf(...)\n 280: invokestatic #107 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 283: invokevirtual #111 // Method java/math/BigInteger.gcd:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 286: astore 6\n 288: aload 5\n 290: aload 6\n 292: invokestatic #115 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 295: aload 6\n 297: invokevirtual #118 // Method java/math/BigInteger.divide:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 300: dup\n 301: ldc #120 // String divide(...)\n 303: invokestatic #107 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 306: invokevirtual #121 // Method java/math/BigInteger.intValue:()I\n 309: nop\n 310: ireturn\n\n private static final boolean isDigitCancellingFractions(int, int);\n Code:\n 0: bipush 10\n 2: iload_0\n 3: if_icmpgt 20\n 6: iload_0\n 7: bipush 100\n 9: if_icmpge 16\n 12: iconst_1\n 13: goto 21\n 16: iconst_0\n 17: goto 21\n 20: iconst_0\n 21: ifne 34\n 24: new #146 // class java/lang/IllegalStateException\n 27: dup\n 28: ldc #148 // String Check failed.\n 30: invokespecial #149 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 33: athrow\n 34: bipush 10\n 36: iload_1\n 37: if_icmpgt 54\n 40: iload_1\n 41: bipush 100\n 43: if_icmpge 50\n 46: iconst_1\n 47: goto 55\n 50: iconst_0\n 51: goto 55\n 54: iconst_0\n 55: ifne 68\n 58: new #146 // class java/lang/IllegalStateException\n 61: dup\n 62: ldc #148 // String Check failed.\n 64: invokespecial #149 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 67: athrow\n 68: iload_0\n 69: iload_1\n 70: if_icmpge 77\n 73: iconst_1\n 74: goto 78\n 77: iconst_0\n 78: ifne 91\n 81: new #146 // class java/lang/IllegalStateException\n 84: dup\n 85: ldc #148 // String Check failed.\n 87: invokespecial #149 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 90: athrow\n 91: iload_0\n 92: invokestatic #155 // Method Problem32Kt.digits:(I)Ljava/util/List;\n 95: checkcast #59 // class java/lang/Iterable\n 98: invokestatic #159 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 101: astore_2\n 102: iload_1\n 103: invokestatic #155 // Method Problem32Kt.digits:(I)Ljava/util/List;\n 106: checkcast #59 // class java/lang/Iterable\n 109: invokestatic #159 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 112: astore_3\n 113: aload_2\n 114: checkcast #59 // class java/lang/Iterable\n 117: aload_3\n 118: checkcast #59 // class java/lang/Iterable\n 121: invokestatic #163 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 124: astore 4\n 126: aload_2\n 127: invokeinterface #168, 1 // InterfaceMethod java/util/Set.size:()I\n 132: iconst_1\n 133: if_icmpeq 157\n 136: aload_3\n 137: invokeinterface #168, 1 // InterfaceMethod java/util/Set.size:()I\n 142: iconst_1\n 143: if_icmpeq 157\n 146: aload 4\n 148: invokeinterface #168, 1 // InterfaceMethod java/util/Set.size:()I\n 153: iconst_1\n 154: if_icmpeq 159\n 157: iconst_0\n 158: ireturn\n 159: aload 4\n 161: checkcast #59 // class java/lang/Iterable\n 164: invokestatic #172 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 167: checkcast #88 // class java/lang/Number\n 170: invokevirtual #91 // Method java/lang/Number.intValue:()I\n 173: istore 5\n 175: aload_2\n 176: checkcast #59 // class java/lang/Iterable\n 179: astore 8\n 181: iconst_0\n 182: istore 9\n 184: aload 8\n 186: invokeinterface #63, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 191: astore 10\n 193: aload 10\n 195: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 200: ifeq 245\n 203: aload 10\n 205: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 210: astore 11\n 212: aload 11\n 214: checkcast #88 // class java/lang/Number\n 217: invokevirtual #91 // Method java/lang/Number.intValue:()I\n 220: istore 12\n 222: iconst_0\n 223: istore 13\n 225: iload 12\n 227: iload 5\n 229: if_icmpeq 236\n 232: iconst_1\n 233: goto 237\n 236: iconst_0\n 237: ifeq 193\n 240: aload 11\n 242: goto 255\n 245: new #174 // class java/util/NoSuchElementException\n 248: dup\n 249: ldc #176 // String Collection contains no element matching the predicate.\n 251: invokespecial #177 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 254: athrow\n 255: checkcast #88 // class java/lang/Number\n 258: invokevirtual #91 // Method java/lang/Number.intValue:()I\n 261: i2d\n 262: dstore 6\n 264: aload_3\n 265: checkcast #59 // class java/lang/Iterable\n 268: astore 10\n 270: iconst_0\n 271: istore 11\n 273: aload 10\n 275: invokeinterface #63, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 280: astore 12\n 282: aload 12\n 284: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 289: ifeq 334\n 292: aload 12\n 294: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 299: astore 13\n 301: aload 13\n 303: checkcast #88 // class java/lang/Number\n 306: invokevirtual #91 // Method java/lang/Number.intValue:()I\n 309: istore 14\n 311: iconst_0\n 312: istore 15\n 314: iload 14\n 316: iload 5\n 318: if_icmpeq 325\n 321: iconst_1\n 322: goto 326\n 325: iconst_0\n 326: ifeq 282\n 329: aload 13\n 331: goto 344\n 334: new #174 // class java/util/NoSuchElementException\n 337: dup\n 338: ldc #176 // String Collection contains no element matching the predicate.\n 340: invokespecial #177 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 343: athrow\n 344: checkcast #88 // class java/lang/Number\n 347: invokevirtual #91 // Method java/lang/Number.intValue:()I\n 350: i2d\n 351: dstore 8\n 353: iload 5\n 355: ifeq 399\n 358: dload 8\n 360: dconst_0\n 361: dcmpg\n 362: ifne 369\n 365: iconst_1\n 366: goto 370\n 369: iconst_0\n 370: ifne 399\n 373: iload_0\n 374: i2d\n 375: iload_1\n 376: i2d\n 377: ddiv\n 378: dload 6\n 380: dload 8\n 382: ddiv\n 383: dcmpg\n 384: ifne 391\n 387: iconst_1\n 388: goto 392\n 391: iconst_0\n 392: ifeq 399\n 395: iconst_1\n 396: goto 400\n 399: iconst_0\n 400: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #194 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem26.kt
|
import java.util.Comparator
/**
* Reciprocal cycles
*
* A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to
* 10 are given:
*
* 1/2 = 0.5
* 1/3 = 0.(3)
* 1/4 = 0.25
* 1/5 = 0.2
* 1/6 = 0.1(6)
* 1/7 = 0.(142857)
* 1/8 = 0.125
* 1/9 = 0.(1)
* 1/10 = 0.1
*
* Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle. It can be seen that 1/7 has a 6-digit recurring
* cycle.
*
* Find the value of d < 1000 for which 1/d contains the longest recurring cycle in its decimal fraction part.
*
* https://projecteuler.net/problem=26
*/
fun main() {
println(2.countRepeatingDecimalsInUnitFraction())
println(3.countRepeatingDecimalsInUnitFraction())
println(4.countRepeatingDecimalsInUnitFraction())
println(5.countRepeatingDecimalsInUnitFraction())
println(6.countRepeatingDecimalsInUnitFraction())
println(7.countRepeatingDecimalsInUnitFraction())
println(8.countRepeatingDecimalsInUnitFraction())
println(9.countRepeatingDecimalsInUnitFraction())
println(10.countRepeatingDecimalsInUnitFraction())
println(findLongestRecurringCycle(1_000))
}
private fun findLongestRecurringCycle(limit: Int): Int = (2 until limit)
.map { it to it.countRepeatingDecimalsInUnitFraction() }
.maxWithOrNull(Comparator.comparingInt(Pair<Int, Int>::second))!!
.first
private fun Int.countRepeatingDecimalsInUnitFraction(): Int {
var acc = 10
var rem: Int
val rems = mutableMapOf<Int, Int>()
var index = 0
do {
rem = acc / this
acc -= (this * rem)
if (acc in rems) {
return rems.size - rems[acc]!!
} else {
rems[acc] = index
index++
}
acc *= 10
} while (acc > 0)
return 0
}
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem26Kt.class",
"javap": "Compiled from \"Problem26.kt\"\npublic final class Problem26Kt {\n public static final void main();\n Code:\n 0: iconst_2\n 1: invokestatic #10 // Method countRepeatingDecimalsInUnitFraction:(I)I\n 4: istore_0\n 5: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 8: iload_0\n 9: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 12: iconst_3\n 13: invokestatic #10 // Method countRepeatingDecimalsInUnitFraction:(I)I\n 16: istore_0\n 17: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 20: iload_0\n 21: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 24: iconst_4\n 25: invokestatic #10 // Method countRepeatingDecimalsInUnitFraction:(I)I\n 28: istore_0\n 29: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 32: iload_0\n 33: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 36: iconst_5\n 37: invokestatic #10 // Method countRepeatingDecimalsInUnitFraction:(I)I\n 40: istore_0\n 41: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 44: iload_0\n 45: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 48: bipush 6\n 50: invokestatic #10 // Method countRepeatingDecimalsInUnitFraction:(I)I\n 53: istore_0\n 54: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 57: iload_0\n 58: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 61: bipush 7\n 63: invokestatic #10 // Method countRepeatingDecimalsInUnitFraction:(I)I\n 66: istore_0\n 67: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 70: iload_0\n 71: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 74: bipush 8\n 76: invokestatic #10 // Method countRepeatingDecimalsInUnitFraction:(I)I\n 79: istore_0\n 80: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 83: iload_0\n 84: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 87: bipush 9\n 89: invokestatic #10 // Method countRepeatingDecimalsInUnitFraction:(I)I\n 92: istore_0\n 93: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 96: iload_0\n 97: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 100: bipush 10\n 102: invokestatic #10 // Method countRepeatingDecimalsInUnitFraction:(I)I\n 105: istore_0\n 106: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 109: iload_0\n 110: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 113: sipush 1000\n 116: invokestatic #25 // Method findLongestRecurringCycle:(I)I\n 119: istore_0\n 120: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 123: iload_0\n 124: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 127: return\n\n private static final int findLongestRecurringCycle(int);\n Code:\n 0: iconst_2\n 1: iload_0\n 2: invokestatic #31 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 5: checkcast #33 // class java/lang/Iterable\n 8: astore_1\n 9: nop\n 10: iconst_0\n 11: istore_2\n 12: aload_1\n 13: astore_3\n 14: new #35 // class java/util/ArrayList\n 17: dup\n 18: aload_1\n 19: bipush 10\n 21: invokestatic #41 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 24: invokespecial #44 // Method java/util/ArrayList.\"<init>\":(I)V\n 27: checkcast #46 // class java/util/Collection\n 30: astore 4\n 32: iconst_0\n 33: istore 5\n 35: aload_3\n 36: invokeinterface #50, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 41: astore 6\n 43: aload 6\n 45: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 50: ifeq 102\n 53: aload 6\n 55: checkcast #58 // class kotlin/collections/IntIterator\n 58: invokevirtual #62 // Method kotlin/collections/IntIterator.nextInt:()I\n 61: istore 7\n 63: aload 4\n 65: iload 7\n 67: istore 8\n 69: astore 10\n 71: iconst_0\n 72: istore 9\n 74: iload 8\n 76: invokestatic #68 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 79: iload 8\n 81: invokestatic #10 // Method countRepeatingDecimalsInUnitFraction:(I)I\n 84: invokestatic #68 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 87: invokestatic #74 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 90: aload 10\n 92: swap\n 93: invokeinterface #78, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 98: pop\n 99: goto 43\n 102: aload 4\n 104: checkcast #80 // class java/util/List\n 107: nop\n 108: checkcast #33 // class java/lang/Iterable\n 111: getstatic #86 // Field Problem26Kt$findLongestRecurringCycle$2.INSTANCE:LProblem26Kt$findLongestRecurringCycle$2;\n 114: checkcast #88 // class kotlin/jvm/functions/Function1\n 117: invokedynamic #106, 0 // InvokeDynamic #0:applyAsInt:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/ToIntFunction;\n 122: invokestatic #112 // InterfaceMethod java/util/Comparator.comparingInt:(Ljava/util/function/ToIntFunction;)Ljava/util/Comparator;\n 125: dup\n 126: ldc #114 // String comparingInt(...)\n 128: invokestatic #120 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 131: invokestatic #124 // Method kotlin/collections/CollectionsKt.maxWithOrNull:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/lang/Object;\n 134: dup\n 135: invokestatic #128 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 138: checkcast #130 // class kotlin/Pair\n 141: invokevirtual #134 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 144: checkcast #136 // class java/lang/Number\n 147: invokevirtual #139 // Method java/lang/Number.intValue:()I\n 150: ireturn\n\n private static final int countRepeatingDecimalsInUnitFraction(int);\n Code:\n 0: bipush 10\n 2: istore_1\n 3: iconst_0\n 4: istore_2\n 5: new #153 // class java/util/LinkedHashMap\n 8: dup\n 9: invokespecial #155 // Method java/util/LinkedHashMap.\"<init>\":()V\n 12: checkcast #157 // class java/util/Map\n 15: astore_3\n 16: iconst_0\n 17: istore 4\n 19: iload_1\n 20: iload_0\n 21: idiv\n 22: istore_2\n 23: iload_1\n 24: iload_0\n 25: iload_2\n 26: imul\n 27: isub\n 28: istore_1\n 29: iload_1\n 30: invokestatic #68 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 33: aload_3\n 34: swap\n 35: invokeinterface #160, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 40: ifeq 71\n 43: aload_3\n 44: invokeinterface #163, 1 // InterfaceMethod java/util/Map.size:()I\n 49: aload_3\n 50: iload_1\n 51: invokestatic #68 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 54: invokeinterface #167, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 59: dup\n 60: invokestatic #128 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 63: checkcast #136 // class java/lang/Number\n 66: invokevirtual #139 // Method java/lang/Number.intValue:()I\n 69: isub\n 70: ireturn\n 71: iload_1\n 72: invokestatic #68 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 75: astore 5\n 77: iload 4\n 79: invokestatic #68 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 82: astore 6\n 84: aload_3\n 85: aload 5\n 87: aload 6\n 89: invokeinterface #171, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 94: pop\n 95: iinc 4, 1\n 98: iload_1\n 99: bipush 10\n 101: imul\n 102: istore_1\n 103: iload_1\n 104: ifgt 19\n 107: iconst_0\n 108: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #180 // Method main:()V\n 3: return\n\n private static final int findLongestRecurringCycle$lambda$1(kotlin.jvm.functions.Function1, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokeinterface #185, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: checkcast #136 // class java/lang/Number\n 10: invokevirtual #139 // Method java/lang/Number.intValue:()I\n 13: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "jimmymorales__project-euler__e881cad/Problem26Kt$findLongestRecurringCycle$2.class",
"javap": "Compiled from \"Problem26.kt\"\nfinal class Problem26Kt$findLongestRecurringCycle$2 extends kotlin.jvm.internal.PropertyReference1Impl {\n public static final Problem26Kt$findLongestRecurringCycle$2 INSTANCE;\n\n Problem26Kt$findLongestRecurringCycle$2();\n Code:\n 0: aload_0\n 1: ldc #8 // class kotlin/Pair\n 3: ldc #10 // String second\n 5: ldc #12 // String getSecond()Ljava/lang/Object;\n 7: iconst_0\n 8: invokespecial #15 // Method kotlin/jvm/internal/PropertyReference1Impl.\"<init>\":(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 11: return\n\n public java.lang.Object get(java.lang.Object);\n Code:\n 0: aload_1\n 1: checkcast #8 // class kotlin/Pair\n 4: invokevirtual #23 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 7: areturn\n\n static {};\n Code:\n 0: new #2 // class Problem26Kt$findLongestRecurringCycle$2\n 3: dup\n 4: invokespecial #28 // Method \"<init>\":()V\n 7: putstatic #31 // Field INSTANCE:LProblem26Kt$findLongestRecurringCycle$2;\n 10: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem19.kt
|
/**
* You are given the following information, but you may prefer to do some research for yourself.
* - 1 Jan 1900 was a Monday.
* - Thirty days has September,
* April, June and November.
* All the rest have thirty-one,
* Saving February alone,
* Which has twenty-eight, rain or shine.
* And on leap years, twenty-nine.
* - A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400.
* How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?
*
* https://projecteuler.net/problem=19
*/
fun main() {
println(
countMondaysFirstOfMonth(
MyDate(day = 1, month = 1, year = 1901),
MyDate(day = 31, month = 12, year = 2000)
)
)
}
fun countMondaysFirstOfMonth(from: MyDate, to: MyDate): Int {
var date = MyDate(day = 31, month = 12, year = 1899)
var count = 0
while (date <= to) {
if (date >= from && date.day == 1) {
count++
}
date = date.nextSunday()
}
return count
}
private fun MyDate.nextSunday(): MyDate {
var nextDay = day + 7
var nextMonth = month
var nextYear = year
if (nextDay > daysOfMonth[month]) {
nextDay %= daysOfMonth[month]
nextMonth++
if (nextMonth > 12) {
nextMonth = 1
nextYear++
updateLeapYear(nextYear)
}
}
return MyDate(nextDay, nextMonth, nextYear)
}
private fun updateLeapYear(year: Int) {
val days = when {
year % 400 == 0 -> 29
year % 100 == 0 -> 28
year % 4 == 0 -> 29
else -> 28
}
daysOfMonth[2] = days
}
data class MyDate(val day: Int, val month: Int, val year: Int)
private operator fun MyDate.compareTo(other: MyDate): Int {
val y = year.compareTo(other.year)
if (y != 0) {
return y
}
val m = month.compareTo(other.month)
if (m != 0) {
return m
}
return day.compareTo(other.day)
}
private val daysOfMonth = arrayOf(
0,
31,
28,
31,
30,
31,
30,
31,
31,
30,
31,
30,
31,
)
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem19Kt.class",
"javap": "Compiled from \"Problem19.kt\"\npublic final class Problem19Kt {\n private static final java.lang.Integer[] daysOfMonth;\n\n public static final void main();\n Code:\n 0: new #8 // class MyDate\n 3: dup\n 4: iconst_1\n 5: iconst_1\n 6: sipush 1901\n 9: invokespecial #12 // Method MyDate.\"<init>\":(III)V\n 12: new #8 // class MyDate\n 15: dup\n 16: bipush 31\n 18: bipush 12\n 20: sipush 2000\n 23: invokespecial #12 // Method MyDate.\"<init>\":(III)V\n 26: invokestatic #16 // Method countMondaysFirstOfMonth:(LMyDate;LMyDate;)I\n 29: istore_0\n 30: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 33: iload_0\n 34: invokevirtual #28 // Method java/io/PrintStream.println:(I)V\n 37: return\n\n public static final int countMondaysFirstOfMonth(MyDate, MyDate);\n Code:\n 0: aload_0\n 1: ldc #31 // String from\n 3: invokestatic #37 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #39 // String to\n 9: invokestatic #37 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #8 // class MyDate\n 15: dup\n 16: bipush 31\n 18: bipush 12\n 20: sipush 1899\n 23: invokespecial #12 // Method MyDate.\"<init>\":(III)V\n 26: astore_2\n 27: iconst_0\n 28: istore_3\n 29: aload_2\n 30: aload_1\n 31: invokestatic #42 // Method compareTo:(LMyDate;LMyDate;)I\n 34: ifgt 64\n 37: aload_2\n 38: aload_0\n 39: invokestatic #42 // Method compareTo:(LMyDate;LMyDate;)I\n 42: iflt 56\n 45: aload_2\n 46: invokevirtual #46 // Method MyDate.getDay:()I\n 49: iconst_1\n 50: if_icmpne 56\n 53: iinc 3, 1\n 56: aload_2\n 57: invokestatic #50 // Method nextSunday:(LMyDate;)LMyDate;\n 60: astore_2\n 61: goto 29\n 64: iload_3\n 65: ireturn\n\n private static final MyDate nextSunday(MyDate);\n Code:\n 0: aload_0\n 1: invokevirtual #46 // Method MyDate.getDay:()I\n 4: bipush 7\n 6: iadd\n 7: istore_1\n 8: aload_0\n 9: invokevirtual #57 // Method MyDate.getMonth:()I\n 12: istore_2\n 13: aload_0\n 14: invokevirtual #60 // Method MyDate.getYear:()I\n 17: istore_3\n 18: iload_1\n 19: getstatic #64 // Field daysOfMonth:[Ljava/lang/Integer;\n 22: aload_0\n 23: invokevirtual #57 // Method MyDate.getMonth:()I\n 26: aaload\n 27: invokevirtual #69 // Method java/lang/Integer.intValue:()I\n 30: if_icmple 65\n 33: iload_1\n 34: getstatic #64 // Field daysOfMonth:[Ljava/lang/Integer;\n 37: aload_0\n 38: invokevirtual #57 // Method MyDate.getMonth:()I\n 41: aaload\n 42: invokevirtual #69 // Method java/lang/Integer.intValue:()I\n 45: irem\n 46: istore_1\n 47: iinc 2, 1\n 50: iload_2\n 51: bipush 12\n 53: if_icmple 65\n 56: iconst_1\n 57: istore_2\n 58: iinc 3, 1\n 61: iload_3\n 62: invokestatic #72 // Method updateLeapYear:(I)V\n 65: new #8 // class MyDate\n 68: dup\n 69: iload_1\n 70: iload_2\n 71: iload_3\n 72: invokespecial #12 // Method MyDate.\"<init>\":(III)V\n 75: areturn\n\n private static final void updateLeapYear(int);\n Code:\n 0: nop\n 1: iload_0\n 2: sipush 400\n 5: irem\n 6: ifne 14\n 9: bipush 29\n 11: goto 39\n 14: iload_0\n 15: bipush 100\n 17: irem\n 18: ifne 26\n 21: bipush 28\n 23: goto 39\n 26: iload_0\n 27: iconst_4\n 28: irem\n 29: ifne 37\n 32: bipush 29\n 34: goto 39\n 37: bipush 28\n 39: istore_1\n 40: getstatic #64 // Field daysOfMonth:[Ljava/lang/Integer;\n 43: iconst_2\n 44: iload_1\n 45: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 48: aastore\n 49: return\n\n private static final int compareTo(MyDate, MyDate);\n Code:\n 0: aload_0\n 1: ldc #84 // String <this>\n 3: invokestatic #37 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokevirtual #60 // Method MyDate.getYear:()I\n 10: aload_1\n 11: invokevirtual #60 // Method MyDate.getYear:()I\n 14: invokestatic #88 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 17: istore_2\n 18: iload_2\n 19: ifeq 24\n 22: iload_2\n 23: ireturn\n 24: aload_0\n 25: invokevirtual #57 // Method MyDate.getMonth:()I\n 28: aload_1\n 29: invokevirtual #57 // Method MyDate.getMonth:()I\n 32: invokestatic #88 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 35: istore_3\n 36: iload_3\n 37: ifeq 42\n 40: iload_3\n 41: ireturn\n 42: aload_0\n 43: invokevirtual #46 // Method MyDate.getDay:()I\n 46: aload_1\n 47: invokevirtual #46 // Method MyDate.getDay:()I\n 50: invokestatic #88 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 53: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #95 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: bipush 13\n 2: anewarray #66 // class java/lang/Integer\n 5: astore_0\n 6: aload_0\n 7: iconst_0\n 8: iconst_0\n 9: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 12: aastore\n 13: aload_0\n 14: iconst_1\n 15: bipush 31\n 17: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 20: aastore\n 21: aload_0\n 22: iconst_2\n 23: bipush 28\n 25: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 28: aastore\n 29: aload_0\n 30: iconst_3\n 31: bipush 31\n 33: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 36: aastore\n 37: aload_0\n 38: iconst_4\n 39: bipush 30\n 41: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 44: aastore\n 45: aload_0\n 46: iconst_5\n 47: bipush 31\n 49: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 52: aastore\n 53: aload_0\n 54: bipush 6\n 56: bipush 30\n 58: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 61: aastore\n 62: aload_0\n 63: bipush 7\n 65: bipush 31\n 67: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 70: aastore\n 71: aload_0\n 72: bipush 8\n 74: bipush 31\n 76: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 79: aastore\n 80: aload_0\n 81: bipush 9\n 83: bipush 30\n 85: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 88: aastore\n 89: aload_0\n 90: bipush 10\n 92: bipush 31\n 94: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 97: aastore\n 98: aload_0\n 99: bipush 11\n 101: bipush 30\n 103: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 106: aastore\n 107: aload_0\n 108: bipush 12\n 110: bipush 31\n 112: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 115: aastore\n 116: aload_0\n 117: putstatic #64 // Field daysOfMonth:[Ljava/lang/Integer;\n 120: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem27.kt
|
import kotlin.math.pow
/**
* Quadratic primes
*
* Euler discovered the remarkable quadratic formula: n^2 + n + 41
*
* It turns out that the formula will produce 40 primes for the consecutive integer values 0 <= n <= 39. However, when
* is n = 40, 40^2 + 40 +41 = 40(40+1) + 41 divisible by 41, and certainly when n = 41, 41^2 + 41 + 41 is clearly
* divisible by 41.
*
* The incredible formula n^2 - 79n + 1601 was discovered, which produces 80 primes for the consecutive values
* 0 <= n <= 79. The product of the coefficients, −79 and 1601, is −126479.
*
* Considering quadratics of the form:
*
* n ^2 + an + b, where |a| < 1000 and |b| <= 1000
* where |n| is the modulus/absolute value of n
* e.g. |11| = 11 and |-4| = 4
*
* Find the product of the coefficients, a and b, for the quadratic expression that produces the maximum number of
* primes for consecutive values of n, starting with n = 0.
*
* https://projecteuler.net/problem=27
*/
fun main() {
println(numOfPrimes(a = 1, b = 41))
println(numOfPrimes(a = -79, b = 1601))
println(quadraticPrimes())
}
private fun quadraticPrimes(): Int {
var numOfPrimes = 0
var abPair = 0 to 0
for (a in -999 until 1_000) {
for (b in -1_000..1_000) {
val count = numOfPrimes(a, b)
if (count > numOfPrimes) {
numOfPrimes = count
abPair = a to b
}
}
}
return abPair.first * abPair.second
}
private fun numOfPrimes(a: Int, b: Int): Int {
var count = -1
var n = -1
do {
count++
n++
val res = n.toDouble().pow(2.0) + (a * n) + b
} while (isPrime(res.toLong()))
return count
}
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem27Kt.class",
"javap": "Compiled from \"Problem27.kt\"\npublic final class Problem27Kt {\n public static final void main();\n Code:\n 0: iconst_1\n 1: bipush 41\n 3: invokestatic #10 // Method numOfPrimes:(II)I\n 6: istore_0\n 7: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 10: iload_0\n 11: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 14: bipush -79\n 16: sipush 1601\n 19: invokestatic #10 // Method numOfPrimes:(II)I\n 22: istore_0\n 23: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_0\n 27: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 30: invokestatic #26 // Method quadraticPrimes:()I\n 33: istore_0\n 34: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 37: iload_0\n 38: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 41: return\n\n private static final int quadraticPrimes();\n Code:\n 0: iconst_0\n 1: istore_0\n 2: iconst_0\n 3: invokestatic #32 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 6: iconst_0\n 7: invokestatic #32 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 10: invokestatic #38 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 13: astore_1\n 14: sipush -999\n 17: istore_2\n 18: iload_2\n 19: sipush 1000\n 22: if_icmpge 76\n 25: sipush -1000\n 28: istore_3\n 29: iload_3\n 30: sipush 1001\n 33: if_icmpge 70\n 36: iload_2\n 37: iload_3\n 38: invokestatic #10 // Method numOfPrimes:(II)I\n 41: istore 4\n 43: iload 4\n 45: iload_0\n 46: if_icmple 64\n 49: iload 4\n 51: istore_0\n 52: iload_2\n 53: invokestatic #32 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 56: iload_3\n 57: invokestatic #32 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 60: invokestatic #38 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 63: astore_1\n 64: iinc 3, 1\n 67: goto 29\n 70: iinc 2, 1\n 73: goto 18\n 76: aload_1\n 77: invokevirtual #44 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 80: checkcast #46 // class java/lang/Number\n 83: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 86: aload_1\n 87: invokevirtual #52 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 90: checkcast #46 // class java/lang/Number\n 93: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 96: imul\n 97: ireturn\n\n private static final int numOfPrimes(int, int);\n Code:\n 0: iconst_m1\n 1: istore_2\n 2: iconst_m1\n 3: istore_3\n 4: iinc 2, 1\n 7: iinc 3, 1\n 10: iload_3\n 11: i2d\n 12: ldc2_w #59 // double 2.0d\n 15: invokestatic #66 // Method java/lang/Math.pow:(DD)D\n 18: iload_0\n 19: iload_3\n 20: imul\n 21: i2d\n 22: dadd\n 23: iload_1\n 24: i2d\n 25: dadd\n 26: dstore 4\n 28: dload 4\n 30: d2l\n 31: invokestatic #72 // Method Problem7Kt.isPrime:(J)Z\n 34: ifne 4\n 37: iload_2\n 38: ireturn\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": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem1.kt
|
import kotlin.system.measureNanoTime
/**
* Multiples of 3 or 5
*
* If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these
* multiples is 23.
*
* Find the sum of all the multiples of 3 or 5 below 1000.
*
* https://projecteuler.net/problem=1
*/
fun main() {
val max = 999
val solution1Time = measureNanoTime {
solution1(max)
}
val solution2Time = measureNanoTime {
solution2(max)
}
println(solution1Time)
println(solution2Time)
}
private fun solution1(limit: Int) {
val res = (1 .. limit).asSequence()
.filter { n -> n % 3 == 0 || n % 5 == 0 }
.sum()
println(res)
}
private fun solution2(limit: Int) {
val res2 = sumDivisibleBy(3, limit) + sumDivisibleBy(5, limit) - sumDivisibleBy(15, limit)
println(res2)
}
fun sumDivisibleBy(n: Int, max: Int): Int {
// e.g. 3 + 6 + 9 + 12 + ... + 999 = 3 (1 + 2 + 3 + 4 + ... + 333)
// 333 = 999 / 3 => p = max / n
val p = max / n
// 1 + 2 + 3 + 4 + ... + p = 1/2 * p * (p + 1)
return (n * ( 0.5 * p * (p + 1))).toInt()
}
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem1Kt.class",
"javap": "Compiled from \"Problem1.kt\"\npublic final class Problem1Kt {\n public static final void main();\n Code:\n 0: sipush 999\n 3: istore_0\n 4: iconst_0\n 5: istore_3\n 6: invokestatic #12 // Method java/lang/System.nanoTime:()J\n 9: lstore 4\n 11: iconst_0\n 12: istore 6\n 14: iload_0\n 15: invokestatic #16 // Method solution1:(I)V\n 18: nop\n 19: nop\n 20: invokestatic #12 // Method java/lang/System.nanoTime:()J\n 23: lload 4\n 25: lsub\n 26: lstore_1\n 27: iconst_0\n 28: istore 5\n 30: invokestatic #12 // Method java/lang/System.nanoTime:()J\n 33: lstore 6\n 35: iconst_0\n 36: istore 8\n 38: iload_0\n 39: invokestatic #19 // Method solution2:(I)V\n 42: nop\n 43: nop\n 44: invokestatic #12 // Method java/lang/System.nanoTime:()J\n 47: lload 6\n 49: lsub\n 50: lstore_3\n 51: getstatic #23 // Field java/lang/System.out:Ljava/io/PrintStream;\n 54: lload_1\n 55: invokevirtual #29 // Method java/io/PrintStream.println:(J)V\n 58: getstatic #23 // Field java/lang/System.out:Ljava/io/PrintStream;\n 61: lload_3\n 62: invokevirtual #29 // Method java/io/PrintStream.println:(J)V\n 65: return\n\n private static final void solution1(int);\n Code:\n 0: new #40 // class kotlin/ranges/IntRange\n 3: dup\n 4: iconst_1\n 5: iload_0\n 6: invokespecial #44 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 9: checkcast #46 // class java/lang/Iterable\n 12: invokestatic #52 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 15: invokedynamic #72, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 20: invokestatic #78 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 23: invokestatic #82 // Method kotlin/sequences/SequencesKt.sumOfInt:(Lkotlin/sequences/Sequence;)I\n 26: istore_1\n 27: getstatic #23 // Field java/lang/System.out:Ljava/io/PrintStream;\n 30: iload_1\n 31: invokevirtual #84 // Method java/io/PrintStream.println:(I)V\n 34: return\n\n private static final void solution2(int);\n Code:\n 0: iconst_3\n 1: iload_0\n 2: invokestatic #90 // Method sumDivisibleBy:(II)I\n 5: iconst_5\n 6: iload_0\n 7: invokestatic #90 // Method sumDivisibleBy:(II)I\n 10: iadd\n 11: bipush 15\n 13: iload_0\n 14: invokestatic #90 // Method sumDivisibleBy:(II)I\n 17: isub\n 18: istore_1\n 19: getstatic #23 // Field java/lang/System.out:Ljava/io/PrintStream;\n 22: iload_1\n 23: invokevirtual #84 // Method java/io/PrintStream.println:(I)V\n 26: return\n\n public static final int sumDivisibleBy(int, int);\n Code:\n 0: iload_1\n 1: iload_0\n 2: idiv\n 3: istore_2\n 4: iload_0\n 5: i2d\n 6: ldc2_w #92 // double 0.5d\n 9: iload_2\n 10: i2d\n 11: dmul\n 12: iload_2\n 13: iconst_1\n 14: iadd\n 15: i2d\n 16: dmul\n 17: dmul\n 18: d2i\n 19: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #98 // Method main:()V\n 3: return\n\n private static final boolean solution1$lambda$2(int);\n Code:\n 0: iload_0\n 1: iconst_3\n 2: irem\n 3: ifeq 12\n 6: iload_0\n 7: iconst_5\n 8: irem\n 9: ifne 16\n 12: iconst_1\n 13: goto 17\n 16: iconst_0\n 17: ireturn\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem18.kt
|
/**
* By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from
* top to bottom is 23.
*
* 3
* 7 4
* 2 4 6
* 8 5 9 3
*
* That is, 3 + 7 + 4 + 9 = 23.
*
* Find the maximum total from top to bottom of the triangle below:
*
* 75
* 95 64
* 17 47 82
* 18 35 87 10
* 20 04 82 47 65
* 19 01 23 75 03 34
* 88 02 77 73 07 63 67
* 99 65 04 28 06 16 70 92
* 41 41 26 56 83 40 80 70 33
* 41 48 72 33 47 32 37 16 94 29
* 53 71 44 65 25 43 91 52 97 51 14
* 70 11 33 28 77 73 17 78 39 68 17 57
* 91 71 52 38 17 14 91 43 58 50 27 29 48
* 63 66 04 68 89 53 67 30 73 16 69 87 40 31
* 04 62 98 27 23 09 70 98 73 93 38 53 60 04 23
*
* NOTE: As there are only 16384 routes, it is possible to solve this problem by trying every route.
* However, Problem 67, is the same challenge with a triangle containing one-hundred rows; it cannot be solved by brute
* force, and requires a clever method! ;o)
*
* https://projecteuler.net/problem=18
*/
fun main() {
println(maxSum(smallTriangle, level = 0, pos = 0))
cache.clear()
println(maxSum(triangle, level = 0, pos = 0))
}
private val cache = mutableMapOf<Pair<Int, Int>, Long>()
fun maxSum(triangle: List<List<Int>>, level: Int, pos: Int): Long {
if (level == triangle.size || pos == triangle[level].size) {
return 0
}
if (cache.containsKey(level to pos)) {
return cache[level to pos]!!
}
val sum = maxOf(
maxSum(triangle, level = level + 1, pos),
maxSum(triangle, level = level + 1, pos + 1)
) + triangle[level][pos]
cache[level to pos] = sum
return sum
}
private val smallTriangle = listOf(
listOf(3),
listOf(7, 4),
listOf(2, 4, 6),
listOf(8, 5, 9, 3),
)
private val triangle = listOf(
listOf(75),
listOf(95, 64),
listOf(17, 47, 82),
listOf(18, 35, 87, 10),
listOf(20, 4, 82, 47, 65),
listOf(19, 1, 23, 75, 3, 34),
listOf(88, 2, 77, 73, 7, 63, 67),
listOf(99, 65, 4, 28, 6, 16, 70, 92),
listOf(41, 41, 26, 56, 83, 40, 80, 70, 33),
listOf(41, 48, 72, 33, 47, 32, 37, 16, 94, 29),
listOf(53, 71, 44, 65, 25, 43, 91, 52, 97, 51, 14),
listOf(70, 11, 33, 28, 77, 73, 17, 78, 39, 68, 17, 57),
listOf(91, 71, 52, 38, 17, 14, 91, 43, 58, 50, 27, 29, 48),
listOf(63, 66, 4, 68, 89, 53, 67, 30, 73, 16, 69, 87, 40, 31),
listOf(4, 62, 98, 27, 23, 9, 70, 98, 73, 93, 38, 53, 60, 4, 23),
)
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem18Kt.class",
"javap": "Compiled from \"Problem18.kt\"\npublic final class Problem18Kt {\n private static final java.util.Map<kotlin.Pair<java.lang.Integer, java.lang.Integer>, java.lang.Long> cache;\n\n private static final java.util.List<java.util.List<java.lang.Integer>> smallTriangle;\n\n private static final java.util.List<java.util.List<java.lang.Integer>> triangle;\n\n public static final void main();\n Code:\n 0: getstatic #10 // Field smallTriangle:Ljava/util/List;\n 3: iconst_0\n 4: iconst_0\n 5: invokestatic #14 // Method maxSum:(Ljava/util/List;II)J\n 8: lstore_0\n 9: getstatic #20 // Field java/lang/System.out:Ljava/io/PrintStream;\n 12: lload_0\n 13: invokevirtual #26 // Method java/io/PrintStream.println:(J)V\n 16: getstatic #30 // Field cache:Ljava/util/Map;\n 19: invokeinterface #35, 1 // InterfaceMethod java/util/Map.clear:()V\n 24: getstatic #38 // Field triangle:Ljava/util/List;\n 27: iconst_0\n 28: iconst_0\n 29: invokestatic #14 // Method maxSum:(Ljava/util/List;II)J\n 32: lstore_0\n 33: getstatic #20 // Field java/lang/System.out:Ljava/io/PrintStream;\n 36: lload_0\n 37: invokevirtual #26 // Method java/io/PrintStream.println:(J)V\n 40: return\n\n public static final long maxSum(java.util.List<? extends java.util.List<java.lang.Integer>>, int, int);\n Code:\n 0: aload_0\n 1: ldc #41 // String triangle\n 3: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iload_1\n 7: aload_0\n 8: invokeinterface #53, 1 // InterfaceMethod java/util/List.size:()I\n 13: if_icmpeq 35\n 16: iload_2\n 17: aload_0\n 18: iload_1\n 19: invokeinterface #57, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 24: checkcast #49 // class java/util/List\n 27: invokeinterface #53, 1 // InterfaceMethod java/util/List.size:()I\n 32: if_icmpne 37\n 35: lconst_0\n 36: lreturn\n 37: getstatic #30 // Field cache:Ljava/util/Map;\n 40: iload_1\n 41: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 44: iload_2\n 45: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 48: invokestatic #69 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 51: invokeinterface #73, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 56: ifeq 89\n 59: getstatic #30 // Field cache:Ljava/util/Map;\n 62: iload_1\n 63: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 66: iload_2\n 67: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 70: invokestatic #69 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 73: invokeinterface #76, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 78: dup\n 79: invokestatic #80 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 82: checkcast #82 // class java/lang/Number\n 85: invokevirtual #86 // Method java/lang/Number.longValue:()J\n 88: lreturn\n 89: nop\n 90: aload_0\n 91: iload_1\n 92: iconst_1\n 93: iadd\n 94: iload_2\n 95: invokestatic #14 // Method maxSum:(Ljava/util/List;II)J\n 98: aload_0\n 99: iload_1\n 100: iconst_1\n 101: iadd\n 102: iload_2\n 103: iconst_1\n 104: iadd\n 105: invokestatic #14 // Method maxSum:(Ljava/util/List;II)J\n 108: invokestatic #92 // Method java/lang/Math.max:(JJ)J\n 111: aload_0\n 112: iload_1\n 113: invokeinterface #57, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 118: checkcast #49 // class java/util/List\n 121: iload_2\n 122: invokeinterface #57, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 127: checkcast #82 // class java/lang/Number\n 130: invokevirtual #86 // Method java/lang/Number.longValue:()J\n 133: ladd\n 134: lstore_3\n 135: lload_3\n 136: invokestatic #97 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 139: astore 5\n 141: getstatic #30 // Field cache:Ljava/util/Map;\n 144: iload_1\n 145: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 148: iload_2\n 149: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 152: invokestatic #69 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 155: aload 5\n 157: invokeinterface #101, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 162: pop\n 163: lload_3\n 164: lreturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #109 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: new #114 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #117 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #32 // class java/util/Map\n 10: putstatic #30 // Field cache:Ljava/util/Map;\n 13: iconst_4\n 14: anewarray #49 // class java/util/List\n 17: astore_0\n 18: aload_0\n 19: iconst_0\n 20: iconst_3\n 21: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 24: invokestatic #123 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 27: aastore\n 28: aload_0\n 29: iconst_1\n 30: iconst_2\n 31: anewarray #59 // class java/lang/Integer\n 34: astore_1\n 35: aload_1\n 36: iconst_0\n 37: bipush 7\n 39: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 42: aastore\n 43: aload_1\n 44: iconst_1\n 45: iconst_4\n 46: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 49: aastore\n 50: aload_1\n 51: invokestatic #126 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 54: aastore\n 55: aload_0\n 56: iconst_2\n 57: iconst_3\n 58: anewarray #59 // class java/lang/Integer\n 61: astore_1\n 62: aload_1\n 63: iconst_0\n 64: iconst_2\n 65: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 68: aastore\n 69: aload_1\n 70: iconst_1\n 71: iconst_4\n 72: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 75: aastore\n 76: aload_1\n 77: iconst_2\n 78: bipush 6\n 80: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 83: aastore\n 84: aload_1\n 85: invokestatic #126 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 88: aastore\n 89: aload_0\n 90: iconst_3\n 91: iconst_4\n 92: anewarray #59 // class java/lang/Integer\n 95: astore_1\n 96: aload_1\n 97: iconst_0\n 98: bipush 8\n 100: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 103: aastore\n 104: aload_1\n 105: iconst_1\n 106: iconst_5\n 107: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 110: aastore\n 111: aload_1\n 112: iconst_2\n 113: bipush 9\n 115: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 118: aastore\n 119: aload_1\n 120: iconst_3\n 121: iconst_3\n 122: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 125: aastore\n 126: aload_1\n 127: invokestatic #126 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 130: aastore\n 131: aload_0\n 132: invokestatic #126 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 135: putstatic #10 // Field smallTriangle:Ljava/util/List;\n 138: bipush 15\n 140: anewarray #49 // class java/util/List\n 143: astore_0\n 144: aload_0\n 145: iconst_0\n 146: bipush 75\n 148: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 151: invokestatic #123 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 154: aastore\n 155: aload_0\n 156: iconst_1\n 157: iconst_2\n 158: anewarray #59 // class java/lang/Integer\n 161: astore_1\n 162: aload_1\n 163: iconst_0\n 164: bipush 95\n 166: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 169: aastore\n 170: aload_1\n 171: iconst_1\n 172: bipush 64\n 174: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 177: aastore\n 178: aload_1\n 179: invokestatic #126 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 182: aastore\n 183: aload_0\n 184: iconst_2\n 185: iconst_3\n 186: anewarray #59 // class java/lang/Integer\n 189: astore_1\n 190: aload_1\n 191: iconst_0\n 192: bipush 17\n 194: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 197: aastore\n 198: aload_1\n 199: iconst_1\n 200: bipush 47\n 202: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 205: aastore\n 206: aload_1\n 207: iconst_2\n 208: bipush 82\n 210: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 213: aastore\n 214: aload_1\n 215: invokestatic #126 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 218: aastore\n 219: aload_0\n 220: iconst_3\n 221: iconst_4\n 222: anewarray #59 // class java/lang/Integer\n 225: astore_1\n 226: aload_1\n 227: iconst_0\n 228: bipush 18\n 230: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 233: aastore\n 234: aload_1\n 235: iconst_1\n 236: bipush 35\n 238: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 241: aastore\n 242: aload_1\n 243: iconst_2\n 244: bipush 87\n 246: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 249: aastore\n 250: aload_1\n 251: iconst_3\n 252: bipush 10\n 254: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 257: aastore\n 258: aload_1\n 259: invokestatic #126 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 262: aastore\n 263: aload_0\n 264: iconst_4\n 265: iconst_5\n 266: anewarray #59 // class java/lang/Integer\n 269: astore_1\n 270: aload_1\n 271: iconst_0\n 272: bipush 20\n 274: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 277: aastore\n 278: aload_1\n 279: iconst_1\n 280: iconst_4\n 281: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 284: aastore\n 285: aload_1\n 286: iconst_2\n 287: bipush 82\n 289: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 292: aastore\n 293: aload_1\n 294: iconst_3\n 295: bipush 47\n 297: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 300: aastore\n 301: aload_1\n 302: iconst_4\n 303: bipush 65\n 305: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 308: aastore\n 309: aload_1\n 310: invokestatic #126 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 313: aastore\n 314: aload_0\n 315: iconst_5\n 316: bipush 6\n 318: anewarray #59 // class java/lang/Integer\n 321: astore_1\n 322: aload_1\n 323: iconst_0\n 324: bipush 19\n 326: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 329: aastore\n 330: aload_1\n 331: iconst_1\n 332: iconst_1\n 333: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 336: aastore\n 337: aload_1\n 338: iconst_2\n 339: bipush 23\n 341: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 344: aastore\n 345: aload_1\n 346: iconst_3\n 347: bipush 75\n 349: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 352: aastore\n 353: aload_1\n 354: iconst_4\n 355: iconst_3\n 356: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 359: aastore\n 360: aload_1\n 361: iconst_5\n 362: bipush 34\n 364: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 367: aastore\n 368: aload_1\n 369: invokestatic #126 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 372: aastore\n 373: aload_0\n 374: bipush 6\n 376: bipush 7\n 378: anewarray #59 // class java/lang/Integer\n 381: astore_1\n 382: aload_1\n 383: iconst_0\n 384: bipush 88\n 386: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 389: aastore\n 390: aload_1\n 391: iconst_1\n 392: iconst_2\n 393: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 396: aastore\n 397: aload_1\n 398: iconst_2\n 399: bipush 77\n 401: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 404: aastore\n 405: aload_1\n 406: iconst_3\n 407: bipush 73\n 409: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 412: aastore\n 413: aload_1\n 414: iconst_4\n 415: bipush 7\n 417: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 420: aastore\n 421: aload_1\n 422: iconst_5\n 423: bipush 63\n 425: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 428: aastore\n 429: aload_1\n 430: bipush 6\n 432: bipush 67\n 434: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 437: aastore\n 438: aload_1\n 439: invokestatic #126 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 442: aastore\n 443: aload_0\n 444: bipush 7\n 446: bipush 8\n 448: anewarray #59 // class java/lang/Integer\n 451: astore_1\n 452: aload_1\n 453: iconst_0\n 454: bipush 99\n 456: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 459: aastore\n 460: aload_1\n 461: iconst_1\n 462: bipush 65\n 464: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 467: aastore\n 468: aload_1\n 469: iconst_2\n 470: iconst_4\n 471: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 474: aastore\n 475: aload_1\n 476: iconst_3\n 477: bipush 28\n 479: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 482: aastore\n 483: aload_1\n 484: iconst_4\n 485: bipush 6\n 487: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 490: aastore\n 491: aload_1\n 492: iconst_5\n 493: bipush 16\n 495: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 498: aastore\n 499: aload_1\n 500: bipush 6\n 502: bipush 70\n 504: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 507: aastore\n 508: aload_1\n 509: bipush 7\n 511: bipush 92\n 513: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 516: aastore\n 517: aload_1\n 518: invokestatic #126 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 521: aastore\n 522: aload_0\n 523: bipush 8\n 525: bipush 9\n 527: anewarray #59 // class java/lang/Integer\n 530: astore_1\n 531: aload_1\n 532: iconst_0\n 533: bipush 41\n 535: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 538: aastore\n 539: aload_1\n 540: iconst_1\n 541: bipush 41\n 543: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 546: aastore\n 547: aload_1\n 548: iconst_2\n 549: bipush 26\n 551: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 554: aastore\n 555: aload_1\n 556: iconst_3\n 557: bipush 56\n 559: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 562: aastore\n 563: aload_1\n 564: iconst_4\n 565: bipush 83\n 567: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 570: aastore\n 571: aload_1\n 572: iconst_5\n 573: bipush 40\n 575: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 578: aastore\n 579: aload_1\n 580: bipush 6\n 582: bipush 80\n 584: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 587: aastore\n 588: aload_1\n 589: bipush 7\n 591: bipush 70\n 593: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 596: aastore\n 597: aload_1\n 598: bipush 8\n 600: bipush 33\n 602: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 605: aastore\n 606: aload_1\n 607: invokestatic #126 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 610: aastore\n 611: aload_0\n 612: bipush 9\n 614: bipush 10\n 616: anewarray #59 // class java/lang/Integer\n 619: astore_1\n 620: aload_1\n 621: iconst_0\n 622: bipush 41\n 624: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 627: aastore\n 628: aload_1\n 629: iconst_1\n 630: bipush 48\n 632: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 635: aastore\n 636: aload_1\n 637: iconst_2\n 638: bipush 72\n 640: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 643: aastore\n 644: aload_1\n 645: iconst_3\n 646: bipush 33\n 648: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 651: aastore\n 652: aload_1\n 653: iconst_4\n 654: bipush 47\n 656: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 659: aastore\n 660: aload_1\n 661: iconst_5\n 662: bipush 32\n 664: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 667: aastore\n 668: aload_1\n 669: bipush 6\n 671: bipush 37\n 673: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 676: aastore\n 677: aload_1\n 678: bipush 7\n 680: bipush 16\n 682: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 685: aastore\n 686: aload_1\n 687: bipush 8\n 689: bipush 94\n 691: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 694: aastore\n 695: aload_1\n 696: bipush 9\n 698: bipush 29\n 700: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 703: aastore\n 704: aload_1\n 705: invokestatic #126 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 708: aastore\n 709: aload_0\n 710: bipush 10\n 712: bipush 11\n 714: anewarray #59 // class java/lang/Integer\n 717: astore_1\n 718: aload_1\n 719: iconst_0\n 720: bipush 53\n 722: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 725: aastore\n 726: aload_1\n 727: iconst_1\n 728: bipush 71\n 730: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 733: aastore\n 734: aload_1\n 735: iconst_2\n 736: bipush 44\n 738: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 741: aastore\n 742: aload_1\n 743: iconst_3\n 744: bipush 65\n 746: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 749: aastore\n 750: aload_1\n 751: iconst_4\n 752: bipush 25\n 754: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 757: aastore\n 758: aload_1\n 759: iconst_5\n 760: bipush 43\n 762: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 765: aastore\n 766: aload_1\n 767: bipush 6\n 769: bipush 91\n 771: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 774: aastore\n 775: aload_1\n 776: bipush 7\n 778: bipush 52\n 780: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 783: aastore\n 784: aload_1\n 785: bipush 8\n 787: bipush 97\n 789: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 792: aastore\n 793: aload_1\n 794: bipush 9\n 796: bipush 51\n 798: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 801: aastore\n 802: aload_1\n 803: bipush 10\n 805: bipush 14\n 807: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 810: aastore\n 811: aload_1\n 812: invokestatic #126 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 815: aastore\n 816: aload_0\n 817: bipush 11\n 819: bipush 12\n 821: anewarray #59 // class java/lang/Integer\n 824: astore_1\n 825: aload_1\n 826: iconst_0\n 827: bipush 70\n 829: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 832: aastore\n 833: aload_1\n 834: iconst_1\n 835: bipush 11\n 837: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 840: aastore\n 841: aload_1\n 842: iconst_2\n 843: bipush 33\n 845: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 848: aastore\n 849: aload_1\n 850: iconst_3\n 851: bipush 28\n 853: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 856: aastore\n 857: aload_1\n 858: iconst_4\n 859: bipush 77\n 861: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 864: aastore\n 865: aload_1\n 866: iconst_5\n 867: bipush 73\n 869: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 872: aastore\n 873: aload_1\n 874: bipush 6\n 876: bipush 17\n 878: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 881: aastore\n 882: aload_1\n 883: bipush 7\n 885: bipush 78\n 887: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 890: aastore\n 891: aload_1\n 892: bipush 8\n 894: bipush 39\n 896: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 899: aastore\n 900: aload_1\n 901: bipush 9\n 903: bipush 68\n 905: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 908: aastore\n 909: aload_1\n 910: bipush 10\n 912: bipush 17\n 914: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 917: aastore\n 918: aload_1\n 919: bipush 11\n 921: bipush 57\n 923: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 926: aastore\n 927: aload_1\n 928: invokestatic #126 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 931: aastore\n 932: aload_0\n 933: bipush 12\n 935: bipush 13\n 937: anewarray #59 // class java/lang/Integer\n 940: astore_1\n 941: aload_1\n 942: iconst_0\n 943: bipush 91\n 945: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 948: aastore\n 949: aload_1\n 950: iconst_1\n 951: bipush 71\n 953: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 956: aastore\n 957: aload_1\n 958: iconst_2\n 959: bipush 52\n 961: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 964: aastore\n 965: aload_1\n 966: iconst_3\n 967: bipush 38\n 969: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 972: aastore\n 973: aload_1\n 974: iconst_4\n 975: bipush 17\n 977: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 980: aastore\n 981: aload_1\n 982: iconst_5\n 983: bipush 14\n 985: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 988: aastore\n 989: aload_1\n 990: bipush 6\n 992: bipush 91\n 994: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 997: aastore\n 998: aload_1\n 999: bipush 7\n 1001: bipush 43\n 1003: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1006: aastore\n 1007: aload_1\n 1008: bipush 8\n 1010: bipush 58\n 1012: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1015: aastore\n 1016: aload_1\n 1017: bipush 9\n 1019: bipush 50\n 1021: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1024: aastore\n 1025: aload_1\n 1026: bipush 10\n 1028: bipush 27\n 1030: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1033: aastore\n 1034: aload_1\n 1035: bipush 11\n 1037: bipush 29\n 1039: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1042: aastore\n 1043: aload_1\n 1044: bipush 12\n 1046: bipush 48\n 1048: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1051: aastore\n 1052: aload_1\n 1053: invokestatic #126 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 1056: aastore\n 1057: aload_0\n 1058: bipush 13\n 1060: bipush 14\n 1062: anewarray #59 // class java/lang/Integer\n 1065: astore_1\n 1066: aload_1\n 1067: iconst_0\n 1068: bipush 63\n 1070: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1073: aastore\n 1074: aload_1\n 1075: iconst_1\n 1076: bipush 66\n 1078: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1081: aastore\n 1082: aload_1\n 1083: iconst_2\n 1084: iconst_4\n 1085: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1088: aastore\n 1089: aload_1\n 1090: iconst_3\n 1091: bipush 68\n 1093: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1096: aastore\n 1097: aload_1\n 1098: iconst_4\n 1099: bipush 89\n 1101: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1104: aastore\n 1105: aload_1\n 1106: iconst_5\n 1107: bipush 53\n 1109: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1112: aastore\n 1113: aload_1\n 1114: bipush 6\n 1116: bipush 67\n 1118: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1121: aastore\n 1122: aload_1\n 1123: bipush 7\n 1125: bipush 30\n 1127: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1130: aastore\n 1131: aload_1\n 1132: bipush 8\n 1134: bipush 73\n 1136: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1139: aastore\n 1140: aload_1\n 1141: bipush 9\n 1143: bipush 16\n 1145: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1148: aastore\n 1149: aload_1\n 1150: bipush 10\n 1152: bipush 69\n 1154: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1157: aastore\n 1158: aload_1\n 1159: bipush 11\n 1161: bipush 87\n 1163: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1166: aastore\n 1167: aload_1\n 1168: bipush 12\n 1170: bipush 40\n 1172: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1175: aastore\n 1176: aload_1\n 1177: bipush 13\n 1179: bipush 31\n 1181: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1184: aastore\n 1185: aload_1\n 1186: invokestatic #126 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 1189: aastore\n 1190: aload_0\n 1191: bipush 14\n 1193: bipush 15\n 1195: anewarray #59 // class java/lang/Integer\n 1198: astore_1\n 1199: aload_1\n 1200: iconst_0\n 1201: iconst_4\n 1202: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1205: aastore\n 1206: aload_1\n 1207: iconst_1\n 1208: bipush 62\n 1210: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1213: aastore\n 1214: aload_1\n 1215: iconst_2\n 1216: bipush 98\n 1218: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1221: aastore\n 1222: aload_1\n 1223: iconst_3\n 1224: bipush 27\n 1226: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1229: aastore\n 1230: aload_1\n 1231: iconst_4\n 1232: bipush 23\n 1234: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1237: aastore\n 1238: aload_1\n 1239: iconst_5\n 1240: bipush 9\n 1242: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1245: aastore\n 1246: aload_1\n 1247: bipush 6\n 1249: bipush 70\n 1251: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1254: aastore\n 1255: aload_1\n 1256: bipush 7\n 1258: bipush 98\n 1260: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1263: aastore\n 1264: aload_1\n 1265: bipush 8\n 1267: bipush 73\n 1269: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1272: aastore\n 1273: aload_1\n 1274: bipush 9\n 1276: bipush 93\n 1278: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1281: aastore\n 1282: aload_1\n 1283: bipush 10\n 1285: bipush 38\n 1287: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1290: aastore\n 1291: aload_1\n 1292: bipush 11\n 1294: bipush 53\n 1296: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1299: aastore\n 1300: aload_1\n 1301: bipush 12\n 1303: bipush 60\n 1305: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1308: aastore\n 1309: aload_1\n 1310: bipush 13\n 1312: iconst_4\n 1313: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1316: aastore\n 1317: aload_1\n 1318: bipush 14\n 1320: bipush 23\n 1322: invokestatic #63 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1325: aastore\n 1326: aload_1\n 1327: invokestatic #126 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 1330: aastore\n 1331: aload_0\n 1332: invokestatic #126 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 1335: putstatic #38 // Field triangle:Ljava/util/List;\n 1338: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem11.kt
|
/**
* Largest product in a grid
*
* In the 20×20 grid below, four numbers along a diagonal line have been marked in red.
*
* 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
* 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
* 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65
* 52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91
* 22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80
* 24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50
* 32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70
* 67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21
* 24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72
* 21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95
* 78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92
* 16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57
* 86 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 58
* 19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40
* 04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 66
* 88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69
* 04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36
* 20 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16
* 20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54
* 01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48
*
* The product of these numbers is 26 × 63 × 78 × 14 = 1788696.
*
* What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in
* the 20×20 grid?
*/
fun main() {
println(largestProduct(grid, 4))
}
fun largestProduct(matrix: Array<Array<Int>>, n: Int): Long {
var maxP = 0L
for (i in matrix.indices) {
for (j in matrix[i].indices) {
if (matrix[i][j] == 0) continue
if (matrix.size - i >= n) {
val pv = (0 until n).fold(initial = 1L) { acc, offset -> acc * matrix[i + offset][j] }
if (pv > maxP) {
maxP = pv
}
}
if (matrix[i].size - j >= n) {
val ph = (0 until n).fold(initial = 1L) { acc, offset -> acc * matrix[i][j + offset] }
if (ph > maxP) {
maxP = ph
}
}
if (matrix.size - i >= n && matrix[i].size - j >= n) {
val pdr = (0 until n).fold(initial = 1L) { acc, offset -> acc * matrix[i + offset][j + offset] }
if (pdr > maxP) {
maxP = pdr
}
}
if (matrix.size - i >= n && j >= n - 1) {
val pdl = (0 until n).fold(initial = 1L) { acc, offset -> acc * matrix[i + offset][j - offset] }
if (pdl > maxP) {
maxP = pdl
}
}
}
}
return maxP
}
private val grid = arrayOf(
arrayOf(8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5, 7, 78, 52, 12, 50, 77, 91, 8),
arrayOf(49, 49, 99, 40, 17, 81, 18, 57, 60, 87, 17, 40, 98, 43, 69, 48, 4, 56, 62, 0),
arrayOf(81, 49, 31, 73, 55, 79, 14, 29, 93, 71, 40, 67, 53, 88, 30, 3, 49, 13, 36, 65),
arrayOf(52, 70, 95, 23, 4, 60, 11, 42, 69, 24, 68, 56, 1, 32, 56, 71, 37, 2, 36, 91),
arrayOf(22, 31, 16, 71, 51, 67, 63, 89, 41, 92, 36, 54, 22, 40, 40, 28, 66, 33, 13, 80),
arrayOf(24, 47, 32, 60, 99, 3, 45, 2, 44, 75, 33, 53, 78, 36, 84, 20, 35, 17, 12, 50),
arrayOf(32, 98, 81, 28, 64, 23, 67, 10, 26, 38, 40, 67, 59, 54, 70, 66, 18, 38, 64, 70),
arrayOf(67, 26, 20, 68, 2, 62, 12, 20, 95, 63, 94, 39, 63, 8, 40, 91, 66, 49, 94, 21),
arrayOf(24, 55, 58, 5, 66, 73, 99, 26, 97, 17, 78, 78, 96, 83, 14, 88, 34, 89, 63, 72),
arrayOf(21, 36, 23, 9, 75, 0, 76, 44, 20, 45, 35, 14, 0, 61, 33, 97, 34, 31, 33, 95),
arrayOf(78, 17, 53, 28, 22, 75, 31, 67, 15, 94, 3, 80, 4, 62, 16, 14, 9, 53, 56, 92),
arrayOf(16, 39, 5, 42, 96, 35, 31, 47, 55, 58, 88, 24, 0, 17, 54, 24, 36, 29, 85, 57),
arrayOf(86, 56, 0, 48, 35, 71, 89, 7, 5, 44, 44, 37, 44, 60, 21, 58, 51, 54, 17, 58),
arrayOf(19, 80, 81, 68, 5, 94, 47, 69, 28, 73, 92, 13, 86, 52, 17, 77, 4, 89, 55, 40),
arrayOf(4, 52, 8, 83, 97, 35, 99, 16, 7, 97, 57, 32, 16, 26, 26, 79, 33, 27, 98, 66),
arrayOf(88, 36, 68, 87, 57, 62, 20, 72, 3, 46, 33, 67, 46, 55, 12, 32, 63, 93, 53, 69),
arrayOf(4, 42, 16, 73, 38, 25, 39, 11, 24, 94, 72, 18, 8, 46, 29, 32, 40, 62, 76, 36),
arrayOf(20, 69, 36, 41, 72, 30, 23, 88, 34, 62, 99, 69, 82, 67, 59, 85, 74, 4, 36, 16),
arrayOf(20, 73, 35, 29, 78, 31, 90, 1, 74, 31, 49, 71, 48, 86, 81, 16, 23, 57, 5, 54),
arrayOf(1, 70, 54, 71, 83, 51, 54, 69, 16, 92, 33, 48, 61, 43, 52, 1, 89, 19, 67, 48),
)
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem11Kt.class",
"javap": "Compiled from \"Problem11.kt\"\npublic final class Problem11Kt {\n private static final java.lang.Integer[][] grid;\n\n public static final void main();\n Code:\n 0: getstatic #10 // Field grid:[[Ljava/lang/Integer;\n 3: iconst_4\n 4: invokestatic #14 // Method largestProduct:([[Ljava/lang/Integer;I)J\n 7: lstore_0\n 8: getstatic #20 // Field java/lang/System.out:Ljava/io/PrintStream;\n 11: lload_0\n 12: invokevirtual #26 // Method java/io/PrintStream.println:(J)V\n 15: return\n\n public static final long largestProduct(java.lang.Integer[][], int);\n Code:\n 0: aload_0\n 1: ldc #29 // String matrix\n 3: invokestatic #35 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: lconst_0\n 7: lstore_2\n 8: iconst_0\n 9: istore 4\n 11: aload_0\n 12: checkcast #37 // class \"[Ljava/lang/Object;\"\n 15: arraylength\n 16: istore 5\n 18: iload 4\n 20: iload 5\n 22: if_icmpge 525\n 25: iconst_0\n 26: istore 6\n 28: aload_0\n 29: iload 4\n 31: aaload\n 32: arraylength\n 33: istore 7\n 35: iload 6\n 37: iload 7\n 39: if_icmpge 519\n 42: aload_0\n 43: iload 4\n 45: aaload\n 46: iload 6\n 48: aaload\n 49: invokevirtual #43 // Method java/lang/Integer.intValue:()I\n 52: ifeq 513\n 55: aload_0\n 56: checkcast #37 // class \"[Ljava/lang/Object;\"\n 59: arraylength\n 60: iload 4\n 62: isub\n 63: iload_1\n 64: if_icmplt 163\n 67: iconst_0\n 68: iload_1\n 69: invokestatic #49 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 72: checkcast #51 // class java/lang/Iterable\n 75: astore 10\n 77: lconst_1\n 78: lstore 11\n 80: iconst_0\n 81: istore 13\n 83: lload 11\n 85: lstore 14\n 87: aload 10\n 89: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 94: astore 16\n 96: aload 16\n 98: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 103: ifeq 149\n 106: aload 16\n 108: checkcast #63 // class kotlin/collections/IntIterator\n 111: invokevirtual #66 // Method kotlin/collections/IntIterator.nextInt:()I\n 114: istore 17\n 116: lload 14\n 118: iload 17\n 120: istore 18\n 122: lstore 19\n 124: iconst_0\n 125: istore 21\n 127: lload 19\n 129: aload_0\n 130: iload 4\n 132: iload 18\n 134: iadd\n 135: aaload\n 136: iload 6\n 138: aaload\n 139: invokevirtual #43 // Method java/lang/Integer.intValue:()I\n 142: i2l\n 143: lmul\n 144: lstore 14\n 146: goto 96\n 149: lload 14\n 151: lstore 8\n 153: lload 8\n 155: lload_2\n 156: lcmp\n 157: ifle 163\n 160: lload 8\n 162: lstore_2\n 163: aload_0\n 164: iload 4\n 166: aaload\n 167: arraylength\n 168: iload 6\n 170: isub\n 171: iload_1\n 172: if_icmplt 271\n 175: iconst_0\n 176: iload_1\n 177: invokestatic #49 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 180: checkcast #51 // class java/lang/Iterable\n 183: astore 10\n 185: lconst_1\n 186: lstore 11\n 188: iconst_0\n 189: istore 13\n 191: lload 11\n 193: lstore 14\n 195: aload 10\n 197: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 202: astore 16\n 204: aload 16\n 206: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 211: ifeq 257\n 214: aload 16\n 216: checkcast #63 // class kotlin/collections/IntIterator\n 219: invokevirtual #66 // Method kotlin/collections/IntIterator.nextInt:()I\n 222: istore 17\n 224: lload 14\n 226: iload 17\n 228: istore 18\n 230: lstore 19\n 232: iconst_0\n 233: istore 21\n 235: lload 19\n 237: aload_0\n 238: iload 4\n 240: aaload\n 241: iload 6\n 243: iload 18\n 245: iadd\n 246: aaload\n 247: invokevirtual #43 // Method java/lang/Integer.intValue:()I\n 250: i2l\n 251: lmul\n 252: lstore 14\n 254: goto 204\n 257: lload 14\n 259: lstore 8\n 261: lload 8\n 263: lload_2\n 264: lcmp\n 265: ifle 271\n 268: lload 8\n 270: lstore_2\n 271: aload_0\n 272: checkcast #37 // class \"[Ljava/lang/Object;\"\n 275: arraylength\n 276: iload 4\n 278: isub\n 279: iload_1\n 280: if_icmplt 394\n 283: aload_0\n 284: iload 4\n 286: aaload\n 287: arraylength\n 288: iload 6\n 290: isub\n 291: iload_1\n 292: if_icmplt 394\n 295: iconst_0\n 296: iload_1\n 297: invokestatic #49 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 300: checkcast #51 // class java/lang/Iterable\n 303: astore 10\n 305: lconst_1\n 306: lstore 11\n 308: iconst_0\n 309: istore 13\n 311: lload 11\n 313: lstore 14\n 315: aload 10\n 317: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 322: astore 16\n 324: aload 16\n 326: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 331: ifeq 380\n 334: aload 16\n 336: checkcast #63 // class kotlin/collections/IntIterator\n 339: invokevirtual #66 // Method kotlin/collections/IntIterator.nextInt:()I\n 342: istore 17\n 344: lload 14\n 346: iload 17\n 348: istore 18\n 350: lstore 19\n 352: iconst_0\n 353: istore 21\n 355: lload 19\n 357: aload_0\n 358: iload 4\n 360: iload 18\n 362: iadd\n 363: aaload\n 364: iload 6\n 366: iload 18\n 368: iadd\n 369: aaload\n 370: invokevirtual #43 // Method java/lang/Integer.intValue:()I\n 373: i2l\n 374: lmul\n 375: lstore 14\n 377: goto 324\n 380: lload 14\n 382: lstore 8\n 384: lload 8\n 386: lload_2\n 387: lcmp\n 388: ifle 394\n 391: lload 8\n 393: lstore_2\n 394: aload_0\n 395: checkcast #37 // class \"[Ljava/lang/Object;\"\n 398: arraylength\n 399: iload 4\n 401: isub\n 402: iload_1\n 403: if_icmplt 513\n 406: iload 6\n 408: iload_1\n 409: iconst_1\n 410: isub\n 411: if_icmplt 513\n 414: iconst_0\n 415: iload_1\n 416: invokestatic #49 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 419: checkcast #51 // class java/lang/Iterable\n 422: astore 10\n 424: lconst_1\n 425: lstore 11\n 427: iconst_0\n 428: istore 13\n 430: lload 11\n 432: lstore 14\n 434: aload 10\n 436: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 441: astore 16\n 443: aload 16\n 445: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 450: ifeq 499\n 453: aload 16\n 455: checkcast #63 // class kotlin/collections/IntIterator\n 458: invokevirtual #66 // Method kotlin/collections/IntIterator.nextInt:()I\n 461: istore 17\n 463: lload 14\n 465: iload 17\n 467: istore 18\n 469: lstore 19\n 471: iconst_0\n 472: istore 21\n 474: lload 19\n 476: aload_0\n 477: iload 4\n 479: iload 18\n 481: iadd\n 482: aaload\n 483: iload 6\n 485: iload 18\n 487: isub\n 488: aaload\n 489: invokevirtual #43 // Method java/lang/Integer.intValue:()I\n 492: i2l\n 493: lmul\n 494: lstore 14\n 496: goto 443\n 499: lload 14\n 501: lstore 8\n 503: lload 8\n 505: lload_2\n 506: lcmp\n 507: ifle 513\n 510: lload 8\n 512: lstore_2\n 513: iinc 6, 1\n 516: goto 35\n 519: iinc 4, 1\n 522: goto 18\n 525: lload_2\n 526: lreturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #92 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: bipush 20\n 2: anewarray #97 // class \"[Ljava/lang/Integer;\"\n 5: astore_0\n 6: aload_0\n 7: iconst_0\n 8: bipush 20\n 10: anewarray #39 // class java/lang/Integer\n 13: astore_1\n 14: aload_1\n 15: iconst_0\n 16: bipush 8\n 18: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 21: aastore\n 22: aload_1\n 23: iconst_1\n 24: iconst_2\n 25: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 28: aastore\n 29: aload_1\n 30: iconst_2\n 31: bipush 22\n 33: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 36: aastore\n 37: aload_1\n 38: iconst_3\n 39: bipush 97\n 41: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 44: aastore\n 45: aload_1\n 46: iconst_4\n 47: bipush 38\n 49: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 52: aastore\n 53: aload_1\n 54: iconst_5\n 55: bipush 15\n 57: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 60: aastore\n 61: aload_1\n 62: bipush 6\n 64: iconst_0\n 65: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 68: aastore\n 69: aload_1\n 70: bipush 7\n 72: bipush 40\n 74: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 77: aastore\n 78: aload_1\n 79: bipush 8\n 81: iconst_0\n 82: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 85: aastore\n 86: aload_1\n 87: bipush 9\n 89: bipush 75\n 91: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 94: aastore\n 95: aload_1\n 96: bipush 10\n 98: iconst_4\n 99: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 102: aastore\n 103: aload_1\n 104: bipush 11\n 106: iconst_5\n 107: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 110: aastore\n 111: aload_1\n 112: bipush 12\n 114: bipush 7\n 116: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 119: aastore\n 120: aload_1\n 121: bipush 13\n 123: bipush 78\n 125: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 128: aastore\n 129: aload_1\n 130: bipush 14\n 132: bipush 52\n 134: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 137: aastore\n 138: aload_1\n 139: bipush 15\n 141: bipush 12\n 143: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 146: aastore\n 147: aload_1\n 148: bipush 16\n 150: bipush 50\n 152: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 155: aastore\n 156: aload_1\n 157: bipush 17\n 159: bipush 77\n 161: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 164: aastore\n 165: aload_1\n 166: bipush 18\n 168: bipush 91\n 170: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 173: aastore\n 174: aload_1\n 175: bipush 19\n 177: bipush 8\n 179: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 182: aastore\n 183: aload_1\n 184: aastore\n 185: aload_0\n 186: iconst_1\n 187: bipush 20\n 189: anewarray #39 // class java/lang/Integer\n 192: astore_1\n 193: aload_1\n 194: iconst_0\n 195: bipush 49\n 197: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 200: aastore\n 201: aload_1\n 202: iconst_1\n 203: bipush 49\n 205: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 208: aastore\n 209: aload_1\n 210: iconst_2\n 211: bipush 99\n 213: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 216: aastore\n 217: aload_1\n 218: iconst_3\n 219: bipush 40\n 221: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 224: aastore\n 225: aload_1\n 226: iconst_4\n 227: bipush 17\n 229: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 232: aastore\n 233: aload_1\n 234: iconst_5\n 235: bipush 81\n 237: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 240: aastore\n 241: aload_1\n 242: bipush 6\n 244: bipush 18\n 246: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 249: aastore\n 250: aload_1\n 251: bipush 7\n 253: bipush 57\n 255: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 258: aastore\n 259: aload_1\n 260: bipush 8\n 262: bipush 60\n 264: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 267: aastore\n 268: aload_1\n 269: bipush 9\n 271: bipush 87\n 273: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 276: aastore\n 277: aload_1\n 278: bipush 10\n 280: bipush 17\n 282: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 285: aastore\n 286: aload_1\n 287: bipush 11\n 289: bipush 40\n 291: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 294: aastore\n 295: aload_1\n 296: bipush 12\n 298: bipush 98\n 300: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 303: aastore\n 304: aload_1\n 305: bipush 13\n 307: bipush 43\n 309: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 312: aastore\n 313: aload_1\n 314: bipush 14\n 316: bipush 69\n 318: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 321: aastore\n 322: aload_1\n 323: bipush 15\n 325: bipush 48\n 327: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 330: aastore\n 331: aload_1\n 332: bipush 16\n 334: iconst_4\n 335: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 338: aastore\n 339: aload_1\n 340: bipush 17\n 342: bipush 56\n 344: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 347: aastore\n 348: aload_1\n 349: bipush 18\n 351: bipush 62\n 353: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 356: aastore\n 357: aload_1\n 358: bipush 19\n 360: iconst_0\n 361: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 364: aastore\n 365: aload_1\n 366: aastore\n 367: aload_0\n 368: iconst_2\n 369: bipush 20\n 371: anewarray #39 // class java/lang/Integer\n 374: astore_1\n 375: aload_1\n 376: iconst_0\n 377: bipush 81\n 379: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 382: aastore\n 383: aload_1\n 384: iconst_1\n 385: bipush 49\n 387: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 390: aastore\n 391: aload_1\n 392: iconst_2\n 393: bipush 31\n 395: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 398: aastore\n 399: aload_1\n 400: iconst_3\n 401: bipush 73\n 403: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 406: aastore\n 407: aload_1\n 408: iconst_4\n 409: bipush 55\n 411: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 414: aastore\n 415: aload_1\n 416: iconst_5\n 417: bipush 79\n 419: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 422: aastore\n 423: aload_1\n 424: bipush 6\n 426: bipush 14\n 428: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 431: aastore\n 432: aload_1\n 433: bipush 7\n 435: bipush 29\n 437: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 440: aastore\n 441: aload_1\n 442: bipush 8\n 444: bipush 93\n 446: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 449: aastore\n 450: aload_1\n 451: bipush 9\n 453: bipush 71\n 455: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 458: aastore\n 459: aload_1\n 460: bipush 10\n 462: bipush 40\n 464: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 467: aastore\n 468: aload_1\n 469: bipush 11\n 471: bipush 67\n 473: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 476: aastore\n 477: aload_1\n 478: bipush 12\n 480: bipush 53\n 482: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 485: aastore\n 486: aload_1\n 487: bipush 13\n 489: bipush 88\n 491: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 494: aastore\n 495: aload_1\n 496: bipush 14\n 498: bipush 30\n 500: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 503: aastore\n 504: aload_1\n 505: bipush 15\n 507: iconst_3\n 508: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 511: aastore\n 512: aload_1\n 513: bipush 16\n 515: bipush 49\n 517: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 520: aastore\n 521: aload_1\n 522: bipush 17\n 524: bipush 13\n 526: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 529: aastore\n 530: aload_1\n 531: bipush 18\n 533: bipush 36\n 535: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 538: aastore\n 539: aload_1\n 540: bipush 19\n 542: bipush 65\n 544: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 547: aastore\n 548: aload_1\n 549: aastore\n 550: aload_0\n 551: iconst_3\n 552: bipush 20\n 554: anewarray #39 // class java/lang/Integer\n 557: astore_1\n 558: aload_1\n 559: iconst_0\n 560: bipush 52\n 562: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 565: aastore\n 566: aload_1\n 567: iconst_1\n 568: bipush 70\n 570: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 573: aastore\n 574: aload_1\n 575: iconst_2\n 576: bipush 95\n 578: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 581: aastore\n 582: aload_1\n 583: iconst_3\n 584: bipush 23\n 586: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 589: aastore\n 590: aload_1\n 591: iconst_4\n 592: iconst_4\n 593: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 596: aastore\n 597: aload_1\n 598: iconst_5\n 599: bipush 60\n 601: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 604: aastore\n 605: aload_1\n 606: bipush 6\n 608: bipush 11\n 610: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 613: aastore\n 614: aload_1\n 615: bipush 7\n 617: bipush 42\n 619: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 622: aastore\n 623: aload_1\n 624: bipush 8\n 626: bipush 69\n 628: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 631: aastore\n 632: aload_1\n 633: bipush 9\n 635: bipush 24\n 637: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 640: aastore\n 641: aload_1\n 642: bipush 10\n 644: bipush 68\n 646: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 649: aastore\n 650: aload_1\n 651: bipush 11\n 653: bipush 56\n 655: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 658: aastore\n 659: aload_1\n 660: bipush 12\n 662: iconst_1\n 663: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 666: aastore\n 667: aload_1\n 668: bipush 13\n 670: bipush 32\n 672: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 675: aastore\n 676: aload_1\n 677: bipush 14\n 679: bipush 56\n 681: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 684: aastore\n 685: aload_1\n 686: bipush 15\n 688: bipush 71\n 690: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 693: aastore\n 694: aload_1\n 695: bipush 16\n 697: bipush 37\n 699: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 702: aastore\n 703: aload_1\n 704: bipush 17\n 706: iconst_2\n 707: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 710: aastore\n 711: aload_1\n 712: bipush 18\n 714: bipush 36\n 716: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 719: aastore\n 720: aload_1\n 721: bipush 19\n 723: bipush 91\n 725: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 728: aastore\n 729: aload_1\n 730: aastore\n 731: aload_0\n 732: iconst_4\n 733: bipush 20\n 735: anewarray #39 // class java/lang/Integer\n 738: astore_1\n 739: aload_1\n 740: iconst_0\n 741: bipush 22\n 743: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 746: aastore\n 747: aload_1\n 748: iconst_1\n 749: bipush 31\n 751: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 754: aastore\n 755: aload_1\n 756: iconst_2\n 757: bipush 16\n 759: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 762: aastore\n 763: aload_1\n 764: iconst_3\n 765: bipush 71\n 767: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 770: aastore\n 771: aload_1\n 772: iconst_4\n 773: bipush 51\n 775: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 778: aastore\n 779: aload_1\n 780: iconst_5\n 781: bipush 67\n 783: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 786: aastore\n 787: aload_1\n 788: bipush 6\n 790: bipush 63\n 792: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 795: aastore\n 796: aload_1\n 797: bipush 7\n 799: bipush 89\n 801: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 804: aastore\n 805: aload_1\n 806: bipush 8\n 808: bipush 41\n 810: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 813: aastore\n 814: aload_1\n 815: bipush 9\n 817: bipush 92\n 819: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 822: aastore\n 823: aload_1\n 824: bipush 10\n 826: bipush 36\n 828: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 831: aastore\n 832: aload_1\n 833: bipush 11\n 835: bipush 54\n 837: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 840: aastore\n 841: aload_1\n 842: bipush 12\n 844: bipush 22\n 846: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 849: aastore\n 850: aload_1\n 851: bipush 13\n 853: bipush 40\n 855: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 858: aastore\n 859: aload_1\n 860: bipush 14\n 862: bipush 40\n 864: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 867: aastore\n 868: aload_1\n 869: bipush 15\n 871: bipush 28\n 873: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 876: aastore\n 877: aload_1\n 878: bipush 16\n 880: bipush 66\n 882: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 885: aastore\n 886: aload_1\n 887: bipush 17\n 889: bipush 33\n 891: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 894: aastore\n 895: aload_1\n 896: bipush 18\n 898: bipush 13\n 900: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 903: aastore\n 904: aload_1\n 905: bipush 19\n 907: bipush 80\n 909: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 912: aastore\n 913: aload_1\n 914: aastore\n 915: aload_0\n 916: iconst_5\n 917: bipush 20\n 919: anewarray #39 // class java/lang/Integer\n 922: astore_1\n 923: aload_1\n 924: iconst_0\n 925: bipush 24\n 927: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 930: aastore\n 931: aload_1\n 932: iconst_1\n 933: bipush 47\n 935: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 938: aastore\n 939: aload_1\n 940: iconst_2\n 941: bipush 32\n 943: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 946: aastore\n 947: aload_1\n 948: iconst_3\n 949: bipush 60\n 951: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 954: aastore\n 955: aload_1\n 956: iconst_4\n 957: bipush 99\n 959: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 962: aastore\n 963: aload_1\n 964: iconst_5\n 965: iconst_3\n 966: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 969: aastore\n 970: aload_1\n 971: bipush 6\n 973: bipush 45\n 975: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 978: aastore\n 979: aload_1\n 980: bipush 7\n 982: iconst_2\n 983: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 986: aastore\n 987: aload_1\n 988: bipush 8\n 990: bipush 44\n 992: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 995: aastore\n 996: aload_1\n 997: bipush 9\n 999: bipush 75\n 1001: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1004: aastore\n 1005: aload_1\n 1006: bipush 10\n 1008: bipush 33\n 1010: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1013: aastore\n 1014: aload_1\n 1015: bipush 11\n 1017: bipush 53\n 1019: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1022: aastore\n 1023: aload_1\n 1024: bipush 12\n 1026: bipush 78\n 1028: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1031: aastore\n 1032: aload_1\n 1033: bipush 13\n 1035: bipush 36\n 1037: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1040: aastore\n 1041: aload_1\n 1042: bipush 14\n 1044: bipush 84\n 1046: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1049: aastore\n 1050: aload_1\n 1051: bipush 15\n 1053: bipush 20\n 1055: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1058: aastore\n 1059: aload_1\n 1060: bipush 16\n 1062: bipush 35\n 1064: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1067: aastore\n 1068: aload_1\n 1069: bipush 17\n 1071: bipush 17\n 1073: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1076: aastore\n 1077: aload_1\n 1078: bipush 18\n 1080: bipush 12\n 1082: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1085: aastore\n 1086: aload_1\n 1087: bipush 19\n 1089: bipush 50\n 1091: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1094: aastore\n 1095: aload_1\n 1096: aastore\n 1097: aload_0\n 1098: bipush 6\n 1100: bipush 20\n 1102: anewarray #39 // class java/lang/Integer\n 1105: astore_1\n 1106: aload_1\n 1107: iconst_0\n 1108: bipush 32\n 1110: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1113: aastore\n 1114: aload_1\n 1115: iconst_1\n 1116: bipush 98\n 1118: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1121: aastore\n 1122: aload_1\n 1123: iconst_2\n 1124: bipush 81\n 1126: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1129: aastore\n 1130: aload_1\n 1131: iconst_3\n 1132: bipush 28\n 1134: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1137: aastore\n 1138: aload_1\n 1139: iconst_4\n 1140: bipush 64\n 1142: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1145: aastore\n 1146: aload_1\n 1147: iconst_5\n 1148: bipush 23\n 1150: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1153: aastore\n 1154: aload_1\n 1155: bipush 6\n 1157: bipush 67\n 1159: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1162: aastore\n 1163: aload_1\n 1164: bipush 7\n 1166: bipush 10\n 1168: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1171: aastore\n 1172: aload_1\n 1173: bipush 8\n 1175: bipush 26\n 1177: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1180: aastore\n 1181: aload_1\n 1182: bipush 9\n 1184: bipush 38\n 1186: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1189: aastore\n 1190: aload_1\n 1191: bipush 10\n 1193: bipush 40\n 1195: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1198: aastore\n 1199: aload_1\n 1200: bipush 11\n 1202: bipush 67\n 1204: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1207: aastore\n 1208: aload_1\n 1209: bipush 12\n 1211: bipush 59\n 1213: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1216: aastore\n 1217: aload_1\n 1218: bipush 13\n 1220: bipush 54\n 1222: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1225: aastore\n 1226: aload_1\n 1227: bipush 14\n 1229: bipush 70\n 1231: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1234: aastore\n 1235: aload_1\n 1236: bipush 15\n 1238: bipush 66\n 1240: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1243: aastore\n 1244: aload_1\n 1245: bipush 16\n 1247: bipush 18\n 1249: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1252: aastore\n 1253: aload_1\n 1254: bipush 17\n 1256: bipush 38\n 1258: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1261: aastore\n 1262: aload_1\n 1263: bipush 18\n 1265: bipush 64\n 1267: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1270: aastore\n 1271: aload_1\n 1272: bipush 19\n 1274: bipush 70\n 1276: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1279: aastore\n 1280: aload_1\n 1281: aastore\n 1282: aload_0\n 1283: bipush 7\n 1285: bipush 20\n 1287: anewarray #39 // class java/lang/Integer\n 1290: astore_1\n 1291: aload_1\n 1292: iconst_0\n 1293: bipush 67\n 1295: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1298: aastore\n 1299: aload_1\n 1300: iconst_1\n 1301: bipush 26\n 1303: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1306: aastore\n 1307: aload_1\n 1308: iconst_2\n 1309: bipush 20\n 1311: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1314: aastore\n 1315: aload_1\n 1316: iconst_3\n 1317: bipush 68\n 1319: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1322: aastore\n 1323: aload_1\n 1324: iconst_4\n 1325: iconst_2\n 1326: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1329: aastore\n 1330: aload_1\n 1331: iconst_5\n 1332: bipush 62\n 1334: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1337: aastore\n 1338: aload_1\n 1339: bipush 6\n 1341: bipush 12\n 1343: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1346: aastore\n 1347: aload_1\n 1348: bipush 7\n 1350: bipush 20\n 1352: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1355: aastore\n 1356: aload_1\n 1357: bipush 8\n 1359: bipush 95\n 1361: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1364: aastore\n 1365: aload_1\n 1366: bipush 9\n 1368: bipush 63\n 1370: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1373: aastore\n 1374: aload_1\n 1375: bipush 10\n 1377: bipush 94\n 1379: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1382: aastore\n 1383: aload_1\n 1384: bipush 11\n 1386: bipush 39\n 1388: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1391: aastore\n 1392: aload_1\n 1393: bipush 12\n 1395: bipush 63\n 1397: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1400: aastore\n 1401: aload_1\n 1402: bipush 13\n 1404: bipush 8\n 1406: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1409: aastore\n 1410: aload_1\n 1411: bipush 14\n 1413: bipush 40\n 1415: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1418: aastore\n 1419: aload_1\n 1420: bipush 15\n 1422: bipush 91\n 1424: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1427: aastore\n 1428: aload_1\n 1429: bipush 16\n 1431: bipush 66\n 1433: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1436: aastore\n 1437: aload_1\n 1438: bipush 17\n 1440: bipush 49\n 1442: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1445: aastore\n 1446: aload_1\n 1447: bipush 18\n 1449: bipush 94\n 1451: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1454: aastore\n 1455: aload_1\n 1456: bipush 19\n 1458: bipush 21\n 1460: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1463: aastore\n 1464: aload_1\n 1465: aastore\n 1466: aload_0\n 1467: bipush 8\n 1469: bipush 20\n 1471: anewarray #39 // class java/lang/Integer\n 1474: astore_1\n 1475: aload_1\n 1476: iconst_0\n 1477: bipush 24\n 1479: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1482: aastore\n 1483: aload_1\n 1484: iconst_1\n 1485: bipush 55\n 1487: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1490: aastore\n 1491: aload_1\n 1492: iconst_2\n 1493: bipush 58\n 1495: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1498: aastore\n 1499: aload_1\n 1500: iconst_3\n 1501: iconst_5\n 1502: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1505: aastore\n 1506: aload_1\n 1507: iconst_4\n 1508: bipush 66\n 1510: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1513: aastore\n 1514: aload_1\n 1515: iconst_5\n 1516: bipush 73\n 1518: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1521: aastore\n 1522: aload_1\n 1523: bipush 6\n 1525: bipush 99\n 1527: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1530: aastore\n 1531: aload_1\n 1532: bipush 7\n 1534: bipush 26\n 1536: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1539: aastore\n 1540: aload_1\n 1541: bipush 8\n 1543: bipush 97\n 1545: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1548: aastore\n 1549: aload_1\n 1550: bipush 9\n 1552: bipush 17\n 1554: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1557: aastore\n 1558: aload_1\n 1559: bipush 10\n 1561: bipush 78\n 1563: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1566: aastore\n 1567: aload_1\n 1568: bipush 11\n 1570: bipush 78\n 1572: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1575: aastore\n 1576: aload_1\n 1577: bipush 12\n 1579: bipush 96\n 1581: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1584: aastore\n 1585: aload_1\n 1586: bipush 13\n 1588: bipush 83\n 1590: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1593: aastore\n 1594: aload_1\n 1595: bipush 14\n 1597: bipush 14\n 1599: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1602: aastore\n 1603: aload_1\n 1604: bipush 15\n 1606: bipush 88\n 1608: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1611: aastore\n 1612: aload_1\n 1613: bipush 16\n 1615: bipush 34\n 1617: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1620: aastore\n 1621: aload_1\n 1622: bipush 17\n 1624: bipush 89\n 1626: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1629: aastore\n 1630: aload_1\n 1631: bipush 18\n 1633: bipush 63\n 1635: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1638: aastore\n 1639: aload_1\n 1640: bipush 19\n 1642: bipush 72\n 1644: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1647: aastore\n 1648: aload_1\n 1649: aastore\n 1650: aload_0\n 1651: bipush 9\n 1653: bipush 20\n 1655: anewarray #39 // class java/lang/Integer\n 1658: astore_1\n 1659: aload_1\n 1660: iconst_0\n 1661: bipush 21\n 1663: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1666: aastore\n 1667: aload_1\n 1668: iconst_1\n 1669: bipush 36\n 1671: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1674: aastore\n 1675: aload_1\n 1676: iconst_2\n 1677: bipush 23\n 1679: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1682: aastore\n 1683: aload_1\n 1684: iconst_3\n 1685: bipush 9\n 1687: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1690: aastore\n 1691: aload_1\n 1692: iconst_4\n 1693: bipush 75\n 1695: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1698: aastore\n 1699: aload_1\n 1700: iconst_5\n 1701: iconst_0\n 1702: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1705: aastore\n 1706: aload_1\n 1707: bipush 6\n 1709: bipush 76\n 1711: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1714: aastore\n 1715: aload_1\n 1716: bipush 7\n 1718: bipush 44\n 1720: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1723: aastore\n 1724: aload_1\n 1725: bipush 8\n 1727: bipush 20\n 1729: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1732: aastore\n 1733: aload_1\n 1734: bipush 9\n 1736: bipush 45\n 1738: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1741: aastore\n 1742: aload_1\n 1743: bipush 10\n 1745: bipush 35\n 1747: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1750: aastore\n 1751: aload_1\n 1752: bipush 11\n 1754: bipush 14\n 1756: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1759: aastore\n 1760: aload_1\n 1761: bipush 12\n 1763: iconst_0\n 1764: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1767: aastore\n 1768: aload_1\n 1769: bipush 13\n 1771: bipush 61\n 1773: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1776: aastore\n 1777: aload_1\n 1778: bipush 14\n 1780: bipush 33\n 1782: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1785: aastore\n 1786: aload_1\n 1787: bipush 15\n 1789: bipush 97\n 1791: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1794: aastore\n 1795: aload_1\n 1796: bipush 16\n 1798: bipush 34\n 1800: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1803: aastore\n 1804: aload_1\n 1805: bipush 17\n 1807: bipush 31\n 1809: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1812: aastore\n 1813: aload_1\n 1814: bipush 18\n 1816: bipush 33\n 1818: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1821: aastore\n 1822: aload_1\n 1823: bipush 19\n 1825: bipush 95\n 1827: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1830: aastore\n 1831: aload_1\n 1832: aastore\n 1833: aload_0\n 1834: bipush 10\n 1836: bipush 20\n 1838: anewarray #39 // class java/lang/Integer\n 1841: astore_1\n 1842: aload_1\n 1843: iconst_0\n 1844: bipush 78\n 1846: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1849: aastore\n 1850: aload_1\n 1851: iconst_1\n 1852: bipush 17\n 1854: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1857: aastore\n 1858: aload_1\n 1859: iconst_2\n 1860: bipush 53\n 1862: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1865: aastore\n 1866: aload_1\n 1867: iconst_3\n 1868: bipush 28\n 1870: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1873: aastore\n 1874: aload_1\n 1875: iconst_4\n 1876: bipush 22\n 1878: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1881: aastore\n 1882: aload_1\n 1883: iconst_5\n 1884: bipush 75\n 1886: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1889: aastore\n 1890: aload_1\n 1891: bipush 6\n 1893: bipush 31\n 1895: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1898: aastore\n 1899: aload_1\n 1900: bipush 7\n 1902: bipush 67\n 1904: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1907: aastore\n 1908: aload_1\n 1909: bipush 8\n 1911: bipush 15\n 1913: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1916: aastore\n 1917: aload_1\n 1918: bipush 9\n 1920: bipush 94\n 1922: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1925: aastore\n 1926: aload_1\n 1927: bipush 10\n 1929: iconst_3\n 1930: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1933: aastore\n 1934: aload_1\n 1935: bipush 11\n 1937: bipush 80\n 1939: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1942: aastore\n 1943: aload_1\n 1944: bipush 12\n 1946: iconst_4\n 1947: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1950: aastore\n 1951: aload_1\n 1952: bipush 13\n 1954: bipush 62\n 1956: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1959: aastore\n 1960: aload_1\n 1961: bipush 14\n 1963: bipush 16\n 1965: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1968: aastore\n 1969: aload_1\n 1970: bipush 15\n 1972: bipush 14\n 1974: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1977: aastore\n 1978: aload_1\n 1979: bipush 16\n 1981: bipush 9\n 1983: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1986: aastore\n 1987: aload_1\n 1988: bipush 17\n 1990: bipush 53\n 1992: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1995: aastore\n 1996: aload_1\n 1997: bipush 18\n 1999: bipush 56\n 2001: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2004: aastore\n 2005: aload_1\n 2006: bipush 19\n 2008: bipush 92\n 2010: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2013: aastore\n 2014: aload_1\n 2015: aastore\n 2016: aload_0\n 2017: bipush 11\n 2019: bipush 20\n 2021: anewarray #39 // class java/lang/Integer\n 2024: astore_1\n 2025: aload_1\n 2026: iconst_0\n 2027: bipush 16\n 2029: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2032: aastore\n 2033: aload_1\n 2034: iconst_1\n 2035: bipush 39\n 2037: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2040: aastore\n 2041: aload_1\n 2042: iconst_2\n 2043: iconst_5\n 2044: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2047: aastore\n 2048: aload_1\n 2049: iconst_3\n 2050: bipush 42\n 2052: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2055: aastore\n 2056: aload_1\n 2057: iconst_4\n 2058: bipush 96\n 2060: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2063: aastore\n 2064: aload_1\n 2065: iconst_5\n 2066: bipush 35\n 2068: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2071: aastore\n 2072: aload_1\n 2073: bipush 6\n 2075: bipush 31\n 2077: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2080: aastore\n 2081: aload_1\n 2082: bipush 7\n 2084: bipush 47\n 2086: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2089: aastore\n 2090: aload_1\n 2091: bipush 8\n 2093: bipush 55\n 2095: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2098: aastore\n 2099: aload_1\n 2100: bipush 9\n 2102: bipush 58\n 2104: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2107: aastore\n 2108: aload_1\n 2109: bipush 10\n 2111: bipush 88\n 2113: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2116: aastore\n 2117: aload_1\n 2118: bipush 11\n 2120: bipush 24\n 2122: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2125: aastore\n 2126: aload_1\n 2127: bipush 12\n 2129: iconst_0\n 2130: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2133: aastore\n 2134: aload_1\n 2135: bipush 13\n 2137: bipush 17\n 2139: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2142: aastore\n 2143: aload_1\n 2144: bipush 14\n 2146: bipush 54\n 2148: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2151: aastore\n 2152: aload_1\n 2153: bipush 15\n 2155: bipush 24\n 2157: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2160: aastore\n 2161: aload_1\n 2162: bipush 16\n 2164: bipush 36\n 2166: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2169: aastore\n 2170: aload_1\n 2171: bipush 17\n 2173: bipush 29\n 2175: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2178: aastore\n 2179: aload_1\n 2180: bipush 18\n 2182: bipush 85\n 2184: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2187: aastore\n 2188: aload_1\n 2189: bipush 19\n 2191: bipush 57\n 2193: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2196: aastore\n 2197: aload_1\n 2198: aastore\n 2199: aload_0\n 2200: bipush 12\n 2202: bipush 20\n 2204: anewarray #39 // class java/lang/Integer\n 2207: astore_1\n 2208: aload_1\n 2209: iconst_0\n 2210: bipush 86\n 2212: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2215: aastore\n 2216: aload_1\n 2217: iconst_1\n 2218: bipush 56\n 2220: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2223: aastore\n 2224: aload_1\n 2225: iconst_2\n 2226: iconst_0\n 2227: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2230: aastore\n 2231: aload_1\n 2232: iconst_3\n 2233: bipush 48\n 2235: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2238: aastore\n 2239: aload_1\n 2240: iconst_4\n 2241: bipush 35\n 2243: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2246: aastore\n 2247: aload_1\n 2248: iconst_5\n 2249: bipush 71\n 2251: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2254: aastore\n 2255: aload_1\n 2256: bipush 6\n 2258: bipush 89\n 2260: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2263: aastore\n 2264: aload_1\n 2265: bipush 7\n 2267: bipush 7\n 2269: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2272: aastore\n 2273: aload_1\n 2274: bipush 8\n 2276: iconst_5\n 2277: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2280: aastore\n 2281: aload_1\n 2282: bipush 9\n 2284: bipush 44\n 2286: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2289: aastore\n 2290: aload_1\n 2291: bipush 10\n 2293: bipush 44\n 2295: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2298: aastore\n 2299: aload_1\n 2300: bipush 11\n 2302: bipush 37\n 2304: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2307: aastore\n 2308: aload_1\n 2309: bipush 12\n 2311: bipush 44\n 2313: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2316: aastore\n 2317: aload_1\n 2318: bipush 13\n 2320: bipush 60\n 2322: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2325: aastore\n 2326: aload_1\n 2327: bipush 14\n 2329: bipush 21\n 2331: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2334: aastore\n 2335: aload_1\n 2336: bipush 15\n 2338: bipush 58\n 2340: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2343: aastore\n 2344: aload_1\n 2345: bipush 16\n 2347: bipush 51\n 2349: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2352: aastore\n 2353: aload_1\n 2354: bipush 17\n 2356: bipush 54\n 2358: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2361: aastore\n 2362: aload_1\n 2363: bipush 18\n 2365: bipush 17\n 2367: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2370: aastore\n 2371: aload_1\n 2372: bipush 19\n 2374: bipush 58\n 2376: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2379: aastore\n 2380: aload_1\n 2381: aastore\n 2382: aload_0\n 2383: bipush 13\n 2385: bipush 20\n 2387: anewarray #39 // class java/lang/Integer\n 2390: astore_1\n 2391: aload_1\n 2392: iconst_0\n 2393: bipush 19\n 2395: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2398: aastore\n 2399: aload_1\n 2400: iconst_1\n 2401: bipush 80\n 2403: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2406: aastore\n 2407: aload_1\n 2408: iconst_2\n 2409: bipush 81\n 2411: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2414: aastore\n 2415: aload_1\n 2416: iconst_3\n 2417: bipush 68\n 2419: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2422: aastore\n 2423: aload_1\n 2424: iconst_4\n 2425: iconst_5\n 2426: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2429: aastore\n 2430: aload_1\n 2431: iconst_5\n 2432: bipush 94\n 2434: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2437: aastore\n 2438: aload_1\n 2439: bipush 6\n 2441: bipush 47\n 2443: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2446: aastore\n 2447: aload_1\n 2448: bipush 7\n 2450: bipush 69\n 2452: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2455: aastore\n 2456: aload_1\n 2457: bipush 8\n 2459: bipush 28\n 2461: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2464: aastore\n 2465: aload_1\n 2466: bipush 9\n 2468: bipush 73\n 2470: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2473: aastore\n 2474: aload_1\n 2475: bipush 10\n 2477: bipush 92\n 2479: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2482: aastore\n 2483: aload_1\n 2484: bipush 11\n 2486: bipush 13\n 2488: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2491: aastore\n 2492: aload_1\n 2493: bipush 12\n 2495: bipush 86\n 2497: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2500: aastore\n 2501: aload_1\n 2502: bipush 13\n 2504: bipush 52\n 2506: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2509: aastore\n 2510: aload_1\n 2511: bipush 14\n 2513: bipush 17\n 2515: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2518: aastore\n 2519: aload_1\n 2520: bipush 15\n 2522: bipush 77\n 2524: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2527: aastore\n 2528: aload_1\n 2529: bipush 16\n 2531: iconst_4\n 2532: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2535: aastore\n 2536: aload_1\n 2537: bipush 17\n 2539: bipush 89\n 2541: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2544: aastore\n 2545: aload_1\n 2546: bipush 18\n 2548: bipush 55\n 2550: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2553: aastore\n 2554: aload_1\n 2555: bipush 19\n 2557: bipush 40\n 2559: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2562: aastore\n 2563: aload_1\n 2564: aastore\n 2565: aload_0\n 2566: bipush 14\n 2568: bipush 20\n 2570: anewarray #39 // class java/lang/Integer\n 2573: astore_1\n 2574: aload_1\n 2575: iconst_0\n 2576: iconst_4\n 2577: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2580: aastore\n 2581: aload_1\n 2582: iconst_1\n 2583: bipush 52\n 2585: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2588: aastore\n 2589: aload_1\n 2590: iconst_2\n 2591: bipush 8\n 2593: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2596: aastore\n 2597: aload_1\n 2598: iconst_3\n 2599: bipush 83\n 2601: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2604: aastore\n 2605: aload_1\n 2606: iconst_4\n 2607: bipush 97\n 2609: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2612: aastore\n 2613: aload_1\n 2614: iconst_5\n 2615: bipush 35\n 2617: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2620: aastore\n 2621: aload_1\n 2622: bipush 6\n 2624: bipush 99\n 2626: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2629: aastore\n 2630: aload_1\n 2631: bipush 7\n 2633: bipush 16\n 2635: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2638: aastore\n 2639: aload_1\n 2640: bipush 8\n 2642: bipush 7\n 2644: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2647: aastore\n 2648: aload_1\n 2649: bipush 9\n 2651: bipush 97\n 2653: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2656: aastore\n 2657: aload_1\n 2658: bipush 10\n 2660: bipush 57\n 2662: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2665: aastore\n 2666: aload_1\n 2667: bipush 11\n 2669: bipush 32\n 2671: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2674: aastore\n 2675: aload_1\n 2676: bipush 12\n 2678: bipush 16\n 2680: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2683: aastore\n 2684: aload_1\n 2685: bipush 13\n 2687: bipush 26\n 2689: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2692: aastore\n 2693: aload_1\n 2694: bipush 14\n 2696: bipush 26\n 2698: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2701: aastore\n 2702: aload_1\n 2703: bipush 15\n 2705: bipush 79\n 2707: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2710: aastore\n 2711: aload_1\n 2712: bipush 16\n 2714: bipush 33\n 2716: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2719: aastore\n 2720: aload_1\n 2721: bipush 17\n 2723: bipush 27\n 2725: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2728: aastore\n 2729: aload_1\n 2730: bipush 18\n 2732: bipush 98\n 2734: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2737: aastore\n 2738: aload_1\n 2739: bipush 19\n 2741: bipush 66\n 2743: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2746: aastore\n 2747: aload_1\n 2748: aastore\n 2749: aload_0\n 2750: bipush 15\n 2752: bipush 20\n 2754: anewarray #39 // class java/lang/Integer\n 2757: astore_1\n 2758: aload_1\n 2759: iconst_0\n 2760: bipush 88\n 2762: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2765: aastore\n 2766: aload_1\n 2767: iconst_1\n 2768: bipush 36\n 2770: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2773: aastore\n 2774: aload_1\n 2775: iconst_2\n 2776: bipush 68\n 2778: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2781: aastore\n 2782: aload_1\n 2783: iconst_3\n 2784: bipush 87\n 2786: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2789: aastore\n 2790: aload_1\n 2791: iconst_4\n 2792: bipush 57\n 2794: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2797: aastore\n 2798: aload_1\n 2799: iconst_5\n 2800: bipush 62\n 2802: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2805: aastore\n 2806: aload_1\n 2807: bipush 6\n 2809: bipush 20\n 2811: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2814: aastore\n 2815: aload_1\n 2816: bipush 7\n 2818: bipush 72\n 2820: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2823: aastore\n 2824: aload_1\n 2825: bipush 8\n 2827: iconst_3\n 2828: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2831: aastore\n 2832: aload_1\n 2833: bipush 9\n 2835: bipush 46\n 2837: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2840: aastore\n 2841: aload_1\n 2842: bipush 10\n 2844: bipush 33\n 2846: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2849: aastore\n 2850: aload_1\n 2851: bipush 11\n 2853: bipush 67\n 2855: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2858: aastore\n 2859: aload_1\n 2860: bipush 12\n 2862: bipush 46\n 2864: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2867: aastore\n 2868: aload_1\n 2869: bipush 13\n 2871: bipush 55\n 2873: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2876: aastore\n 2877: aload_1\n 2878: bipush 14\n 2880: bipush 12\n 2882: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2885: aastore\n 2886: aload_1\n 2887: bipush 15\n 2889: bipush 32\n 2891: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2894: aastore\n 2895: aload_1\n 2896: bipush 16\n 2898: bipush 63\n 2900: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2903: aastore\n 2904: aload_1\n 2905: bipush 17\n 2907: bipush 93\n 2909: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2912: aastore\n 2913: aload_1\n 2914: bipush 18\n 2916: bipush 53\n 2918: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2921: aastore\n 2922: aload_1\n 2923: bipush 19\n 2925: bipush 69\n 2927: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2930: aastore\n 2931: aload_1\n 2932: aastore\n 2933: aload_0\n 2934: bipush 16\n 2936: bipush 20\n 2938: anewarray #39 // class java/lang/Integer\n 2941: astore_1\n 2942: aload_1\n 2943: iconst_0\n 2944: iconst_4\n 2945: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2948: aastore\n 2949: aload_1\n 2950: iconst_1\n 2951: bipush 42\n 2953: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2956: aastore\n 2957: aload_1\n 2958: iconst_2\n 2959: bipush 16\n 2961: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2964: aastore\n 2965: aload_1\n 2966: iconst_3\n 2967: bipush 73\n 2969: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2972: aastore\n 2973: aload_1\n 2974: iconst_4\n 2975: bipush 38\n 2977: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2980: aastore\n 2981: aload_1\n 2982: iconst_5\n 2983: bipush 25\n 2985: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2988: aastore\n 2989: aload_1\n 2990: bipush 6\n 2992: bipush 39\n 2994: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 2997: aastore\n 2998: aload_1\n 2999: bipush 7\n 3001: bipush 11\n 3003: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3006: aastore\n 3007: aload_1\n 3008: bipush 8\n 3010: bipush 24\n 3012: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3015: aastore\n 3016: aload_1\n 3017: bipush 9\n 3019: bipush 94\n 3021: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3024: aastore\n 3025: aload_1\n 3026: bipush 10\n 3028: bipush 72\n 3030: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3033: aastore\n 3034: aload_1\n 3035: bipush 11\n 3037: bipush 18\n 3039: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3042: aastore\n 3043: aload_1\n 3044: bipush 12\n 3046: bipush 8\n 3048: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3051: aastore\n 3052: aload_1\n 3053: bipush 13\n 3055: bipush 46\n 3057: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3060: aastore\n 3061: aload_1\n 3062: bipush 14\n 3064: bipush 29\n 3066: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3069: aastore\n 3070: aload_1\n 3071: bipush 15\n 3073: bipush 32\n 3075: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3078: aastore\n 3079: aload_1\n 3080: bipush 16\n 3082: bipush 40\n 3084: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3087: aastore\n 3088: aload_1\n 3089: bipush 17\n 3091: bipush 62\n 3093: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3096: aastore\n 3097: aload_1\n 3098: bipush 18\n 3100: bipush 76\n 3102: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3105: aastore\n 3106: aload_1\n 3107: bipush 19\n 3109: bipush 36\n 3111: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3114: aastore\n 3115: aload_1\n 3116: aastore\n 3117: aload_0\n 3118: bipush 17\n 3120: bipush 20\n 3122: anewarray #39 // class java/lang/Integer\n 3125: astore_1\n 3126: aload_1\n 3127: iconst_0\n 3128: bipush 20\n 3130: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3133: aastore\n 3134: aload_1\n 3135: iconst_1\n 3136: bipush 69\n 3138: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3141: aastore\n 3142: aload_1\n 3143: iconst_2\n 3144: bipush 36\n 3146: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3149: aastore\n 3150: aload_1\n 3151: iconst_3\n 3152: bipush 41\n 3154: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3157: aastore\n 3158: aload_1\n 3159: iconst_4\n 3160: bipush 72\n 3162: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3165: aastore\n 3166: aload_1\n 3167: iconst_5\n 3168: bipush 30\n 3170: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3173: aastore\n 3174: aload_1\n 3175: bipush 6\n 3177: bipush 23\n 3179: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3182: aastore\n 3183: aload_1\n 3184: bipush 7\n 3186: bipush 88\n 3188: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3191: aastore\n 3192: aload_1\n 3193: bipush 8\n 3195: bipush 34\n 3197: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3200: aastore\n 3201: aload_1\n 3202: bipush 9\n 3204: bipush 62\n 3206: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3209: aastore\n 3210: aload_1\n 3211: bipush 10\n 3213: bipush 99\n 3215: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3218: aastore\n 3219: aload_1\n 3220: bipush 11\n 3222: bipush 69\n 3224: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3227: aastore\n 3228: aload_1\n 3229: bipush 12\n 3231: bipush 82\n 3233: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3236: aastore\n 3237: aload_1\n 3238: bipush 13\n 3240: bipush 67\n 3242: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3245: aastore\n 3246: aload_1\n 3247: bipush 14\n 3249: bipush 59\n 3251: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3254: aastore\n 3255: aload_1\n 3256: bipush 15\n 3258: bipush 85\n 3260: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3263: aastore\n 3264: aload_1\n 3265: bipush 16\n 3267: bipush 74\n 3269: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3272: aastore\n 3273: aload_1\n 3274: bipush 17\n 3276: iconst_4\n 3277: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3280: aastore\n 3281: aload_1\n 3282: bipush 18\n 3284: bipush 36\n 3286: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3289: aastore\n 3290: aload_1\n 3291: bipush 19\n 3293: bipush 16\n 3295: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3298: aastore\n 3299: aload_1\n 3300: aastore\n 3301: aload_0\n 3302: bipush 18\n 3304: bipush 20\n 3306: anewarray #39 // class java/lang/Integer\n 3309: astore_1\n 3310: aload_1\n 3311: iconst_0\n 3312: bipush 20\n 3314: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3317: aastore\n 3318: aload_1\n 3319: iconst_1\n 3320: bipush 73\n 3322: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3325: aastore\n 3326: aload_1\n 3327: iconst_2\n 3328: bipush 35\n 3330: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3333: aastore\n 3334: aload_1\n 3335: iconst_3\n 3336: bipush 29\n 3338: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3341: aastore\n 3342: aload_1\n 3343: iconst_4\n 3344: bipush 78\n 3346: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3349: aastore\n 3350: aload_1\n 3351: iconst_5\n 3352: bipush 31\n 3354: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3357: aastore\n 3358: aload_1\n 3359: bipush 6\n 3361: bipush 90\n 3363: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3366: aastore\n 3367: aload_1\n 3368: bipush 7\n 3370: iconst_1\n 3371: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3374: aastore\n 3375: aload_1\n 3376: bipush 8\n 3378: bipush 74\n 3380: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3383: aastore\n 3384: aload_1\n 3385: bipush 9\n 3387: bipush 31\n 3389: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3392: aastore\n 3393: aload_1\n 3394: bipush 10\n 3396: bipush 49\n 3398: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3401: aastore\n 3402: aload_1\n 3403: bipush 11\n 3405: bipush 71\n 3407: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3410: aastore\n 3411: aload_1\n 3412: bipush 12\n 3414: bipush 48\n 3416: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3419: aastore\n 3420: aload_1\n 3421: bipush 13\n 3423: bipush 86\n 3425: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3428: aastore\n 3429: aload_1\n 3430: bipush 14\n 3432: bipush 81\n 3434: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3437: aastore\n 3438: aload_1\n 3439: bipush 15\n 3441: bipush 16\n 3443: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3446: aastore\n 3447: aload_1\n 3448: bipush 16\n 3450: bipush 23\n 3452: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3455: aastore\n 3456: aload_1\n 3457: bipush 17\n 3459: bipush 57\n 3461: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3464: aastore\n 3465: aload_1\n 3466: bipush 18\n 3468: iconst_5\n 3469: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3472: aastore\n 3473: aload_1\n 3474: bipush 19\n 3476: bipush 54\n 3478: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3481: aastore\n 3482: aload_1\n 3483: aastore\n 3484: aload_0\n 3485: bipush 19\n 3487: bipush 20\n 3489: anewarray #39 // class java/lang/Integer\n 3492: astore_1\n 3493: aload_1\n 3494: iconst_0\n 3495: iconst_1\n 3496: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3499: aastore\n 3500: aload_1\n 3501: iconst_1\n 3502: bipush 70\n 3504: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3507: aastore\n 3508: aload_1\n 3509: iconst_2\n 3510: bipush 54\n 3512: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3515: aastore\n 3516: aload_1\n 3517: iconst_3\n 3518: bipush 71\n 3520: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3523: aastore\n 3524: aload_1\n 3525: iconst_4\n 3526: bipush 83\n 3528: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3531: aastore\n 3532: aload_1\n 3533: iconst_5\n 3534: bipush 51\n 3536: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3539: aastore\n 3540: aload_1\n 3541: bipush 6\n 3543: bipush 54\n 3545: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3548: aastore\n 3549: aload_1\n 3550: bipush 7\n 3552: bipush 69\n 3554: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3557: aastore\n 3558: aload_1\n 3559: bipush 8\n 3561: bipush 16\n 3563: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3566: aastore\n 3567: aload_1\n 3568: bipush 9\n 3570: bipush 92\n 3572: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3575: aastore\n 3576: aload_1\n 3577: bipush 10\n 3579: bipush 33\n 3581: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3584: aastore\n 3585: aload_1\n 3586: bipush 11\n 3588: bipush 48\n 3590: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3593: aastore\n 3594: aload_1\n 3595: bipush 12\n 3597: bipush 61\n 3599: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3602: aastore\n 3603: aload_1\n 3604: bipush 13\n 3606: bipush 43\n 3608: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3611: aastore\n 3612: aload_1\n 3613: bipush 14\n 3615: bipush 52\n 3617: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3620: aastore\n 3621: aload_1\n 3622: bipush 15\n 3624: iconst_1\n 3625: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3628: aastore\n 3629: aload_1\n 3630: bipush 16\n 3632: bipush 89\n 3634: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3637: aastore\n 3638: aload_1\n 3639: bipush 17\n 3641: bipush 19\n 3643: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3646: aastore\n 3647: aload_1\n 3648: bipush 18\n 3650: bipush 67\n 3652: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3655: aastore\n 3656: aload_1\n 3657: bipush 19\n 3659: bipush 48\n 3661: invokestatic #101 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 3664: aastore\n 3665: aload_1\n 3666: aastore\n 3667: aload_0\n 3668: putstatic #10 // Field grid:[[Ljava/lang/Integer;\n 3671: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem35.kt
|
/**
* Circular primes
*
* The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves
* prime.
*
* There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97.
*
* How many circular primes are there below one million?
*
* https://projecteuler.net/problem=35
*/
fun main() {
println(197.isCircularPrime())
println(countCircularPrimes(limit = 100))
println(countCircularPrimes(limit = 1_000_000))
}
private fun countCircularPrimes(limit: Long): Int {
return primes(limit).count(Int::isCircularPrime)
}
private fun Int.isCircularPrime(): Boolean {
val digits = digits()
for (i in digits.indices) {
val nextDigits = digits.subList(fromIndex = i, digits.size) + digits.subList(fromIndex = 0, toIndex = i)
if (!isPrime(nextDigits.joinToString(separator = "").toLong())) {
return false
}
}
return true
}
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem35Kt.class",
"javap": "Compiled from \"Problem35.kt\"\npublic final class Problem35Kt {\n public static final void main();\n Code:\n 0: sipush 197\n 3: invokestatic #10 // Method isCircularPrime:(I)Z\n 6: istore_0\n 7: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 10: iload_0\n 11: invokevirtual #22 // Method java/io/PrintStream.println:(Z)V\n 14: ldc2_w #23 // long 100l\n 17: invokestatic #28 // Method countCircularPrimes:(J)I\n 20: istore_0\n 21: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 24: iload_0\n 25: invokevirtual #31 // Method java/io/PrintStream.println:(I)V\n 28: ldc2_w #32 // long 1000000l\n 31: invokestatic #28 // Method countCircularPrimes:(J)I\n 34: istore_0\n 35: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 38: iload_0\n 39: invokevirtual #31 // Method java/io/PrintStream.println:(I)V\n 42: return\n\n private static final int countCircularPrimes(long);\n Code:\n 0: lload_0\n 1: invokestatic #39 // Method Problem10Kt.primes:(J)Ljava/util/List;\n 4: checkcast #41 // class java/lang/Iterable\n 7: astore_2\n 8: iconst_0\n 9: istore_3\n 10: aload_2\n 11: instanceof #43 // class java/util/Collection\n 14: ifeq 33\n 17: aload_2\n 18: checkcast #43 // class java/util/Collection\n 21: invokeinterface #47, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 26: ifeq 33\n 29: iconst_0\n 30: goto 100\n 33: iconst_0\n 34: istore 4\n 36: aload_2\n 37: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 5\n 44: aload 5\n 46: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 98\n 54: aload 5\n 56: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 6\n 63: aload 6\n 65: checkcast #62 // class java/lang/Number\n 68: invokevirtual #66 // Method java/lang/Number.intValue:()I\n 71: istore 7\n 73: iconst_0\n 74: istore 8\n 76: iload 7\n 78: invokestatic #10 // Method isCircularPrime:(I)Z\n 81: ifeq 44\n 84: iinc 4, 1\n 87: iload 4\n 89: ifge 44\n 92: invokestatic #71 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 95: goto 44\n 98: iload 4\n 100: ireturn\n\n private static final boolean isCircularPrime(int);\n Code:\n 0: iload_0\n 1: invokestatic #88 // Method Problem32Kt.digits:(I)Ljava/util/List;\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: checkcast #43 // class java/util/Collection\n 11: invokeinterface #91, 1 // InterfaceMethod java/util/Collection.size:()I\n 16: istore_3\n 17: iload_2\n 18: iload_3\n 19: if_icmpge 92\n 22: aload_1\n 23: iload_2\n 24: aload_1\n 25: invokeinterface #94, 1 // InterfaceMethod java/util/List.size:()I\n 30: invokeinterface #98, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 35: checkcast #43 // class java/util/Collection\n 38: aload_1\n 39: iconst_0\n 40: iload_2\n 41: invokeinterface #98, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 46: checkcast #41 // class java/lang/Iterable\n 49: invokestatic #102 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 52: astore 4\n 54: aload 4\n 56: checkcast #41 // class java/lang/Iterable\n 59: ldc #104 // String\n 61: checkcast #106 // class java/lang/CharSequence\n 64: aconst_null\n 65: aconst_null\n 66: iconst_0\n 67: aconst_null\n 68: aconst_null\n 69: bipush 62\n 71: aconst_null\n 72: 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 75: invokestatic #116 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 78: invokestatic #122 // Method Problem7Kt.isPrime:(J)Z\n 81: ifne 86\n 84: iconst_0\n 85: ireturn\n 86: iinc 2, 1\n 89: goto 17\n 92: iconst_1\n 93: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #129 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem25.kt
|
import kotlin.math.max
/**
* 1000-digit Fibonacci number
*
* The Fibonacci sequence is defined by the recurrence relation:
* Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1.
* Hence the first 12 terms will be:
* F1 = 1
* F2 = 1
* F3 = 2
* F4 = 3
* F5 = 5
* F6 = 8
* F7 = 13
* F8 = 21
* F9 = 34
* F10 = 55
* F11 = 89
* F12 = 144
*
* The 12th term, F12, is the first term to contain three digits.
* What is the index of the first term in the Fibonacci sequence to contain 1000 digits?
*
* https://projecteuler.net/problem=25
*/
fun main() {
println(fibIndexOfDigitsCount(digitsCount = 3))
println(fibIndexOfDigitsCount(digitsCount = 1_000))
}
private fun fibIndexOfDigitsCount(digitsCount: Int): Int {
if (digitsCount == 1) return 1
val f1 = mutableListOf(1)
val f2 = mutableListOf(1)
var index = 2
var turn = true // true for f1, false for f2
while (f1.size != digitsCount && f2.size != digitsCount) {
if (turn) {
sum(f1, f2)
} else {
sum(f2, f1)
}
turn = !turn
index++
}
return index
}
private fun sum(list1: MutableList<Int>, list2: MutableList<Int>) {
var acc = 0
for (i in 0 until max(list1.size, list2.size)) {
val sum = list1.getOrElse(i) { 0 } + list2.getOrElse(i) { 0 } + acc
if (i < list1.size) {
list1[i] = sum % 10
} else {
list1.add(sum % 10)
}
acc = sum / 10
}
while (acc != 0) {
list1.add(acc % 10)
acc /= 10
}
}
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem25Kt.class",
"javap": "Compiled from \"Problem25.kt\"\npublic final class Problem25Kt {\n public static final void main();\n Code:\n 0: iconst_3\n 1: invokestatic #10 // Method fibIndexOfDigitsCount:(I)I\n 4: istore_0\n 5: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 8: iload_0\n 9: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 12: sipush 1000\n 15: invokestatic #10 // Method fibIndexOfDigitsCount:(I)I\n 18: istore_0\n 19: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 22: iload_0\n 23: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 26: return\n\n private static final int fibIndexOfDigitsCount(int);\n Code:\n 0: iload_0\n 1: iconst_1\n 2: if_icmpne 7\n 5: iconst_1\n 6: ireturn\n 7: iconst_1\n 8: anewarray #24 // class java/lang/Integer\n 11: astore_2\n 12: aload_2\n 13: iconst_0\n 14: iconst_1\n 15: invokestatic #28 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 18: aastore\n 19: aload_2\n 20: invokestatic #34 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 23: astore_1\n 24: iconst_1\n 25: anewarray #24 // class java/lang/Integer\n 28: astore_3\n 29: aload_3\n 30: iconst_0\n 31: iconst_1\n 32: invokestatic #28 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 35: aastore\n 36: aload_3\n 37: invokestatic #34 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 40: astore_2\n 41: iconst_2\n 42: istore_3\n 43: iconst_1\n 44: istore 4\n 46: aload_1\n 47: invokeinterface #40, 1 // InterfaceMethod java/util/List.size:()I\n 52: iload_0\n 53: if_icmpeq 102\n 56: aload_2\n 57: invokeinterface #40, 1 // InterfaceMethod java/util/List.size:()I\n 62: iload_0\n 63: if_icmpeq 102\n 66: iload 4\n 68: ifeq 79\n 71: aload_1\n 72: aload_2\n 73: invokestatic #44 // Method sum:(Ljava/util/List;Ljava/util/List;)V\n 76: goto 84\n 79: aload_2\n 80: aload_1\n 81: invokestatic #44 // Method sum:(Ljava/util/List;Ljava/util/List;)V\n 84: iload 4\n 86: ifne 93\n 89: iconst_1\n 90: goto 94\n 93: iconst_0\n 94: istore 4\n 96: iinc 3, 1\n 99: goto 46\n 102: iload_3\n 103: ireturn\n\n private static final void sum(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>);\n Code:\n 0: iconst_0\n 1: istore_2\n 2: iconst_0\n 3: istore_3\n 4: aload_0\n 5: invokeinterface #40, 1 // InterfaceMethod java/util/List.size:()I\n 10: aload_1\n 11: invokeinterface #40, 1 // InterfaceMethod java/util/List.size:()I\n 16: invokestatic #59 // Method java/lang/Math.max:(II)I\n 19: istore 4\n 21: iload_3\n 22: iload 4\n 24: if_icmpge 212\n 27: aload_0\n 28: astore 6\n 30: iconst_0\n 31: iload_3\n 32: if_icmpgt 54\n 35: iload_3\n 36: aload 6\n 38: invokeinterface #40, 1 // InterfaceMethod java/util/List.size:()I\n 43: if_icmpge 50\n 46: iconst_1\n 47: goto 55\n 50: iconst_0\n 51: goto 55\n 54: iconst_0\n 55: ifeq 69\n 58: aload 6\n 60: iload_3\n 61: invokeinterface #63, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 66: goto 79\n 69: iload_3\n 70: istore 7\n 72: iconst_0\n 73: istore 8\n 75: iconst_0\n 76: invokestatic #28 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 79: checkcast #65 // class java/lang/Number\n 82: invokevirtual #68 // Method java/lang/Number.intValue:()I\n 85: aload_1\n 86: astore 6\n 88: iconst_0\n 89: iload_3\n 90: if_icmpgt 112\n 93: iload_3\n 94: aload 6\n 96: invokeinterface #40, 1 // InterfaceMethod java/util/List.size:()I\n 101: if_icmpge 108\n 104: iconst_1\n 105: goto 113\n 108: iconst_0\n 109: goto 113\n 112: iconst_0\n 113: ifeq 127\n 116: aload 6\n 118: iload_3\n 119: invokeinterface #63, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 124: goto 145\n 127: iload_3\n 128: istore 7\n 130: istore 9\n 132: iconst_0\n 133: istore 8\n 135: iconst_0\n 136: invokestatic #28 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 139: astore 10\n 141: iload 9\n 143: aload 10\n 145: checkcast #65 // class java/lang/Number\n 148: invokevirtual #68 // Method java/lang/Number.intValue:()I\n 151: iadd\n 152: iload_2\n 153: iadd\n 154: istore 5\n 156: iload_3\n 157: aload_0\n 158: invokeinterface #40, 1 // InterfaceMethod java/util/List.size:()I\n 163: if_icmpge 185\n 166: aload_0\n 167: iload_3\n 168: iload 5\n 170: bipush 10\n 172: irem\n 173: invokestatic #28 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 176: invokeinterface #72, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 181: pop\n 182: goto 200\n 185: aload_0\n 186: iload 5\n 188: bipush 10\n 190: irem\n 191: invokestatic #28 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 194: invokeinterface #76, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 199: pop\n 200: iload 5\n 202: bipush 10\n 204: idiv\n 205: istore_2\n 206: iinc 3, 1\n 209: goto 21\n 212: iload_2\n 213: ifeq 238\n 216: aload_0\n 217: iload_2\n 218: bipush 10\n 220: irem\n 221: invokestatic #28 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 224: invokeinterface #76, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 229: pop\n 230: iload_2\n 231: bipush 10\n 233: idiv\n 234: istore_2\n 235: goto 212\n 238: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #86 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem3.kt
|
import kotlin.math.sqrt
/**
* Largest prime factor
*
* The prime factors of 13195 are 5, 7, 13 and 29.
* What is the largest prime factor of the number 600851475143 ?
*
* https://projecteuler.net/problem=3
*/
fun main() {
println(solution3(600851475143L))
}
private fun solution3(n: Long): Long {
var num = n
var lastFactor = if (n % 2 == 0L) {
num /= 2
while (num % 2 == 0L) {
num /= 2
}
2L
} else {
1L
}
var factor = 3L
var maxFactor = sqrt(num.toDouble()).toLong()
while (num > 1 && factor <= maxFactor) {
if (num % factor == 0L) {
num /= factor
lastFactor = factor
while (num % factor == 0L) {
num /= factor
}
maxFactor = sqrt(num.toDouble()).toLong()
}
factor += 2
}
return if (num == 1L) lastFactor else num
}
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem3Kt.class",
"javap": "Compiled from \"Problem3.kt\"\npublic final class Problem3Kt {\n public static final void main();\n Code:\n 0: ldc2_w #7 // long 600851475143l\n 3: invokestatic #12 // Method solution3:(J)J\n 6: lstore_0\n 7: getstatic #18 // Field java/lang/System.out:Ljava/io/PrintStream;\n 10: lload_0\n 11: invokevirtual #24 // Method java/io/PrintStream.println:(J)V\n 14: return\n\n private static final long solution3(long);\n Code:\n 0: lload_0\n 1: lstore_2\n 2: lload_0\n 3: iconst_2\n 4: i2l\n 5: lrem\n 6: lconst_0\n 7: lcmp\n 8: ifne 39\n 11: lload_2\n 12: iconst_2\n 13: i2l\n 14: ldiv\n 15: lstore_2\n 16: lload_2\n 17: iconst_2\n 18: i2l\n 19: lrem\n 20: lconst_0\n 21: lcmp\n 22: ifne 33\n 25: lload_2\n 26: iconst_2\n 27: i2l\n 28: ldiv\n 29: lstore_2\n 30: goto 16\n 33: ldc2_w #25 // long 2l\n 36: goto 40\n 39: lconst_1\n 40: lstore 4\n 42: ldc2_w #27 // long 3l\n 45: lstore 6\n 47: lload_2\n 48: l2d\n 49: invokestatic #34 // Method java/lang/Math.sqrt:(D)D\n 52: d2l\n 53: lstore 8\n 55: lload_2\n 56: lconst_1\n 57: lcmp\n 58: ifle 122\n 61: lload 6\n 63: lload 8\n 65: lcmp\n 66: ifgt 122\n 69: lload_2\n 70: lload 6\n 72: lrem\n 73: lconst_0\n 74: lcmp\n 75: ifne 112\n 78: lload_2\n 79: lload 6\n 81: ldiv\n 82: lstore_2\n 83: lload 6\n 85: lstore 4\n 87: lload_2\n 88: lload 6\n 90: lrem\n 91: lconst_0\n 92: lcmp\n 93: ifne 104\n 96: lload_2\n 97: lload 6\n 99: ldiv\n 100: lstore_2\n 101: goto 87\n 104: lload_2\n 105: l2d\n 106: invokestatic #34 // Method java/lang/Math.sqrt:(D)D\n 109: d2l\n 110: lstore 8\n 112: lload 6\n 114: iconst_2\n 115: i2l\n 116: ladd\n 117: lstore 6\n 119: goto 55\n 122: lload_2\n 123: lconst_1\n 124: lcmp\n 125: ifne 133\n 128: lload 4\n 130: goto 134\n 133: lload_2\n 134: lreturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #43 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem12.kt
|
/**
* Highly divisible triangular number
*
* The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be
* 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:
*
* 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
*
* Let us list the factors of the first seven triangle numbers:
*
* 1: 1
* 3: 1,3
* 6: 1,2,3,6
* 10: 1,2,5,10
* 15: 1,3,5,15
* 21: 1,3,7,21
* 28: 1,2,4,7,14,28
* We can see that 28 is the first triangle number to have over five divisors.
*
* What is the value of the first triangle number to have over five hundred divisors?
*
* https://projecteuler.net/problem=12
*/
fun main() {
println(highlyDivisibleTriangularNumber(5))
println(highlyDivisibleTriangularNumber(500))
}
private fun highlyDivisibleTriangularNumber(n: Int): Int {
var num = 1
while (true) {
val triangular = (num * (num + 1)) / 2
val numberOfFactors = primeFactorizationOf(triangular)
.map { it.value + 1 }
.fold(1L) { acc, i -> acc * i }
if (numberOfFactors > n) {
return triangular
}
num++
}
}
fun primeFactorizationOf(n: Int): Map<Int, Int> = buildMap {
var num = n
while (num != 1) {
primeLoop@ for (i in 1..n) {
if (primes[i] == 0) {
primes[i] = findPrime(i).toInt()
}
val prime = primes[i]
if (num % prime == 0) {
num /= prime
set(prime, getOrDefault(prime, 0) + 1)
break@primeLoop
}
}
}
}
private val primes = IntArray(65500) { 0 }
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem12Kt.class",
"javap": "Compiled from \"Problem12.kt\"\npublic final class Problem12Kt {\n private static final int[] primes;\n\n public static final void main();\n Code:\n 0: iconst_5\n 1: invokestatic #10 // Method highlyDivisibleTriangularNumber:(I)I\n 4: istore_0\n 5: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 8: iload_0\n 9: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 12: sipush 500\n 15: invokestatic #10 // Method highlyDivisibleTriangularNumber:(I)I\n 18: istore_0\n 19: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 22: iload_0\n 23: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 26: return\n\n private static final int highlyDivisibleTriangularNumber(int);\n Code:\n 0: iconst_1\n 1: istore_1\n 2: nop\n 3: iload_1\n 4: iload_1\n 5: iconst_1\n 6: iadd\n 7: imul\n 8: iconst_2\n 9: idiv\n 10: istore_2\n 11: iload_2\n 12: invokestatic #26 // Method primeFactorizationOf:(I)Ljava/util/Map;\n 15: astore 5\n 17: nop\n 18: iconst_0\n 19: istore 6\n 21: aload 5\n 23: astore 8\n 25: new #28 // class java/util/ArrayList\n 28: dup\n 29: aload 5\n 31: invokeinterface #34, 1 // InterfaceMethod java/util/Map.size:()I\n 36: invokespecial #37 // Method java/util/ArrayList.\"<init>\":(I)V\n 39: checkcast #39 // class java/util/Collection\n 42: astore 9\n 44: iconst_0\n 45: istore 11\n 47: aload 8\n 49: invokeinterface #43, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 54: invokeinterface #49, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 59: astore 12\n 61: aload 12\n 63: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 68: ifeq 124\n 71: aload 12\n 73: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 78: checkcast #61 // class java/util/Map$Entry\n 81: astore 13\n 83: aload 9\n 85: aload 13\n 87: astore 14\n 89: astore 17\n 91: iconst_0\n 92: istore 15\n 94: aload 14\n 96: invokeinterface #64, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 101: checkcast #66 // class java/lang/Number\n 104: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 107: iconst_1\n 108: iadd\n 109: invokestatic #75 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 112: aload 17\n 114: swap\n 115: invokeinterface #79, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 120: pop\n 121: goto 61\n 124: aload 9\n 126: checkcast #81 // class java/util/List\n 129: nop\n 130: checkcast #83 // class java/lang/Iterable\n 133: astore 5\n 135: lconst_1\n 136: lstore 6\n 138: iconst_0\n 139: istore 8\n 141: lload 6\n 143: lstore 9\n 145: aload 5\n 147: invokeinterface #84, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 152: astore 11\n 154: aload 11\n 156: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 161: ifeq 201\n 164: aload 11\n 166: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 171: astore 12\n 173: lload 9\n 175: aload 12\n 177: checkcast #66 // class java/lang/Number\n 180: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 183: istore 13\n 185: lstore 14\n 187: iconst_0\n 188: istore 16\n 190: lload 14\n 192: iload 13\n 194: i2l\n 195: lmul\n 196: lstore 9\n 198: goto 154\n 201: lload 9\n 203: lstore_3\n 204: lload_3\n 205: iload_0\n 206: i2l\n 207: lcmp\n 208: ifle 213\n 211: iload_2\n 212: ireturn\n 213: iinc 1, 1\n 216: goto 2\n\n public static final java.util.Map<java.lang.Integer, java.lang.Integer> primeFactorizationOf(int);\n Code:\n 0: invokestatic #119 // Method kotlin/collections/MapsKt.createMapBuilder:()Ljava/util/Map;\n 3: astore_1\n 4: aload_1\n 5: astore_2\n 6: iconst_0\n 7: istore_3\n 8: iload_0\n 9: istore 4\n 11: iload 4\n 13: iconst_1\n 14: if_icmpeq 127\n 17: iconst_1\n 18: istore 5\n 20: iload 5\n 22: iload_0\n 23: if_icmpgt 11\n 26: getstatic #123 // Field primes:[I\n 29: iload 5\n 31: iaload\n 32: ifne 47\n 35: getstatic #123 // Field primes:[I\n 38: iload 5\n 40: iload 5\n 42: invokestatic #129 // Method Problem7Kt.findPrime:(I)J\n 45: l2i\n 46: iastore\n 47: getstatic #123 // Field primes:[I\n 50: iload 5\n 52: iaload\n 53: istore 6\n 55: iload 4\n 57: iload 6\n 59: irem\n 60: ifne 115\n 63: iload 4\n 65: iload 6\n 67: idiv\n 68: istore 4\n 70: iload 6\n 72: invokestatic #75 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 75: astore 7\n 77: aload_2\n 78: aload 7\n 80: aload_2\n 81: iload 6\n 83: invokestatic #75 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 86: iconst_0\n 87: invokestatic #75 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 90: invokeinterface #133, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 95: checkcast #66 // class java/lang/Number\n 98: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 101: iconst_1\n 102: iadd\n 103: invokestatic #75 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 106: invokeinterface #136, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 111: pop\n 112: goto 11\n 115: iload 5\n 117: iload_0\n 118: if_icmpeq 11\n 121: iinc 5, 1\n 124: goto 26\n 127: nop\n 128: aload_1\n 129: invokestatic #140 // Method kotlin/collections/MapsKt.build:(Ljava/util/Map;)Ljava/util/Map;\n 132: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #146 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: iconst_0\n 1: istore_0\n 2: ldc #150 // int 65500\n 4: newarray int\n 6: astore_1\n 7: iload_0\n 8: ldc #150 // int 65500\n 10: if_icmpge 25\n 13: iload_0\n 14: istore_2\n 15: aload_1\n 16: iload_2\n 17: iconst_0\n 18: iastore\n 19: iinc 0, 1\n 22: goto 7\n 25: aload_1\n 26: putstatic #123 // Field primes:[I\n 29: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem24.kt
|
/**
* Lexicographic permutations
*
* A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2,
* 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The
* lexicographic permutations of 0, 1 and 2 are:
*
* 012 021 102 120 201 210
*
* What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9?
*
* https://projecteuler.net/problem=24
*/
fun main() {
println(lexicographicPermutations(listOf('0', '1', '2')))
println(lexicographicPermutationsAt(listOf('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'), 1_000_000))
}
private fun lexicographicPermutations(digits: List<Char>): List<String> = buildList {
val arr = digits.toCharArray()
while (true) {
add(String(arr))
if (!arr.nextPermutation()) break
}
}
private fun lexicographicPermutationsAt(digits: List<Char>, n: Int): String {
val arr = digits.toCharArray()
var count = 0
while (true) {
count++
if (count == n) {
return String(arr)
}
if (!arr.nextPermutation()) break
}
return ""
}
private fun CharArray.nextPermutation(): Boolean {
// Find the rightmost character which is smaller than its next character.
val i = ((lastIndex - 1) downTo 0).firstOrNull { this[it] < this[it + 1] } ?: return false
// Find the ceil of 'first char' in right of first character. Ceil of a character is the smallest character
// greater than it.
val ceilIndex = findCeil(this[i], i + 1, lastIndex)
// Swap first and second characters
swap(i, ceilIndex)
// reverse the string on right of 'first char'
reverse(i + 1, lastIndex)
return true
}
// This function finds the index of the smallest
// character which is greater than 'first' and is
// present in str[l..h]
private fun CharArray.findCeil(first: Char, l: Int, h: Int): Int {
// initialize index of ceiling element
var ceilIndex = l
// Now iterate through rest of the elements and find
// the smallest character greater than 'first'
for (i in l + 1..h) {
if (this[i] > first && this[i] < this[ceilIndex]) {
ceilIndex = i
}
}
return ceilIndex
}
// A utility function two swap two characters a and b
private fun CharArray.swap(i: Int, j: Int) {
val t = this[i]
this[i] = this[j]
this[j] = t
}
// A utility function to reverse a string str[l..h]
private fun CharArray.reverse(l: Int, h: Int) {
var low = l
var high = h
while (low < high) {
swap(low, high)
low++
high--
}
}
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem24Kt.class",
"javap": "Compiled from \"Problem24.kt\"\npublic final class Problem24Kt {\n public static final void main();\n Code:\n 0: iconst_3\n 1: anewarray #8 // class java/lang/Character\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: bipush 48\n 9: invokestatic #12 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 12: aastore\n 13: aload_0\n 14: iconst_1\n 15: bipush 49\n 17: invokestatic #12 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 20: aastore\n 21: aload_0\n 22: iconst_2\n 23: bipush 50\n 25: invokestatic #12 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 28: aastore\n 29: aload_0\n 30: invokestatic #18 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 33: invokestatic #22 // Method lexicographicPermutations:(Ljava/util/List;)Ljava/util/List;\n 36: getstatic #28 // Field java/lang/System.out:Ljava/io/PrintStream;\n 39: swap\n 40: invokevirtual #34 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 43: bipush 10\n 45: anewarray #8 // class java/lang/Character\n 48: astore_0\n 49: aload_0\n 50: iconst_0\n 51: bipush 48\n 53: invokestatic #12 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 56: aastore\n 57: aload_0\n 58: iconst_1\n 59: bipush 49\n 61: invokestatic #12 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 64: aastore\n 65: aload_0\n 66: iconst_2\n 67: bipush 50\n 69: invokestatic #12 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 72: aastore\n 73: aload_0\n 74: iconst_3\n 75: bipush 51\n 77: invokestatic #12 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 80: aastore\n 81: aload_0\n 82: iconst_4\n 83: bipush 52\n 85: invokestatic #12 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 88: aastore\n 89: aload_0\n 90: iconst_5\n 91: bipush 53\n 93: invokestatic #12 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 96: aastore\n 97: aload_0\n 98: bipush 6\n 100: bipush 54\n 102: invokestatic #12 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 105: aastore\n 106: aload_0\n 107: bipush 7\n 109: bipush 55\n 111: invokestatic #12 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 114: aastore\n 115: aload_0\n 116: bipush 8\n 118: bipush 56\n 120: invokestatic #12 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 123: aastore\n 124: aload_0\n 125: bipush 9\n 127: bipush 57\n 129: invokestatic #12 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 132: aastore\n 133: aload_0\n 134: invokestatic #18 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 137: ldc #35 // int 1000000\n 139: invokestatic #39 // Method lexicographicPermutationsAt:(Ljava/util/List;I)Ljava/lang/String;\n 142: getstatic #28 // Field java/lang/System.out:Ljava/io/PrintStream;\n 145: swap\n 146: invokevirtual #34 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 149: return\n\n private static final java.util.List<java.lang.String> lexicographicPermutations(java.util.List<java.lang.Character>);\n Code:\n 0: invokestatic #44 // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;\n 3: astore_1\n 4: aload_1\n 5: astore_2\n 6: iconst_0\n 7: istore_3\n 8: aload_0\n 9: checkcast #46 // class java/util/Collection\n 12: invokestatic #50 // Method kotlin/collections/CollectionsKt.toCharArray:(Ljava/util/Collection;)[C\n 15: astore 4\n 17: nop\n 18: aload_2\n 19: new #52 // class java/lang/String\n 22: dup\n 23: aload 4\n 25: invokespecial #56 // Method java/lang/String.\"<init>\":([C)V\n 28: invokeinterface #62, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 33: pop\n 34: aload 4\n 36: invokestatic #66 // Method nextPermutation:([C)Z\n 39: ifne 17\n 42: goto 45\n 45: nop\n 46: aload_1\n 47: invokestatic #69 // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;\n 50: areturn\n\n private static final java.lang.String lexicographicPermutationsAt(java.util.List<java.lang.Character>, int);\n Code:\n 0: aload_0\n 1: checkcast #46 // class java/util/Collection\n 4: invokestatic #50 // Method kotlin/collections/CollectionsKt.toCharArray:(Ljava/util/Collection;)[C\n 7: astore_2\n 8: iconst_0\n 9: istore_3\n 10: nop\n 11: iinc 3, 1\n 14: iload_3\n 15: iload_1\n 16: if_icmpne 28\n 19: new #52 // class java/lang/String\n 22: dup\n 23: aload_2\n 24: invokespecial #56 // Method java/lang/String.\"<init>\":([C)V\n 27: areturn\n 28: aload_2\n 29: invokestatic #66 // Method nextPermutation:([C)Z\n 32: ifne 10\n 35: goto 38\n 38: ldc #80 // String\n 40: areturn\n\n private static final boolean nextPermutation(char[]);\n Code:\n 0: aload_0\n 1: invokestatic #88 // Method kotlin/collections/ArraysKt.getLastIndex:([C)I\n 4: iconst_1\n 5: isub\n 6: iconst_0\n 7: invokestatic #94 // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;\n 10: checkcast #96 // class java/lang/Iterable\n 13: astore_3\n 14: iconst_0\n 15: istore 4\n 17: aload_3\n 18: invokeinterface #100, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 23: astore 5\n 25: aload 5\n 27: invokeinterface #106, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 32: ifeq 86\n 35: aload 5\n 37: invokeinterface #110, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 42: astore 6\n 44: aload 6\n 46: checkcast #112 // class java/lang/Number\n 49: invokevirtual #116 // Method java/lang/Number.intValue:()I\n 52: istore 7\n 54: iconst_0\n 55: istore 8\n 57: aload_0\n 58: iload 7\n 60: caload\n 61: aload_0\n 62: iload 7\n 64: iconst_1\n 65: iadd\n 66: caload\n 67: invokestatic #122 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 70: ifge 77\n 73: iconst_1\n 74: goto 78\n 77: iconst_0\n 78: ifeq 25\n 81: aload 6\n 83: goto 87\n 86: aconst_null\n 87: checkcast #124 // class java/lang/Integer\n 90: dup\n 91: ifnull 100\n 94: invokevirtual #125 // Method java/lang/Integer.intValue:()I\n 97: goto 103\n 100: pop\n 101: iconst_0\n 102: ireturn\n 103: istore_1\n 104: aload_0\n 105: aload_0\n 106: iload_1\n 107: caload\n 108: iload_1\n 109: iconst_1\n 110: iadd\n 111: aload_0\n 112: invokestatic #88 // Method kotlin/collections/ArraysKt.getLastIndex:([C)I\n 115: invokestatic #129 // Method findCeil:([CCII)I\n 118: istore_2\n 119: aload_0\n 120: iload_1\n 121: iload_2\n 122: invokestatic #133 // Method swap:([CII)V\n 125: aload_0\n 126: iload_1\n 127: iconst_1\n 128: iadd\n 129: aload_0\n 130: invokestatic #88 // Method kotlin/collections/ArraysKt.getLastIndex:([C)I\n 133: invokestatic #136 // Method reverse:([CII)V\n 136: iconst_1\n 137: ireturn\n\n private static final int findCeil(char[], char, int, int);\n Code:\n 0: iload_2\n 1: istore 4\n 3: iload_2\n 4: iconst_1\n 5: iadd\n 6: istore 5\n 8: iload 5\n 10: iload_3\n 11: if_icmpgt 55\n 14: aload_0\n 15: iload 5\n 17: caload\n 18: iload_1\n 19: invokestatic #122 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 22: ifle 43\n 25: aload_0\n 26: iload 5\n 28: caload\n 29: aload_0\n 30: iload 4\n 32: caload\n 33: invokestatic #122 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 36: ifge 43\n 39: iload 5\n 41: istore 4\n 43: iload 5\n 45: iload_3\n 46: if_icmpeq 55\n 49: iinc 5, 1\n 52: goto 14\n 55: iload 4\n 57: ireturn\n\n private static final void swap(char[], int, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: caload\n 3: istore_3\n 4: aload_0\n 5: iload_1\n 6: aload_0\n 7: iload_2\n 8: caload\n 9: castore\n 10: aload_0\n 11: iload_2\n 12: iload_3\n 13: castore\n 14: return\n\n private static final void reverse(char[], int, int);\n Code:\n 0: iload_1\n 1: istore_3\n 2: iload_2\n 3: istore 4\n 5: iload_3\n 6: iload 4\n 8: if_icmpge 27\n 11: aload_0\n 12: iload_3\n 13: iload 4\n 15: invokestatic #133 // Method swap:([CII)V\n 18: iinc 3, 1\n 21: iinc 4, -1\n 24: goto 5\n 27: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #160 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem34.kt
|
/**
* Digit factorials
*
* 145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
*
* Find the sum of all numbers which are equal to the sum of the factorial of their digits.
*
* Note: As 1! = 1 and 2! = 2 are not sums they are not included.
*
* https://projecteuler.net/problem=34
*/
fun main() {
check(145.isDigitFactorial())
println(sumOfDigitFactorials())
}
private fun sumOfDigitFactorials(from: Int = 10, to: Int = 99999): Int =
(from..to).filter(Int::isDigitFactorial).sum()
private fun Int.isDigitFactorial(): Boolean = digits().sumOf(Int::factorial) == this
private fun Int.factorial(): Int = (1..this).fold(1) { x, y -> x * y }
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem34Kt.class",
"javap": "Compiled from \"Problem34.kt\"\npublic final class Problem34Kt {\n public static final void main();\n Code:\n 0: sipush 145\n 3: invokestatic #10 // Method isDigitFactorial:(I)Z\n 6: ifne 19\n 9: new #12 // class java/lang/IllegalStateException\n 12: dup\n 13: ldc #14 // String Check failed.\n 15: invokespecial #18 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 18: athrow\n 19: iconst_0\n 20: iconst_0\n 21: iconst_3\n 22: aconst_null\n 23: invokestatic #22 // Method sumOfDigitFactorials$default:(IIILjava/lang/Object;)I\n 26: istore_0\n 27: getstatic #28 // Field java/lang/System.out:Ljava/io/PrintStream;\n 30: iload_0\n 31: invokevirtual #34 // Method java/io/PrintStream.println:(I)V\n 34: return\n\n private static final int sumOfDigitFactorials(int, int);\n Code:\n 0: new #38 // class kotlin/ranges/IntRange\n 3: dup\n 4: iload_0\n 5: iload_1\n 6: invokespecial #41 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 9: checkcast #43 // class java/lang/Iterable\n 12: astore_2\n 13: iconst_0\n 14: istore_3\n 15: aload_2\n 16: astore 4\n 18: new #45 // class java/util/ArrayList\n 21: dup\n 22: invokespecial #47 // Method java/util/ArrayList.\"<init>\":()V\n 25: checkcast #49 // class java/util/Collection\n 28: astore 5\n 30: iconst_0\n 31: istore 6\n 33: aload 4\n 35: invokeinterface #53, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 40: astore 7\n 42: aload 7\n 44: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 49: ifeq 95\n 52: aload 7\n 54: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 59: astore 8\n 61: aload 8\n 63: checkcast #65 // class java/lang/Number\n 66: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 69: istore 9\n 71: iconst_0\n 72: istore 10\n 74: iload 9\n 76: invokestatic #10 // Method isDigitFactorial:(I)Z\n 79: ifeq 42\n 82: aload 5\n 84: aload 8\n 86: invokeinterface #73, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 91: pop\n 92: goto 42\n 95: aload 5\n 97: checkcast #75 // class java/util/List\n 100: nop\n 101: checkcast #43 // class java/lang/Iterable\n 104: invokestatic #81 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 107: ireturn\n\n static int sumOfDigitFactorials$default(int, int, int, java.lang.Object);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: iand\n 3: ifeq 9\n 6: bipush 10\n 8: istore_0\n 9: iload_2\n 10: iconst_2\n 11: iand\n 12: ifeq 18\n 15: ldc #96 // int 99999\n 17: istore_1\n 18: iload_0\n 19: iload_1\n 20: invokestatic #98 // Method sumOfDigitFactorials:(II)I\n 23: ireturn\n\n private static final boolean isDigitFactorial(int);\n Code:\n 0: iload_0\n 1: invokestatic #104 // Method Problem32Kt.digits:(I)Ljava/util/List;\n 4: checkcast #43 // class java/lang/Iterable\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: invokeinterface #53, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 16: astore_3\n 17: aload_3\n 18: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 23: ifeq 66\n 26: aload_3\n 27: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 32: astore 4\n 34: iload_2\n 35: aload 4\n 37: checkcast #65 // class java/lang/Number\n 40: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 43: istore 5\n 45: istore 7\n 47: iconst_0\n 48: istore 6\n 50: iload 5\n 52: invokestatic #108 // Method factorial:(I)I\n 55: istore 8\n 57: iload 7\n 59: iload 8\n 61: iadd\n 62: istore_2\n 63: goto 17\n 66: iload_2\n 67: iload_0\n 68: if_icmpne 75\n 71: iconst_1\n 72: goto 76\n 75: iconst_0\n 76: ireturn\n\n private static final int factorial(int);\n Code:\n 0: new #38 // class kotlin/ranges/IntRange\n 3: dup\n 4: iconst_1\n 5: iload_0\n 6: invokespecial #41 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 9: checkcast #43 // class java/lang/Iterable\n 12: astore_1\n 13: iconst_1\n 14: istore_2\n 15: iconst_0\n 16: istore_3\n 17: iload_2\n 18: istore 4\n 20: aload_1\n 21: invokeinterface #53, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 26: astore 5\n 28: aload 5\n 30: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 35: ifeq 69\n 38: aload 5\n 40: checkcast #112 // class kotlin/collections/IntIterator\n 43: invokevirtual #115 // Method kotlin/collections/IntIterator.nextInt:()I\n 46: istore 6\n 48: iload 4\n 50: iload 6\n 52: istore 7\n 54: istore 8\n 56: iconst_0\n 57: istore 9\n 59: iload 8\n 61: iload 7\n 63: imul\n 64: istore 4\n 66: goto 28\n 69: iload 4\n 71: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #127 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
jimmymorales__project-euler__e881cad/src/main/kotlin/Problem2.kt
|
import kotlin.system.measureNanoTime
/**
* Even Fibonacci numbers
*
* Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the
* first 10 terms will be:
*
* 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
*
* By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the
* even-valued terms.
*
* https://projecteuler.net/problem=2
*/
fun main() {
val limit = 4_000_000
val solution1Time = measureNanoTime {
solution1(limit)
}
val solution2Time = measureNanoTime {
solution2(limit)
}
println(solution1Time)
println(solution2Time)
}
private fun solution1(limit: Int) {
var n1 = 1
var n2 = 1
var sum = 0
while (n2 < limit) {
if (n2 % 2 == 0) {
sum += n2
}
val fib = n1 + n2
n1 = n2
n2 = fib
}
println(sum)
}
private fun solution2(limit: Int) {
// 1 1 2 3 5 8 13 21 34 55 89 144
// a b c a b c a b c a b c
var a = 1
var b = 1
var c = a + b
var sum = 0
while (c < limit) {
sum += c
a = b + c
b = c + a
c = a + b
}
println(sum)
}
|
[
{
"class_path": "jimmymorales__project-euler__e881cad/Problem2Kt.class",
"javap": "Compiled from \"Problem2.kt\"\npublic final class Problem2Kt {\n public static final void main();\n Code:\n 0: ldc #7 // int 4000000\n 2: istore_0\n 3: iconst_0\n 4: istore_3\n 5: invokestatic #13 // Method java/lang/System.nanoTime:()J\n 8: lstore 4\n 10: iconst_0\n 11: istore 6\n 13: iload_0\n 14: invokestatic #17 // Method solution1:(I)V\n 17: nop\n 18: nop\n 19: invokestatic #13 // Method java/lang/System.nanoTime:()J\n 22: lload 4\n 24: lsub\n 25: lstore_1\n 26: iconst_0\n 27: istore 5\n 29: invokestatic #13 // Method java/lang/System.nanoTime:()J\n 32: lstore 6\n 34: iconst_0\n 35: istore 8\n 37: iload_0\n 38: invokestatic #20 // Method solution2:(I)V\n 41: nop\n 42: nop\n 43: invokestatic #13 // Method java/lang/System.nanoTime:()J\n 46: lload 6\n 48: lsub\n 49: lstore_3\n 50: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 53: lload_1\n 54: invokevirtual #30 // Method java/io/PrintStream.println:(J)V\n 57: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 60: lload_3\n 61: invokevirtual #30 // Method java/io/PrintStream.println:(J)V\n 64: return\n\n private static final void solution1(int);\n Code:\n 0: iconst_1\n 1: istore_1\n 2: iconst_1\n 3: istore_2\n 4: iconst_0\n 5: istore_3\n 6: iload_2\n 7: iload_0\n 8: if_icmpge 34\n 11: iload_2\n 12: iconst_2\n 13: irem\n 14: ifne 21\n 17: iload_3\n 18: iload_2\n 19: iadd\n 20: istore_3\n 21: iload_1\n 22: iload_2\n 23: iadd\n 24: istore 4\n 26: iload_2\n 27: istore_1\n 28: iload 4\n 30: istore_2\n 31: goto 6\n 34: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 37: iload_3\n 38: invokevirtual #41 // Method java/io/PrintStream.println:(I)V\n 41: return\n\n private static final void solution2(int);\n Code:\n 0: iconst_1\n 1: istore_1\n 2: iconst_1\n 3: istore_2\n 4: iload_1\n 5: iload_2\n 6: iadd\n 7: istore_3\n 8: iconst_0\n 9: istore 4\n 11: iload_3\n 12: iload_0\n 13: if_icmpge 37\n 16: iload 4\n 18: iload_3\n 19: iadd\n 20: istore 4\n 22: iload_2\n 23: iload_3\n 24: iadd\n 25: istore_1\n 26: iload_3\n 27: iload_1\n 28: iadd\n 29: istore_2\n 30: iload_1\n 31: iload_2\n 32: iadd\n 33: istore_3\n 34: goto 11\n 37: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 40: iload 4\n 42: invokevirtual #41 // Method java/io/PrintStream.println:(I)V\n 45: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #51 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
margalis__Kotlin_Koans_mg__faf2034/Generics/Generic functions/src/Task.kt
|
import java.util.*
public fun <T, C : MutableCollection<in T>> Collection<T>.partitionTo(col1: C, col2: C, predicate: (T)-> Boolean): Pair<C,C> {
//T-n itemi tesak, C-n` Collectioni mejini
//greladzevy` toCollectioni pes
for( item in this){
if(predicate(item)){
col1.add(item)
}
else{
col2.add(item)
}
}
return Pair(col1,col2) // qanzi partition()-y sl-um pair er veradardznum
}
fun partitionWordsAndLines() {
val (words, lines) = listOf("a", "a b", "c", "d e")
.partitionTo(ArrayList(), ArrayList()) { s -> !s.contains(" ") }
check(words == listOf("a", "c"))
check(lines == listOf("a b", "d e"))
}
fun partitionLettersAndOtherSymbols() {
val (letters, other) = setOf('a', '%', 'r', '}')
.partitionTo(HashSet(), HashSet()) { c -> c in 'a'..'z' || c in 'A'..'Z' }
check(letters == setOf('a', 'r'))
check(other == setOf('%', '}'))
}
|
[
{
"class_path": "margalis__Kotlin_Koans_mg__faf2034/TaskKt.class",
"javap": "Compiled from \"Task.kt\"\npublic final class TaskKt {\n public static final <T, C extends java.util.Collection<? super T>> kotlin.Pair<C, C> partitionTo(java.util.Collection<? extends T>, C, C, kotlin.jvm.functions.Function1<? super T, java.lang.Boolean>);\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 #18 // String col1\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_2\n 13: ldc #20 // String col2\n 15: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: aload_3\n 19: ldc #22 // String predicate\n 21: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 24: aload_0\n 25: invokeinterface #28, 1 // InterfaceMethod java/util/Collection.iterator:()Ljava/util/Iterator;\n 30: astore 4\n 32: aload 4\n 34: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 39: ifeq 91\n 42: aload 4\n 44: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 49: astore 5\n 51: aload_3\n 52: aload 5\n 54: invokeinterface #44, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 59: checkcast #46 // class java/lang/Boolean\n 62: invokevirtual #49 // Method java/lang/Boolean.booleanValue:()Z\n 65: ifeq 79\n 68: aload_1\n 69: aload 5\n 71: invokeinterface #53, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 76: goto 87\n 79: aload_2\n 80: aload 5\n 82: invokeinterface #53, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 87: pop\n 88: goto 32\n 91: new #55 // class kotlin/Pair\n 94: dup\n 95: aload_1\n 96: aload_2\n 97: invokespecial #59 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 100: areturn\n\n public static final void partitionWordsAndLines();\n Code:\n 0: iconst_4\n 1: anewarray #68 // class java/lang/String\n 4: astore_1\n 5: aload_1\n 6: iconst_0\n 7: ldc #70 // String a\n 9: aastore\n 10: aload_1\n 11: iconst_1\n 12: ldc #72 // String a b\n 14: aastore\n 15: aload_1\n 16: iconst_2\n 17: ldc #74 // String c\n 19: aastore\n 20: aload_1\n 21: iconst_3\n 22: ldc #76 // String d e\n 24: aastore\n 25: aload_1\n 26: invokestatic #82 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 29: checkcast #24 // class java/util/Collection\n 32: new #84 // class java/util/ArrayList\n 35: dup\n 36: invokespecial #86 // Method java/util/ArrayList.\"<init>\":()V\n 39: checkcast #24 // class java/util/Collection\n 42: new #84 // class java/util/ArrayList\n 45: dup\n 46: invokespecial #86 // Method java/util/ArrayList.\"<init>\":()V\n 49: checkcast #24 // class java/util/Collection\n 52: invokedynamic #104, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 57: invokestatic #106 // Method partitionTo:(Ljava/util/Collection;Ljava/util/Collection;Ljava/util/Collection;Lkotlin/jvm/functions/Function1;)Lkotlin/Pair;\n 60: astore_0\n 61: aload_0\n 62: invokevirtual #109 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 65: checkcast #84 // class java/util/ArrayList\n 68: astore_1\n 69: aload_0\n 70: invokevirtual #112 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 73: checkcast #84 // class java/util/ArrayList\n 76: astore_2\n 77: aload_1\n 78: iconst_2\n 79: anewarray #68 // class java/lang/String\n 82: astore_3\n 83: aload_3\n 84: iconst_0\n 85: ldc #70 // String a\n 87: aastore\n 88: aload_3\n 89: iconst_1\n 90: ldc #74 // String c\n 92: aastore\n 93: aload_3\n 94: invokestatic #82 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 97: invokestatic #116 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 100: ifne 113\n 103: new #118 // class java/lang/IllegalStateException\n 106: dup\n 107: ldc #120 // String Check failed.\n 109: invokespecial #123 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 112: athrow\n 113: aload_2\n 114: iconst_2\n 115: anewarray #68 // class java/lang/String\n 118: astore_3\n 119: aload_3\n 120: iconst_0\n 121: ldc #72 // String a b\n 123: aastore\n 124: aload_3\n 125: iconst_1\n 126: ldc #76 // String d e\n 128: aastore\n 129: aload_3\n 130: invokestatic #82 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 133: invokestatic #116 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 136: ifne 149\n 139: new #118 // class java/lang/IllegalStateException\n 142: dup\n 143: ldc #120 // String Check failed.\n 145: invokespecial #123 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 148: athrow\n 149: return\n\n public static final void partitionLettersAndOtherSymbols();\n Code:\n 0: iconst_4\n 1: anewarray #131 // class java/lang/Character\n 4: astore_1\n 5: aload_1\n 6: iconst_0\n 7: bipush 97\n 9: invokestatic #135 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 12: aastore\n 13: aload_1\n 14: iconst_1\n 15: bipush 37\n 17: invokestatic #135 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 20: aastore\n 21: aload_1\n 22: iconst_2\n 23: bipush 114\n 25: invokestatic #135 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 28: aastore\n 29: aload_1\n 30: iconst_3\n 31: bipush 125\n 33: invokestatic #135 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 36: aastore\n 37: aload_1\n 38: invokestatic #141 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 41: checkcast #24 // class java/util/Collection\n 44: new #143 // class java/util/HashSet\n 47: dup\n 48: invokespecial #144 // Method java/util/HashSet.\"<init>\":()V\n 51: checkcast #24 // class java/util/Collection\n 54: new #143 // class java/util/HashSet\n 57: dup\n 58: invokespecial #144 // Method java/util/HashSet.\"<init>\":()V\n 61: checkcast #24 // class java/util/Collection\n 64: invokedynamic #152, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 69: invokestatic #106 // Method partitionTo:(Ljava/util/Collection;Ljava/util/Collection;Ljava/util/Collection;Lkotlin/jvm/functions/Function1;)Lkotlin/Pair;\n 72: astore_0\n 73: aload_0\n 74: invokevirtual #109 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 77: checkcast #143 // class java/util/HashSet\n 80: astore_1\n 81: aload_0\n 82: invokevirtual #112 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 85: checkcast #143 // class java/util/HashSet\n 88: astore_2\n 89: aload_1\n 90: iconst_2\n 91: anewarray #131 // class java/lang/Character\n 94: astore_3\n 95: aload_3\n 96: iconst_0\n 97: bipush 97\n 99: invokestatic #135 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 102: aastore\n 103: aload_3\n 104: iconst_1\n 105: bipush 114\n 107: invokestatic #135 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 110: aastore\n 111: aload_3\n 112: invokestatic #141 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 115: invokestatic #116 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 118: ifne 131\n 121: new #118 // class java/lang/IllegalStateException\n 124: dup\n 125: ldc #120 // String Check failed.\n 127: invokespecial #123 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 130: athrow\n 131: aload_2\n 132: iconst_2\n 133: anewarray #131 // class java/lang/Character\n 136: astore_3\n 137: aload_3\n 138: iconst_0\n 139: bipush 37\n 141: invokestatic #135 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 144: aastore\n 145: aload_3\n 146: iconst_1\n 147: bipush 125\n 149: invokestatic #135 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 152: aastore\n 153: aload_3\n 154: invokestatic #141 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 157: invokestatic #116 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 160: ifne 173\n 163: new #118 // class java/lang/IllegalStateException\n 166: dup\n 167: ldc #120 // String Check failed.\n 169: invokespecial #123 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 172: athrow\n 173: return\n\n private static final boolean partitionWordsAndLines$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #159 // String s\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #161 // class java/lang/CharSequence\n 10: ldc #163 // String\n 12: checkcast #161 // class java/lang/CharSequence\n 15: iconst_0\n 16: iconst_2\n 17: aconst_null\n 18: invokestatic #169 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z\n 21: ifne 28\n 24: iconst_1\n 25: goto 29\n 28: iconst_0\n 29: ireturn\n\n private static final boolean partitionLettersAndOtherSymbols$lambda$1(char);\n Code:\n 0: bipush 97\n 2: iload_0\n 3: if_icmpgt 20\n 6: iload_0\n 7: bipush 123\n 9: if_icmpge 16\n 12: iconst_1\n 13: goto 21\n 16: iconst_0\n 17: goto 21\n 20: iconst_0\n 21: ifne 48\n 24: bipush 65\n 26: iload_0\n 27: if_icmpgt 44\n 30: iload_0\n 31: bipush 91\n 33: if_icmpge 40\n 36: iconst_1\n 37: goto 45\n 40: iconst_0\n 41: goto 45\n 44: iconst_0\n 45: ifeq 52\n 48: iconst_1\n 49: goto 53\n 52: iconst_0\n 53: ireturn\n}\n",
"javap_err": ""
}
] |
aragos__aoc2023__7bca0a8/aoc/src/Calibration.kt
|
import java.io.File
fun main() {
println(Calibration.readCalibrationDigitsAndWords("aoc/inputs/calibration.txt").sum())
}
object Calibration {
fun readCalibrationDigits(): List<Int> = buildList {
File("aoc/inputs/calibration.txt").forEachLine { line ->
val allDigits = Regex("[1-9]").findAll(line).map { it.value }
val twoDigits = (allDigits.first() + allDigits.last()).toInt()
add(twoDigits)
}
}
fun readCalibrationDigitsAndWords(fileLocation: String): List<Int> = buildList {
File(fileLocation).forEachLine { line ->
add(digitAndWordLineToNumber(line))
}
}
fun digitAndWordLineToNumber(line: String): Int {
val allDigits = Regex("(?=([1-9]|one|two|three|four|five|six|seven|eight|nine)).")
.findAll(line)
.mapNotNull { it.groups[1]?.value }
.map(::numberToDigit)
.toList()
return (allDigits.first() + allDigits.last()).toInt()
}
private fun numberToDigit(number: String) = when (number) {
// No zeros here!
"one" -> "1"
"two" -> "2"
"three" -> "3"
"four" -> "4"
"five" -> "5"
"six" -> "6"
"seven" -> "7"
"eight" -> "8"
"nine" -> "9"
else -> number
}
}
|
[
{
"class_path": "aragos__aoc2023__7bca0a8/CalibrationKt.class",
"javap": "Compiled from \"Calibration.kt\"\npublic final class CalibrationKt {\n public static final void main();\n Code:\n 0: getstatic #12 // Field Calibration.INSTANCE:LCalibration;\n 3: ldc #14 // String aoc/inputs/calibration.txt\n 5: invokevirtual #18 // Method Calibration.readCalibrationDigitsAndWords:(Ljava/lang/String;)Ljava/util/List;\n 8: checkcast #20 // class java/lang/Iterable\n 11: invokestatic #26 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 14: istore_0\n 15: getstatic #32 // Field java/lang/System.out:Ljava/io/PrintStream;\n 18: iload_0\n 19: invokevirtual #38 // Method java/io/PrintStream.println:(I)V\n 22: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #41 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
},
{
"class_path": "aragos__aoc2023__7bca0a8/Calibration$digitAndWordLineToNumber$allDigits$2.class",
"javap": "Compiled from \"Calibration.kt\"\nfinal class Calibration$digitAndWordLineToNumber$allDigits$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, java.lang.String> {\n Calibration$digitAndWordLineToNumber$allDigits$2(java.lang.Object);\n Code:\n 0: aload_0\n 1: iconst_1\n 2: aload_1\n 3: ldc #11 // class Calibration\n 5: ldc #13 // String numberToDigit\n 7: ldc #15 // String numberToDigit(Ljava/lang/String;)Ljava/lang/String;\n 9: iconst_0\n 10: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Object;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 13: return\n\n public final java.lang.String invoke(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #26 // String p0\n 3: invokestatic #32 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getfield #34 // Field receiver:Ljava/lang/Object;\n 10: checkcast #11 // class Calibration\n 13: aload_1\n 14: invokestatic #38 // Method Calibration.access$numberToDigit:(LCalibration;Ljava/lang/String;)Ljava/lang/String;\n 17: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #42 // class java/lang/String\n 5: invokevirtual #44 // Method invoke:(Ljava/lang/String;)Ljava/lang/String;\n 8: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "aragos__aoc2023__7bca0a8/Calibration.class",
"javap": "Compiled from \"Calibration.kt\"\npublic final class Calibration {\n public static final Calibration INSTANCE;\n\n private Calibration();\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> readCalibrationDigits();\n Code:\n 0: invokestatic #19 // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;\n 3: astore_1\n 4: aload_1\n 5: astore_2\n 6: iconst_0\n 7: istore_3\n 8: new #21 // class java/io/File\n 11: dup\n 12: ldc #23 // String aoc/inputs/calibration.txt\n 14: invokespecial #26 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 17: aconst_null\n 18: aload_2\n 19: invokedynamic #46, 0 // InvokeDynamic #0:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function1;\n 24: iconst_1\n 25: aconst_null\n 26: invokestatic #52 // Method kotlin/io/FilesKt.forEachLine$default:(Ljava/io/File;Ljava/nio/charset/Charset;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V\n 29: nop\n 30: aload_1\n 31: invokestatic #56 // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;\n 34: areturn\n\n public final java.util.List<java.lang.Integer> readCalibrationDigitsAndWords(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #65 // String fileLocation\n 3: invokestatic #71 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: invokestatic #19 // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;\n 9: astore_2\n 10: aload_2\n 11: astore_3\n 12: iconst_0\n 13: istore 4\n 15: new #21 // class java/io/File\n 18: dup\n 19: aload_1\n 20: invokespecial #26 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 23: aconst_null\n 24: aload_3\n 25: invokedynamic #76, 0 // InvokeDynamic #1:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function1;\n 30: iconst_1\n 31: aconst_null\n 32: invokestatic #52 // Method kotlin/io/FilesKt.forEachLine$default:(Ljava/io/File;Ljava/nio/charset/Charset;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V\n 35: nop\n 36: aload_2\n 37: invokestatic #56 // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;\n 40: areturn\n\n public final int digitAndWordLineToNumber(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #83 // String line\n 3: invokestatic #71 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #85 // class kotlin/text/Regex\n 9: dup\n 10: ldc #87 // String (?=([1-9]|one|two|three|four|five|six|seven|eight|nine)).\n 12: invokespecial #88 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 15: aload_1\n 16: checkcast #90 // class java/lang/CharSequence\n 19: iconst_0\n 20: iconst_2\n 21: aconst_null\n 22: invokestatic #94 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 25: invokedynamic #103, 0 // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;\n 30: invokestatic #109 // Method kotlin/sequences/SequencesKt.mapNotNull:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 33: new #111 // class Calibration$digitAndWordLineToNumber$allDigits$2\n 36: dup\n 37: aload_0\n 38: invokespecial #114 // Method Calibration$digitAndWordLineToNumber$allDigits$2.\"<init>\":(Ljava/lang/Object;)V\n 41: checkcast #116 // class kotlin/jvm/functions/Function1\n 44: invokestatic #119 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 47: invokestatic #123 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 50: astore_2\n 51: new #125 // class java/lang/StringBuilder\n 54: dup\n 55: invokespecial #126 // Method java/lang/StringBuilder.\"<init>\":()V\n 58: aload_2\n 59: invokestatic #130 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 62: checkcast #132 // class java/lang/String\n 65: invokevirtual #136 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 68: aload_2\n 69: invokestatic #139 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 72: checkcast #132 // class java/lang/String\n 75: invokevirtual #136 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 78: invokevirtual #143 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 81: invokestatic #148 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 84: ireturn\n\n private final java.lang.String numberToDigit(java.lang.String);\n Code:\n 0: aload_1\n 1: astore_2\n 2: aload_2\n 3: invokevirtual #155 // Method java/lang/String.hashCode:()I\n 6: lookupswitch { // 9\n 110182: 124\n 113890: 100\n 115276: 148\n 3143346: 172\n 3149094: 112\n 3381426: 88\n 96505999: 184\n 109330445: 136\n 110339486: 160\n default: 241\n }\n 88: aload_2\n 89: ldc #157 // String nine\n 91: invokevirtual #161 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 94: ifne 236\n 97: goto 241\n 100: aload_2\n 101: ldc #163 // String six\n 103: invokevirtual #161 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 106: ifne 221\n 109: goto 241\n 112: aload_2\n 113: ldc #165 // String four\n 115: invokevirtual #161 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 118: ifne 211\n 121: goto 241\n 124: aload_2\n 125: ldc #167 // String one\n 127: invokevirtual #161 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 130: ifne 196\n 133: goto 241\n 136: aload_2\n 137: ldc #169 // String seven\n 139: invokevirtual #161 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 142: ifne 226\n 145: goto 241\n 148: aload_2\n 149: ldc #171 // String two\n 151: invokevirtual #161 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 154: ifne 201\n 157: goto 241\n 160: aload_2\n 161: ldc #173 // String three\n 163: invokevirtual #161 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 166: ifne 206\n 169: goto 241\n 172: aload_2\n 173: ldc #175 // String five\n 175: invokevirtual #161 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 178: ifne 216\n 181: goto 241\n 184: aload_2\n 185: ldc #177 // String eight\n 187: invokevirtual #161 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 190: ifne 231\n 193: goto 241\n 196: ldc #179 // String 1\n 198: goto 242\n 201: ldc #181 // String 2\n 203: goto 242\n 206: ldc #183 // String 3\n 208: goto 242\n 211: ldc #185 // String 4\n 213: goto 242\n 216: ldc #187 // String 5\n 218: goto 242\n 221: ldc #189 // String 6\n 223: goto 242\n 226: ldc #191 // String 7\n 228: goto 242\n 231: ldc #193 // String 8\n 233: goto 242\n 236: ldc #195 // String 9\n 238: goto 242\n 241: aload_1\n 242: areturn\n\n private static final java.lang.String readCalibrationDigits$lambda$2$lambda$1$lambda$0(kotlin.text.MatchResult);\n Code:\n 0: aload_0\n 1: ldc #199 // String it\n 3: invokestatic #71 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #204, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 12: areturn\n\n private static final kotlin.Unit readCalibrationDigits$lambda$2$lambda$1(java.util.List, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #83 // String line\n 3: invokestatic #71 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #85 // class kotlin/text/Regex\n 9: dup\n 10: ldc #207 // String [1-9]\n 12: invokespecial #88 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 15: aload_1\n 16: checkcast #90 // class java/lang/CharSequence\n 19: iconst_0\n 20: iconst_2\n 21: aconst_null\n 22: invokestatic #94 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 25: invokedynamic #211, 0 // InvokeDynamic #3:invoke:()Lkotlin/jvm/functions/Function1;\n 30: invokestatic #119 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 33: astore_2\n 34: new #125 // class java/lang/StringBuilder\n 37: dup\n 38: invokespecial #126 // Method java/lang/StringBuilder.\"<init>\":()V\n 41: aload_2\n 42: invokestatic #214 // Method kotlin/sequences/SequencesKt.first:(Lkotlin/sequences/Sequence;)Ljava/lang/Object;\n 45: checkcast #132 // class java/lang/String\n 48: invokevirtual #136 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: aload_2\n 52: invokestatic #216 // Method kotlin/sequences/SequencesKt.last:(Lkotlin/sequences/Sequence;)Ljava/lang/Object;\n 55: checkcast #132 // class java/lang/String\n 58: invokevirtual #136 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 61: invokevirtual #143 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 64: invokestatic #148 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 67: istore_3\n 68: aload_0\n 69: iload_3\n 70: invokestatic #220 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 73: invokeinterface #225, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 78: pop\n 79: getstatic #231 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 82: areturn\n\n private static final kotlin.Unit readCalibrationDigitsAndWords$lambda$4$lambda$3(java.util.List, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #83 // String line\n 3: invokestatic #71 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getstatic #236 // Field INSTANCE:LCalibration;\n 10: aload_1\n 11: invokevirtual #238 // Method digitAndWordLineToNumber:(Ljava/lang/String;)I\n 14: invokestatic #220 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 17: invokeinterface #225, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 22: pop\n 23: getstatic #231 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 26: areturn\n\n private static final java.lang.String digitAndWordLineToNumber$lambda$5(kotlin.text.MatchResult);\n Code:\n 0: aload_0\n 1: ldc #199 // String it\n 3: invokestatic #71 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #242, 1 // InterfaceMethod kotlin/text/MatchResult.getGroups:()Lkotlin/text/MatchGroupCollection;\n 12: iconst_1\n 13: invokeinterface #248, 2 // InterfaceMethod kotlin/text/MatchGroupCollection.get:(I)Lkotlin/text/MatchGroup;\n 18: dup\n 19: ifnull 28\n 22: invokevirtual #251 // Method kotlin/text/MatchGroup.getValue:()Ljava/lang/String;\n 25: goto 30\n 28: pop\n 29: aconst_null\n 30: areturn\n\n public static final java.lang.String access$numberToDigit(Calibration, java.lang.String);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #255 // Method numberToDigit:(Ljava/lang/String;)Ljava/lang/String;\n 5: areturn\n\n static {};\n Code:\n 0: new #2 // class Calibration\n 3: dup\n 4: invokespecial #258 // Method \"<init>\":()V\n 7: putstatic #236 // Field INSTANCE:LCalibration;\n 10: return\n}\n",
"javap_err": ""
}
] |
aragos__aoc2023__7bca0a8/aoc/src/Soil.kt
|
import java.io.File
import java.lang.IllegalArgumentException
data class Range(val sourceStart: Long, val destinationStart: Long, val rangeLength: Long) {
val sources = LongRange(sourceStart, sourceStart + rangeLength - 1)
override fun toString(): String {
return "$sources -> ${LongRange(destinationStart, destinationStart + rangeLength - 1)}"
}
fun mapId(id: Long) = destinationStart + id - sourceStart
fun invert() = Range(destinationStart, sourceStart, rangeLength)
}
class Mapping(val name: String, ranges: Set<Range>) {
val sortedRanges = ranges.sortedBy { it.sources.start }
fun map(sourceId: Long): Long {
for (range in sortedRanges) {
if (sourceId < range.sources.start) {
return sourceId
} else if (sourceId in range.sources) {
return range.mapId(sourceId)
}
}
return sourceId
}
override fun toString(): String {
return "Mapping:\n" + sortedRanges.joinToString(separator = "\n") { " $it" }
}
}
fun main() {
val lines = File("inputs/soil.txt").readLines()
val rawSeeds = Regex("\\d+").findAll(lines[0].split(":")[1]).map { it.value.toLong() }
val mappings = lines.parseMappings()
// println(calculateMinLocationSimpleSeeds(rawSeeds, mappings))
println(calculateMinLocationSeedRanges(rawSeeds, mappings))
}
fun calculateMinLocationSeedRanges(rawSeeds: Sequence<Long>, forwardMappings: List<Mapping>): Long {
val seedRanges = rawSeeds
.chunked(2)
.map { pair -> LongRange(start = pair[0], endInclusive = pair[0] + pair[1] - 1) }
.sortedBy { range -> range.start }
.toList()
val reverseMappings = forwardMappings.map { mapping ->
Mapping("~${mapping.name}", mapping.sortedRanges.map { it.invert() }.toSet())
}.reversed()
val locations2Humidity = reverseMappings.first()
locations2Humidity.sortedRanges.forEach { range ->
range.sources.forEach { location ->
val seed = reverseMappings.fold(location)
seedRanges.forEach { seedRange ->
if (seed in seedRange) {
return location
}
}
}
}
throw IllegalArgumentException()
}
private fun calculateMinLocationSimpleSeeds(
rawSeeds: Sequence<Long>,
mappings: List<Mapping>,
): Long = rawSeeds.map { value ->
mappings.fold(value)
}.min()
private fun List<Mapping>.fold(value: Long) =
this.fold(value) { acc, mapping ->
mapping.map(acc)
}
private fun List<String>.parseMappings(): List<Mapping> {
val seed2Soil = parseMapping("seed2Soil", startInclusive = 3, endExclusive = 32)
val soil2Fertilizer = parseMapping("soil2Fertilizer", startInclusive = 34, endExclusive = 53)
val fertilizer2Water = parseMapping("fertilizer2Water", startInclusive = 55, endExclusive = 97)
val water2Light = parseMapping("water2Light", startInclusive = 99, endExclusive = 117)
val light2Temperature =
parseMapping("light2Temperature", startInclusive = 119, endExclusive = 132)
val temperature2Humidity =
parseMapping("temperature2Humidity", startInclusive = 135, endExclusive = 144)
val humidity2Location =
parseMapping("humidity2Location", startInclusive = 146, endExclusive = 190)
return listOf(
seed2Soil,
soil2Fertilizer,
fertilizer2Water,
water2Light,
light2Temperature,
temperature2Humidity,
humidity2Location
)
}
private fun List<String>.parseMapping(
name: String,
startInclusive: Int,
endExclusive: Int,
): Mapping =
Mapping(name, subList(startInclusive, endExclusive).map { line ->
val numbers = Regex("\\d+").findAll(line).map { it.value.toLong() }.toList()
Range(sourceStart = numbers[1], destinationStart = numbers[0], rangeLength = numbers[2])
}.toSet())
|
[
{
"class_path": "aragos__aoc2023__7bca0a8/SoilKt.class",
"javap": "Compiled from \"Soil.kt\"\npublic final class SoilKt {\n public static final void main();\n Code:\n 0: new #8 // class java/io/File\n 3: dup\n 4: ldc #10 // String inputs/soil.txt\n 6: invokespecial #14 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: aconst_null\n 10: iconst_1\n 11: aconst_null\n 12: invokestatic #20 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 15: astore_0\n 16: new #22 // class kotlin/text/Regex\n 19: dup\n 20: ldc #24 // String \\\\d+\n 22: invokespecial #25 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 25: aload_0\n 26: iconst_0\n 27: invokeinterface #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 32: checkcast #33 // class java/lang/CharSequence\n 35: iconst_1\n 36: anewarray #35 // class java/lang/String\n 39: astore_2\n 40: aload_2\n 41: iconst_0\n 42: ldc #37 // String :\n 44: aastore\n 45: aload_2\n 46: iconst_0\n 47: iconst_0\n 48: bipush 6\n 50: aconst_null\n 51: invokestatic #43 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 54: iconst_1\n 55: invokeinterface #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 60: checkcast #33 // class java/lang/CharSequence\n 63: iconst_0\n 64: iconst_2\n 65: aconst_null\n 66: invokestatic #47 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 69: invokedynamic #67, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 74: invokestatic #73 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 77: astore_1\n 78: aload_0\n 79: invokestatic #77 // Method parseMappings:(Ljava/util/List;)Ljava/util/List;\n 82: astore_2\n 83: aload_1\n 84: aload_2\n 85: invokestatic #81 // Method calculateMinLocationSeedRanges:(Lkotlin/sequences/Sequence;Ljava/util/List;)J\n 88: lstore_3\n 89: getstatic #87 // Field java/lang/System.out:Ljava/io/PrintStream;\n 92: lload_3\n 93: invokevirtual #93 // Method java/io/PrintStream.println:(J)V\n 96: return\n\n public static final long calculateMinLocationSeedRanges(kotlin.sequences.Sequence<java.lang.Long>, java.util.List<Mapping>);\n Code:\n 0: aload_0\n 1: ldc #101 // String rawSeeds\n 3: invokestatic #107 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #109 // String forwardMappings\n 9: invokestatic #107 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: iconst_2\n 14: invokestatic #113 // Method kotlin/sequences/SequencesKt.chunked:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;\n 17: invokedynamic #120, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 22: invokestatic #73 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 25: astore_3\n 26: nop\n 27: iconst_0\n 28: istore 4\n 30: aload_3\n 31: new #122 // class SoilKt$calculateMinLocationSeedRanges$$inlined$sortedBy$1\n 34: dup\n 35: invokespecial #124 // Method SoilKt$calculateMinLocationSeedRanges$$inlined$sortedBy$1.\"<init>\":()V\n 38: checkcast #126 // class java/util/Comparator\n 41: invokestatic #130 // Method kotlin/sequences/SequencesKt.sortedWith:(Lkotlin/sequences/Sequence;Ljava/util/Comparator;)Lkotlin/sequences/Sequence;\n 44: invokestatic #134 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 47: astore_2\n 48: aload_1\n 49: checkcast #136 // class java/lang/Iterable\n 52: astore 4\n 54: iconst_0\n 55: istore 5\n 57: aload 4\n 59: astore 6\n 61: new #138 // class java/util/ArrayList\n 64: dup\n 65: aload 4\n 67: bipush 10\n 69: invokestatic #144 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 72: invokespecial #147 // Method java/util/ArrayList.\"<init>\":(I)V\n 75: checkcast #149 // class java/util/Collection\n 78: astore 7\n 80: iconst_0\n 81: istore 8\n 83: aload 6\n 85: invokeinterface #153, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 90: astore 9\n 92: aload 9\n 94: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 99: ifeq 290\n 102: aload 9\n 104: invokeinterface #163, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 109: astore 10\n 111: aload 7\n 113: aload 10\n 115: checkcast #165 // class Mapping\n 118: astore 11\n 120: astore 29\n 122: iconst_0\n 123: istore 12\n 125: new #167 // class java/lang/StringBuilder\n 128: dup\n 129: invokespecial #168 // Method java/lang/StringBuilder.\"<init>\":()V\n 132: bipush 126\n 134: invokevirtual #172 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 137: aload 11\n 139: invokevirtual #176 // Method Mapping.getName:()Ljava/lang/String;\n 142: invokevirtual #179 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 145: invokevirtual #182 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 148: aload 11\n 150: invokevirtual #186 // Method Mapping.getSortedRanges:()Ljava/util/List;\n 153: checkcast #136 // class java/lang/Iterable\n 156: astore 13\n 158: astore 14\n 160: iconst_0\n 161: istore 18\n 163: aload 13\n 165: astore 19\n 167: new #138 // class java/util/ArrayList\n 170: dup\n 171: aload 13\n 173: bipush 10\n 175: invokestatic #144 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 178: invokespecial #147 // Method java/util/ArrayList.\"<init>\":(I)V\n 181: checkcast #149 // class java/util/Collection\n 184: astore 20\n 186: iconst_0\n 187: istore 21\n 189: aload 19\n 191: invokeinterface #153, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 196: astore 22\n 198: aload 22\n 200: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 205: ifeq 248\n 208: aload 22\n 210: invokeinterface #163, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 215: astore 23\n 217: aload 20\n 219: aload 23\n 221: checkcast #188 // class Range\n 224: astore 24\n 226: astore 25\n 228: iconst_0\n 229: istore 26\n 231: aload 24\n 233: invokevirtual #192 // Method Range.invert:()LRange;\n 236: aload 25\n 238: swap\n 239: invokeinterface #196, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 244: pop\n 245: goto 198\n 248: aload 20\n 250: checkcast #27 // class java/util/List\n 253: nop\n 254: aload 14\n 256: swap\n 257: checkcast #136 // class java/lang/Iterable\n 260: invokestatic #200 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 263: astore 30\n 265: astore 31\n 267: new #165 // class Mapping\n 270: dup\n 271: aload 31\n 273: aload 30\n 275: invokespecial #203 // Method Mapping.\"<init>\":(Ljava/lang/String;Ljava/util/Set;)V\n 278: aload 29\n 280: swap\n 281: invokeinterface #196, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 286: pop\n 287: goto 92\n 290: aload 7\n 292: checkcast #27 // class java/util/List\n 295: nop\n 296: checkcast #136 // class java/lang/Iterable\n 299: invokestatic #207 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 302: astore_3\n 303: aload_3\n 304: invokestatic #211 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 307: checkcast #165 // class Mapping\n 310: astore 4\n 312: aload 4\n 314: invokevirtual #186 // Method Mapping.getSortedRanges:()Ljava/util/List;\n 317: checkcast #136 // class java/lang/Iterable\n 320: astore 5\n 322: iconst_0\n 323: istore 6\n 325: aload 5\n 327: invokeinterface #153, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 332: astore 7\n 334: aload 7\n 336: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 341: ifeq 525\n 344: aload 7\n 346: invokeinterface #163, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 351: astore 8\n 353: aload 8\n 355: checkcast #188 // class Range\n 358: astore 9\n 360: iconst_0\n 361: istore 10\n 363: aload 9\n 365: invokevirtual #215 // Method Range.getSources:()Lkotlin/ranges/LongRange;\n 368: checkcast #136 // class java/lang/Iterable\n 371: astore 11\n 373: iconst_0\n 374: istore 12\n 376: aload 11\n 378: invokeinterface #153, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 383: astore 13\n 385: aload 13\n 387: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 392: ifeq 519\n 395: aload 13\n 397: checkcast #217 // class kotlin/collections/LongIterator\n 400: invokevirtual #221 // Method kotlin/collections/LongIterator.nextLong:()J\n 403: lstore 14\n 405: lload 14\n 407: lstore 16\n 409: iconst_0\n 410: istore 18\n 412: aload_3\n 413: lload 16\n 415: invokestatic #225 // Method fold:(Ljava/util/List;J)J\n 418: lstore 19\n 420: aload_2\n 421: checkcast #136 // class java/lang/Iterable\n 424: astore 21\n 426: iconst_0\n 427: istore 22\n 429: aload 21\n 431: invokeinterface #153, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 436: astore 23\n 438: aload 23\n 440: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 445: ifeq 513\n 448: aload 23\n 450: invokeinterface #163, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 455: astore 24\n 457: aload 24\n 459: checkcast #227 // class kotlin/ranges/LongRange\n 462: astore 25\n 464: iconst_0\n 465: istore 26\n 467: aload 25\n 469: invokevirtual #230 // Method kotlin/ranges/LongRange.getFirst:()J\n 472: lstore 27\n 474: lload 19\n 476: aload 25\n 478: invokevirtual #233 // Method kotlin/ranges/LongRange.getLast:()J\n 481: lcmp\n 482: ifgt 501\n 485: lload 27\n 487: lload 19\n 489: lcmp\n 490: ifgt 497\n 493: iconst_1\n 494: goto 502\n 497: iconst_0\n 498: goto 502\n 501: iconst_0\n 502: ifeq 508\n 505: lload 16\n 507: lreturn\n 508: nop\n 509: nop\n 510: goto 438\n 513: nop\n 514: nop\n 515: nop\n 516: goto 385\n 519: nop\n 520: nop\n 521: nop\n 522: goto 334\n 525: nop\n 526: new #235 // class java/lang/IllegalArgumentException\n 529: dup\n 530: invokespecial #236 // Method java/lang/IllegalArgumentException.\"<init>\":()V\n 533: athrow\n\n private static final long calculateMinLocationSimpleSeeds(kotlin.sequences.Sequence<java.lang.Long>, java.util.List<Mapping>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokedynamic #281, 0 // InvokeDynamic #2:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function1;\n 7: invokestatic #73 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 10: invokestatic #285 // Method kotlin/sequences/SequencesKt.minOrThrow:(Lkotlin/sequences/Sequence;)Ljava/lang/Comparable;\n 13: checkcast #287 // class java/lang/Number\n 16: invokevirtual #290 // Method java/lang/Number.longValue:()J\n 19: lreturn\n\n private static final long fold(java.util.List<Mapping>, long);\n Code:\n 0: aload_0\n 1: checkcast #136 // class java/lang/Iterable\n 4: astore_3\n 5: lload_1\n 6: lstore 4\n 8: iconst_0\n 9: istore 6\n 11: lload 4\n 13: lstore 7\n 15: aload_3\n 16: invokeinterface #153, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 21: astore 9\n 23: aload 9\n 25: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 30: ifeq 68\n 33: aload 9\n 35: invokeinterface #163, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 40: astore 10\n 42: lload 7\n 44: aload 10\n 46: checkcast #165 // class Mapping\n 49: astore 11\n 51: lstore 12\n 53: iconst_0\n 54: istore 14\n 56: aload 11\n 58: lload 12\n 60: invokevirtual #294 // Method Mapping.map:(J)J\n 63: lstore 7\n 65: goto 23\n 68: lload 7\n 70: lreturn\n\n private static final java.util.List<Mapping> parseMappings(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc_w #305 // String seed2Soil\n 4: iconst_3\n 5: bipush 32\n 7: invokestatic #309 // Method parseMapping:(Ljava/util/List;Ljava/lang/String;II)LMapping;\n 10: astore_1\n 11: aload_0\n 12: ldc_w #311 // String soil2Fertilizer\n 15: bipush 34\n 17: bipush 53\n 19: invokestatic #309 // Method parseMapping:(Ljava/util/List;Ljava/lang/String;II)LMapping;\n 22: astore_2\n 23: aload_0\n 24: ldc_w #313 // String fertilizer2Water\n 27: bipush 55\n 29: bipush 97\n 31: invokestatic #309 // Method parseMapping:(Ljava/util/List;Ljava/lang/String;II)LMapping;\n 34: astore_3\n 35: aload_0\n 36: ldc_w #315 // String water2Light\n 39: bipush 99\n 41: bipush 117\n 43: invokestatic #309 // Method parseMapping:(Ljava/util/List;Ljava/lang/String;II)LMapping;\n 46: astore 4\n 48: aload_0\n 49: ldc_w #317 // String light2Temperature\n 52: bipush 119\n 54: sipush 132\n 57: invokestatic #309 // Method parseMapping:(Ljava/util/List;Ljava/lang/String;II)LMapping;\n 60: astore 5\n 62: aload_0\n 63: ldc_w #319 // String temperature2Humidity\n 66: sipush 135\n 69: sipush 144\n 72: invokestatic #309 // Method parseMapping:(Ljava/util/List;Ljava/lang/String;II)LMapping;\n 75: astore 6\n 77: aload_0\n 78: ldc_w #321 // String humidity2Location\n 81: sipush 146\n 84: sipush 190\n 87: invokestatic #309 // Method parseMapping:(Ljava/util/List;Ljava/lang/String;II)LMapping;\n 90: astore 7\n 92: bipush 7\n 94: anewarray #165 // class Mapping\n 97: astore 8\n 99: aload 8\n 101: iconst_0\n 102: aload_1\n 103: aastore\n 104: aload 8\n 106: iconst_1\n 107: aload_2\n 108: aastore\n 109: aload 8\n 111: iconst_2\n 112: aload_3\n 113: aastore\n 114: aload 8\n 116: iconst_3\n 117: aload 4\n 119: aastore\n 120: aload 8\n 122: iconst_4\n 123: aload 5\n 125: aastore\n 126: aload 8\n 128: iconst_5\n 129: aload 6\n 131: aastore\n 132: aload 8\n 134: bipush 6\n 136: aload 7\n 138: aastore\n 139: aload 8\n 141: invokestatic #325 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 144: areturn\n\n private static final Mapping parseMapping(java.util.List<java.lang.String>, java.lang.String, int, int);\n Code:\n 0: aload_1\n 1: aload_0\n 2: iload_2\n 3: iload_3\n 4: invokeinterface #331, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 9: checkcast #136 // class java/lang/Iterable\n 12: astore 4\n 14: astore 14\n 16: iconst_0\n 17: istore 5\n 19: aload 4\n 21: astore 6\n 23: new #138 // class java/util/ArrayList\n 26: dup\n 27: aload 4\n 29: bipush 10\n 31: invokestatic #144 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 34: invokespecial #147 // Method java/util/ArrayList.\"<init>\":(I)V\n 37: checkcast #149 // class java/util/Collection\n 40: astore 7\n 42: iconst_0\n 43: istore 8\n 45: aload 6\n 47: invokeinterface #153, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 52: astore 9\n 54: aload 9\n 56: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 61: ifeq 181\n 64: aload 9\n 66: invokeinterface #163, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 71: astore 10\n 73: aload 7\n 75: aload 10\n 77: checkcast #35 // class java/lang/String\n 80: astore 11\n 82: astore 15\n 84: iconst_0\n 85: istore 12\n 87: new #22 // class kotlin/text/Regex\n 90: dup\n 91: ldc #24 // String \\\\d+\n 93: invokespecial #25 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 96: aload 11\n 98: checkcast #33 // class java/lang/CharSequence\n 101: iconst_0\n 102: iconst_2\n 103: aconst_null\n 104: invokestatic #47 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 107: invokedynamic #336, 0 // InvokeDynamic #3:invoke:()Lkotlin/jvm/functions/Function1;\n 112: invokestatic #73 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 115: invokestatic #134 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 118: astore 13\n 120: new #188 // class Range\n 123: dup\n 124: aload 13\n 126: iconst_1\n 127: invokeinterface #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 132: checkcast #287 // class java/lang/Number\n 135: invokevirtual #290 // Method java/lang/Number.longValue:()J\n 138: aload 13\n 140: iconst_0\n 141: invokeinterface #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 146: checkcast #287 // class java/lang/Number\n 149: invokevirtual #290 // Method java/lang/Number.longValue:()J\n 152: aload 13\n 154: iconst_2\n 155: invokeinterface #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 160: checkcast #287 // class java/lang/Number\n 163: invokevirtual #290 // Method java/lang/Number.longValue:()J\n 166: invokespecial #339 // Method Range.\"<init>\":(JJJ)V\n 169: aload 15\n 171: swap\n 172: invokeinterface #196, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 177: pop\n 178: goto 54\n 181: aload 7\n 183: checkcast #27 // class java/util/List\n 186: nop\n 187: aload 14\n 189: swap\n 190: checkcast #136 // class java/lang/Iterable\n 193: invokestatic #200 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 196: astore 16\n 198: astore 17\n 200: new #165 // class Mapping\n 203: dup\n 204: aload 17\n 206: aload 16\n 208: invokespecial #203 // Method Mapping.\"<init>\":(Ljava/lang/String;Ljava/util/Set;)V\n 211: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #350 // Method main:()V\n 3: return\n\n private static final long main$lambda$0(kotlin.text.MatchResult);\n Code:\n 0: aload_0\n 1: ldc_w #353 // String it\n 4: invokestatic #107 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokeinterface #358, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 13: invokestatic #364 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 16: lreturn\n\n private static final kotlin.ranges.LongRange calculateMinLocationSeedRanges$lambda$1(java.util.List);\n Code:\n 0: aload_0\n 1: ldc_w #367 // String pair\n 4: invokestatic #107 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: new #227 // class kotlin/ranges/LongRange\n 10: dup\n 11: aload_0\n 12: iconst_0\n 13: invokeinterface #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 18: checkcast #287 // class java/lang/Number\n 21: invokevirtual #290 // Method java/lang/Number.longValue:()J\n 24: aload_0\n 25: iconst_0\n 26: invokeinterface #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 31: checkcast #287 // class java/lang/Number\n 34: invokevirtual #290 // Method java/lang/Number.longValue:()J\n 37: aload_0\n 38: iconst_1\n 39: invokeinterface #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 44: checkcast #287 // class java/lang/Number\n 47: invokevirtual #290 // Method java/lang/Number.longValue:()J\n 50: ladd\n 51: lconst_1\n 52: lsub\n 53: invokespecial #370 // Method kotlin/ranges/LongRange.\"<init>\":(JJ)V\n 56: areturn\n\n private static final long calculateMinLocationSimpleSeeds$lambda$8(java.util.List, long);\n Code:\n 0: aload_0\n 1: lload_1\n 2: invokestatic #225 // Method fold:(Ljava/util/List;J)J\n 5: lreturn\n\n private static final long parseMapping$lambda$11$lambda$10(kotlin.text.MatchResult);\n Code:\n 0: aload_0\n 1: ldc_w #353 // String it\n 4: invokestatic #107 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokeinterface #358, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 13: invokestatic #364 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 16: lreturn\n}\n",
"javap_err": ""
},
{
"class_path": "aragos__aoc2023__7bca0a8/SoilKt$calculateMinLocationSeedRanges$$inlined$sortedBy$1.class",
"javap": "Compiled from \"Comparisons.kt\"\npublic final class SoilKt$calculateMinLocationSeedRanges$$inlined$sortedBy$1<T> implements java.util.Comparator {\n public SoilKt$calculateMinLocationSeedRanges$$inlined$sortedBy$1();\n Code:\n 0: aload_0\n 1: invokespecial #16 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int compare(T, T);\n Code:\n 0: aload_1\n 1: checkcast #23 // class kotlin/ranges/LongRange\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method kotlin/ranges/LongRange.getStart:()Ljava/lang/Long;\n 12: checkcast #29 // class java/lang/Comparable\n 15: aload_2\n 16: checkcast #23 // class kotlin/ranges/LongRange\n 19: astore_3\n 20: astore 5\n 22: iconst_0\n 23: istore 4\n 25: aload_3\n 26: invokevirtual #27 // Method kotlin/ranges/LongRange.getStart:()Ljava/lang/Long;\n 29: aload 5\n 31: swap\n 32: checkcast #29 // class java/lang/Comparable\n 35: invokestatic #35 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I\n 38: ireturn\n}\n",
"javap_err": ""
}
] |
aragos__aoc2023__7bca0a8/aoc/src/Parts.kt
|
import java.io.File
fun main() {
// countPartNumbers()
countGearRatios()
}
private data class PartNumber(val value: Int, val location: IntRange) {
fun isAdjacentTo(i: Int) = i in (location.first-1)..(location.last+1)
}
private fun countGearRatios() {
var line1: Set<PartNumber>
var line2 = setOf<PartNumber>()
var line3 = setOf<PartNumber>()
var previousLine = ""
val allRatios = File("inputs/parts.txt").readLines().map { line ->
line1 = line2
line2 = line3
line3 = Regex("\\d+").findAll(line).map { PartNumber(it.value.toInt(), it.range) }.toSet()
val ratioSum = scanRatios(previousLine, line1 + line2 + line3)
previousLine = line
ratioSum
}.sum()
println(allRatios + scanRatios(previousLine, line2 + line3))
}
private fun scanRatios(
previousLine: String,
partNumbers1: Set<PartNumber>,
): Int {
val ratioSum = previousLine.mapIndexedNotNull { ix, char ->
if (char != '*') {
null
} else {
val partNumbers = partNumbers1.filter { it.isAdjacentTo(ix) }
if (partNumbers.size == 2) {
partNumbers[0].value * partNumbers[1].value
} else {
null
}
}
}.sum()
return ratioSum
}
private fun countPartNumbers() {
var line1: Set<Int>
var line2 = setOf<Int>()
var line3 = setOf<Int>()
var previousLine = ""
val allNumbers = File("inputs/parts.txt").readLines().map { line ->
line1 = line2
line2 = line3
line3 =
line.mapIndexedNotNull { ix, char -> if (char != '.' && char.isNotANumber()) ix else null }
.toSet()
val line2PartNumberSum = scanPartNumbers(previousLine, line1 + line2 + line3)
previousLine = line
line2PartNumberSum
}.sum()
println(allNumbers + scanPartNumbers(previousLine, line2 + line3))
}
private fun scanPartNumbers(
partNumberLine: String,
partLocations: Set<Int>,
): Int {
return Regex("\\d+").findAll(partNumberLine).mapNotNull {
val number = it.value.toInt()
for (i in (it.range.first - 1)..(it.range.last + 1)) {
if (i in partLocations) {
return@mapNotNull number
}
}
null
}.sum()
}
private fun Char.isNotANumber() = digitToIntOrNull() == null
|
[
{
"class_path": "aragos__aoc2023__7bca0a8/PartsKt.class",
"javap": "Compiled from \"Parts.kt\"\npublic final class PartsKt {\n public static final void main();\n Code:\n 0: invokestatic #9 // Method countGearRatios:()V\n 3: return\n\n private static final void countGearRatios();\n Code:\n 0: aconst_null\n 1: astore_0\n 2: aconst_null\n 3: astore_1\n 4: invokestatic #15 // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;\n 7: astore_1\n 8: aconst_null\n 9: astore_2\n 10: invokestatic #15 // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;\n 13: astore_2\n 14: aconst_null\n 15: astore_3\n 16: ldc #17 // String\n 18: astore_3\n 19: new #19 // class java/io/File\n 22: dup\n 23: ldc #21 // String inputs/parts.txt\n 25: invokespecial #25 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 28: aconst_null\n 29: iconst_1\n 30: aconst_null\n 31: invokestatic #31 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 34: checkcast #33 // class java/lang/Iterable\n 37: astore 5\n 39: iconst_0\n 40: istore 6\n 42: aload 5\n 44: astore 7\n 46: new #35 // class java/util/ArrayList\n 49: dup\n 50: aload 5\n 52: bipush 10\n 54: invokestatic #41 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 57: invokespecial #44 // Method java/util/ArrayList.\"<init>\":(I)V\n 60: checkcast #46 // class java/util/Collection\n 63: astore 8\n 65: iconst_0\n 66: istore 9\n 68: aload 7\n 70: invokeinterface #50, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 75: astore 10\n 77: aload 10\n 79: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 84: ifeq 187\n 87: aload 10\n 89: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 94: astore 11\n 96: aload 8\n 98: aload 11\n 100: checkcast #62 // class java/lang/String\n 103: astore 12\n 105: astore 15\n 107: iconst_0\n 108: istore 13\n 110: aload_1\n 111: astore_0\n 112: aload_2\n 113: astore_1\n 114: new #64 // class kotlin/text/Regex\n 117: dup\n 118: ldc #66 // String \\\\d+\n 120: invokespecial #67 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 123: aload 12\n 125: checkcast #69 // class java/lang/CharSequence\n 128: iconst_0\n 129: iconst_2\n 130: aconst_null\n 131: invokestatic #73 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 134: invokedynamic #92, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 139: invokestatic #98 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 142: invokestatic #102 // Method kotlin/sequences/SequencesKt.toSet:(Lkotlin/sequences/Sequence;)Ljava/util/Set;\n 145: astore_2\n 146: aload_3\n 147: aload_0\n 148: aload_1\n 149: checkcast #33 // class java/lang/Iterable\n 152: invokestatic #106 // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Iterable;)Ljava/util/Set;\n 155: aload_2\n 156: checkcast #33 // class java/lang/Iterable\n 159: invokestatic #106 // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Iterable;)Ljava/util/Set;\n 162: invokestatic #110 // Method scanRatios:(Ljava/lang/String;Ljava/util/Set;)I\n 165: istore 14\n 167: aload 12\n 169: astore_3\n 170: iload 14\n 172: invokestatic #116 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 175: aload 15\n 177: swap\n 178: invokeinterface #120, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 183: pop\n 184: goto 77\n 187: aload 8\n 189: checkcast #122 // class java/util/List\n 192: nop\n 193: checkcast #33 // class java/lang/Iterable\n 196: invokestatic #126 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 199: istore 4\n 201: iload 4\n 203: aload_3\n 204: aload_1\n 205: aload_2\n 206: checkcast #33 // class java/lang/Iterable\n 209: invokestatic #106 // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Iterable;)Ljava/util/Set;\n 212: invokestatic #110 // Method scanRatios:(Ljava/lang/String;Ljava/util/Set;)I\n 215: iadd\n 216: istore 5\n 218: getstatic #132 // Field java/lang/System.out:Ljava/io/PrintStream;\n 221: iload 5\n 223: invokevirtual #137 // Method java/io/PrintStream.println:(I)V\n 226: return\n\n private static final int scanRatios(java.lang.String, java.util.Set<PartNumber>);\n Code:\n 0: aload_0\n 1: checkcast #69 // class java/lang/CharSequence\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: astore 5\n 11: new #35 // class java/util/ArrayList\n 14: dup\n 15: invokespecial #161 // Method java/util/ArrayList.\"<init>\":()V\n 18: checkcast #46 // class java/util/Collection\n 21: astore 6\n 23: iconst_0\n 24: istore 7\n 26: aload 5\n 28: astore 8\n 30: iconst_0\n 31: istore 9\n 33: iconst_0\n 34: istore 10\n 36: iconst_0\n 37: istore 11\n 39: iload 11\n 41: aload 8\n 43: invokeinterface #165, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 48: if_icmpge 273\n 51: aload 8\n 53: iload 11\n 55: invokeinterface #169, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 60: istore 12\n 62: iload 10\n 64: iinc 10, 1\n 67: iload 12\n 69: istore 13\n 71: istore 14\n 73: iconst_0\n 74: istore 15\n 76: iload 14\n 78: iload 13\n 80: istore 16\n 82: istore 17\n 84: iconst_0\n 85: istore 18\n 87: iload 16\n 89: bipush 42\n 91: if_icmpeq 98\n 94: aconst_null\n 95: goto 242\n 98: aload_1\n 99: checkcast #33 // class java/lang/Iterable\n 102: astore 19\n 104: iconst_0\n 105: istore 20\n 107: aload 19\n 109: astore 21\n 111: new #35 // class java/util/ArrayList\n 114: dup\n 115: invokespecial #161 // Method java/util/ArrayList.\"<init>\":()V\n 118: checkcast #46 // class java/util/Collection\n 121: astore 22\n 123: iconst_0\n 124: istore 23\n 126: aload 21\n 128: invokeinterface #50, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 133: astore 24\n 135: aload 24\n 137: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 142: ifeq 187\n 145: aload 24\n 147: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 152: astore 25\n 154: aload 25\n 156: checkcast #171 // class PartNumber\n 159: astore 26\n 161: iconst_0\n 162: istore 27\n 164: aload 26\n 166: iload 17\n 168: invokevirtual #175 // Method PartNumber.isAdjacentTo:(I)Z\n 171: ifeq 135\n 174: aload 22\n 176: aload 25\n 178: invokeinterface #120, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 183: pop\n 184: goto 135\n 187: aload 22\n 189: checkcast #122 // class java/util/List\n 192: nop\n 193: astore 28\n 195: aload 28\n 197: invokeinterface #178, 1 // InterfaceMethod java/util/List.size:()I\n 202: iconst_2\n 203: if_icmpne 241\n 206: aload 28\n 208: iconst_0\n 209: invokeinterface #182, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 214: checkcast #171 // class PartNumber\n 217: invokevirtual #185 // Method PartNumber.getValue:()I\n 220: aload 28\n 222: iconst_1\n 223: invokeinterface #182, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 228: checkcast #171 // class PartNumber\n 231: invokevirtual #185 // Method PartNumber.getValue:()I\n 234: imul\n 235: invokestatic #116 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 238: goto 242\n 241: aconst_null\n 242: nop\n 243: dup\n 244: ifnull 265\n 247: astore 29\n 249: iconst_0\n 250: istore 30\n 252: aload 6\n 254: aload 29\n 256: invokeinterface #120, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 261: pop\n 262: goto 266\n 265: pop\n 266: nop\n 267: iinc 11, 1\n 270: goto 39\n 273: nop\n 274: aload 6\n 276: checkcast #122 // class java/util/List\n 279: nop\n 280: checkcast #33 // class java/lang/Iterable\n 283: invokestatic #126 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 286: istore_2\n 287: iload_2\n 288: ireturn\n\n private static final void countPartNumbers();\n Code:\n 0: aconst_null\n 1: astore_0\n 2: aconst_null\n 3: astore_1\n 4: invokestatic #15 // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;\n 7: astore_1\n 8: new #217 // class kotlin/jvm/internal/Ref$ObjectRef\n 11: dup\n 12: invokespecial #218 // Method kotlin/jvm/internal/Ref$ObjectRef.\"<init>\":()V\n 15: astore_2\n 16: aload_2\n 17: invokestatic #15 // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;\n 20: putfield #221 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 23: aconst_null\n 24: astore_3\n 25: ldc #17 // String\n 27: astore_3\n 28: new #19 // class java/io/File\n 31: dup\n 32: ldc #21 // String inputs/parts.txt\n 34: invokespecial #25 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 37: aconst_null\n 38: iconst_1\n 39: aconst_null\n 40: invokestatic #31 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 43: checkcast #33 // class java/lang/Iterable\n 46: astore 5\n 48: iconst_0\n 49: istore 6\n 51: aload 5\n 53: astore 7\n 55: new #35 // class java/util/ArrayList\n 58: dup\n 59: aload 5\n 61: bipush 10\n 63: invokestatic #41 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 66: invokespecial #44 // Method java/util/ArrayList.\"<init>\":(I)V\n 69: checkcast #46 // class java/util/Collection\n 72: astore 8\n 74: iconst_0\n 75: istore 9\n 77: aload 7\n 79: invokeinterface #50, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 84: astore 10\n 86: aload 10\n 88: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 93: ifeq 339\n 96: aload 10\n 98: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 103: astore 11\n 105: aload 8\n 107: aload 11\n 109: checkcast #62 // class java/lang/String\n 112: astore 12\n 114: astore 33\n 116: iconst_0\n 117: istore 13\n 119: aload_1\n 120: astore_0\n 121: aload_2\n 122: getfield #221 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 125: astore_1\n 126: aload_2\n 127: aload 12\n 129: checkcast #69 // class java/lang/CharSequence\n 132: astore 14\n 134: astore 15\n 136: iconst_0\n 137: istore 16\n 139: aload 14\n 141: astore 17\n 143: new #35 // class java/util/ArrayList\n 146: dup\n 147: invokespecial #161 // Method java/util/ArrayList.\"<init>\":()V\n 150: checkcast #46 // class java/util/Collection\n 153: astore 18\n 155: iconst_0\n 156: istore 19\n 158: aload 17\n 160: astore 20\n 162: iconst_0\n 163: istore 21\n 165: iconst_0\n 166: istore 22\n 168: iconst_0\n 169: istore 23\n 171: iload 23\n 173: aload 20\n 175: invokeinterface #165, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 180: if_icmpge 273\n 183: aload 20\n 185: iload 23\n 187: invokeinterface #169, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 192: istore 24\n 194: iload 22\n 196: iinc 22, 1\n 199: iload 24\n 201: istore 25\n 203: istore 26\n 205: iconst_0\n 206: istore 27\n 208: iload 26\n 210: iload 25\n 212: istore 28\n 214: istore 29\n 216: iconst_0\n 217: istore 30\n 219: iload 28\n 221: bipush 46\n 223: if_icmpeq 242\n 226: iload 28\n 228: invokestatic #225 // Method isNotANumber:(C)Z\n 231: ifeq 242\n 234: iload 29\n 236: invokestatic #116 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 239: goto 243\n 242: aconst_null\n 243: dup\n 244: ifnull 265\n 247: astore 31\n 249: iconst_0\n 250: istore 32\n 252: aload 18\n 254: aload 31\n 256: invokeinterface #120, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 261: pop\n 262: goto 266\n 265: pop\n 266: nop\n 267: iinc 23, 1\n 270: goto 171\n 273: nop\n 274: aload 18\n 276: checkcast #122 // class java/util/List\n 279: nop\n 280: aload 15\n 282: swap\n 283: checkcast #33 // class java/lang/Iterable\n 286: invokestatic #228 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 289: putfield #221 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 292: aload_3\n 293: aload_0\n 294: checkcast #158 // class java/util/Set\n 297: aload_1\n 298: checkcast #33 // class java/lang/Iterable\n 301: invokestatic #106 // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Iterable;)Ljava/util/Set;\n 304: aload_2\n 305: getfield #221 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 308: checkcast #33 // class java/lang/Iterable\n 311: invokestatic #106 // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Iterable;)Ljava/util/Set;\n 314: invokestatic #231 // Method scanPartNumbers:(Ljava/lang/String;Ljava/util/Set;)I\n 317: istore 14\n 319: aload 12\n 321: astore_3\n 322: iload 14\n 324: invokestatic #116 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 327: aload 33\n 329: swap\n 330: invokeinterface #120, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 335: pop\n 336: goto 86\n 339: aload 8\n 341: checkcast #122 // class java/util/List\n 344: nop\n 345: checkcast #33 // class java/lang/Iterable\n 348: invokestatic #126 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 351: istore 4\n 353: iload 4\n 355: aload_3\n 356: aload_1\n 357: checkcast #158 // class java/util/Set\n 360: aload_2\n 361: getfield #221 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;\n 364: checkcast #33 // class java/lang/Iterable\n 367: invokestatic #106 // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Iterable;)Ljava/util/Set;\n 370: invokestatic #231 // Method scanPartNumbers:(Ljava/lang/String;Ljava/util/Set;)I\n 373: iadd\n 374: istore 5\n 376: getstatic #132 // Field java/lang/System.out:Ljava/io/PrintStream;\n 379: iload 5\n 381: invokevirtual #137 // Method java/io/PrintStream.println:(I)V\n 384: return\n\n private static final int scanPartNumbers(java.lang.String, java.util.Set<java.lang.Integer>);\n Code:\n 0: new #64 // class kotlin/text/Regex\n 3: dup\n 4: ldc #66 // String \\\\d+\n 6: invokespecial #67 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 9: aload_0\n 10: checkcast #69 // class java/lang/CharSequence\n 13: iconst_0\n 14: iconst_2\n 15: aconst_null\n 16: invokestatic #73 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 19: aload_1\n 20: invokedynamic #247, 0 // InvokeDynamic #1:invoke:(Ljava/util/Set;)Lkotlin/jvm/functions/Function1;\n 25: invokestatic #250 // Method kotlin/sequences/SequencesKt.mapNotNull:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 28: invokestatic #253 // Method kotlin/sequences/SequencesKt.sumOfInt:(Lkotlin/sequences/Sequence;)I\n 31: ireturn\n\n private static final boolean isNotANumber(char);\n Code:\n 0: iload_0\n 1: invokestatic #261 // Method kotlin/text/CharsKt.digitToIntOrNull:(C)Ljava/lang/Integer;\n 4: ifnonnull 11\n 7: iconst_1\n 8: goto 12\n 11: iconst_0\n 12: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #265 // Method main:()V\n 3: return\n\n private static final PartNumber countGearRatios$lambda$1$lambda$0(kotlin.text.MatchResult);\n Code:\n 0: aload_0\n 1: ldc_w #268 // String it\n 4: invokestatic #274 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: new #171 // class PartNumber\n 10: dup\n 11: aload_0\n 12: invokeinterface #279, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 17: invokestatic #283 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 20: aload_0\n 21: invokeinterface #287, 1 // InterfaceMethod kotlin/text/MatchResult.getRange:()Lkotlin/ranges/IntRange;\n 26: invokespecial #290 // Method PartNumber.\"<init>\":(ILkotlin/ranges/IntRange;)V\n 29: areturn\n\n private static final java.lang.Integer scanPartNumbers$lambda$6(java.util.Set, kotlin.text.MatchResult);\n Code:\n 0: aload_1\n 1: ldc_w #268 // String it\n 4: invokestatic #274 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: invokeinterface #279, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 13: invokestatic #283 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 16: istore_2\n 17: aload_1\n 18: invokeinterface #287, 1 // InterfaceMethod kotlin/text/MatchResult.getRange:()Lkotlin/ranges/IntRange;\n 23: invokevirtual #296 // Method kotlin/ranges/IntRange.getFirst:()I\n 26: iconst_1\n 27: isub\n 28: istore_3\n 29: aload_1\n 30: invokeinterface #287, 1 // InterfaceMethod kotlin/text/MatchResult.getRange:()Lkotlin/ranges/IntRange;\n 35: invokevirtual #299 // Method kotlin/ranges/IntRange.getLast:()I\n 38: iconst_1\n 39: iadd\n 40: istore 4\n 42: iload_3\n 43: iload 4\n 45: if_icmpgt 78\n 48: aload_0\n 49: iload_3\n 50: invokestatic #116 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 53: invokeinterface #302, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 58: ifeq 66\n 61: iload_2\n 62: invokestatic #116 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 65: areturn\n 66: iload_3\n 67: iload 4\n 69: if_icmpeq 78\n 72: iinc 3, 1\n 75: goto 48\n 78: aconst_null\n 79: areturn\n}\n",
"javap_err": ""
}
] |
aragos__aoc2023__7bca0a8/aoc/src/Hands.kt
|
import Card.Companion.toCard
import java.io.File
fun main() {
val lines = File("aoc/inputs/hands.txt").readLines()
println(linesToWinnings(lines))
}
internal fun linesToWinnings(lines: List<String>): Int {
return lines
.map { line ->
HandWinnings(
Hand(line.substring(0, 5).map { it.toCard() }),
line.substring(6).toInt()
)
}
.sortedByDescending(HandWinnings::hand)
.mapIndexed { ix, handWinnings -> (ix + 1) * handWinnings.winnings }
.sum()
}
data class HandWinnings(val hand: Hand, val winnings: Int)
enum class Card(val representation: Char) {
Ace('A'),
King('K'),
Queen('Q'),
// Jack('J'),
Ten('T'),
Nine('9'),
Eight('8'),
Seven('7'),
Six('6'),
Five('5'),
Four('4'),
Three('3'),
Two('2'),
Joker('J');
companion object {
fun Char.toCard(): Card {
for (card in entries) {
if (this == card.representation) {
return card
}
}
throw IllegalArgumentException("Non-card character '$this'")
}
}
}
enum class Type { Five, Four, FullHouse, Three, TwoPair, OnePair, High }
class Hand(private val cards: List<Card>) : Comparable<Hand> {
private val distribution: Map<Card, Int> =
cards.fold(mutableMapOf()) { dist, card ->
dist[card] = dist.getOrDefault(card, 0) + 1
dist
}
private val type: Type
get() {
return when (distribution.size) {
1 -> Type.Five
2 -> if (distribution.values.any { it == 4 }) Type.Four else Type.FullHouse
3 -> if (distribution.values.any { it == 3 }) Type.Three else Type.TwoPair
4 -> Type.OnePair
5 -> Type.High
else -> throw IllegalStateException("Wrong number of cards")
}
}
private val complexType: Type
get() {
var nonJokers = 0
val distribution = cards.fold(mutableMapOf<Card, Int>()) { dist, card ->
if (card != Card.Joker) {
dist[card] = dist.getOrDefault(card, 0) + 1
nonJokers++
}
dist
}
val jokers = 5 - nonJokers
return when (distribution.size) {
0 -> Type.Five // All jokers
1 -> Type.Five // Jokers become the one other card type
2 -> if (distribution.values.any { it == nonJokers - 1 }) Type.Four else Type.FullHouse
3 -> if (distribution.values.any { it == 3-jokers }) Type.Three else Type.TwoPair
4 -> Type.OnePair
5 -> Type.High
else -> throw IllegalStateException("Wrong number of cards")
}
}
override operator fun compareTo(other: Hand): Int {
if (this.complexType != other.complexType) {
return this.complexType.compareTo(other.complexType)
}
for (i in 0..4) {
if (this.cards[i] != other.cards[i]) {
return this.cards[i].compareTo(other.cards[i])
}
}
return 0
}
}
|
[
{
"class_path": "aragos__aoc2023__7bca0a8/HandsKt$linesToWinnings$$inlined$sortedByDescending$1.class",
"javap": "Compiled from \"Comparisons.kt\"\npublic final class HandsKt$linesToWinnings$$inlined$sortedByDescending$1<T> implements java.util.Comparator {\n public HandsKt$linesToWinnings$$inlined$sortedByDescending$1();\n Code:\n 0: aload_0\n 1: invokespecial #16 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int compare(T, T);\n Code:\n 0: aload_2\n 1: checkcast #23 // class HandWinnings\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method HandWinnings.getHand:()LHand;\n 12: checkcast #29 // class java/lang/Comparable\n 15: aload_1\n 16: checkcast #23 // class HandWinnings\n 19: astore_3\n 20: astore 5\n 22: iconst_0\n 23: istore 4\n 25: aload_3\n 26: invokevirtual #27 // Method HandWinnings.getHand:()LHand;\n 29: aload 5\n 31: swap\n 32: checkcast #29 // class java/lang/Comparable\n 35: invokestatic #35 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I\n 38: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "aragos__aoc2023__7bca0a8/HandsKt.class",
"javap": "Compiled from \"Hands.kt\"\npublic final class HandsKt {\n public static final void main();\n Code:\n 0: new #8 // class java/io/File\n 3: dup\n 4: ldc #10 // String aoc/inputs/hands.txt\n 6: invokespecial #14 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: aconst_null\n 10: iconst_1\n 11: aconst_null\n 12: invokestatic #20 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 15: astore_0\n 16: aload_0\n 17: invokestatic #24 // Method linesToWinnings:(Ljava/util/List;)I\n 20: istore_1\n 21: getstatic #30 // Field java/lang/System.out:Ljava/io/PrintStream;\n 24: iload_1\n 25: invokevirtual #36 // Method java/io/PrintStream.println:(I)V\n 28: return\n\n public static final int linesToWinnings(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #41 // String lines\n 3: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #49 // class java/lang/Iterable\n 10: astore_1\n 11: nop\n 12: iconst_0\n 13: istore_2\n 14: aload_1\n 15: astore_3\n 16: new #51 // class java/util/ArrayList\n 19: dup\n 20: aload_1\n 21: bipush 10\n 23: invokestatic #57 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #59 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #61 // class java/util/Collection\n 32: astore 4\n 34: iconst_0\n 35: istore 5\n 37: aload_3\n 38: invokeinterface #65, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 43: astore 6\n 45: aload 6\n 47: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 52: ifeq 247\n 55: aload 6\n 57: invokeinterface #75, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 62: astore 7\n 64: aload 4\n 66: aload 7\n 68: checkcast #77 // class java/lang/String\n 71: astore 8\n 73: astore 22\n 75: iconst_0\n 76: istore 9\n 78: aload 8\n 80: iconst_0\n 81: iconst_5\n 82: invokevirtual #81 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 85: dup\n 86: ldc #83 // String substring(...)\n 88: invokestatic #86 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 91: checkcast #88 // class java/lang/CharSequence\n 94: astore 10\n 96: iconst_0\n 97: istore 13\n 99: aload 10\n 101: astore 14\n 103: new #51 // class java/util/ArrayList\n 106: dup\n 107: aload 10\n 109: invokeinterface #92, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 114: invokespecial #59 // Method java/util/ArrayList.\"<init>\":(I)V\n 117: checkcast #61 // class java/util/Collection\n 120: astore 15\n 122: iconst_0\n 123: istore 16\n 125: iconst_0\n 126: istore 17\n 128: iload 17\n 130: aload 14\n 132: invokeinterface #92, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 137: if_icmpge 185\n 140: aload 14\n 142: iload 17\n 144: invokeinterface #96, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 149: istore 18\n 151: aload 15\n 153: iload 18\n 155: istore 19\n 157: astore 20\n 159: iconst_0\n 160: istore 21\n 162: getstatic #102 // Field Card.Companion:LCard$Companion;\n 165: iload 19\n 167: invokevirtual #108 // Method Card$Companion.toCard:(C)LCard;\n 170: aload 20\n 172: swap\n 173: invokeinterface #112, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 178: pop\n 179: iinc 17, 1\n 182: goto 128\n 185: aload 15\n 187: checkcast #114 // class java/util/List\n 190: nop\n 191: astore 23\n 193: new #116 // class Hand\n 196: dup\n 197: aload 23\n 199: invokespecial #119 // Method Hand.\"<init>\":(Ljava/util/List;)V\n 202: nop\n 203: aload 8\n 205: bipush 6\n 207: invokevirtual #122 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 210: dup\n 211: ldc #83 // String substring(...)\n 213: invokestatic #86 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 216: invokestatic #128 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 219: istore 24\n 221: astore 25\n 223: new #130 // class HandWinnings\n 226: dup\n 227: aload 25\n 229: iload 24\n 231: invokespecial #133 // Method HandWinnings.\"<init>\":(LHand;I)V\n 234: nop\n 235: aload 22\n 237: swap\n 238: invokeinterface #112, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 243: pop\n 244: goto 45\n 247: aload 4\n 249: checkcast #114 // class java/util/List\n 252: nop\n 253: checkcast #49 // class java/lang/Iterable\n 256: astore_1\n 257: nop\n 258: iconst_0\n 259: istore_2\n 260: aload_1\n 261: new #135 // class HandsKt$linesToWinnings$$inlined$sortedByDescending$1\n 264: dup\n 265: invokespecial #137 // Method HandsKt$linesToWinnings$$inlined$sortedByDescending$1.\"<init>\":()V\n 268: checkcast #139 // class java/util/Comparator\n 271: invokestatic #143 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 274: checkcast #49 // class java/lang/Iterable\n 277: astore_1\n 278: nop\n 279: iconst_0\n 280: istore_2\n 281: aload_1\n 282: astore_3\n 283: new #51 // class java/util/ArrayList\n 286: dup\n 287: aload_1\n 288: bipush 10\n 290: invokestatic #57 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 293: invokespecial #59 // Method java/util/ArrayList.\"<init>\":(I)V\n 296: checkcast #61 // class java/util/Collection\n 299: astore 4\n 301: iconst_0\n 302: istore 5\n 304: iconst_0\n 305: istore 6\n 307: aload_3\n 308: invokeinterface #65, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 313: astore 7\n 315: aload 7\n 317: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 322: ifeq 392\n 325: aload 7\n 327: invokeinterface #75, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 332: astore 8\n 334: aload 4\n 336: iload 6\n 338: iinc 6, 1\n 341: istore 9\n 343: iload 9\n 345: ifge 351\n 348: invokestatic #146 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 351: iload 9\n 353: aload 8\n 355: checkcast #130 // class HandWinnings\n 358: astore 10\n 360: istore 11\n 362: astore 22\n 364: iconst_0\n 365: istore 12\n 367: iload 11\n 369: iconst_1\n 370: iadd\n 371: aload 10\n 373: invokevirtual #149 // Method HandWinnings.getWinnings:()I\n 376: imul\n 377: invokestatic #153 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 380: aload 22\n 382: swap\n 383: invokeinterface #112, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 388: pop\n 389: goto 315\n 392: aload 4\n 394: checkcast #114 // class java/util/List\n 397: nop\n 398: checkcast #49 // class java/lang/Iterable\n 401: invokestatic #157 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 404: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #188 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
aragos__aoc2023__7bca0a8/aoc/src/ColorGame.kt
|
import java.io.File
fun main() {
// problem1()
problem2()
}
private fun problem2() {
var powerSum = 0
val colors = listOf("red", "green", "blue")
File("inputs/colorGame.txt").forEachLine { line ->
val split = line.split(":")
val maxes = colors.associateWith { 0 }.toMutableMap()
split[1].split(";").forEach {
it.split(",").forEach { color ->
for ((name, max) in maxes) {
if (color.contains(name)) {
val count = Regex("\\d+").find(color)?.value?.toInt() ?: 0
if (count > max) {
maxes[name] = count
}
}
}
}
}
powerSum += maxes.values.reduce { acc, value -> acc * value }
}
println(powerSum)
}
private fun problem1() {
val colors = mapOf("red" to 12, "green" to 13, "blue" to 14)
var validGamesSum = 0
File("inputs/colorGame.txt").forEachLine { line ->
val split = line.split(":")
val gameId = split[0].substring(5).toInt()
split[1].split(";").forEach {
it.split(",").forEach { color ->
for ((name, max) in colors) {
if (color.contains(name)) {
if ((Regex("\\d+").find(color)?.value?.toInt() ?: 0) > max) {
return@forEachLine
}
}
}
}
}
validGamesSum += gameId
}
println(validGamesSum)
}
|
[
{
"class_path": "aragos__aoc2023__7bca0a8/ColorGameKt.class",
"javap": "Compiled from \"ColorGame.kt\"\npublic final class ColorGameKt {\n public static final void main();\n Code:\n 0: invokestatic #9 // Method problem2:()V\n 3: return\n\n private static final void problem2();\n Code:\n 0: new #11 // class kotlin/jvm/internal/Ref$IntRef\n 3: dup\n 4: invokespecial #14 // Method kotlin/jvm/internal/Ref$IntRef.\"<init>\":()V\n 7: astore_0\n 8: iconst_3\n 9: anewarray #16 // class java/lang/String\n 12: astore_2\n 13: aload_2\n 14: iconst_0\n 15: ldc #18 // String red\n 17: aastore\n 18: aload_2\n 19: iconst_1\n 20: ldc #20 // String green\n 22: aastore\n 23: aload_2\n 24: iconst_2\n 25: ldc #22 // String blue\n 27: aastore\n 28: aload_2\n 29: invokestatic #28 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 32: astore_1\n 33: new #30 // class java/io/File\n 36: dup\n 37: ldc #32 // String inputs/colorGame.txt\n 39: invokespecial #35 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 42: aconst_null\n 43: aload_1\n 44: aload_0\n 45: invokedynamic #55, 0 // InvokeDynamic #0:invoke:(Ljava/util/List;Lkotlin/jvm/internal/Ref$IntRef;)Lkotlin/jvm/functions/Function1;\n 50: iconst_1\n 51: aconst_null\n 52: invokestatic #61 // Method kotlin/io/FilesKt.forEachLine$default:(Ljava/io/File;Ljava/nio/charset/Charset;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V\n 55: aload_0\n 56: getfield #65 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 59: istore_2\n 60: getstatic #71 // Field java/lang/System.out:Ljava/io/PrintStream;\n 63: iload_2\n 64: invokevirtual #77 // Method java/io/PrintStream.println:(I)V\n 67: return\n\n private static final void problem1();\n Code:\n 0: iconst_3\n 1: anewarray #84 // class kotlin/Pair\n 4: astore_1\n 5: aload_1\n 6: iconst_0\n 7: ldc #18 // String red\n 9: bipush 12\n 11: invokestatic #90 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 14: invokestatic #96 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 17: aastore\n 18: aload_1\n 19: iconst_1\n 20: ldc #20 // String green\n 22: bipush 13\n 24: invokestatic #90 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 27: invokestatic #96 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 30: aastore\n 31: aload_1\n 32: iconst_2\n 33: ldc #22 // String blue\n 35: bipush 14\n 37: invokestatic #90 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 40: invokestatic #96 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 43: aastore\n 44: aload_1\n 45: invokestatic #102 // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 48: astore_0\n 49: new #11 // class kotlin/jvm/internal/Ref$IntRef\n 52: dup\n 53: invokespecial #14 // Method kotlin/jvm/internal/Ref$IntRef.\"<init>\":()V\n 56: astore_1\n 57: new #30 // class java/io/File\n 60: dup\n 61: ldc #32 // String inputs/colorGame.txt\n 63: invokespecial #35 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 66: aconst_null\n 67: aload_1\n 68: aload_0\n 69: invokedynamic #110, 0 // InvokeDynamic #1:invoke:(Lkotlin/jvm/internal/Ref$IntRef;Ljava/util/Map;)Lkotlin/jvm/functions/Function1;\n 74: iconst_1\n 75: aconst_null\n 76: invokestatic #61 // Method kotlin/io/FilesKt.forEachLine$default:(Ljava/io/File;Ljava/nio/charset/Charset;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V\n 79: aload_1\n 80: getfield #65 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 83: istore_2\n 84: getstatic #71 // Field java/lang/System.out:Ljava/io/PrintStream;\n 87: iload_2\n 88: invokevirtual #77 // Method java/io/PrintStream.println:(I)V\n 91: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #115 // Method main:()V\n 3: return\n\n private static final kotlin.Unit problem2$lambda$4(java.util.List, kotlin.jvm.internal.Ref$IntRef, java.lang.String);\n Code:\n 0: aload_2\n 1: ldc #119 // String line\n 3: invokestatic #125 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: checkcast #127 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #16 // class java/lang/String\n 14: astore 4\n 16: aload 4\n 18: iconst_0\n 19: ldc #129 // String :\n 21: aastore\n 22: aload 4\n 24: iconst_0\n 25: iconst_0\n 26: bipush 6\n 28: aconst_null\n 29: invokestatic #135 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 32: astore_3\n 33: aload_0\n 34: checkcast #137 // class java/lang/Iterable\n 37: astore 5\n 39: iconst_0\n 40: istore 6\n 42: new #139 // class java/util/LinkedHashMap\n 45: dup\n 46: aload 5\n 48: bipush 10\n 50: invokestatic #143 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 53: invokestatic #147 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 56: bipush 16\n 58: invokestatic #153 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 61: invokespecial #155 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 64: astore 7\n 66: aload 5\n 68: astore 8\n 70: iconst_0\n 71: istore 9\n 73: aload 8\n 75: invokeinterface #159, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 80: astore 10\n 82: aload 10\n 84: invokeinterface #165, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 89: ifeq 143\n 92: aload 10\n 94: invokeinterface #169, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 99: astore 11\n 101: aload 7\n 103: checkcast #171 // class java/util/Map\n 106: aload 11\n 108: aload 11\n 110: checkcast #16 // class java/lang/String\n 113: astore 12\n 115: astore 24\n 117: astore 23\n 119: iconst_0\n 120: istore 13\n 122: iconst_0\n 123: invokestatic #90 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 126: astore 25\n 128: aload 23\n 130: aload 24\n 132: aload 25\n 134: invokeinterface #175, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 139: pop\n 140: goto 82\n 143: aload 7\n 145: checkcast #171 // class java/util/Map\n 148: nop\n 149: invokestatic #179 // Method kotlin/collections/MapsKt.toMutableMap:(Ljava/util/Map;)Ljava/util/Map;\n 152: astore 4\n 154: aload_3\n 155: iconst_1\n 156: invokeinterface #185, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 161: checkcast #127 // class java/lang/CharSequence\n 164: iconst_1\n 165: anewarray #16 // class java/lang/String\n 168: astore 5\n 170: aload 5\n 172: iconst_0\n 173: ldc #187 // String ;\n 175: aastore\n 176: aload 5\n 178: iconst_0\n 179: iconst_0\n 180: bipush 6\n 182: aconst_null\n 183: invokestatic #135 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 186: checkcast #137 // class java/lang/Iterable\n 189: astore 5\n 191: iconst_0\n 192: istore 6\n 194: aload 5\n 196: invokeinterface #159, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 201: astore 7\n 203: aload 7\n 205: invokeinterface #165, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 210: ifeq 470\n 213: aload 7\n 215: invokeinterface #169, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 220: astore 8\n 222: aload 8\n 224: checkcast #16 // class java/lang/String\n 227: astore 9\n 229: iconst_0\n 230: istore 10\n 232: aload 9\n 234: checkcast #127 // class java/lang/CharSequence\n 237: iconst_1\n 238: anewarray #16 // class java/lang/String\n 241: astore 11\n 243: aload 11\n 245: iconst_0\n 246: ldc #189 // String ,\n 248: aastore\n 249: aload 11\n 251: iconst_0\n 252: iconst_0\n 253: bipush 6\n 255: aconst_null\n 256: invokestatic #135 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 259: checkcast #137 // class java/lang/Iterable\n 262: astore 11\n 264: iconst_0\n 265: istore 12\n 267: aload 11\n 269: invokeinterface #159, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 274: astore 13\n 276: aload 13\n 278: invokeinterface #165, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 283: ifeq 464\n 286: aload 13\n 288: invokeinterface #169, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 293: astore 14\n 295: aload 14\n 297: checkcast #16 // class java/lang/String\n 300: astore 15\n 302: iconst_0\n 303: istore 16\n 305: aload 4\n 307: invokeinterface #193, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 312: invokeinterface #196, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 317: astore 17\n 319: aload 17\n 321: invokeinterface #165, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 326: ifeq 459\n 329: aload 17\n 331: invokeinterface #169, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 336: checkcast #198 // class java/util/Map$Entry\n 339: astore 18\n 341: aload 18\n 343: invokeinterface #201, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 348: checkcast #16 // class java/lang/String\n 351: astore 19\n 353: aload 18\n 355: invokeinterface #204, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 360: checkcast #206 // class java/lang/Number\n 363: invokevirtual #210 // Method java/lang/Number.intValue:()I\n 366: istore 20\n 368: aload 15\n 370: checkcast #127 // class java/lang/CharSequence\n 373: aload 19\n 375: checkcast #127 // class java/lang/CharSequence\n 378: iconst_0\n 379: iconst_2\n 380: aconst_null\n 381: invokestatic #214 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z\n 384: ifeq 319\n 387: new #216 // class kotlin/text/Regex\n 390: dup\n 391: ldc #218 // String \\\\d+\n 393: invokespecial #219 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 396: aload 15\n 398: checkcast #127 // class java/lang/CharSequence\n 401: iconst_0\n 402: iconst_2\n 403: aconst_null\n 404: invokestatic #223 // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;\n 407: dup\n 408: ifnull 426\n 411: invokeinterface #228, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 416: dup\n 417: ifnull 426\n 420: invokestatic #232 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 423: goto 428\n 426: pop\n 427: iconst_0\n 428: istore 21\n 430: iload 21\n 432: iload 20\n 434: if_icmple 319\n 437: iload 21\n 439: invokestatic #90 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 442: astore 22\n 444: aload 4\n 446: aload 19\n 448: aload 22\n 450: invokeinterface #175, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 455: pop\n 456: goto 319\n 459: nop\n 460: nop\n 461: goto 276\n 464: nop\n 465: nop\n 466: nop\n 467: goto 203\n 470: nop\n 471: aload_1\n 472: aload_1\n 473: getfield #65 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 476: aload 4\n 478: invokeinterface #236, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 483: checkcast #137 // class java/lang/Iterable\n 486: astore 5\n 488: istore 24\n 490: astore 23\n 492: iconst_0\n 493: istore 6\n 495: aload 5\n 497: invokeinterface #159, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 502: astore 7\n 504: aload 7\n 506: invokeinterface #165, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 511: ifne 524\n 514: new #238 // class java/lang/UnsupportedOperationException\n 517: dup\n 518: ldc #240 // String Empty collection can\\'t be reduced.\n 520: invokespecial #241 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 523: athrow\n 524: aload 7\n 526: invokeinterface #169, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 531: astore 8\n 533: aload 7\n 535: invokeinterface #165, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 540: ifeq 584\n 543: aload 8\n 545: aload 7\n 547: invokeinterface #169, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 552: checkcast #206 // class java/lang/Number\n 555: invokevirtual #210 // Method java/lang/Number.intValue:()I\n 558: istore 9\n 560: checkcast #206 // class java/lang/Number\n 563: invokevirtual #210 // Method java/lang/Number.intValue:()I\n 566: istore 10\n 568: iconst_0\n 569: istore 11\n 571: iload 10\n 573: iload 9\n 575: imul\n 576: invokestatic #90 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 579: astore 8\n 581: goto 533\n 584: aload 8\n 586: astore 25\n 588: aload 23\n 590: iload 24\n 592: aload 25\n 594: checkcast #206 // class java/lang/Number\n 597: invokevirtual #210 // Method java/lang/Number.intValue:()I\n 600: iadd\n 601: putfield #65 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 604: getstatic #247 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 607: areturn\n\n private static final kotlin.Unit problem1$lambda$7(kotlin.jvm.internal.Ref$IntRef, java.util.Map, java.lang.String);\n Code:\n 0: aload_2\n 1: ldc #119 // String line\n 3: invokestatic #125 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: checkcast #127 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #16 // class java/lang/String\n 14: astore 4\n 16: aload 4\n 18: iconst_0\n 19: ldc #129 // String :\n 21: aastore\n 22: aload 4\n 24: iconst_0\n 25: iconst_0\n 26: bipush 6\n 28: aconst_null\n 29: invokestatic #135 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 32: astore_3\n 33: nop\n 34: aload_3\n 35: iconst_0\n 36: invokeinterface #185, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 41: checkcast #16 // class java/lang/String\n 44: iconst_5\n 45: invokevirtual #285 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 48: dup\n 49: ldc_w #287 // String substring(...)\n 52: invokestatic #290 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 55: invokestatic #232 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 58: istore 4\n 60: aload_3\n 61: iconst_1\n 62: invokeinterface #185, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 67: checkcast #127 // class java/lang/CharSequence\n 70: iconst_1\n 71: anewarray #16 // class java/lang/String\n 74: astore 5\n 76: aload 5\n 78: iconst_0\n 79: ldc #187 // String ;\n 81: aastore\n 82: aload 5\n 84: iconst_0\n 85: iconst_0\n 86: bipush 6\n 88: aconst_null\n 89: invokestatic #135 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 92: checkcast #137 // class java/lang/Iterable\n 95: astore 5\n 97: iconst_0\n 98: istore 6\n 100: aload 5\n 102: invokeinterface #159, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 107: astore 7\n 109: aload 7\n 111: invokeinterface #165, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 116: ifeq 353\n 119: aload 7\n 121: invokeinterface #169, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 126: astore 8\n 128: aload 8\n 130: checkcast #16 // class java/lang/String\n 133: astore 9\n 135: iconst_0\n 136: istore 10\n 138: aload 9\n 140: checkcast #127 // class java/lang/CharSequence\n 143: iconst_1\n 144: anewarray #16 // class java/lang/String\n 147: astore 11\n 149: aload 11\n 151: iconst_0\n 152: ldc #189 // String ,\n 154: aastore\n 155: aload 11\n 157: iconst_0\n 158: iconst_0\n 159: bipush 6\n 161: aconst_null\n 162: invokestatic #135 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 165: checkcast #137 // class java/lang/Iterable\n 168: astore 11\n 170: iconst_0\n 171: istore 12\n 173: aload 11\n 175: invokeinterface #159, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 180: astore 13\n 182: aload 13\n 184: invokeinterface #165, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 189: ifeq 347\n 192: aload 13\n 194: invokeinterface #169, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 199: astore 14\n 201: aload 14\n 203: checkcast #16 // class java/lang/String\n 206: astore 15\n 208: iconst_0\n 209: istore 16\n 211: aload_1\n 212: invokeinterface #193, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 217: invokeinterface #196, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 222: astore 17\n 224: aload 17\n 226: invokeinterface #165, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 231: ifeq 342\n 234: aload 17\n 236: invokeinterface #169, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 241: checkcast #198 // class java/util/Map$Entry\n 244: astore 18\n 246: aload 18\n 248: invokeinterface #201, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 253: checkcast #16 // class java/lang/String\n 256: astore 19\n 258: aload 18\n 260: invokeinterface #204, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 265: checkcast #206 // class java/lang/Number\n 268: invokevirtual #210 // Method java/lang/Number.intValue:()I\n 271: istore 20\n 273: aload 15\n 275: checkcast #127 // class java/lang/CharSequence\n 278: aload 19\n 280: checkcast #127 // class java/lang/CharSequence\n 283: iconst_0\n 284: iconst_2\n 285: aconst_null\n 286: invokestatic #214 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z\n 289: ifeq 224\n 292: new #216 // class kotlin/text/Regex\n 295: dup\n 296: ldc #218 // String \\\\d+\n 298: invokespecial #219 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 301: aload 15\n 303: checkcast #127 // class java/lang/CharSequence\n 306: iconst_0\n 307: iconst_2\n 308: aconst_null\n 309: invokestatic #223 // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;\n 312: dup\n 313: ifnull 331\n 316: invokeinterface #228, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 321: dup\n 322: ifnull 331\n 325: invokestatic #232 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 328: goto 333\n 331: pop\n 332: iconst_0\n 333: iload 20\n 335: if_icmple 224\n 338: getstatic #247 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 341: areturn\n 342: nop\n 343: nop\n 344: goto 182\n 347: nop\n 348: nop\n 349: nop\n 350: goto 109\n 353: nop\n 354: aload_0\n 355: aload_0\n 356: getfield #65 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 359: iload 4\n 361: iadd\n 362: putfield #65 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 365: getstatic #247 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 368: areturn\n}\n",
"javap_err": ""
}
] |
aragos__aoc2023__7bca0a8/aoc/src/Scratch.kt
|
import java.io.File
import kotlin.math.pow
fun main() {
println(countPoints())
println(countCards())
}
private fun countCards(): Int {
val cardCount = (0..211).associateWith { 1 }.toMutableMap()
File("inputs/scratch.txt").readLines().mapIndexed() { ix, line ->
if (line.isBlank()) return@mapIndexed
val winningCount = countWinningNumbers(line)
val times = cardCount[ix]!!
for (j in (ix + 1)..ix + winningCount) {
cardCount[j] = cardCount[j]!! + times
}
}
return cardCount.values.sum()
}
private fun countPoints(): Int = File("inputs/scratch.txt").readLines().map { line ->
val winningCount = countWinningNumbers(line)
if (winningCount == 0) 0 else 2.0.pow(winningCount - 1).toInt()
}.sum()
private fun countWinningNumbers(line: String): Int {
val (winning, actual) = line.split(":")[1].split("|")
val winningNumbers = winning.toNumbers().toSet()
return actual.toNumbers().count { winningNumbers.contains(it) }
}
private fun String.toNumbers() = Regex("\\d+").findAll(this).map { it.value.toInt() }.toList()
|
[
{
"class_path": "aragos__aoc2023__7bca0a8/ScratchKt.class",
"javap": "Compiled from \"Scratch.kt\"\npublic final class ScratchKt {\n public static final void main();\n Code:\n 0: invokestatic #10 // Method countPoints:()I\n 3: istore_0\n 4: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 7: iload_0\n 8: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 11: invokestatic #25 // Method countCards:()I\n 14: istore_0\n 15: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 18: iload_0\n 19: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 22: return\n\n private static final int countCards();\n Code:\n 0: new #27 // class kotlin/ranges/IntRange\n 3: dup\n 4: iconst_0\n 5: sipush 211\n 8: invokespecial #31 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 11: checkcast #33 // class java/lang/Iterable\n 14: astore_1\n 15: iconst_0\n 16: istore_2\n 17: new #35 // class java/util/LinkedHashMap\n 20: dup\n 21: aload_1\n 22: bipush 10\n 24: invokestatic #41 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 27: invokestatic #47 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 30: bipush 16\n 32: invokestatic #53 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 35: invokespecial #55 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 38: astore_3\n 39: aload_1\n 40: astore 4\n 42: iconst_0\n 43: istore 5\n 45: aload 4\n 47: invokeinterface #59, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 52: astore 6\n 54: aload 6\n 56: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 61: ifeq 117\n 64: aload 6\n 66: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 71: astore 7\n 73: aload_3\n 74: checkcast #71 // class java/util/Map\n 77: aload 7\n 79: aload 7\n 81: checkcast #73 // class java/lang/Number\n 84: invokevirtual #76 // Method java/lang/Number.intValue:()I\n 87: istore 8\n 89: astore 19\n 91: astore 18\n 93: iconst_0\n 94: istore 9\n 96: iconst_1\n 97: invokestatic #82 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 100: astore 20\n 102: aload 18\n 104: aload 19\n 106: aload 20\n 108: invokeinterface #86, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 113: pop\n 114: goto 54\n 117: aload_3\n 118: checkcast #71 // class java/util/Map\n 121: nop\n 122: invokestatic #90 // Method kotlin/collections/MapsKt.toMutableMap:(Ljava/util/Map;)Ljava/util/Map;\n 125: astore_0\n 126: new #92 // class java/io/File\n 129: dup\n 130: ldc #94 // String inputs/scratch.txt\n 132: invokespecial #97 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 135: aconst_null\n 136: iconst_1\n 137: aconst_null\n 138: invokestatic #103 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 141: checkcast #33 // class java/lang/Iterable\n 144: astore_1\n 145: iconst_0\n 146: istore_2\n 147: aload_1\n 148: astore_3\n 149: new #105 // class java/util/ArrayList\n 152: dup\n 153: aload_1\n 154: bipush 10\n 156: invokestatic #41 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 159: invokespecial #106 // Method java/util/ArrayList.\"<init>\":(I)V\n 162: checkcast #108 // class java/util/Collection\n 165: astore 4\n 167: iconst_0\n 168: istore 5\n 170: iconst_0\n 171: istore 6\n 173: aload_3\n 174: invokeinterface #59, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 179: astore 7\n 181: aload 7\n 183: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 188: ifeq 365\n 191: aload 7\n 193: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 198: astore 8\n 200: aload 4\n 202: iload 6\n 204: iinc 6, 1\n 207: istore 9\n 209: iload 9\n 211: ifge 217\n 214: invokestatic #111 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 217: iload 9\n 219: aload 8\n 221: checkcast #113 // class java/lang/String\n 224: astore 10\n 226: istore 11\n 228: astore 18\n 230: iconst_0\n 231: istore 12\n 233: aload 10\n 235: checkcast #115 // class java/lang/CharSequence\n 238: invokestatic #121 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 241: ifne 351\n 244: aload 10\n 246: invokestatic #125 // Method countWinningNumbers:(Ljava/lang/String;)I\n 249: istore 13\n 251: aload_0\n 252: iload 11\n 254: invokestatic #82 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 257: invokeinterface #129, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 262: dup\n 263: invokestatic #135 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 266: checkcast #73 // class java/lang/Number\n 269: invokevirtual #76 // Method java/lang/Number.intValue:()I\n 272: istore 14\n 274: iload 11\n 276: iconst_1\n 277: iadd\n 278: istore 15\n 280: iload 11\n 282: iload 13\n 284: iadd\n 285: istore 16\n 287: iload 15\n 289: iload 16\n 291: if_icmpgt 350\n 294: iload 15\n 296: invokestatic #82 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 299: astore 17\n 301: aload_0\n 302: aload 17\n 304: aload_0\n 305: iload 15\n 307: invokestatic #82 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 310: invokeinterface #129, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 315: dup\n 316: invokestatic #135 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 319: checkcast #73 // class java/lang/Number\n 322: invokevirtual #76 // Method java/lang/Number.intValue:()I\n 325: iload 14\n 327: iadd\n 328: invokestatic #82 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 331: invokeinterface #86, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 336: pop\n 337: iload 15\n 339: iload 16\n 341: if_icmpeq 350\n 344: iinc 15, 1\n 347: goto 294\n 350: nop\n 351: aload 18\n 353: getstatic #141 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 356: invokeinterface #145, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 361: pop\n 362: goto 181\n 365: aload 4\n 367: checkcast #147 // class java/util/List\n 370: nop\n 371: pop\n 372: aload_0\n 373: invokeinterface #151, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 378: checkcast #33 // class java/lang/Iterable\n 381: invokestatic #155 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 384: ireturn\n\n private static final int countPoints();\n Code:\n 0: new #92 // class java/io/File\n 3: dup\n 4: ldc #94 // String inputs/scratch.txt\n 6: invokespecial #97 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: aconst_null\n 10: iconst_1\n 11: aconst_null\n 12: invokestatic #103 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 15: checkcast #33 // class java/lang/Iterable\n 18: astore_0\n 19: iconst_0\n 20: istore_1\n 21: aload_0\n 22: astore_2\n 23: new #105 // class java/util/ArrayList\n 26: dup\n 27: aload_0\n 28: bipush 10\n 30: invokestatic #41 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 33: invokespecial #106 // Method java/util/ArrayList.\"<init>\":(I)V\n 36: checkcast #108 // class java/util/Collection\n 39: astore_3\n 40: iconst_0\n 41: istore 4\n 43: aload_2\n 44: invokeinterface #59, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 49: astore 5\n 51: aload 5\n 53: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 58: ifeq 126\n 61: aload 5\n 63: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 68: astore 6\n 70: aload_3\n 71: aload 6\n 73: checkcast #113 // class java/lang/String\n 76: astore 7\n 78: astore 10\n 80: iconst_0\n 81: istore 8\n 83: aload 7\n 85: invokestatic #125 // Method countWinningNumbers:(Ljava/lang/String;)I\n 88: istore 9\n 90: iload 9\n 92: ifne 99\n 95: iconst_0\n 96: goto 111\n 99: ldc2_w #185 // double 2.0d\n 102: iload 9\n 104: iconst_1\n 105: isub\n 106: i2d\n 107: invokestatic #192 // Method java/lang/Math.pow:(DD)D\n 110: d2i\n 111: invokestatic #82 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 114: aload 10\n 116: swap\n 117: invokeinterface #145, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 122: pop\n 123: goto 51\n 126: aload_3\n 127: checkcast #147 // class java/util/List\n 130: nop\n 131: checkcast #33 // class java/lang/Iterable\n 134: invokestatic #155 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 137: ireturn\n\n private static final int countWinningNumbers(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #115 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #113 // class java/lang/String\n 8: astore_2\n 9: aload_2\n 10: iconst_0\n 11: ldc #199 // String :\n 13: aastore\n 14: aload_2\n 15: iconst_0\n 16: iconst_0\n 17: bipush 6\n 19: aconst_null\n 20: invokestatic #203 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 23: iconst_1\n 24: invokeinterface #206, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 29: checkcast #115 // class java/lang/CharSequence\n 32: iconst_1\n 33: anewarray #113 // class java/lang/String\n 36: astore_2\n 37: aload_2\n 38: iconst_0\n 39: ldc #208 // String |\n 41: aastore\n 42: aload_2\n 43: iconst_0\n 44: iconst_0\n 45: bipush 6\n 47: aconst_null\n 48: invokestatic #203 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 51: astore_1\n 52: aload_1\n 53: iconst_0\n 54: invokeinterface #206, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 59: checkcast #113 // class java/lang/String\n 62: astore_2\n 63: aload_1\n 64: iconst_1\n 65: invokeinterface #206, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 70: checkcast #113 // class java/lang/String\n 73: astore_3\n 74: aload_2\n 75: invokestatic #212 // Method toNumbers:(Ljava/lang/String;)Ljava/util/List;\n 78: checkcast #33 // class java/lang/Iterable\n 81: invokestatic #216 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 84: astore 4\n 86: aload_3\n 87: invokestatic #212 // Method toNumbers:(Ljava/lang/String;)Ljava/util/List;\n 90: checkcast #33 // class java/lang/Iterable\n 93: astore 5\n 95: iconst_0\n 96: istore 6\n 98: aload 5\n 100: instanceof #108 // class java/util/Collection\n 103: ifeq 123\n 106: aload 5\n 108: checkcast #108 // class java/util/Collection\n 111: invokeinterface #219, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 116: ifeq 123\n 119: iconst_0\n 120: goto 198\n 123: iconst_0\n 124: istore 7\n 126: aload 5\n 128: invokeinterface #59, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 133: astore 8\n 135: aload 8\n 137: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 142: ifeq 196\n 145: aload 8\n 147: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 152: astore 9\n 154: aload 9\n 156: checkcast #73 // class java/lang/Number\n 159: invokevirtual #76 // Method java/lang/Number.intValue:()I\n 162: istore 10\n 164: iconst_0\n 165: istore 11\n 167: aload 4\n 169: iload 10\n 171: invokestatic #82 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 174: invokeinterface #224, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 179: ifeq 135\n 182: iinc 7, 1\n 185: iload 7\n 187: ifge 135\n 190: invokestatic #227 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 193: goto 135\n 196: iload 7\n 198: ireturn\n\n private static final java.util.List<java.lang.Integer> toNumbers(java.lang.String);\n Code:\n 0: new #239 // class kotlin/text/Regex\n 3: dup\n 4: ldc #241 // String \\\\d+\n 6: invokespecial #242 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 9: aload_0\n 10: checkcast #115 // class java/lang/CharSequence\n 13: iconst_0\n 14: iconst_2\n 15: aconst_null\n 16: invokestatic #246 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 19: invokedynamic #265, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 24: invokestatic #271 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 27: invokestatic #275 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 30: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #279 // Method main:()V\n 3: return\n\n private static final int toNumbers$lambda$4(kotlin.text.MatchResult);\n Code:\n 0: aload_0\n 1: ldc_w #282 // String it\n 4: invokestatic #286 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokeinterface #292, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 13: invokestatic #295 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 16: ireturn\n}\n",
"javap_err": ""
}
] |
shyoutarou__desafios-DIO__b312f8f/Desafios/Kotlin/Primeiros passos em Kotlin/Carrefour Android Developer/Figurinhas/figurinhas.kt
|
/*
Ricardo e Vicente são aficionados por figurinhas. Nas horas vagas, eles arrumam um jeito de jogar um “bafo” ou algum outro jogo que envolva tais figurinhas. Ambos também têm o hábito de trocarem as figuras repetidas com seus amigos e certo dia pensaram em uma brincadeira diferente. Chamaram todos os amigos e propuseram o seguinte: com as figurinhas em mãos, cada um tentava fazer uma troca com o amigo que estava mais perto seguindo a seguinte regra: cada um contava quantas figurinhas tinha. Em seguida, eles tinham que dividir as figurinhas de cada um em pilhas do mesmo tamanho, no maior tamanho que fosse possível para ambos. Então, cada um escolhia uma das pilhas de figurinhas do amigo para receber. Por exemplo, se Ricardo e Vicente fossem trocar as figurinhas e tivessem respectivamente 8 e 12 figuras, ambos dividiam todas as suas figuras em pilhas de 4 figuras (Ricardo teria 2 pilhas e Vicente teria 3 pilhas) e ambos escolhiam uma pilha do amigo para receber.
Entrada
A primeira linha da entrada contém um único inteiro N (1 ≤ N ≤ 3000), indicando o número de casos de teste. Cada caso de teste contém 2 inteiros F1 (1 ≤ F1 ≤ 1000) e F2 (1 ≤ F2 ≤ 1000) indicando, respectivamente, a quantidade de figurinhas que Ricardo e Vicente têm para trocar.
Saída
Para cada caso de teste de entrada haverá um valor na saída, representando o tamanho máximo da pilha de figurinhas que poderia ser trocada entre dois jogadores.
*/
fun main(args: Array<String>)
{
val lista = mutableListOf<Int>()
for (i in 1..readLine()!!.toInt()) {
val input = readLine()!!.split(" ").map { it.toInt() }
input.forEach { number ->
lista.add(number)
}
println(mdc(lista[0], lista[1]))
lista.clear()
}
}
fun mdc(n1: Int, n2: Int): Int
{
return if (n2 == 0) {
n1
} else {
mdc(n2, (n1 % n2))
}
}
|
[
{
"class_path": "shyoutarou__desafios-DIO__b312f8f/FigurinhasKt.class",
"javap": "Compiled from \"figurinhas.kt\"\npublic final class FigurinhasKt {\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: new #17 // class java/util/ArrayList\n 9: dup\n 10: invokespecial #21 // Method java/util/ArrayList.\"<init>\":()V\n 13: checkcast #23 // class java/util/List\n 16: astore_1\n 17: iconst_1\n 18: istore_2\n 19: invokestatic #29 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 22: dup\n 23: invokestatic #33 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 26: invokestatic #39 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 29: istore_3\n 30: iload_2\n 31: iload_3\n 32: if_icmpgt 297\n 35: invokestatic #29 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 38: dup\n 39: invokestatic #33 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 42: checkcast #41 // class java/lang/CharSequence\n 45: iconst_1\n 46: anewarray #43 // class java/lang/String\n 49: astore 5\n 51: aload 5\n 53: iconst_0\n 54: ldc #45 // String\n 56: aastore\n 57: aload 5\n 59: iconst_0\n 60: iconst_0\n 61: bipush 6\n 63: aconst_null\n 64: invokestatic #51 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 67: checkcast #53 // class java/lang/Iterable\n 70: astore 5\n 72: iconst_0\n 73: istore 6\n 75: aload 5\n 77: astore 7\n 79: new #17 // class java/util/ArrayList\n 82: dup\n 83: aload 5\n 85: bipush 10\n 87: invokestatic #59 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 90: invokespecial #62 // Method java/util/ArrayList.\"<init>\":(I)V\n 93: checkcast #64 // class java/util/Collection\n 96: astore 8\n 98: iconst_0\n 99: istore 9\n 101: aload 7\n 103: invokeinterface #68, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 108: astore 10\n 110: aload 10\n 112: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 117: ifeq 164\n 120: aload 10\n 122: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 127: astore 11\n 129: aload 8\n 131: aload 11\n 133: checkcast #43 // class java/lang/String\n 136: astore 12\n 138: astore 14\n 140: iconst_0\n 141: istore 13\n 143: aload 12\n 145: invokestatic #39 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 148: nop\n 149: invokestatic #82 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 152: aload 14\n 154: swap\n 155: invokeinterface #86, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 160: pop\n 161: goto 110\n 164: aload 8\n 166: checkcast #23 // class java/util/List\n 169: nop\n 170: astore 4\n 172: aload 4\n 174: checkcast #53 // class java/lang/Iterable\n 177: astore 5\n 179: iconst_0\n 180: istore 6\n 182: aload 5\n 184: invokeinterface #68, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 189: astore 7\n 191: aload 7\n 193: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 198: ifeq 240\n 201: aload 7\n 203: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 208: astore 8\n 210: aload 8\n 212: checkcast #88 // class java/lang/Number\n 215: invokevirtual #92 // Method java/lang/Number.intValue:()I\n 218: istore 9\n 220: iconst_0\n 221: istore 10\n 223: aload_1\n 224: iload 9\n 226: invokestatic #82 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 229: invokeinterface #93, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 234: pop\n 235: nop\n 236: nop\n 237: goto 191\n 240: nop\n 241: aload_1\n 242: iconst_0\n 243: invokeinterface #97, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 248: checkcast #88 // class java/lang/Number\n 251: invokevirtual #92 // Method java/lang/Number.intValue:()I\n 254: aload_1\n 255: iconst_1\n 256: invokeinterface #97, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 261: checkcast #88 // class java/lang/Number\n 264: invokevirtual #92 // Method java/lang/Number.intValue:()I\n 267: invokestatic #101 // Method mdc:(II)I\n 270: istore 5\n 272: getstatic #107 // Field java/lang/System.out:Ljava/io/PrintStream;\n 275: iload 5\n 277: invokevirtual #112 // Method java/io/PrintStream.println:(I)V\n 280: aload_1\n 281: invokeinterface #115, 1 // InterfaceMethod java/util/List.clear:()V\n 286: iload_2\n 287: iload_3\n 288: if_icmpeq 297\n 291: iinc 2, 1\n 294: goto 35\n 297: return\n\n public static final int mdc(int, int);\n Code:\n 0: iload_1\n 1: ifne 8\n 4: iload_0\n 5: goto 15\n 8: iload_1\n 9: iload_0\n 10: iload_1\n 11: irem\n 12: invokestatic #101 // Method mdc:(II)I\n 15: ireturn\n}\n",
"javap_err": ""
}
] |
LaraEstudillo__coins_challenge_1__b710f68/coins.kt
|
import kotlin.collections.listOf
var amount = 11
var result: ArrayList<CoinsAndQuantity> = ArrayList()
fun main() {
println(minCoins())
}
fun minCoins() {
val coins = listOf(1,2,5).sorted()
val suma = coins.sum();
if(suma == amount) {
println(suma);
return;
}
calculation(coins.size, coins)
println(result)
println(sumItems())
if(sumItems() != amount) println(-1)
else println(result)
}
private fun sumItems(): Int {
var data = 0
result.forEach { item ->
data += item.coin * item.quantity
}
return data
}
private fun calculation(index: Int, coins: List<Int>) {
if(index > 0) {
val divisor = (amount / coins[index-1]).toInt()
val restante = (amount % coins[index-1]).toInt()
amount = restante
divisor.takeIf { it > 0 }?.also {
result.add(CoinsAndQuantity(coins[index-1], divisor))
}
calculation(index - 1, coins)
}
}
data class CoinsAndQuantity (
var coin: Int = 0,
var quantity: Int = 0
)
|
[
{
"class_path": "LaraEstudillo__coins_challenge_1__b710f68/CoinsKt.class",
"javap": "Compiled from \"coins.kt\"\npublic final class CoinsKt {\n private static int amount;\n\n private static java.util.ArrayList<CoinsAndQuantity> result;\n\n public static final int getAmount();\n Code:\n 0: getstatic #10 // Field amount:I\n 3: ireturn\n\n public static final void setAmount(int);\n Code:\n 0: iload_0\n 1: putstatic #10 // Field amount:I\n 4: return\n\n public static final java.util.ArrayList<CoinsAndQuantity> getResult();\n Code:\n 0: getstatic #21 // Field result:Ljava/util/ArrayList;\n 3: areturn\n\n public static final void setResult(java.util.ArrayList<CoinsAndQuantity>);\n Code:\n 0: aload_0\n 1: ldc #25 // String <set-?>\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: putstatic #21 // Field result:Ljava/util/ArrayList;\n 10: return\n\n public static final void main();\n Code:\n 0: invokestatic #36 // Method minCoins:()V\n 3: getstatic #42 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 6: getstatic #48 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: swap\n 10: invokevirtual #54 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 13: return\n\n public static final void minCoins();\n Code:\n 0: iconst_3\n 1: anewarray #56 // class java/lang/Integer\n 4: astore_1\n 5: aload_1\n 6: iconst_0\n 7: iconst_1\n 8: invokestatic #60 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 11: aastore\n 12: aload_1\n 13: iconst_1\n 14: iconst_2\n 15: invokestatic #60 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 18: aastore\n 19: aload_1\n 20: iconst_2\n 21: iconst_5\n 22: invokestatic #60 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 25: aastore\n 26: aload_1\n 27: invokestatic #66 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 30: checkcast #68 // class java/lang/Iterable\n 33: invokestatic #72 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;\n 36: astore_0\n 37: aload_0\n 38: checkcast #68 // class java/lang/Iterable\n 41: invokestatic #76 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 44: istore_1\n 45: iload_1\n 46: getstatic #10 // Field amount:I\n 49: if_icmpne 60\n 52: getstatic #48 // Field java/lang/System.out:Ljava/io/PrintStream;\n 55: iload_1\n 56: invokevirtual #78 // Method java/io/PrintStream.println:(I)V\n 59: return\n 60: aload_0\n 61: invokeinterface #83, 1 // InterfaceMethod java/util/List.size:()I\n 66: aload_0\n 67: invokestatic #87 // Method calculation:(ILjava/util/List;)V\n 70: getstatic #21 // Field result:Ljava/util/ArrayList;\n 73: getstatic #48 // Field java/lang/System.out:Ljava/io/PrintStream;\n 76: swap\n 77: invokevirtual #54 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 80: invokestatic #90 // Method sumItems:()I\n 83: istore_2\n 84: getstatic #48 // Field java/lang/System.out:Ljava/io/PrintStream;\n 87: iload_2\n 88: invokevirtual #78 // Method java/io/PrintStream.println:(I)V\n 91: invokestatic #90 // Method sumItems:()I\n 94: getstatic #10 // Field amount:I\n 97: if_icmpeq 112\n 100: iconst_m1\n 101: istore_2\n 102: getstatic #48 // Field java/lang/System.out:Ljava/io/PrintStream;\n 105: iload_2\n 106: invokevirtual #78 // Method java/io/PrintStream.println:(I)V\n 109: goto 122\n 112: getstatic #21 // Field result:Ljava/util/ArrayList;\n 115: getstatic #48 // Field java/lang/System.out:Ljava/io/PrintStream;\n 118: swap\n 119: invokevirtual #54 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 122: return\n\n private static final int sumItems();\n Code:\n 0: iconst_0\n 1: istore_0\n 2: getstatic #21 // Field result:Ljava/util/ArrayList;\n 5: checkcast #68 // class java/lang/Iterable\n 8: astore_1\n 9: iconst_0\n 10: istore_2\n 11: aload_1\n 12: invokeinterface #97, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 17: astore_3\n 18: aload_3\n 19: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 24: ifeq 64\n 27: aload_3\n 28: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 33: astore 4\n 35: aload 4\n 37: checkcast #109 // class CoinsAndQuantity\n 40: astore 5\n 42: iconst_0\n 43: istore 6\n 45: iload_0\n 46: aload 5\n 48: invokevirtual #112 // Method CoinsAndQuantity.getCoin:()I\n 51: aload 5\n 53: invokevirtual #115 // Method CoinsAndQuantity.getQuantity:()I\n 56: imul\n 57: iadd\n 58: istore_0\n 59: nop\n 60: nop\n 61: goto 18\n 64: nop\n 65: iload_0\n 66: ireturn\n\n private static final void calculation(int, java.util.List<java.lang.Integer>);\n Code:\n 0: iload_0\n 1: ifle 148\n 4: getstatic #10 // Field amount:I\n 7: aload_1\n 8: iload_0\n 9: iconst_1\n 10: isub\n 11: invokeinterface #129, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 16: checkcast #131 // class java/lang/Number\n 19: invokevirtual #134 // Method java/lang/Number.intValue:()I\n 22: idiv\n 23: istore_2\n 24: getstatic #10 // Field amount:I\n 27: aload_1\n 28: iload_0\n 29: iconst_1\n 30: isub\n 31: invokeinterface #129, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 36: checkcast #131 // class java/lang/Number\n 39: invokevirtual #134 // Method java/lang/Number.intValue:()I\n 42: irem\n 43: istore_3\n 44: iload_3\n 45: putstatic #10 // Field amount:I\n 48: iload_2\n 49: invokestatic #60 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 52: astore 4\n 54: aload 4\n 56: checkcast #131 // class java/lang/Number\n 59: invokevirtual #134 // Method java/lang/Number.intValue:()I\n 62: istore 5\n 64: iconst_0\n 65: istore 6\n 67: iload 5\n 69: ifle 76\n 72: iconst_1\n 73: goto 77\n 76: iconst_0\n 77: ifeq 85\n 80: aload 4\n 82: goto 86\n 85: aconst_null\n 86: dup\n 87: ifnull 139\n 90: astore 4\n 92: aload 4\n 94: checkcast #131 // class java/lang/Number\n 97: invokevirtual #134 // Method java/lang/Number.intValue:()I\n 100: istore 5\n 102: iconst_0\n 103: istore 6\n 105: getstatic #21 // Field result:Ljava/util/ArrayList;\n 108: new #109 // class CoinsAndQuantity\n 111: dup\n 112: aload_1\n 113: iload_0\n 114: iconst_1\n 115: isub\n 116: invokeinterface #129, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 121: checkcast #131 // class java/lang/Number\n 124: invokevirtual #134 // Method java/lang/Number.intValue:()I\n 127: iload_2\n 128: invokespecial #138 // Method CoinsAndQuantity.\"<init>\":(II)V\n 131: invokevirtual #144 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 134: pop\n 135: nop\n 136: goto 141\n 139: pop\n 140: nop\n 141: iload_0\n 142: iconst_1\n 143: isub\n 144: aload_1\n 145: invokestatic #87 // Method calculation:(ILjava/util/List;)V\n 148: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #153 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: bipush 11\n 2: putstatic #10 // Field amount:I\n 5: new #140 // class java/util/ArrayList\n 8: dup\n 9: invokespecial #158 // Method java/util/ArrayList.\"<init>\":()V\n 12: putstatic #21 // Field result:Ljava/util/ArrayList;\n 15: return\n}\n",
"javap_err": ""
}
] |
GreyWolf2020__aoc-2022-in-kotlin__498da88/src/Day04.kt
|
fun main() {
fun part1(input: List<String>): Int = input
.contains(::fullyContains)
fun part2(input: List<String>): Int = input
.contains(::partiallyContains)
// test if implementation meets criteria from the description, like:
// val testInput = readInput("Day04_test")
// check(part1(testInput) == 2)
//
// check(part2(testInput) == 4)
//
// val input = readInput("Day04")
// println(part1(input))
// println(part2(input))
}
fun List<String>.contains(fullyOrPartialContains: (List<Int>, List<Int>) -> Boolean) = map {
it
.split(",")
}
.foldRight(0) { cleaningAreas, containedAreas ->
val (cleaningAreaOne, cleaningAreaTwo) = cleaningAreas
.map { cleaningArea ->
cleaningArea
.split("-")
.map { it.toInt() }
}
containedAreas + if (fullyOrPartialContains(cleaningAreaOne, cleaningAreaTwo))
1
else 0
}
fun fullyContains(areaOne: List<Int>, areaTwo: List<Int>): Boolean = when {
areaOne.first() >= areaTwo.first() && areaOne.last() <= areaTwo.last() || areaTwo.first() >= areaOne.first() && areaTwo.last() <= areaOne.last() -> true
else -> false
}
fun partiallyContains(areaOne: List<Int>, areaTwo: List<Int>): Boolean = (areaOne.first() .. areaOne.last()).toSet().intersect((areaTwo.first() .. areaTwo.last()).toSet()).size >= 1
|
[
{
"class_path": "GreyWolf2020__aoc-2022-in-kotlin__498da88/Day04Kt.class",
"javap": "Compiled from \"Day04.kt\"\npublic final class Day04Kt {\n public static final void main();\n Code:\n 0: return\n\n public static final int contains(java.util.List<java.lang.String>, kotlin.jvm.functions.Function2<? super java.util.List<java.lang.Integer>, ? super java.util.List<java.lang.Integer>, java.lang.Boolean>);\n Code:\n 0: aload_0\n 1: ldc #12 // String <this>\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #20 // String fullyOrPartialContains\n 9: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: checkcast #22 // 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 #24 // class java/util/ArrayList\n 25: dup\n 26: aload_2\n 27: bipush 10\n 29: invokestatic #30 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 32: invokespecial #34 // Method java/util/ArrayList.\"<init>\":(I)V\n 35: checkcast #36 // class java/util/Collection\n 38: astore 5\n 40: iconst_0\n 41: istore 6\n 43: aload 4\n 45: invokeinterface #40, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 50: astore 7\n 52: aload 7\n 54: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 124\n 62: aload 7\n 64: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 69: astore 8\n 71: aload 5\n 73: aload 8\n 75: checkcast #52 // class java/lang/String\n 78: astore 9\n 80: astore 31\n 82: iconst_0\n 83: istore 10\n 85: aload 9\n 87: checkcast #54 // class java/lang/CharSequence\n 90: iconst_1\n 91: anewarray #52 // class java/lang/String\n 94: astore 11\n 96: aload 11\n 98: iconst_0\n 99: ldc #56 // 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 #62 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 112: aload 31\n 114: swap\n 115: invokeinterface #66, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 120: pop\n 121: goto 52\n 124: aload 5\n 126: checkcast #68 // class java/util/List\n 129: nop\n 130: astore_2\n 131: iconst_0\n 132: istore_3\n 133: iconst_0\n 134: istore 4\n 136: iload_3\n 137: istore 5\n 139: aload_2\n 140: invokeinterface #71, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 145: ifne 481\n 148: aload_2\n 149: aload_2\n 150: invokeinterface #75, 1 // InterfaceMethod java/util/List.size:()I\n 155: invokeinterface #79, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 160: astore 6\n 162: aload 6\n 164: invokeinterface #84, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 169: ifeq 481\n 172: aload 6\n 174: invokeinterface #87, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 179: iload 5\n 181: istore 7\n 183: checkcast #68 // class java/util/List\n 186: astore 8\n 188: iconst_0\n 189: istore 9\n 191: aload 8\n 193: checkcast #22 // class java/lang/Iterable\n 196: astore 10\n 198: nop\n 199: iconst_0\n 200: istore 11\n 202: aload 10\n 204: astore 12\n 206: new #24 // class java/util/ArrayList\n 209: dup\n 210: aload 10\n 212: bipush 10\n 214: invokestatic #30 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 217: invokespecial #34 // Method java/util/ArrayList.\"<init>\":(I)V\n 220: checkcast #36 // class java/util/Collection\n 223: astore 13\n 225: iconst_0\n 226: istore 14\n 228: aload 12\n 230: invokeinterface #40, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 235: astore 15\n 237: aload 15\n 239: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 244: ifeq 414\n 247: aload 15\n 249: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 254: astore 16\n 256: aload 13\n 258: aload 16\n 260: checkcast #52 // class java/lang/String\n 263: astore 17\n 265: astore 18\n 267: iconst_0\n 268: istore 19\n 270: aload 17\n 272: checkcast #54 // class java/lang/CharSequence\n 275: iconst_1\n 276: anewarray #52 // class java/lang/String\n 279: astore 20\n 281: aload 20\n 283: iconst_0\n 284: ldc #89 // String -\n 286: aastore\n 287: aload 20\n 289: iconst_0\n 290: iconst_0\n 291: bipush 6\n 293: aconst_null\n 294: invokestatic #62 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 297: checkcast #22 // class java/lang/Iterable\n 300: astore 20\n 302: nop\n 303: iconst_0\n 304: istore 21\n 306: aload 20\n 308: astore 22\n 310: new #24 // class java/util/ArrayList\n 313: dup\n 314: aload 20\n 316: bipush 10\n 318: invokestatic #30 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 321: invokespecial #34 // Method java/util/ArrayList.\"<init>\":(I)V\n 324: checkcast #36 // class java/util/Collection\n 327: astore 23\n 329: iconst_0\n 330: istore 24\n 332: aload 22\n 334: invokeinterface #40, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 339: astore 25\n 341: aload 25\n 343: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 348: ifeq 395\n 351: aload 25\n 353: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 358: astore 26\n 360: aload 23\n 362: aload 26\n 364: checkcast #52 // class java/lang/String\n 367: astore 27\n 369: astore 28\n 371: iconst_0\n 372: istore 29\n 374: aload 27\n 376: invokestatic #95 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 379: nop\n 380: invokestatic #99 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 383: aload 28\n 385: swap\n 386: invokeinterface #66, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 391: pop\n 392: goto 341\n 395: aload 23\n 397: checkcast #68 // class java/util/List\n 400: nop\n 401: nop\n 402: aload 18\n 404: swap\n 405: invokeinterface #66, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 410: pop\n 411: goto 237\n 414: aload 13\n 416: checkcast #68 // class java/util/List\n 419: nop\n 420: astore 30\n 422: aload 30\n 424: iconst_0\n 425: invokeinterface #103, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 430: checkcast #68 // class java/util/List\n 433: astore 10\n 435: aload 30\n 437: iconst_1\n 438: invokeinterface #103, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 443: checkcast #68 // class java/util/List\n 446: astore 11\n 448: iload 7\n 450: aload_1\n 451: aload 10\n 453: aload 11\n 455: invokeinterface #109, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 460: checkcast #111 // class java/lang/Boolean\n 463: invokevirtual #114 // Method java/lang/Boolean.booleanValue:()Z\n 466: ifeq 473\n 469: iconst_1\n 470: goto 474\n 473: iconst_0\n 474: iadd\n 475: nop\n 476: istore 5\n 478: goto 162\n 481: iload 5\n 483: ireturn\n\n public static final boolean fullyContains(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #149 // String areaOne\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #151 // String areaTwo\n 9: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: nop\n 13: aload_0\n 14: invokestatic #155 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 17: checkcast #157 // class java/lang/Number\n 20: invokevirtual #160 // Method java/lang/Number.intValue:()I\n 23: aload_1\n 24: invokestatic #155 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 27: checkcast #157 // class java/lang/Number\n 30: invokevirtual #160 // Method java/lang/Number.intValue:()I\n 33: if_icmplt 59\n 36: aload_0\n 37: invokestatic #163 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 40: checkcast #157 // class java/lang/Number\n 43: invokevirtual #160 // Method java/lang/Number.intValue:()I\n 46: aload_1\n 47: invokestatic #163 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 50: checkcast #157 // class java/lang/Number\n 53: invokevirtual #160 // Method java/lang/Number.intValue:()I\n 56: if_icmple 105\n 59: aload_1\n 60: invokestatic #155 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 63: checkcast #157 // class java/lang/Number\n 66: invokevirtual #160 // Method java/lang/Number.intValue:()I\n 69: aload_0\n 70: invokestatic #155 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 73: checkcast #157 // class java/lang/Number\n 76: invokevirtual #160 // Method java/lang/Number.intValue:()I\n 79: if_icmplt 109\n 82: aload_1\n 83: invokestatic #163 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 86: checkcast #157 // class java/lang/Number\n 89: invokevirtual #160 // Method java/lang/Number.intValue:()I\n 92: aload_0\n 93: invokestatic #163 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 96: checkcast #157 // class java/lang/Number\n 99: invokevirtual #160 // Method java/lang/Number.intValue:()I\n 102: if_icmpgt 109\n 105: iconst_1\n 106: goto 110\n 109: iconst_0\n 110: ireturn\n\n public static final boolean partiallyContains(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #149 // String areaOne\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #151 // String areaTwo\n 9: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #166 // class kotlin/ranges/IntRange\n 15: dup\n 16: aload_0\n 17: invokestatic #155 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 20: checkcast #157 // class java/lang/Number\n 23: invokevirtual #160 // Method java/lang/Number.intValue:()I\n 26: aload_0\n 27: invokestatic #163 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 30: checkcast #157 // class java/lang/Number\n 33: invokevirtual #160 // Method java/lang/Number.intValue:()I\n 36: invokespecial #169 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 39: checkcast #22 // class java/lang/Iterable\n 42: invokestatic #173 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 45: checkcast #22 // class java/lang/Iterable\n 48: new #166 // class kotlin/ranges/IntRange\n 51: dup\n 52: aload_1\n 53: invokestatic #155 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 56: checkcast #157 // class java/lang/Number\n 59: invokevirtual #160 // Method java/lang/Number.intValue:()I\n 62: aload_1\n 63: invokestatic #163 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 66: checkcast #157 // class java/lang/Number\n 69: invokevirtual #160 // Method java/lang/Number.intValue:()I\n 72: invokespecial #169 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 75: checkcast #22 // class java/lang/Iterable\n 78: invokestatic #173 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 81: checkcast #22 // class java/lang/Iterable\n 84: invokestatic #177 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 87: invokeinterface #180, 1 // InterfaceMethod java/util/Set.size:()I\n 92: iconst_1\n 93: if_icmplt 100\n 96: iconst_1\n 97: goto 101\n 100: iconst_0\n 101: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #183 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: getstatic #194 // Field Day04Kt$main$part1$1.INSTANCE:LDay04Kt$main$part1$1;\n 4: checkcast #105 // class kotlin/jvm/functions/Function2\n 7: invokestatic #196 // Method contains:(Ljava/util/List;Lkotlin/jvm/functions/Function2;)I\n 10: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: getstatic #203 // Field Day04Kt$main$part2$1.INSTANCE:LDay04Kt$main$part2$1;\n 4: checkcast #105 // class kotlin/jvm/functions/Function2\n 7: invokestatic #196 // Method contains:(Ljava/util/List;Lkotlin/jvm/functions/Function2;)I\n 10: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "GreyWolf2020__aoc-2022-in-kotlin__498da88/Day04Kt$main$part2$1.class",
"javap": "Compiled from \"Day04.kt\"\nfinal class Day04Kt$main$part2$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<java.util.List<? extends java.lang.Integer>, java.util.List<? extends java.lang.Integer>, java.lang.Boolean> {\n public static final Day04Kt$main$part2$1 INSTANCE;\n\n Day04Kt$main$part2$1();\n Code:\n 0: aload_0\n 1: iconst_2\n 2: ldc #11 // class Day04Kt\n 4: ldc #13 // String partiallyContains\n 6: ldc #15 // String partiallyContains(Ljava/util/List;Ljava/util/List;)Z\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final java.lang.Boolean invoke(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>);\n Code:\n 0: aload_1\n 1: ldc #25 // String p0\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #33 // String p1\n 9: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: aload_2\n 14: invokestatic #36 // Method Day04Kt.partiallyContains:(Ljava/util/List;Ljava/util/List;)Z\n 17: invokestatic #42 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 20: areturn\n\n public java.lang.Object invoke(java.lang.Object, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #46 // class java/util/List\n 5: aload_2\n 6: checkcast #46 // class java/util/List\n 9: invokevirtual #48 // Method invoke:(Ljava/util/List;Ljava/util/List;)Ljava/lang/Boolean;\n 12: areturn\n\n static {};\n Code:\n 0: new #2 // class Day04Kt$main$part2$1\n 3: dup\n 4: invokespecial #53 // Method \"<init>\":()V\n 7: putstatic #56 // Field INSTANCE:LDay04Kt$main$part2$1;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "GreyWolf2020__aoc-2022-in-kotlin__498da88/Day04Kt$main$part1$1.class",
"javap": "Compiled from \"Day04.kt\"\nfinal class Day04Kt$main$part1$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<java.util.List<? extends java.lang.Integer>, java.util.List<? extends java.lang.Integer>, java.lang.Boolean> {\n public static final Day04Kt$main$part1$1 INSTANCE;\n\n Day04Kt$main$part1$1();\n Code:\n 0: aload_0\n 1: iconst_2\n 2: ldc #11 // class Day04Kt\n 4: ldc #13 // String fullyContains\n 6: ldc #15 // String fullyContains(Ljava/util/List;Ljava/util/List;)Z\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final java.lang.Boolean invoke(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>);\n Code:\n 0: aload_1\n 1: ldc #25 // String p0\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #33 // String p1\n 9: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: aload_2\n 14: invokestatic #36 // Method Day04Kt.fullyContains:(Ljava/util/List;Ljava/util/List;)Z\n 17: invokestatic #42 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 20: areturn\n\n public java.lang.Object invoke(java.lang.Object, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #46 // class java/util/List\n 5: aload_2\n 6: checkcast #46 // class java/util/List\n 9: invokevirtual #48 // Method invoke:(Ljava/util/List;Ljava/util/List;)Ljava/lang/Boolean;\n 12: areturn\n\n static {};\n Code:\n 0: new #2 // class Day04Kt$main$part1$1\n 3: dup\n 4: invokespecial #53 // Method \"<init>\":()V\n 7: putstatic #56 // Field INSTANCE:LDay04Kt$main$part1$1;\n 10: return\n}\n",
"javap_err": ""
}
] |
GreyWolf2020__aoc-2022-in-kotlin__498da88/src/Day05.kt
|
import java.io.File
import java.util.Stack
typealias Stacks<E> = List<Stack<E>>
typealias StacksOfChar = Stacks<Char>
fun main() {
fun part1(input: String) = findCratesOnTopOfAllStacks(
input,
StacksOfChar::moveOneStackAtTime
)
fun part2(input: String) = findCratesOnTopOfAllStacks(
input,
StacksOfChar::moveAllStacksOnce
)
// test if implementation meets criteria from the description, like:
// val testInput = readInputAsString("Day05_test")
// check(part1(testInput) == "CMZ")
// check(part2(testInput) == "MCD")
//
// val input = readInputAsString("Day05")
// println(part1(input))
// println(part2(input))
}
fun findCratesOnTopOfAllStacks(
input: String,
moveOneOrAllAtATime: StacksOfChar.(Int, Int, Int) -> StacksOfChar
): String {
val (stackData, proceduresData) = input
.split("\n\r\n") // separate the information of stacks from that of procedures
val stackSize = stackData
.toIntStackSize() // get the last number of the stacks which is in turn the size of stacks
val listOfStacks = buildList { repeat(stackSize) { add(Stack<Char>()) } }
stackData
.lines() // get the cranes at each level of the stacks from the top
.dropLast(2) // the line with the numbering of the stacks
.map {
it
.chunked(4)
.map { it[1] }
} // remove the clutter such as the space and the brackets, take only the character content of the cranes
.foldRight(listOfStacks) { cranes, stacks ->
cranes.forEachIndexed { craneStackNum, crane ->
if (crane.toString().isNotBlank()) {
stacks[craneStackNum].push(crane) // push the crates into the list of stacks
}
} // build the initial state of the states
stacks
}
proceduresData
.lines() // get the lines of the procedures
.map {
it.split(" ")
}
.fold(listOfStacks) { stacks, procedure ->
stacks
.moveOneOrAllAtATime(
procedure[1].toInt(), // the number of cranes to move
procedure[3].toInt() - 1, // the stack to move the cranes from
procedure[5].toInt() - 1 // the stack to move the cranes to
)
}
return buildString { listOfStacks.forEach { if (it.isEmpty()) append(" ") else append(it.pop()) } }
}
private fun <E> Stacks<E>.moveOneStackAtTime(crates: Int, fromStack: Int, toStack: Int): Stacks<E> = apply {
repeat(crates) {
if (this[fromStack].isNotEmpty()) {
this[toStack].push(this[fromStack].pop())
} else this.map { println(it) }
}
}
private fun <E> Stacks<E>.moveAllStacksOnce(crates: Int, fromStack: Int, toStack: Int): Stacks<E> = apply {
val tempStack = Stack<E>()
repeat(crates) {
if (this[fromStack].isNotEmpty()) {
tempStack.push(this[fromStack].pop())
} else this.map { println(it) }
}
repeat(crates) {
if (tempStack.isNotEmpty()) {
this[toStack].push(tempStack.pop())
}
}
}
private fun String.toIntStackSize() = split("\n")
.last()// get the labels of all the stack
.split(" ")// get the list of each stack's label
.last() // get the last stack's label
.trim() // remove any characters around the label
.toInt() // return the label as an Int
|
[
{
"class_path": "GreyWolf2020__aoc-2022-in-kotlin__498da88/Day05Kt.class",
"javap": "Compiled from \"Day05.kt\"\npublic final class Day05Kt {\n public static final void main();\n Code:\n 0: return\n\n public static final java.lang.String findCratesOnTopOfAllStacks(java.lang.String, kotlin.jvm.functions.Function4<? super java.util.List<? extends java.util.Stack<java.lang.Character>>, ? super java.lang.Integer, ? super java.lang.Integer, ? super java.lang.Integer, ? extends java.util.List<? extends java.util.Stack<java.lang.Character>>>);\n Code:\n 0: aload_0\n 1: ldc #12 // String input\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #20 // String moveOneOrAllAtATime\n 9: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: checkcast #22 // class java/lang/CharSequence\n 16: iconst_1\n 17: anewarray #24 // class java/lang/String\n 20: astore_3\n 21: aload_3\n 22: iconst_0\n 23: ldc #26 // String \\n\\r\\n\n 25: aastore\n 26: aload_3\n 27: iconst_0\n 28: iconst_0\n 29: bipush 6\n 31: aconst_null\n 32: invokestatic #32 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 35: astore_2\n 36: aload_2\n 37: iconst_0\n 38: invokeinterface #38, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 43: checkcast #24 // class java/lang/String\n 46: astore_3\n 47: aload_2\n 48: iconst_1\n 49: invokeinterface #38, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 54: checkcast #24 // class java/lang/String\n 57: astore 4\n 59: aload_3\n 60: invokestatic #42 // Method toIntStackSize:(Ljava/lang/String;)I\n 63: istore 5\n 65: invokestatic #48 // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;\n 68: astore 7\n 70: aload 7\n 72: astore 8\n 74: iconst_0\n 75: istore 9\n 77: iconst_0\n 78: istore 10\n 80: iload 10\n 82: iload 5\n 84: if_icmpge 115\n 87: iload 10\n 89: istore 11\n 91: iconst_0\n 92: istore 12\n 94: aload 8\n 96: new #50 // class java/util/Stack\n 99: dup\n 100: invokespecial #53 // Method java/util/Stack.\"<init>\":()V\n 103: invokeinterface #57, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 108: pop\n 109: iinc 10, 1\n 112: goto 80\n 115: nop\n 116: aload 7\n 118: invokestatic #61 // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;\n 121: astore 6\n 123: aload_3\n 124: checkcast #22 // class java/lang/CharSequence\n 127: invokestatic #65 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 130: iconst_2\n 131: invokestatic #69 // Method kotlin/collections/CollectionsKt.dropLast:(Ljava/util/List;I)Ljava/util/List;\n 134: checkcast #71 // class java/lang/Iterable\n 137: astore 7\n 139: nop\n 140: iconst_0\n 141: istore 8\n 143: aload 7\n 145: astore 9\n 147: new #73 // class java/util/ArrayList\n 150: dup\n 151: aload 7\n 153: bipush 10\n 155: invokestatic #77 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 158: invokespecial #80 // Method java/util/ArrayList.\"<init>\":(I)V\n 161: checkcast #82 // class java/util/Collection\n 164: astore 10\n 166: iconst_0\n 167: istore 11\n 169: aload 9\n 171: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 176: astore 12\n 178: aload 12\n 180: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 185: ifeq 337\n 188: aload 12\n 190: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 195: astore 13\n 197: aload 10\n 199: aload 13\n 201: checkcast #24 // class java/lang/String\n 204: astore 14\n 206: astore 26\n 208: iconst_0\n 209: istore 15\n 211: aload 14\n 213: checkcast #22 // class java/lang/CharSequence\n 216: iconst_4\n 217: invokestatic #100 // Method kotlin/text/StringsKt.chunked:(Ljava/lang/CharSequence;I)Ljava/util/List;\n 220: checkcast #71 // class java/lang/Iterable\n 223: astore 16\n 225: nop\n 226: iconst_0\n 227: istore 17\n 229: aload 16\n 231: astore 18\n 233: new #73 // class java/util/ArrayList\n 236: dup\n 237: aload 16\n 239: bipush 10\n 241: invokestatic #77 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 244: invokespecial #80 // Method java/util/ArrayList.\"<init>\":(I)V\n 247: checkcast #82 // class java/util/Collection\n 250: astore 19\n 252: iconst_0\n 253: istore 20\n 255: aload 18\n 257: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 262: astore 21\n 264: aload 21\n 266: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 271: ifeq 318\n 274: aload 21\n 276: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 281: astore 22\n 283: aload 19\n 285: aload 22\n 287: checkcast #24 // class java/lang/String\n 290: astore 23\n 292: astore 24\n 294: iconst_0\n 295: istore 25\n 297: aload 23\n 299: iconst_1\n 300: invokevirtual #104 // Method java/lang/String.charAt:(I)C\n 303: invokestatic #110 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 306: aload 24\n 308: swap\n 309: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 314: pop\n 315: goto 264\n 318: aload 19\n 320: checkcast #34 // class java/util/List\n 323: nop\n 324: nop\n 325: aload 26\n 327: swap\n 328: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 333: pop\n 334: goto 178\n 337: aload 10\n 339: checkcast #34 // class java/util/List\n 342: nop\n 343: astore 7\n 345: nop\n 346: iconst_0\n 347: istore 8\n 349: aload 6\n 351: astore 9\n 353: aload 7\n 355: invokeinterface #114, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 360: ifne 537\n 363: aload 7\n 365: aload 7\n 367: invokeinterface #118, 1 // InterfaceMethod java/util/List.size:()I\n 372: invokeinterface #122, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 377: astore 10\n 379: aload 10\n 381: invokeinterface #127, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 386: ifeq 537\n 389: aload 10\n 391: invokeinterface #130, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 396: aload 9\n 398: astore 11\n 400: checkcast #34 // class java/util/List\n 403: astore 12\n 405: iconst_0\n 406: istore 13\n 408: aload 12\n 410: checkcast #71 // class java/lang/Iterable\n 413: astore 14\n 415: iconst_0\n 416: istore 15\n 418: iconst_0\n 419: istore 16\n 421: aload 14\n 423: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 428: astore 17\n 430: aload 17\n 432: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 437: ifeq 529\n 440: aload 17\n 442: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 447: astore 18\n 449: iload 16\n 451: iinc 16, 1\n 454: istore 19\n 456: iload 19\n 458: ifge 464\n 461: invokestatic #133 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 464: iload 19\n 466: aload 18\n 468: checkcast #106 // class java/lang/Character\n 471: invokevirtual #137 // Method java/lang/Character.charValue:()C\n 474: istore 20\n 476: istore 21\n 478: iconst_0\n 479: istore 22\n 481: iload 20\n 483: invokestatic #140 // Method java/lang/String.valueOf:(C)Ljava/lang/String;\n 486: checkcast #22 // class java/lang/CharSequence\n 489: invokestatic #144 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 492: ifne 499\n 495: iconst_1\n 496: goto 500\n 499: iconst_0\n 500: ifeq 524\n 503: aload 11\n 505: iload 21\n 507: invokeinterface #38, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 512: checkcast #50 // class java/util/Stack\n 515: iload 20\n 517: invokestatic #110 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 520: invokevirtual #148 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 523: pop\n 524: nop\n 525: nop\n 526: goto 430\n 529: nop\n 530: aload 11\n 532: astore 9\n 534: goto 379\n 537: nop\n 538: aload 4\n 540: checkcast #22 // class java/lang/CharSequence\n 543: invokestatic #65 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 546: checkcast #71 // class java/lang/Iterable\n 549: astore 7\n 551: nop\n 552: iconst_0\n 553: istore 8\n 555: aload 7\n 557: astore 9\n 559: new #73 // class java/util/ArrayList\n 562: dup\n 563: aload 7\n 565: bipush 10\n 567: invokestatic #77 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 570: invokespecial #80 // Method java/util/ArrayList.\"<init>\":(I)V\n 573: checkcast #82 // class java/util/Collection\n 576: astore 10\n 578: iconst_0\n 579: istore 11\n 581: aload 9\n 583: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 588: astore 12\n 590: aload 12\n 592: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 597: ifeq 662\n 600: aload 12\n 602: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 607: astore 13\n 609: aload 10\n 611: aload 13\n 613: checkcast #24 // class java/lang/String\n 616: astore 14\n 618: astore 26\n 620: iconst_0\n 621: istore 15\n 623: aload 14\n 625: checkcast #22 // class java/lang/CharSequence\n 628: iconst_1\n 629: anewarray #24 // class java/lang/String\n 632: astore 16\n 634: aload 16\n 636: iconst_0\n 637: ldc #150 // String\n 639: aastore\n 640: aload 16\n 642: iconst_0\n 643: iconst_0\n 644: bipush 6\n 646: aconst_null\n 647: invokestatic #32 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 650: aload 26\n 652: swap\n 653: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 658: pop\n 659: goto 590\n 662: aload 10\n 664: checkcast #34 // class java/util/List\n 667: nop\n 668: checkcast #71 // class java/lang/Iterable\n 671: astore 7\n 673: nop\n 674: iconst_0\n 675: istore 8\n 677: aload 6\n 679: astore 9\n 681: aload 7\n 683: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 688: astore 10\n 690: aload 10\n 692: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 697: ifeq 795\n 700: aload 10\n 702: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 707: astore 11\n 709: aload 9\n 711: aload 11\n 713: checkcast #34 // class java/util/List\n 716: astore 12\n 718: astore 13\n 720: iconst_0\n 721: istore 14\n 723: aload_1\n 724: aload 13\n 726: aload 12\n 728: iconst_1\n 729: invokeinterface #38, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 734: checkcast #24 // class java/lang/String\n 737: invokestatic #155 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 740: invokestatic #158 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 743: aload 12\n 745: iconst_3\n 746: invokeinterface #38, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 751: checkcast #24 // class java/lang/String\n 754: invokestatic #155 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 757: iconst_1\n 758: isub\n 759: invokestatic #158 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 762: aload 12\n 764: iconst_5\n 765: invokeinterface #38, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 770: checkcast #24 // class java/lang/String\n 773: invokestatic #155 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 776: iconst_1\n 777: isub\n 778: invokestatic #158 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 781: invokeinterface #164, 5 // InterfaceMethod kotlin/jvm/functions/Function4.invoke:(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 786: checkcast #34 // class java/util/List\n 789: nop\n 790: astore 9\n 792: goto 690\n 795: nop\n 796: new #166 // class java/lang/StringBuilder\n 799: dup\n 800: invokespecial #167 // Method java/lang/StringBuilder.\"<init>\":()V\n 803: astore 7\n 805: aload 7\n 807: astore 8\n 809: iconst_0\n 810: istore 9\n 812: aload 6\n 814: checkcast #71 // class java/lang/Iterable\n 817: astore 10\n 819: iconst_0\n 820: istore 11\n 822: aload 10\n 824: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 829: astore 12\n 831: aload 12\n 833: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 838: ifeq 905\n 841: aload 12\n 843: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 848: astore 13\n 850: aload 13\n 852: checkcast #50 // class java/util/Stack\n 855: astore 14\n 857: iconst_0\n 858: istore 15\n 860: aload 14\n 862: invokevirtual #168 // Method java/util/Stack.isEmpty:()Z\n 865: ifeq 878\n 868: aload 8\n 870: ldc #150 // String\n 872: invokevirtual #172 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 875: goto 900\n 878: aload 8\n 880: aload 14\n 882: invokevirtual #175 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 885: dup\n 886: ldc #177 // String pop(...)\n 888: invokestatic #180 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 891: checkcast #106 // class java/lang/Character\n 894: invokevirtual #137 // Method java/lang/Character.charValue:()C\n 897: invokevirtual #183 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 900: pop\n 901: nop\n 902: goto 831\n 905: nop\n 906: nop\n 907: aload 7\n 909: invokevirtual #187 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 912: areturn\n\n private static final <E> java.util.List<java.util.Stack<E>> moveOneStackAtTime(java.util.List<? extends java.util.Stack<E>>, int, int, int);\n Code:\n 0: aload_0\n 1: astore 4\n 3: aload 4\n 5: astore 5\n 7: iconst_0\n 8: istore 6\n 10: iconst_0\n 11: istore 7\n 13: iload 7\n 15: iload_1\n 16: if_icmpge 199\n 19: iload 7\n 21: istore 8\n 23: iconst_0\n 24: istore 9\n 26: aload 5\n 28: iload_2\n 29: invokeinterface #38, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 34: checkcast #82 // class java/util/Collection\n 37: invokeinterface #243, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 42: ifne 49\n 45: iconst_1\n 46: goto 50\n 49: iconst_0\n 50: ifeq 84\n 53: aload 5\n 55: iload_3\n 56: invokeinterface #38, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 61: checkcast #50 // class java/util/Stack\n 64: aload 5\n 66: iload_2\n 67: invokeinterface #38, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 72: checkcast #50 // class java/util/Stack\n 75: invokevirtual #175 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 78: invokevirtual #148 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 81: goto 191\n 84: aload 5\n 86: checkcast #71 // class java/lang/Iterable\n 89: astore 10\n 91: iconst_0\n 92: istore 11\n 94: aload 10\n 96: astore 12\n 98: new #73 // class java/util/ArrayList\n 101: dup\n 102: aload 10\n 104: bipush 10\n 106: invokestatic #77 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 109: invokespecial #80 // Method java/util/ArrayList.\"<init>\":(I)V\n 112: checkcast #82 // class java/util/Collection\n 115: astore 13\n 117: iconst_0\n 118: istore 14\n 120: aload 12\n 122: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 127: astore 15\n 129: aload 15\n 131: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 136: ifeq 185\n 139: aload 15\n 141: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 146: astore 16\n 148: aload 13\n 150: aload 16\n 152: checkcast #50 // class java/util/Stack\n 155: astore 17\n 157: astore 18\n 159: iconst_0\n 160: istore 19\n 162: getstatic #249 // Field java/lang/System.out:Ljava/io/PrintStream;\n 165: aload 17\n 167: invokevirtual #255 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 170: nop\n 171: aload 18\n 173: getstatic #261 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 176: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 181: pop\n 182: goto 129\n 185: aload 13\n 187: checkcast #34 // class java/util/List\n 190: nop\n 191: pop\n 192: nop\n 193: iinc 7, 1\n 196: goto 13\n 199: nop\n 200: aload 4\n 202: areturn\n\n private static final <E> java.util.List<java.util.Stack<E>> moveAllStacksOnce(java.util.List<? extends java.util.Stack<E>>, int, int, int);\n Code:\n 0: aload_0\n 1: astore 4\n 3: aload 4\n 5: astore 5\n 7: iconst_0\n 8: istore 6\n 10: new #50 // class java/util/Stack\n 13: dup\n 14: invokespecial #53 // Method java/util/Stack.\"<init>\":()V\n 17: astore 7\n 19: iconst_0\n 20: istore 8\n 22: iload 8\n 24: iload_1\n 25: if_icmpge 199\n 28: iload 8\n 30: istore 9\n 32: iconst_0\n 33: istore 10\n 35: aload 5\n 37: iload_2\n 38: invokeinterface #38, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 43: checkcast #82 // class java/util/Collection\n 46: invokeinterface #243, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 51: ifne 58\n 54: iconst_1\n 55: goto 59\n 58: iconst_0\n 59: ifeq 84\n 62: aload 7\n 64: aload 5\n 66: iload_2\n 67: invokeinterface #38, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 72: checkcast #50 // class java/util/Stack\n 75: invokevirtual #175 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 78: invokevirtual #148 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 81: goto 191\n 84: aload 5\n 86: checkcast #71 // class java/lang/Iterable\n 89: astore 11\n 91: iconst_0\n 92: istore 12\n 94: aload 11\n 96: astore 13\n 98: new #73 // class java/util/ArrayList\n 101: dup\n 102: aload 11\n 104: bipush 10\n 106: invokestatic #77 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 109: invokespecial #80 // Method java/util/ArrayList.\"<init>\":(I)V\n 112: checkcast #82 // class java/util/Collection\n 115: astore 14\n 117: iconst_0\n 118: istore 15\n 120: aload 13\n 122: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 127: astore 16\n 129: aload 16\n 131: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 136: ifeq 185\n 139: aload 16\n 141: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 146: astore 17\n 148: aload 14\n 150: aload 17\n 152: checkcast #50 // class java/util/Stack\n 155: astore 18\n 157: astore 19\n 159: iconst_0\n 160: istore 20\n 162: getstatic #249 // Field java/lang/System.out:Ljava/io/PrintStream;\n 165: aload 18\n 167: invokevirtual #255 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 170: nop\n 171: aload 19\n 173: getstatic #261 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 176: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 181: pop\n 182: goto 129\n 185: aload 14\n 187: checkcast #34 // class java/util/List\n 190: nop\n 191: pop\n 192: nop\n 193: iinc 8, 1\n 196: goto 22\n 199: iconst_0\n 200: istore 8\n 202: iload 8\n 204: iload_1\n 205: if_icmpge 263\n 208: iload 8\n 210: istore 9\n 212: iconst_0\n 213: istore 10\n 215: aload 7\n 217: checkcast #82 // class java/util/Collection\n 220: invokeinterface #243, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 225: ifne 232\n 228: iconst_1\n 229: goto 233\n 232: iconst_0\n 233: ifeq 256\n 236: aload 5\n 238: iload_3\n 239: invokeinterface #38, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 244: checkcast #50 // class java/util/Stack\n 247: aload 7\n 249: invokevirtual #175 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 252: invokevirtual #148 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 255: pop\n 256: nop\n 257: iinc 8, 1\n 260: goto 202\n 263: nop\n 264: aload 4\n 266: areturn\n\n private static final int toIntStackSize(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #22 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #24 // class java/lang/String\n 8: astore_1\n 9: aload_1\n 10: iconst_0\n 11: ldc_w #279 // String \\n\n 14: aastore\n 15: aload_1\n 16: iconst_0\n 17: iconst_0\n 18: bipush 6\n 20: aconst_null\n 21: invokestatic #32 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 24: invokestatic #283 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 27: checkcast #22 // class java/lang/CharSequence\n 30: iconst_1\n 31: anewarray #24 // class java/lang/String\n 34: astore_1\n 35: aload_1\n 36: iconst_0\n 37: ldc #150 // String\n 39: aastore\n 40: aload_1\n 41: iconst_0\n 42: iconst_0\n 43: bipush 6\n 45: aconst_null\n 46: invokestatic #32 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 49: invokestatic #283 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 52: checkcast #24 // class java/lang/String\n 55: checkcast #22 // class java/lang/CharSequence\n 58: invokestatic #287 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 61: invokevirtual #288 // Method java/lang/Object.toString:()Ljava/lang/String;\n 64: invokestatic #155 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 67: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #292 // Method main:()V\n 3: return\n\n private static final java.lang.String main$part1(java.lang.String);\n Code:\n 0: aload_0\n 1: getstatic #301 // Field Day05Kt$main$part1$1.INSTANCE:LDay05Kt$main$part1$1;\n 4: checkcast #160 // class kotlin/jvm/functions/Function4\n 7: invokestatic #303 // Method findCratesOnTopOfAllStacks:(Ljava/lang/String;Lkotlin/jvm/functions/Function4;)Ljava/lang/String;\n 10: areturn\n\n private static final java.lang.String main$part2(java.lang.String);\n Code:\n 0: aload_0\n 1: getstatic #309 // Field Day05Kt$main$part2$1.INSTANCE:LDay05Kt$main$part2$1;\n 4: checkcast #160 // class kotlin/jvm/functions/Function4\n 7: invokestatic #303 // Method findCratesOnTopOfAllStacks:(Ljava/lang/String;Lkotlin/jvm/functions/Function4;)Ljava/lang/String;\n 10: areturn\n\n public static final java.util.List access$moveOneStackAtTime(java.util.List, int, int, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: iload_2\n 3: iload_3\n 4: invokestatic #312 // Method moveOneStackAtTime:(Ljava/util/List;III)Ljava/util/List;\n 7: areturn\n\n public static final java.util.List access$moveAllStacksOnce(java.util.List, int, int, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: iload_2\n 3: iload_3\n 4: invokestatic #316 // Method moveAllStacksOnce:(Ljava/util/List;III)Ljava/util/List;\n 7: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "GreyWolf2020__aoc-2022-in-kotlin__498da88/Day05Kt$main$part1$1.class",
"javap": "Compiled from \"Day05.kt\"\nfinal class Day05Kt$main$part1$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function4<java.util.List<? extends java.util.Stack<java.lang.Character>>, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.util.List<? extends java.util.Stack<java.lang.Character>>> {\n public static final Day05Kt$main$part1$1 INSTANCE;\n\n Day05Kt$main$part1$1();\n Code:\n 0: aload_0\n 1: iconst_4\n 2: ldc #11 // class Day05Kt\n 4: ldc #13 // String moveOneStackAtTime\n 6: ldc #15 // String moveOneStackAtTime(Ljava/util/List;III)Ljava/util/List;\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final java.util.List<java.util.Stack<java.lang.Character>> invoke(java.util.List<? extends java.util.Stack<java.lang.Character>>, int, int, int);\n Code:\n 0: aload_1\n 1: ldc #25 // String p0\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: iload_2\n 8: iload_3\n 9: iload 4\n 11: invokestatic #34 // Method Day05Kt.access$moveOneStackAtTime:(Ljava/util/List;III)Ljava/util/List;\n 14: areturn\n\n public java.lang.Object invoke(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #42 // class java/util/List\n 5: aload_2\n 6: checkcast #44 // class java/lang/Number\n 9: invokevirtual #48 // Method java/lang/Number.intValue:()I\n 12: aload_3\n 13: checkcast #44 // class java/lang/Number\n 16: invokevirtual #48 // Method java/lang/Number.intValue:()I\n 19: aload 4\n 21: checkcast #44 // class java/lang/Number\n 24: invokevirtual #48 // Method java/lang/Number.intValue:()I\n 27: invokevirtual #50 // Method invoke:(Ljava/util/List;III)Ljava/util/List;\n 30: areturn\n\n static {};\n Code:\n 0: new #2 // class Day05Kt$main$part1$1\n 3: dup\n 4: invokespecial #55 // Method \"<init>\":()V\n 7: putstatic #58 // Field INSTANCE:LDay05Kt$main$part1$1;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "GreyWolf2020__aoc-2022-in-kotlin__498da88/Day05Kt$main$part2$1.class",
"javap": "Compiled from \"Day05.kt\"\nfinal class Day05Kt$main$part2$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function4<java.util.List<? extends java.util.Stack<java.lang.Character>>, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.util.List<? extends java.util.Stack<java.lang.Character>>> {\n public static final Day05Kt$main$part2$1 INSTANCE;\n\n Day05Kt$main$part2$1();\n Code:\n 0: aload_0\n 1: iconst_4\n 2: ldc #11 // class Day05Kt\n 4: ldc #13 // String moveAllStacksOnce\n 6: ldc #15 // String moveAllStacksOnce(Ljava/util/List;III)Ljava/util/List;\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final java.util.List<java.util.Stack<java.lang.Character>> invoke(java.util.List<? extends java.util.Stack<java.lang.Character>>, int, int, int);\n Code:\n 0: aload_1\n 1: ldc #25 // String p0\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: iload_2\n 8: iload_3\n 9: iload 4\n 11: invokestatic #34 // Method Day05Kt.access$moveAllStacksOnce:(Ljava/util/List;III)Ljava/util/List;\n 14: areturn\n\n public java.lang.Object invoke(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #42 // class java/util/List\n 5: aload_2\n 6: checkcast #44 // class java/lang/Number\n 9: invokevirtual #48 // Method java/lang/Number.intValue:()I\n 12: aload_3\n 13: checkcast #44 // class java/lang/Number\n 16: invokevirtual #48 // Method java/lang/Number.intValue:()I\n 19: aload 4\n 21: checkcast #44 // class java/lang/Number\n 24: invokevirtual #48 // Method java/lang/Number.intValue:()I\n 27: invokevirtual #50 // Method invoke:(Ljava/util/List;III)Ljava/util/List;\n 30: areturn\n\n static {};\n Code:\n 0: new #2 // class Day05Kt$main$part2$1\n 3: dup\n 4: invokespecial #55 // Method \"<init>\":()V\n 7: putstatic #58 // Field INSTANCE:LDay05Kt$main$part2$1;\n 10: return\n}\n",
"javap_err": ""
}
] |
GreyWolf2020__aoc-2022-in-kotlin__498da88/src/Day07.kt
|
const val TOTALDISKSPACE = 70000000
const val NEEDEDUNUSEDSPACE = 30000000
fun main() {
fun part1(input: String): Int = FileSystem().run {
parseInstructions(input)
getListOfDirNSizes()
.map { it.second }
.filter { it < 100000 }
.sum()
}
fun part2(input: String): Pair<String, Int> = FileSystem().run {
parseInstructions(input)
val listOfDirNSizes = getListOfDirNSizes()
val totalUsedSize = getListOfDirNSizes().maxOf { it.second }
val totalUnUsedSpace = TOTALDISKSPACE - totalUsedSize
listOfDirNSizes
.filter { dirNSize ->
val (_, size) = dirNSize
size >= NEEDEDUNUSEDSPACE - totalUnUsedSpace
}
.minBy { it.second }
}
// test if implementation meets criteria from the description, like:
// table test of part1
// val testInput = readInputAsString("Day07_test")
// check(part1(testInput) == 95437)
// check(part2(testInput) == Pair("d", 24933642))
//
// val input = readInputAsString("Day07")
// println(part1(input))
// println(part2(input))
}
sealed class FileType (val name: String, val parent: FileType.Dir?) {
class Dir(name: String, parent: FileType.Dir?, val children: HashMap<String, FileType> = hashMapOf()) : FileType(name, parent) {
override fun getTheSize(): Int = children
.map {
it.value
}
.fold(0) { sizes, children ->
sizes + children.getTheSize()
}
}
class MyFile(name: String, parent: FileType.Dir, val size: Int) : FileType(name, parent) {
override fun getTheSize(): Int = size
}
abstract fun getTheSize(): Int
}
fun FileType.Dir.getDirNSize(list: MutableList<Pair<String, Int>>) {
children.map { it.value }
.forEach {
if (it is FileType.Dir)
it.getDirNSize(list)
}
val size = getTheSize()
list.add(
Pair(name, size)
)
}
class FileSystem {
private val rootDir = FileType.Dir("/", null)
private var current = rootDir
fun changeDirectory(param: String) {
current = when(param) {
".." -> current.parent ?: rootDir
"/" -> rootDir
else -> current
.children
.getOrElse(param){
val newChild = FileType.Dir(param, current)
current.children.put(param, newChild)
newChild
} as FileType.Dir
}
}
fun listing(files: List<String>) {
files
.map {
it.split(" ")
}
.fold(current) { cur, file ->
when {
file.first() == "dir" -> cur.children.put(file.last(), FileType.Dir(file.last(), cur))
else -> cur.children.put(file.last(), FileType.MyFile(file.last(), cur, file.first().toInt()))
}
cur
}
}
fun parseInstructions(instructions: String) {
instructions
.split("$")
.map {
it.trim()
}
.forEach {
val commandNParamsData = it
.lines()
val command = commandNParamsData
.first()
.split(" ")
when (command.first()) {
"cd" -> changeDirectory(command.last())
"ls" -> listing(commandNParamsData
.drop(1) // remove any string that follows the command ls, which is blank in this case
)
else -> {}
}
}
}
fun getListOfDirNSizes(): MutableList<Pair<String, Int>> = mutableListOf<Pair<String, Int>>().apply {
rootDir.getDirNSize(this)
}
}
|
[
{
"class_path": "GreyWolf2020__aoc-2022-in-kotlin__498da88/Day07Kt.class",
"javap": "Compiled from \"Day07.kt\"\npublic final class Day07Kt {\n public static final int TOTALDISKSPACE;\n\n public static final int NEEDEDUNUSEDSPACE;\n\n public static final void main();\n Code:\n 0: return\n\n public static final void getDirNSize(FileType$Dir, java.util.List<kotlin.Pair<java.lang.String, java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: ldc #12 // String <this>\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #20 // String list\n 9: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokevirtual #26 // Method FileType$Dir.getChildren:()Ljava/util/HashMap;\n 16: checkcast #28 // class java/util/Map\n 19: astore_2\n 20: iconst_0\n 21: istore_3\n 22: aload_2\n 23: astore 4\n 25: new #30 // class java/util/ArrayList\n 28: dup\n 29: aload_2\n 30: invokeinterface #34, 1 // InterfaceMethod java/util/Map.size:()I\n 35: invokespecial #38 // Method java/util/ArrayList.\"<init>\":(I)V\n 38: checkcast #40 // class java/util/Collection\n 41: astore 5\n 43: iconst_0\n 44: istore 6\n 46: aload 4\n 48: invokeinterface #44, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 53: invokeinterface #50, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 58: astore 7\n 60: aload 7\n 62: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 67: ifeq 115\n 70: aload 7\n 72: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 77: checkcast #62 // class java/util/Map$Entry\n 80: astore 8\n 82: aload 5\n 84: aload 8\n 86: astore 9\n 88: astore 11\n 90: iconst_0\n 91: istore 10\n 93: aload 9\n 95: invokeinterface #65, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 100: checkcast #67 // class FileType\n 103: aload 11\n 105: swap\n 106: invokeinterface #71, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 111: pop\n 112: goto 60\n 115: aload 5\n 117: checkcast #73 // class java/util/List\n 120: nop\n 121: checkcast #75 // class java/lang/Iterable\n 124: astore_2\n 125: nop\n 126: iconst_0\n 127: istore_3\n 128: aload_2\n 129: invokeinterface #76, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 134: astore 4\n 136: aload 4\n 138: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 143: ifeq 187\n 146: aload 4\n 148: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 153: astore 5\n 155: aload 5\n 157: checkcast #67 // class FileType\n 160: astore 6\n 162: iconst_0\n 163: istore 7\n 165: aload 6\n 167: instanceof #22 // class FileType$Dir\n 170: ifeq 182\n 173: aload 6\n 175: checkcast #22 // class FileType$Dir\n 178: aload_1\n 179: invokestatic #78 // Method getDirNSize:(LFileType$Dir;Ljava/util/List;)V\n 182: nop\n 183: nop\n 184: goto 136\n 187: nop\n 188: aload_0\n 189: invokevirtual #81 // Method FileType$Dir.getTheSize:()I\n 192: istore_2\n 193: aload_1\n 194: new #83 // class kotlin/Pair\n 197: dup\n 198: aload_0\n 199: invokevirtual #87 // Method FileType$Dir.getName:()Ljava/lang/String;\n 202: iload_2\n 203: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 206: invokespecial #96 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 209: invokeinterface #97, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 214: pop\n 215: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #122 // Method main:()V\n 3: return\n\n private static final int main$part1(java.lang.String);\n Code:\n 0: new #128 // class FileSystem\n 3: dup\n 4: invokespecial #130 // Method FileSystem.\"<init>\":()V\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: aload_0\n 12: invokevirtual #134 // Method FileSystem.parseInstructions:(Ljava/lang/String;)V\n 15: aload_1\n 16: invokevirtual #138 // Method FileSystem.getListOfDirNSizes:()Ljava/util/List;\n 19: checkcast #75 // class java/lang/Iterable\n 22: astore_3\n 23: nop\n 24: iconst_0\n 25: istore 4\n 27: aload_3\n 28: astore 5\n 30: new #30 // class java/util/ArrayList\n 33: dup\n 34: aload_3\n 35: bipush 10\n 37: invokestatic #144 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 40: invokespecial #38 // Method java/util/ArrayList.\"<init>\":(I)V\n 43: checkcast #40 // class java/util/Collection\n 46: astore 6\n 48: iconst_0\n 49: istore 7\n 51: aload 5\n 53: invokeinterface #76, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 58: astore 8\n 60: aload 8\n 62: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 67: ifeq 119\n 70: aload 8\n 72: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 77: astore 9\n 79: aload 6\n 81: aload 9\n 83: checkcast #83 // class kotlin/Pair\n 86: astore 10\n 88: astore 11\n 90: iconst_0\n 91: istore 12\n 93: aload 10\n 95: invokevirtual #147 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 98: checkcast #149 // class java/lang/Number\n 101: invokevirtual #152 // Method java/lang/Number.intValue:()I\n 104: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 107: aload 11\n 109: swap\n 110: invokeinterface #71, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 115: pop\n 116: goto 60\n 119: aload 6\n 121: checkcast #73 // class java/util/List\n 124: nop\n 125: checkcast #75 // class java/lang/Iterable\n 128: astore_3\n 129: nop\n 130: iconst_0\n 131: istore 4\n 133: aload_3\n 134: astore 5\n 136: new #30 // class java/util/ArrayList\n 139: dup\n 140: invokespecial #153 // Method java/util/ArrayList.\"<init>\":()V\n 143: checkcast #40 // class java/util/Collection\n 146: astore 6\n 148: iconst_0\n 149: istore 7\n 151: aload 5\n 153: invokeinterface #76, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 158: astore 8\n 160: aload 8\n 162: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 167: ifeq 220\n 170: aload 8\n 172: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 177: astore 9\n 179: aload 9\n 181: checkcast #149 // class java/lang/Number\n 184: invokevirtual #152 // Method java/lang/Number.intValue:()I\n 187: istore 10\n 189: iconst_0\n 190: istore 12\n 192: iload 10\n 194: ldc #154 // int 100000\n 196: if_icmpge 203\n 199: iconst_1\n 200: goto 204\n 203: iconst_0\n 204: ifeq 160\n 207: aload 6\n 209: aload 9\n 211: invokeinterface #71, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 216: pop\n 217: goto 160\n 220: aload 6\n 222: checkcast #73 // class java/util/List\n 225: nop\n 226: checkcast #75 // class java/lang/Iterable\n 229: invokestatic #158 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 232: nop\n 233: ireturn\n\n private static final kotlin.Pair<java.lang.String, java.lang.Integer> main$part2(java.lang.String);\n Code:\n 0: new #128 // class FileSystem\n 3: dup\n 4: invokespecial #130 // Method FileSystem.\"<init>\":()V\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: aload_0\n 12: invokevirtual #134 // Method FileSystem.parseInstructions:(Ljava/lang/String;)V\n 15: aload_1\n 16: invokevirtual #138 // Method FileSystem.getListOfDirNSizes:()Ljava/util/List;\n 19: astore_3\n 20: aload_1\n 21: invokevirtual #138 // Method FileSystem.getListOfDirNSizes:()Ljava/util/List;\n 24: checkcast #75 // class java/lang/Iterable\n 27: invokeinterface #76, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 32: astore 4\n 34: aload 4\n 36: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 41: ifne 52\n 44: new #178 // class java/util/NoSuchElementException\n 47: dup\n 48: invokespecial #179 // Method java/util/NoSuchElementException.\"<init>\":()V\n 51: athrow\n 52: aload 4\n 54: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 59: checkcast #83 // class kotlin/Pair\n 62: astore 5\n 64: iconst_0\n 65: istore 6\n 67: aload 5\n 69: invokevirtual #147 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 72: checkcast #149 // class java/lang/Number\n 75: invokevirtual #152 // Method java/lang/Number.intValue:()I\n 78: istore 5\n 80: aload 4\n 82: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 87: ifeq 132\n 90: aload 4\n 92: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 97: checkcast #83 // class kotlin/Pair\n 100: astore 6\n 102: iconst_0\n 103: istore 7\n 105: aload 6\n 107: invokevirtual #147 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 110: checkcast #149 // class java/lang/Number\n 113: invokevirtual #152 // Method java/lang/Number.intValue:()I\n 116: istore 6\n 118: iload 5\n 120: iload 6\n 122: if_icmpge 80\n 125: iload 6\n 127: istore 5\n 129: goto 80\n 132: iload 5\n 134: istore 8\n 136: ldc #180 // int 70000000\n 138: iload 8\n 140: isub\n 141: istore 9\n 143: aload_3\n 144: checkcast #75 // class java/lang/Iterable\n 147: astore 4\n 149: nop\n 150: iconst_0\n 151: istore 5\n 153: aload 4\n 155: astore 6\n 157: new #30 // class java/util/ArrayList\n 160: dup\n 161: invokespecial #153 // Method java/util/ArrayList.\"<init>\":()V\n 164: checkcast #40 // class java/util/Collection\n 167: astore 7\n 169: iconst_0\n 170: istore 10\n 172: aload 6\n 174: invokeinterface #76, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 179: astore 11\n 181: aload 11\n 183: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 188: ifeq 254\n 191: aload 11\n 193: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 198: astore 12\n 200: aload 12\n 202: checkcast #83 // class kotlin/Pair\n 205: astore 13\n 207: iconst_0\n 208: istore 14\n 210: aload 13\n 212: invokevirtual #183 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 215: checkcast #149 // class java/lang/Number\n 218: invokevirtual #152 // Method java/lang/Number.intValue:()I\n 221: istore 15\n 223: iload 15\n 225: ldc #184 // int 30000000\n 227: iload 9\n 229: isub\n 230: if_icmplt 237\n 233: iconst_1\n 234: goto 238\n 237: iconst_0\n 238: ifeq 181\n 241: aload 7\n 243: aload 12\n 245: invokeinterface #71, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 250: pop\n 251: goto 181\n 254: aload 7\n 256: checkcast #73 // class java/util/List\n 259: nop\n 260: checkcast #75 // class java/lang/Iterable\n 263: astore 4\n 265: nop\n 266: iconst_0\n 267: istore 5\n 269: aload 4\n 271: invokeinterface #76, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 276: astore 6\n 278: aload 6\n 280: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 285: ifne 296\n 288: new #178 // class java/util/NoSuchElementException\n 291: dup\n 292: invokespecial #179 // Method java/util/NoSuchElementException.\"<init>\":()V\n 295: athrow\n 296: aload 6\n 298: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 303: astore 7\n 305: aload 6\n 307: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 312: ifne 320\n 315: aload 7\n 317: goto 402\n 320: aload 7\n 322: checkcast #83 // class kotlin/Pair\n 325: astore 10\n 327: iconst_0\n 328: istore 11\n 330: aload 10\n 332: invokevirtual #147 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 335: checkcast #149 // class java/lang/Number\n 338: invokevirtual #152 // Method java/lang/Number.intValue:()I\n 341: istore 10\n 343: aload 6\n 345: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 350: astore 11\n 352: aload 11\n 354: checkcast #83 // class kotlin/Pair\n 357: astore 12\n 359: iconst_0\n 360: istore 13\n 362: aload 12\n 364: invokevirtual #147 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 367: checkcast #149 // class java/lang/Number\n 370: invokevirtual #152 // Method java/lang/Number.intValue:()I\n 373: istore 12\n 375: iload 10\n 377: iload 12\n 379: if_icmple 390\n 382: aload 11\n 384: astore 7\n 386: iload 12\n 388: istore 10\n 390: aload 6\n 392: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 397: ifne 343\n 400: aload 7\n 402: checkcast #83 // class kotlin/Pair\n 405: nop\n 406: nop\n 407: areturn\n}\n",
"javap_err": ""
}
] |
GreyWolf2020__aoc-2022-in-kotlin__498da88/src/Day06.kt
|
fun main() {
fun part1(signal: String, n: Int = 4): Int = firstNUniqueCharacters(signal = signal, n = n)
fun part2(signal: String, n: Int = 14): Int = firstNUniqueCharacters(signal = signal, n = n)
// test if implementation meets criteria from the description, like:
// table test of part1
// val testInput01 = readInput("Day06_test_part01")
// val testInput01Solutions = listOf<Int>(7, 5, 6, 10, 11)
// testInput01
// .zip(testInput01Solutions)
// .map {
// check(part1(it.first) == it.second)
// }
//
// // table test of part2
// val testInput02 = readInput("Day06_test_part02")
// val testInput02Solutions = listOf<Int>(19, 23, 23, 29, 26)
// testInput02
// .zip(testInput02Solutions)
// .map {
// check(part2(it.first) == it.second)
// }
//
// val input = readInputAsString("Day06")
// println(part1(input))
// println(part2(input))
}
fun firstNUniqueCharacters(signal: String, n: Int): Int {
val possiblePacketMarkers = signal.windowed(n)
.map { it.toSet() }
var lastPositionOfMarker = n
for (possiblePacketMarker in possiblePacketMarkers) {
if (possiblePacketMarker.size == n) {
break
}
lastPositionOfMarker++
}
return lastPositionOfMarker
}
|
[
{
"class_path": "GreyWolf2020__aoc-2022-in-kotlin__498da88/Day06Kt.class",
"javap": "Compiled from \"Day06.kt\"\npublic final class Day06Kt {\n public static final void main();\n Code:\n 0: return\n\n public static final int firstNUniqueCharacters(java.lang.String, int);\n Code:\n 0: aload_0\n 1: ldc #11 // String signal\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #19 // class java/lang/CharSequence\n 10: iload_1\n 11: iconst_0\n 12: iconst_0\n 13: bipush 6\n 15: aconst_null\n 16: invokestatic #25 // Method kotlin/text/StringsKt.windowed$default:(Ljava/lang/CharSequence;IIZILjava/lang/Object;)Ljava/util/List;\n 19: checkcast #27 // class java/lang/Iterable\n 22: astore_3\n 23: nop\n 24: iconst_0\n 25: istore 4\n 27: aload_3\n 28: astore 5\n 30: new #29 // class java/util/ArrayList\n 33: dup\n 34: aload_3\n 35: bipush 10\n 37: invokestatic #35 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 40: invokespecial #39 // Method java/util/ArrayList.\"<init>\":(I)V\n 43: checkcast #41 // class java/util/Collection\n 46: astore 6\n 48: iconst_0\n 49: istore 7\n 51: aload 5\n 53: invokeinterface #45, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 58: astore 8\n 60: aload 8\n 62: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 67: ifeq 113\n 70: aload 8\n 72: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 77: astore 9\n 79: aload 6\n 81: aload 9\n 83: checkcast #57 // class java/lang/String\n 86: astore 10\n 88: astore 12\n 90: iconst_0\n 91: istore 11\n 93: aload 10\n 95: checkcast #19 // class java/lang/CharSequence\n 98: invokestatic #61 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 101: aload 12\n 103: swap\n 104: invokeinterface #65, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 109: pop\n 110: goto 60\n 113: aload 6\n 115: checkcast #67 // class java/util/List\n 118: nop\n 119: astore_2\n 120: iload_1\n 121: istore_3\n 122: aload_2\n 123: invokeinterface #68, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 128: astore 4\n 130: aload 4\n 132: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 137: ifeq 172\n 140: aload 4\n 142: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 147: checkcast #70 // class java/util/Set\n 150: astore 5\n 152: aload 5\n 154: invokeinterface #74, 1 // InterfaceMethod java/util/Set.size:()I\n 159: iload_1\n 160: if_icmpne 166\n 163: goto 172\n 166: iinc 3, 1\n 169: goto 130\n 172: iload_3\n 173: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #96 // Method main:()V\n 3: return\n\n private static final int main$part1(java.lang.String, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: invokestatic #101 // Method firstNUniqueCharacters:(Ljava/lang/String;I)I\n 5: ireturn\n\n static int main$part1$default(java.lang.String, int, int, java.lang.Object);\n Code:\n 0: iload_2\n 1: iconst_2\n 2: iand\n 3: ifeq 8\n 6: iconst_4\n 7: istore_1\n 8: aload_0\n 9: iload_1\n 10: invokestatic #105 // Method main$part1:(Ljava/lang/String;I)I\n 13: ireturn\n\n private static final int main$part2(java.lang.String, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: invokestatic #101 // Method firstNUniqueCharacters:(Ljava/lang/String;I)I\n 5: ireturn\n\n static int main$part2$default(java.lang.String, int, int, java.lang.Object);\n Code:\n 0: iload_2\n 1: iconst_2\n 2: iand\n 3: ifeq 9\n 6: bipush 14\n 8: istore_1\n 9: aload_0\n 10: iload_1\n 11: invokestatic #109 // Method main$part2:(Ljava/lang/String;I)I\n 14: ireturn\n}\n",
"javap_err": ""
}
] |
GreyWolf2020__aoc-2022-in-kotlin__498da88/src/Day03.kt
|
fun main() {
fun itemPriority(c: Char): Int = when {
c.isLowerCase() -> c.code - 96
c.isUpperCase() -> c.code - 64 + 26
else -> 0
}
fun part1(input: List<String>): Int = input.foldRight(0) { rucksack, prioritySum ->
rucksack
.chunked(rucksack.length / 2)
.map {
it.toSet()
}
.intersection()
.map(::itemPriority)
.sum() + prioritySum
}
fun part2(input: List<String>): Int = input
.windowed(3, 3)
.foldRight(0) { threeRucksacks, prioritySum ->
threeRucksacks
.map { it.toSet() }
.intersection()
.map(::itemPriority)
.sum() + prioritySum
}
// test if implementation meets criteria from the description, like:
// val testInput = readInput("Day03_test")
// check(part1(testInput) == 157)
// check(part2(testInput) == 70)
//
// val input = readInput("Day03")
// println(part1(input))
// println(part2(input))
}
//
//fun List<Set<Char>>.intersection() = reduce { element, acc ->
// element.intersect(acc)
//}
private fun <A> List<Set<A>>.intersection(): Set<A> = reduce { element, acc ->
element.intersect(acc)
}
|
[
{
"class_path": "GreyWolf2020__aoc-2022-in-kotlin__498da88/Day03Kt.class",
"javap": "Compiled from \"Day03.kt\"\npublic final class Day03Kt {\n public static final void main();\n Code:\n 0: return\n\n private static final <A> java.util.Set<A> intersection(java.util.List<? extends java.util.Set<? extends A>>);\n Code:\n 0: aload_0\n 1: checkcast #11 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: invokeinterface #15, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore_3\n 14: aload_3\n 15: invokeinterface #21, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 20: ifne 33\n 23: new #23 // class java/lang/UnsupportedOperationException\n 26: dup\n 27: ldc #25 // String Empty collection can\\'t be reduced.\n 29: invokespecial #29 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 32: athrow\n 33: aload_3\n 34: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 39: astore 4\n 41: aload_3\n 42: invokeinterface #21, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 89\n 50: aload 4\n 52: aload_3\n 53: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: checkcast #35 // class java/util/Set\n 61: astore 5\n 63: checkcast #35 // class java/util/Set\n 66: astore 6\n 68: iconst_0\n 69: istore 7\n 71: aload 6\n 73: checkcast #11 // class java/lang/Iterable\n 76: aload 5\n 78: checkcast #11 // class java/lang/Iterable\n 81: invokestatic #41 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 84: astore 4\n 86: goto 41\n 89: aload 4\n 91: checkcast #35 // class java/util/Set\n 94: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #58 // Method main:()V\n 3: return\n\n private static final int main$itemPriority(char);\n Code:\n 0: nop\n 1: iload_0\n 2: invokestatic #68 // Method java/lang/Character.isLowerCase:(C)Z\n 5: ifeq 15\n 8: iload_0\n 9: bipush 96\n 11: isub\n 12: goto 33\n 15: iload_0\n 16: invokestatic #71 // Method java/lang/Character.isUpperCase:(C)Z\n 19: ifeq 32\n 22: iload_0\n 23: bipush 64\n 25: isub\n 26: bipush 26\n 28: iadd\n 29: goto 33\n 32: iconst_0\n 33: ireturn\n\n private static final int main$part1(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: iload_2\n 7: istore 4\n 9: aload_1\n 10: invokeinterface #81, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 15: ifne 303\n 18: aload_1\n 19: aload_1\n 20: invokeinterface #85, 1 // InterfaceMethod java/util/List.size:()I\n 25: invokeinterface #89, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 30: astore 5\n 32: aload 5\n 34: invokeinterface #94, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 39: ifeq 303\n 42: aload 5\n 44: invokeinterface #97, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 49: iload 4\n 51: istore 6\n 53: checkcast #99 // class java/lang/String\n 56: astore 7\n 58: iconst_0\n 59: istore 8\n 61: aload 7\n 63: checkcast #101 // class java/lang/CharSequence\n 66: aload 7\n 68: invokevirtual #104 // Method java/lang/String.length:()I\n 71: iconst_2\n 72: idiv\n 73: invokestatic #110 // Method kotlin/text/StringsKt.chunked:(Ljava/lang/CharSequence;I)Ljava/util/List;\n 76: checkcast #11 // class java/lang/Iterable\n 79: astore 9\n 81: nop\n 82: iconst_0\n 83: istore 10\n 85: aload 9\n 87: astore 11\n 89: new #112 // class java/util/ArrayList\n 92: dup\n 93: aload 9\n 95: bipush 10\n 97: invokestatic #116 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 100: invokespecial #119 // Method java/util/ArrayList.\"<init>\":(I)V\n 103: checkcast #121 // class java/util/Collection\n 106: astore 12\n 108: iconst_0\n 109: istore 13\n 111: aload 11\n 113: invokeinterface #15, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 118: astore 14\n 120: aload 14\n 122: invokeinterface #21, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 127: ifeq 173\n 130: aload 14\n 132: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 137: astore 15\n 139: aload 12\n 141: aload 15\n 143: checkcast #99 // class java/lang/String\n 146: astore 16\n 148: astore 17\n 150: iconst_0\n 151: istore 18\n 153: aload 16\n 155: checkcast #101 // class java/lang/CharSequence\n 158: invokestatic #125 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 161: aload 17\n 163: swap\n 164: invokeinterface #129, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 169: pop\n 170: goto 120\n 173: aload 12\n 175: checkcast #78 // class java/util/List\n 178: nop\n 179: invokestatic #131 // Method intersection:(Ljava/util/List;)Ljava/util/Set;\n 182: checkcast #11 // class java/lang/Iterable\n 185: astore 9\n 187: nop\n 188: iconst_0\n 189: istore 10\n 191: aload 9\n 193: astore 11\n 195: new #112 // class java/util/ArrayList\n 198: dup\n 199: aload 9\n 201: bipush 10\n 203: invokestatic #116 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 206: invokespecial #119 // Method java/util/ArrayList.\"<init>\":(I)V\n 209: checkcast #121 // class java/util/Collection\n 212: astore 12\n 214: iconst_0\n 215: istore 13\n 217: aload 11\n 219: invokeinterface #15, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 224: astore 14\n 226: aload 14\n 228: invokeinterface #21, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 233: ifeq 282\n 236: aload 14\n 238: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 243: astore 15\n 245: aload 12\n 247: aload 15\n 249: checkcast #64 // class java/lang/Character\n 252: invokevirtual #135 // Method java/lang/Character.charValue:()C\n 255: istore 16\n 257: astore 17\n 259: iconst_0\n 260: istore 18\n 262: iload 16\n 264: invokestatic #137 // Method main$itemPriority:(C)I\n 267: invokestatic #143 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 270: aload 17\n 272: swap\n 273: invokeinterface #129, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 278: pop\n 279: goto 226\n 282: aload 12\n 284: checkcast #78 // class java/util/List\n 287: nop\n 288: checkcast #11 // class java/lang/Iterable\n 291: invokestatic #147 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 294: iload 6\n 296: iadd\n 297: nop\n 298: istore 4\n 300: goto 32\n 303: iload 4\n 305: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #11 // class java/lang/Iterable\n 4: iconst_3\n 5: iconst_3\n 6: iconst_0\n 7: iconst_4\n 8: aconst_null\n 9: invokestatic #172 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;\n 12: astore_1\n 13: iconst_0\n 14: istore_2\n 15: iconst_0\n 16: istore_3\n 17: iload_2\n 18: istore 4\n 20: aload_1\n 21: invokeinterface #81, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 26: ifne 301\n 29: aload_1\n 30: aload_1\n 31: invokeinterface #85, 1 // InterfaceMethod java/util/List.size:()I\n 36: invokeinterface #89, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 41: astore 5\n 43: aload 5\n 45: invokeinterface #94, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 50: ifeq 301\n 53: aload 5\n 55: invokeinterface #97, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 60: iload 4\n 62: istore 6\n 64: checkcast #78 // class java/util/List\n 67: astore 7\n 69: iconst_0\n 70: istore 8\n 72: aload 7\n 74: checkcast #11 // class java/lang/Iterable\n 77: astore 9\n 79: nop\n 80: iconst_0\n 81: istore 10\n 83: aload 9\n 85: astore 11\n 87: new #112 // class java/util/ArrayList\n 90: dup\n 91: aload 9\n 93: bipush 10\n 95: invokestatic #116 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 98: invokespecial #119 // Method java/util/ArrayList.\"<init>\":(I)V\n 101: checkcast #121 // class java/util/Collection\n 104: astore 12\n 106: iconst_0\n 107: istore 13\n 109: aload 11\n 111: invokeinterface #15, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 116: astore 14\n 118: aload 14\n 120: invokeinterface #21, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 125: ifeq 171\n 128: aload 14\n 130: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 135: astore 15\n 137: aload 12\n 139: aload 15\n 141: checkcast #99 // class java/lang/String\n 144: astore 16\n 146: astore 17\n 148: iconst_0\n 149: istore 18\n 151: aload 16\n 153: checkcast #101 // class java/lang/CharSequence\n 156: invokestatic #125 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 159: aload 17\n 161: swap\n 162: invokeinterface #129, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 167: pop\n 168: goto 118\n 171: aload 12\n 173: checkcast #78 // class java/util/List\n 176: nop\n 177: invokestatic #131 // Method intersection:(Ljava/util/List;)Ljava/util/Set;\n 180: checkcast #11 // class java/lang/Iterable\n 183: astore 9\n 185: nop\n 186: iconst_0\n 187: istore 10\n 189: aload 9\n 191: astore 11\n 193: new #112 // class java/util/ArrayList\n 196: dup\n 197: aload 9\n 199: bipush 10\n 201: invokestatic #116 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 204: invokespecial #119 // Method java/util/ArrayList.\"<init>\":(I)V\n 207: checkcast #121 // class java/util/Collection\n 210: astore 12\n 212: iconst_0\n 213: istore 13\n 215: aload 11\n 217: invokeinterface #15, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 222: astore 14\n 224: aload 14\n 226: invokeinterface #21, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 231: ifeq 280\n 234: aload 14\n 236: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 241: astore 15\n 243: aload 12\n 245: aload 15\n 247: checkcast #64 // class java/lang/Character\n 250: invokevirtual #135 // Method java/lang/Character.charValue:()C\n 253: istore 16\n 255: astore 17\n 257: iconst_0\n 258: istore 18\n 260: iload 16\n 262: invokestatic #137 // Method main$itemPriority:(C)I\n 265: invokestatic #143 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 268: aload 17\n 270: swap\n 271: invokeinterface #129, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 276: pop\n 277: goto 224\n 280: aload 12\n 282: checkcast #78 // class java/util/List\n 285: nop\n 286: checkcast #11 // class java/lang/Iterable\n 289: invokestatic #147 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 292: iload 6\n 294: iadd\n 295: nop\n 296: istore 4\n 298: goto 43\n 301: iload 4\n 303: ireturn\n}\n",
"javap_err": ""
}
] |
GreyWolf2020__aoc-2022-in-kotlin__498da88/src/Day02.kt
|
/*enum class RockPaperScissorsPermutation(val result: Int) {
`A X`(3 + 1), `A Y`(6 + 2), `A Z`(0 + 3),
`B X`(0 + 1), `B Y`(3 + 2), `B Z`(6 + 3),
`C X`(6 + 1), `C Y`(0 + 2), `C Z`(3 + 3)
}*/
val RoPaScPermutations = mapOf<String, Int>(
"A X" to 3 + 1, "A Y" to 6 + 2, "A Z" to 0 + 3,
"B X" to 0 + 1, "B Y" to 3 + 2, "B Z" to 6 + 3,
"C X" to 6 + 1, "C Y" to 0 + 2, "C Z" to 3 + 3
)
val RoPaScPermElfStrategy = mapOf<String, Int>(
"A X" to 0 + 3, "A Y" to 3 + 1, "A Z" to 6 + 2,
"B X" to 0 + 1, "B Y" to 3 + 2, "B Z" to 6 + 3,
"C X" to 0 + 2, "C Y" to 3 + 3, "C Z" to 6 + 1
)
fun main() {
fun part1(input: List<String>): Int = input.foldRight(0) { singlePlayResult, acc ->
acc + RoPaScPermutations.getOrDefault(singlePlayResult, 0)
}
fun part2(input: List<String>): Int = input.foldRight(0) { singlePlayResult, acc ->
acc + RoPaScPermElfStrategy.getOrDefault(singlePlayResult, 0)
}
// test if implementation meets criteria from the description, like:
// val testInput = readInput("Day02_test")
// check(part1(testInput) == 15)
// check(part2(testInput) == 12)
//
// val input = readInput("Day02")
// println(part1(input))
// println(part2(input))
}
|
[
{
"class_path": "GreyWolf2020__aoc-2022-in-kotlin__498da88/Day02Kt.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class Day02Kt {\n private static final java.util.Map<java.lang.String, java.lang.Integer> RoPaScPermutations;\n\n private static final java.util.Map<java.lang.String, java.lang.Integer> RoPaScPermElfStrategy;\n\n public static final java.util.Map<java.lang.String, java.lang.Integer> getRoPaScPermutations();\n Code:\n 0: getstatic #12 // Field RoPaScPermutations:Ljava/util/Map;\n 3: areturn\n\n public static final java.util.Map<java.lang.String, java.lang.Integer> getRoPaScPermElfStrategy();\n Code:\n 0: getstatic #16 // Field RoPaScPermElfStrategy:Ljava/util/Map;\n 3: areturn\n\n public static final void main();\n Code:\n 0: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #21 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: astore_1\n 2: iconst_0\n 3: istore_2\n 4: iconst_0\n 5: istore_3\n 6: iload_2\n 7: istore 4\n 9: aload_1\n 10: invokeinterface #32, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 15: ifne 89\n 18: aload_1\n 19: aload_1\n 20: invokeinterface #36, 1 // InterfaceMethod java/util/List.size:()I\n 25: invokeinterface #40, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 30: astore 5\n 32: aload 5\n 34: invokeinterface #45, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 39: ifeq 89\n 42: aload 5\n 44: invokeinterface #49, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 49: iload 4\n 51: istore 6\n 53: checkcast #51 // class java/lang/String\n 56: astore 7\n 58: iconst_0\n 59: istore 8\n 61: iload 6\n 63: getstatic #12 // Field RoPaScPermutations:Ljava/util/Map;\n 66: aload 7\n 68: iconst_0\n 69: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 72: invokeinterface #63, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 77: checkcast #65 // class java/lang/Number\n 80: invokevirtual #68 // Method java/lang/Number.intValue:()I\n 83: iadd\n 84: istore 4\n 86: goto 32\n 89: iload 4\n 91: ireturn\n\n private static final int main$part2(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: iload_2\n 7: istore 4\n 9: aload_1\n 10: invokeinterface #32, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 15: ifne 89\n 18: aload_1\n 19: aload_1\n 20: invokeinterface #36, 1 // InterfaceMethod java/util/List.size:()I\n 25: invokeinterface #40, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 30: astore 5\n 32: aload 5\n 34: invokeinterface #45, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 39: ifeq 89\n 42: aload 5\n 44: invokeinterface #49, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 49: iload 4\n 51: istore 6\n 53: checkcast #51 // class java/lang/String\n 56: astore 7\n 58: iconst_0\n 59: istore 8\n 61: iload 6\n 63: getstatic #16 // Field RoPaScPermElfStrategy:Ljava/util/Map;\n 66: aload 7\n 68: iconst_0\n 69: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 72: invokeinterface #63, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 77: checkcast #65 // class java/lang/Number\n 80: invokevirtual #68 // Method java/lang/Number.intValue:()I\n 83: iadd\n 84: istore 4\n 86: goto 32\n 89: iload 4\n 91: ireturn\n\n static {};\n Code:\n 0: bipush 9\n 2: anewarray #86 // class kotlin/Pair\n 5: astore_0\n 6: aload_0\n 7: iconst_0\n 8: ldc #88 // String A X\n 10: iconst_4\n 11: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 14: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 17: aastore\n 18: aload_0\n 19: iconst_1\n 20: ldc #96 // String A Y\n 22: bipush 8\n 24: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 27: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 30: aastore\n 31: aload_0\n 32: iconst_2\n 33: ldc #98 // String A Z\n 35: iconst_3\n 36: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 39: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 42: aastore\n 43: aload_0\n 44: iconst_3\n 45: ldc #100 // String B X\n 47: iconst_1\n 48: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 51: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 54: aastore\n 55: aload_0\n 56: iconst_4\n 57: ldc #102 // String B Y\n 59: iconst_5\n 60: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 63: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 66: aastore\n 67: aload_0\n 68: iconst_5\n 69: ldc #104 // String B Z\n 71: bipush 9\n 73: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 76: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 79: aastore\n 80: aload_0\n 81: bipush 6\n 83: ldc #106 // String C X\n 85: bipush 7\n 87: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 90: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 93: aastore\n 94: aload_0\n 95: bipush 7\n 97: ldc #108 // String C Y\n 99: iconst_2\n 100: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 103: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 106: aastore\n 107: aload_0\n 108: bipush 8\n 110: ldc #110 // String C Z\n 112: bipush 6\n 114: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 117: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 120: aastore\n 121: aload_0\n 122: invokestatic #116 // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 125: putstatic #12 // Field RoPaScPermutations:Ljava/util/Map;\n 128: bipush 9\n 130: anewarray #86 // class kotlin/Pair\n 133: astore_0\n 134: aload_0\n 135: iconst_0\n 136: ldc #88 // String A X\n 138: iconst_3\n 139: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 142: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 145: aastore\n 146: aload_0\n 147: iconst_1\n 148: ldc #96 // String A Y\n 150: iconst_4\n 151: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 154: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 157: aastore\n 158: aload_0\n 159: iconst_2\n 160: ldc #98 // String A Z\n 162: bipush 8\n 164: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 167: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 170: aastore\n 171: aload_0\n 172: iconst_3\n 173: ldc #100 // String B X\n 175: iconst_1\n 176: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 179: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 182: aastore\n 183: aload_0\n 184: iconst_4\n 185: ldc #102 // String B Y\n 187: iconst_5\n 188: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 191: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 194: aastore\n 195: aload_0\n 196: iconst_5\n 197: ldc #104 // String B Z\n 199: bipush 9\n 201: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 204: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 207: aastore\n 208: aload_0\n 209: bipush 6\n 211: ldc #106 // String C X\n 213: iconst_2\n 214: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 217: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 220: aastore\n 221: aload_0\n 222: bipush 7\n 224: ldc #108 // String C Y\n 226: bipush 6\n 228: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 231: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 234: aastore\n 235: aload_0\n 236: bipush 8\n 238: ldc #110 // String C Z\n 240: bipush 7\n 242: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 245: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 248: aastore\n 249: aload_0\n 250: invokestatic #116 // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 253: putstatic #16 // Field RoPaScPermElfStrategy:Ljava/util/Map;\n 256: return\n}\n",
"javap_err": ""
}
] |
GreyWolf2020__aoc-2022-in-kotlin__498da88/src/Day10.kt
|
fun main() {
fun part1(input: List<String>): Int {
val cycleForSignalStrength = mutableListOf<Int>(20, 60, 100, 140, 180, 220)
val register = Register()
val clock = Clock().apply { addProcessors(register) }
val signalStrength = buildList {
input
.forEach { instruction ->
register
.parseInstruction(instruction)
while (!register.isInstructionDone) {
clock.incrementCycle()
if (cycleForSignalStrength.isNotEmpty() && clock.cycle == cycleForSignalStrength.first()) {
add(Pair(cycleForSignalStrength.removeFirst(), register.value))
}
}
register.executeInstruction()
}
}
clock.removeProcessor(register)
return signalStrength
.sumOf { it.first * it.second }
}
fun part2(input: List<String>): Int {
val register = Register()
val clock = Clock().apply { addProcessors(register) }
val crtAllPixels = buildList {
input
.forEach { instruction ->
register
.parseInstruction(instruction)
while (!register.isInstructionDone) {
val crtCurrentPosition = (clock.cycle) % 40
val sprite = register.value - 1 .. register.value + 1
if (crtCurrentPosition in sprite)
add("#")
else add(".")
clock.incrementCycle()
}
register.executeInstruction()
}
}
clock.removeProcessor(register)
return crtAllPixels
.also { drawCrtAllPixels(it) }
.also { println() }
.filter { it == "#" }
.size
}
// test if implementation meets criteria from the description, like:
// val testInput = readInput("Day10_test")
// check(part1(testInput) == 13140)
// check(part2(testInput) == 124)
//
// val input = readInput("Day10")
// println(part1(input))
// println(part2(input))
}
interface Processor {
fun process()
}
data class Clock(var cycle: Int = 0) {
val processors = mutableListOf<Processor>()
fun incrementCycle() {
cycle++
processors.forEach { processor -> processor.process() }
}
fun addProcessors(processor: Processor) {
if (!processors.contains(processor))
processors.add(processor)
}
fun removeProcessor(processor: Processor) {
if (!processors.contains(processor))
processors.remove(processor)
}
}
class Register(var value: Int = 1) : Processor {
sealed class Instruction(var cyclesLeft: Int, val valueToAdd: Int) {
data class Noop(val value: Int = 0): Instruction(1, value)
data class AddX(val value: Int): Instruction(2, value)
}
val isInstructionDone: Boolean
get() = currentInstruction.cyclesLeft == 0
lateinit var currentInstruction: Instruction
override fun process() {
currentInstruction.cyclesLeft--
}
fun executeInstruction() {
value += currentInstruction.valueToAdd
}
}
fun Register.parseInstruction(instruction: String) {
val noopOrAddX = instruction.split(" ")
when (noopOrAddX.first()) {
"noop" -> currentInstruction = Register.Instruction.Noop()
"addx" -> currentInstruction = Register.Instruction.AddX(noopOrAddX.last().toInt())
}
}
fun drawCrtAllPixels(crtAllPixels: List<String>) {
crtAllPixels.forEachIndexed { index, pixel ->
if ((index) % 40 == 0)
println()
print(pixel)
}
}
|
[
{
"class_path": "GreyWolf2020__aoc-2022-in-kotlin__498da88/Day10Kt.class",
"javap": "Compiled from \"Day10.kt\"\npublic final class Day10Kt {\n public static final void main();\n Code:\n 0: return\n\n public static final void parseInstruction(Register, java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #11 // String <this>\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #19 // String instruction\n 9: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: checkcast #21 // class java/lang/CharSequence\n 16: iconst_1\n 17: anewarray #23 // class java/lang/String\n 20: astore_3\n 21: aload_3\n 22: iconst_0\n 23: ldc #25 // String\n 25: aastore\n 26: aload_3\n 27: iconst_0\n 28: iconst_0\n 29: bipush 6\n 31: aconst_null\n 32: invokestatic #31 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 35: astore_2\n 36: aload_2\n 37: invokestatic #37 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 40: checkcast #23 // class java/lang/String\n 43: astore_3\n 44: aload_3\n 45: ldc #39 // String noop\n 47: invokestatic #43 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 50: ifeq 73\n 53: aload_0\n 54: new #45 // class Register$Instruction$Noop\n 57: dup\n 58: iconst_0\n 59: iconst_1\n 60: aconst_null\n 61: invokespecial #49 // Method Register$Instruction$Noop.\"<init>\":(IILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 64: checkcast #51 // class Register$Instruction\n 67: invokevirtual #57 // Method Register.setCurrentInstruction:(LRegister$Instruction;)V\n 70: goto 106\n 73: aload_3\n 74: ldc #59 // String addx\n 76: invokestatic #43 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 79: ifeq 106\n 82: aload_0\n 83: new #61 // class Register$Instruction$AddX\n 86: dup\n 87: aload_2\n 88: invokestatic #64 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 91: checkcast #23 // class java/lang/String\n 94: invokestatic #70 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 97: invokespecial #73 // Method Register$Instruction$AddX.\"<init>\":(I)V\n 100: checkcast #51 // class Register$Instruction\n 103: invokevirtual #57 // Method Register.setCurrentInstruction:(LRegister$Instruction;)V\n 106: return\n\n public static final void drawCrtAllPixels(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #85 // String crtAllPixels\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #87 // class java/lang/Iterable\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: iconst_0\n 14: istore_3\n 15: aload_1\n 16: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 21: astore 4\n 23: aload 4\n 25: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 30: ifeq 97\n 33: aload 4\n 35: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 40: astore 5\n 42: iload_3\n 43: iinc 3, 1\n 46: istore 6\n 48: iload 6\n 50: ifge 56\n 53: invokestatic #104 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 56: iload 6\n 58: aload 5\n 60: checkcast #23 // class java/lang/String\n 63: astore 7\n 65: istore 8\n 67: iconst_0\n 68: istore 9\n 70: iload 8\n 72: bipush 40\n 74: irem\n 75: ifne 84\n 78: getstatic #110 // Field java/lang/System.out:Ljava/io/PrintStream;\n 81: invokevirtual #115 // Method java/io/PrintStream.println:()V\n 84: getstatic #110 // Field java/lang/System.out:Ljava/io/PrintStream;\n 87: aload 7\n 89: invokevirtual #119 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 92: nop\n 93: nop\n 94: goto 23\n 97: nop\n 98: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #132 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: bipush 6\n 2: anewarray #66 // class java/lang/Integer\n 5: astore_2\n 6: aload_2\n 7: iconst_0\n 8: bipush 20\n 10: invokestatic #141 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 13: aastore\n 14: aload_2\n 15: iconst_1\n 16: bipush 60\n 18: invokestatic #141 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 21: aastore\n 22: aload_2\n 23: iconst_2\n 24: bipush 100\n 26: invokestatic #141 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 29: aastore\n 30: aload_2\n 31: iconst_3\n 32: sipush 140\n 35: invokestatic #141 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 38: aastore\n 39: aload_2\n 40: iconst_4\n 41: sipush 180\n 44: invokestatic #141 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 47: aastore\n 48: aload_2\n 49: iconst_5\n 50: sipush 220\n 53: invokestatic #141 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 56: aastore\n 57: aload_2\n 58: invokestatic #145 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 61: astore_1\n 62: new #53 // class Register\n 65: dup\n 66: iconst_0\n 67: iconst_1\n 68: aconst_null\n 69: invokespecial #146 // Method Register.\"<init>\":(IILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 72: astore_2\n 73: new #148 // class Clock\n 76: dup\n 77: iconst_0\n 78: iconst_1\n 79: aconst_null\n 80: invokespecial #149 // Method Clock.\"<init>\":(IILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 83: astore 4\n 85: aload 4\n 87: astore 5\n 89: iconst_0\n 90: istore 6\n 92: aload 5\n 94: aload_2\n 95: checkcast #151 // class Processor\n 98: invokevirtual #155 // Method Clock.addProcessors:(LProcessor;)V\n 101: aload 4\n 103: astore_3\n 104: invokestatic #159 // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;\n 107: astore 5\n 109: aload 5\n 111: astore 6\n 113: iconst_0\n 114: istore 7\n 116: aload_0\n 117: checkcast #87 // class java/lang/Iterable\n 120: astore 8\n 122: nop\n 123: iconst_0\n 124: istore 9\n 126: aload 8\n 128: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 133: astore 10\n 135: aload 10\n 137: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 142: ifeq 258\n 145: aload 10\n 147: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 152: astore 11\n 154: aload 11\n 156: checkcast #23 // class java/lang/String\n 159: astore 12\n 161: iconst_0\n 162: istore 13\n 164: aload_2\n 165: aload 12\n 167: invokestatic #161 // Method parseInstruction:(LRegister;Ljava/lang/String;)V\n 170: aload_2\n 171: invokevirtual #164 // Method Register.isInstructionDone:()Z\n 174: ifne 249\n 177: aload_3\n 178: invokevirtual #167 // Method Clock.incrementCycle:()V\n 181: aload_1\n 182: checkcast #169 // class java/util/Collection\n 185: invokeinterface #172, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 190: ifne 197\n 193: iconst_1\n 194: goto 198\n 197: iconst_0\n 198: ifeq 170\n 201: aload_3\n 202: invokevirtual #176 // Method Clock.getCycle:()I\n 205: aload_1\n 206: invokestatic #37 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 209: checkcast #178 // class java/lang/Number\n 212: invokevirtual #181 // Method java/lang/Number.intValue:()I\n 215: if_icmpne 170\n 218: aload 6\n 220: new #183 // class kotlin/Pair\n 223: dup\n 224: aload_1\n 225: invokeinterface #186, 1 // InterfaceMethod java/util/List.removeFirst:()Ljava/lang/Object;\n 230: aload_2\n 231: invokevirtual #189 // Method Register.getValue:()I\n 234: invokestatic #141 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 237: invokespecial #192 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 240: invokeinterface #196, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 245: pop\n 246: goto 170\n 249: aload_2\n 250: invokevirtual #199 // Method Register.executeInstruction:()V\n 253: nop\n 254: nop\n 255: goto 135\n 258: nop\n 259: nop\n 260: aload 5\n 262: invokestatic #203 // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;\n 265: astore 4\n 267: aload_3\n 268: aload_2\n 269: checkcast #151 // class Processor\n 272: invokevirtual #206 // Method Clock.removeProcessor:(LProcessor;)V\n 275: aload 4\n 277: checkcast #87 // class java/lang/Iterable\n 280: astore 5\n 282: iconst_0\n 283: istore 6\n 285: aload 5\n 287: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 292: astore 7\n 294: aload 7\n 296: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 301: ifeq 362\n 304: aload 7\n 306: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 311: astore 8\n 313: iload 6\n 315: aload 8\n 317: checkcast #183 // class kotlin/Pair\n 320: astore 9\n 322: istore 14\n 324: iconst_0\n 325: istore 10\n 327: aload 9\n 329: invokevirtual #209 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 332: checkcast #178 // class java/lang/Number\n 335: invokevirtual #181 // Method java/lang/Number.intValue:()I\n 338: aload 9\n 340: invokevirtual #212 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 343: checkcast #178 // class java/lang/Number\n 346: invokevirtual #181 // Method java/lang/Number.intValue:()I\n 349: imul\n 350: istore 15\n 352: iload 14\n 354: iload 15\n 356: iadd\n 357: istore 6\n 359: goto 294\n 362: iload 6\n 364: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: new #53 // class Register\n 3: dup\n 4: iconst_0\n 5: iconst_1\n 6: aconst_null\n 7: invokespecial #146 // Method Register.\"<init>\":(IILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 10: astore_1\n 11: new #148 // class Clock\n 14: dup\n 15: iconst_0\n 16: iconst_1\n 17: aconst_null\n 18: invokespecial #149 // Method Clock.\"<init>\":(IILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 21: astore_3\n 22: aload_3\n 23: astore 4\n 25: iconst_0\n 26: istore 5\n 28: aload 4\n 30: aload_1\n 31: checkcast #151 // class Processor\n 34: invokevirtual #155 // Method Clock.addProcessors:(LProcessor;)V\n 37: aload_3\n 38: astore_2\n 39: invokestatic #159 // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;\n 42: astore 4\n 44: aload 4\n 46: astore 5\n 48: iconst_0\n 49: istore 6\n 51: aload_0\n 52: checkcast #87 // class java/lang/Iterable\n 55: astore 7\n 57: nop\n 58: iconst_0\n 59: istore 8\n 61: aload 7\n 63: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 68: astore 9\n 70: aload 9\n 72: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 77: ifeq 216\n 80: aload 9\n 82: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 87: astore 10\n 89: aload 10\n 91: checkcast #23 // class java/lang/String\n 94: astore 11\n 96: iconst_0\n 97: istore 12\n 99: aload_1\n 100: aload 11\n 102: invokestatic #161 // Method parseInstruction:(LRegister;Ljava/lang/String;)V\n 105: aload_1\n 106: invokevirtual #164 // Method Register.isInstructionDone:()Z\n 109: ifne 207\n 112: aload_2\n 113: invokevirtual #176 // Method Clock.getCycle:()I\n 116: bipush 40\n 118: irem\n 119: istore 13\n 121: new #232 // class kotlin/ranges/IntRange\n 124: dup\n 125: aload_1\n 126: invokevirtual #189 // Method Register.getValue:()I\n 129: iconst_1\n 130: isub\n 131: aload_1\n 132: invokevirtual #189 // Method Register.getValue:()I\n 135: iconst_1\n 136: iadd\n 137: invokespecial #235 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 140: astore 14\n 142: aload 14\n 144: invokevirtual #237 // Method kotlin/ranges/IntRange.getFirst:()I\n 147: istore 15\n 149: iload 13\n 151: aload 14\n 153: invokevirtual #240 // Method kotlin/ranges/IntRange.getLast:()I\n 156: if_icmpgt 174\n 159: iload 15\n 161: iload 13\n 163: if_icmpgt 170\n 166: iconst_1\n 167: goto 175\n 170: iconst_0\n 171: goto 175\n 174: iconst_0\n 175: ifeq 190\n 178: aload 5\n 180: ldc #242 // String #\n 182: invokeinterface #196, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 187: goto 199\n 190: aload 5\n 192: ldc #244 // String .\n 194: invokeinterface #196, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 199: pop\n 200: aload_2\n 201: invokevirtual #167 // Method Clock.incrementCycle:()V\n 204: goto 105\n 207: aload_1\n 208: invokevirtual #199 // Method Register.executeInstruction:()V\n 211: nop\n 212: nop\n 213: goto 70\n 216: nop\n 217: nop\n 218: aload 4\n 220: invokestatic #203 // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;\n 223: astore_3\n 224: aload_2\n 225: aload_1\n 226: checkcast #151 // class Processor\n 229: invokevirtual #206 // Method Clock.removeProcessor:(LProcessor;)V\n 232: aload_3\n 233: astore 4\n 235: aload 4\n 237: astore 5\n 239: iconst_0\n 240: istore 6\n 242: aload 5\n 244: invokestatic #246 // Method drawCrtAllPixels:(Ljava/util/List;)V\n 247: aload 4\n 249: astore 4\n 251: aload 4\n 253: astore 5\n 255: iconst_0\n 256: istore 6\n 258: getstatic #110 // Field java/lang/System.out:Ljava/io/PrintStream;\n 261: invokevirtual #115 // Method java/io/PrintStream.println:()V\n 264: nop\n 265: aload 4\n 267: checkcast #87 // class java/lang/Iterable\n 270: astore 4\n 272: nop\n 273: iconst_0\n 274: istore 5\n 276: aload 4\n 278: astore 6\n 280: new #248 // class java/util/ArrayList\n 283: dup\n 284: invokespecial #250 // Method java/util/ArrayList.\"<init>\":()V\n 287: checkcast #169 // class java/util/Collection\n 290: astore 7\n 292: iconst_0\n 293: istore 8\n 295: aload 6\n 297: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 302: astore 9\n 304: aload 9\n 306: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 311: ifeq 356\n 314: aload 9\n 316: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 321: astore 10\n 323: aload 10\n 325: checkcast #23 // class java/lang/String\n 328: astore 11\n 330: iconst_0\n 331: istore 12\n 333: aload 11\n 335: ldc #242 // String #\n 337: invokestatic #43 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 340: ifeq 304\n 343: aload 7\n 345: aload 10\n 347: invokeinterface #251, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 352: pop\n 353: goto 304\n 356: aload 7\n 358: checkcast #80 // class java/util/List\n 361: nop\n 362: invokeinterface #254, 1 // InterfaceMethod java/util/List.size:()I\n 367: ireturn\n}\n",
"javap_err": ""
}
] |
GreyWolf2020__aoc-2022-in-kotlin__498da88/src/Day08.kt
|
import java.lang.StrictMath.max
fun main() {
fun part1(input: List<String>): Int {
val treesGraph = AdjacencyList<Int>()
val verticesOfTreeHeight = treesGraph.parseVertices(input)
return verticesOfTreeHeight
.fold(0) { acc, vertex ->
if (vertex `is max in all directions of` treesGraph)
acc + 1
else
acc
}
}
fun part2(input: List<String>): Int {
val treesGraph = AdjacencyList<Int>()
val verticesOfTreeHeight = treesGraph.parseVertices(input)
return verticesOfTreeHeight
.fold(Int.MIN_VALUE) { maxScenicScoreSoFar, vertex ->
max(
maxScenicScoreSoFar,
vertex `scenic score` treesGraph
)
}
}
// test if implementation meets criteria from the description, like:
/* val testInput = readInput("Day08_test")
check(part1(testInput) == 21)
check(part2(testInput) == 8)
val input = readInput("Day08")
println(part1(input))
println(part2(input))*/
}
data class Vertex<T>(
val index: Int,
val data: T
)
data class Edge<T>(
val source: Vertex<T>,
val destination: Vertex<T>,
val direction: Graph.EdgeType,
val weight: Double?
)
interface Graph<T> {
fun createVertex(data: T): Vertex<T>
fun addDirectedEdge(
source: Vertex<T>,
destination: Vertex<T>,
direction: EdgeType,
weight: Double?,
)
fun addUndirectedEdge(
source: Vertex<T>,
destination: Vertex<T>,
direction: EdgeType,
weight: Double?
)
fun add(
edge: EdgeType,
source: Vertex<T>,
destination: Vertex<T>,
weight: Double?
)
fun edges(source: Vertex<T>): Map<EdgeType,Edge<T>>
fun weight(
source: Vertex<T>,
destination: Vertex<T>
) : Double?
enum class EdgeType {
RIGHT,
LEFT,
ABOVE,
BELOW
}
}
fun Graph.EdgeType.opposite(): Graph.EdgeType = when(this) {
Graph.EdgeType.RIGHT -> Graph.EdgeType.LEFT
Graph.EdgeType.LEFT -> Graph.EdgeType.RIGHT
Graph.EdgeType.ABOVE -> Graph.EdgeType.BELOW
Graph.EdgeType.BELOW -> Graph.EdgeType.ABOVE
}
class AdjacencyList <T> : Graph<T> {
private val adjacencies: HashMap<Vertex<T>, MutableMap<Graph.EdgeType,Edge<T>>> = HashMap()
override fun createVertex(data: T): Vertex<T> {
val vertex = Vertex(adjacencies.count(), data)
adjacencies[vertex] = mutableMapOf()
return vertex
}
override fun addDirectedEdge(
source: Vertex<T>,
destination: Vertex<T>,
direction: Graph.EdgeType,
weight: Double?
) {
val edge = Edge(source, destination, direction, weight)
adjacencies[source]?.put(edge.direction, edge)
}
override fun addUndirectedEdge(
source: Vertex<T>,
destination: Vertex<T>,
direction: Graph.EdgeType,
weight: Double?
) {
addDirectedEdge(source, destination, direction, weight)
addDirectedEdge(destination, source, direction.opposite(), weight)
}
override fun add(edge: Graph.EdgeType, source: Vertex<T>, destination: Vertex<T>, weight: Double?) = addUndirectedEdge(source, destination, edge, weight)
override fun edges(source: Vertex<T>): Map<Graph.EdgeType, Edge<T>> = adjacencies[source] ?: mutableMapOf<Graph.EdgeType, Edge<T>>()
override fun weight(source: Vertex<T>, destination: Vertex<T>): Double? {
return edges(source).map { it.value }.firstOrNull { it.destination == destination }?.weight
}
override fun toString(): String {
return buildString { // 1
adjacencies.forEach { (vertex, edges) -> // 2
val edgeString = edges
.map {Pair(it.key,it.value)}.joinToString { it.second.destination.data.toString() + " " + it.first.toString()} // 3
append("${vertex.data} ---> [ $edgeString ]\n") // 4
}
}
}
}
fun AdjacencyList<Int>.parseVertices(verticesData: List<String>): List<Vertex<Int>> {
val verticesDataMatrix = verticesData.map { verticesDataRow ->
verticesDataRow
.chunked(1)
.map { treeHeight ->
treeHeight.toInt()
}
}
val verticesDataRow = verticesDataMatrix.first().size
val verticesDataColumn = verticesDataMatrix.size
val verticesLastRow = verticesDataRow * verticesDataColumn + 1 - verticesDataRow .. verticesDataRow * verticesDataColumn
val verticesList = verticesDataMatrix
.flatten()
.map {
createVertex(it)
}
for (vertex in verticesList) {
val vertexPosition = vertex.index + 1
if (vertexPosition % verticesDataRow != 0) {
add(Graph.EdgeType.RIGHT, vertex, verticesList[vertex.index + 1], null)
}
if (vertexPosition !in verticesLastRow) {
add(Graph.EdgeType.BELOW, vertex, verticesList[vertex.index + verticesDataRow], null)
}
}
return verticesList
}
fun Vertex<Int>.isMax(graph: Graph<Int>, direction: Graph.EdgeType): Boolean {
tailrec fun go(direction: Graph.EdgeType, vert: Vertex< Int>, maxSoFar: Int): Int {
val destinationVertex = graph.edges(vert)[direction]?.destination
return if (destinationVertex == null)
maxSoFar
else go(direction, destinationVertex, max(maxSoFar, destinationVertex.data))
}
val isMaximum by lazy {
this.data > go(direction, this, Integer.MIN_VALUE)
}
return isMaximum
}
infix fun Vertex<Int>.`is max in all directions of`(graph: Graph<Int>): Boolean = isMax(graph, Graph.EdgeType.RIGHT) ||
isMax(graph, Graph.EdgeType.LEFT) ||
isMax(graph, Graph.EdgeType.ABOVE) ||
isMax(graph, Graph.EdgeType.BELOW)
fun Vertex<Int>.countToImmediateMax(graph: Graph<Int>, direction: Graph.EdgeType): Int {
fun Int.go(direction: Graph.EdgeType, vert: Vertex<Int>, smallerImmediateVerticesCount: Int): Int {
val destinationVertex = graph.edges(vert)[direction]?.destination
return when {
destinationVertex == null -> smallerImmediateVerticesCount
destinationVertex.data >= this -> smallerImmediateVerticesCount + 1
else -> go(direction, destinationVertex, smallerImmediateVerticesCount + 1)
}
}
return data.go(direction, this, 0)
}
infix fun Vertex<Int>.`scenic score`(graph: Graph<Int>): Int = countToImmediateMax(graph, Graph.EdgeType.RIGHT) *
countToImmediateMax(graph, Graph.EdgeType.LEFT) *
countToImmediateMax(graph, Graph.EdgeType.ABOVE) *
countToImmediateMax(graph, Graph.EdgeType.BELOW)
|
[
{
"class_path": "GreyWolf2020__aoc-2022-in-kotlin__498da88/Day08Kt$WhenMappings.class",
"javap": "Compiled from \"Day08.kt\"\npublic final class Day08Kt$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method Graph$EdgeType.values:()[LGraph$EdgeType;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field Graph$EdgeType.RIGHT:LGraph$EdgeType;\n 12: invokevirtual #22 // Method Graph$EdgeType.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 Graph$EdgeType.LEFT:LGraph$EdgeType;\n 26: invokevirtual #22 // Method Graph$EdgeType.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 Graph$EdgeType.ABOVE:LGraph$EdgeType;\n 40: invokevirtual #22 // Method Graph$EdgeType.ordinal:()I\n 43: iconst_3\n 44: iastore\n 45: goto 49\n 48: astore_1\n 49: nop\n 50: aload_0\n 51: getstatic #31 // Field Graph$EdgeType.BELOW:LGraph$EdgeType;\n 54: invokevirtual #22 // Method Graph$EdgeType.ordinal:()I\n 57: iconst_4\n 58: iastore\n 59: goto 63\n 62: astore_1\n 63: aload_0\n 64: putstatic #35 // Field $EnumSwitchMapping$0:[I\n 67: return\n Exception table:\n from to target type\n 7 17 20 Class java/lang/NoSuchFieldError\n 21 31 34 Class java/lang/NoSuchFieldError\n 35 45 48 Class java/lang/NoSuchFieldError\n 49 59 62 Class java/lang/NoSuchFieldError\n}\n",
"javap_err": ""
},
{
"class_path": "GreyWolf2020__aoc-2022-in-kotlin__498da88/Day08Kt.class",
"javap": "Compiled from \"Day08.kt\"\npublic final class Day08Kt {\n public static final void main();\n Code:\n 0: return\n\n public static final Graph$EdgeType opposite(Graph$EdgeType);\n Code:\n 0: aload_0\n 1: ldc #11 // String <this>\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getstatic #23 // Field Day08Kt$WhenMappings.$EnumSwitchMapping$0:[I\n 10: swap\n 11: invokevirtual #29 // Method Graph$EdgeType.ordinal:()I\n 14: iaload\n 15: tableswitch { // 1 to 4\n 1: 44\n 2: 50\n 3: 56\n 4: 62\n default: 68\n }\n 44: getstatic #33 // Field Graph$EdgeType.LEFT:LGraph$EdgeType;\n 47: goto 76\n 50: getstatic #36 // Field Graph$EdgeType.RIGHT:LGraph$EdgeType;\n 53: goto 76\n 56: getstatic #39 // Field Graph$EdgeType.BELOW:LGraph$EdgeType;\n 59: goto 76\n 62: getstatic #42 // Field Graph$EdgeType.ABOVE:LGraph$EdgeType;\n 65: goto 76\n 68: new #44 // class kotlin/NoWhenBranchMatchedException\n 71: dup\n 72: invokespecial #47 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 75: athrow\n 76: areturn\n\n public static final java.util.List<Vertex<java.lang.Integer>> parseVertices(AdjacencyList<java.lang.Integer>, java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #11 // String <this>\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #53 // String verticesData\n 9: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: checkcast #55 // class java/lang/Iterable\n 16: astore_3\n 17: iconst_0\n 18: istore 4\n 20: aload_3\n 21: astore 5\n 23: new #57 // class java/util/ArrayList\n 26: dup\n 27: aload_3\n 28: bipush 10\n 30: invokestatic #63 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 33: invokespecial #66 // Method java/util/ArrayList.\"<init>\":(I)V\n 36: checkcast #68 // class java/util/Collection\n 39: astore 6\n 41: iconst_0\n 42: istore 7\n 44: aload 5\n 46: invokeinterface #72, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 51: astore 8\n 53: aload 8\n 55: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 60: ifeq 212\n 63: aload 8\n 65: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 70: astore 9\n 72: aload 6\n 74: aload 9\n 76: checkcast #84 // class java/lang/String\n 79: astore 10\n 81: astore 22\n 83: iconst_0\n 84: istore 11\n 86: aload 10\n 88: checkcast #86 // class java/lang/CharSequence\n 91: iconst_1\n 92: invokestatic #92 // Method kotlin/text/StringsKt.chunked:(Ljava/lang/CharSequence;I)Ljava/util/List;\n 95: checkcast #55 // class java/lang/Iterable\n 98: astore 12\n 100: nop\n 101: iconst_0\n 102: istore 13\n 104: aload 12\n 106: astore 14\n 108: new #57 // class java/util/ArrayList\n 111: dup\n 112: aload 12\n 114: bipush 10\n 116: invokestatic #63 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 119: invokespecial #66 // Method java/util/ArrayList.\"<init>\":(I)V\n 122: checkcast #68 // class java/util/Collection\n 125: astore 15\n 127: iconst_0\n 128: istore 16\n 130: aload 14\n 132: invokeinterface #72, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 137: astore 17\n 139: aload 17\n 141: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 146: ifeq 193\n 149: aload 17\n 151: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 156: astore 18\n 158: aload 15\n 160: aload 18\n 162: checkcast #84 // class java/lang/String\n 165: astore 19\n 167: astore 20\n 169: iconst_0\n 170: istore 21\n 172: aload 19\n 174: invokestatic #98 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 177: nop\n 178: invokestatic #102 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 181: aload 20\n 183: swap\n 184: invokeinterface #106, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 189: pop\n 190: goto 139\n 193: aload 15\n 195: checkcast #108 // class java/util/List\n 198: nop\n 199: nop\n 200: aload 22\n 202: swap\n 203: invokeinterface #106, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 208: pop\n 209: goto 53\n 212: aload 6\n 214: checkcast #108 // class java/util/List\n 217: nop\n 218: astore_2\n 219: aload_2\n 220: invokestatic #112 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 223: checkcast #108 // class java/util/List\n 226: invokeinterface #115, 1 // InterfaceMethod java/util/List.size:()I\n 231: istore_3\n 232: aload_2\n 233: invokeinterface #115, 1 // InterfaceMethod java/util/List.size:()I\n 238: istore 4\n 240: new #117 // class kotlin/ranges/IntRange\n 243: dup\n 244: iload_3\n 245: iload 4\n 247: imul\n 248: iconst_1\n 249: iadd\n 250: iload_3\n 251: isub\n 252: iload_3\n 253: iload 4\n 255: imul\n 256: invokespecial #120 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 259: astore 5\n 261: aload_2\n 262: checkcast #55 // class java/lang/Iterable\n 265: invokestatic #124 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 268: checkcast #55 // class java/lang/Iterable\n 271: astore 7\n 273: nop\n 274: iconst_0\n 275: istore 8\n 277: aload 7\n 279: astore 9\n 281: new #57 // class java/util/ArrayList\n 284: dup\n 285: aload 7\n 287: bipush 10\n 289: invokestatic #63 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 292: invokespecial #66 // Method java/util/ArrayList.\"<init>\":(I)V\n 295: checkcast #68 // class java/util/Collection\n 298: astore 10\n 300: iconst_0\n 301: istore 11\n 303: aload 9\n 305: invokeinterface #72, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 310: astore 12\n 312: aload 12\n 314: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 319: ifeq 369\n 322: aload 12\n 324: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 329: astore 13\n 331: aload 10\n 333: aload 13\n 335: checkcast #126 // class java/lang/Number\n 338: invokevirtual #129 // Method java/lang/Number.intValue:()I\n 341: istore 14\n 343: astore 22\n 345: iconst_0\n 346: istore 15\n 348: aload_0\n 349: iload 14\n 351: invokestatic #102 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 354: invokevirtual #135 // Method AdjacencyList.createVertex:(Ljava/lang/Object;)LVertex;\n 357: aload 22\n 359: swap\n 360: invokeinterface #106, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 365: pop\n 366: goto 312\n 369: aload 10\n 371: checkcast #108 // class java/util/List\n 374: nop\n 375: astore 6\n 377: aload 6\n 379: invokeinterface #136, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 384: astore 7\n 386: aload 7\n 388: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 393: ifeq 517\n 396: aload 7\n 398: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 403: checkcast #138 // class Vertex\n 406: astore 8\n 408: aload 8\n 410: invokevirtual #141 // Method Vertex.getIndex:()I\n 413: iconst_1\n 414: iadd\n 415: istore 9\n 417: iload 9\n 419: iload_3\n 420: irem\n 421: ifeq 451\n 424: aload_0\n 425: getstatic #36 // Field Graph$EdgeType.RIGHT:LGraph$EdgeType;\n 428: aload 8\n 430: aload 6\n 432: aload 8\n 434: invokevirtual #141 // Method Vertex.getIndex:()I\n 437: iconst_1\n 438: iadd\n 439: invokeinterface #145, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 444: checkcast #138 // class Vertex\n 447: aconst_null\n 448: invokevirtual #148 // Method AdjacencyList.add:(LGraph$EdgeType;LVertex;LVertex;Ljava/lang/Double;)V\n 451: aload 5\n 453: invokevirtual #151 // Method kotlin/ranges/IntRange.getFirst:()I\n 456: istore 10\n 458: iload 9\n 460: aload 5\n 462: invokevirtual #154 // Method kotlin/ranges/IntRange.getLast:()I\n 465: if_icmpgt 483\n 468: iload 10\n 470: iload 9\n 472: if_icmpgt 479\n 475: iconst_1\n 476: goto 484\n 479: iconst_0\n 480: goto 484\n 483: iconst_0\n 484: ifne 386\n 487: aload_0\n 488: getstatic #39 // Field Graph$EdgeType.BELOW:LGraph$EdgeType;\n 491: aload 8\n 493: aload 6\n 495: aload 8\n 497: invokevirtual #141 // Method Vertex.getIndex:()I\n 500: iload_3\n 501: iadd\n 502: invokeinterface #145, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 507: checkcast #138 // class Vertex\n 510: aconst_null\n 511: invokevirtual #148 // Method AdjacencyList.add:(LGraph$EdgeType;LVertex;LVertex;Ljava/lang/Double;)V\n 514: goto 386\n 517: aload 6\n 519: areturn\n\n public static final boolean isMax(Vertex<java.lang.Integer>, Graph<java.lang.Integer>, Graph$EdgeType);\n Code:\n 0: aload_0\n 1: ldc #11 // String <this>\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #187 // String graph\n 9: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_2\n 13: ldc #189 // String direction\n 15: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: aload_0\n 19: aload_2\n 20: aload_1\n 21: invokedynamic #208, 0 // InvokeDynamic #0:invoke:(LVertex;LGraph$EdgeType;LGraph;)Lkotlin/jvm/functions/Function0;\n 26: invokestatic #214 // Method kotlin/LazyKt.lazy:(Lkotlin/jvm/functions/Function0;)Lkotlin/Lazy;\n 29: astore_3\n 30: aload_3\n 31: invokestatic #218 // Method isMax$lambda$6:(Lkotlin/Lazy;)Z\n 34: ireturn\n\n public static final boolean is max in all directions of(Vertex<java.lang.Integer>, Graph<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #11 // String <this>\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #187 // String graph\n 9: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: aload_1\n 14: getstatic #36 // Field Graph$EdgeType.RIGHT:LGraph$EdgeType;\n 17: invokestatic #227 // Method isMax:(LVertex;LGraph;LGraph$EdgeType;)Z\n 20: ifne 56\n 23: aload_0\n 24: aload_1\n 25: getstatic #33 // Field Graph$EdgeType.LEFT:LGraph$EdgeType;\n 28: invokestatic #227 // Method isMax:(LVertex;LGraph;LGraph$EdgeType;)Z\n 31: ifne 56\n 34: aload_0\n 35: aload_1\n 36: getstatic #42 // Field Graph$EdgeType.ABOVE:LGraph$EdgeType;\n 39: invokestatic #227 // Method isMax:(LVertex;LGraph;LGraph$EdgeType;)Z\n 42: ifne 56\n 45: aload_0\n 46: aload_1\n 47: getstatic #39 // Field Graph$EdgeType.BELOW:LGraph$EdgeType;\n 50: invokestatic #227 // Method isMax:(LVertex;LGraph;LGraph$EdgeType;)Z\n 53: ifeq 60\n 56: iconst_1\n 57: goto 61\n 60: iconst_0\n 61: ireturn\n\n public static final int countToImmediateMax(Vertex<java.lang.Integer>, Graph<java.lang.Integer>, Graph$EdgeType);\n Code:\n 0: aload_0\n 1: ldc #11 // String <this>\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #187 // String graph\n 9: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_2\n 13: ldc #189 // String direction\n 15: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: aload_0\n 19: invokevirtual #234 // Method Vertex.getData:()Ljava/lang/Object;\n 22: checkcast #126 // class java/lang/Number\n 25: invokevirtual #129 // Method java/lang/Number.intValue:()I\n 28: aload_1\n 29: aload_2\n 30: aload_0\n 31: iconst_0\n 32: invokestatic #238 // Method countToImmediateMax$go$7:(ILGraph;LGraph$EdgeType;LVertex;I)I\n 35: ireturn\n\n public static final int scenic score(Vertex<java.lang.Integer>, Graph<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #11 // String <this>\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #187 // String graph\n 9: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: aload_1\n 14: getstatic #36 // Field Graph$EdgeType.RIGHT:LGraph$EdgeType;\n 17: invokestatic #244 // Method countToImmediateMax:(LVertex;LGraph;LGraph$EdgeType;)I\n 20: aload_0\n 21: aload_1\n 22: getstatic #33 // Field Graph$EdgeType.LEFT:LGraph$EdgeType;\n 25: invokestatic #244 // Method countToImmediateMax:(LVertex;LGraph;LGraph$EdgeType;)I\n 28: imul\n 29: aload_0\n 30: aload_1\n 31: getstatic #42 // Field Graph$EdgeType.ABOVE:LGraph$EdgeType;\n 34: invokestatic #244 // Method countToImmediateMax:(LVertex;LGraph;LGraph$EdgeType;)I\n 37: imul\n 38: aload_0\n 39: aload_1\n 40: getstatic #39 // Field Graph$EdgeType.BELOW:LGraph$EdgeType;\n 43: invokestatic #244 // Method countToImmediateMax:(LVertex;LGraph;LGraph$EdgeType;)I\n 46: imul\n 47: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #248 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: new #131 // class AdjacencyList\n 3: dup\n 4: invokespecial #254 // Method AdjacencyList.\"<init>\":()V\n 7: astore_1\n 8: aload_1\n 9: aload_0\n 10: invokestatic #256 // Method parseVertices:(LAdjacencyList;Ljava/util/List;)Ljava/util/List;\n 13: astore_2\n 14: aload_2\n 15: checkcast #55 // class java/lang/Iterable\n 18: astore_3\n 19: iconst_0\n 20: istore 4\n 22: iconst_0\n 23: istore 5\n 25: iload 4\n 27: istore 6\n 29: aload_3\n 30: invokeinterface #72, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 35: astore 7\n 37: aload 7\n 39: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 44: ifeq 96\n 47: aload 7\n 49: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 54: astore 8\n 56: iload 6\n 58: aload 8\n 60: checkcast #138 // class Vertex\n 63: astore 9\n 65: istore 10\n 67: iconst_0\n 68: istore 11\n 70: aload 9\n 72: aload_1\n 73: checkcast #258 // class Graph\n 76: invokestatic #260 // Method \"is max in all directions of\":(LVertex;LGraph;)Z\n 79: ifeq 89\n 82: iload 10\n 84: iconst_1\n 85: iadd\n 86: goto 91\n 89: iload 10\n 91: istore 6\n 93: goto 37\n 96: iload 6\n 98: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: new #131 // class AdjacencyList\n 3: dup\n 4: invokespecial #254 // Method AdjacencyList.\"<init>\":()V\n 7: astore_1\n 8: aload_1\n 9: aload_0\n 10: invokestatic #256 // Method parseVertices:(LAdjacencyList;Ljava/util/List;)Ljava/util/List;\n 13: astore_2\n 14: aload_2\n 15: checkcast #55 // class java/lang/Iterable\n 18: astore_3\n 19: ldc_w #272 // int -2147483648\n 22: istore 4\n 24: iconst_0\n 25: istore 5\n 27: iload 4\n 29: istore 6\n 31: aload_3\n 32: invokeinterface #72, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 37: astore 7\n 39: aload 7\n 41: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 46: ifeq 92\n 49: aload 7\n 51: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 56: astore 8\n 58: iload 6\n 60: aload 8\n 62: checkcast #138 // class Vertex\n 65: astore 9\n 67: istore 10\n 69: iconst_0\n 70: istore 11\n 72: iload 10\n 74: aload 9\n 76: aload_1\n 77: checkcast #258 // class Graph\n 80: invokestatic #274 // Method \"scenic score\":(LVertex;LGraph;)I\n 83: invokestatic #280 // Method java/lang/StrictMath.max:(II)I\n 86: nop\n 87: istore 6\n 89: goto 39\n 92: iload 6\n 94: ireturn\n\n private static final int isMax$go(Graph<java.lang.Integer>, Graph$EdgeType, Vertex<java.lang.Integer>, int);\n Code:\n 0: aload_0\n 1: aload_2\n 2: invokeinterface #289, 2 // InterfaceMethod Graph.edges:(LVertex;)Ljava/util/Map;\n 7: aload_1\n 8: invokeinterface #294, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 13: checkcast #296 // class Edge\n 16: dup\n 17: ifnull 26\n 20: invokevirtual #300 // Method Edge.getDestination:()LVertex;\n 23: goto 28\n 26: pop\n 27: aconst_null\n 28: astore 4\n 30: aload 4\n 32: ifnonnull 39\n 35: iload_3\n 36: goto 71\n 39: aload_1\n 40: astore 5\n 42: iload_3\n 43: aload 4\n 45: invokevirtual #234 // Method Vertex.getData:()Ljava/lang/Object;\n 48: checkcast #126 // class java/lang/Number\n 51: invokevirtual #129 // Method java/lang/Number.intValue:()I\n 54: invokestatic #280 // Method java/lang/StrictMath.max:(II)I\n 57: istore 6\n 59: aload 5\n 61: astore_1\n 62: aload 4\n 64: astore_2\n 65: iload 6\n 67: istore_3\n 68: goto 0\n 71: ireturn\n\n private static final boolean isMax$lambda$5(Vertex, Graph$EdgeType, Graph);\n Code:\n 0: aload_0\n 1: invokevirtual #234 // Method Vertex.getData:()Ljava/lang/Object;\n 4: checkcast #126 // class java/lang/Number\n 7: invokevirtual #129 // Method java/lang/Number.intValue:()I\n 10: aload_2\n 11: aload_1\n 12: aload_0\n 13: ldc_w #272 // int -2147483648\n 16: invokestatic #306 // Method isMax$go:(LGraph;LGraph$EdgeType;LVertex;I)I\n 19: if_icmple 26\n 22: iconst_1\n 23: goto 27\n 26: iconst_0\n 27: ireturn\n\n private static final boolean isMax$lambda$6(kotlin.Lazy<java.lang.Boolean>);\n Code:\n 0: aload_0\n 1: astore_1\n 2: aload_1\n 3: invokeinterface #314, 1 // InterfaceMethod kotlin/Lazy.getValue:()Ljava/lang/Object;\n 8: checkcast #316 // class java/lang/Boolean\n 11: invokevirtual #319 // Method java/lang/Boolean.booleanValue:()Z\n 14: ireturn\n\n private static final int countToImmediateMax$go$7(int, Graph<java.lang.Integer>, Graph$EdgeType, Vertex<java.lang.Integer>, int);\n Code:\n 0: aload_1\n 1: aload_3\n 2: invokeinterface #289, 2 // InterfaceMethod Graph.edges:(LVertex;)Ljava/util/Map;\n 7: aload_2\n 8: invokeinterface #294, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 13: checkcast #296 // class Edge\n 16: dup\n 17: ifnull 26\n 20: invokevirtual #300 // Method Edge.getDestination:()LVertex;\n 23: goto 28\n 26: pop\n 27: aconst_null\n 28: astore 5\n 30: nop\n 31: aload 5\n 33: ifnonnull 41\n 36: iload 4\n 38: goto 75\n 41: aload 5\n 43: invokevirtual #234 // Method Vertex.getData:()Ljava/lang/Object;\n 46: checkcast #126 // class java/lang/Number\n 49: invokevirtual #129 // Method java/lang/Number.intValue:()I\n 52: iload_0\n 53: if_icmplt 63\n 56: iload 4\n 58: iconst_1\n 59: iadd\n 60: goto 75\n 63: iload_0\n 64: aload_1\n 65: aload_2\n 66: aload 5\n 68: iload 4\n 70: iconst_1\n 71: iadd\n 72: invokestatic #238 // Method countToImmediateMax$go$7:(ILGraph;LGraph$EdgeType;LVertex;I)I\n 75: ireturn\n}\n",
"javap_err": ""
}
] |
GreyWolf2020__aoc-2022-in-kotlin__498da88/src/Day09.kt
|
import java.lang.Math.abs
fun main() {
fun part1(headKnotMotionsData: List<String>): Int {
val tail = Knot("tail")
val head = Knot("head")
tail `join to follow` head
headKnotMotionsData
.map { it.split(" ") }
.forEach {
val direction = it.first()
val magnitude = it.last().toInt()
head
.appendMove(direction, magnitude)
head.execute()
}
tail `unjoin so as not to follow` head
return tail
.positions
.distinct()
.also {
it.map(::println)
}
.size
}
fun part2(headKnotMotionsData: List<String>): Int {
val head = Knot("head")
val tailOne = Knot("tailOne")
val tailTwo = Knot("tailTwo")
val tailThree = Knot("tailThree")
val tailFour = Knot("tailFour")
val tailFive = Knot("tailFive")
val tailSix = Knot("tailSix")
val tailSeven = Knot("tailSeven")
val tailEight = Knot("tailEight")
val tailNine = Knot("tailNine")
tailOne `join to follow` head
tailTwo `join to follow` tailOne
tailThree `join to follow` tailTwo
tailFour `join to follow` tailThree
tailFive `join to follow` tailFour
tailSix `join to follow` tailFive
tailSeven `join to follow` tailSix
tailEight `join to follow` tailSeven
tailNine `join to follow` tailEight
headKnotMotionsData
.map { it.split(" ") }
.forEach {
val direction = it.first()
val magnitude = it.last().toInt()
head
.appendMove(direction, magnitude)
}
head.execute()
tailOne `unjoin so as not to follow` head
tailTwo `unjoin so as not to follow` tailOne
tailThree `unjoin so as not to follow` tailTwo
tailFour `unjoin so as not to follow` tailThree
tailFive `unjoin so as not to follow` tailFour
tailSix `unjoin so as not to follow` tailFive
tailSeven `unjoin so as not to follow` tailSix
tailEight `unjoin so as not to follow` tailSeven
tailNine `unjoin so as not to follow` tailEight
return tailNine
.positions
.distinct()
.also {
it.map(::println)
}
.size
}
// test if implementation meets criteria from the description, like:
/* val testInput = readInput("Day09_test")
check(part1(testInput) == 13)
// testInputTwo is the larger example on the AOC website day 09 challenge of 2022
val testInputTwo = readInput("Day09_test_two")
check(part2(testInputTwo) == 36)
check(part2(testInput) == 1)
val input = readInput("Day09")
println(part1(input))
println(part2(input))*/
}
typealias Command = () -> Unit
data class Position(val x: Int, val y: Int)
class Knot(
val name: String,
var _xPosition: Int = 0,
var _yPosition: Int = 0
) {
private val orders = mutableListOf<Command>()
private val _positions = mutableListOf<Position>()
val positions
get() = _positions.toList()
val followers: HashMap<String, Knot> = HashMap()
val moveGenerator = fun(
knot: Knot,
direction: String,
qnty: Int
): Command {
return fun() {
when (direction) {
"R" -> repeat(qnty) { knot.toRight() }
"L" -> repeat(qnty) { knot.toLeft() }
"U" -> repeat(qnty) { knot.toUp() }
"D" -> repeat(qnty) { knot.toDown() }
else -> {}
}
}
}
init {
appendOrigin()
}
fun xPosition(xPosition: Int) { _xPosition = xPosition }
fun yPosition(yPosition: Int) { _yPosition = yPosition }
fun appendMove(direction: String, qnty: Int) = apply {
orders.add(moveGenerator(this, direction, qnty))
}
fun appendOrigin() {
_positions.add(Position(0, 0))
}
private fun toLeft() {
_xPosition--
moved()
}
private fun toRight() {
_xPosition++
moved()
}
private fun toDown() {
_yPosition--
moved()
}
private fun toUp() {
_yPosition++
moved()
}
fun moved() {
_positions.add(Position(_xPosition, _yPosition))
for ((_, follower) in followers) {
follower.follow(this)
}
}
fun execute() {
while (!orders.isEmpty()) {
val order = orders.removeAt(0)
order.invoke()
println("$name x -> $_xPosition y -> $_yPosition")
}
}
fun follow(leader: Knot) {
val deltaX = abs(leader._xPosition - this._xPosition)
val deltaY = abs(leader._yPosition - this._yPosition)
val xDirection = if (leader._xPosition - _xPosition > 0) "R" else "L"
val yDirection = if (leader._yPosition - _yPosition > 0) "U" else "D"
when {
deltaX > 1 && deltaY > 0 || deltaY > 1 && deltaX > 0 -> {
moveDiagonally(xDirection, yDirection)
moved()
}
deltaX > 1 -> appendMove(xDirection, deltaX - 1).execute()
deltaY > 1 -> appendMove(yDirection, deltaY - 1).execute()
}
}
fun moveDiagonally(xDirection: String, yDirection: String) {
when {
xDirection == "L" -> _xPosition--
xDirection == "R" -> _xPosition++
}
when {
yDirection == "U" -> _yPosition++
yDirection == "D" -> _yPosition--
}
/*
appendMove(xDirection, 1)
.appendMove(yDirection, 1)
.execute()*/
}
}
infix fun Knot.`join to follow`(head: Knot) {
head.followers.put(this.name, this)
println("${head.name} has a new follower $name")
}
infix fun Knot.`unjoin so as not to follow`(head: Knot) {
head.followers.remove(name)
println("${head.name} has been unfollowed by $name")
}
|
[
{
"class_path": "GreyWolf2020__aoc-2022-in-kotlin__498da88/Day09Kt.class",
"javap": "Compiled from \"Day09.kt\"\npublic final class Day09Kt {\n public static final void main();\n Code:\n 0: return\n\n public static final void join to follow(Knot, Knot);\n Code:\n 0: aload_0\n 1: ldc #11 // String <this>\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #19 // String head\n 9: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: invokevirtual #25 // Method Knot.getFollowers:()Ljava/util/HashMap;\n 16: aload_0\n 17: invokevirtual #29 // Method Knot.getName:()Ljava/lang/String;\n 20: aload_0\n 21: invokevirtual #35 // Method java/util/HashMap.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 24: pop\n 25: new #37 // class java/lang/StringBuilder\n 28: dup\n 29: invokespecial #40 // Method java/lang/StringBuilder.\"<init>\":()V\n 32: aload_1\n 33: invokevirtual #29 // Method Knot.getName:()Ljava/lang/String;\n 36: invokevirtual #44 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 39: ldc #46 // String has a new follower\n 41: invokevirtual #44 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 44: aload_0\n 45: invokevirtual #29 // Method Knot.getName:()Ljava/lang/String;\n 48: invokevirtual #44 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: invokevirtual #49 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 54: getstatic #55 // Field java/lang/System.out:Ljava/io/PrintStream;\n 57: swap\n 58: invokevirtual #61 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 61: return\n\n public static final void unjoin so as not to follow(Knot, Knot);\n Code:\n 0: aload_0\n 1: ldc #11 // String <this>\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #19 // String head\n 9: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: invokevirtual #25 // Method Knot.getFollowers:()Ljava/util/HashMap;\n 16: aload_0\n 17: invokevirtual #29 // Method Knot.getName:()Ljava/lang/String;\n 20: invokevirtual #68 // Method java/util/HashMap.remove:(Ljava/lang/Object;)Ljava/lang/Object;\n 23: pop\n 24: new #37 // class java/lang/StringBuilder\n 27: dup\n 28: invokespecial #40 // Method java/lang/StringBuilder.\"<init>\":()V\n 31: aload_1\n 32: invokevirtual #29 // Method Knot.getName:()Ljava/lang/String;\n 35: invokevirtual #44 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 38: ldc #70 // String has been unfollowed by\n 40: invokevirtual #44 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 43: aload_0\n 44: invokevirtual #29 // Method Knot.getName:()Ljava/lang/String;\n 47: invokevirtual #44 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 50: invokevirtual #49 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 53: getstatic #55 // Field java/lang/System.out:Ljava/io/PrintStream;\n 56: swap\n 57: invokevirtual #61 // 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 #74 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: new #21 // class Knot\n 3: dup\n 4: ldc #81 // String tail\n 6: iconst_0\n 7: iconst_0\n 8: bipush 6\n 10: aconst_null\n 11: invokespecial #84 // Method Knot.\"<init>\":(Ljava/lang/String;IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 14: astore_1\n 15: new #21 // class Knot\n 18: dup\n 19: ldc #19 // String head\n 21: iconst_0\n 22: iconst_0\n 23: bipush 6\n 25: aconst_null\n 26: invokespecial #84 // Method Knot.\"<init>\":(Ljava/lang/String;IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 29: astore_2\n 30: aload_1\n 31: aload_2\n 32: invokestatic #86 // Method \"join to follow\":(LKnot;LKnot;)V\n 35: aload_0\n 36: checkcast #88 // class java/lang/Iterable\n 39: astore_3\n 40: nop\n 41: iconst_0\n 42: istore 4\n 44: aload_3\n 45: astore 5\n 47: new #90 // class java/util/ArrayList\n 50: dup\n 51: aload_3\n 52: bipush 10\n 54: invokestatic #96 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 57: invokespecial #99 // Method java/util/ArrayList.\"<init>\":(I)V\n 60: checkcast #101 // class java/util/Collection\n 63: astore 6\n 65: iconst_0\n 66: istore 7\n 68: aload 5\n 70: invokeinterface #105, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 75: astore 8\n 77: aload 8\n 79: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 84: ifeq 149\n 87: aload 8\n 89: invokeinterface #115, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 94: astore 9\n 96: aload 6\n 98: aload 9\n 100: checkcast #117 // class java/lang/String\n 103: astore 10\n 105: astore 16\n 107: iconst_0\n 108: istore 11\n 110: aload 10\n 112: checkcast #119 // class java/lang/CharSequence\n 115: iconst_1\n 116: anewarray #117 // class java/lang/String\n 119: astore 12\n 121: aload 12\n 123: iconst_0\n 124: ldc #121 // String\n 126: aastore\n 127: aload 12\n 129: iconst_0\n 130: iconst_0\n 131: bipush 6\n 133: aconst_null\n 134: invokestatic #127 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 137: aload 16\n 139: swap\n 140: invokeinterface #131, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 145: pop\n 146: goto 77\n 149: aload 6\n 151: checkcast #133 // class java/util/List\n 154: nop\n 155: checkcast #88 // class java/lang/Iterable\n 158: astore_3\n 159: nop\n 160: iconst_0\n 161: istore 4\n 163: aload_3\n 164: invokeinterface #105, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 169: astore 5\n 171: aload 5\n 173: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 178: ifeq 241\n 181: aload 5\n 183: invokeinterface #115, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 188: astore 6\n 190: aload 6\n 192: checkcast #133 // class java/util/List\n 195: astore 7\n 197: iconst_0\n 198: istore 8\n 200: aload 7\n 202: invokestatic #137 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 205: checkcast #117 // class java/lang/String\n 208: astore 9\n 210: aload 7\n 212: invokestatic #140 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 215: checkcast #117 // class java/lang/String\n 218: invokestatic #146 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 221: istore 10\n 223: aload_2\n 224: aload 9\n 226: iload 10\n 228: invokevirtual #150 // Method Knot.appendMove:(Ljava/lang/String;I)LKnot;\n 231: pop\n 232: aload_2\n 233: invokevirtual #153 // Method Knot.execute:()V\n 236: nop\n 237: nop\n 238: goto 171\n 241: nop\n 242: aload_1\n 243: aload_2\n 244: invokestatic #155 // Method \"unjoin so as not to follow\":(LKnot;LKnot;)V\n 247: aload_1\n 248: invokevirtual #159 // Method Knot.getPositions:()Ljava/util/List;\n 251: checkcast #88 // class java/lang/Iterable\n 254: invokestatic #163 // Method kotlin/collections/CollectionsKt.distinct:(Ljava/lang/Iterable;)Ljava/util/List;\n 257: astore_3\n 258: aload_3\n 259: astore 4\n 261: iconst_0\n 262: istore 5\n 264: aload 4\n 266: checkcast #88 // class java/lang/Iterable\n 269: astore 6\n 271: iconst_0\n 272: istore 7\n 274: aload 6\n 276: astore 8\n 278: new #90 // class java/util/ArrayList\n 281: dup\n 282: aload 6\n 284: bipush 10\n 286: invokestatic #96 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 289: invokespecial #99 // Method java/util/ArrayList.\"<init>\":(I)V\n 292: checkcast #101 // class java/util/Collection\n 295: astore 9\n 297: iconst_0\n 298: istore 10\n 300: aload 8\n 302: invokeinterface #105, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 307: astore 11\n 309: aload 11\n 311: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 316: ifeq 362\n 319: aload 11\n 321: invokeinterface #115, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 326: astore 12\n 328: aload 9\n 330: aload 12\n 332: astore 13\n 334: astore 14\n 336: iconst_0\n 337: istore 15\n 339: getstatic #55 // Field java/lang/System.out:Ljava/io/PrintStream;\n 342: aload 13\n 344: invokevirtual #61 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 347: nop\n 348: aload 14\n 350: getstatic #169 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 353: invokeinterface #131, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 358: pop\n 359: goto 309\n 362: aload 9\n 364: checkcast #133 // class java/util/List\n 367: nop\n 368: pop\n 369: nop\n 370: aload_3\n 371: invokeinterface #173, 1 // InterfaceMethod java/util/List.size:()I\n 376: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: new #21 // class Knot\n 3: dup\n 4: ldc #19 // String head\n 6: iconst_0\n 7: iconst_0\n 8: bipush 6\n 10: aconst_null\n 11: invokespecial #84 // Method Knot.\"<init>\":(Ljava/lang/String;IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 14: astore_1\n 15: new #21 // class Knot\n 18: dup\n 19: ldc #200 // String tailOne\n 21: iconst_0\n 22: iconst_0\n 23: bipush 6\n 25: aconst_null\n 26: invokespecial #84 // Method Knot.\"<init>\":(Ljava/lang/String;IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 29: astore_2\n 30: new #21 // class Knot\n 33: dup\n 34: ldc #202 // String tailTwo\n 36: iconst_0\n 37: iconst_0\n 38: bipush 6\n 40: aconst_null\n 41: invokespecial #84 // Method Knot.\"<init>\":(Ljava/lang/String;IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 44: astore_3\n 45: new #21 // class Knot\n 48: dup\n 49: ldc #204 // String tailThree\n 51: iconst_0\n 52: iconst_0\n 53: bipush 6\n 55: aconst_null\n 56: invokespecial #84 // Method Knot.\"<init>\":(Ljava/lang/String;IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 59: astore 4\n 61: new #21 // class Knot\n 64: dup\n 65: ldc #206 // String tailFour\n 67: iconst_0\n 68: iconst_0\n 69: bipush 6\n 71: aconst_null\n 72: invokespecial #84 // Method Knot.\"<init>\":(Ljava/lang/String;IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 75: astore 5\n 77: new #21 // class Knot\n 80: dup\n 81: ldc #208 // String tailFive\n 83: iconst_0\n 84: iconst_0\n 85: bipush 6\n 87: aconst_null\n 88: invokespecial #84 // Method Knot.\"<init>\":(Ljava/lang/String;IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 91: astore 6\n 93: new #21 // class Knot\n 96: dup\n 97: ldc #210 // String tailSix\n 99: iconst_0\n 100: iconst_0\n 101: bipush 6\n 103: aconst_null\n 104: invokespecial #84 // Method Knot.\"<init>\":(Ljava/lang/String;IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 107: astore 7\n 109: new #21 // class Knot\n 112: dup\n 113: ldc #212 // String tailSeven\n 115: iconst_0\n 116: iconst_0\n 117: bipush 6\n 119: aconst_null\n 120: invokespecial #84 // Method Knot.\"<init>\":(Ljava/lang/String;IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 123: astore 8\n 125: new #21 // class Knot\n 128: dup\n 129: ldc #214 // String tailEight\n 131: iconst_0\n 132: iconst_0\n 133: bipush 6\n 135: aconst_null\n 136: invokespecial #84 // Method Knot.\"<init>\":(Ljava/lang/String;IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 139: astore 9\n 141: new #21 // class Knot\n 144: dup\n 145: ldc #216 // String tailNine\n 147: iconst_0\n 148: iconst_0\n 149: bipush 6\n 151: aconst_null\n 152: invokespecial #84 // Method Knot.\"<init>\":(Ljava/lang/String;IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 155: astore 10\n 157: aload_2\n 158: aload_1\n 159: invokestatic #86 // Method \"join to follow\":(LKnot;LKnot;)V\n 162: aload_3\n 163: aload_2\n 164: invokestatic #86 // Method \"join to follow\":(LKnot;LKnot;)V\n 167: aload 4\n 169: aload_3\n 170: invokestatic #86 // Method \"join to follow\":(LKnot;LKnot;)V\n 173: aload 5\n 175: aload 4\n 177: invokestatic #86 // Method \"join to follow\":(LKnot;LKnot;)V\n 180: aload 6\n 182: aload 5\n 184: invokestatic #86 // Method \"join to follow\":(LKnot;LKnot;)V\n 187: aload 7\n 189: aload 6\n 191: invokestatic #86 // Method \"join to follow\":(LKnot;LKnot;)V\n 194: aload 8\n 196: aload 7\n 198: invokestatic #86 // Method \"join to follow\":(LKnot;LKnot;)V\n 201: aload 9\n 203: aload 8\n 205: invokestatic #86 // Method \"join to follow\":(LKnot;LKnot;)V\n 208: aload 10\n 210: aload 9\n 212: invokestatic #86 // Method \"join to follow\":(LKnot;LKnot;)V\n 215: aload_0\n 216: checkcast #88 // class java/lang/Iterable\n 219: astore 11\n 221: nop\n 222: iconst_0\n 223: istore 12\n 225: aload 11\n 227: astore 13\n 229: new #90 // class java/util/ArrayList\n 232: dup\n 233: aload 11\n 235: bipush 10\n 237: invokestatic #96 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 240: invokespecial #99 // Method java/util/ArrayList.\"<init>\":(I)V\n 243: checkcast #101 // class java/util/Collection\n 246: astore 14\n 248: iconst_0\n 249: istore 15\n 251: aload 13\n 253: invokeinterface #105, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 258: astore 16\n 260: aload 16\n 262: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 267: ifeq 332\n 270: aload 16\n 272: invokeinterface #115, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 277: astore 17\n 279: aload 14\n 281: aload 17\n 283: checkcast #117 // class java/lang/String\n 286: astore 18\n 288: astore 24\n 290: iconst_0\n 291: istore 19\n 293: aload 18\n 295: checkcast #119 // class java/lang/CharSequence\n 298: iconst_1\n 299: anewarray #117 // class java/lang/String\n 302: astore 20\n 304: aload 20\n 306: iconst_0\n 307: ldc #121 // String\n 309: aastore\n 310: aload 20\n 312: iconst_0\n 313: iconst_0\n 314: bipush 6\n 316: aconst_null\n 317: invokestatic #127 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 320: aload 24\n 322: swap\n 323: invokeinterface #131, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 328: pop\n 329: goto 260\n 332: aload 14\n 334: checkcast #133 // class java/util/List\n 337: nop\n 338: checkcast #88 // class java/lang/Iterable\n 341: astore 11\n 343: nop\n 344: iconst_0\n 345: istore 12\n 347: aload 11\n 349: invokeinterface #105, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 354: astore 13\n 356: aload 13\n 358: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 363: ifeq 422\n 366: aload 13\n 368: invokeinterface #115, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 373: astore 14\n 375: aload 14\n 377: checkcast #133 // class java/util/List\n 380: astore 15\n 382: iconst_0\n 383: istore 16\n 385: aload 15\n 387: invokestatic #137 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 390: checkcast #117 // class java/lang/String\n 393: astore 17\n 395: aload 15\n 397: invokestatic #140 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 400: checkcast #117 // class java/lang/String\n 403: invokestatic #146 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 406: istore 18\n 408: aload_1\n 409: aload 17\n 411: iload 18\n 413: invokevirtual #150 // Method Knot.appendMove:(Ljava/lang/String;I)LKnot;\n 416: pop\n 417: nop\n 418: nop\n 419: goto 356\n 422: nop\n 423: aload_1\n 424: invokevirtual #153 // Method Knot.execute:()V\n 427: aload_2\n 428: aload_1\n 429: invokestatic #155 // Method \"unjoin so as not to follow\":(LKnot;LKnot;)V\n 432: aload_3\n 433: aload_2\n 434: invokestatic #155 // Method \"unjoin so as not to follow\":(LKnot;LKnot;)V\n 437: aload 4\n 439: aload_3\n 440: invokestatic #155 // Method \"unjoin so as not to follow\":(LKnot;LKnot;)V\n 443: aload 5\n 445: aload 4\n 447: invokestatic #155 // Method \"unjoin so as not to follow\":(LKnot;LKnot;)V\n 450: aload 6\n 452: aload 5\n 454: invokestatic #155 // Method \"unjoin so as not to follow\":(LKnot;LKnot;)V\n 457: aload 7\n 459: aload 6\n 461: invokestatic #155 // Method \"unjoin so as not to follow\":(LKnot;LKnot;)V\n 464: aload 8\n 466: aload 7\n 468: invokestatic #155 // Method \"unjoin so as not to follow\":(LKnot;LKnot;)V\n 471: aload 9\n 473: aload 8\n 475: invokestatic #155 // Method \"unjoin so as not to follow\":(LKnot;LKnot;)V\n 478: aload 10\n 480: aload 9\n 482: invokestatic #155 // Method \"unjoin so as not to follow\":(LKnot;LKnot;)V\n 485: aload 10\n 487: invokevirtual #159 // Method Knot.getPositions:()Ljava/util/List;\n 490: checkcast #88 // class java/lang/Iterable\n 493: invokestatic #163 // Method kotlin/collections/CollectionsKt.distinct:(Ljava/lang/Iterable;)Ljava/util/List;\n 496: astore 11\n 498: aload 11\n 500: astore 12\n 502: iconst_0\n 503: istore 13\n 505: aload 12\n 507: checkcast #88 // class java/lang/Iterable\n 510: astore 14\n 512: iconst_0\n 513: istore 15\n 515: aload 14\n 517: astore 16\n 519: new #90 // class java/util/ArrayList\n 522: dup\n 523: aload 14\n 525: bipush 10\n 527: invokestatic #96 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 530: invokespecial #99 // Method java/util/ArrayList.\"<init>\":(I)V\n 533: checkcast #101 // class java/util/Collection\n 536: astore 17\n 538: iconst_0\n 539: istore 18\n 541: aload 16\n 543: invokeinterface #105, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 548: astore 19\n 550: aload 19\n 552: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 557: ifeq 603\n 560: aload 19\n 562: invokeinterface #115, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 567: astore 20\n 569: aload 17\n 571: aload 20\n 573: astore 21\n 575: astore 22\n 577: iconst_0\n 578: istore 23\n 580: getstatic #55 // Field java/lang/System.out:Ljava/io/PrintStream;\n 583: aload 21\n 585: invokevirtual #61 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 588: nop\n 589: aload 22\n 591: getstatic #169 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 594: invokeinterface #131, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 599: pop\n 600: goto 550\n 603: aload 17\n 605: checkcast #133 // class java/util/List\n 608: nop\n 609: pop\n 610: nop\n 611: aload 11\n 613: invokeinterface #173, 1 // InterfaceMethod java/util/List.size:()I\n 618: ireturn\n}\n",
"javap_err": ""
}
] |
GreyWolf2020__aoc-2022-in-kotlin__498da88/src/Day01.kt
|
import java.lang.Integer.max
fun main() {
fun part1(input: List<String>): Int {
val sumIndex = 0
val maxSumIndex = 1
val zeroCalorie = 0
return input.map {
it.toIntOrNull()
}.foldRight(intArrayOf(0, 0)) { calorieOrNull, acc ->
calorieOrNull ?.let { calorie ->
intArrayOf(acc[sumIndex] + calorie, acc[maxSumIndex])
} ?: run {
intArrayOf(zeroCalorie, max(acc[maxSumIndex], acc[sumIndex]))
}
}[maxSumIndex]
}
fun part2(input: List<String>): Int {
val sumIndex = 0
val highSumIndex = 1
val highHighSumIndex = 2
val highHighHighSumIndex = 3
val zeroCalorie = 0
return input.map {
it.toIntOrNull()
}.foldRight(intArrayOf(0, 0, 0, 0)) { calorieOrNull, acc ->
calorieOrNull?.let { calorie ->
intArrayOf(acc[sumIndex] + calorie, acc[highSumIndex], acc[highHighSumIndex], acc[highHighHighSumIndex])
} ?: run {
when {
acc[sumIndex] > acc[highSumIndex] && acc[sumIndex] < acc[highHighSumIndex] -> intArrayOf(zeroCalorie, acc[sumIndex], acc[highHighSumIndex], acc[highHighHighSumIndex])
acc[sumIndex] > acc[highHighSumIndex] && acc[sumIndex] < acc[highHighHighSumIndex] -> intArrayOf(zeroCalorie, acc[highHighSumIndex], acc[sumIndex], acc[highHighHighSumIndex])
acc[sumIndex] > acc[3] -> intArrayOf(zeroCalorie, acc[highHighSumIndex], acc[highHighHighSumIndex], acc[sumIndex])
else -> intArrayOf(zeroCalorie, acc[highSumIndex], acc[highHighSumIndex], acc[highHighHighSumIndex])
}
}
}
.drop(1)
.sum()
}
// test if implementation meets criteria from the description, like:
// val testInput = readInput("Day01_test")
// check(part1(testInput) == 24000)
// check(part2(testInput) == 45000)
//
// val input = readInput("Day01")
// println(part1(input))
// println(part2(input))
}
|
[
{
"class_path": "GreyWolf2020__aoc-2022-in-kotlin__498da88/Day01Kt.class",
"javap": "Compiled from \"Day01.kt\"\npublic final class Day01Kt {\n public static final void main();\n Code:\n 0: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #9 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: iconst_1\n 3: istore_2\n 4: iconst_0\n 5: istore_3\n 6: aload_0\n 7: checkcast #16 // class java/lang/Iterable\n 10: astore 4\n 12: iconst_0\n 13: istore 5\n 15: aload 4\n 17: astore 6\n 19: new #18 // class java/util/ArrayList\n 22: dup\n 23: aload 4\n 25: bipush 10\n 27: invokestatic #24 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 30: invokespecial #28 // Method java/util/ArrayList.\"<init>\":(I)V\n 33: checkcast #30 // class java/util/Collection\n 36: astore 7\n 38: iconst_0\n 39: istore 8\n 41: aload 6\n 43: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 48: astore 9\n 50: aload 9\n 52: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 57: ifeq 100\n 60: aload 9\n 62: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 67: astore 10\n 69: aload 7\n 71: aload 10\n 73: checkcast #46 // class java/lang/String\n 76: astore 11\n 78: astore 16\n 80: iconst_0\n 81: istore 12\n 83: aload 11\n 85: invokestatic #52 // Method kotlin/text/StringsKt.toIntOrNull:(Ljava/lang/String;)Ljava/lang/Integer;\n 88: aload 16\n 90: swap\n 91: invokeinterface #56, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 96: pop\n 97: goto 50\n 100: aload 7\n 102: checkcast #58 // class java/util/List\n 105: nop\n 106: astore 4\n 108: iconst_2\n 109: newarray int\n 111: astore 5\n 113: aload 5\n 115: iconst_0\n 116: iconst_0\n 117: iastore\n 118: aload 5\n 120: iconst_1\n 121: iconst_0\n 122: iastore\n 123: aload 5\n 125: astore 5\n 127: iconst_0\n 128: istore 6\n 130: aload 5\n 132: astore 7\n 134: aload 4\n 136: invokeinterface #61, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 141: ifne 274\n 144: aload 4\n 146: aload 4\n 148: invokeinterface #65, 1 // InterfaceMethod java/util/List.size:()I\n 153: invokeinterface #69, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 158: astore 8\n 160: aload 8\n 162: invokeinterface #74, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 167: ifeq 274\n 170: aload 8\n 172: invokeinterface #77, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 177: aload 7\n 179: astore 9\n 181: checkcast #79 // class java/lang/Integer\n 184: astore 10\n 186: iconst_0\n 187: istore 11\n 189: aload 10\n 191: dup\n 192: ifnull 236\n 195: checkcast #81 // class java/lang/Number\n 198: invokevirtual #84 // Method java/lang/Number.intValue:()I\n 201: istore 12\n 203: iconst_0\n 204: istore 13\n 206: iconst_2\n 207: newarray int\n 209: astore 14\n 211: aload 14\n 213: iconst_0\n 214: aload 9\n 216: iload_1\n 217: iaload\n 218: iload 12\n 220: iadd\n 221: iastore\n 222: aload 14\n 224: iconst_1\n 225: aload 9\n 227: iload_2\n 228: iaload\n 229: iastore\n 230: aload 14\n 232: nop\n 233: goto 268\n 236: pop\n 237: iconst_0\n 238: istore 15\n 240: iconst_2\n 241: newarray int\n 243: astore 12\n 245: aload 12\n 247: iconst_0\n 248: iload_3\n 249: iastore\n 250: aload 12\n 252: iconst_1\n 253: aload 9\n 255: iload_2\n 256: iaload\n 257: aload 9\n 259: iload_1\n 260: iaload\n 261: invokestatic #88 // Method java/lang/Integer.max:(II)I\n 264: iastore\n 265: aload 12\n 267: nop\n 268: nop\n 269: astore 7\n 271: goto 160\n 274: aload 7\n 276: iload_2\n 277: iaload\n 278: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: iconst_1\n 3: istore_2\n 4: iconst_2\n 5: istore_3\n 6: iconst_3\n 7: istore 4\n 9: iconst_0\n 10: istore 5\n 12: aload_0\n 13: checkcast #16 // class java/lang/Iterable\n 16: astore 6\n 18: iconst_0\n 19: istore 7\n 21: aload 6\n 23: astore 8\n 25: new #18 // class java/util/ArrayList\n 28: dup\n 29: aload 6\n 31: bipush 10\n 33: invokestatic #24 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 36: invokespecial #28 // Method java/util/ArrayList.\"<init>\":(I)V\n 39: checkcast #30 // class java/util/Collection\n 42: astore 9\n 44: iconst_0\n 45: istore 10\n 47: aload 8\n 49: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 54: astore 11\n 56: aload 11\n 58: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 63: ifeq 106\n 66: aload 11\n 68: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 73: astore 12\n 75: aload 9\n 77: aload 12\n 79: checkcast #46 // class java/lang/String\n 82: astore 13\n 84: astore 18\n 86: iconst_0\n 87: istore 14\n 89: aload 13\n 91: invokestatic #52 // Method kotlin/text/StringsKt.toIntOrNull:(Ljava/lang/String;)Ljava/lang/Integer;\n 94: aload 18\n 96: swap\n 97: invokeinterface #56, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 102: pop\n 103: goto 56\n 106: aload 9\n 108: checkcast #58 // class java/util/List\n 111: nop\n 112: astore 6\n 114: iconst_4\n 115: newarray int\n 117: astore 7\n 119: aload 7\n 121: iconst_0\n 122: iconst_0\n 123: iastore\n 124: aload 7\n 126: iconst_1\n 127: iconst_0\n 128: iastore\n 129: aload 7\n 131: iconst_2\n 132: iconst_0\n 133: iastore\n 134: aload 7\n 136: iconst_3\n 137: iconst_0\n 138: iastore\n 139: aload 7\n 141: astore 7\n 143: iconst_0\n 144: istore 8\n 146: aload 7\n 148: astore 9\n 150: aload 6\n 152: invokeinterface #61, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 157: ifne 499\n 160: aload 6\n 162: aload 6\n 164: invokeinterface #65, 1 // InterfaceMethod java/util/List.size:()I\n 169: invokeinterface #69, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 174: astore 10\n 176: aload 10\n 178: invokeinterface #74, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 183: ifeq 499\n 186: aload 10\n 188: invokeinterface #77, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 193: aload 9\n 195: astore 11\n 197: checkcast #79 // class java/lang/Integer\n 200: astore 12\n 202: iconst_0\n 203: istore 13\n 205: aload 12\n 207: dup\n 208: ifnull 269\n 211: checkcast #81 // class java/lang/Number\n 214: invokevirtual #84 // Method java/lang/Number.intValue:()I\n 217: istore 14\n 219: iconst_0\n 220: istore 15\n 222: iconst_4\n 223: newarray int\n 225: astore 16\n 227: aload 16\n 229: iconst_0\n 230: aload 11\n 232: iload_1\n 233: iaload\n 234: iload 14\n 236: iadd\n 237: iastore\n 238: aload 16\n 240: iconst_1\n 241: aload 11\n 243: iload_2\n 244: iaload\n 245: iastore\n 246: aload 16\n 248: iconst_2\n 249: aload 11\n 251: iload_3\n 252: iaload\n 253: iastore\n 254: aload 16\n 256: iconst_3\n 257: aload 11\n 259: iload 4\n 261: iaload\n 262: iastore\n 263: aload 16\n 265: nop\n 266: goto 493\n 269: pop\n 270: iconst_0\n 271: istore 17\n 273: nop\n 274: aload 11\n 276: iload_1\n 277: iaload\n 278: aload 11\n 280: iload_2\n 281: iaload\n 282: if_icmple 337\n 285: aload 11\n 287: iload_1\n 288: iaload\n 289: aload 11\n 291: iload_3\n 292: iaload\n 293: if_icmpge 337\n 296: iconst_4\n 297: newarray int\n 299: astore 14\n 301: aload 14\n 303: iconst_0\n 304: iload 5\n 306: iastore\n 307: aload 14\n 309: iconst_1\n 310: aload 11\n 312: iload_1\n 313: iaload\n 314: iastore\n 315: aload 14\n 317: iconst_2\n 318: aload 11\n 320: iload_3\n 321: iaload\n 322: iastore\n 323: aload 14\n 325: iconst_3\n 326: aload 11\n 328: iload 4\n 330: iaload\n 331: iastore\n 332: aload 14\n 334: goto 491\n 337: aload 11\n 339: iload_1\n 340: iaload\n 341: aload 11\n 343: iload_3\n 344: iaload\n 345: if_icmple 401\n 348: aload 11\n 350: iload_1\n 351: iaload\n 352: aload 11\n 354: iload 4\n 356: iaload\n 357: if_icmpge 401\n 360: iconst_4\n 361: newarray int\n 363: astore 14\n 365: aload 14\n 367: iconst_0\n 368: iload 5\n 370: iastore\n 371: aload 14\n 373: iconst_1\n 374: aload 11\n 376: iload_3\n 377: iaload\n 378: iastore\n 379: aload 14\n 381: iconst_2\n 382: aload 11\n 384: iload_1\n 385: iaload\n 386: iastore\n 387: aload 14\n 389: iconst_3\n 390: aload 11\n 392: iload 4\n 394: iaload\n 395: iastore\n 396: aload 14\n 398: goto 491\n 401: aload 11\n 403: iload_1\n 404: iaload\n 405: aload 11\n 407: iconst_3\n 408: iaload\n 409: if_icmple 453\n 412: iconst_4\n 413: newarray int\n 415: astore 14\n 417: aload 14\n 419: iconst_0\n 420: iload 5\n 422: iastore\n 423: aload 14\n 425: iconst_1\n 426: aload 11\n 428: iload_3\n 429: iaload\n 430: iastore\n 431: aload 14\n 433: iconst_2\n 434: aload 11\n 436: iload 4\n 438: iaload\n 439: iastore\n 440: aload 14\n 442: iconst_3\n 443: aload 11\n 445: iload_1\n 446: iaload\n 447: iastore\n 448: aload 14\n 450: goto 491\n 453: iconst_4\n 454: newarray int\n 456: astore 14\n 458: aload 14\n 460: iconst_0\n 461: iload 5\n 463: iastore\n 464: aload 14\n 466: iconst_1\n 467: aload 11\n 469: iload_2\n 470: iaload\n 471: iastore\n 472: aload 14\n 474: iconst_2\n 475: aload 11\n 477: iload_3\n 478: iaload\n 479: iastore\n 480: aload 14\n 482: iconst_3\n 483: aload 11\n 485: iload 4\n 487: iaload\n 488: iastore\n 489: aload 14\n 491: nop\n 492: nop\n 493: nop\n 494: astore 9\n 496: goto 176\n 499: aload 9\n 501: iconst_1\n 502: invokestatic #128 // Method kotlin/collections/ArraysKt.drop:([II)Ljava/util/List;\n 505: checkcast #16 // class java/lang/Iterable\n 508: invokestatic #132 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 511: ireturn\n}\n",
"javap_err": ""
}
] |
holukent__aoc-2022-in-kotlin__6993a6f/src/Day04.kt
|
import java.io.File
fun main() {
fun part1(input: String): Int {
val data = input.split("\r\n")
var result = 0
for (d in data) {
val temp = d.split(",").map { it.split("-") }
val first = temp[0]
val second = temp[1]
if (
(first[0].toInt() <= second[0].toInt() && first[1].toInt() >= second[1].toInt()) ||
(first[0].toInt() >= second[0].toInt() && first[1].toInt() <= second[1].toInt())
) {
result++
}
}
return result
}
fun part2(input: String): Int {
val data = input.split("\r\n")
var result = 0
for (d in data) {
val temp = d.split(",").map { it.split("-") }
val first = temp[0].map { it.toInt() }
val second = temp[1].map { it.toInt() }
if (
(first[0] in second[0]..second[1]) ||
(first[1] in second[0]..second[1]) ||
(second[0] in first[0]..first[1]) ||
(second[0] in first[0]..first[1])
)
{
result++
}
}
return result
}
val testInput = File("src/Day04_test.txt").readText()
check(part2(testInput) == 4)
val input = File("src/Day04.txt").readText()
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "holukent__aoc-2022-in-kotlin__6993a6f/Day04Kt.class",
"javap": "Compiled from \"Day04.kt\"\npublic final class Day04Kt {\n public static final void main();\n Code:\n 0: new #8 // class java/io/File\n 3: dup\n 4: ldc #10 // String src/Day04_test.txt\n 6: invokespecial #14 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: aconst_null\n 10: iconst_1\n 11: aconst_null\n 12: invokestatic #20 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;\n 15: astore_0\n 16: aload_0\n 17: invokestatic #24 // Method main$part2:(Ljava/lang/String;)I\n 20: iconst_4\n 21: if_icmpne 28\n 24: iconst_1\n 25: goto 29\n 28: iconst_0\n 29: ifne 42\n 32: new #26 // class java/lang/IllegalStateException\n 35: dup\n 36: ldc #28 // String Check failed.\n 38: invokespecial #29 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 41: athrow\n 42: new #8 // class java/io/File\n 45: dup\n 46: ldc #31 // String src/Day04.txt\n 48: invokespecial #14 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 51: aconst_null\n 52: iconst_1\n 53: aconst_null\n 54: invokestatic #20 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;\n 57: astore_1\n 58: aload_1\n 59: invokestatic #34 // Method main$part1:(Ljava/lang/String;)I\n 62: istore_2\n 63: getstatic #40 // Field java/lang/System.out:Ljava/io/PrintStream;\n 66: iload_2\n 67: invokevirtual #46 // Method java/io/PrintStream.println:(I)V\n 70: aload_1\n 71: invokestatic #24 // Method main$part2:(Ljava/lang/String;)I\n 74: istore_2\n 75: getstatic #40 // Field java/lang/System.out:Ljava/io/PrintStream;\n 78: iload_2\n 79: invokevirtual #46 // Method java/io/PrintStream.println:(I)V\n 82: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #54 // Method main:()V\n 3: return\n\n private static final int main$part1(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #58 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #51 // class java/lang/String\n 8: astore_2\n 9: aload_2\n 10: iconst_0\n 11: ldc #60 // String \\r\\n\n 13: aastore\n 14: aload_2\n 15: iconst_0\n 16: iconst_0\n 17: bipush 6\n 19: aconst_null\n 20: invokestatic #66 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 23: astore_1\n 24: iconst_0\n 25: istore_2\n 26: aload_1\n 27: invokeinterface #72, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 32: astore_3\n 33: aload_3\n 34: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 39: ifeq 359\n 42: aload_3\n 43: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 48: checkcast #51 // class java/lang/String\n 51: astore 4\n 53: aload 4\n 55: checkcast #58 // class java/lang/CharSequence\n 58: iconst_1\n 59: anewarray #51 // class java/lang/String\n 62: astore 6\n 64: aload 6\n 66: iconst_0\n 67: ldc #84 // String ,\n 69: aastore\n 70: aload 6\n 72: iconst_0\n 73: iconst_0\n 74: bipush 6\n 76: aconst_null\n 77: invokestatic #66 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 80: checkcast #86 // class java/lang/Iterable\n 83: astore 6\n 85: iconst_0\n 86: istore 7\n 88: aload 6\n 90: astore 8\n 92: new #88 // class java/util/ArrayList\n 95: dup\n 96: aload 6\n 98: bipush 10\n 100: invokestatic #94 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 103: invokespecial #96 // Method java/util/ArrayList.\"<init>\":(I)V\n 106: checkcast #98 // class java/util/Collection\n 109: astore 9\n 111: iconst_0\n 112: istore 10\n 114: aload 8\n 116: invokeinterface #99, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 121: astore 11\n 123: aload 11\n 125: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 130: ifeq 195\n 133: aload 11\n 135: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 140: astore 12\n 142: aload 9\n 144: aload 12\n 146: checkcast #51 // class java/lang/String\n 149: astore 13\n 151: astore 16\n 153: iconst_0\n 154: istore 14\n 156: aload 13\n 158: checkcast #58 // class java/lang/CharSequence\n 161: iconst_1\n 162: anewarray #51 // class java/lang/String\n 165: astore 15\n 167: aload 15\n 169: iconst_0\n 170: ldc #101 // String -\n 172: aastore\n 173: aload 15\n 175: iconst_0\n 176: iconst_0\n 177: bipush 6\n 179: aconst_null\n 180: invokestatic #66 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 183: aload 16\n 185: swap\n 186: invokeinterface #105, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 191: pop\n 192: goto 123\n 195: aload 9\n 197: checkcast #68 // class java/util/List\n 200: nop\n 201: astore 5\n 203: aload 5\n 205: iconst_0\n 206: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 211: checkcast #68 // class java/util/List\n 214: astore 6\n 216: aload 5\n 218: iconst_1\n 219: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 224: checkcast #68 // class java/util/List\n 227: astore 7\n 229: aload 6\n 231: iconst_0\n 232: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 237: checkcast #51 // class java/lang/String\n 240: invokestatic #114 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 243: aload 7\n 245: iconst_0\n 246: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 251: checkcast #51 // class java/lang/String\n 254: invokestatic #114 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 257: if_icmpgt 291\n 260: aload 6\n 262: iconst_1\n 263: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 268: checkcast #51 // class java/lang/String\n 271: invokestatic #114 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 274: aload 7\n 276: iconst_1\n 277: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 282: checkcast #51 // class java/lang/String\n 285: invokestatic #114 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 288: if_icmpge 353\n 291: aload 6\n 293: iconst_0\n 294: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 299: checkcast #51 // class java/lang/String\n 302: invokestatic #114 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 305: aload 7\n 307: iconst_0\n 308: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 313: checkcast #51 // class java/lang/String\n 316: invokestatic #114 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 319: if_icmplt 33\n 322: aload 6\n 324: iconst_1\n 325: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 330: checkcast #51 // class java/lang/String\n 333: invokestatic #114 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 336: aload 7\n 338: iconst_1\n 339: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 344: checkcast #51 // class java/lang/String\n 347: invokestatic #114 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 350: if_icmpgt 33\n 353: iinc 2, 1\n 356: goto 33\n 359: iload_2\n 360: ireturn\n\n private static final int main$part2(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #58 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #51 // class java/lang/String\n 8: astore_2\n 9: aload_2\n 10: iconst_0\n 11: ldc #60 // String \\r\\n\n 13: aastore\n 14: aload_2\n 15: iconst_0\n 16: iconst_0\n 17: bipush 6\n 19: aconst_null\n 20: invokestatic #66 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 23: astore_1\n 24: iconst_0\n 25: istore_2\n 26: aload_1\n 27: invokeinterface #72, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 32: astore_3\n 33: aload_3\n 34: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 39: ifeq 731\n 42: aload_3\n 43: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 48: checkcast #51 // class java/lang/String\n 51: astore 4\n 53: aload 4\n 55: checkcast #58 // class java/lang/CharSequence\n 58: iconst_1\n 59: anewarray #51 // class java/lang/String\n 62: astore 6\n 64: aload 6\n 66: iconst_0\n 67: ldc #84 // String ,\n 69: aastore\n 70: aload 6\n 72: iconst_0\n 73: iconst_0\n 74: bipush 6\n 76: aconst_null\n 77: invokestatic #66 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 80: checkcast #86 // class java/lang/Iterable\n 83: astore 6\n 85: iconst_0\n 86: istore 7\n 88: aload 6\n 90: astore 8\n 92: new #88 // class java/util/ArrayList\n 95: dup\n 96: aload 6\n 98: bipush 10\n 100: invokestatic #94 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 103: invokespecial #96 // Method java/util/ArrayList.\"<init>\":(I)V\n 106: checkcast #98 // class java/util/Collection\n 109: astore 9\n 111: iconst_0\n 112: istore 10\n 114: aload 8\n 116: invokeinterface #99, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 121: astore 11\n 123: aload 11\n 125: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 130: ifeq 195\n 133: aload 11\n 135: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 140: astore 12\n 142: aload 9\n 144: aload 12\n 146: checkcast #51 // class java/lang/String\n 149: astore 13\n 151: astore 17\n 153: iconst_0\n 154: istore 14\n 156: aload 13\n 158: checkcast #58 // class java/lang/CharSequence\n 161: iconst_1\n 162: anewarray #51 // class java/lang/String\n 165: astore 15\n 167: aload 15\n 169: iconst_0\n 170: ldc #101 // String -\n 172: aastore\n 173: aload 15\n 175: iconst_0\n 176: iconst_0\n 177: bipush 6\n 179: aconst_null\n 180: invokestatic #66 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 183: aload 17\n 185: swap\n 186: invokeinterface #105, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 191: pop\n 192: goto 123\n 195: aload 9\n 197: checkcast #68 // class java/util/List\n 200: nop\n 201: astore 5\n 203: aload 5\n 205: iconst_0\n 206: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 211: checkcast #86 // class java/lang/Iterable\n 214: astore 7\n 216: iconst_0\n 217: istore 8\n 219: aload 7\n 221: astore 9\n 223: new #88 // class java/util/ArrayList\n 226: dup\n 227: aload 7\n 229: bipush 10\n 231: invokestatic #94 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 234: invokespecial #96 // Method java/util/ArrayList.\"<init>\":(I)V\n 237: checkcast #98 // class java/util/Collection\n 240: astore 10\n 242: iconst_0\n 243: istore 11\n 245: aload 9\n 247: invokeinterface #99, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 252: astore 12\n 254: aload 12\n 256: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 261: ifeq 308\n 264: aload 12\n 266: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 271: astore 13\n 273: aload 10\n 275: aload 13\n 277: checkcast #51 // class java/lang/String\n 280: astore 14\n 282: astore 17\n 284: iconst_0\n 285: istore 15\n 287: aload 14\n 289: invokestatic #114 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 292: nop\n 293: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 296: aload 17\n 298: swap\n 299: invokeinterface #105, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 304: pop\n 305: goto 254\n 308: aload 10\n 310: checkcast #68 // class java/util/List\n 313: nop\n 314: astore 6\n 316: aload 5\n 318: iconst_1\n 319: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 324: checkcast #86 // class java/lang/Iterable\n 327: astore 8\n 329: iconst_0\n 330: istore 9\n 332: aload 8\n 334: astore 10\n 336: new #88 // class java/util/ArrayList\n 339: dup\n 340: aload 8\n 342: bipush 10\n 344: invokestatic #94 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 347: invokespecial #96 // Method java/util/ArrayList.\"<init>\":(I)V\n 350: checkcast #98 // class java/util/Collection\n 353: astore 11\n 355: iconst_0\n 356: istore 12\n 358: aload 10\n 360: invokeinterface #99, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 365: astore 13\n 367: aload 13\n 369: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 374: ifeq 421\n 377: aload 13\n 379: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 384: astore 14\n 386: aload 11\n 388: aload 14\n 390: checkcast #51 // class java/lang/String\n 393: astore 15\n 395: astore 17\n 397: iconst_0\n 398: istore 16\n 400: aload 15\n 402: invokestatic #114 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 405: nop\n 406: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 409: aload 17\n 411: swap\n 412: invokeinterface #105, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 417: pop\n 418: goto 367\n 421: aload 11\n 423: checkcast #68 // class java/util/List\n 426: nop\n 427: astore 7\n 429: aload 7\n 431: iconst_0\n 432: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 437: checkcast #139 // class java/lang/Number\n 440: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 443: istore 8\n 445: aload 7\n 447: iconst_1\n 448: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 453: checkcast #139 // class java/lang/Number\n 456: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 459: istore 9\n 461: aload 6\n 463: iconst_0\n 464: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 469: checkcast #139 // class java/lang/Number\n 472: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 475: istore 10\n 477: iload 8\n 479: iload 10\n 481: if_icmpgt 499\n 484: iload 10\n 486: iload 9\n 488: if_icmpgt 495\n 491: iconst_1\n 492: goto 500\n 495: iconst_0\n 496: goto 500\n 499: iconst_0\n 500: ifne 725\n 503: aload 7\n 505: iconst_0\n 506: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 511: checkcast #139 // class java/lang/Number\n 514: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 517: istore 8\n 519: aload 7\n 521: iconst_1\n 522: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 527: checkcast #139 // class java/lang/Number\n 530: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 533: istore 9\n 535: aload 6\n 537: iconst_1\n 538: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 543: checkcast #139 // class java/lang/Number\n 546: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 549: istore 10\n 551: iload 8\n 553: iload 10\n 555: if_icmpgt 573\n 558: iload 10\n 560: iload 9\n 562: if_icmpgt 569\n 565: iconst_1\n 566: goto 574\n 569: iconst_0\n 570: goto 574\n 573: iconst_0\n 574: ifne 725\n 577: aload 6\n 579: iconst_0\n 580: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 585: checkcast #139 // class java/lang/Number\n 588: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 591: istore 8\n 593: aload 6\n 595: iconst_1\n 596: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 601: checkcast #139 // class java/lang/Number\n 604: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 607: istore 9\n 609: aload 7\n 611: iconst_0\n 612: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 617: checkcast #139 // class java/lang/Number\n 620: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 623: istore 10\n 625: iload 8\n 627: iload 10\n 629: if_icmpgt 647\n 632: iload 10\n 634: iload 9\n 636: if_icmpgt 643\n 639: iconst_1\n 640: goto 648\n 643: iconst_0\n 644: goto 648\n 647: iconst_0\n 648: ifne 725\n 651: aload 6\n 653: iconst_0\n 654: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 659: checkcast #139 // class java/lang/Number\n 662: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 665: istore 8\n 667: aload 6\n 669: iconst_1\n 670: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 675: checkcast #139 // class java/lang/Number\n 678: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 681: istore 9\n 683: aload 7\n 685: iconst_0\n 686: invokeinterface #109, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 691: checkcast #139 // class java/lang/Number\n 694: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 697: istore 10\n 699: iload 8\n 701: iload 10\n 703: if_icmpgt 721\n 706: iload 10\n 708: iload 9\n 710: if_icmpgt 717\n 713: iconst_1\n 714: goto 722\n 717: iconst_0\n 718: goto 722\n 721: iconst_0\n 722: ifeq 33\n 725: iinc 2, 1\n 728: goto 33\n 731: iload_2\n 732: ireturn\n}\n",
"javap_err": ""
}
] |
TheRenegadeCoder__sample-programs__bd5f385/archive/k/kotlin/JobSequencing.kt
|
fun main(args: Array<String>) {
val jobs = buildJobs(args)
if (jobs.isNullOrEmpty()) {
println("Usage: please provide a list of profits and a list of deadlines")
} else {
println(maxProfit(jobs))
}
}
/**
* Calculates the maximum profit of a list of jobs
*/
private fun maxProfit(jobs: List<Job>): Int {
val scheduled = hashSetOf<Int>()
var profit = 0
jobs.sortedByDescending { it.profit }.forEach {
for (i in it.deadline downTo 1) {
if (scheduled.add(i)) {
profit += it.profit
break
}
}
}
return profit
}
/**
* Builds job list with input arguments
*/
private fun buildJobs(args: Array<String>): List<Job>? {
if (args.run { isNullOrEmpty() || size < 2 || any { it.isBlank() } }) return null
val profits = args[0].toIntArray()
val deadlines = args[1].toIntArray()
if (profits.size != deadlines.size) return null
return profits.mapIndexed { index, profit -> Job(profit, deadlines[index]) }
}
/**
* Represents the information of a job
*/
class Job(val profit: Int, val deadline: Int)
/**
* Extracts an array of integers from the string
*/
fun String.toIntArray() = split(",").mapNotNull { it.trim().toIntOrNull() }
|
[
{
"class_path": "TheRenegadeCoder__sample-programs__bd5f385/JobSequencingKt.class",
"javap": "Compiled from \"JobSequencing.kt\"\npublic final class JobSequencingKt {\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: invokestatic #19 // Method buildJobs:([Ljava/lang/String;)Ljava/util/List;\n 10: astore_1\n 11: aload_1\n 12: checkcast #21 // class java/util/Collection\n 15: astore_2\n 16: aload_2\n 17: ifnull 29\n 20: aload_2\n 21: invokeinterface #25, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 26: ifeq 33\n 29: iconst_1\n 30: goto 34\n 33: iconst_0\n 34: ifeq 49\n 37: ldc #27 // String Usage: please provide a list of profits and a list of deadlines\n 39: getstatic #33 // Field java/lang/System.out:Ljava/io/PrintStream;\n 42: swap\n 43: invokevirtual #39 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 46: goto 61\n 49: aload_1\n 50: invokestatic #43 // Method maxProfit:(Ljava/util/List;)I\n 53: istore_2\n 54: getstatic #33 // Field java/lang/System.out:Ljava/io/PrintStream;\n 57: iload_2\n 58: invokevirtual #46 // Method java/io/PrintStream.println:(I)V\n 61: return\n\n private static final int maxProfit(java.util.List<Job>);\n Code:\n 0: new #54 // class java/util/HashSet\n 3: dup\n 4: invokespecial #58 // Method java/util/HashSet.\"<init>\":()V\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_0\n 11: checkcast #60 // class java/lang/Iterable\n 14: astore_3\n 15: iconst_0\n 16: istore 4\n 18: aload_3\n 19: new #62 // class JobSequencingKt$maxProfit$$inlined$sortedByDescending$1\n 22: dup\n 23: invokespecial #63 // Method JobSequencingKt$maxProfit$$inlined$sortedByDescending$1.\"<init>\":()V\n 26: checkcast #65 // class java/util/Comparator\n 29: invokestatic #71 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 32: checkcast #60 // class java/lang/Iterable\n 35: astore_3\n 36: nop\n 37: iconst_0\n 38: istore 4\n 40: aload_3\n 41: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 46: astore 5\n 48: aload 5\n 50: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 55: ifeq 124\n 58: aload 5\n 60: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 65: astore 6\n 67: aload 6\n 69: checkcast #86 // class Job\n 72: astore 7\n 74: iconst_0\n 75: istore 8\n 77: aload 7\n 79: invokevirtual #90 // Method Job.getDeadline:()I\n 82: istore 9\n 84: iconst_0\n 85: iload 9\n 87: if_icmpge 119\n 90: aload_1\n 91: iload 9\n 93: invokestatic #96 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 96: invokevirtual #100 // Method java/util/HashSet.add:(Ljava/lang/Object;)Z\n 99: ifeq 113\n 102: iload_2\n 103: aload 7\n 105: invokevirtual #103 // Method Job.getProfit:()I\n 108: iadd\n 109: istore_2\n 110: goto 119\n 113: iinc 9, -1\n 116: goto 84\n 119: nop\n 120: nop\n 121: goto 48\n 124: nop\n 125: iload_2\n 126: ireturn\n\n private static final java.util.List<Job> buildJobs(java.lang.String[]);\n Code:\n 0: aload_0\n 1: astore_2\n 2: iconst_0\n 3: istore_3\n 4: aload_2\n 5: astore 4\n 7: aload 4\n 9: ifnull 26\n 12: aload 4\n 14: arraylength\n 15: ifne 22\n 18: iconst_1\n 19: goto 23\n 22: iconst_0\n 23: ifeq 30\n 26: iconst_1\n 27: goto 31\n 30: iconst_0\n 31: ifne 100\n 34: aload_2\n 35: arraylength\n 36: iconst_2\n 37: if_icmplt 100\n 40: aload_2\n 41: astore 4\n 43: iconst_0\n 44: istore 5\n 46: iconst_0\n 47: istore 6\n 49: aload 4\n 51: arraylength\n 52: istore 7\n 54: iload 6\n 56: iload 7\n 58: if_icmpge 96\n 61: aload 4\n 63: iload 6\n 65: aaload\n 66: astore 8\n 68: aload 8\n 70: astore 9\n 72: iconst_0\n 73: istore 10\n 75: aload 9\n 77: checkcast #121 // class java/lang/CharSequence\n 80: invokestatic #127 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 83: ifeq 90\n 86: iconst_1\n 87: goto 97\n 90: iinc 6, 1\n 93: goto 54\n 96: iconst_0\n 97: ifeq 104\n 100: iconst_1\n 101: goto 105\n 104: iconst_0\n 105: nop\n 106: ifeq 111\n 109: aconst_null\n 110: areturn\n 111: aload_0\n 112: iconst_0\n 113: aaload\n 114: invokestatic #131 // Method toIntArray:(Ljava/lang/String;)Ljava/util/List;\n 117: astore_1\n 118: aload_0\n 119: iconst_1\n 120: aaload\n 121: invokestatic #131 // Method toIntArray:(Ljava/lang/String;)Ljava/util/List;\n 124: astore_2\n 125: aload_1\n 126: invokeinterface #134, 1 // InterfaceMethod java/util/List.size:()I\n 131: aload_2\n 132: invokeinterface #134, 1 // InterfaceMethod java/util/List.size:()I\n 137: if_icmpeq 142\n 140: aconst_null\n 141: areturn\n 142: aload_1\n 143: checkcast #60 // class java/lang/Iterable\n 146: astore_3\n 147: iconst_0\n 148: istore 4\n 150: aload_3\n 151: astore 5\n 153: new #136 // class java/util/ArrayList\n 156: dup\n 157: aload_3\n 158: bipush 10\n 160: invokestatic #140 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 163: invokespecial #142 // Method java/util/ArrayList.\"<init>\":(I)V\n 166: checkcast #21 // class java/util/Collection\n 169: astore 6\n 171: iconst_0\n 172: istore 7\n 174: iconst_0\n 175: istore 8\n 177: aload 5\n 179: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 184: astore 9\n 186: aload 9\n 188: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 193: ifeq 276\n 196: aload 9\n 198: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 203: astore 10\n 205: aload 6\n 207: iload 8\n 209: iinc 8, 1\n 212: istore 11\n 214: iload 11\n 216: ifge 222\n 219: invokestatic #145 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 222: iload 11\n 224: aload 10\n 226: checkcast #147 // class java/lang/Number\n 229: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 232: istore 12\n 234: istore 13\n 236: astore 15\n 238: iconst_0\n 239: istore 14\n 241: new #86 // class Job\n 244: dup\n 245: iload 12\n 247: aload_2\n 248: iload 13\n 250: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 255: checkcast #147 // class java/lang/Number\n 258: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 261: invokespecial #157 // Method Job.\"<init>\":(II)V\n 264: aload 15\n 266: swap\n 267: invokeinterface #158, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 272: pop\n 273: goto 186\n 276: aload 6\n 278: checkcast #51 // class java/util/List\n 281: nop\n 282: areturn\n\n public static final java.util.List<java.lang.Integer> toIntArray(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #183 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #121 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #180 // class java/lang/String\n 14: astore_1\n 15: aload_1\n 16: iconst_0\n 17: ldc #185 // String ,\n 19: aastore\n 20: aload_1\n 21: iconst_0\n 22: iconst_0\n 23: bipush 6\n 25: aconst_null\n 26: invokestatic #189 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: checkcast #60 // class java/lang/Iterable\n 32: astore_1\n 33: iconst_0\n 34: istore_2\n 35: aload_1\n 36: astore_3\n 37: new #136 // class java/util/ArrayList\n 40: dup\n 41: invokespecial #190 // Method java/util/ArrayList.\"<init>\":()V\n 44: checkcast #21 // class java/util/Collection\n 47: astore 4\n 49: iconst_0\n 50: istore 5\n 52: aload_3\n 53: astore 6\n 55: iconst_0\n 56: istore 7\n 58: aload 6\n 60: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 65: astore 8\n 67: aload 8\n 69: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 74: ifeq 144\n 77: aload 8\n 79: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 84: astore 9\n 86: aload 9\n 88: astore 10\n 90: iconst_0\n 91: istore 11\n 93: aload 10\n 95: checkcast #180 // class java/lang/String\n 98: astore 12\n 100: iconst_0\n 101: istore 13\n 103: aload 12\n 105: checkcast #121 // class java/lang/CharSequence\n 108: invokestatic #194 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 111: invokevirtual #198 // Method java/lang/Object.toString:()Ljava/lang/String;\n 114: invokestatic #202 // Method kotlin/text/StringsKt.toIntOrNull:(Ljava/lang/String;)Ljava/lang/Integer;\n 117: dup\n 118: ifnull 139\n 121: astore 14\n 123: iconst_0\n 124: istore 15\n 126: aload 4\n 128: aload 14\n 130: invokeinterface #158, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 135: pop\n 136: goto 140\n 139: pop\n 140: nop\n 141: goto 67\n 144: nop\n 145: aload 4\n 147: checkcast #51 // class java/util/List\n 150: nop\n 151: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "TheRenegadeCoder__sample-programs__bd5f385/JobSequencingKt$maxProfit$$inlined$sortedByDescending$1.class",
"javap": "Compiled from \"Comparisons.kt\"\npublic final class JobSequencingKt$maxProfit$$inlined$sortedByDescending$1<T> implements java.util.Comparator {\n public JobSequencingKt$maxProfit$$inlined$sortedByDescending$1();\n Code:\n 0: aload_0\n 1: invokespecial #16 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int compare(T, T);\n Code:\n 0: aload_2\n 1: checkcast #23 // class Job\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method Job.getProfit:()I\n 12: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 15: checkcast #35 // class java/lang/Comparable\n 18: aload_1\n 19: checkcast #23 // class Job\n 22: astore_3\n 23: astore 5\n 25: iconst_0\n 26: istore 4\n 28: aload_3\n 29: invokevirtual #27 // Method Job.getProfit:()I\n 32: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 35: aload 5\n 37: swap\n 38: checkcast #35 // class java/lang/Comparable\n 41: invokestatic #41 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I\n 44: ireturn\n}\n",
"javap_err": ""
}
] |
TheRenegadeCoder__sample-programs__bd5f385/archive/k/kotlin/Rot13.kt
|
data class EncodingBounds(val lowerBound: Int, val upperBound: Int)
fun encodingBoundsForCharValue(c: Char): EncodingBounds? {
val lowerCaseBounds = EncodingBounds('a'.toInt(), 'z'.toInt())
val upperCaseBounds = EncodingBounds('A'.toInt(), 'Z'.toInt())
return when (c) {
in 'a'..'z' -> lowerCaseBounds
in 'A'..'Z' -> upperCaseBounds
else -> null
}
}
fun calculateRotatedChar(char: Char, rotation: Int, bounds: EncodingBounds): Char {
val rotatedCharVal = char.toInt() + rotation
val remainder = rotatedCharVal - (bounds.upperBound + 1)
return (if (rotatedCharVal > bounds.upperBound) bounds.lowerBound + remainder else rotatedCharVal).toChar()
}
fun parseInput(args: Array<String>): String? {
if (args.isEmpty()) {
return null
}
val text = args[0]
if (text.isEmpty()) {
return null
}
return text
}
fun rot13Encode(text: String): String {
val rotation = 13
return text.map { c ->
val bounds = encodingBoundsForCharValue(c)
if (bounds == null) {
c.toString()
} else {
calculateRotatedChar(c, rotation, bounds).toString()
}
}.reduce { encodedText, encodedChar ->
encodedText + encodedChar
}
}
fun main(args: Array<String>) {
val strToEncode = parseInput(args)
if (strToEncode == null) {
println("Usage: please provide a string to encrypt")
} else {
println(rot13Encode(strToEncode))
}
}
|
[
{
"class_path": "TheRenegadeCoder__sample-programs__bd5f385/Rot13Kt.class",
"javap": "Compiled from \"Rot13.kt\"\npublic final class Rot13Kt {\n public static final EncodingBounds encodingBoundsForCharValue(char);\n Code:\n 0: new #9 // class EncodingBounds\n 3: dup\n 4: bipush 97\n 6: bipush 122\n 8: invokespecial #13 // Method EncodingBounds.\"<init>\":(II)V\n 11: astore_1\n 12: new #9 // class EncodingBounds\n 15: dup\n 16: bipush 65\n 18: bipush 90\n 20: invokespecial #13 // Method EncodingBounds.\"<init>\":(II)V\n 23: astore_2\n 24: iload_0\n 25: istore_3\n 26: bipush 97\n 28: iload_3\n 29: if_icmpgt 46\n 32: iload_3\n 33: bipush 123\n 35: if_icmpge 42\n 38: iconst_1\n 39: goto 47\n 42: iconst_0\n 43: goto 47\n 46: iconst_0\n 47: ifeq 54\n 50: aload_1\n 51: goto 83\n 54: bipush 65\n 56: iload_3\n 57: if_icmpgt 74\n 60: iload_3\n 61: bipush 91\n 63: if_icmpge 70\n 66: iconst_1\n 67: goto 75\n 70: iconst_0\n 71: goto 75\n 74: iconst_0\n 75: ifeq 82\n 78: aload_2\n 79: goto 83\n 82: aconst_null\n 83: areturn\n\n public static final char calculateRotatedChar(char, int, EncodingBounds);\n Code:\n 0: aload_2\n 1: ldc #23 // String bounds\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iload_0\n 7: iload_1\n 8: iadd\n 9: istore_3\n 10: iload_3\n 11: aload_2\n 12: invokevirtual #33 // Method EncodingBounds.getUpperBound:()I\n 15: iconst_1\n 16: iadd\n 17: isub\n 18: istore 4\n 20: iload_3\n 21: aload_2\n 22: invokevirtual #33 // Method EncodingBounds.getUpperBound:()I\n 25: if_icmple 38\n 28: aload_2\n 29: invokevirtual #36 // Method EncodingBounds.getLowerBound:()I\n 32: iload 4\n 34: iadd\n 35: goto 39\n 38: iload_3\n 39: i2c\n 40: ireturn\n\n public static final java.lang.String parseInput(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #45 // String args\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: arraylength\n 8: ifne 15\n 11: iconst_1\n 12: goto 16\n 15: iconst_0\n 16: ifeq 21\n 19: aconst_null\n 20: areturn\n 21: aload_0\n 22: iconst_0\n 23: aaload\n 24: astore_1\n 25: aload_1\n 26: checkcast #47 // class java/lang/CharSequence\n 29: invokeinterface #50, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 34: ifne 41\n 37: iconst_1\n 38: goto 42\n 41: iconst_0\n 42: ifeq 47\n 45: aconst_null\n 46: areturn\n 47: aload_1\n 48: areturn\n\n public static final java.lang.String rot13Encode(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #58 // String text\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: bipush 13\n 8: istore_1\n 9: aload_0\n 10: checkcast #47 // class java/lang/CharSequence\n 13: astore_2\n 14: iconst_0\n 15: istore_3\n 16: aload_2\n 17: astore 4\n 19: new #60 // class java/util/ArrayList\n 22: dup\n 23: aload_2\n 24: invokeinterface #50, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 29: invokespecial #63 // Method java/util/ArrayList.\"<init>\":(I)V\n 32: checkcast #65 // class java/util/Collection\n 35: astore 5\n 37: iconst_0\n 38: istore 6\n 40: iconst_0\n 41: istore 7\n 43: iload 7\n 45: aload 4\n 47: invokeinterface #50, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 52: if_icmpge 124\n 55: aload 4\n 57: iload 7\n 59: invokeinterface #69, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 64: istore 8\n 66: aload 5\n 68: iload 8\n 70: istore 9\n 72: astore 12\n 74: iconst_0\n 75: istore 10\n 77: iload 9\n 79: invokestatic #71 // Method encodingBoundsForCharValue:(C)LEncodingBounds;\n 82: astore 11\n 84: aload 11\n 86: ifnonnull 97\n 89: iload 9\n 91: invokestatic #75 // Method java/lang/String.valueOf:(C)Ljava/lang/String;\n 94: goto 108\n 97: iload 9\n 99: iload_1\n 100: aload 11\n 102: invokestatic #77 // Method calculateRotatedChar:(CILEncodingBounds;)C\n 105: invokestatic #75 // Method java/lang/String.valueOf:(C)Ljava/lang/String;\n 108: nop\n 109: aload 12\n 111: swap\n 112: invokeinterface #81, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 117: pop\n 118: iinc 7, 1\n 121: goto 43\n 124: aload 5\n 126: checkcast #83 // class java/util/List\n 129: nop\n 130: checkcast #85 // class java/lang/Iterable\n 133: astore_2\n 134: nop\n 135: iconst_0\n 136: istore_3\n 137: aload_2\n 138: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 143: astore 4\n 145: aload 4\n 147: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 152: ifne 165\n 155: new #97 // class java/lang/UnsupportedOperationException\n 158: dup\n 159: ldc #99 // String Empty collection can\\'t be reduced.\n 161: invokespecial #102 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 164: athrow\n 165: aload 4\n 167: invokeinterface #106, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 172: astore 5\n 174: aload 4\n 176: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 181: ifeq 231\n 184: aload 5\n 186: aload 4\n 188: invokeinterface #106, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 193: checkcast #55 // class java/lang/String\n 196: astore 6\n 198: checkcast #55 // class java/lang/String\n 201: astore 7\n 203: iconst_0\n 204: istore 8\n 206: new #108 // class java/lang/StringBuilder\n 209: dup\n 210: invokespecial #111 // Method java/lang/StringBuilder.\"<init>\":()V\n 213: aload 7\n 215: invokevirtual #115 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 218: aload 6\n 220: invokevirtual #115 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 223: invokevirtual #119 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 226: astore 5\n 228: goto 174\n 231: aload 5\n 233: checkcast #55 // class java/lang/String\n 236: areturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #45 // String args\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #142 // Method parseInput:([Ljava/lang/String;)Ljava/lang/String;\n 10: astore_1\n 11: aload_1\n 12: ifnonnull 27\n 15: ldc #144 // String Usage: please provide a string to encrypt\n 17: getstatic #150 // Field java/lang/System.out:Ljava/io/PrintStream;\n 20: swap\n 21: invokevirtual #156 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 24: goto 38\n 27: aload_1\n 28: invokestatic #158 // Method rot13Encode:(Ljava/lang/String;)Ljava/lang/String;\n 31: getstatic #150 // Field java/lang/System.out:Ljava/io/PrintStream;\n 34: swap\n 35: invokevirtual #156 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 38: return\n}\n",
"javap_err": ""
}
] |
Ad0lphus__AOC2021__02f219e/day15/Kotlin/day15.kt
|
import java.io.*
import java.util.*
fun print_day_15() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 15" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Chiton -c -f small")
val reader = BufferedReader(InputStreamReader(process.inputStream))
reader.forEachLine { println(it) }
println(reset)
println(yellow + "-".repeat(33) + "Output" + "-".repeat(33) + reset + "\n")
}
fun main() {
print_day_15()
Day15().part_1()
Day15().part_2()
println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}
class Day15 {
data class Node(val x:Int = 0, val y:Int = 0, val dist: Int = 0)
fun part_1() {
val grid = File("../Input/day15.txt").readLines().map { it.toCharArray().map{ it.digitToInt() } }
print("Puzzle 1: ")
findShortestPath(grid)
}
private fun findShortestPath(grid: List<List<Int>>) {
val pathways = Array(grid.size) { Array(grid[0].size) { Int.MAX_VALUE } }
val queue = PriorityQueue<Node> { nodeA, nodeB -> nodeA.dist - nodeB.dist }
pathways[0][0] = 0
queue.add(Node(0,0, 0))
while(queue.isNotEmpty()) {
val (x, y, dist) = queue.poll()
listOf(x to y + 1, x to y - 1, x + 1 to y, x - 1 to y).forEach { (X, Y) ->
if (X in grid.indices && Y in grid[0].indices && pathways[X][Y] > dist + grid[X][Y]) {
pathways[X][Y] = dist + grid[X][Y]
queue.add(Node(X, Y, pathways[X][Y]))
}
}
}
println(pathways.last().last())
}
fun part_2() {
val input = File("../Input/day15.txt").readLines()
val totalY = input.size
val totalX = input.first().length
val grid = (0 until totalY * 5).map { y ->
(0 until totalX * 5).map { x ->
val baseNum = input[y % totalY][x % totalX].digitToInt()
val tileDistance = (x/totalX) + (y/totalY)
if (baseNum + tileDistance < 10) baseNum + tileDistance else (baseNum + tileDistance) - 9
}
}
print("Puzzle 2: ")
findShortestPath(grid)
}
}
|
[
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day15.class",
"javap": "Compiled from \"day15.kt\"\npublic final class Day15 {\n public Day15();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final void part_1();\n Code:\n 0: new #13 // class java/io/File\n 3: dup\n 4: ldc #15 // String ../Input/day15.txt\n 6: invokespecial #18 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: aconst_null\n 10: iconst_1\n 11: aconst_null\n 12: invokestatic #24 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 15: checkcast #26 // class java/lang/Iterable\n 18: astore_2\n 19: iconst_0\n 20: istore_3\n 21: aload_2\n 22: astore 4\n 24: new #28 // class java/util/ArrayList\n 27: dup\n 28: aload_2\n 29: bipush 10\n 31: invokestatic #34 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 34: invokespecial #37 // Method java/util/ArrayList.\"<init>\":(I)V\n 37: checkcast #39 // class java/util/Collection\n 40: astore 5\n 42: iconst_0\n 43: istore 6\n 45: aload 4\n 47: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 52: astore 7\n 54: aload 7\n 56: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 61: ifeq 201\n 64: aload 7\n 66: invokeinterface #53, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 71: astore 8\n 73: aload 5\n 75: aload 8\n 77: checkcast #55 // class java/lang/String\n 80: astore 9\n 82: astore 22\n 84: iconst_0\n 85: istore 10\n 87: aload 9\n 89: invokevirtual #59 // Method java/lang/String.toCharArray:()[C\n 92: dup\n 93: ldc #61 // String toCharArray(...)\n 95: invokestatic #67 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 98: astore 11\n 100: nop\n 101: iconst_0\n 102: istore 12\n 104: aload 11\n 106: astore 13\n 108: new #28 // class java/util/ArrayList\n 111: dup\n 112: aload 11\n 114: arraylength\n 115: invokespecial #37 // Method java/util/ArrayList.\"<init>\":(I)V\n 118: checkcast #39 // class java/util/Collection\n 121: astore 14\n 123: iconst_0\n 124: istore 15\n 126: iconst_0\n 127: istore 16\n 129: aload 13\n 131: arraylength\n 132: istore 17\n 134: iload 16\n 136: iload 17\n 138: if_icmpge 182\n 141: aload 13\n 143: iload 16\n 145: caload\n 146: istore 18\n 148: aload 14\n 150: iload 18\n 152: istore 19\n 154: astore 20\n 156: iconst_0\n 157: istore 21\n 159: iload 19\n 161: invokestatic #73 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 164: invokestatic #79 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 167: aload 20\n 169: swap\n 170: invokeinterface #83, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 175: pop\n 176: iinc 16, 1\n 179: goto 134\n 182: aload 14\n 184: checkcast #85 // class java/util/List\n 187: nop\n 188: nop\n 189: aload 22\n 191: swap\n 192: invokeinterface #83, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 197: pop\n 198: goto 54\n 201: aload 5\n 203: checkcast #85 // class java/util/List\n 206: nop\n 207: astore_1\n 208: ldc #87 // String Puzzle 1:\n 210: getstatic #93 // Field java/lang/System.out:Ljava/io/PrintStream;\n 213: swap\n 214: invokevirtual #99 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 217: aload_0\n 218: aload_1\n 219: invokespecial #103 // Method findShortestPath:(Ljava/util/List;)V\n 222: return\n\n private final void findShortestPath(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 #127, 1 // InterfaceMethod java/util/List.size:()I\n 8: istore 4\n 10: iload 4\n 12: anewarray #129 // class \"[Ljava/lang/Integer;\"\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 #133, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 40: checkcast #85 // class java/util/List\n 43: invokeinterface #127, 1 // InterfaceMethod java/util/List.size:()I\n 48: istore 8\n 50: iload 8\n 52: anewarray #75 // class java/lang/Integer\n 55: astore 9\n 57: istore 17\n 59: astore 16\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: ldc #134 // int 2147483647\n 78: invokestatic #79 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 81: aastore\n 82: iinc 7, 1\n 85: goto 61\n 88: aload 16\n 90: iload 17\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: new #136 // class java/util/PriorityQueue\n 107: dup\n 108: invokedynamic #156, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;\n 113: invokedynamic #167, 0 // InvokeDynamic #1:compare:(Lkotlin/jvm/functions/Function2;)Ljava/util/Comparator;\n 118: invokespecial #170 // Method java/util/PriorityQueue.\"<init>\":(Ljava/util/Comparator;)V\n 121: astore_3\n 122: aload_2\n 123: iconst_0\n 124: aaload\n 125: iconst_0\n 126: iconst_0\n 127: invokestatic #79 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 130: aastore\n 131: aload_3\n 132: new #172 // class Day15$Node\n 135: dup\n 136: iconst_0\n 137: iconst_0\n 138: iconst_0\n 139: invokespecial #175 // Method Day15$Node.\"<init>\":(III)V\n 142: invokevirtual #176 // Method java/util/PriorityQueue.add:(Ljava/lang/Object;)Z\n 145: pop\n 146: aload_3\n 147: checkcast #39 // class java/util/Collection\n 150: invokeinterface #179, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 155: ifne 162\n 158: iconst_1\n 159: goto 163\n 162: iconst_0\n 163: ifeq 537\n 166: aload_3\n 167: invokevirtual #182 // Method java/util/PriorityQueue.poll:()Ljava/lang/Object;\n 170: checkcast #172 // class Day15$Node\n 173: astore 4\n 175: aload 4\n 177: invokevirtual #185 // Method Day15$Node.component1:()I\n 180: istore 5\n 182: aload 4\n 184: invokevirtual #188 // Method Day15$Node.component2:()I\n 187: istore 6\n 189: aload 4\n 191: invokevirtual #191 // Method Day15$Node.component3:()I\n 194: istore 7\n 196: iconst_4\n 197: anewarray #193 // class kotlin/Pair\n 200: astore 8\n 202: aload 8\n 204: iconst_0\n 205: iload 5\n 207: invokestatic #79 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 210: iload 6\n 212: iconst_1\n 213: iadd\n 214: invokestatic #79 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 217: invokestatic #199 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 220: aastore\n 221: aload 8\n 223: iconst_1\n 224: iload 5\n 226: invokestatic #79 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 229: iload 6\n 231: iconst_1\n 232: isub\n 233: invokestatic #79 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 236: invokestatic #199 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 239: aastore\n 240: aload 8\n 242: iconst_2\n 243: iload 5\n 245: iconst_1\n 246: iadd\n 247: invokestatic #79 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 250: iload 6\n 252: invokestatic #79 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 255: invokestatic #199 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 258: aastore\n 259: aload 8\n 261: iconst_3\n 262: iload 5\n 264: iconst_1\n 265: isub\n 266: invokestatic #79 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 269: iload 6\n 271: invokestatic #79 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 274: invokestatic #199 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 277: aastore\n 278: aload 8\n 280: invokestatic #203 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 283: checkcast #26 // class java/lang/Iterable\n 286: astore 8\n 288: iconst_0\n 289: istore 9\n 291: aload 8\n 293: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 298: astore 10\n 300: aload 10\n 302: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 307: ifeq 533\n 310: aload 10\n 312: invokeinterface #53, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 317: astore 11\n 319: aload 11\n 321: checkcast #193 // class kotlin/Pair\n 324: astore 12\n 326: iconst_0\n 327: istore 13\n 329: aload 12\n 331: invokevirtual #205 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 334: checkcast #207 // class java/lang/Number\n 337: invokevirtual #210 // Method java/lang/Number.intValue:()I\n 340: istore 14\n 342: aload 12\n 344: invokevirtual #212 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 347: checkcast #207 // class java/lang/Number\n 350: invokevirtual #210 // Method java/lang/Number.intValue:()I\n 353: istore 15\n 355: iconst_0\n 356: iload 14\n 358: if_icmpgt 383\n 361: iload 14\n 363: aload_1\n 364: checkcast #39 // class java/util/Collection\n 367: invokeinterface #213, 1 // InterfaceMethod java/util/Collection.size:()I\n 372: if_icmpge 379\n 375: iconst_1\n 376: goto 384\n 379: iconst_0\n 380: goto 384\n 383: iconst_0\n 384: ifeq 528\n 387: iconst_0\n 388: iload 15\n 390: if_icmpgt 421\n 393: iload 15\n 395: aload_1\n 396: iconst_0\n 397: invokeinterface #133, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 402: checkcast #39 // class java/util/Collection\n 405: invokeinterface #213, 1 // InterfaceMethod java/util/Collection.size:()I\n 410: if_icmpge 417\n 413: iconst_1\n 414: goto 422\n 417: iconst_0\n 418: goto 422\n 421: iconst_0\n 422: ifeq 528\n 425: aload_2\n 426: iload 14\n 428: aaload\n 429: iload 15\n 431: aaload\n 432: invokevirtual #214 // Method java/lang/Integer.intValue:()I\n 435: iload 7\n 437: aload_1\n 438: iload 14\n 440: invokeinterface #133, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 445: checkcast #85 // class java/util/List\n 448: iload 15\n 450: invokeinterface #133, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 455: checkcast #207 // class java/lang/Number\n 458: invokevirtual #210 // Method java/lang/Number.intValue:()I\n 461: iadd\n 462: if_icmple 528\n 465: aload_2\n 466: iload 14\n 468: aaload\n 469: iload 15\n 471: iload 7\n 473: aload_1\n 474: iload 14\n 476: invokeinterface #133, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 481: checkcast #85 // class java/util/List\n 484: iload 15\n 486: invokeinterface #133, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 491: checkcast #207 // class java/lang/Number\n 494: invokevirtual #210 // Method java/lang/Number.intValue:()I\n 497: iadd\n 498: invokestatic #79 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 501: aastore\n 502: aload_3\n 503: new #172 // class Day15$Node\n 506: dup\n 507: iload 14\n 509: iload 15\n 511: aload_2\n 512: iload 14\n 514: aaload\n 515: iload 15\n 517: aaload\n 518: invokevirtual #214 // Method java/lang/Integer.intValue:()I\n 521: invokespecial #175 // Method Day15$Node.\"<init>\":(III)V\n 524: invokevirtual #176 // Method java/util/PriorityQueue.add:(Ljava/lang/Object;)Z\n 527: pop\n 528: nop\n 529: nop\n 530: goto 300\n 533: nop\n 534: goto 146\n 537: aload_2\n 538: checkcast #216 // class \"[Ljava/lang/Object;\"\n 541: invokestatic #222 // Method kotlin/collections/ArraysKt.last:([Ljava/lang/Object;)Ljava/lang/Object;\n 544: checkcast #216 // class \"[Ljava/lang/Object;\"\n 547: invokestatic #222 // Method kotlin/collections/ArraysKt.last:([Ljava/lang/Object;)Ljava/lang/Object;\n 550: checkcast #207 // class java/lang/Number\n 553: invokevirtual #210 // Method java/lang/Number.intValue:()I\n 556: istore 4\n 558: getstatic #93 // Field java/lang/System.out:Ljava/io/PrintStream;\n 561: iload 4\n 563: invokevirtual #225 // Method java/io/PrintStream.println:(I)V\n 566: return\n\n public final void part_2();\n Code:\n 0: new #13 // class java/io/File\n 3: dup\n 4: ldc #15 // String ../Input/day15.txt\n 6: invokespecial #18 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: aconst_null\n 10: iconst_1\n 11: aconst_null\n 12: invokestatic #24 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 15: astore_1\n 16: aload_1\n 17: invokeinterface #127, 1 // InterfaceMethod java/util/List.size:()I\n 22: istore_2\n 23: aload_1\n 24: invokestatic #244 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 27: checkcast #55 // class java/lang/String\n 30: invokevirtual #247 // Method java/lang/String.length:()I\n 33: istore_3\n 34: iconst_0\n 35: iload_2\n 36: iconst_5\n 37: imul\n 38: invokestatic #253 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 41: checkcast #26 // class java/lang/Iterable\n 44: astore 5\n 46: iconst_0\n 47: istore 6\n 49: aload 5\n 51: astore 7\n 53: new #28 // class java/util/ArrayList\n 56: dup\n 57: aload 5\n 59: bipush 10\n 61: invokestatic #34 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 64: invokespecial #37 // Method java/util/ArrayList.\"<init>\":(I)V\n 67: checkcast #39 // class java/util/Collection\n 70: astore 8\n 72: iconst_0\n 73: istore 9\n 75: aload 7\n 77: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 82: astore 10\n 84: aload 10\n 86: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 91: ifeq 292\n 94: aload 10\n 96: checkcast #255 // class kotlin/collections/IntIterator\n 99: invokevirtual #258 // Method kotlin/collections/IntIterator.nextInt:()I\n 102: istore 11\n 104: aload 8\n 106: iload 11\n 108: istore 12\n 110: astore 26\n 112: iconst_0\n 113: istore 13\n 115: iconst_0\n 116: iload_3\n 117: iconst_5\n 118: imul\n 119: invokestatic #253 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 122: checkcast #26 // class java/lang/Iterable\n 125: astore 14\n 127: iconst_0\n 128: istore 15\n 130: aload 14\n 132: astore 16\n 134: new #28 // class java/util/ArrayList\n 137: dup\n 138: aload 14\n 140: bipush 10\n 142: invokestatic #34 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 145: invokespecial #37 // Method java/util/ArrayList.\"<init>\":(I)V\n 148: checkcast #39 // class java/util/Collection\n 151: astore 17\n 153: iconst_0\n 154: istore 18\n 156: aload 16\n 158: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 163: astore 19\n 165: aload 19\n 167: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 172: ifeq 273\n 175: aload 19\n 177: checkcast #255 // class kotlin/collections/IntIterator\n 180: invokevirtual #258 // Method kotlin/collections/IntIterator.nextInt:()I\n 183: istore 20\n 185: aload 17\n 187: iload 20\n 189: istore 21\n 191: astore 22\n 193: iconst_0\n 194: istore 23\n 196: aload_1\n 197: iload 12\n 199: iload_2\n 200: irem\n 201: invokeinterface #133, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 206: checkcast #55 // class java/lang/String\n 209: iload 21\n 211: iload_3\n 212: irem\n 213: invokevirtual #262 // Method java/lang/String.charAt:(I)C\n 216: invokestatic #73 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 219: istore 24\n 221: iload 21\n 223: iload_3\n 224: idiv\n 225: iload 12\n 227: iload_2\n 228: idiv\n 229: iadd\n 230: istore 25\n 232: iload 24\n 234: iload 25\n 236: iadd\n 237: bipush 10\n 239: if_icmpge 250\n 242: iload 24\n 244: iload 25\n 246: iadd\n 247: goto 258\n 250: iload 24\n 252: iload 25\n 254: iadd\n 255: bipush 9\n 257: isub\n 258: invokestatic #79 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 261: aload 22\n 263: swap\n 264: invokeinterface #83, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 269: pop\n 270: goto 165\n 273: aload 17\n 275: checkcast #85 // class java/util/List\n 278: nop\n 279: nop\n 280: aload 26\n 282: swap\n 283: invokeinterface #83, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 288: pop\n 289: goto 84\n 292: aload 8\n 294: checkcast #85 // class java/util/List\n 297: nop\n 298: astore 4\n 300: ldc_w #264 // String Puzzle 2:\n 303: getstatic #93 // Field java/lang/System.out:Ljava/io/PrintStream;\n 306: swap\n 307: invokevirtual #99 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 310: aload_0\n 311: aload 4\n 313: invokespecial #103 // Method findShortestPath:(Ljava/util/List;)V\n 316: return\n\n private static final int findShortestPath$lambda$2(Day15$Node, Day15$Node);\n Code:\n 0: aload_0\n 1: invokevirtual #274 // Method Day15$Node.getDist:()I\n 4: aload_1\n 5: invokevirtual #274 // Method Day15$Node.getDist:()I\n 8: isub\n 9: ireturn\n\n private static final int findShortestPath$lambda$3(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 #281, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 8: checkcast #207 // class java/lang/Number\n 11: invokevirtual #210 // Method java/lang/Number.intValue:()I\n 14: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day15$Node.class",
"javap": "Compiled from \"day15.kt\"\npublic final class Day15$Node {\n private final int x;\n\n private final int y;\n\n private final int dist;\n\n public Day15$Node(int, int, int);\n Code:\n 0: aload_0\n 1: invokespecial #9 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #13 // Field x:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field y:I\n 14: aload_0\n 15: iload_3\n 16: putfield #19 // Field dist:I\n 19: return\n\n public Day15$Node(int, int, int, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload 4\n 2: iconst_1\n 3: iand\n 4: ifeq 9\n 7: iconst_0\n 8: istore_1\n 9: iload 4\n 11: iconst_2\n 12: iand\n 13: ifeq 18\n 16: iconst_0\n 17: istore_2\n 18: iload 4\n 20: iconst_4\n 21: iand\n 22: ifeq 27\n 25: iconst_0\n 26: istore_3\n 27: aload_0\n 28: iload_1\n 29: iload_2\n 30: iload_3\n 31: invokespecial #24 // Method \"<init>\":(III)V\n 34: 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 getDist();\n Code:\n 0: aload_0\n 1: getfield #19 // Field dist:I\n 4: ireturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field y:I\n 4: ireturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #19 // Field dist:I\n 4: ireturn\n\n public final Day15$Node copy(int, int, int);\n Code:\n 0: new #2 // class Day15$Node\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: iload_3\n 7: invokespecial #24 // Method \"<init>\":(III)V\n 10: areturn\n\n public static Day15$Node copy$default(Day15$Node, int, int, int, int, java.lang.Object);\n Code:\n 0: iload 4\n 2: iconst_1\n 3: iand\n 4: ifeq 12\n 7: aload_0\n 8: getfield #13 // Field x:I\n 11: istore_1\n 12: iload 4\n 14: iconst_2\n 15: iand\n 16: ifeq 24\n 19: aload_0\n 20: getfield #16 // Field y:I\n 23: istore_2\n 24: iload 4\n 26: iconst_4\n 27: iand\n 28: ifeq 36\n 31: aload_0\n 32: getfield #19 // Field dist:I\n 35: istore_3\n 36: aload_0\n 37: iload_1\n 38: iload_2\n 39: iload_3\n 40: invokevirtual #38 // Method copy:(III)LDay15$Node;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #42 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #43 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #45 // String Node(x=\n 9: invokevirtual #49 // 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 #52 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #54 // String , y=\n 21: invokevirtual #49 // 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 #52 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #56 // String , dist=\n 33: invokevirtual #49 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #19 // Field dist:I\n 40: invokevirtual #52 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #59 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #61 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 51: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: invokestatic #67 // 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 #67 // 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 dist:I\n 29: invokestatic #67 // 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 Day15$Node\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day15$Node\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field x:I\n 25: aload_2\n 26: getfield #13 // Field x:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field y:I\n 38: aload_2\n 39: getfield #16 // Field y:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: aload_0\n 48: getfield #19 // Field dist:I\n 51: aload_2\n 52: getfield #19 // Field dist:I\n 55: if_icmpeq 60\n 58: iconst_0\n 59: ireturn\n 60: iconst_1\n 61: ireturn\n\n public Day15$Node();\n Code:\n 0: aload_0\n 1: iconst_0\n 2: iconst_0\n 3: iconst_0\n 4: bipush 7\n 6: aconst_null\n 7: invokespecial #75 // Method \"<init>\":(IIIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day15Kt.class",
"javap": "Compiled from \"day15.kt\"\npublic final class Day15Kt {\n public static final void print_day_15();\n Code:\n 0: ldc #8 // String \\u001b[33m\n 2: astore_0\n 3: ldc #10 // String \\u001b[0m\n 5: astore_1\n 6: ldc #12 // String \\u001b[32m\n 8: astore_2\n 9: new #14 // class java/lang/StringBuilder\n 12: dup\n 13: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 16: aload_0\n 17: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: ldc #23 // String -\n 22: checkcast #25 // class java/lang/CharSequence\n 25: bipush 25\n 27: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 30: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 33: ldc #33 // String Advent of Code - Day 15\n 35: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 38: ldc #23 // String -\n 40: checkcast #25 // class java/lang/CharSequence\n 43: bipush 25\n 45: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 48: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: aload_1\n 52: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 55: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 58: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 61: swap\n 62: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 65: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: aload_2\n 69: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: invokestatic #55 // Method java/lang/Runtime.getRuntime:()Ljava/lang/Runtime;\n 75: ldc #57 // String figlet Chiton -c -f small\n 77: invokevirtual #61 // Method java/lang/Runtime.exec:(Ljava/lang/String;)Ljava/lang/Process;\n 80: astore_3\n 81: new #63 // class java/io/BufferedReader\n 84: dup\n 85: new #65 // class java/io/InputStreamReader\n 88: dup\n 89: aload_3\n 90: invokevirtual #71 // Method java/lang/Process.getInputStream:()Ljava/io/InputStream;\n 93: invokespecial #74 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;)V\n 96: checkcast #76 // class java/io/Reader\n 99: invokespecial #79 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;)V\n 102: astore 4\n 104: aload 4\n 106: checkcast #76 // class java/io/Reader\n 109: invokedynamic #98, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 114: invokestatic #104 // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V\n 117: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 120: aload_1\n 121: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 124: new #14 // class java/lang/StringBuilder\n 127: dup\n 128: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 131: aload_0\n 132: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 135: ldc #23 // String -\n 137: checkcast #25 // class java/lang/CharSequence\n 140: bipush 33\n 142: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 145: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 148: ldc #106 // String Output\n 150: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 153: ldc #23 // String -\n 155: checkcast #25 // class java/lang/CharSequence\n 158: bipush 33\n 160: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 163: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 166: aload_1\n 167: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 170: bipush 10\n 172: invokevirtual #109 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 175: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 178: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 181: swap\n 182: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 185: return\n\n public static final void main();\n Code:\n 0: invokestatic #120 // Method print_day_15:()V\n 3: new #122 // class Day15\n 6: dup\n 7: invokespecial #123 // Method Day15.\"<init>\":()V\n 10: invokevirtual #126 // Method Day15.part_1:()V\n 13: new #122 // class Day15\n 16: dup\n 17: invokespecial #123 // Method Day15.\"<init>\":()V\n 20: invokevirtual #129 // Method Day15.part_2:()V\n 23: new #14 // class java/lang/StringBuilder\n 26: dup\n 27: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 30: ldc #131 // String \\n\\u001b[33m\n 32: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 35: ldc #133 // String =\n 37: checkcast #25 // class java/lang/CharSequence\n 40: bipush 72\n 42: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 45: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: ldc #135 // String \\u001b[0m\\n\n 50: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 53: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 56: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 59: swap\n 60: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 63: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #138 // Method main:()V\n 3: return\n\n private static final kotlin.Unit print_day_15$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #142 // String it\n 3: invokestatic #148 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: aload_0\n 10: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 13: getstatic #154 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 16: areturn\n}\n",
"javap_err": ""
}
] |
Ad0lphus__AOC2021__02f219e/day21/Kotlin/day21.kt
|
import java.io.*
import java.util.concurrent.atomic.AtomicInteger
fun print_day_21() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 21" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Dirac Dice -c -f small")
val reader = BufferedReader(InputStreamReader(process.inputStream))
reader.forEachLine { println(it) }
println(reset)
println(yellow + "-".repeat(33) + "Output" + "-".repeat(33) + reset + "\n")
}
fun main() {
print_day_21()
Day21().part1()
Day21().part2()
println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}
class Day21 {
fun part1() {
val startPos = File("../Input/day21.txt").readLines().map { it.last().digitToInt() }
val scores = intArrayOf(0, 0)
val space = startPos.toIntArray()
val dice = AtomicInteger()
var diceRolls = 0
fun nextRoll(): Int {
if (dice.get() >= 100) dice.set(0)
diceRolls++
return dice.incrementAndGet()
}
while (true) {
repeat(2) {
val roll = nextRoll() + nextRoll() + nextRoll()
space[it] = (space[it] + roll) % 10
scores[it] += if (space[it] != 0) space[it] else 10
if (scores[it] >= 1000) {
println("Puzzle 1: " + scores[(it + 1) % 2] * diceRolls)
return
}
}
}
}
fun part2() {
data class Universe(val p1: Int, val p2: Int, val s1: Int, val s2: Int)
val startPos = File("../Input/day21.txt").readLines().map { it.last().digitToInt() }
val dp = mutableMapOf<Universe, Pair<Long, Long>>()
fun solve(u: Universe): Pair<Long, Long> {
dp[u]?.let {
return it
}
if (u.s1 >= 21) return 1L to 0L
if (u.s2 >= 21) return 0L to 1L
var ans = 0L to 0L
for (d1 in 1..3) for (d2 in 1..3) for (d3 in 1..3) {
val newP1 = (u.p1 + d1 + d2 + d3 - 1) % 10 + 1
val newS1 = u.s1 + newP1
val (x, y) = solve(Universe(u.p2, newP1, u.s2, newS1))
ans = ans.first + y to ans.second + x
}
return ans.also { dp[u] = it }
}
println(
"Puzzle 2: " +
solve(Universe(startPos[0], startPos[1], 0, 0)).let {
maxOf(it.first, it.second)
}
)
}
}
|
[
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day21$part2$Universe.class",
"javap": "Compiled from \"day21.kt\"\npublic final class Day21$part2$Universe {\n private final int p1;\n\n private final int p2;\n\n private final int s1;\n\n private final int s2;\n\n public Day21$part2$Universe(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 p1:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field p2:I\n 14: aload_0\n 15: iload_3\n 16: putfield #19 // Field s1:I\n 19: aload_0\n 20: iload 4\n 22: putfield #22 // Field s2:I\n 25: return\n\n public final int getP1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field p1:I\n 4: ireturn\n\n public final int getP2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field p2:I\n 4: ireturn\n\n public final int getS1();\n Code:\n 0: aload_0\n 1: getfield #19 // Field s1:I\n 4: ireturn\n\n public final int getS2();\n Code:\n 0: aload_0\n 1: getfield #22 // Field s2:I\n 4: ireturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field p1:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field p2:I\n 4: ireturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #19 // Field s1:I\n 4: ireturn\n\n public final int component4();\n Code:\n 0: aload_0\n 1: getfield #22 // Field s2:I\n 4: ireturn\n\n public final Day21$part2$Universe copy(int, int, int, int);\n Code:\n 0: new #2 // class Day21$part2$Universe\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: iload_3\n 7: iload 4\n 9: invokespecial #37 // Method \"<init>\":(IIII)V\n 12: areturn\n\n public static Day21$part2$Universe copy$default(Day21$part2$Universe, 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 p1: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 p2: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 s1: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 s2: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 #41 // Method copy:(IIII)LDay21$part2$Universe;\n 59: 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 Universe(p1=\n 9: invokevirtual #52 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field p1:I\n 16: invokevirtual #55 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #57 // String , p2=\n 21: invokevirtual #52 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #16 // Field p2:I\n 28: invokevirtual #55 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #59 // String , s1=\n 33: invokevirtual #52 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #19 // Field s1:I\n 40: invokevirtual #55 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 43: ldc #61 // String , s2=\n 45: invokevirtual #52 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: aload_0\n 49: getfield #22 // Field s2:I\n 52: invokevirtual #55 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 55: bipush 41\n 57: invokevirtual #64 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 60: invokevirtual #66 // 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 p1:I\n 4: invokestatic #72 // 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 p2:I\n 16: invokestatic #72 // 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 s1:I\n 29: invokestatic #72 // 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 s2:I\n 42: invokestatic #72 // 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 Day21$part2$Universe\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day21$part2$Universe\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field p1:I\n 25: aload_2\n 26: getfield #13 // Field p1:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field p2:I\n 38: aload_2\n 39: getfield #16 // Field p2:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: aload_0\n 48: getfield #19 // Field s1:I\n 51: aload_2\n 52: getfield #19 // Field s1:I\n 55: if_icmpeq 60\n 58: iconst_0\n 59: ireturn\n 60: aload_0\n 61: getfield #22 // Field s2:I\n 64: aload_2\n 65: getfield #22 // Field s2: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": "Ad0lphus__AOC2021__02f219e/Day21Kt.class",
"javap": "Compiled from \"day21.kt\"\npublic final class Day21Kt {\n public static final void print_day_21();\n Code:\n 0: ldc #8 // String \\u001b[33m\n 2: astore_0\n 3: ldc #10 // String \\u001b[0m\n 5: astore_1\n 6: ldc #12 // String \\u001b[32m\n 8: astore_2\n 9: new #14 // class java/lang/StringBuilder\n 12: dup\n 13: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 16: aload_0\n 17: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: ldc #23 // String -\n 22: checkcast #25 // class java/lang/CharSequence\n 25: bipush 25\n 27: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 30: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 33: ldc #33 // String Advent of Code - Day 21\n 35: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 38: ldc #23 // String -\n 40: checkcast #25 // class java/lang/CharSequence\n 43: bipush 25\n 45: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 48: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: aload_1\n 52: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 55: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 58: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 61: swap\n 62: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 65: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: aload_2\n 69: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: invokestatic #55 // Method java/lang/Runtime.getRuntime:()Ljava/lang/Runtime;\n 75: ldc #57 // String figlet Dirac Dice -c -f small\n 77: invokevirtual #61 // Method java/lang/Runtime.exec:(Ljava/lang/String;)Ljava/lang/Process;\n 80: astore_3\n 81: new #63 // class java/io/BufferedReader\n 84: dup\n 85: new #65 // class java/io/InputStreamReader\n 88: dup\n 89: aload_3\n 90: invokevirtual #71 // Method java/lang/Process.getInputStream:()Ljava/io/InputStream;\n 93: invokespecial #74 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;)V\n 96: checkcast #76 // class java/io/Reader\n 99: invokespecial #79 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;)V\n 102: astore 4\n 104: aload 4\n 106: checkcast #76 // class java/io/Reader\n 109: invokedynamic #98, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 114: invokestatic #104 // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V\n 117: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 120: aload_1\n 121: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 124: new #14 // class java/lang/StringBuilder\n 127: dup\n 128: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 131: aload_0\n 132: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 135: ldc #23 // String -\n 137: checkcast #25 // class java/lang/CharSequence\n 140: bipush 33\n 142: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 145: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 148: ldc #106 // String Output\n 150: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 153: ldc #23 // String -\n 155: checkcast #25 // class java/lang/CharSequence\n 158: bipush 33\n 160: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 163: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 166: aload_1\n 167: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 170: bipush 10\n 172: invokevirtual #109 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 175: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 178: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 181: swap\n 182: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 185: return\n\n public static final void main();\n Code:\n 0: invokestatic #120 // Method print_day_21:()V\n 3: new #122 // class Day21\n 6: dup\n 7: invokespecial #123 // Method Day21.\"<init>\":()V\n 10: invokevirtual #126 // Method Day21.part1:()V\n 13: new #122 // class Day21\n 16: dup\n 17: invokespecial #123 // Method Day21.\"<init>\":()V\n 20: invokevirtual #129 // Method Day21.part2:()V\n 23: new #14 // class java/lang/StringBuilder\n 26: dup\n 27: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 30: ldc #131 // String \\n\\u001b[33m\n 32: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 35: ldc #133 // String =\n 37: checkcast #25 // class java/lang/CharSequence\n 40: bipush 72\n 42: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 45: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: ldc #135 // String \\u001b[0m\\n\n 50: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 53: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 56: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 59: swap\n 60: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 63: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #138 // Method main:()V\n 3: return\n\n private static final kotlin.Unit print_day_21$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #142 // String it\n 3: invokestatic #148 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: aload_0\n 10: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 13: getstatic #154 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 16: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day21.class",
"javap": "Compiled from \"day21.kt\"\npublic final class Day21 {\n public Day21();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final void part1();\n Code:\n 0: new #13 // class java/io/File\n 3: dup\n 4: ldc #15 // String ../Input/day21.txt\n 6: invokespecial #18 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: aconst_null\n 10: iconst_1\n 11: aconst_null\n 12: invokestatic #24 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 15: checkcast #26 // class java/lang/Iterable\n 18: astore_2\n 19: iconst_0\n 20: istore_3\n 21: aload_2\n 22: astore 4\n 24: new #28 // class java/util/ArrayList\n 27: dup\n 28: aload_2\n 29: bipush 10\n 31: invokestatic #34 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 34: invokespecial #37 // Method java/util/ArrayList.\"<init>\":(I)V\n 37: checkcast #39 // class java/util/Collection\n 40: astore 5\n 42: iconst_0\n 43: istore 6\n 45: aload 4\n 47: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 52: astore 7\n 54: aload 7\n 56: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 61: ifeq 113\n 64: aload 7\n 66: invokeinterface #53, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 71: astore 8\n 73: aload 5\n 75: aload 8\n 77: checkcast #55 // class java/lang/String\n 80: astore 9\n 82: astore 11\n 84: iconst_0\n 85: istore 10\n 87: aload 9\n 89: checkcast #57 // class java/lang/CharSequence\n 92: invokestatic #63 // Method kotlin/text/StringsKt.last:(Ljava/lang/CharSequence;)C\n 95: invokestatic #69 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 98: invokestatic #75 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 101: aload 11\n 103: swap\n 104: invokeinterface #79, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 109: pop\n 110: goto 54\n 113: aload 5\n 115: checkcast #81 // class java/util/List\n 118: nop\n 119: astore_1\n 120: iconst_2\n 121: newarray int\n 123: astore_3\n 124: aload_3\n 125: iconst_0\n 126: iconst_0\n 127: iastore\n 128: aload_3\n 129: iconst_1\n 130: iconst_0\n 131: iastore\n 132: aload_3\n 133: astore_2\n 134: aload_1\n 135: checkcast #39 // class java/util/Collection\n 138: invokestatic #85 // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I\n 141: astore_3\n 142: new #87 // class java/util/concurrent/atomic/AtomicInteger\n 145: dup\n 146: invokespecial #88 // Method java/util/concurrent/atomic/AtomicInteger.\"<init>\":()V\n 149: astore 4\n 151: new #90 // class kotlin/jvm/internal/Ref$IntRef\n 154: dup\n 155: invokespecial #91 // Method kotlin/jvm/internal/Ref$IntRef.\"<init>\":()V\n 158: astore 5\n 160: nop\n 161: iconst_2\n 162: istore 6\n 164: iconst_0\n 165: istore 7\n 167: iload 7\n 169: iload 6\n 171: if_icmpge 160\n 174: iload 7\n 176: istore 8\n 178: iconst_0\n 179: istore 9\n 181: aload 4\n 183: aload 5\n 185: invokestatic #95 // Method part1$nextRoll:(Ljava/util/concurrent/atomic/AtomicInteger;Lkotlin/jvm/internal/Ref$IntRef;)I\n 188: aload 4\n 190: aload 5\n 192: invokestatic #95 // Method part1$nextRoll:(Ljava/util/concurrent/atomic/AtomicInteger;Lkotlin/jvm/internal/Ref$IntRef;)I\n 195: iadd\n 196: aload 4\n 198: aload 5\n 200: invokestatic #95 // Method part1$nextRoll:(Ljava/util/concurrent/atomic/AtomicInteger;Lkotlin/jvm/internal/Ref$IntRef;)I\n 203: iadd\n 204: istore 10\n 206: aload_3\n 207: iload 8\n 209: aload_3\n 210: iload 8\n 212: iaload\n 213: iload 10\n 215: iadd\n 216: bipush 10\n 218: irem\n 219: iastore\n 220: aload_2\n 221: iload 8\n 223: aload_2\n 224: iload 8\n 226: iaload\n 227: aload_3\n 228: iload 8\n 230: iaload\n 231: ifeq 241\n 234: aload_3\n 235: iload 8\n 237: iaload\n 238: goto 243\n 241: bipush 10\n 243: iadd\n 244: iastore\n 245: aload_2\n 246: iload 8\n 248: iaload\n 249: sipush 1000\n 252: if_icmplt 295\n 255: new #97 // class java/lang/StringBuilder\n 258: dup\n 259: invokespecial #98 // Method java/lang/StringBuilder.\"<init>\":()V\n 262: ldc #100 // String Puzzle 1:\n 264: invokevirtual #104 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 267: aload_2\n 268: iload 8\n 270: iconst_1\n 271: iadd\n 272: iconst_2\n 273: irem\n 274: iaload\n 275: aload 5\n 277: getfield #108 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 280: imul\n 281: invokevirtual #111 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 284: invokevirtual #115 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 287: getstatic #121 // Field java/lang/System.out:Ljava/io/PrintStream;\n 290: swap\n 291: invokevirtual #127 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 294: return\n 295: nop\n 296: iinc 7, 1\n 299: goto 167\n\n public final void part2();\n Code:\n 0: new #13 // class java/io/File\n 3: dup\n 4: ldc #15 // String ../Input/day21.txt\n 6: invokespecial #18 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: aconst_null\n 10: iconst_1\n 11: aconst_null\n 12: invokestatic #24 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 15: checkcast #26 // class java/lang/Iterable\n 18: astore_2\n 19: iconst_0\n 20: istore_3\n 21: aload_2\n 22: astore 4\n 24: new #28 // class java/util/ArrayList\n 27: dup\n 28: aload_2\n 29: bipush 10\n 31: invokestatic #34 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 34: invokespecial #37 // Method java/util/ArrayList.\"<init>\":(I)V\n 37: checkcast #39 // class java/util/Collection\n 40: astore 5\n 42: iconst_0\n 43: istore 6\n 45: aload 4\n 47: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 52: astore 7\n 54: aload 7\n 56: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 61: ifeq 113\n 64: aload 7\n 66: invokeinterface #53, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 71: astore 8\n 73: aload 5\n 75: aload 8\n 77: checkcast #55 // class java/lang/String\n 80: astore 9\n 82: astore 11\n 84: iconst_0\n 85: istore 10\n 87: aload 9\n 89: checkcast #57 // class java/lang/CharSequence\n 92: invokestatic #63 // Method kotlin/text/StringsKt.last:(Ljava/lang/CharSequence;)C\n 95: invokestatic #69 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 98: invokestatic #75 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 101: aload 11\n 103: swap\n 104: invokeinterface #79, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 109: pop\n 110: goto 54\n 113: aload 5\n 115: checkcast #81 // class java/util/List\n 118: nop\n 119: astore_1\n 120: new #154 // class java/util/LinkedHashMap\n 123: dup\n 124: invokespecial #155 // Method java/util/LinkedHashMap.\"<init>\":()V\n 127: checkcast #157 // class java/util/Map\n 130: astore_2\n 131: new #97 // class java/lang/StringBuilder\n 134: dup\n 135: invokespecial #98 // Method java/lang/StringBuilder.\"<init>\":()V\n 138: ldc #159 // String Puzzle 2:\n 140: invokevirtual #104 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 143: aload_2\n 144: new #161 // class Day21$part2$Universe\n 147: dup\n 148: aload_1\n 149: iconst_0\n 150: invokeinterface #165, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 155: checkcast #167 // class java/lang/Number\n 158: invokevirtual #171 // Method java/lang/Number.intValue:()I\n 161: aload_1\n 162: iconst_1\n 163: invokeinterface #165, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 168: checkcast #167 // class java/lang/Number\n 171: invokevirtual #171 // Method java/lang/Number.intValue:()I\n 174: iconst_0\n 175: iconst_0\n 176: invokespecial #174 // Method Day21$part2$Universe.\"<init>\":(IIII)V\n 179: invokestatic #178 // Method part2$solve:(Ljava/util/Map;LDay21$part2$Universe;)Lkotlin/Pair;\n 182: astore 4\n 184: astore 11\n 186: iconst_0\n 187: istore 5\n 189: aload 4\n 191: invokevirtual #183 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 194: checkcast #167 // class java/lang/Number\n 197: invokevirtual #187 // Method java/lang/Number.longValue:()J\n 200: aload 4\n 202: invokevirtual #190 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 205: checkcast #167 // class java/lang/Number\n 208: invokevirtual #187 // Method java/lang/Number.longValue:()J\n 211: invokestatic #196 // Method java/lang/Math.max:(JJ)J\n 214: nop\n 215: lstore 12\n 217: aload 11\n 219: lload 12\n 221: nop\n 222: invokevirtual #199 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 225: invokevirtual #115 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 228: astore_3\n 229: getstatic #121 // Field java/lang/System.out:Ljava/io/PrintStream;\n 232: aload_3\n 233: invokevirtual #127 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 236: return\n\n private static final int part1$nextRoll(java.util.concurrent.atomic.AtomicInteger, kotlin.jvm.internal.Ref$IntRef);\n Code:\n 0: aload_0\n 1: invokevirtual #206 // Method java/util/concurrent/atomic/AtomicInteger.get:()I\n 4: bipush 100\n 6: if_icmplt 14\n 9: aload_0\n 10: iconst_0\n 11: invokevirtual #209 // Method java/util/concurrent/atomic/AtomicInteger.set:(I)V\n 14: aload_1\n 15: getfield #108 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 18: istore_2\n 19: aload_1\n 20: iload_2\n 21: iconst_1\n 22: iadd\n 23: putfield #108 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 26: aload_0\n 27: invokevirtual #212 // Method java/util/concurrent/atomic/AtomicInteger.incrementAndGet:()I\n 30: ireturn\n\n private static final kotlin.Pair<java.lang.Long, java.lang.Long> part2$solve(java.util.Map<Day21$part2$Universe, kotlin.Pair<java.lang.Long, java.lang.Long>>, Day21$part2$Universe);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokeinterface #216, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: checkcast #180 // class kotlin/Pair\n 10: astore_2\n 11: aload_2\n 12: ifnull 24\n 15: aload_2\n 16: astore 4\n 18: iconst_0\n 19: istore 5\n 21: aload 4\n 23: areturn\n 24: aload_1\n 25: invokevirtual #219 // Method Day21$part2$Universe.getS1:()I\n 28: bipush 21\n 30: if_icmplt 45\n 33: lconst_1\n 34: invokestatic #224 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 37: lconst_0\n 38: invokestatic #224 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 41: invokestatic #230 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 44: areturn\n 45: aload_1\n 46: invokevirtual #233 // Method Day21$part2$Universe.getS2:()I\n 49: bipush 21\n 51: if_icmplt 66\n 54: lconst_0\n 55: invokestatic #224 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 58: lconst_1\n 59: invokestatic #224 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 62: invokestatic #230 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 65: areturn\n 66: lconst_0\n 67: invokestatic #224 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 70: lconst_0\n 71: invokestatic #224 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 74: invokestatic #230 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 77: astore_2\n 78: iconst_1\n 79: istore_3\n 80: iload_3\n 81: iconst_4\n 82: if_icmpge 238\n 85: iconst_1\n 86: istore 4\n 88: iload 4\n 90: iconst_4\n 91: if_icmpge 232\n 94: iconst_1\n 95: istore 5\n 97: iload 5\n 99: iconst_4\n 100: if_icmpge 226\n 103: aload_1\n 104: invokevirtual #236 // Method Day21$part2$Universe.getP1:()I\n 107: iload_3\n 108: iadd\n 109: iload 4\n 111: iadd\n 112: iload 5\n 114: iadd\n 115: iconst_1\n 116: isub\n 117: bipush 10\n 119: irem\n 120: iconst_1\n 121: iadd\n 122: istore 6\n 124: aload_1\n 125: invokevirtual #219 // Method Day21$part2$Universe.getS1:()I\n 128: iload 6\n 130: iadd\n 131: istore 7\n 133: aload_0\n 134: new #161 // class Day21$part2$Universe\n 137: dup\n 138: aload_1\n 139: invokevirtual #239 // Method Day21$part2$Universe.getP2:()I\n 142: iload 6\n 144: aload_1\n 145: invokevirtual #233 // Method Day21$part2$Universe.getS2:()I\n 148: iload 7\n 150: invokespecial #174 // Method Day21$part2$Universe.\"<init>\":(IIII)V\n 153: invokestatic #178 // Method part2$solve:(Ljava/util/Map;LDay21$part2$Universe;)Lkotlin/Pair;\n 156: astore 8\n 158: aload 8\n 160: invokevirtual #242 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 163: checkcast #167 // class java/lang/Number\n 166: invokevirtual #187 // Method java/lang/Number.longValue:()J\n 169: lstore 9\n 171: aload 8\n 173: invokevirtual #245 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 176: checkcast #167 // class java/lang/Number\n 179: invokevirtual #187 // Method java/lang/Number.longValue:()J\n 182: lstore 11\n 184: aload_2\n 185: invokevirtual #183 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 188: checkcast #167 // class java/lang/Number\n 191: invokevirtual #187 // Method java/lang/Number.longValue:()J\n 194: lload 11\n 196: ladd\n 197: invokestatic #224 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 200: aload_2\n 201: invokevirtual #190 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 204: checkcast #167 // class java/lang/Number\n 207: invokevirtual #187 // Method java/lang/Number.longValue:()J\n 210: lload 9\n 212: ladd\n 213: invokestatic #224 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 216: invokestatic #230 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 219: astore_2\n 220: iinc 5, 1\n 223: goto 97\n 226: iinc 4, 1\n 229: goto 88\n 232: iinc 3, 1\n 235: goto 80\n 238: aload_2\n 239: astore_3\n 240: aload_3\n 241: astore 4\n 243: iconst_0\n 244: istore 5\n 246: aload_0\n 247: aload_1\n 248: aload 4\n 250: invokeinterface #249, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 255: pop\n 256: nop\n 257: aload_3\n 258: areturn\n}\n",
"javap_err": ""
}
] |
Ad0lphus__AOC2021__02f219e/day14/Kotlin/day14.kt
|
import java.io.*
fun print_day_14() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 14" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Extended Polymerization -c -f small")
val reader = BufferedReader(InputStreamReader(process.inputStream))
reader.forEachLine { println(it) }
println(reset)
println(yellow + "-".repeat(33) + "Output" + "-".repeat(33) + reset + "\n")
}
fun main() {
print_day_14()
Day14().part_1()
Day14().part_2()
println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}
class Day14 {
val lines = File("../Input/day14.txt").readLines()
val polyTemplate = lines.first()
fun part_1() {
val pairInsertions = lines.drop(2).map {
val (pair, insertion) = it.split(" -> ")
pair to insertion
}
var polyIteration = polyTemplate
for (step in 1..10) {
polyIteration = polyIteration.fold("") { str, curr ->
val pairCheck = "" + (str.lastOrNull() ?: "") + curr
val insert = pairInsertions.find { it.first == pairCheck } ?.second ?: ""
str + insert + curr
}
}
val elementCounts = polyIteration.groupBy { it }.map { it.key to it.value.size }.sortedBy { it.second }
val ans = elementCounts.last().second - elementCounts.first().second
println("Puzzle 1: $ans")
}
fun part_2() {
val insertPattern = lines.drop(2).map { it.split(" -> ") }.associate { it[0] to it[1] }
var pairFrequency = mutableMapOf<String, Long>()
polyTemplate.windowed(2).forEach{ pairFrequency.put(it, pairFrequency.getOrDefault(it, 0) + 1) }
for (step in 1..40) {
val updatedFrequencies = mutableMapOf<String, Long>()
pairFrequency.forEach {
val key1 = it.key[0] + insertPattern[it.key]!!
val key2 = insertPattern[it.key]!! + it.key[1]
updatedFrequencies.put(key1, updatedFrequencies.getOrDefault(key1, 0) + it.value)
updatedFrequencies.put(key2, updatedFrequencies.getOrDefault(key2, 0) + it.value)
}
pairFrequency = updatedFrequencies
}
val charFrequency = pairFrequency.toList().fold(mutableMapOf<Char, Long>()) { acc, pair ->
acc.put(pair.first[0], acc.getOrDefault(pair.first[0], 0) + pair.second)
acc
}
charFrequency.put(polyTemplate.last(), charFrequency.getOrDefault(polyTemplate.last(), 0) + 1)
val sorted = charFrequency.values.sorted()
val ans = sorted.last() - sorted.first()
println("Puzzle 2: $ans")
}
}
|
[
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day14Kt.class",
"javap": "Compiled from \"day14.kt\"\npublic final class Day14Kt {\n public static final void print_day_14();\n Code:\n 0: ldc #8 // String \\u001b[33m\n 2: astore_0\n 3: ldc #10 // String \\u001b[0m\n 5: astore_1\n 6: ldc #12 // String \\u001b[32m\n 8: astore_2\n 9: new #14 // class java/lang/StringBuilder\n 12: dup\n 13: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 16: aload_0\n 17: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: ldc #23 // String -\n 22: checkcast #25 // class java/lang/CharSequence\n 25: bipush 25\n 27: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 30: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 33: ldc #33 // String Advent of Code - Day 14\n 35: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 38: ldc #23 // String -\n 40: checkcast #25 // class java/lang/CharSequence\n 43: bipush 25\n 45: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 48: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: aload_1\n 52: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 55: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 58: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 61: swap\n 62: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 65: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: aload_2\n 69: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: invokestatic #55 // Method java/lang/Runtime.getRuntime:()Ljava/lang/Runtime;\n 75: ldc #57 // String figlet Extended Polymerization -c -f small\n 77: invokevirtual #61 // Method java/lang/Runtime.exec:(Ljava/lang/String;)Ljava/lang/Process;\n 80: astore_3\n 81: new #63 // class java/io/BufferedReader\n 84: dup\n 85: new #65 // class java/io/InputStreamReader\n 88: dup\n 89: aload_3\n 90: invokevirtual #71 // Method java/lang/Process.getInputStream:()Ljava/io/InputStream;\n 93: invokespecial #74 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;)V\n 96: checkcast #76 // class java/io/Reader\n 99: invokespecial #79 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;)V\n 102: astore 4\n 104: aload 4\n 106: checkcast #76 // class java/io/Reader\n 109: invokedynamic #98, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 114: invokestatic #104 // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V\n 117: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 120: aload_1\n 121: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 124: new #14 // class java/lang/StringBuilder\n 127: dup\n 128: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 131: aload_0\n 132: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 135: ldc #23 // String -\n 137: checkcast #25 // class java/lang/CharSequence\n 140: bipush 33\n 142: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 145: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 148: ldc #106 // String Output\n 150: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 153: ldc #23 // String -\n 155: checkcast #25 // class java/lang/CharSequence\n 158: bipush 33\n 160: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 163: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 166: aload_1\n 167: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 170: bipush 10\n 172: invokevirtual #109 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 175: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 178: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 181: swap\n 182: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 185: return\n\n public static final void main();\n Code:\n 0: invokestatic #120 // Method print_day_14:()V\n 3: new #122 // class Day14\n 6: dup\n 7: invokespecial #123 // Method Day14.\"<init>\":()V\n 10: invokevirtual #126 // Method Day14.part_1:()V\n 13: new #122 // class Day14\n 16: dup\n 17: invokespecial #123 // Method Day14.\"<init>\":()V\n 20: invokevirtual #129 // Method Day14.part_2:()V\n 23: new #14 // class java/lang/StringBuilder\n 26: dup\n 27: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 30: ldc #131 // String \\n\\u001b[33m\n 32: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 35: ldc #133 // String =\n 37: checkcast #25 // class java/lang/CharSequence\n 40: bipush 72\n 42: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 45: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: ldc #135 // String \\u001b[0m\\n\n 50: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 53: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 56: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 59: swap\n 60: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 63: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #138 // Method main:()V\n 3: return\n\n private static final kotlin.Unit print_day_14$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #142 // String it\n 3: invokestatic #148 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: aload_0\n 10: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 13: getstatic #154 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 16: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day14.class",
"javap": "Compiled from \"day14.kt\"\npublic final class Day14 {\n private final java.util.List<java.lang.String> lines;\n\n private final java.lang.String polyTemplate;\n\n public Day14();\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 java/io/File\n 8: dup\n 9: ldc #12 // String ../Input/day14.txt\n 11: invokespecial #15 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 14: aconst_null\n 15: iconst_1\n 16: aconst_null\n 17: invokestatic #21 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 20: putfield #25 // Field lines:Ljava/util/List;\n 23: aload_0\n 24: aload_0\n 25: getfield #25 // Field lines:Ljava/util/List;\n 28: invokestatic #31 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 31: checkcast #33 // class java/lang/String\n 34: putfield #37 // Field polyTemplate:Ljava/lang/String;\n 37: return\n\n public final java.util.List<java.lang.String> getLines();\n Code:\n 0: aload_0\n 1: getfield #25 // Field lines:Ljava/util/List;\n 4: areturn\n\n public final java.lang.String getPolyTemplate();\n Code:\n 0: aload_0\n 1: getfield #37 // Field polyTemplate:Ljava/lang/String;\n 4: areturn\n\n public final void part_1();\n Code:\n 0: aload_0\n 1: getfield #25 // Field lines:Ljava/util/List;\n 4: checkcast #48 // class java/lang/Iterable\n 7: iconst_2\n 8: invokestatic #52 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 11: checkcast #48 // class java/lang/Iterable\n 14: astore_2\n 15: iconst_0\n 16: istore_3\n 17: aload_2\n 18: astore 4\n 20: new #54 // class java/util/ArrayList\n 23: dup\n 24: aload_2\n 25: bipush 10\n 27: invokestatic #58 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 30: invokespecial #61 // Method java/util/ArrayList.\"<init>\":(I)V\n 33: checkcast #63 // class java/util/Collection\n 36: astore 5\n 38: iconst_0\n 39: istore 6\n 41: aload 4\n 43: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 48: astore 7\n 50: aload 7\n 52: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 57: ifeq 157\n 60: aload 7\n 62: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 67: astore 8\n 69: aload 5\n 71: aload 8\n 73: checkcast #33 // class java/lang/String\n 76: astore 9\n 78: astore 20\n 80: iconst_0\n 81: istore 10\n 83: aload 9\n 85: checkcast #79 // class java/lang/CharSequence\n 88: iconst_1\n 89: anewarray #33 // class java/lang/String\n 92: astore 11\n 94: aload 11\n 96: iconst_0\n 97: ldc #81 // String ->\n 99: aastore\n 100: aload 11\n 102: iconst_0\n 103: iconst_0\n 104: bipush 6\n 106: aconst_null\n 107: invokestatic #87 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 110: astore 12\n 112: aload 12\n 114: iconst_0\n 115: invokeinterface #93, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 120: checkcast #33 // class java/lang/String\n 123: astore 11\n 125: aload 12\n 127: iconst_1\n 128: invokeinterface #93, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 133: checkcast #33 // class java/lang/String\n 136: astore 13\n 138: aload 11\n 140: aload 13\n 142: invokestatic #99 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 145: aload 20\n 147: swap\n 148: invokeinterface #103, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 153: pop\n 154: goto 50\n 157: aload 5\n 159: checkcast #89 // class java/util/List\n 162: nop\n 163: astore_1\n 164: aload_0\n 165: getfield #37 // Field polyTemplate:Ljava/lang/String;\n 168: astore_2\n 169: iconst_1\n 170: istore_3\n 171: iload_3\n 172: bipush 11\n 174: if_icmpge 398\n 177: aload_2\n 178: checkcast #79 // class java/lang/CharSequence\n 181: astore 4\n 183: ldc #105 // String\n 185: astore 5\n 187: iconst_0\n 188: istore 6\n 190: aload 5\n 192: astore 7\n 194: iconst_0\n 195: istore 8\n 197: iload 8\n 199: aload 4\n 201: invokeinterface #109, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 206: if_icmpge 389\n 209: aload 4\n 211: iload 8\n 213: invokeinterface #113, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 218: istore 9\n 220: aload 7\n 222: iload 9\n 224: istore 10\n 226: astore 11\n 228: iconst_0\n 229: istore 12\n 231: new #115 // class java/lang/StringBuilder\n 234: dup\n 235: invokespecial #116 // Method java/lang/StringBuilder.\"<init>\":()V\n 238: ldc #105 // String\n 240: invokevirtual #120 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 243: aload 11\n 245: checkcast #79 // class java/lang/CharSequence\n 248: invokestatic #124 // Method kotlin/text/StringsKt.lastOrNull:(Ljava/lang/CharSequence;)Ljava/lang/Character;\n 251: dup\n 252: ifnonnull 258\n 255: pop\n 256: ldc #105 // String\n 258: invokevirtual #127 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 261: iload 10\n 263: invokevirtual #130 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 266: invokevirtual #133 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 269: astore 13\n 271: aload_1\n 272: checkcast #48 // class java/lang/Iterable\n 275: astore 14\n 277: aload 14\n 279: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 284: astore 15\n 286: aload 15\n 288: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 293: ifeq 333\n 296: aload 15\n 298: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 303: astore 16\n 305: aload 16\n 307: checkcast #135 // class kotlin/Pair\n 310: astore 17\n 312: iconst_0\n 313: istore 18\n 315: aload 17\n 317: invokevirtual #138 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 320: aload 13\n 322: invokestatic #144 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 325: ifeq 286\n 328: aload 16\n 330: goto 334\n 333: aconst_null\n 334: checkcast #135 // class kotlin/Pair\n 337: dup\n 338: ifnull 351\n 341: invokevirtual #147 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 344: checkcast #33 // class java/lang/String\n 347: dup\n 348: ifnonnull 354\n 351: pop\n 352: ldc #105 // String\n 354: astore 19\n 356: new #115 // class java/lang/StringBuilder\n 359: dup\n 360: invokespecial #116 // Method java/lang/StringBuilder.\"<init>\":()V\n 363: aload 11\n 365: invokevirtual #120 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 368: aload 19\n 370: invokevirtual #120 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 373: iload 10\n 375: invokevirtual #130 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 378: invokevirtual #133 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 381: astore 7\n 383: iinc 8, 1\n 386: goto 197\n 389: aload 7\n 391: astore_2\n 392: iinc 3, 1\n 395: goto 171\n 398: aload_2\n 399: checkcast #79 // class java/lang/CharSequence\n 402: astore 4\n 404: iconst_0\n 405: istore 5\n 407: aload 4\n 409: astore 6\n 411: new #149 // class java/util/LinkedHashMap\n 414: dup\n 415: invokespecial #150 // Method java/util/LinkedHashMap.\"<init>\":()V\n 418: checkcast #152 // class java/util/Map\n 421: astore 7\n 423: iconst_0\n 424: istore 8\n 426: iconst_0\n 427: istore 9\n 429: iload 9\n 431: aload 6\n 433: invokeinterface #109, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 438: if_icmpge 548\n 441: aload 6\n 443: iload 9\n 445: invokeinterface #113, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 450: istore 10\n 452: iload 10\n 454: istore 11\n 456: iconst_0\n 457: istore 12\n 459: iload 11\n 461: invokestatic #158 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 464: astore 13\n 466: aload 7\n 468: astore 14\n 470: iconst_0\n 471: istore 15\n 473: aload 14\n 475: aload 13\n 477: invokeinterface #161, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 482: astore 16\n 484: aload 16\n 486: ifnonnull 521\n 489: iconst_0\n 490: istore 17\n 492: new #54 // class java/util/ArrayList\n 495: dup\n 496: invokespecial #162 // Method java/util/ArrayList.\"<init>\":()V\n 499: checkcast #89 // class java/util/List\n 502: astore 17\n 504: aload 14\n 506: aload 13\n 508: aload 17\n 510: invokeinterface #166, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 515: pop\n 516: aload 17\n 518: goto 523\n 521: aload 16\n 523: nop\n 524: checkcast #89 // class java/util/List\n 527: astore 11\n 529: aload 11\n 531: iload 10\n 533: invokestatic #158 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 536: invokeinterface #167, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 541: pop\n 542: iinc 9, 1\n 545: goto 429\n 548: aload 7\n 550: nop\n 551: astore 4\n 553: nop\n 554: iconst_0\n 555: istore 5\n 557: aload 4\n 559: astore 6\n 561: new #54 // class java/util/ArrayList\n 564: dup\n 565: aload 4\n 567: invokeinterface #170, 1 // InterfaceMethod java/util/Map.size:()I\n 572: invokespecial #61 // Method java/util/ArrayList.\"<init>\":(I)V\n 575: checkcast #63 // class java/util/Collection\n 578: astore 7\n 580: iconst_0\n 581: istore 8\n 583: aload 6\n 585: invokeinterface #174, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 590: invokeinterface #177, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 595: astore 9\n 597: aload 9\n 599: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 604: ifeq 670\n 607: aload 9\n 609: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 614: checkcast #179 // class java/util/Map$Entry\n 617: astore 10\n 619: aload 7\n 621: aload 10\n 623: astore 11\n 625: astore 20\n 627: iconst_0\n 628: istore 12\n 630: aload 11\n 632: invokeinterface #182, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 637: aload 11\n 639: invokeinterface #185, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 644: checkcast #89 // class java/util/List\n 647: invokeinterface #186, 1 // InterfaceMethod java/util/List.size:()I\n 652: invokestatic #191 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 655: invokestatic #99 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 658: aload 20\n 660: swap\n 661: invokeinterface #103, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 666: pop\n 667: goto 597\n 670: aload 7\n 672: checkcast #89 // class java/util/List\n 675: nop\n 676: checkcast #48 // class java/lang/Iterable\n 679: astore 4\n 681: nop\n 682: iconst_0\n 683: istore 5\n 685: aload 4\n 687: new #193 // class Day14$part_1$$inlined$sortedBy$1\n 690: dup\n 691: invokespecial #194 // Method Day14$part_1$$inlined$sortedBy$1.\"<init>\":()V\n 694: checkcast #196 // class java/util/Comparator\n 697: invokestatic #200 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 700: astore_3\n 701: aload_3\n 702: invokestatic #203 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 705: checkcast #135 // class kotlin/Pair\n 708: invokevirtual #147 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 711: checkcast #205 // class java/lang/Number\n 714: invokevirtual #208 // Method java/lang/Number.intValue:()I\n 717: aload_3\n 718: invokestatic #31 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 721: checkcast #135 // class kotlin/Pair\n 724: invokevirtual #147 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 727: checkcast #205 // class java/lang/Number\n 730: invokevirtual #208 // Method java/lang/Number.intValue:()I\n 733: isub\n 734: istore 4\n 736: new #115 // class java/lang/StringBuilder\n 739: dup\n 740: invokespecial #116 // Method java/lang/StringBuilder.\"<init>\":()V\n 743: ldc #210 // String Puzzle 1:\n 745: invokevirtual #120 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 748: iload 4\n 750: invokevirtual #213 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 753: invokevirtual #133 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 756: getstatic #219 // Field java/lang/System.out:Ljava/io/PrintStream;\n 759: swap\n 760: invokevirtual #225 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 763: return\n\n public final void part_2();\n Code:\n 0: aload_0\n 1: getfield #25 // Field lines:Ljava/util/List;\n 4: checkcast #48 // class java/lang/Iterable\n 7: iconst_2\n 8: invokestatic #52 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 11: checkcast #48 // class java/lang/Iterable\n 14: astore_2\n 15: iconst_0\n 16: istore_3\n 17: aload_2\n 18: astore 4\n 20: new #54 // class java/util/ArrayList\n 23: dup\n 24: aload_2\n 25: bipush 10\n 27: invokestatic #58 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 30: invokespecial #61 // Method java/util/ArrayList.\"<init>\":(I)V\n 33: checkcast #63 // class java/util/Collection\n 36: astore 5\n 38: iconst_0\n 39: istore 6\n 41: aload 4\n 43: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 48: astore 7\n 50: aload 7\n 52: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 57: ifeq 122\n 60: aload 7\n 62: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 67: astore 8\n 69: aload 5\n 71: aload 8\n 73: checkcast #33 // class java/lang/String\n 76: astore 9\n 78: astore 14\n 80: iconst_0\n 81: istore 10\n 83: aload 9\n 85: checkcast #79 // class java/lang/CharSequence\n 88: iconst_1\n 89: anewarray #33 // class java/lang/String\n 92: astore 11\n 94: aload 11\n 96: iconst_0\n 97: ldc #81 // String ->\n 99: aastore\n 100: aload 11\n 102: iconst_0\n 103: iconst_0\n 104: bipush 6\n 106: aconst_null\n 107: invokestatic #87 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 110: aload 14\n 112: swap\n 113: invokeinterface #103, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 118: pop\n 119: goto 50\n 122: aload 5\n 124: checkcast #89 // class java/util/List\n 127: nop\n 128: checkcast #48 // class java/lang/Iterable\n 131: astore_2\n 132: nop\n 133: iconst_0\n 134: istore_3\n 135: aload_2\n 136: bipush 10\n 138: invokestatic #58 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 141: invokestatic #283 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 144: bipush 16\n 146: invokestatic #289 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 149: istore 4\n 151: aload_2\n 152: astore 5\n 154: new #149 // class java/util/LinkedHashMap\n 157: dup\n 158: iload 4\n 160: invokespecial #290 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 163: checkcast #152 // class java/util/Map\n 166: astore 6\n 168: iconst_0\n 169: istore 7\n 171: aload 5\n 173: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 178: astore 8\n 180: aload 8\n 182: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 187: ifeq 255\n 190: aload 8\n 192: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 197: astore 9\n 199: aload 6\n 201: astore 10\n 203: aload 9\n 205: checkcast #89 // class java/util/List\n 208: astore 11\n 210: iconst_0\n 211: istore 12\n 213: aload 11\n 215: iconst_0\n 216: invokeinterface #93, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 221: aload 11\n 223: iconst_1\n 224: invokeinterface #93, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 229: invokestatic #99 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 232: astore 11\n 234: aload 10\n 236: aload 11\n 238: invokevirtual #138 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 241: aload 11\n 243: invokevirtual #147 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 246: invokeinterface #166, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 251: pop\n 252: goto 180\n 255: aload 6\n 257: nop\n 258: astore_1\n 259: aconst_null\n 260: astore_2\n 261: new #149 // class java/util/LinkedHashMap\n 264: dup\n 265: invokespecial #150 // Method java/util/LinkedHashMap.\"<init>\":()V\n 268: checkcast #152 // class java/util/Map\n 271: astore_2\n 272: aload_0\n 273: getfield #37 // Field polyTemplate:Ljava/lang/String;\n 276: checkcast #79 // class java/lang/CharSequence\n 279: iconst_2\n 280: iconst_0\n 281: iconst_0\n 282: bipush 6\n 284: aconst_null\n 285: invokestatic #294 // Method kotlin/text/StringsKt.windowed$default:(Ljava/lang/CharSequence;IIZILjava/lang/Object;)Ljava/util/List;\n 288: checkcast #48 // class java/lang/Iterable\n 291: astore_3\n 292: iconst_0\n 293: istore 4\n 295: aload_3\n 296: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 301: astore 5\n 303: aload 5\n 305: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 310: ifeq 368\n 313: aload 5\n 315: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 320: astore 6\n 322: aload 6\n 324: checkcast #33 // class java/lang/String\n 327: astore 7\n 329: iconst_0\n 330: istore 8\n 332: aload_2\n 333: aload 7\n 335: aload_2\n 336: aload 7\n 338: lconst_0\n 339: invokestatic #299 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 342: invokeinterface #302, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 347: checkcast #205 // class java/lang/Number\n 350: invokevirtual #306 // Method java/lang/Number.longValue:()J\n 353: lconst_1\n 354: ladd\n 355: invokestatic #299 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 358: invokeinterface #166, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 363: pop\n 364: nop\n 365: goto 303\n 368: nop\n 369: iconst_1\n 370: istore_3\n 371: iload_3\n 372: bipush 41\n 374: if_icmpge 657\n 377: new #149 // class java/util/LinkedHashMap\n 380: dup\n 381: invokespecial #150 // Method java/util/LinkedHashMap.\"<init>\":()V\n 384: checkcast #152 // class java/util/Map\n 387: astore 4\n 389: aload_2\n 390: astore 5\n 392: iconst_0\n 393: istore 6\n 395: aload 5\n 397: invokeinterface #174, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 402: invokeinterface #177, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 407: astore 7\n 409: aload 7\n 411: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 416: ifeq 647\n 419: aload 7\n 421: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 426: checkcast #179 // class java/util/Map$Entry\n 429: astore 8\n 431: aload 8\n 433: astore 9\n 435: iconst_0\n 436: istore 10\n 438: aload 9\n 440: invokeinterface #182, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 445: checkcast #33 // class java/lang/String\n 448: iconst_0\n 449: invokevirtual #307 // Method java/lang/String.charAt:(I)C\n 452: istore 11\n 454: aload_1\n 455: aload 9\n 457: invokeinterface #182, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 462: invokeinterface #161, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 467: dup\n 468: invokestatic #310 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 471: checkcast #33 // class java/lang/String\n 474: astore 12\n 476: new #115 // class java/lang/StringBuilder\n 479: dup\n 480: invokespecial #116 // Method java/lang/StringBuilder.\"<init>\":()V\n 483: iload 11\n 485: invokevirtual #130 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 488: aload 12\n 490: invokevirtual #120 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 493: invokevirtual #133 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 496: astore 13\n 498: new #115 // class java/lang/StringBuilder\n 501: dup\n 502: invokespecial #116 // Method java/lang/StringBuilder.\"<init>\":()V\n 505: aload_1\n 506: aload 9\n 508: invokeinterface #182, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 513: invokeinterface #161, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 518: dup\n 519: invokestatic #310 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 522: checkcast #33 // class java/lang/String\n 525: invokevirtual #120 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 528: aload 9\n 530: invokeinterface #182, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 535: checkcast #33 // class java/lang/String\n 538: iconst_1\n 539: invokevirtual #307 // Method java/lang/String.charAt:(I)C\n 542: invokevirtual #130 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 545: invokevirtual #133 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 548: astore 11\n 550: aload 4\n 552: aload 13\n 554: aload 4\n 556: aload 13\n 558: lconst_0\n 559: invokestatic #299 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 562: invokeinterface #302, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 567: checkcast #205 // class java/lang/Number\n 570: invokevirtual #306 // Method java/lang/Number.longValue:()J\n 573: aload 9\n 575: invokeinterface #185, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 580: checkcast #205 // class java/lang/Number\n 583: invokevirtual #306 // Method java/lang/Number.longValue:()J\n 586: ladd\n 587: invokestatic #299 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 590: invokeinterface #166, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 595: pop\n 596: aload 4\n 598: aload 11\n 600: aload 4\n 602: aload 11\n 604: lconst_0\n 605: invokestatic #299 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 608: invokeinterface #302, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 613: checkcast #205 // class java/lang/Number\n 616: invokevirtual #306 // Method java/lang/Number.longValue:()J\n 619: aload 9\n 621: invokeinterface #185, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 626: checkcast #205 // class java/lang/Number\n 629: invokevirtual #306 // Method java/lang/Number.longValue:()J\n 632: ladd\n 633: invokestatic #299 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 636: invokeinterface #166, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 641: pop\n 642: nop\n 643: nop\n 644: goto 409\n 647: nop\n 648: aload 4\n 650: astore_2\n 651: iinc 3, 1\n 654: goto 371\n 657: aload_2\n 658: invokestatic #314 // Method kotlin/collections/MapsKt.toList:(Ljava/util/Map;)Ljava/util/List;\n 661: checkcast #48 // class java/lang/Iterable\n 664: astore 4\n 666: new #149 // class java/util/LinkedHashMap\n 669: dup\n 670: invokespecial #150 // Method java/util/LinkedHashMap.\"<init>\":()V\n 673: checkcast #152 // class java/util/Map\n 676: astore 5\n 678: nop\n 679: iconst_0\n 680: istore 6\n 682: aload 5\n 684: astore 7\n 686: aload 4\n 688: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 693: astore 8\n 695: aload 8\n 697: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 702: ifeq 805\n 705: aload 8\n 707: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 712: astore 9\n 714: aload 7\n 716: aload 9\n 718: checkcast #135 // class kotlin/Pair\n 721: astore 10\n 723: astore 11\n 725: iconst_0\n 726: istore 12\n 728: aload 11\n 730: aload 10\n 732: invokevirtual #138 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 735: checkcast #33 // class java/lang/String\n 738: iconst_0\n 739: invokevirtual #307 // Method java/lang/String.charAt:(I)C\n 742: invokestatic #158 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 745: aload 11\n 747: aload 10\n 749: invokevirtual #138 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 752: checkcast #33 // class java/lang/String\n 755: iconst_0\n 756: invokevirtual #307 // Method java/lang/String.charAt:(I)C\n 759: invokestatic #158 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 762: lconst_0\n 763: invokestatic #299 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 766: invokeinterface #302, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 771: checkcast #205 // class java/lang/Number\n 774: invokevirtual #306 // Method java/lang/Number.longValue:()J\n 777: aload 10\n 779: invokevirtual #147 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 782: checkcast #205 // class java/lang/Number\n 785: invokevirtual #306 // Method java/lang/Number.longValue:()J\n 788: ladd\n 789: invokestatic #299 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 792: invokeinterface #166, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 797: pop\n 798: aload 11\n 800: astore 7\n 802: goto 695\n 805: aload 7\n 807: astore_3\n 808: aload_3\n 809: aload_0\n 810: getfield #37 // Field polyTemplate:Ljava/lang/String;\n 813: checkcast #79 // class java/lang/CharSequence\n 816: invokestatic #317 // Method kotlin/text/StringsKt.last:(Ljava/lang/CharSequence;)C\n 819: invokestatic #158 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 822: aload_3\n 823: aload_0\n 824: getfield #37 // Field polyTemplate:Ljava/lang/String;\n 827: checkcast #79 // class java/lang/CharSequence\n 830: invokestatic #317 // Method kotlin/text/StringsKt.last:(Ljava/lang/CharSequence;)C\n 833: invokestatic #158 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 836: lconst_0\n 837: invokestatic #299 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 840: invokeinterface #302, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 845: checkcast #205 // class java/lang/Number\n 848: invokevirtual #306 // Method java/lang/Number.longValue:()J\n 851: lconst_1\n 852: ladd\n 853: invokestatic #299 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 856: invokeinterface #166, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 861: pop\n 862: aload_3\n 863: invokeinterface #321, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 868: checkcast #48 // class java/lang/Iterable\n 871: invokestatic #325 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;\n 874: astore 4\n 876: aload 4\n 878: invokestatic #203 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 881: checkcast #205 // class java/lang/Number\n 884: invokevirtual #306 // Method java/lang/Number.longValue:()J\n 887: aload 4\n 889: invokestatic #31 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 892: checkcast #205 // class java/lang/Number\n 895: invokevirtual #306 // Method java/lang/Number.longValue:()J\n 898: lsub\n 899: lstore 5\n 901: new #115 // class java/lang/StringBuilder\n 904: dup\n 905: invokespecial #116 // Method java/lang/StringBuilder.\"<init>\":()V\n 908: ldc_w #327 // String Puzzle 2:\n 911: invokevirtual #120 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 914: lload 5\n 916: invokevirtual #330 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 919: invokevirtual #133 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 922: getstatic #219 // Field java/lang/System.out:Ljava/io/PrintStream;\n 925: swap\n 926: invokevirtual #225 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 929: return\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day14$part_1$$inlined$sortedBy$1.class",
"javap": "Compiled from \"Comparisons.kt\"\npublic final class Day14$part_1$$inlined$sortedBy$1<T> implements java.util.Comparator {\n public Day14$part_1$$inlined$sortedBy$1();\n Code:\n 0: aload_0\n 1: invokespecial #16 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int compare(T, T);\n Code:\n 0: aload_1\n 1: checkcast #23 // class kotlin/Pair\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 12: checkcast #29 // class java/lang/Integer\n 15: checkcast #31 // class java/lang/Comparable\n 18: aload_2\n 19: checkcast #23 // class kotlin/Pair\n 22: astore_3\n 23: astore 5\n 25: iconst_0\n 26: istore 4\n 28: aload_3\n 29: invokevirtual #27 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 32: checkcast #29 // class java/lang/Integer\n 35: aload 5\n 37: swap\n 38: checkcast #31 // class java/lang/Comparable\n 41: invokestatic #37 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I\n 44: ireturn\n}\n",
"javap_err": ""
}
] |
Ad0lphus__AOC2021__02f219e/day04/Kotlin/day04.kt
|
import java.io.*
fun print_day_4() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 4" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Giant Squid -c -f small")
val reader = BufferedReader(InputStreamReader(process.inputStream))
reader.forEachLine { println(it) }
println(reset)
println(yellow + "-".repeat(33) + "Output" + "-".repeat(33) + reset + "\n")
}
fun main() {
print_day_4()
print("Puzzle 1: ")
Day4().part_1()
print("Puzzle 2: ")
Day4().part_2()
println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}
class Day4 {
private val lines = File("../Input/day4.txt").readLines()
private val drawOrder = lines[0].split(",").map { it.toInt() }
private val boards =
lines.drop(1).windowed(6, 6) {
it.drop(1).map { line ->
line.trim().split(" ", " ").map { numStr -> numStr.toInt() }
}
}
fun checkLine(line: List<Int>, drawn: List<Int>) = drawn.containsAll(line)
fun checkBoard(board: List<List<Int>>, drawn: List<Int>): Boolean {
val hasHorizontalLine = board.any { checkLine(it, drawn) }
val flippedBoard =
(board[0].indices).map { outer ->
(board.indices).map { inner -> board[inner][outer] }
}
val hasVerticalLine = flippedBoard.any { checkLine(it, drawn) }
return hasHorizontalLine || hasVerticalLine
}
fun part_1() {
for (i in 5..drawOrder.size) {
val currentDraw = drawOrder.take(i)
boards.forEach() {
if (checkBoard(it, currentDraw)) {
return calculateWinner(it, currentDraw)
}
}
}
}
private fun calculateWinner(board: List<List<Int>>, currentDraw: List<Int>) {
println(board.flatten().filter { !currentDraw.contains(it) }.sum() * currentDraw.last())
}
fun part_2() {
val winners = mutableListOf<Int>()
for (i in 5..drawOrder.size) {
val currentDraw = drawOrder.take(i)
boards.forEachIndexed() { index, board ->
if (!winners.contains(index) && checkBoard(board, currentDraw)) {
winners.add(index)
if (winners.size == boards.size) {
return calculateWinner(board, currentDraw)
}
}
}
}
}
}
|
[
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day04Kt.class",
"javap": "Compiled from \"day04.kt\"\npublic final class Day04Kt {\n public static final void print_day_4();\n Code:\n 0: ldc #8 // String \\u001b[33m\n 2: astore_0\n 3: ldc #10 // String \\u001b[0m\n 5: astore_1\n 6: ldc #12 // String \\u001b[32m\n 8: astore_2\n 9: new #14 // class java/lang/StringBuilder\n 12: dup\n 13: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 16: aload_0\n 17: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: ldc #23 // String -\n 22: checkcast #25 // class java/lang/CharSequence\n 25: bipush 25\n 27: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 30: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 33: ldc #33 // String Advent of Code - Day 4\n 35: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 38: ldc #23 // String -\n 40: checkcast #25 // class java/lang/CharSequence\n 43: bipush 25\n 45: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 48: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: aload_1\n 52: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 55: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 58: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 61: swap\n 62: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 65: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: aload_2\n 69: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: invokestatic #55 // Method java/lang/Runtime.getRuntime:()Ljava/lang/Runtime;\n 75: ldc #57 // String figlet Giant Squid -c -f small\n 77: invokevirtual #61 // Method java/lang/Runtime.exec:(Ljava/lang/String;)Ljava/lang/Process;\n 80: astore_3\n 81: new #63 // class java/io/BufferedReader\n 84: dup\n 85: new #65 // class java/io/InputStreamReader\n 88: dup\n 89: aload_3\n 90: invokevirtual #71 // Method java/lang/Process.getInputStream:()Ljava/io/InputStream;\n 93: invokespecial #74 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;)V\n 96: checkcast #76 // class java/io/Reader\n 99: invokespecial #79 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;)V\n 102: astore 4\n 104: aload 4\n 106: checkcast #76 // class java/io/Reader\n 109: invokedynamic #98, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 114: invokestatic #104 // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V\n 117: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 120: aload_1\n 121: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 124: new #14 // class java/lang/StringBuilder\n 127: dup\n 128: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 131: aload_0\n 132: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 135: ldc #23 // String -\n 137: checkcast #25 // class java/lang/CharSequence\n 140: bipush 33\n 142: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 145: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 148: ldc #106 // String Output\n 150: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 153: ldc #23 // String -\n 155: checkcast #25 // class java/lang/CharSequence\n 158: bipush 33\n 160: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 163: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 166: aload_1\n 167: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 170: bipush 10\n 172: invokevirtual #109 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 175: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 178: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 181: swap\n 182: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 185: return\n\n public static final void main();\n Code:\n 0: invokestatic #120 // Method print_day_4:()V\n 3: ldc #122 // String Puzzle 1:\n 5: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 8: swap\n 9: invokevirtual #125 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 12: new #127 // class Day4\n 15: dup\n 16: invokespecial #128 // Method Day4.\"<init>\":()V\n 19: invokevirtual #131 // Method Day4.part_1:()V\n 22: ldc #133 // String Puzzle 2:\n 24: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 27: swap\n 28: invokevirtual #125 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 31: new #127 // class Day4\n 34: dup\n 35: invokespecial #128 // Method Day4.\"<init>\":()V\n 38: invokevirtual #136 // Method Day4.part_2:()V\n 41: new #14 // class java/lang/StringBuilder\n 44: dup\n 45: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 48: ldc #138 // String \\n\\u001b[33m\n 50: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 53: ldc #140 // String =\n 55: checkcast #25 // class java/lang/CharSequence\n 58: bipush 72\n 60: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 63: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 66: ldc #142 // String \\u001b[0m\\n\n 68: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 71: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 74: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 77: swap\n 78: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 81: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #145 // Method main:()V\n 3: return\n\n private static final kotlin.Unit print_day_4$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #149 // String it\n 3: invokestatic #155 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: aload_0\n 10: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 13: getstatic #161 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 16: areturn\n}\n",
"javap_err": ""
}
] |
Ad0lphus__AOC2021__02f219e/day22/Kotlin/day22.kt
|
import java.io.*
fun print_day_22() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 22" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Reactor Reboot -c -f small")
val reader = BufferedReader(InputStreamReader(process.inputStream))
reader.forEachLine { println(it) }
println(reset)
println(yellow + "-".repeat(33) + "Output" + "-".repeat(33) + reset + "\n")
}
fun main() {
print_day_22()
Day22().part1()
Day22().part2()
println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}
fun String.toRange(): IntRange = this.split("..").let { IntRange(it[0].toInt(), it[1].toInt()) }
class Day22 {
fun String.toRange(): IntRange = this.split("..").let { IntRange(it[0].toInt(), it[1].toInt()) }
data class Point3D(val x: Int, val y: Int, val z: Int)
data class Cube(val xAxis: IntRange, val yAxis: IntRange, val zAxis: IntRange) {
fun cubicVolume() = 1L * this.xAxis.count() * this.yAxis.count() * this.zAxis.count()
fun overlaps(that: Cube) =
(this.xAxis.first <= that.xAxis.last && this.xAxis.last >= that.xAxis.first) &&
(this.yAxis.first <= that.yAxis.last &&
this.yAxis.last >= that.yAxis.first) &&
(this.zAxis.first <= that.zAxis.last && this.zAxis.last >= that.zAxis.first)
fun intersect(that: Cube) =
if (!overlaps(that)) null
else
Cube(
maxOf(this.xAxis.first, that.xAxis.first)..minOf(
this.xAxis.last,
that.xAxis.last
),
maxOf(this.yAxis.first, that.yAxis.first)..minOf(
this.yAxis.last,
that.yAxis.last
),
maxOf(this.zAxis.first, that.zAxis.first)..minOf(
this.zAxis.last,
that.zAxis.last
)
)
}
data class Cuboid(val cube: Cube, val on: Boolean) {
fun intersect(other: Cuboid) =
if (this.cube.overlaps(other.cube)) Cuboid(this.cube.intersect(other.cube)!!, !on)
else null
}
private val cubes =
File("../Input/day22.txt").readLines().map {
val on = it.split(" ").first() == "on"
val cube =
it.split(" ").last().split(",").let {
Cube(
it[0].drop(2).toRange(),
it[1].drop(2).toRange(),
it[2].drop(2).toRange()
)
}
Cuboid(cube, on)
}
fun part1() {
val region = Cube(-50..50, -50..50, -50..50)
val onCubes = mutableSetOf<Point3D>()
cubes.forEach {
val (cube, on) = it
if (cube.overlaps(region)) {
cube.xAxis.forEach { x ->
cube.yAxis.forEach { y ->
cube.zAxis.forEach { z ->
if (on) onCubes.add(Point3D(x, y, z))
else onCubes.remove(Point3D(x, y, z))
}
}
}
}
}
println("Puzzle 1: " + onCubes.size)
}
fun part2() {
fun findIntersections(a: Cube, b: Cube): Cube? = if (a.overlaps(b)) a.intersect(b) else null
val volumes = mutableListOf<Cuboid>()
cubes.forEach { cube ->
volumes.addAll(
volumes.mapNotNull { other ->
findIntersections(cube.cube, other.cube)?.let { Cuboid(it, !other.on) }
}
)
if (cube.on) volumes.add(cube)
}
println("Puzzle 2: " + volumes.sumOf { it.cube.cubicVolume() * (if (it.on) 1 else -1) })
}
}
|
[
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day22Kt.class",
"javap": "Compiled from \"day22.kt\"\npublic final class Day22Kt {\n public static final void print_day_22();\n Code:\n 0: ldc #8 // String \\u001b[33m\n 2: astore_0\n 3: ldc #10 // String \\u001b[0m\n 5: astore_1\n 6: ldc #12 // String \\u001b[32m\n 8: astore_2\n 9: new #14 // class java/lang/StringBuilder\n 12: dup\n 13: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 16: aload_0\n 17: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: ldc #23 // String -\n 22: checkcast #25 // class java/lang/CharSequence\n 25: bipush 25\n 27: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 30: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 33: ldc #33 // String Advent of Code - Day 22\n 35: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 38: ldc #23 // String -\n 40: checkcast #25 // class java/lang/CharSequence\n 43: bipush 25\n 45: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 48: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: aload_1\n 52: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 55: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 58: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 61: swap\n 62: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 65: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: aload_2\n 69: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: invokestatic #55 // Method java/lang/Runtime.getRuntime:()Ljava/lang/Runtime;\n 75: ldc #57 // String figlet Reactor Reboot -c -f small\n 77: invokevirtual #61 // Method java/lang/Runtime.exec:(Ljava/lang/String;)Ljava/lang/Process;\n 80: astore_3\n 81: new #63 // class java/io/BufferedReader\n 84: dup\n 85: new #65 // class java/io/InputStreamReader\n 88: dup\n 89: aload_3\n 90: invokevirtual #71 // Method java/lang/Process.getInputStream:()Ljava/io/InputStream;\n 93: invokespecial #74 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;)V\n 96: checkcast #76 // class java/io/Reader\n 99: invokespecial #79 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;)V\n 102: astore 4\n 104: aload 4\n 106: checkcast #76 // class java/io/Reader\n 109: invokedynamic #98, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 114: invokestatic #104 // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V\n 117: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 120: aload_1\n 121: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 124: new #14 // class java/lang/StringBuilder\n 127: dup\n 128: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 131: aload_0\n 132: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 135: ldc #23 // String -\n 137: checkcast #25 // class java/lang/CharSequence\n 140: bipush 33\n 142: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 145: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 148: ldc #106 // String Output\n 150: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 153: ldc #23 // String -\n 155: checkcast #25 // class java/lang/CharSequence\n 158: bipush 33\n 160: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 163: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 166: aload_1\n 167: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 170: bipush 10\n 172: invokevirtual #109 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 175: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 178: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 181: swap\n 182: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 185: return\n\n public static final void main();\n Code:\n 0: invokestatic #120 // Method print_day_22:()V\n 3: new #122 // class Day22\n 6: dup\n 7: invokespecial #123 // Method Day22.\"<init>\":()V\n 10: invokevirtual #126 // Method Day22.part1:()V\n 13: new #122 // class Day22\n 16: dup\n 17: invokespecial #123 // Method Day22.\"<init>\":()V\n 20: invokevirtual #129 // Method Day22.part2:()V\n 23: new #14 // class java/lang/StringBuilder\n 26: dup\n 27: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 30: ldc #131 // String \\n\\u001b[33m\n 32: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 35: ldc #133 // String =\n 37: checkcast #25 // class java/lang/CharSequence\n 40: bipush 72\n 42: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 45: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: ldc #135 // String \\u001b[0m\\n\n 50: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 53: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 56: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 59: swap\n 60: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 63: return\n\n public static final kotlin.ranges.IntRange toRange(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #140 // String <this>\n 3: invokestatic #146 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #25 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #148 // class java/lang/String\n 14: astore_1\n 15: aload_1\n 16: iconst_0\n 17: ldc #150 // String ..\n 19: aastore\n 20: aload_1\n 21: iconst_0\n 22: iconst_0\n 23: bipush 6\n 25: aconst_null\n 26: invokestatic #154 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: astore_2\n 30: iconst_0\n 31: istore_3\n 32: new #156 // class kotlin/ranges/IntRange\n 35: dup\n 36: aload_2\n 37: iconst_0\n 38: invokeinterface #162, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 43: checkcast #148 // class java/lang/String\n 46: invokestatic #168 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 49: aload_2\n 50: iconst_1\n 51: invokeinterface #162, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 56: checkcast #148 // class java/lang/String\n 59: invokestatic #168 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 62: invokespecial #171 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 65: nop\n 66: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #179 // Method main:()V\n 3: return\n\n private static final kotlin.Unit print_day_22$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #182 // String it\n 3: invokestatic #146 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: aload_0\n 10: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 13: getstatic #188 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 16: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day22$Cube.class",
"javap": "Compiled from \"day22.kt\"\npublic final class Day22$Cube {\n private final kotlin.ranges.IntRange xAxis;\n\n private final kotlin.ranges.IntRange yAxis;\n\n private final kotlin.ranges.IntRange zAxis;\n\n public Day22$Cube(kotlin.ranges.IntRange, kotlin.ranges.IntRange, kotlin.ranges.IntRange);\n Code:\n 0: aload_1\n 1: ldc #9 // String xAxis\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 yAxis\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 zAxis\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 xAxis:Lkotlin/ranges/IntRange;\n 27: aload_0\n 28: aload_2\n 29: putfield #27 // Field yAxis:Lkotlin/ranges/IntRange;\n 32: aload_0\n 33: aload_3\n 34: putfield #29 // Field zAxis:Lkotlin/ranges/IntRange;\n 37: return\n\n public final kotlin.ranges.IntRange getXAxis();\n Code:\n 0: aload_0\n 1: getfield #25 // Field xAxis:Lkotlin/ranges/IntRange;\n 4: areturn\n\n public final kotlin.ranges.IntRange getYAxis();\n Code:\n 0: aload_0\n 1: getfield #27 // Field yAxis:Lkotlin/ranges/IntRange;\n 4: areturn\n\n public final kotlin.ranges.IntRange getZAxis();\n Code:\n 0: aload_0\n 1: getfield #29 // Field zAxis:Lkotlin/ranges/IntRange;\n 4: areturn\n\n public final long cubicVolume();\n Code:\n 0: lconst_1\n 1: aload_0\n 2: getfield #25 // Field xAxis:Lkotlin/ranges/IntRange;\n 5: checkcast #39 // class java/lang/Iterable\n 8: invokestatic #45 // Method kotlin/collections/CollectionsKt.count:(Ljava/lang/Iterable;)I\n 11: i2l\n 12: lmul\n 13: aload_0\n 14: getfield #27 // Field yAxis:Lkotlin/ranges/IntRange;\n 17: checkcast #39 // class java/lang/Iterable\n 20: invokestatic #45 // Method kotlin/collections/CollectionsKt.count:(Ljava/lang/Iterable;)I\n 23: i2l\n 24: lmul\n 25: aload_0\n 26: getfield #29 // Field zAxis:Lkotlin/ranges/IntRange;\n 29: checkcast #39 // class java/lang/Iterable\n 32: invokestatic #45 // Method kotlin/collections/CollectionsKt.count:(Ljava/lang/Iterable;)I\n 35: i2l\n 36: lmul\n 37: lreturn\n\n public final boolean overlaps(Day22$Cube);\n Code:\n 0: aload_1\n 1: ldc #49 // String that\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 xAxis:Lkotlin/ranges/IntRange;\n 10: invokevirtual #55 // Method kotlin/ranges/IntRange.getFirst:()I\n 13: aload_1\n 14: getfield #25 // Field xAxis:Lkotlin/ranges/IntRange;\n 17: invokevirtual #58 // Method kotlin/ranges/IntRange.getLast:()I\n 20: if_icmpgt 112\n 23: aload_0\n 24: getfield #25 // Field xAxis:Lkotlin/ranges/IntRange;\n 27: invokevirtual #58 // Method kotlin/ranges/IntRange.getLast:()I\n 30: aload_1\n 31: getfield #25 // Field xAxis:Lkotlin/ranges/IntRange;\n 34: invokevirtual #55 // Method kotlin/ranges/IntRange.getFirst:()I\n 37: if_icmplt 112\n 40: aload_0\n 41: getfield #27 // Field yAxis:Lkotlin/ranges/IntRange;\n 44: invokevirtual #55 // Method kotlin/ranges/IntRange.getFirst:()I\n 47: aload_1\n 48: getfield #27 // Field yAxis:Lkotlin/ranges/IntRange;\n 51: invokevirtual #58 // Method kotlin/ranges/IntRange.getLast:()I\n 54: if_icmpgt 112\n 57: aload_0\n 58: getfield #27 // Field yAxis:Lkotlin/ranges/IntRange;\n 61: invokevirtual #58 // Method kotlin/ranges/IntRange.getLast:()I\n 64: aload_1\n 65: getfield #27 // Field yAxis:Lkotlin/ranges/IntRange;\n 68: invokevirtual #55 // Method kotlin/ranges/IntRange.getFirst:()I\n 71: if_icmplt 112\n 74: aload_0\n 75: getfield #29 // Field zAxis:Lkotlin/ranges/IntRange;\n 78: invokevirtual #55 // Method kotlin/ranges/IntRange.getFirst:()I\n 81: aload_1\n 82: getfield #29 // Field zAxis:Lkotlin/ranges/IntRange;\n 85: invokevirtual #58 // Method kotlin/ranges/IntRange.getLast:()I\n 88: if_icmpgt 112\n 91: aload_0\n 92: getfield #29 // Field zAxis:Lkotlin/ranges/IntRange;\n 95: invokevirtual #58 // Method kotlin/ranges/IntRange.getLast:()I\n 98: aload_1\n 99: getfield #29 // Field zAxis:Lkotlin/ranges/IntRange;\n 102: invokevirtual #55 // Method kotlin/ranges/IntRange.getFirst:()I\n 105: if_icmplt 112\n 108: iconst_1\n 109: goto 113\n 112: iconst_0\n 113: ireturn\n\n public final Day22$Cube intersect(Day22$Cube);\n Code:\n 0: aload_1\n 1: ldc #49 // String that\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokevirtual #63 // Method overlaps:(LDay22$Cube;)Z\n 11: ifne 18\n 14: aconst_null\n 15: goto 151\n 18: new #2 // class Day22$Cube\n 21: dup\n 22: new #51 // class kotlin/ranges/IntRange\n 25: dup\n 26: aload_0\n 27: getfield #25 // Field xAxis:Lkotlin/ranges/IntRange;\n 30: invokevirtual #55 // Method kotlin/ranges/IntRange.getFirst:()I\n 33: aload_1\n 34: getfield #25 // Field xAxis:Lkotlin/ranges/IntRange;\n 37: invokevirtual #55 // Method kotlin/ranges/IntRange.getFirst:()I\n 40: invokestatic #69 // Method java/lang/Math.max:(II)I\n 43: nop\n 44: aload_0\n 45: getfield #25 // Field xAxis:Lkotlin/ranges/IntRange;\n 48: invokevirtual #58 // Method kotlin/ranges/IntRange.getLast:()I\n 51: aload_1\n 52: getfield #25 // Field xAxis:Lkotlin/ranges/IntRange;\n 55: invokevirtual #58 // Method kotlin/ranges/IntRange.getLast:()I\n 58: invokestatic #72 // Method java/lang/Math.min:(II)I\n 61: invokespecial #75 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 64: new #51 // class kotlin/ranges/IntRange\n 67: dup\n 68: aload_0\n 69: getfield #27 // Field yAxis:Lkotlin/ranges/IntRange;\n 72: invokevirtual #55 // Method kotlin/ranges/IntRange.getFirst:()I\n 75: aload_1\n 76: getfield #27 // Field yAxis:Lkotlin/ranges/IntRange;\n 79: invokevirtual #55 // Method kotlin/ranges/IntRange.getFirst:()I\n 82: invokestatic #69 // Method java/lang/Math.max:(II)I\n 85: nop\n 86: aload_0\n 87: getfield #27 // Field yAxis:Lkotlin/ranges/IntRange;\n 90: invokevirtual #58 // Method kotlin/ranges/IntRange.getLast:()I\n 93: aload_1\n 94: getfield #27 // Field yAxis:Lkotlin/ranges/IntRange;\n 97: invokevirtual #58 // Method kotlin/ranges/IntRange.getLast:()I\n 100: invokestatic #72 // Method java/lang/Math.min:(II)I\n 103: invokespecial #75 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 106: new #51 // class kotlin/ranges/IntRange\n 109: dup\n 110: aload_0\n 111: getfield #29 // Field zAxis:Lkotlin/ranges/IntRange;\n 114: invokevirtual #55 // Method kotlin/ranges/IntRange.getFirst:()I\n 117: aload_1\n 118: getfield #29 // Field zAxis:Lkotlin/ranges/IntRange;\n 121: invokevirtual #55 // Method kotlin/ranges/IntRange.getFirst:()I\n 124: invokestatic #69 // Method java/lang/Math.max:(II)I\n 127: nop\n 128: aload_0\n 129: getfield #29 // Field zAxis:Lkotlin/ranges/IntRange;\n 132: invokevirtual #58 // Method kotlin/ranges/IntRange.getLast:()I\n 135: aload_1\n 136: getfield #29 // Field zAxis:Lkotlin/ranges/IntRange;\n 139: invokevirtual #58 // Method kotlin/ranges/IntRange.getLast:()I\n 142: invokestatic #72 // Method java/lang/Math.min:(II)I\n 145: invokespecial #75 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 148: invokespecial #77 // Method \"<init>\":(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)V\n 151: areturn\n\n public final kotlin.ranges.IntRange component1();\n Code:\n 0: aload_0\n 1: getfield #25 // Field xAxis: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 yAxis: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 zAxis:Lkotlin/ranges/IntRange;\n 4: areturn\n\n public final Day22$Cube copy(kotlin.ranges.IntRange, kotlin.ranges.IntRange, kotlin.ranges.IntRange);\n Code:\n 0: aload_1\n 1: ldc #9 // String xAxis\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 yAxis\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 zAxis\n 15: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: new #2 // class Day22$Cube\n 21: dup\n 22: aload_1\n 23: aload_2\n 24: aload_3\n 25: invokespecial #77 // Method \"<init>\":(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)V\n 28: areturn\n\n public static Day22$Cube copy$default(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 xAxis: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 yAxis: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 zAxis: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 #86 // Method copy:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)LDay22$Cube;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #90 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #91 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #93 // String Cube(xAxis=\n 9: invokevirtual #97 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #25 // Field xAxis:Lkotlin/ranges/IntRange;\n 16: invokevirtual #100 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #102 // String , yAxis=\n 21: invokevirtual #97 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #27 // Field yAxis:Lkotlin/ranges/IntRange;\n 28: invokevirtual #100 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: ldc #104 // String , zAxis=\n 33: invokevirtual #97 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #29 // Field zAxis:Lkotlin/ranges/IntRange;\n 40: invokevirtual #100 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #107 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #109 // 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 xAxis:Lkotlin/ranges/IntRange;\n 4: invokevirtual #112 // 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 yAxis:Lkotlin/ranges/IntRange;\n 16: invokevirtual #112 // 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 zAxis:Lkotlin/ranges/IntRange;\n 29: invokevirtual #112 // 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 Day22$Cube\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day22$Cube\n 20: astore_2\n 21: aload_0\n 22: getfield #25 // Field xAxis:Lkotlin/ranges/IntRange;\n 25: aload_2\n 26: getfield #25 // Field xAxis:Lkotlin/ranges/IntRange;\n 29: invokestatic #120 // 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 yAxis:Lkotlin/ranges/IntRange;\n 41: aload_2\n 42: getfield #27 // Field yAxis:Lkotlin/ranges/IntRange;\n 45: invokestatic #120 // 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 zAxis:Lkotlin/ranges/IntRange;\n 57: aload_2\n 58: getfield #29 // Field zAxis:Lkotlin/ranges/IntRange;\n 61: invokestatic #120 // 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": "Ad0lphus__AOC2021__02f219e/Day22.class",
"javap": "Compiled from \"day22.kt\"\npublic final class Day22 {\n private final java.util.List<Day22$Cuboid> cubes;\n\n public Day22();\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 java/io/File\n 8: dup\n 9: ldc #12 // String ../Input/day22.txt\n 11: invokespecial #15 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 14: aconst_null\n 15: iconst_1\n 16: aconst_null\n 17: invokestatic #21 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 20: checkcast #23 // class java/lang/Iterable\n 23: astore_1\n 24: astore 15\n 26: iconst_0\n 27: istore_2\n 28: aload_1\n 29: astore_3\n 30: new #25 // class java/util/ArrayList\n 33: dup\n 34: aload_1\n 35: bipush 10\n 37: invokestatic #31 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 40: invokespecial #34 // Method java/util/ArrayList.\"<init>\":(I)V\n 43: checkcast #36 // class java/util/Collection\n 46: astore 4\n 48: iconst_0\n 49: istore 5\n 51: aload_3\n 52: invokeinterface #40, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 57: astore 6\n 59: aload 6\n 61: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 66: ifeq 280\n 69: aload 6\n 71: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 76: astore 7\n 78: aload 4\n 80: aload 7\n 82: checkcast #52 // class java/lang/String\n 85: astore 8\n 87: astore 16\n 89: iconst_0\n 90: istore 9\n 92: aload 8\n 94: checkcast #54 // class java/lang/CharSequence\n 97: iconst_1\n 98: anewarray #52 // class java/lang/String\n 101: astore 10\n 103: aload 10\n 105: iconst_0\n 106: ldc #56 // String\n 108: aastore\n 109: aload 10\n 111: iconst_0\n 112: iconst_0\n 113: bipush 6\n 115: aconst_null\n 116: invokestatic #62 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 119: invokestatic #66 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 122: ldc #68 // String on\n 124: invokestatic #74 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 127: istore 11\n 129: aload 8\n 131: checkcast #54 // class java/lang/CharSequence\n 134: iconst_1\n 135: anewarray #52 // class java/lang/String\n 138: astore 12\n 140: aload 12\n 142: iconst_0\n 143: ldc #56 // String\n 145: aastore\n 146: aload 12\n 148: iconst_0\n 149: iconst_0\n 150: bipush 6\n 152: aconst_null\n 153: invokestatic #62 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 156: invokestatic #77 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 159: checkcast #54 // class java/lang/CharSequence\n 162: iconst_1\n 163: anewarray #52 // class java/lang/String\n 166: astore 12\n 168: aload 12\n 170: iconst_0\n 171: ldc #79 // String ,\n 173: aastore\n 174: aload 12\n 176: iconst_0\n 177: iconst_0\n 178: bipush 6\n 180: aconst_null\n 181: invokestatic #62 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 184: astore 13\n 186: iconst_0\n 187: istore 14\n 189: new #81 // class Day22$Cube\n 192: dup\n 193: aload_0\n 194: aload 13\n 196: iconst_0\n 197: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 202: checkcast #52 // class java/lang/String\n 205: iconst_2\n 206: invokestatic #91 // Method kotlin/text/StringsKt.drop:(Ljava/lang/String;I)Ljava/lang/String;\n 209: invokevirtual #95 // Method toRange:(Ljava/lang/String;)Lkotlin/ranges/IntRange;\n 212: aload_0\n 213: aload 13\n 215: iconst_1\n 216: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 221: checkcast #52 // class java/lang/String\n 224: iconst_2\n 225: invokestatic #91 // Method kotlin/text/StringsKt.drop:(Ljava/lang/String;I)Ljava/lang/String;\n 228: invokevirtual #95 // Method toRange:(Ljava/lang/String;)Lkotlin/ranges/IntRange;\n 231: aload_0\n 232: aload 13\n 234: iconst_2\n 235: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 240: checkcast #52 // class java/lang/String\n 243: iconst_2\n 244: invokestatic #91 // Method kotlin/text/StringsKt.drop:(Ljava/lang/String;I)Ljava/lang/String;\n 247: invokevirtual #95 // Method toRange:(Ljava/lang/String;)Lkotlin/ranges/IntRange;\n 250: invokespecial #98 // Method Day22$Cube.\"<init>\":(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)V\n 253: nop\n 254: nop\n 255: astore 10\n 257: new #100 // class Day22$Cuboid\n 260: dup\n 261: aload 10\n 263: iload 11\n 265: invokespecial #103 // Method Day22$Cuboid.\"<init>\":(LDay22$Cube;Z)V\n 268: aload 16\n 270: swap\n 271: invokeinterface #107, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 276: pop\n 277: goto 59\n 280: aload 4\n 282: checkcast #83 // class java/util/List\n 285: nop\n 286: aload 15\n 288: swap\n 289: putfield #111 // Field cubes:Ljava/util/List;\n 292: return\n\n public final kotlin.ranges.IntRange toRange(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #133 // String <this>\n 3: invokestatic #137 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #54 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #52 // class java/lang/String\n 14: astore_2\n 15: aload_2\n 16: iconst_0\n 17: ldc #139 // 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 #62 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: astore_3\n 30: iconst_0\n 31: istore 4\n 33: new #141 // class kotlin/ranges/IntRange\n 36: dup\n 37: aload_3\n 38: iconst_0\n 39: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 44: checkcast #52 // class java/lang/String\n 47: invokestatic #147 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 50: aload_3\n 51: iconst_1\n 52: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 57: checkcast #52 // class java/lang/String\n 60: invokestatic #147 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 63: invokespecial #150 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 66: nop\n 67: areturn\n\n public final void part1();\n Code:\n 0: new #81 // class Day22$Cube\n 3: dup\n 4: new #141 // class kotlin/ranges/IntRange\n 7: dup\n 8: bipush -50\n 10: bipush 50\n 12: invokespecial #150 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 15: new #141 // class kotlin/ranges/IntRange\n 18: dup\n 19: bipush -50\n 21: bipush 50\n 23: invokespecial #150 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 26: new #141 // class kotlin/ranges/IntRange\n 29: dup\n 30: bipush -50\n 32: bipush 50\n 34: invokespecial #150 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 37: invokespecial #98 // Method Day22$Cube.\"<init>\":(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)V\n 40: astore_1\n 41: new #155 // class java/util/LinkedHashSet\n 44: dup\n 45: invokespecial #156 // Method java/util/LinkedHashSet.\"<init>\":()V\n 48: checkcast #158 // class java/util/Set\n 51: astore_2\n 52: aload_0\n 53: getfield #111 // Field cubes:Ljava/util/List;\n 56: checkcast #23 // class java/lang/Iterable\n 59: astore_3\n 60: iconst_0\n 61: istore 4\n 63: aload_3\n 64: invokeinterface #40, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 69: astore 5\n 71: aload 5\n 73: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 78: ifeq 340\n 81: aload 5\n 83: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 88: astore 6\n 90: aload 6\n 92: checkcast #100 // class Day22$Cuboid\n 95: astore 7\n 97: iconst_0\n 98: istore 8\n 100: aload 7\n 102: invokevirtual #162 // Method Day22$Cuboid.component1:()LDay22$Cube;\n 105: astore 9\n 107: aload 7\n 109: invokevirtual #165 // Method Day22$Cuboid.component2:()Z\n 112: istore 10\n 114: aload 9\n 116: aload_1\n 117: invokevirtual #169 // Method Day22$Cube.overlaps:(LDay22$Cube;)Z\n 120: ifeq 335\n 123: aload 9\n 125: invokevirtual #173 // Method Day22$Cube.getXAxis:()Lkotlin/ranges/IntRange;\n 128: checkcast #23 // class java/lang/Iterable\n 131: astore 11\n 133: iconst_0\n 134: istore 12\n 136: aload 11\n 138: invokeinterface #40, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 143: astore 13\n 145: aload 13\n 147: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 152: ifeq 334\n 155: aload 13\n 157: checkcast #175 // class kotlin/collections/IntIterator\n 160: invokevirtual #179 // Method kotlin/collections/IntIterator.nextInt:()I\n 163: istore 14\n 165: iload 14\n 167: istore 15\n 169: iconst_0\n 170: istore 16\n 172: aload 9\n 174: invokevirtual #182 // Method Day22$Cube.getYAxis:()Lkotlin/ranges/IntRange;\n 177: checkcast #23 // class java/lang/Iterable\n 180: astore 17\n 182: iconst_0\n 183: istore 18\n 185: aload 17\n 187: invokeinterface #40, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 192: astore 19\n 194: aload 19\n 196: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 201: ifeq 328\n 204: aload 19\n 206: checkcast #175 // class kotlin/collections/IntIterator\n 209: invokevirtual #179 // Method kotlin/collections/IntIterator.nextInt:()I\n 212: istore 20\n 214: iload 20\n 216: istore 21\n 218: iconst_0\n 219: istore 22\n 221: aload 9\n 223: invokevirtual #185 // Method Day22$Cube.getZAxis:()Lkotlin/ranges/IntRange;\n 226: checkcast #23 // class java/lang/Iterable\n 229: astore 23\n 231: iconst_0\n 232: istore 24\n 234: aload 23\n 236: invokeinterface #40, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 241: astore 25\n 243: aload 25\n 245: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 250: ifeq 322\n 253: aload 25\n 255: checkcast #175 // class kotlin/collections/IntIterator\n 258: invokevirtual #179 // Method kotlin/collections/IntIterator.nextInt:()I\n 261: istore 26\n 263: iload 26\n 265: istore 27\n 267: iconst_0\n 268: istore 28\n 270: iload 10\n 272: ifeq 297\n 275: aload_2\n 276: new #187 // class Day22$Point3D\n 279: dup\n 280: iload 15\n 282: iload 21\n 284: iload 27\n 286: invokespecial #190 // Method Day22$Point3D.\"<init>\":(III)V\n 289: invokeinterface #191, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 294: goto 316\n 297: aload_2\n 298: new #187 // class Day22$Point3D\n 301: dup\n 302: iload 15\n 304: iload 21\n 306: iload 27\n 308: invokespecial #190 // Method Day22$Point3D.\"<init>\":(III)V\n 311: invokeinterface #194, 2 // InterfaceMethod java/util/Set.remove:(Ljava/lang/Object;)Z\n 316: pop\n 317: nop\n 318: nop\n 319: goto 243\n 322: nop\n 323: nop\n 324: nop\n 325: goto 194\n 328: nop\n 329: nop\n 330: nop\n 331: goto 145\n 334: nop\n 335: nop\n 336: nop\n 337: goto 71\n 340: nop\n 341: new #196 // class java/lang/StringBuilder\n 344: dup\n 345: invokespecial #197 // Method java/lang/StringBuilder.\"<init>\":()V\n 348: ldc #199 // String Puzzle 1:\n 350: invokevirtual #203 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 353: aload_2\n 354: invokeinterface #206, 1 // InterfaceMethod java/util/Set.size:()I\n 359: invokevirtual #209 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 362: invokevirtual #213 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 365: getstatic #219 // Field java/lang/System.out:Ljava/io/PrintStream;\n 368: swap\n 369: invokevirtual #225 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 372: return\n\n public final void part2();\n Code:\n 0: new #25 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #241 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #83 // class java/util/List\n 10: astore_1\n 11: aload_0\n 12: getfield #111 // Field cubes:Ljava/util/List;\n 15: checkcast #23 // class java/lang/Iterable\n 18: astore_2\n 19: iconst_0\n 20: istore_3\n 21: aload_2\n 22: invokeinterface #40, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 27: astore 4\n 29: aload 4\n 31: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 36: ifeq 258\n 39: aload 4\n 41: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 46: astore 5\n 48: aload 5\n 50: checkcast #100 // class Day22$Cuboid\n 53: astore 6\n 55: iconst_0\n 56: istore 7\n 58: aload_1\n 59: aload_1\n 60: checkcast #23 // class java/lang/Iterable\n 63: astore 8\n 65: astore 9\n 67: iconst_0\n 68: istore 10\n 70: aload 8\n 72: astore 11\n 74: new #25 // class java/util/ArrayList\n 77: dup\n 78: invokespecial #241 // Method java/util/ArrayList.\"<init>\":()V\n 81: checkcast #36 // class java/util/Collection\n 84: astore 12\n 86: iconst_0\n 87: istore 13\n 89: aload 11\n 91: astore 14\n 93: iconst_0\n 94: istore 15\n 96: aload 14\n 98: invokeinterface #40, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 103: astore 16\n 105: aload 16\n 107: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 112: ifeq 217\n 115: aload 16\n 117: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 122: astore 17\n 124: aload 17\n 126: astore 18\n 128: iconst_0\n 129: istore 19\n 131: aload 18\n 133: checkcast #100 // class Day22$Cuboid\n 136: astore 20\n 138: iconst_0\n 139: istore 21\n 141: aload 6\n 143: invokevirtual #244 // Method Day22$Cuboid.getCube:()LDay22$Cube;\n 146: aload 20\n 148: invokevirtual #244 // Method Day22$Cuboid.getCube:()LDay22$Cube;\n 151: invokestatic #248 // Method part2$findIntersections:(LDay22$Cube;LDay22$Cube;)LDay22$Cube;\n 154: dup\n 155: ifnull 188\n 158: astore 22\n 160: iconst_0\n 161: istore 23\n 163: new #100 // class Day22$Cuboid\n 166: dup\n 167: aload 22\n 169: aload 20\n 171: invokevirtual #251 // Method Day22$Cuboid.getOn:()Z\n 174: ifne 181\n 177: iconst_1\n 178: goto 182\n 181: iconst_0\n 182: invokespecial #103 // Method Day22$Cuboid.\"<init>\":(LDay22$Cube;Z)V\n 185: goto 190\n 188: pop\n 189: aconst_null\n 190: dup\n 191: ifnull 212\n 194: astore 24\n 196: iconst_0\n 197: istore 25\n 199: aload 12\n 201: aload 24\n 203: invokeinterface #107, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 208: pop\n 209: goto 213\n 212: pop\n 213: nop\n 214: goto 105\n 217: nop\n 218: aload 12\n 220: checkcast #83 // class java/util/List\n 223: nop\n 224: aload 9\n 226: swap\n 227: checkcast #36 // class java/util/Collection\n 230: invokeinterface #255, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 235: pop\n 236: aload 6\n 238: invokevirtual #251 // Method Day22$Cuboid.getOn:()Z\n 241: ifeq 253\n 244: aload_1\n 245: aload 6\n 247: invokeinterface #256, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 252: pop\n 253: nop\n 254: nop\n 255: goto 29\n 258: nop\n 259: new #196 // class java/lang/StringBuilder\n 262: dup\n 263: invokespecial #197 // Method java/lang/StringBuilder.\"<init>\":()V\n 266: ldc_w #258 // String Puzzle 2:\n 269: invokevirtual #203 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 272: aload_1\n 273: checkcast #23 // class java/lang/Iterable\n 276: astore_2\n 277: astore 26\n 279: lconst_0\n 280: lstore_3\n 281: aload_2\n 282: invokeinterface #40, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 287: astore 5\n 289: aload 5\n 291: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 296: ifeq 355\n 299: aload 5\n 301: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 306: astore 6\n 308: lload_3\n 309: aload 6\n 311: checkcast #100 // class Day22$Cuboid\n 314: astore 7\n 316: lstore 27\n 318: iconst_0\n 319: istore 8\n 321: aload 7\n 323: invokevirtual #244 // Method Day22$Cuboid.getCube:()LDay22$Cube;\n 326: invokevirtual #262 // Method Day22$Cube.cubicVolume:()J\n 329: aload 7\n 331: invokevirtual #251 // Method Day22$Cuboid.getOn:()Z\n 334: ifeq 341\n 337: iconst_1\n 338: goto 342\n 341: iconst_m1\n 342: i2l\n 343: lmul\n 344: lstore 29\n 346: lload 27\n 348: lload 29\n 350: ladd\n 351: lstore_3\n 352: goto 289\n 355: lload_3\n 356: lstore 27\n 358: aload 26\n 360: lload 27\n 362: invokevirtual #265 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 365: invokevirtual #213 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 368: getstatic #219 // Field java/lang/System.out:Ljava/io/PrintStream;\n 371: swap\n 372: invokevirtual #225 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 375: return\n\n private static final Day22$Cube part2$findIntersections(Day22$Cube, Day22$Cube);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokevirtual #169 // Method Day22$Cube.overlaps:(LDay22$Cube;)Z\n 5: ifeq 16\n 8: aload_0\n 9: aload_1\n 10: invokevirtual #285 // Method Day22$Cube.intersect:(LDay22$Cube;)LDay22$Cube;\n 13: goto 17\n 16: aconst_null\n 17: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day22$Point3D.class",
"javap": "Compiled from \"day22.kt\"\npublic final class Day22$Point3D {\n private final int x;\n\n private final int y;\n\n private final int z;\n\n public Day22$Point3D(int, int, int);\n Code:\n 0: aload_0\n 1: invokespecial #9 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #13 // Field x:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field y:I\n 14: aload_0\n 15: iload_3\n 16: putfield #19 // Field z:I\n 19: return\n\n public final int getX();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: ireturn\n\n public final int getY();\n Code:\n 0: aload_0\n 1: getfield #16 // Field y:I\n 4: ireturn\n\n public final int getZ();\n Code:\n 0: aload_0\n 1: getfield #19 // Field z:I\n 4: ireturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field y:I\n 4: ireturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #19 // Field z:I\n 4: ireturn\n\n public final Day22$Point3D copy(int, int, int);\n Code:\n 0: new #2 // class Day22$Point3D\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 Day22$Point3D copy$default(Day22$Point3D, int, int, int, int, java.lang.Object);\n Code:\n 0: iload 4\n 2: iconst_1\n 3: iand\n 4: ifeq 12\n 7: aload_0\n 8: getfield #13 // Field x:I\n 11: istore_1\n 12: iload 4\n 14: iconst_2\n 15: iand\n 16: ifeq 24\n 19: aload_0\n 20: getfield #16 // Field y:I\n 23: istore_2\n 24: iload 4\n 26: iconst_4\n 27: iand\n 28: ifeq 36\n 31: aload_0\n 32: getfield #19 // Field z:I\n 35: istore_3\n 36: aload_0\n 37: iload_1\n 38: iload_2\n 39: iload_3\n 40: invokevirtual #37 // Method copy:(III)LDay22$Point3D;\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 Point3D(x=\n 9: invokevirtual #48 // 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 #51 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #53 // String , y=\n 21: invokevirtual #48 // 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 #51 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #55 // String , z=\n 33: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #19 // Field z:I\n 40: invokevirtual #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 x: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 y: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 z: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 Day22$Point3D\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day22$Point3D\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field x:I\n 25: aload_2\n 26: getfield #13 // Field x:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field y:I\n 38: aload_2\n 39: getfield #16 // Field y:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: aload_0\n 48: getfield #19 // Field z:I\n 51: aload_2\n 52: getfield #19 // Field z:I\n 55: if_icmpeq 60\n 58: iconst_0\n 59: ireturn\n 60: iconst_1\n 61: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day22$Cuboid.class",
"javap": "Compiled from \"day22.kt\"\npublic final class Day22$Cuboid {\n private final Day22$Cube cube;\n\n private final boolean on;\n\n public Day22$Cuboid(Day22$Cube, boolean);\n Code:\n 0: aload_1\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: aload_1\n 12: putfield #21 // Field cube:LDay22$Cube;\n 15: aload_0\n 16: iload_2\n 17: putfield #25 // Field on:Z\n 20: return\n\n public final Day22$Cube getCube();\n Code:\n 0: aload_0\n 1: getfield #21 // Field cube:LDay22$Cube;\n 4: areturn\n\n public final boolean getOn();\n Code:\n 0: aload_0\n 1: getfield #25 // Field on:Z\n 4: ireturn\n\n public final Day22$Cuboid intersect(Day22$Cuboid);\n Code:\n 0: aload_1\n 1: ldc #36 // 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 #21 // Field cube:LDay22$Cube;\n 10: aload_1\n 11: getfield #21 // Field cube:LDay22$Cube;\n 14: invokevirtual #42 // Method Day22$Cube.overlaps:(LDay22$Cube;)Z\n 17: ifeq 57\n 20: new #2 // class Day22$Cuboid\n 23: dup\n 24: aload_0\n 25: getfield #21 // Field cube:LDay22$Cube;\n 28: aload_1\n 29: getfield #21 // Field cube:LDay22$Cube;\n 32: invokevirtual #45 // Method Day22$Cube.intersect:(LDay22$Cube;)LDay22$Cube;\n 35: dup\n 36: invokestatic #49 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 39: aload_0\n 40: getfield #25 // Field on:Z\n 43: ifne 50\n 46: iconst_1\n 47: goto 51\n 50: iconst_0\n 51: invokespecial #51 // Method \"<init>\":(LDay22$Cube;Z)V\n 54: goto 58\n 57: aconst_null\n 58: areturn\n\n public final Day22$Cube component1();\n Code:\n 0: aload_0\n 1: getfield #21 // Field cube:LDay22$Cube;\n 4: areturn\n\n public final boolean component2();\n Code:\n 0: aload_0\n 1: getfield #25 // Field on:Z\n 4: ireturn\n\n public final Day22$Cuboid copy(Day22$Cube, boolean);\n Code:\n 0: aload_1\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 Day22$Cuboid\n 9: dup\n 10: aload_1\n 11: iload_2\n 12: invokespecial #51 // Method \"<init>\":(LDay22$Cube;Z)V\n 15: areturn\n\n public static Day22$Cuboid copy$default(Day22$Cuboid, Day22$Cube, 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 cube:LDay22$Cube;\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 on:Z\n 21: istore_2\n 22: aload_0\n 23: aload_1\n 24: iload_2\n 25: invokevirtual #59 // Method copy:(LDay22$Cube;Z)LDay22$Cuboid;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #63 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #64 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #66 // String Cuboid(cube=\n 9: invokevirtual #70 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #21 // Field cube:LDay22$Cube;\n 16: invokevirtual #73 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #75 // String , on=\n 21: invokevirtual #70 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #25 // Field on:Z\n 28: invokevirtual #78 // Method java/lang/StringBuilder.append:(Z)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #81 // 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 int hashCode();\n Code:\n 0: aload_0\n 1: getfield #21 // Field cube:LDay22$Cube;\n 4: invokevirtual #87 // Method Day22$Cube.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 on:Z\n 16: invokestatic #92 // 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 Day22$Cuboid\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day22$Cuboid\n 20: astore_2\n 21: aload_0\n 22: getfield #21 // Field cube:LDay22$Cube;\n 25: aload_2\n 26: getfield #21 // Field cube:LDay22$Cube;\n 29: invokestatic #100 // 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 on:Z\n 41: aload_2\n 42: getfield #25 // Field on:Z\n 45: if_icmpeq 50\n 48: iconst_0\n 49: ireturn\n 50: iconst_1\n 51: ireturn\n}\n",
"javap_err": ""
}
] |
Ad0lphus__AOC2021__02f219e/day17/Kotlin/day17.kt
|
import java.io.*
fun print_day_17() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 17" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Trick Shot -c -f small")
val reader = BufferedReader(InputStreamReader(process.inputStream))
reader.forEachLine { println(it) }
println(reset)
println(yellow + "-".repeat(33) + "Output" + "-".repeat(33) + reset + "\n")
}
fun main() {
print_day_17()
println("Puzzle 1: ${Day17().part_1()}")
println("Puzzle 2: ${Day17().part_2()}")
println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}
class Day17 {
data class BoundingBox(val xRange: IntRange, val yRange: IntRange)
private val target = File("../Input/day17.txt").readLines().first().drop(13)
.split(", ").map { it.drop(2).split("..").let { (a, b) -> a.toInt()..b.toInt() }}
.let { BoundingBox(it[0], it[1]) }
fun part_1() = (1..400).flatMap { x -> (1..400).map { y -> checkStep(x, y, target) } }.fold(0) { max, step -> if (step.first) maxOf(max, step.second) else max }
fun part_2() = (1..400).flatMap { x -> (-400..400).map { y -> checkStep(x, y, target).first } }.count { it }
data class Coord(var x:Int, var y:Int)
data class Velocity(var x:Int, var y:Int)
private fun checkStep(xVelocity: Int, yVelocity: Int, target: BoundingBox): Pair<Boolean, Int> {
val p = Coord(0, 0)
val v = Velocity(xVelocity, yVelocity)
var maxHeight = 0
var hitTarget = false
while (p.x <= target.xRange.last && p.y >= target.yRange.first) {
p.x += v.x
p.y += v.y
maxHeight = maxOf(p.y, maxHeight)
if (p.x in target.xRange && p.y in target.yRange) {
hitTarget = true
break
}
if (v.x > 0) v.x--
v.y--
}
return Pair(hitTarget, maxHeight)
}
}
|
[
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day17.class",
"javap": "Compiled from \"day17.kt\"\npublic final class Day17 {\n private final Day17$BoundingBox target;\n\n public Day17();\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 java/io/File\n 8: dup\n 9: ldc #12 // String ../Input/day17.txt\n 11: invokespecial #15 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 14: aconst_null\n 15: iconst_1\n 16: aconst_null\n 17: invokestatic #21 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 20: invokestatic #27 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 23: checkcast #29 // class java/lang/String\n 26: bipush 13\n 28: invokestatic #35 // Method kotlin/text/StringsKt.drop:(Ljava/lang/String;I)Ljava/lang/String;\n 31: checkcast #37 // class java/lang/CharSequence\n 34: iconst_1\n 35: anewarray #29 // class java/lang/String\n 38: astore_1\n 39: aload_1\n 40: iconst_0\n 41: ldc #39 // String ,\n 43: aastore\n 44: aload_1\n 45: iconst_0\n 46: iconst_0\n 47: bipush 6\n 49: aconst_null\n 50: invokestatic #43 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 53: checkcast #45 // class java/lang/Iterable\n 56: astore_1\n 57: astore 15\n 59: iconst_0\n 60: istore_2\n 61: aload_1\n 62: astore_3\n 63: new #47 // class java/util/ArrayList\n 66: dup\n 67: aload_1\n 68: bipush 10\n 70: invokestatic #51 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 73: invokespecial #54 // Method java/util/ArrayList.\"<init>\":(I)V\n 76: checkcast #56 // class java/util/Collection\n 79: astore 4\n 81: iconst_0\n 82: istore 5\n 84: aload_3\n 85: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 90: astore 6\n 92: aload 6\n 94: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 99: ifeq 218\n 102: aload 6\n 104: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 109: astore 7\n 111: aload 4\n 113: aload 7\n 115: checkcast #29 // class java/lang/String\n 118: astore 8\n 120: astore 16\n 122: iconst_0\n 123: istore 9\n 125: aload 8\n 127: iconst_2\n 128: invokestatic #35 // Method kotlin/text/StringsKt.drop:(Ljava/lang/String;I)Ljava/lang/String;\n 131: checkcast #37 // class java/lang/CharSequence\n 134: iconst_1\n 135: anewarray #29 // class java/lang/String\n 138: astore 10\n 140: aload 10\n 142: iconst_0\n 143: ldc #72 // String ..\n 145: aastore\n 146: aload 10\n 148: iconst_0\n 149: iconst_0\n 150: bipush 6\n 152: aconst_null\n 153: invokestatic #43 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 156: astore 11\n 158: iconst_0\n 159: istore 12\n 161: aload 11\n 163: iconst_0\n 164: invokeinterface #78, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 169: checkcast #29 // class java/lang/String\n 172: astore 13\n 174: aload 11\n 176: iconst_1\n 177: invokeinterface #78, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 182: checkcast #29 // class java/lang/String\n 185: astore 14\n 187: new #80 // class kotlin/ranges/IntRange\n 190: dup\n 191: aload 13\n 193: invokestatic #86 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 196: aload 14\n 198: invokestatic #86 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 201: invokespecial #89 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 204: nop\n 205: nop\n 206: aload 16\n 208: swap\n 209: invokeinterface #93, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 214: pop\n 215: goto 92\n 218: aload 4\n 220: checkcast #74 // class java/util/List\n 223: nop\n 224: aload 15\n 226: swap\n 227: astore_2\n 228: astore 15\n 230: iconst_0\n 231: istore_3\n 232: new #95 // class Day17$BoundingBox\n 235: dup\n 236: aload_2\n 237: iconst_0\n 238: invokeinterface #78, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 243: checkcast #80 // class kotlin/ranges/IntRange\n 246: aload_2\n 247: iconst_1\n 248: invokeinterface #78, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 253: checkcast #80 // class kotlin/ranges/IntRange\n 256: invokespecial #98 // Method Day17$BoundingBox.\"<init>\":(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)V\n 259: aload 15\n 261: swap\n 262: nop\n 263: putfield #102 // Field target:LDay17$BoundingBox;\n 266: return\n\n public final int part_1();\n Code:\n 0: new #80 // class kotlin/ranges/IntRange\n 3: dup\n 4: iconst_1\n 5: sipush 400\n 8: invokespecial #89 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 11: checkcast #45 // class java/lang/Iterable\n 14: astore_1\n 15: iconst_0\n 16: istore_2\n 17: aload_1\n 18: astore_3\n 19: new #47 // class java/util/ArrayList\n 22: dup\n 23: invokespecial #125 // Method java/util/ArrayList.\"<init>\":()V\n 26: checkcast #56 // class java/util/Collection\n 29: astore 4\n 31: iconst_0\n 32: istore 5\n 34: aload_3\n 35: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 40: astore 6\n 42: aload 6\n 44: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 49: ifeq 201\n 52: aload 6\n 54: checkcast #127 // class kotlin/collections/IntIterator\n 57: invokevirtual #130 // Method kotlin/collections/IntIterator.nextInt:()I\n 60: istore 7\n 62: iload 7\n 64: istore 8\n 66: iconst_0\n 67: istore 9\n 69: new #80 // class kotlin/ranges/IntRange\n 72: dup\n 73: iconst_1\n 74: sipush 400\n 77: invokespecial #89 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 80: checkcast #45 // class java/lang/Iterable\n 83: astore 10\n 85: iconst_0\n 86: istore 11\n 88: aload 10\n 90: astore 12\n 92: new #47 // class java/util/ArrayList\n 95: dup\n 96: aload 10\n 98: bipush 10\n 100: invokestatic #51 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 103: invokespecial #54 // Method java/util/ArrayList.\"<init>\":(I)V\n 106: checkcast #56 // class java/util/Collection\n 109: astore 13\n 111: iconst_0\n 112: istore 14\n 114: aload 12\n 116: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 121: astore 15\n 123: aload 15\n 125: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 130: ifeq 178\n 133: aload 15\n 135: checkcast #127 // class kotlin/collections/IntIterator\n 138: invokevirtual #130 // Method kotlin/collections/IntIterator.nextInt:()I\n 141: istore 16\n 143: aload 13\n 145: iload 16\n 147: istore 17\n 149: astore 18\n 151: iconst_0\n 152: istore 19\n 154: aload_0\n 155: iload 8\n 157: iload 17\n 159: aload_0\n 160: getfield #102 // Field target:LDay17$BoundingBox;\n 163: invokespecial #134 // Method checkStep:(IILDay17$BoundingBox;)Lkotlin/Pair;\n 166: aload 18\n 168: swap\n 169: invokeinterface #93, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 174: pop\n 175: goto 123\n 178: aload 13\n 180: checkcast #74 // class java/util/List\n 183: nop\n 184: checkcast #45 // class java/lang/Iterable\n 187: nop\n 188: astore 8\n 190: aload 4\n 192: aload 8\n 194: invokestatic #138 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 197: pop\n 198: goto 42\n 201: aload 4\n 203: checkcast #74 // class java/util/List\n 206: nop\n 207: checkcast #45 // class java/lang/Iterable\n 210: astore_1\n 211: iconst_0\n 212: istore_2\n 213: iconst_0\n 214: istore_3\n 215: iload_2\n 216: istore 4\n 218: aload_1\n 219: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 224: astore 5\n 226: aload 5\n 228: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 233: ifeq 299\n 236: aload 5\n 238: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 243: astore 6\n 245: iload 4\n 247: aload 6\n 249: checkcast #140 // class kotlin/Pair\n 252: astore 7\n 254: istore 8\n 256: iconst_0\n 257: istore 9\n 259: aload 7\n 261: invokevirtual #143 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 264: checkcast #145 // class java/lang/Boolean\n 267: invokevirtual #148 // Method java/lang/Boolean.booleanValue:()Z\n 270: ifeq 292\n 273: iload 8\n 275: aload 7\n 277: invokevirtual #151 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 280: checkcast #153 // class java/lang/Number\n 283: invokevirtual #156 // Method java/lang/Number.intValue:()I\n 286: invokestatic #162 // Method java/lang/Math.max:(II)I\n 289: goto 294\n 292: iload 8\n 294: istore 4\n 296: goto 226\n 299: iload 4\n 301: ireturn\n\n public final int part_2();\n Code:\n 0: new #80 // class kotlin/ranges/IntRange\n 3: dup\n 4: iconst_1\n 5: sipush 400\n 8: invokespecial #89 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 11: checkcast #45 // class java/lang/Iterable\n 14: astore_1\n 15: iconst_0\n 16: istore_2\n 17: aload_1\n 18: astore_3\n 19: new #47 // class java/util/ArrayList\n 22: dup\n 23: invokespecial #125 // Method java/util/ArrayList.\"<init>\":()V\n 26: checkcast #56 // class java/util/Collection\n 29: astore 4\n 31: iconst_0\n 32: istore 5\n 34: aload_3\n 35: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 40: astore 6\n 42: aload 6\n 44: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 49: ifeq 215\n 52: aload 6\n 54: checkcast #127 // class kotlin/collections/IntIterator\n 57: invokevirtual #130 // Method kotlin/collections/IntIterator.nextInt:()I\n 60: istore 7\n 62: iload 7\n 64: istore 8\n 66: iconst_0\n 67: istore 9\n 69: new #80 // class kotlin/ranges/IntRange\n 72: dup\n 73: sipush -400\n 76: sipush 400\n 79: invokespecial #89 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 82: checkcast #45 // class java/lang/Iterable\n 85: astore 10\n 87: iconst_0\n 88: istore 11\n 90: aload 10\n 92: astore 12\n 94: new #47 // class java/util/ArrayList\n 97: dup\n 98: aload 10\n 100: bipush 10\n 102: invokestatic #51 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 105: invokespecial #54 // Method java/util/ArrayList.\"<init>\":(I)V\n 108: checkcast #56 // class java/util/Collection\n 111: astore 13\n 113: iconst_0\n 114: istore 14\n 116: aload 12\n 118: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 123: astore 15\n 125: aload 15\n 127: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 132: ifeq 192\n 135: aload 15\n 137: checkcast #127 // class kotlin/collections/IntIterator\n 140: invokevirtual #130 // Method kotlin/collections/IntIterator.nextInt:()I\n 143: istore 16\n 145: aload 13\n 147: iload 16\n 149: istore 17\n 151: astore 18\n 153: iconst_0\n 154: istore 19\n 156: aload_0\n 157: iload 8\n 159: iload 17\n 161: aload_0\n 162: getfield #102 // Field target:LDay17$BoundingBox;\n 165: invokespecial #134 // Method checkStep:(IILDay17$BoundingBox;)Lkotlin/Pair;\n 168: invokevirtual #143 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 171: checkcast #145 // class java/lang/Boolean\n 174: invokevirtual #148 // Method java/lang/Boolean.booleanValue:()Z\n 177: invokestatic #185 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 180: aload 18\n 182: swap\n 183: invokeinterface #93, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 188: pop\n 189: goto 125\n 192: aload 13\n 194: checkcast #74 // class java/util/List\n 197: nop\n 198: checkcast #45 // class java/lang/Iterable\n 201: nop\n 202: astore 8\n 204: aload 4\n 206: aload 8\n 208: invokestatic #138 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 211: pop\n 212: goto 42\n 215: aload 4\n 217: checkcast #74 // class java/util/List\n 220: nop\n 221: checkcast #45 // class java/lang/Iterable\n 224: astore_1\n 225: nop\n 226: iconst_0\n 227: istore_2\n 228: aload_1\n 229: instanceof #56 // class java/util/Collection\n 232: ifeq 251\n 235: aload_1\n 236: checkcast #56 // class java/util/Collection\n 239: invokeinterface #188, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 244: ifeq 251\n 247: iconst_0\n 248: goto 312\n 251: iconst_0\n 252: istore_3\n 253: aload_1\n 254: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 259: astore 4\n 261: aload 4\n 263: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 268: ifeq 311\n 271: aload 4\n 273: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 278: astore 5\n 280: aload 5\n 282: checkcast #145 // class java/lang/Boolean\n 285: invokevirtual #148 // Method java/lang/Boolean.booleanValue:()Z\n 288: istore 6\n 290: iconst_0\n 291: istore 7\n 293: iload 6\n 295: ifeq 261\n 298: iinc 3, 1\n 301: iload_3\n 302: ifge 261\n 305: invokestatic #191 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 308: goto 261\n 311: iload_3\n 312: ireturn\n\n private final kotlin.Pair<java.lang.Boolean, java.lang.Integer> checkStep(int, int, Day17$BoundingBox);\n Code:\n 0: new #201 // class Day17$Coord\n 3: dup\n 4: iconst_0\n 5: iconst_0\n 6: invokespecial #202 // Method Day17$Coord.\"<init>\":(II)V\n 9: astore 4\n 11: new #204 // class Day17$Velocity\n 14: dup\n 15: iload_1\n 16: iload_2\n 17: invokespecial #205 // Method Day17$Velocity.\"<init>\":(II)V\n 20: astore 5\n 22: iconst_0\n 23: istore 6\n 25: iconst_0\n 26: istore 7\n 28: aload 4\n 30: invokevirtual #208 // Method Day17$Coord.getX:()I\n 33: aload_3\n 34: invokevirtual #212 // Method Day17$BoundingBox.getXRange:()Lkotlin/ranges/IntRange;\n 37: invokevirtual #215 // Method kotlin/ranges/IntRange.getLast:()I\n 40: if_icmpgt 257\n 43: aload 4\n 45: invokevirtual #218 // Method Day17$Coord.getY:()I\n 48: aload_3\n 49: invokevirtual #221 // Method Day17$BoundingBox.getYRange:()Lkotlin/ranges/IntRange;\n 52: invokevirtual #223 // Method kotlin/ranges/IntRange.getFirst:()I\n 55: if_icmplt 257\n 58: aload 4\n 60: aload 4\n 62: invokevirtual #208 // Method Day17$Coord.getX:()I\n 65: aload 5\n 67: invokevirtual #224 // Method Day17$Velocity.getX:()I\n 70: iadd\n 71: invokevirtual #227 // Method Day17$Coord.setX:(I)V\n 74: aload 4\n 76: aload 4\n 78: invokevirtual #218 // Method Day17$Coord.getY:()I\n 81: aload 5\n 83: invokevirtual #228 // Method Day17$Velocity.getY:()I\n 86: iadd\n 87: invokevirtual #231 // Method Day17$Coord.setY:(I)V\n 90: aload 4\n 92: invokevirtual #218 // Method Day17$Coord.getY:()I\n 95: iload 6\n 97: invokestatic #162 // Method java/lang/Math.max:(II)I\n 100: istore 6\n 102: aload_3\n 103: invokevirtual #212 // Method Day17$BoundingBox.getXRange:()Lkotlin/ranges/IntRange;\n 106: astore 8\n 108: aload 8\n 110: invokevirtual #223 // Method kotlin/ranges/IntRange.getFirst:()I\n 113: istore 9\n 115: aload 8\n 117: invokevirtual #215 // Method kotlin/ranges/IntRange.getLast:()I\n 120: istore 10\n 122: aload 4\n 124: invokevirtual #208 // Method Day17$Coord.getX:()I\n 127: istore 11\n 129: iload 9\n 131: iload 11\n 133: if_icmpgt 151\n 136: iload 11\n 138: iload 10\n 140: if_icmpgt 147\n 143: iconst_1\n 144: goto 152\n 147: iconst_0\n 148: goto 152\n 151: iconst_0\n 152: ifeq 214\n 155: aload_3\n 156: invokevirtual #221 // Method Day17$BoundingBox.getYRange:()Lkotlin/ranges/IntRange;\n 159: astore 8\n 161: aload 8\n 163: invokevirtual #223 // Method kotlin/ranges/IntRange.getFirst:()I\n 166: istore 9\n 168: aload 8\n 170: invokevirtual #215 // Method kotlin/ranges/IntRange.getLast:()I\n 173: istore 10\n 175: aload 4\n 177: invokevirtual #218 // Method Day17$Coord.getY:()I\n 180: istore 11\n 182: iload 9\n 184: iload 11\n 186: if_icmpgt 204\n 189: iload 11\n 191: iload 10\n 193: if_icmpgt 200\n 196: iconst_1\n 197: goto 205\n 200: iconst_0\n 201: goto 205\n 204: iconst_0\n 205: ifeq 214\n 208: iconst_1\n 209: istore 7\n 211: goto 257\n 214: aload 5\n 216: invokevirtual #224 // Method Day17$Velocity.getX:()I\n 219: ifle 238\n 222: aload 5\n 224: invokevirtual #224 // Method Day17$Velocity.getX:()I\n 227: istore 8\n 229: aload 5\n 231: iload 8\n 233: iconst_m1\n 234: iadd\n 235: invokevirtual #232 // Method Day17$Velocity.setX:(I)V\n 238: aload 5\n 240: invokevirtual #228 // Method Day17$Velocity.getY:()I\n 243: istore 8\n 245: aload 5\n 247: iload 8\n 249: iconst_m1\n 250: iadd\n 251: invokevirtual #233 // Method Day17$Velocity.setY:(I)V\n 254: goto 28\n 257: new #140 // class kotlin/Pair\n 260: dup\n 261: iload 7\n 263: invokestatic #185 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 266: iload 6\n 268: invokestatic #236 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 271: invokespecial #239 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 274: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day17$Coord.class",
"javap": "Compiled from \"day17.kt\"\npublic final class Day17$Coord {\n private int x;\n\n private int y;\n\n public Day17$Coord(int, int);\n Code:\n 0: aload_0\n 1: invokespecial #9 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #13 // Field x:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field y:I\n 14: return\n\n public final int getX();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: ireturn\n\n public final void setX(int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: putfield #13 // Field x:I\n 5: return\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 void setY(int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: putfield #16 // Field y:I\n 5: return\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field y:I\n 4: ireturn\n\n public final Day17$Coord copy(int, int);\n Code:\n 0: new #2 // class Day17$Coord\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: invokespecial #32 // Method \"<init>\":(II)V\n 9: areturn\n\n public static Day17$Coord copy$default(Day17$Coord, int, int, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_1\n 2: iand\n 3: ifeq 11\n 6: aload_0\n 7: getfield #13 // Field x:I\n 10: istore_1\n 11: iload_3\n 12: iconst_2\n 13: iand\n 14: ifeq 22\n 17: aload_0\n 18: getfield #16 // Field y:I\n 21: istore_2\n 22: aload_0\n 23: iload_1\n 24: iload_2\n 25: invokevirtual #36 // Method copy:(II)LDay17$Coord;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #40 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #41 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #43 // String Coord(x=\n 9: invokevirtual #47 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field x:I\n 16: invokevirtual #50 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #52 // String , y=\n 21: invokevirtual #47 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #16 // Field y:I\n 28: invokevirtual #50 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #55 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #57 // 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 #63 // 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 #63 // Method java/lang/Integer.hashCode:(I)I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: ireturn\n\n public boolean equals(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: if_acmpne 7\n 5: iconst_1\n 6: ireturn\n 7: aload_1\n 8: instanceof #2 // class Day17$Coord\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day17$Coord\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field x:I\n 25: aload_2\n 26: getfield #13 // Field x:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field y:I\n 38: aload_2\n 39: getfield #16 // Field y:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: iconst_1\n 48: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day17$BoundingBox.class",
"javap": "Compiled from \"day17.kt\"\npublic final class Day17$BoundingBox {\n private final kotlin.ranges.IntRange xRange;\n\n private final kotlin.ranges.IntRange yRange;\n\n public Day17$BoundingBox(kotlin.ranges.IntRange, kotlin.ranges.IntRange);\n Code:\n 0: aload_1\n 1: ldc #9 // String xRange\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 yRange\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokespecial #20 // Method java/lang/Object.\"<init>\":()V\n 16: aload_0\n 17: aload_1\n 18: putfield #23 // Field xRange:Lkotlin/ranges/IntRange;\n 21: aload_0\n 22: aload_2\n 23: putfield #25 // Field yRange:Lkotlin/ranges/IntRange;\n 26: return\n\n public final kotlin.ranges.IntRange getXRange();\n Code:\n 0: aload_0\n 1: getfield #23 // Field xRange:Lkotlin/ranges/IntRange;\n 4: areturn\n\n public final kotlin.ranges.IntRange getYRange();\n Code:\n 0: aload_0\n 1: getfield #25 // Field yRange:Lkotlin/ranges/IntRange;\n 4: areturn\n\n public final kotlin.ranges.IntRange component1();\n Code:\n 0: aload_0\n 1: getfield #23 // Field xRange:Lkotlin/ranges/IntRange;\n 4: areturn\n\n public final kotlin.ranges.IntRange component2();\n Code:\n 0: aload_0\n 1: getfield #25 // Field yRange:Lkotlin/ranges/IntRange;\n 4: areturn\n\n public final Day17$BoundingBox copy(kotlin.ranges.IntRange, kotlin.ranges.IntRange);\n Code:\n 0: aload_1\n 1: ldc #9 // String xRange\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 yRange\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class Day17$BoundingBox\n 15: dup\n 16: aload_1\n 17: aload_2\n 18: invokespecial #36 // Method \"<init>\":(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)V\n 21: areturn\n\n public static Day17$BoundingBox copy$default(Day17$BoundingBox, kotlin.ranges.IntRange, kotlin.ranges.IntRange, 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 xRange:Lkotlin/ranges/IntRange;\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 yRange:Lkotlin/ranges/IntRange;\n 21: astore_2\n 22: aload_0\n 23: aload_1\n 24: aload_2\n 25: invokevirtual #40 // Method copy:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)LDay17$BoundingBox;\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 BoundingBox(xRange=\n 9: invokevirtual #51 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #23 // Field xRange:Lkotlin/ranges/IntRange;\n 16: invokevirtual #54 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #56 // String , yRange=\n 21: invokevirtual #51 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #25 // Field yRange:Lkotlin/ranges/IntRange;\n 28: invokevirtual #54 // 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 #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 #23 // Field xRange:Lkotlin/ranges/IntRange;\n 4: invokevirtual #67 // 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 #25 // Field yRange:Lkotlin/ranges/IntRange;\n 16: invokevirtual #67 // Method kotlin/ranges/IntRange.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 Day17$BoundingBox\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day17$BoundingBox\n 20: astore_2\n 21: aload_0\n 22: getfield #23 // Field xRange:Lkotlin/ranges/IntRange;\n 25: aload_2\n 26: getfield #23 // Field xRange:Lkotlin/ranges/IntRange;\n 29: invokestatic #76 // 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 yRange:Lkotlin/ranges/IntRange;\n 41: aload_2\n 42: getfield #25 // Field yRange:Lkotlin/ranges/IntRange;\n 45: invokestatic #76 // 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": "Ad0lphus__AOC2021__02f219e/Day17Kt.class",
"javap": "Compiled from \"day17.kt\"\npublic final class Day17Kt {\n public static final void print_day_17();\n Code:\n 0: ldc #8 // String \\u001b[33m\n 2: astore_0\n 3: ldc #10 // String \\u001b[0m\n 5: astore_1\n 6: ldc #12 // String \\u001b[32m\n 8: astore_2\n 9: new #14 // class java/lang/StringBuilder\n 12: dup\n 13: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 16: aload_0\n 17: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: ldc #23 // String -\n 22: checkcast #25 // class java/lang/CharSequence\n 25: bipush 25\n 27: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 30: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 33: ldc #33 // String Advent of Code - Day 17\n 35: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 38: ldc #23 // String -\n 40: checkcast #25 // class java/lang/CharSequence\n 43: bipush 25\n 45: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 48: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: aload_1\n 52: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 55: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 58: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 61: swap\n 62: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 65: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: aload_2\n 69: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: invokestatic #55 // Method java/lang/Runtime.getRuntime:()Ljava/lang/Runtime;\n 75: ldc #57 // String figlet Trick Shot -c -f small\n 77: invokevirtual #61 // Method java/lang/Runtime.exec:(Ljava/lang/String;)Ljava/lang/Process;\n 80: astore_3\n 81: new #63 // class java/io/BufferedReader\n 84: dup\n 85: new #65 // class java/io/InputStreamReader\n 88: dup\n 89: aload_3\n 90: invokevirtual #71 // Method java/lang/Process.getInputStream:()Ljava/io/InputStream;\n 93: invokespecial #74 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;)V\n 96: checkcast #76 // class java/io/Reader\n 99: invokespecial #79 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;)V\n 102: astore 4\n 104: aload 4\n 106: checkcast #76 // class java/io/Reader\n 109: invokedynamic #98, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 114: invokestatic #104 // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V\n 117: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 120: aload_1\n 121: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 124: new #14 // class java/lang/StringBuilder\n 127: dup\n 128: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 131: aload_0\n 132: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 135: ldc #23 // String -\n 137: checkcast #25 // class java/lang/CharSequence\n 140: bipush 33\n 142: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 145: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 148: ldc #106 // String Output\n 150: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 153: ldc #23 // String -\n 155: checkcast #25 // class java/lang/CharSequence\n 158: bipush 33\n 160: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 163: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 166: aload_1\n 167: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 170: bipush 10\n 172: invokevirtual #109 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 175: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 178: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 181: swap\n 182: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 185: return\n\n public static final void main();\n Code:\n 0: invokestatic #120 // Method print_day_17:()V\n 3: new #14 // class java/lang/StringBuilder\n 6: dup\n 7: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 10: ldc #122 // String Puzzle 1:\n 12: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 15: new #124 // class Day17\n 18: dup\n 19: invokespecial #125 // Method Day17.\"<init>\":()V\n 22: invokevirtual #129 // Method Day17.part_1:()I\n 25: invokevirtual #132 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 28: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 31: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 34: swap\n 35: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 38: new #14 // class java/lang/StringBuilder\n 41: dup\n 42: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 45: ldc #134 // String Puzzle 2:\n 47: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 50: new #124 // class Day17\n 53: dup\n 54: invokespecial #125 // Method Day17.\"<init>\":()V\n 57: invokevirtual #137 // Method Day17.part_2:()I\n 60: invokevirtual #132 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 63: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 66: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 69: swap\n 70: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 73: new #14 // class java/lang/StringBuilder\n 76: dup\n 77: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 80: ldc #139 // String \\n\\u001b[33m\n 82: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 85: ldc #141 // String =\n 87: checkcast #25 // class java/lang/CharSequence\n 90: bipush 72\n 92: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 95: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 98: ldc #143 // String \\u001b[0m\\n\n 100: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 103: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 106: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 109: swap\n 110: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 113: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #146 // Method main:()V\n 3: return\n\n private static final kotlin.Unit print_day_17$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #150 // String it\n 3: invokestatic #156 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: aload_0\n 10: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 13: getstatic #162 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 16: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day17$Velocity.class",
"javap": "Compiled from \"day17.kt\"\npublic final class Day17$Velocity {\n private int x;\n\n private int y;\n\n public Day17$Velocity(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 void setX(int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: putfield #13 // Field x:I\n 5: return\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 void setY(int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: putfield #16 // Field y:I\n 5: return\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field y:I\n 4: ireturn\n\n public final Day17$Velocity copy(int, int);\n Code:\n 0: new #2 // class Day17$Velocity\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: invokespecial #32 // Method \"<init>\":(II)V\n 9: areturn\n\n public static Day17$Velocity copy$default(Day17$Velocity, 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 #36 // Method copy:(II)LDay17$Velocity;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #40 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #41 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #43 // String Velocity(x=\n 9: invokevirtual #47 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field x:I\n 16: invokevirtual #50 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #52 // String , y=\n 21: invokevirtual #47 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #16 // Field y:I\n 28: invokevirtual #50 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #55 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #57 // 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 #63 // 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 #63 // Method java/lang/Integer.hashCode:(I)I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: ireturn\n\n public boolean equals(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: if_acmpne 7\n 5: iconst_1\n 6: ireturn\n 7: aload_1\n 8: instanceof #2 // class Day17$Velocity\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day17$Velocity\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": ""
}
] |
Ad0lphus__AOC2021__02f219e/day13/Kotlin/day13.kt
|
import java.io.*
fun print_day_13() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 13" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Transparent Origami -c -f small")
val reader = BufferedReader(InputStreamReader(process.inputStream))
reader.forEachLine { println(it) }
println(reset)
println(yellow + "-".repeat(33) + "Output" + "-".repeat(33) + reset + "\n")
}
fun main() {
print_day_13()
Day13().part_1()
Day13().part_2()
println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}
class Day13 {
private val lines = File("../Input/day13.txt").readLines()
private val coords = lines.takeWhile { it.trim() != "" }.map {
val (x, y) = it.split(",")
x.toInt() to y.toInt()
}
private val folds = lines.drop(coords.size + 1)
fun part_1() {
val maxX = coords.maxOf { it.first }
val maxY = coords.maxOf { it.second }
val yFold = folds.first().startsWith("fold along y")
val foldAmount = folds.first().split("=")[1].toInt()
val afterFold = if (yFold) {
val newCoords = coords.filter { it.second < foldAmount }.toMutableList()
for (pair in coords.filter {it.second > foldAmount} ) {
newCoords.add(pair.first to maxY - pair.second)
}
newCoords
}
else {
val newCoords = coords.filter { it.first < foldAmount }.toMutableList()
for (pair in coords.filter {it.first > foldAmount} ) {
newCoords.add(maxX - pair.first to pair.second)
}
newCoords
}
println("Puzzle 1: " + afterFold.distinct().size)
}
fun part_2() {
var foldedCoords = coords
folds.forEach { fold ->
val maxX = foldedCoords.maxOf { it.first }
val maxY = foldedCoords.maxOf { it.second }
val yFold = fold.startsWith("fold along y")
val foldAmount = fold.split("=")[1].toInt()
val afterFold = if (yFold) {
val newCoords = foldedCoords.filter { it.second < foldAmount }.toMutableList()
for (pair in foldedCoords.filter {it.second > foldAmount} ) {
newCoords.add(pair.first to maxY - pair.second)
}
newCoords
}
else {
val newCoords = foldedCoords.filter { it.first < foldAmount }.toMutableList()
for (pair in foldedCoords.filter {it.first > foldAmount} ) {
newCoords.add(maxX - pair.first to pair.second)
}
newCoords
}
foldedCoords = afterFold
}
val maxX = foldedCoords.maxOf { it.first }
val maxY = foldedCoords.maxOf { it.second }
println("Puzzle 2: ")
for (y in 0..maxY) {
for (x in 0..maxX) {
print( if ((x to y) in foldedCoords) "#" else " ")
}
println()
}
}
}
|
[
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day13.class",
"javap": "Compiled from \"day13.kt\"\npublic final class Day13 {\n private final java.util.List<java.lang.String> lines;\n\n private final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> coords;\n\n private final java.util.List<java.lang.String> folds;\n\n public Day13();\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 java/io/File\n 8: dup\n 9: ldc #12 // String ../Input/day13.txt\n 11: invokespecial #15 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 14: aconst_null\n 15: iconst_1\n 16: aconst_null\n 17: invokestatic #21 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 20: putfield #25 // Field lines:Ljava/util/List;\n 23: aload_0\n 24: aload_0\n 25: getfield #25 // Field lines:Ljava/util/List;\n 28: checkcast #27 // class java/lang/Iterable\n 31: astore_1\n 32: astore 13\n 34: iconst_0\n 35: istore_2\n 36: new #29 // class java/util/ArrayList\n 39: dup\n 40: invokespecial #30 // Method java/util/ArrayList.\"<init>\":()V\n 43: astore_3\n 44: aload_1\n 45: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 50: astore 4\n 52: aload 4\n 54: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 121\n 62: aload 4\n 64: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 69: astore 5\n 71: aload 5\n 73: checkcast #46 // class java/lang/String\n 76: astore 6\n 78: iconst_0\n 79: istore 7\n 81: aload 6\n 83: checkcast #48 // class java/lang/CharSequence\n 86: invokestatic #54 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 89: invokevirtual #58 // Method java/lang/Object.toString:()Ljava/lang/String;\n 92: ldc #60 // String\n 94: invokestatic #66 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 97: ifne 104\n 100: iconst_1\n 101: goto 105\n 104: iconst_0\n 105: ifne 111\n 108: goto 121\n 111: aload_3\n 112: aload 5\n 114: invokevirtual #70 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 117: pop\n 118: goto 52\n 121: aload_3\n 122: checkcast #72 // class java/util/List\n 125: aload 13\n 127: swap\n 128: checkcast #27 // class java/lang/Iterable\n 131: astore_1\n 132: astore 13\n 134: iconst_0\n 135: istore_2\n 136: aload_1\n 137: astore_3\n 138: new #29 // class java/util/ArrayList\n 141: dup\n 142: aload_1\n 143: bipush 10\n 145: invokestatic #78 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 148: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 151: checkcast #83 // class java/util/Collection\n 154: astore 4\n 156: iconst_0\n 157: istore 5\n 159: aload_3\n 160: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 165: astore 6\n 167: aload 6\n 169: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 174: ifeq 286\n 177: aload 6\n 179: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 184: astore 7\n 186: aload 4\n 188: aload 7\n 190: checkcast #46 // class java/lang/String\n 193: astore 8\n 195: astore 14\n 197: iconst_0\n 198: istore 9\n 200: aload 8\n 202: checkcast #48 // class java/lang/CharSequence\n 205: iconst_1\n 206: anewarray #46 // class java/lang/String\n 209: astore 10\n 211: aload 10\n 213: iconst_0\n 214: ldc #85 // String ,\n 216: aastore\n 217: aload 10\n 219: iconst_0\n 220: iconst_0\n 221: bipush 6\n 223: aconst_null\n 224: invokestatic #89 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 227: astore 11\n 229: aload 11\n 231: iconst_0\n 232: invokeinterface #93, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 237: checkcast #46 // class java/lang/String\n 240: astore 10\n 242: aload 11\n 244: iconst_1\n 245: invokeinterface #93, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 250: checkcast #46 // class java/lang/String\n 253: astore 12\n 255: aload 10\n 257: invokestatic #99 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 260: invokestatic #103 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 263: aload 12\n 265: invokestatic #99 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 268: invokestatic #103 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 271: invokestatic #109 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 274: aload 14\n 276: swap\n 277: invokeinterface #110, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 282: pop\n 283: goto 167\n 286: aload 4\n 288: checkcast #72 // class java/util/List\n 291: nop\n 292: aload 13\n 294: swap\n 295: putfield #113 // Field coords:Ljava/util/List;\n 298: aload_0\n 299: aload_0\n 300: getfield #25 // Field lines:Ljava/util/List;\n 303: checkcast #27 // class java/lang/Iterable\n 306: aload_0\n 307: getfield #113 // Field coords:Ljava/util/List;\n 310: invokeinterface #117, 1 // InterfaceMethod java/util/List.size:()I\n 315: iconst_1\n 316: iadd\n 317: invokestatic #121 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 320: putfield #124 // Field folds:Ljava/util/List;\n 323: return\n\n public final void part_1();\n Code:\n 0: aload_0\n 1: getfield #113 // Field coords:Ljava/util/List;\n 4: checkcast #27 // class java/lang/Iterable\n 7: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 12: astore_3\n 13: aload_3\n 14: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 19: ifne 30\n 22: new #150 // class java/util/NoSuchElementException\n 25: dup\n 26: invokespecial #151 // Method java/util/NoSuchElementException.\"<init>\":()V\n 29: athrow\n 30: aload_3\n 31: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 36: checkcast #153 // class kotlin/Pair\n 39: astore 4\n 41: iconst_0\n 42: istore 5\n 44: aload 4\n 46: invokevirtual #156 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 49: checkcast #158 // class java/lang/Number\n 52: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 55: istore 4\n 57: aload_3\n 58: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 63: ifeq 107\n 66: aload_3\n 67: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 72: checkcast #153 // class kotlin/Pair\n 75: astore 5\n 77: iconst_0\n 78: istore 6\n 80: aload 5\n 82: invokevirtual #156 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 85: checkcast #158 // class java/lang/Number\n 88: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 91: istore 5\n 93: iload 4\n 95: iload 5\n 97: if_icmpge 57\n 100: iload 5\n 102: istore 4\n 104: goto 57\n 107: iload 4\n 109: istore_1\n 110: aload_0\n 111: getfield #113 // Field coords:Ljava/util/List;\n 114: checkcast #27 // class java/lang/Iterable\n 117: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 122: astore 4\n 124: aload 4\n 126: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 131: ifne 142\n 134: new #150 // class java/util/NoSuchElementException\n 137: dup\n 138: invokespecial #151 // Method java/util/NoSuchElementException.\"<init>\":()V\n 141: athrow\n 142: aload 4\n 144: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 149: checkcast #153 // class kotlin/Pair\n 152: astore 5\n 154: iconst_0\n 155: istore 6\n 157: aload 5\n 159: invokevirtual #164 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 162: checkcast #158 // class java/lang/Number\n 165: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 168: istore 5\n 170: aload 4\n 172: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 177: ifeq 222\n 180: aload 4\n 182: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 187: checkcast #153 // class kotlin/Pair\n 190: astore 6\n 192: iconst_0\n 193: istore 7\n 195: aload 6\n 197: invokevirtual #164 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 200: checkcast #158 // class java/lang/Number\n 203: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 206: istore 6\n 208: iload 5\n 210: iload 6\n 212: if_icmpge 170\n 215: iload 6\n 217: istore 5\n 219: goto 170\n 222: iload 5\n 224: istore_2\n 225: aload_0\n 226: getfield #124 // Field folds:Ljava/util/List;\n 229: invokestatic #168 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 232: checkcast #46 // class java/lang/String\n 235: ldc #170 // String fold along y\n 237: iconst_0\n 238: iconst_2\n 239: aconst_null\n 240: invokestatic #174 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 243: istore_3\n 244: aload_0\n 245: getfield #124 // Field folds:Ljava/util/List;\n 248: invokestatic #168 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 251: checkcast #48 // class java/lang/CharSequence\n 254: iconst_1\n 255: anewarray #46 // class java/lang/String\n 258: astore 5\n 260: aload 5\n 262: iconst_0\n 263: ldc #176 // String =\n 265: aastore\n 266: aload 5\n 268: iconst_0\n 269: iconst_0\n 270: bipush 6\n 272: aconst_null\n 273: invokestatic #89 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 276: iconst_1\n 277: invokeinterface #93, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 282: checkcast #46 // class java/lang/String\n 285: invokestatic #99 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 288: istore 4\n 290: iload_3\n 291: ifeq 595\n 294: aload_0\n 295: getfield #113 // Field coords:Ljava/util/List;\n 298: checkcast #27 // class java/lang/Iterable\n 301: astore 7\n 303: iconst_0\n 304: istore 8\n 306: aload 7\n 308: astore 9\n 310: new #29 // class java/util/ArrayList\n 313: dup\n 314: invokespecial #30 // Method java/util/ArrayList.\"<init>\":()V\n 317: checkcast #83 // class java/util/Collection\n 320: astore 10\n 322: iconst_0\n 323: istore 11\n 325: aload 9\n 327: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 332: astore 12\n 334: aload 12\n 336: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 341: ifeq 400\n 344: aload 12\n 346: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 351: astore 13\n 353: aload 13\n 355: checkcast #153 // class kotlin/Pair\n 358: astore 14\n 360: iconst_0\n 361: istore 15\n 363: aload 14\n 365: invokevirtual #164 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 368: checkcast #158 // class java/lang/Number\n 371: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 374: iload 4\n 376: if_icmpge 383\n 379: iconst_1\n 380: goto 384\n 383: iconst_0\n 384: ifeq 334\n 387: aload 10\n 389: aload 13\n 391: invokeinterface #110, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 396: pop\n 397: goto 334\n 400: aload 10\n 402: checkcast #72 // class java/util/List\n 405: nop\n 406: checkcast #83 // class java/util/Collection\n 409: invokestatic #180 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 412: astore 6\n 414: aload_0\n 415: getfield #113 // Field coords:Ljava/util/List;\n 418: checkcast #27 // class java/lang/Iterable\n 421: astore 8\n 423: iconst_0\n 424: istore 9\n 426: aload 8\n 428: astore 10\n 430: new #29 // class java/util/ArrayList\n 433: dup\n 434: invokespecial #30 // Method java/util/ArrayList.\"<init>\":()V\n 437: checkcast #83 // class java/util/Collection\n 440: astore 11\n 442: iconst_0\n 443: istore 12\n 445: aload 10\n 447: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 452: astore 13\n 454: aload 13\n 456: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 461: ifeq 520\n 464: aload 13\n 466: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 471: astore 14\n 473: aload 14\n 475: checkcast #153 // class kotlin/Pair\n 478: astore 15\n 480: iconst_0\n 481: istore 16\n 483: aload 15\n 485: invokevirtual #164 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 488: checkcast #158 // class java/lang/Number\n 491: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 494: iload 4\n 496: if_icmple 503\n 499: iconst_1\n 500: goto 504\n 503: iconst_0\n 504: ifeq 454\n 507: aload 11\n 509: aload 14\n 511: invokeinterface #110, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 516: pop\n 517: goto 454\n 520: aload 11\n 522: checkcast #72 // class java/util/List\n 525: nop\n 526: invokeinterface #181, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 531: astore 7\n 533: aload 7\n 535: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 540: ifeq 590\n 543: aload 7\n 545: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 550: checkcast #153 // class kotlin/Pair\n 553: astore 8\n 555: aload 6\n 557: aload 8\n 559: invokevirtual #156 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 562: iload_2\n 563: aload 8\n 565: invokevirtual #164 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 568: checkcast #158 // class java/lang/Number\n 571: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 574: isub\n 575: invokestatic #103 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 578: invokestatic #109 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 581: invokeinterface #182, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 586: pop\n 587: goto 533\n 590: aload 6\n 592: goto 893\n 595: aload_0\n 596: getfield #113 // Field coords:Ljava/util/List;\n 599: checkcast #27 // class java/lang/Iterable\n 602: astore 7\n 604: iconst_0\n 605: istore 8\n 607: aload 7\n 609: astore 9\n 611: new #29 // class java/util/ArrayList\n 614: dup\n 615: invokespecial #30 // Method java/util/ArrayList.\"<init>\":()V\n 618: checkcast #83 // class java/util/Collection\n 621: astore 10\n 623: iconst_0\n 624: istore 11\n 626: aload 9\n 628: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 633: astore 12\n 635: aload 12\n 637: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 642: ifeq 701\n 645: aload 12\n 647: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 652: astore 13\n 654: aload 13\n 656: checkcast #153 // class kotlin/Pair\n 659: astore 14\n 661: iconst_0\n 662: istore 15\n 664: aload 14\n 666: invokevirtual #156 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 669: checkcast #158 // class java/lang/Number\n 672: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 675: iload 4\n 677: if_icmpge 684\n 680: iconst_1\n 681: goto 685\n 684: iconst_0\n 685: ifeq 635\n 688: aload 10\n 690: aload 13\n 692: invokeinterface #110, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 697: pop\n 698: goto 635\n 701: aload 10\n 703: checkcast #72 // class java/util/List\n 706: nop\n 707: checkcast #83 // class java/util/Collection\n 710: invokestatic #180 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 713: astore 6\n 715: aload_0\n 716: getfield #113 // Field coords:Ljava/util/List;\n 719: checkcast #27 // class java/lang/Iterable\n 722: astore 8\n 724: iconst_0\n 725: istore 9\n 727: aload 8\n 729: astore 10\n 731: new #29 // class java/util/ArrayList\n 734: dup\n 735: invokespecial #30 // Method java/util/ArrayList.\"<init>\":()V\n 738: checkcast #83 // class java/util/Collection\n 741: astore 11\n 743: iconst_0\n 744: istore 12\n 746: aload 10\n 748: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 753: astore 13\n 755: aload 13\n 757: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 762: ifeq 821\n 765: aload 13\n 767: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 772: astore 14\n 774: aload 14\n 776: checkcast #153 // class kotlin/Pair\n 779: astore 15\n 781: iconst_0\n 782: istore 16\n 784: aload 15\n 786: invokevirtual #156 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 789: checkcast #158 // class java/lang/Number\n 792: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 795: iload 4\n 797: if_icmple 804\n 800: iconst_1\n 801: goto 805\n 804: iconst_0\n 805: ifeq 755\n 808: aload 11\n 810: aload 14\n 812: invokeinterface #110, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 817: pop\n 818: goto 755\n 821: aload 11\n 823: checkcast #72 // class java/util/List\n 826: nop\n 827: invokeinterface #181, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 832: astore 7\n 834: aload 7\n 836: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 841: ifeq 891\n 844: aload 7\n 846: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 851: checkcast #153 // class kotlin/Pair\n 854: astore 8\n 856: aload 6\n 858: iload_1\n 859: aload 8\n 861: invokevirtual #156 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 864: checkcast #158 // class java/lang/Number\n 867: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 870: isub\n 871: invokestatic #103 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 874: aload 8\n 876: invokevirtual #164 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 879: invokestatic #109 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 882: invokeinterface #182, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 887: pop\n 888: goto 834\n 891: aload 6\n 893: astore 5\n 895: new #184 // class java/lang/StringBuilder\n 898: dup\n 899: invokespecial #185 // Method java/lang/StringBuilder.\"<init>\":()V\n 902: ldc #187 // String Puzzle 1:\n 904: invokevirtual #191 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 907: aload 5\n 909: checkcast #27 // class java/lang/Iterable\n 912: invokestatic #195 // Method kotlin/collections/CollectionsKt.distinct:(Ljava/lang/Iterable;)Ljava/util/List;\n 915: invokeinterface #117, 1 // InterfaceMethod java/util/List.size:()I\n 920: invokevirtual #198 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 923: invokevirtual #199 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 926: getstatic #205 // Field java/lang/System.out:Ljava/io/PrintStream;\n 929: swap\n 930: invokevirtual #211 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 933: return\n\n public final void part_2();\n Code:\n 0: aconst_null\n 1: astore_1\n 2: aload_0\n 3: getfield #113 // Field coords:Ljava/util/List;\n 6: astore_1\n 7: aload_0\n 8: getfield #124 // Field folds:Ljava/util/List;\n 11: checkcast #27 // class java/lang/Iterable\n 14: astore_2\n 15: iconst_0\n 16: istore_3\n 17: aload_2\n 18: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 23: astore 4\n 25: aload 4\n 27: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 32: ifeq 937\n 35: aload 4\n 37: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 42: astore 5\n 44: aload 5\n 46: checkcast #46 // class java/lang/String\n 49: astore 6\n 51: iconst_0\n 52: istore 7\n 54: aload_1\n 55: checkcast #27 // class java/lang/Iterable\n 58: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 63: astore 8\n 65: aload 8\n 67: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 72: ifne 83\n 75: new #150 // class java/util/NoSuchElementException\n 78: dup\n 79: invokespecial #151 // Method java/util/NoSuchElementException.\"<init>\":()V\n 82: athrow\n 83: aload 8\n 85: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 90: checkcast #153 // class kotlin/Pair\n 93: astore 9\n 95: iconst_0\n 96: istore 10\n 98: aload 9\n 100: invokevirtual #156 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 103: checkcast #158 // class java/lang/Number\n 106: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 109: istore 9\n 111: aload 8\n 113: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 118: ifeq 163\n 121: aload 8\n 123: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 128: checkcast #153 // class kotlin/Pair\n 131: astore 10\n 133: iconst_0\n 134: istore 11\n 136: aload 10\n 138: invokevirtual #156 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 141: checkcast #158 // class java/lang/Number\n 144: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 147: istore 10\n 149: iload 9\n 151: iload 10\n 153: if_icmpge 111\n 156: iload 10\n 158: istore 9\n 160: goto 111\n 163: iload 9\n 165: istore 12\n 167: aload_1\n 168: checkcast #27 // class java/lang/Iterable\n 171: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 176: astore 9\n 178: aload 9\n 180: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 185: ifne 196\n 188: new #150 // class java/util/NoSuchElementException\n 191: dup\n 192: invokespecial #151 // Method java/util/NoSuchElementException.\"<init>\":()V\n 195: athrow\n 196: aload 9\n 198: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 203: checkcast #153 // class kotlin/Pair\n 206: astore 10\n 208: iconst_0\n 209: istore 11\n 211: aload 10\n 213: invokevirtual #164 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 216: checkcast #158 // class java/lang/Number\n 219: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 222: istore 10\n 224: aload 9\n 226: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 231: ifeq 276\n 234: aload 9\n 236: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 241: checkcast #153 // class kotlin/Pair\n 244: astore 11\n 246: iconst_0\n 247: istore 13\n 249: aload 11\n 251: invokevirtual #164 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 254: checkcast #158 // class java/lang/Number\n 257: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 260: istore 11\n 262: iload 10\n 264: iload 11\n 266: if_icmpge 224\n 269: iload 11\n 271: istore 10\n 273: goto 224\n 276: iload 10\n 278: istore 14\n 280: aload 6\n 282: ldc #170 // String fold along y\n 284: iconst_0\n 285: iconst_2\n 286: aconst_null\n 287: invokestatic #174 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 290: istore 8\n 292: aload 6\n 294: checkcast #48 // class java/lang/CharSequence\n 297: iconst_1\n 298: anewarray #46 // class java/lang/String\n 301: astore 10\n 303: aload 10\n 305: iconst_0\n 306: ldc #176 // String =\n 308: aastore\n 309: aload 10\n 311: iconst_0\n 312: iconst_0\n 313: bipush 6\n 315: aconst_null\n 316: invokestatic #89 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 319: iconst_1\n 320: invokeinterface #93, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 325: checkcast #46 // class java/lang/String\n 328: invokestatic #99 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 331: istore 9\n 333: iload 8\n 335: ifeq 634\n 338: aload_1\n 339: checkcast #27 // class java/lang/Iterable\n 342: astore 13\n 344: iconst_0\n 345: istore 15\n 347: aload 13\n 349: astore 16\n 351: new #29 // class java/util/ArrayList\n 354: dup\n 355: invokespecial #30 // Method java/util/ArrayList.\"<init>\":()V\n 358: checkcast #83 // class java/util/Collection\n 361: astore 17\n 363: iconst_0\n 364: istore 18\n 366: aload 16\n 368: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 373: astore 19\n 375: aload 19\n 377: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 382: ifeq 441\n 385: aload 19\n 387: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 392: astore 20\n 394: aload 20\n 396: checkcast #153 // class kotlin/Pair\n 399: astore 21\n 401: iconst_0\n 402: istore 22\n 404: aload 21\n 406: invokevirtual #164 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 409: checkcast #158 // class java/lang/Number\n 412: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 415: iload 9\n 417: if_icmpge 424\n 420: iconst_1\n 421: goto 425\n 424: iconst_0\n 425: ifeq 375\n 428: aload 17\n 430: aload 20\n 432: invokeinterface #110, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 437: pop\n 438: goto 375\n 441: aload 17\n 443: checkcast #72 // class java/util/List\n 446: nop\n 447: checkcast #83 // class java/util/Collection\n 450: invokestatic #180 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 453: astore 11\n 455: aload_1\n 456: checkcast #27 // class java/lang/Iterable\n 459: astore 15\n 461: iconst_0\n 462: istore 16\n 464: aload 15\n 466: astore 17\n 468: new #29 // class java/util/ArrayList\n 471: dup\n 472: invokespecial #30 // Method java/util/ArrayList.\"<init>\":()V\n 475: checkcast #83 // class java/util/Collection\n 478: astore 18\n 480: iconst_0\n 481: istore 19\n 483: aload 17\n 485: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 490: astore 20\n 492: aload 20\n 494: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 499: ifeq 558\n 502: aload 20\n 504: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 509: astore 21\n 511: aload 21\n 513: checkcast #153 // class kotlin/Pair\n 516: astore 22\n 518: iconst_0\n 519: istore 23\n 521: aload 22\n 523: invokevirtual #164 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 526: checkcast #158 // class java/lang/Number\n 529: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 532: iload 9\n 534: if_icmple 541\n 537: iconst_1\n 538: goto 542\n 541: iconst_0\n 542: ifeq 492\n 545: aload 18\n 547: aload 21\n 549: invokeinterface #110, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 554: pop\n 555: goto 492\n 558: aload 18\n 560: checkcast #72 // class java/util/List\n 563: nop\n 564: invokeinterface #181, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 569: astore 13\n 571: aload 13\n 573: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 578: ifeq 629\n 581: aload 13\n 583: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 588: checkcast #153 // class kotlin/Pair\n 591: astore 15\n 593: aload 11\n 595: aload 15\n 597: invokevirtual #156 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 600: iload 14\n 602: aload 15\n 604: invokevirtual #164 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 607: checkcast #158 // class java/lang/Number\n 610: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 613: isub\n 614: invokestatic #103 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 617: invokestatic #109 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 620: invokeinterface #182, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 625: pop\n 626: goto 571\n 629: aload 11\n 631: goto 927\n 634: aload_1\n 635: checkcast #27 // class java/lang/Iterable\n 638: astore 13\n 640: iconst_0\n 641: istore 15\n 643: aload 13\n 645: astore 16\n 647: new #29 // class java/util/ArrayList\n 650: dup\n 651: invokespecial #30 // Method java/util/ArrayList.\"<init>\":()V\n 654: checkcast #83 // class java/util/Collection\n 657: astore 17\n 659: iconst_0\n 660: istore 18\n 662: aload 16\n 664: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 669: astore 19\n 671: aload 19\n 673: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 678: ifeq 737\n 681: aload 19\n 683: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 688: astore 20\n 690: aload 20\n 692: checkcast #153 // class kotlin/Pair\n 695: astore 21\n 697: iconst_0\n 698: istore 22\n 700: aload 21\n 702: invokevirtual #156 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 705: checkcast #158 // class java/lang/Number\n 708: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 711: iload 9\n 713: if_icmpge 720\n 716: iconst_1\n 717: goto 721\n 720: iconst_0\n 721: ifeq 671\n 724: aload 17\n 726: aload 20\n 728: invokeinterface #110, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 733: pop\n 734: goto 671\n 737: aload 17\n 739: checkcast #72 // class java/util/List\n 742: nop\n 743: checkcast #83 // class java/util/Collection\n 746: invokestatic #180 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 749: astore 11\n 751: aload_1\n 752: checkcast #27 // class java/lang/Iterable\n 755: astore 15\n 757: iconst_0\n 758: istore 16\n 760: aload 15\n 762: astore 17\n 764: new #29 // class java/util/ArrayList\n 767: dup\n 768: invokespecial #30 // Method java/util/ArrayList.\"<init>\":()V\n 771: checkcast #83 // class java/util/Collection\n 774: astore 18\n 776: iconst_0\n 777: istore 19\n 779: aload 17\n 781: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 786: astore 20\n 788: aload 20\n 790: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 795: ifeq 854\n 798: aload 20\n 800: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 805: astore 21\n 807: aload 21\n 809: checkcast #153 // class kotlin/Pair\n 812: astore 22\n 814: iconst_0\n 815: istore 23\n 817: aload 22\n 819: invokevirtual #156 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 822: checkcast #158 // class java/lang/Number\n 825: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 828: iload 9\n 830: if_icmple 837\n 833: iconst_1\n 834: goto 838\n 837: iconst_0\n 838: ifeq 788\n 841: aload 18\n 843: aload 21\n 845: invokeinterface #110, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 850: pop\n 851: goto 788\n 854: aload 18\n 856: checkcast #72 // class java/util/List\n 859: nop\n 860: invokeinterface #181, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 865: astore 13\n 867: aload 13\n 869: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 874: ifeq 925\n 877: aload 13\n 879: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 884: checkcast #153 // class kotlin/Pair\n 887: astore 15\n 889: aload 11\n 891: iload 12\n 893: aload 15\n 895: invokevirtual #156 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 898: checkcast #158 // class java/lang/Number\n 901: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 904: isub\n 905: invokestatic #103 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 908: aload 15\n 910: invokevirtual #164 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 913: invokestatic #109 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 916: invokeinterface #182, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 921: pop\n 922: goto 867\n 925: aload 11\n 927: astore 10\n 929: aload 10\n 931: astore_1\n 932: nop\n 933: nop\n 934: goto 25\n 937: nop\n 938: aload_1\n 939: checkcast #27 // class java/lang/Iterable\n 942: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 947: astore 4\n 949: aload 4\n 951: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 956: ifne 967\n 959: new #150 // class java/util/NoSuchElementException\n 962: dup\n 963: invokespecial #151 // Method java/util/NoSuchElementException.\"<init>\":()V\n 966: athrow\n 967: aload 4\n 969: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 974: checkcast #153 // class kotlin/Pair\n 977: astore 5\n 979: iconst_0\n 980: istore 6\n 982: aload 5\n 984: invokevirtual #156 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 987: checkcast #158 // class java/lang/Number\n 990: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 993: istore 5\n 995: aload 4\n 997: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1002: ifeq 1047\n 1005: aload 4\n 1007: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1012: checkcast #153 // class kotlin/Pair\n 1015: astore 6\n 1017: iconst_0\n 1018: istore 7\n 1020: aload 6\n 1022: invokevirtual #156 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 1025: checkcast #158 // class java/lang/Number\n 1028: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 1031: istore 6\n 1033: iload 5\n 1035: iload 6\n 1037: if_icmpge 995\n 1040: iload 6\n 1042: istore 5\n 1044: goto 995\n 1047: iload 5\n 1049: istore_2\n 1050: aload_1\n 1051: checkcast #27 // class java/lang/Iterable\n 1054: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1059: astore 5\n 1061: aload 5\n 1063: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1068: ifne 1079\n 1071: new #150 // class java/util/NoSuchElementException\n 1074: dup\n 1075: invokespecial #151 // Method java/util/NoSuchElementException.\"<init>\":()V\n 1078: athrow\n 1079: aload 5\n 1081: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1086: checkcast #153 // class kotlin/Pair\n 1089: astore 6\n 1091: iconst_0\n 1092: istore 7\n 1094: aload 6\n 1096: invokevirtual #164 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 1099: checkcast #158 // class java/lang/Number\n 1102: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 1105: istore 6\n 1107: aload 5\n 1109: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1114: ifeq 1159\n 1117: aload 5\n 1119: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1124: checkcast #153 // class kotlin/Pair\n 1127: astore 7\n 1129: iconst_0\n 1130: istore 8\n 1132: aload 7\n 1134: invokevirtual #164 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 1137: checkcast #158 // class java/lang/Number\n 1140: invokevirtual #161 // Method java/lang/Number.intValue:()I\n 1143: istore 7\n 1145: iload 6\n 1147: iload 7\n 1149: if_icmpge 1107\n 1152: iload 7\n 1154: istore 6\n 1156: goto 1107\n 1159: iload 6\n 1161: istore_3\n 1162: ldc #236 // String Puzzle 2:\n 1164: getstatic #205 // Field java/lang/System.out:Ljava/io/PrintStream;\n 1167: swap\n 1168: invokevirtual #211 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 1171: iconst_0\n 1172: istore 4\n 1174: iload 4\n 1176: iload_3\n 1177: if_icmpgt 1255\n 1180: iconst_0\n 1181: istore 5\n 1183: iload 5\n 1185: iload_2\n 1186: if_icmpgt 1237\n 1189: aload_1\n 1190: iload 5\n 1192: invokestatic #103 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1195: iload 4\n 1197: invokestatic #103 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1200: invokestatic #109 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 1203: invokeinterface #239, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 1208: ifeq 1216\n 1211: ldc #241 // String #\n 1213: goto 1218\n 1216: ldc #243 // String\n 1218: getstatic #205 // Field java/lang/System.out:Ljava/io/PrintStream;\n 1221: swap\n 1222: invokevirtual #246 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 1225: iload 5\n 1227: iload_2\n 1228: if_icmpeq 1237\n 1231: iinc 5, 1\n 1234: goto 1189\n 1237: getstatic #205 // Field java/lang/System.out:Ljava/io/PrintStream;\n 1240: invokevirtual #248 // Method java/io/PrintStream.println:()V\n 1243: iload 4\n 1245: iload_3\n 1246: if_icmpeq 1255\n 1249: iinc 4, 1\n 1252: goto 1180\n 1255: return\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day13Kt.class",
"javap": "Compiled from \"day13.kt\"\npublic final class Day13Kt {\n public static final void print_day_13();\n Code:\n 0: ldc #8 // String \\u001b[33m\n 2: astore_0\n 3: ldc #10 // String \\u001b[0m\n 5: astore_1\n 6: ldc #12 // String \\u001b[32m\n 8: astore_2\n 9: new #14 // class java/lang/StringBuilder\n 12: dup\n 13: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 16: aload_0\n 17: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: ldc #23 // String -\n 22: checkcast #25 // class java/lang/CharSequence\n 25: bipush 25\n 27: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 30: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 33: ldc #33 // String Advent of Code - Day 13\n 35: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 38: ldc #23 // String -\n 40: checkcast #25 // class java/lang/CharSequence\n 43: bipush 25\n 45: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 48: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: aload_1\n 52: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 55: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 58: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 61: swap\n 62: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 65: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: aload_2\n 69: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: invokestatic #55 // Method java/lang/Runtime.getRuntime:()Ljava/lang/Runtime;\n 75: ldc #57 // String figlet Transparent Origami -c -f small\n 77: invokevirtual #61 // Method java/lang/Runtime.exec:(Ljava/lang/String;)Ljava/lang/Process;\n 80: astore_3\n 81: new #63 // class java/io/BufferedReader\n 84: dup\n 85: new #65 // class java/io/InputStreamReader\n 88: dup\n 89: aload_3\n 90: invokevirtual #71 // Method java/lang/Process.getInputStream:()Ljava/io/InputStream;\n 93: invokespecial #74 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;)V\n 96: checkcast #76 // class java/io/Reader\n 99: invokespecial #79 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;)V\n 102: astore 4\n 104: aload 4\n 106: checkcast #76 // class java/io/Reader\n 109: invokedynamic #98, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 114: invokestatic #104 // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V\n 117: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 120: aload_1\n 121: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 124: new #14 // class java/lang/StringBuilder\n 127: dup\n 128: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 131: aload_0\n 132: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 135: ldc #23 // String -\n 137: checkcast #25 // class java/lang/CharSequence\n 140: bipush 33\n 142: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 145: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 148: ldc #106 // String Output\n 150: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 153: ldc #23 // String -\n 155: checkcast #25 // class java/lang/CharSequence\n 158: bipush 33\n 160: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 163: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 166: aload_1\n 167: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 170: bipush 10\n 172: invokevirtual #109 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 175: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 178: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 181: swap\n 182: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 185: return\n\n public static final void main();\n Code:\n 0: invokestatic #120 // Method print_day_13:()V\n 3: new #122 // class Day13\n 6: dup\n 7: invokespecial #123 // Method Day13.\"<init>\":()V\n 10: invokevirtual #126 // Method Day13.part_1:()V\n 13: new #122 // class Day13\n 16: dup\n 17: invokespecial #123 // Method Day13.\"<init>\":()V\n 20: invokevirtual #129 // Method Day13.part_2:()V\n 23: new #14 // class java/lang/StringBuilder\n 26: dup\n 27: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 30: ldc #131 // String \\n\\u001b[33m\n 32: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 35: ldc #133 // String =\n 37: checkcast #25 // class java/lang/CharSequence\n 40: bipush 72\n 42: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 45: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: ldc #135 // String \\u001b[0m\\n\n 50: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 53: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 56: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 59: swap\n 60: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 63: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #138 // Method main:()V\n 3: return\n\n private static final kotlin.Unit print_day_13$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #142 // String it\n 3: invokestatic #148 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: aload_0\n 10: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 13: getstatic #154 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 16: areturn\n}\n",
"javap_err": ""
}
] |
Ad0lphus__AOC2021__02f219e/day05/Kotlin/day05.kt
|
import java.io.*
import kotlin.math.abs
fun print_day_5() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 5" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Hydrothermal Venture -c -f small")
val reader = BufferedReader(InputStreamReader(process.inputStream))
reader.forEachLine { println(it) }
println(reset)
println(yellow + "-".repeat(33) + "Output" + "-".repeat(33) + reset + "\n")
}
fun main() {
print_day_5()
Day5().puzzle1()
Day5().puzzle2()
println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}
class Day5 {
data class Point(val x:Int, val y: Int)
private val lines = File("../Input/day5.txt").readLines()
private val points = lines.map { line ->
line.split(" -> ").map { point ->
val pairs = point.split(",")
Point(pairs[0].toInt(), pairs[1].toInt())
}
}
fun puzzle1() {
val map2d = Array(1000) { Array(1000) { 0 } }
points.forEach() {
if (it[0].x == it[1].x) {
val min = Math.min(it[0].y, it[1].y)
val max = Math.max(it[0].y, it[1].y)
for(i in min..max) {
map2d[i][it[0].x]++
}
}
else if (it[0].y == it[1].y) {
val min = Math.min(it[0].x, it[1].x)
val max = Math.max(it[0].x, it[1].x)
for(i in min..max) {
map2d[it[0].y][i]++
}
}
}
val overlaps = map2d.sumOf { it.count { point -> point >= 2 } }
println("Puzzle 1: " + overlaps)
}
fun puzzle2() {
val map2d = Array(1000) { Array(1000) { 0 } }
points.forEach() {
if (it[0].x == it[1].x) {
val min = Math.min(it[0].y, it[1].y)
val max = Math.max(it[0].y, it[1].y)
for(i in min..max) {
map2d[i][it[0].x]++
}
}
else if (it[0].y == it[1].y) {
val min = Math.min(it[0].x, it[1].x)
val max = Math.max(it[0].x, it[1].x)
for(i in min..max) {
map2d[it[0].y][i]++
}
}
else if ( isDiagonal(it[0], it[1]) ) {
val len = abs(it[0].x - it[1].x)
val xStep = if (it[1].x - it[0].x > 0) 1 else -1
val yStep = if (it[1].y - it[0].y > 0) 1 else -1
for(i in 0..len) {
val y = it[0].y + (i*yStep)
val x = it[0].x + (i*xStep)
map2d[y][x]++
}
}
}
val overlaps = map2d.sumOf { it.count { point -> point >= 2 } }
println("Puzzle 2: " + overlaps)
}
private fun isDiagonal(p1: Point, p2: Point): Boolean = abs(p1.x - p2.x) == abs(p1.y - p2.y)
}
|
[
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day05Kt.class",
"javap": "Compiled from \"day05.kt\"\npublic final class Day05Kt {\n public static final void print_day_5();\n Code:\n 0: ldc #8 // String \\u001b[33m\n 2: astore_0\n 3: ldc #10 // String \\u001b[0m\n 5: astore_1\n 6: ldc #12 // String \\u001b[32m\n 8: astore_2\n 9: new #14 // class java/lang/StringBuilder\n 12: dup\n 13: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 16: aload_0\n 17: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: ldc #23 // String -\n 22: checkcast #25 // class java/lang/CharSequence\n 25: bipush 25\n 27: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 30: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 33: ldc #33 // String Advent of Code - Day 5\n 35: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 38: ldc #23 // String -\n 40: checkcast #25 // class java/lang/CharSequence\n 43: bipush 25\n 45: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 48: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: aload_1\n 52: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 55: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 58: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 61: swap\n 62: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 65: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: aload_2\n 69: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: invokestatic #55 // Method java/lang/Runtime.getRuntime:()Ljava/lang/Runtime;\n 75: ldc #57 // String figlet Hydrothermal Venture -c -f small\n 77: invokevirtual #61 // Method java/lang/Runtime.exec:(Ljava/lang/String;)Ljava/lang/Process;\n 80: astore_3\n 81: new #63 // class java/io/BufferedReader\n 84: dup\n 85: new #65 // class java/io/InputStreamReader\n 88: dup\n 89: aload_3\n 90: invokevirtual #71 // Method java/lang/Process.getInputStream:()Ljava/io/InputStream;\n 93: invokespecial #74 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;)V\n 96: checkcast #76 // class java/io/Reader\n 99: invokespecial #79 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;)V\n 102: astore 4\n 104: aload 4\n 106: checkcast #76 // class java/io/Reader\n 109: invokedynamic #98, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 114: invokestatic #104 // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V\n 117: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 120: aload_1\n 121: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 124: new #14 // class java/lang/StringBuilder\n 127: dup\n 128: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 131: aload_0\n 132: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 135: ldc #23 // String -\n 137: checkcast #25 // class java/lang/CharSequence\n 140: bipush 33\n 142: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 145: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 148: ldc #106 // String Output\n 150: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 153: ldc #23 // String -\n 155: checkcast #25 // class java/lang/CharSequence\n 158: bipush 33\n 160: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 163: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 166: aload_1\n 167: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 170: bipush 10\n 172: invokevirtual #109 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 175: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 178: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 181: swap\n 182: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 185: return\n\n public static final void main();\n Code:\n 0: invokestatic #120 // Method print_day_5:()V\n 3: new #122 // class Day5\n 6: dup\n 7: invokespecial #123 // Method Day5.\"<init>\":()V\n 10: invokevirtual #126 // Method Day5.puzzle1:()V\n 13: new #122 // class Day5\n 16: dup\n 17: invokespecial #123 // Method Day5.\"<init>\":()V\n 20: invokevirtual #129 // Method Day5.puzzle2:()V\n 23: new #14 // class java/lang/StringBuilder\n 26: dup\n 27: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 30: ldc #131 // String \\n\\u001b[33m\n 32: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 35: ldc #133 // String =\n 37: checkcast #25 // class java/lang/CharSequence\n 40: bipush 72\n 42: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 45: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: ldc #135 // String \\u001b[0m\\n\n 50: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 53: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 56: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 59: swap\n 60: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 63: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #138 // Method main:()V\n 3: return\n\n private static final kotlin.Unit print_day_5$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #142 // String it\n 3: invokestatic #148 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: aload_0\n 10: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 13: getstatic #154 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 16: areturn\n}\n",
"javap_err": ""
}
] |
Ad0lphus__AOC2021__02f219e/day11/Kotlin/day11.kt
|
import java.io.*
fun print_day_11() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 11" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Dumbo Octopus -c -f small")
val reader = BufferedReader(InputStreamReader(process.inputStream))
reader.forEachLine { println(it) }
println(reset)
println(yellow + "-".repeat(33) + "Output" + "-".repeat(33) + reset + "\n")
}
fun main() {
print_day_11()
Day11().part_1()
Day11().part_2()
println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}
class Day11 {
private val octogrid = File("../Input/day11.txt").readLines().map { it.toCharArray().map { c -> c.digitToInt() }.toMutableList() }.toMutableList()
data class GridPoint(val x:Int, val y:Int) {
fun neighbours(xBoundary: Int, yBoundary: Int): List<GridPoint> =
(-1 .. 1).map { yOffset -> (-1 .. 1).map { xOffset -> GridPoint(x+xOffset, y+yOffset) } }.flatten()
.filter {
it.x in 0 until xBoundary && it.y in 0 until yBoundary && !(it.x == x && it.y == y)
}
}
fun part_1() {
var totalFlashes = 0
for(step in 1..100) {
val flashed = mutableListOf<GridPoint>()
for (y in octogrid.indices) {
for (x in octogrid[y].indices) {
octogrid[y][x]++
}
}
do {
val newFlashes = mutableListOf<GridPoint>()
for (y in octogrid.indices) {
for (x in octogrid[y].indices) {
val gp = GridPoint(x, y)
if (octogrid[y][x] > 9 && gp !in flashed) {
newFlashes.add(gp)
gp.neighbours(octogrid[y].size, octogrid.size).forEach {
octogrid[it.y][it.x]++
}
}
}
}
flashed.addAll(newFlashes)
} while(newFlashes.isNotEmpty())
totalFlashes += flashed.size
flashed.forEach { octogrid[it.y][it.x] = 0 }
}
println("Puzzle 1: " + totalFlashes)
}
fun part_2() {
val totalOctos = octogrid.flatten().size
var step = 0
do {
step++
val flashed = mutableListOf<GridPoint>()
for (y in octogrid.indices) {
for (x in octogrid[y].indices) {
octogrid[y][x]++
}
}
do {
val newFlashes = mutableListOf<GridPoint>()
for (y in octogrid.indices) {
for (x in octogrid[y].indices) {
val gp = GridPoint(x, y)
if (octogrid[y][x] > 9 && gp !in flashed) {
newFlashes.add(gp)
gp.neighbours(octogrid[y].size, octogrid.size).forEach {
octogrid[it.y][it.x]++
}
}
}
}
flashed.addAll(newFlashes)
} while(newFlashes.isNotEmpty())
flashed.forEach { octogrid[it.y][it.x] = 0 }
} while(flashed.size != totalOctos)
println("Puzzle 2: " + step)
}
}
|
[
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day11.class",
"javap": "Compiled from \"day11.kt\"\npublic final class Day11 {\n private final java.util.List<java.util.List<java.lang.Integer>> octogrid;\n\n public Day11();\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 java/io/File\n 8: dup\n 9: ldc #12 // String ../Input/day11.txt\n 11: invokespecial #15 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 14: aconst_null\n 15: iconst_1\n 16: aconst_null\n 17: invokestatic #21 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 20: checkcast #23 // class java/lang/Iterable\n 23: astore_1\n 24: astore 21\n 26: iconst_0\n 27: istore_2\n 28: aload_1\n 29: astore_3\n 30: new #25 // class java/util/ArrayList\n 33: dup\n 34: aload_1\n 35: bipush 10\n 37: invokestatic #31 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 40: invokespecial #34 // Method java/util/ArrayList.\"<init>\":(I)V\n 43: checkcast #36 // class java/util/Collection\n 46: astore 4\n 48: iconst_0\n 49: istore 5\n 51: aload_3\n 52: invokeinterface #40, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 57: astore 6\n 59: aload 6\n 61: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 66: ifeq 211\n 69: aload 6\n 71: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 76: astore 7\n 78: aload 4\n 80: aload 7\n 82: checkcast #52 // class java/lang/String\n 85: astore 8\n 87: astore 22\n 89: iconst_0\n 90: istore 9\n 92: aload 8\n 94: invokevirtual #56 // Method java/lang/String.toCharArray:()[C\n 97: dup\n 98: ldc #58 // String toCharArray(...)\n 100: invokestatic #64 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 103: astore 10\n 105: nop\n 106: iconst_0\n 107: istore 11\n 109: aload 10\n 111: astore 12\n 113: new #25 // class java/util/ArrayList\n 116: dup\n 117: aload 10\n 119: arraylength\n 120: invokespecial #34 // Method java/util/ArrayList.\"<init>\":(I)V\n 123: checkcast #36 // class java/util/Collection\n 126: astore 13\n 128: iconst_0\n 129: istore 14\n 131: iconst_0\n 132: istore 15\n 134: aload 12\n 136: arraylength\n 137: istore 16\n 139: iload 15\n 141: iload 16\n 143: if_icmpge 187\n 146: aload 12\n 148: iload 15\n 150: caload\n 151: istore 17\n 153: aload 13\n 155: iload 17\n 157: istore 18\n 159: astore 19\n 161: iconst_0\n 162: istore 20\n 164: iload 18\n 166: invokestatic #70 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 169: invokestatic #76 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 172: aload 19\n 174: swap\n 175: invokeinterface #80, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 180: pop\n 181: iinc 15, 1\n 184: goto 139\n 187: aload 13\n 189: checkcast #82 // class java/util/List\n 192: nop\n 193: checkcast #36 // class java/util/Collection\n 196: invokestatic #86 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 199: aload 22\n 201: swap\n 202: invokeinterface #80, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 207: pop\n 208: goto 59\n 211: aload 4\n 213: checkcast #82 // class java/util/List\n 216: nop\n 217: aload 21\n 219: swap\n 220: checkcast #36 // class java/util/Collection\n 223: invokestatic #86 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 226: putfield #90 // Field octogrid:Ljava/util/List;\n 229: return\n\n public final void part_1();\n Code:\n 0: iconst_0\n 1: istore_1\n 2: iconst_1\n 3: istore_2\n 4: iload_2\n 5: bipush 101\n 7: if_icmpge 564\n 10: new #25 // class java/util/ArrayList\n 13: dup\n 14: invokespecial #112 // Method java/util/ArrayList.\"<init>\":()V\n 17: checkcast #82 // class java/util/List\n 20: astore_3\n 21: iconst_0\n 22: istore 4\n 24: aload_0\n 25: getfield #90 // Field octogrid:Ljava/util/List;\n 28: checkcast #36 // class java/util/Collection\n 31: invokeinterface #116, 1 // InterfaceMethod java/util/Collection.size:()I\n 36: istore 5\n 38: iload 4\n 40: iload 5\n 42: if_icmpge 142\n 45: iconst_0\n 46: istore 6\n 48: aload_0\n 49: getfield #90 // Field octogrid:Ljava/util/List;\n 52: iload 4\n 54: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 59: checkcast #36 // class java/util/Collection\n 62: invokeinterface #116, 1 // InterfaceMethod java/util/Collection.size:()I\n 67: istore 7\n 69: iload 6\n 71: iload 7\n 73: if_icmpge 136\n 76: aload_0\n 77: getfield #90 // Field octogrid:Ljava/util/List;\n 80: iload 4\n 82: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 87: checkcast #82 // class java/util/List\n 90: astore 8\n 92: iload 6\n 94: istore 9\n 96: aload 8\n 98: iload 9\n 100: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 105: checkcast #122 // class java/lang/Number\n 108: invokevirtual #125 // Method java/lang/Number.intValue:()I\n 111: istore 10\n 113: aload 8\n 115: iload 9\n 117: iload 10\n 119: iconst_1\n 120: iadd\n 121: invokestatic #76 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 124: invokeinterface #129, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 129: pop\n 130: iinc 6, 1\n 133: goto 69\n 136: iinc 4, 1\n 139: goto 38\n 142: new #25 // class java/util/ArrayList\n 145: dup\n 146: invokespecial #112 // Method java/util/ArrayList.\"<init>\":()V\n 149: checkcast #82 // class java/util/List\n 152: astore 4\n 154: iconst_0\n 155: istore 5\n 157: aload_0\n 158: getfield #90 // Field octogrid:Ljava/util/List;\n 161: checkcast #36 // class java/util/Collection\n 164: invokeinterface #116, 1 // InterfaceMethod java/util/Collection.size:()I\n 169: istore 6\n 171: iload 5\n 173: iload 6\n 175: if_icmpge 432\n 178: iconst_0\n 179: istore 7\n 181: aload_0\n 182: getfield #90 // Field octogrid:Ljava/util/List;\n 185: iload 5\n 187: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 192: checkcast #36 // class java/util/Collection\n 195: invokeinterface #116, 1 // InterfaceMethod java/util/Collection.size:()I\n 200: istore 8\n 202: iload 7\n 204: iload 8\n 206: if_icmpge 426\n 209: new #131 // class Day11$GridPoint\n 212: dup\n 213: iload 7\n 215: iload 5\n 217: invokespecial #134 // Method Day11$GridPoint.\"<init>\":(II)V\n 220: astore 9\n 222: aload_0\n 223: getfield #90 // Field octogrid:Ljava/util/List;\n 226: iload 5\n 228: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 233: checkcast #82 // class java/util/List\n 236: iload 7\n 238: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 243: checkcast #122 // class java/lang/Number\n 246: invokevirtual #125 // Method java/lang/Number.intValue:()I\n 249: bipush 9\n 251: if_icmple 420\n 254: aload_3\n 255: aload 9\n 257: invokeinterface #137, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 262: ifne 420\n 265: aload 4\n 267: aload 9\n 269: invokeinterface #138, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 274: pop\n 275: aload 9\n 277: aload_0\n 278: getfield #90 // Field octogrid:Ljava/util/List;\n 281: iload 5\n 283: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 288: checkcast #82 // class java/util/List\n 291: invokeinterface #139, 1 // InterfaceMethod java/util/List.size:()I\n 296: aload_0\n 297: getfield #90 // Field octogrid:Ljava/util/List;\n 300: invokeinterface #139, 1 // InterfaceMethod java/util/List.size:()I\n 305: invokevirtual #143 // Method Day11$GridPoint.neighbours:(II)Ljava/util/List;\n 308: checkcast #23 // class java/lang/Iterable\n 311: astore 10\n 313: iconst_0\n 314: istore 11\n 316: aload 10\n 318: invokeinterface #40, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 323: astore 12\n 325: aload 12\n 327: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 332: ifeq 419\n 335: aload 12\n 337: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 342: astore 13\n 344: aload 13\n 346: checkcast #131 // class Day11$GridPoint\n 349: astore 14\n 351: iconst_0\n 352: istore 15\n 354: aload_0\n 355: getfield #90 // Field octogrid:Ljava/util/List;\n 358: aload 14\n 360: invokevirtual #146 // Method Day11$GridPoint.getY:()I\n 363: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 368: checkcast #82 // class java/util/List\n 371: astore 16\n 373: aload 14\n 375: invokevirtual #149 // Method Day11$GridPoint.getX:()I\n 378: istore 17\n 380: aload 16\n 382: iload 17\n 384: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 389: checkcast #122 // class java/lang/Number\n 392: invokevirtual #125 // Method java/lang/Number.intValue:()I\n 395: istore 18\n 397: aload 16\n 399: iload 17\n 401: iload 18\n 403: iconst_1\n 404: iadd\n 405: invokestatic #76 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 408: invokeinterface #129, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 413: pop\n 414: nop\n 415: nop\n 416: goto 325\n 419: nop\n 420: iinc 7, 1\n 423: goto 202\n 426: iinc 5, 1\n 429: goto 171\n 432: aload_3\n 433: aload 4\n 435: checkcast #36 // class java/util/Collection\n 438: invokeinterface #153, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 443: pop\n 444: aload 4\n 446: checkcast #36 // class java/util/Collection\n 449: invokeinterface #156, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 454: ifne 461\n 457: iconst_1\n 458: goto 462\n 461: iconst_0\n 462: ifne 142\n 465: iload_1\n 466: aload_3\n 467: invokeinterface #139, 1 // InterfaceMethod java/util/List.size:()I\n 472: iadd\n 473: istore_1\n 474: aload_3\n 475: checkcast #23 // class java/lang/Iterable\n 478: astore 4\n 480: iconst_0\n 481: istore 5\n 483: aload 4\n 485: invokeinterface #40, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 490: astore 6\n 492: aload 6\n 494: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 499: ifeq 557\n 502: aload 6\n 504: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 509: astore 7\n 511: aload 7\n 513: checkcast #131 // class Day11$GridPoint\n 516: astore 8\n 518: iconst_0\n 519: istore 9\n 521: aload_0\n 522: getfield #90 // Field octogrid:Ljava/util/List;\n 525: aload 8\n 527: invokevirtual #146 // Method Day11$GridPoint.getY:()I\n 530: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 535: checkcast #82 // class java/util/List\n 538: aload 8\n 540: invokevirtual #149 // Method Day11$GridPoint.getX:()I\n 543: iconst_0\n 544: invokestatic #76 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 547: invokeinterface #129, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 552: pop\n 553: nop\n 554: goto 492\n 557: nop\n 558: iinc 2, 1\n 561: goto 4\n 564: new #158 // class java/lang/StringBuilder\n 567: dup\n 568: invokespecial #159 // Method java/lang/StringBuilder.\"<init>\":()V\n 571: ldc #161 // String Puzzle 1:\n 573: invokevirtual #165 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 576: iload_1\n 577: invokevirtual #168 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 580: invokevirtual #172 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 583: getstatic #178 // Field java/lang/System.out:Ljava/io/PrintStream;\n 586: swap\n 587: invokevirtual #184 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 590: return\n\n public final void part_2();\n Code:\n 0: aload_0\n 1: getfield #90 // Field octogrid:Ljava/util/List;\n 4: checkcast #23 // class java/lang/Iterable\n 7: invokestatic #202 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 10: invokeinterface #139, 1 // InterfaceMethod java/util/List.size:()I\n 15: istore_1\n 16: iconst_0\n 17: istore_2\n 18: iinc 2, 1\n 21: new #25 // class java/util/ArrayList\n 24: dup\n 25: invokespecial #112 // Method java/util/ArrayList.\"<init>\":()V\n 28: checkcast #82 // class java/util/List\n 31: astore_3\n 32: iconst_0\n 33: istore 4\n 35: aload_0\n 36: getfield #90 // Field octogrid:Ljava/util/List;\n 39: checkcast #36 // class java/util/Collection\n 42: invokeinterface #116, 1 // InterfaceMethod java/util/Collection.size:()I\n 47: istore 5\n 49: iload 4\n 51: iload 5\n 53: if_icmpge 153\n 56: iconst_0\n 57: istore 6\n 59: aload_0\n 60: getfield #90 // Field octogrid:Ljava/util/List;\n 63: iload 4\n 65: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 70: checkcast #36 // class java/util/Collection\n 73: invokeinterface #116, 1 // InterfaceMethod java/util/Collection.size:()I\n 78: istore 7\n 80: iload 6\n 82: iload 7\n 84: if_icmpge 147\n 87: aload_0\n 88: getfield #90 // Field octogrid:Ljava/util/List;\n 91: iload 4\n 93: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 98: checkcast #82 // class java/util/List\n 101: astore 8\n 103: iload 6\n 105: istore 9\n 107: aload 8\n 109: iload 9\n 111: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 116: checkcast #122 // class java/lang/Number\n 119: invokevirtual #125 // Method java/lang/Number.intValue:()I\n 122: istore 10\n 124: aload 8\n 126: iload 9\n 128: iload 10\n 130: iconst_1\n 131: iadd\n 132: invokestatic #76 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 135: invokeinterface #129, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 140: pop\n 141: iinc 6, 1\n 144: goto 80\n 147: iinc 4, 1\n 150: goto 49\n 153: new #25 // class java/util/ArrayList\n 156: dup\n 157: invokespecial #112 // Method java/util/ArrayList.\"<init>\":()V\n 160: checkcast #82 // class java/util/List\n 163: astore 4\n 165: iconst_0\n 166: istore 5\n 168: aload_0\n 169: getfield #90 // Field octogrid:Ljava/util/List;\n 172: checkcast #36 // class java/util/Collection\n 175: invokeinterface #116, 1 // InterfaceMethod java/util/Collection.size:()I\n 180: istore 6\n 182: iload 5\n 184: iload 6\n 186: if_icmpge 443\n 189: iconst_0\n 190: istore 7\n 192: aload_0\n 193: getfield #90 // Field octogrid:Ljava/util/List;\n 196: iload 5\n 198: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 203: checkcast #36 // class java/util/Collection\n 206: invokeinterface #116, 1 // InterfaceMethod java/util/Collection.size:()I\n 211: istore 8\n 213: iload 7\n 215: iload 8\n 217: if_icmpge 437\n 220: new #131 // class Day11$GridPoint\n 223: dup\n 224: iload 7\n 226: iload 5\n 228: invokespecial #134 // Method Day11$GridPoint.\"<init>\":(II)V\n 231: astore 9\n 233: aload_0\n 234: getfield #90 // Field octogrid:Ljava/util/List;\n 237: iload 5\n 239: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 244: checkcast #82 // class java/util/List\n 247: iload 7\n 249: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 254: checkcast #122 // class java/lang/Number\n 257: invokevirtual #125 // Method java/lang/Number.intValue:()I\n 260: bipush 9\n 262: if_icmple 431\n 265: aload_3\n 266: aload 9\n 268: invokeinterface #137, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 273: ifne 431\n 276: aload 4\n 278: aload 9\n 280: invokeinterface #138, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 285: pop\n 286: aload 9\n 288: aload_0\n 289: getfield #90 // Field octogrid:Ljava/util/List;\n 292: iload 5\n 294: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 299: checkcast #82 // class java/util/List\n 302: invokeinterface #139, 1 // InterfaceMethod java/util/List.size:()I\n 307: aload_0\n 308: getfield #90 // Field octogrid:Ljava/util/List;\n 311: invokeinterface #139, 1 // InterfaceMethod java/util/List.size:()I\n 316: invokevirtual #143 // Method Day11$GridPoint.neighbours:(II)Ljava/util/List;\n 319: checkcast #23 // class java/lang/Iterable\n 322: astore 10\n 324: iconst_0\n 325: istore 11\n 327: aload 10\n 329: invokeinterface #40, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 334: astore 12\n 336: aload 12\n 338: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 343: ifeq 430\n 346: aload 12\n 348: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 353: astore 13\n 355: aload 13\n 357: checkcast #131 // class Day11$GridPoint\n 360: astore 14\n 362: iconst_0\n 363: istore 15\n 365: aload_0\n 366: getfield #90 // Field octogrid:Ljava/util/List;\n 369: aload 14\n 371: invokevirtual #146 // Method Day11$GridPoint.getY:()I\n 374: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 379: checkcast #82 // class java/util/List\n 382: astore 16\n 384: aload 14\n 386: invokevirtual #149 // Method Day11$GridPoint.getX:()I\n 389: istore 17\n 391: aload 16\n 393: iload 17\n 395: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 400: checkcast #122 // class java/lang/Number\n 403: invokevirtual #125 // Method java/lang/Number.intValue:()I\n 406: istore 18\n 408: aload 16\n 410: iload 17\n 412: iload 18\n 414: iconst_1\n 415: iadd\n 416: invokestatic #76 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 419: invokeinterface #129, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 424: pop\n 425: nop\n 426: nop\n 427: goto 336\n 430: nop\n 431: iinc 7, 1\n 434: goto 213\n 437: iinc 5, 1\n 440: goto 182\n 443: aload_3\n 444: aload 4\n 446: checkcast #36 // class java/util/Collection\n 449: invokeinterface #153, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 454: pop\n 455: aload 4\n 457: checkcast #36 // class java/util/Collection\n 460: invokeinterface #156, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 465: ifne 472\n 468: iconst_1\n 469: goto 473\n 472: iconst_0\n 473: ifne 153\n 476: aload_3\n 477: checkcast #23 // class java/lang/Iterable\n 480: astore 4\n 482: iconst_0\n 483: istore 5\n 485: aload 4\n 487: invokeinterface #40, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 492: astore 6\n 494: aload 6\n 496: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 501: ifeq 559\n 504: aload 6\n 506: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 511: astore 7\n 513: aload 7\n 515: checkcast #131 // class Day11$GridPoint\n 518: astore 8\n 520: iconst_0\n 521: istore 9\n 523: aload_0\n 524: getfield #90 // Field octogrid:Ljava/util/List;\n 527: aload 8\n 529: invokevirtual #146 // Method Day11$GridPoint.getY:()I\n 532: invokeinterface #120, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 537: checkcast #82 // class java/util/List\n 540: aload 8\n 542: invokevirtual #149 // Method Day11$GridPoint.getX:()I\n 545: iconst_0\n 546: invokestatic #76 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 549: invokeinterface #129, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 554: pop\n 555: nop\n 556: goto 494\n 559: nop\n 560: aload_3\n 561: invokeinterface #139, 1 // InterfaceMethod java/util/List.size:()I\n 566: iload_1\n 567: if_icmpne 18\n 570: new #158 // class java/lang/StringBuilder\n 573: dup\n 574: invokespecial #159 // Method java/lang/StringBuilder.\"<init>\":()V\n 577: ldc #204 // String Puzzle 2:\n 579: invokevirtual #165 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 582: iload_2\n 583: invokevirtual #168 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 586: invokevirtual #172 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 589: getstatic #178 // Field java/lang/System.out:Ljava/io/PrintStream;\n 592: swap\n 593: invokevirtual #184 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 596: return\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day11$GridPoint.class",
"javap": "Compiled from \"day11.kt\"\npublic final class Day11$GridPoint {\n private final int x;\n\n private final int y;\n\n public Day11$GridPoint(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 java.util.List<Day11$GridPoint> neighbours(int, int);\n Code:\n 0: new #27 // class kotlin/ranges/IntRange\n 3: dup\n 4: iconst_m1\n 5: iconst_1\n 6: invokespecial #29 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 9: checkcast #31 // class java/lang/Iterable\n 12: astore_3\n 13: iconst_0\n 14: istore 4\n 16: aload_3\n 17: astore 5\n 19: new #33 // class java/util/ArrayList\n 22: dup\n 23: aload_3\n 24: bipush 10\n 26: invokestatic #39 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 29: invokespecial #42 // Method java/util/ArrayList.\"<init>\":(I)V\n 32: checkcast #44 // class java/util/Collection\n 35: astore 6\n 37: iconst_0\n 38: istore 7\n 40: aload 5\n 42: invokeinterface #48, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 47: astore 8\n 49: aload 8\n 51: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 56: ifeq 215\n 59: aload 8\n 61: checkcast #56 // class kotlin/collections/IntIterator\n 64: invokevirtual #59 // Method kotlin/collections/IntIterator.nextInt:()I\n 67: istore 9\n 69: aload 6\n 71: iload 9\n 73: istore 10\n 75: astore 22\n 77: iconst_0\n 78: istore 11\n 80: new #27 // class kotlin/ranges/IntRange\n 83: dup\n 84: iconst_m1\n 85: iconst_1\n 86: invokespecial #29 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 89: checkcast #31 // class java/lang/Iterable\n 92: astore 12\n 94: iconst_0\n 95: istore 13\n 97: aload 12\n 99: astore 14\n 101: new #33 // class java/util/ArrayList\n 104: dup\n 105: aload 12\n 107: bipush 10\n 109: invokestatic #39 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 112: invokespecial #42 // Method java/util/ArrayList.\"<init>\":(I)V\n 115: checkcast #44 // class java/util/Collection\n 118: astore 15\n 120: iconst_0\n 121: istore 16\n 123: aload 14\n 125: invokeinterface #48, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 130: astore 17\n 132: aload 17\n 134: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 139: ifeq 196\n 142: aload 17\n 144: checkcast #56 // class kotlin/collections/IntIterator\n 147: invokevirtual #59 // Method kotlin/collections/IntIterator.nextInt:()I\n 150: istore 18\n 152: aload 15\n 154: iload 18\n 156: istore 19\n 158: astore 20\n 160: iconst_0\n 161: istore 21\n 163: new #2 // class Day11$GridPoint\n 166: dup\n 167: aload_0\n 168: getfield #13 // Field x:I\n 171: iload 19\n 173: iadd\n 174: aload_0\n 175: getfield #16 // Field y:I\n 178: iload 10\n 180: iadd\n 181: invokespecial #60 // Method \"<init>\":(II)V\n 184: aload 20\n 186: swap\n 187: invokeinterface #64, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 192: pop\n 193: goto 132\n 196: aload 15\n 198: checkcast #66 // class java/util/List\n 201: nop\n 202: nop\n 203: aload 22\n 205: swap\n 206: invokeinterface #64, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 211: pop\n 212: goto 49\n 215: aload 6\n 217: checkcast #66 // class java/util/List\n 220: nop\n 221: checkcast #31 // class java/lang/Iterable\n 224: invokestatic #70 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 227: checkcast #31 // class java/lang/Iterable\n 230: astore_3\n 231: nop\n 232: iconst_0\n 233: istore 4\n 235: aload_3\n 236: astore 5\n 238: new #33 // class java/util/ArrayList\n 241: dup\n 242: invokespecial #71 // Method java/util/ArrayList.\"<init>\":()V\n 245: checkcast #44 // class java/util/Collection\n 248: astore 6\n 250: iconst_0\n 251: istore 7\n 253: aload 5\n 255: invokeinterface #48, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 260: astore 8\n 262: aload 8\n 264: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 269: ifeq 398\n 272: aload 8\n 274: invokeinterface #75, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 279: astore 9\n 281: aload 9\n 283: checkcast #2 // class Day11$GridPoint\n 286: astore 10\n 288: iconst_0\n 289: istore 11\n 291: aload 10\n 293: getfield #13 // Field x:I\n 296: istore 12\n 298: iconst_0\n 299: iload 12\n 301: if_icmpgt 318\n 304: iload 12\n 306: iload_1\n 307: if_icmpge 314\n 310: iconst_1\n 311: goto 319\n 314: iconst_0\n 315: goto 319\n 318: iconst_0\n 319: ifeq 381\n 322: aload 10\n 324: getfield #16 // Field y:I\n 327: istore 12\n 329: iconst_0\n 330: iload 12\n 332: if_icmpgt 349\n 335: iload 12\n 337: iload_2\n 338: if_icmpge 345\n 341: iconst_1\n 342: goto 350\n 345: iconst_0\n 346: goto 350\n 349: iconst_0\n 350: ifeq 381\n 353: aload 10\n 355: getfield #13 // Field x:I\n 358: aload_0\n 359: getfield #13 // Field x:I\n 362: if_icmpne 377\n 365: aload 10\n 367: getfield #16 // Field y:I\n 370: aload_0\n 371: getfield #16 // Field y:I\n 374: if_icmpeq 381\n 377: iconst_1\n 378: goto 382\n 381: iconst_0\n 382: ifeq 262\n 385: aload 6\n 387: aload 9\n 389: invokeinterface #64, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 394: pop\n 395: goto 262\n 398: aload 6\n 400: checkcast #66 // class java/util/List\n 403: nop\n 404: areturn\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 Day11$GridPoint copy(int, int);\n Code:\n 0: new #2 // class Day11$GridPoint\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: invokespecial #60 // Method \"<init>\":(II)V\n 9: areturn\n\n public static Day11$GridPoint copy$default(Day11$GridPoint, 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 #105 // Method copy:(II)LDay11$GridPoint;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #109 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #110 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #112 // String GridPoint(x=\n 9: invokevirtual #116 // 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 #119 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #121 // String , y=\n 21: invokevirtual #116 // 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 #119 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #124 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #126 // 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 #132 // 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 #132 // 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 Day11$GridPoint\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day11$GridPoint\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": "Ad0lphus__AOC2021__02f219e/Day11Kt.class",
"javap": "Compiled from \"day11.kt\"\npublic final class Day11Kt {\n public static final void print_day_11();\n Code:\n 0: ldc #8 // String \\u001b[33m\n 2: astore_0\n 3: ldc #10 // String \\u001b[0m\n 5: astore_1\n 6: ldc #12 // String \\u001b[32m\n 8: astore_2\n 9: new #14 // class java/lang/StringBuilder\n 12: dup\n 13: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 16: aload_0\n 17: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: ldc #23 // String -\n 22: checkcast #25 // class java/lang/CharSequence\n 25: bipush 25\n 27: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 30: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 33: ldc #33 // String Advent of Code - Day 11\n 35: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 38: ldc #23 // String -\n 40: checkcast #25 // class java/lang/CharSequence\n 43: bipush 25\n 45: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 48: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: aload_1\n 52: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 55: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 58: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 61: swap\n 62: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 65: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: aload_2\n 69: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: invokestatic #55 // Method java/lang/Runtime.getRuntime:()Ljava/lang/Runtime;\n 75: ldc #57 // String figlet Dumbo Octopus -c -f small\n 77: invokevirtual #61 // Method java/lang/Runtime.exec:(Ljava/lang/String;)Ljava/lang/Process;\n 80: astore_3\n 81: new #63 // class java/io/BufferedReader\n 84: dup\n 85: new #65 // class java/io/InputStreamReader\n 88: dup\n 89: aload_3\n 90: invokevirtual #71 // Method java/lang/Process.getInputStream:()Ljava/io/InputStream;\n 93: invokespecial #74 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;)V\n 96: checkcast #76 // class java/io/Reader\n 99: invokespecial #79 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;)V\n 102: astore 4\n 104: aload 4\n 106: checkcast #76 // class java/io/Reader\n 109: invokedynamic #98, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 114: invokestatic #104 // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V\n 117: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 120: aload_1\n 121: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 124: new #14 // class java/lang/StringBuilder\n 127: dup\n 128: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 131: aload_0\n 132: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 135: ldc #23 // String -\n 137: checkcast #25 // class java/lang/CharSequence\n 140: bipush 33\n 142: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 145: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 148: ldc #106 // String Output\n 150: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 153: ldc #23 // String -\n 155: checkcast #25 // class java/lang/CharSequence\n 158: bipush 33\n 160: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 163: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 166: aload_1\n 167: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 170: bipush 10\n 172: invokevirtual #109 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 175: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 178: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 181: swap\n 182: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 185: return\n\n public static final void main();\n Code:\n 0: invokestatic #120 // Method print_day_11:()V\n 3: new #122 // class Day11\n 6: dup\n 7: invokespecial #123 // Method Day11.\"<init>\":()V\n 10: invokevirtual #126 // Method Day11.part_1:()V\n 13: new #122 // class Day11\n 16: dup\n 17: invokespecial #123 // Method Day11.\"<init>\":()V\n 20: invokevirtual #129 // Method Day11.part_2:()V\n 23: new #14 // class java/lang/StringBuilder\n 26: dup\n 27: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 30: ldc #131 // String \\n\\u001b[33m\n 32: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 35: ldc #133 // String =\n 37: checkcast #25 // class java/lang/CharSequence\n 40: bipush 72\n 42: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 45: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: ldc #135 // String \\u001b[0m\\n\n 50: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 53: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 56: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 59: swap\n 60: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 63: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #138 // Method main:()V\n 3: return\n\n private static final kotlin.Unit print_day_11$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #142 // String it\n 3: invokestatic #148 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: aload_0\n 10: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 13: getstatic #154 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 16: areturn\n}\n",
"javap_err": ""
}
] |
Ad0lphus__AOC2021__02f219e/day12/Kotlin/day12.kt
|
import java.io.*
fun print_day_12() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 12" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Passage Pathing -c -f small")
val reader = BufferedReader(InputStreamReader(process.inputStream))
reader.forEachLine { println(it) }
println(reset)
println(yellow + "-".repeat(33) + "Output" + "-".repeat(33) + reset + "\n")
}
fun main() {
print_day_12()
Day12().part_1()
Day12().part_2()
println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}
class Day12 {
data class Node(val name: String, val isLarge: Boolean = false, var connections: List<Node> = mutableListOf())
fun part_1() {
val nodes = mutableMapOf<String, Node>()
fun followPaths(node: Node, path: List<Node>): List<List<Node>> {
val newPath = path+node
return if (node.name == "end" || (path.contains(node) && !node.isLarge)) {
listOf(newPath)
} else {
node.connections.flatMap {
followPaths(it, newPath)
}
}
}
File("../Input/day12.txt").readLines().forEach {
val pathway = it.split("-").map { node ->
if (!nodes.containsKey(node)) {
nodes[node] = Node(node, node.isUpperCase())
}
nodes[node]!!
}
pathway[0].connections += pathway[1]
pathway[1].connections += pathway[0]
}
val start = nodes["start"]!!
val paths = followPaths(start, listOf()).filter { it.last().name == "end" } // only keep nodes that actually end
println("Puzzle 1: ${paths.size}")
}
fun part_2() {
val nodes = HashMap<String, HashSet<String>>()
File("../Input/day12.txt").readLines().forEach {
val (a,b) = it.split("-")
nodes.getOrPut(a) { HashSet() }.add(b)
nodes.getOrPut(b) { HashSet() }.add(a)
}
fun canVisit(name: String, path: List<String>): Boolean =
when {
name.isUpperCase() -> true
name == "start" -> false
name !in path -> true
else -> path.filterNot { it.isUpperCase() }.groupBy { it }.none { it.value.size == 2 }
}
fun followPaths(path: List<String> = listOf("start")): List<List<String>> =
if (path.last() == "end") listOf(path)
else nodes.getValue(path.last())
.filter { canVisit(it, path) }
.flatMap { followPaths( path + it) }
println("Puzzle 2: ${followPaths().size}")
}
}
private fun String.isUpperCase(): Boolean = this == this.uppercase()
|
[
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day12$Node.class",
"javap": "Compiled from \"day12.kt\"\npublic final class Day12$Node {\n private final java.lang.String name;\n\n private final boolean isLarge;\n\n private java.util.List<Day12$Node> connections;\n\n public Day12$Node(java.lang.String, boolean, java.util.List<Day12$Node>);\n Code:\n 0: aload_1\n 1: ldc #10 // String name\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_3\n 7: ldc #18 // String connections\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokespecial #21 // Method java/lang/Object.\"<init>\":()V\n 16: aload_0\n 17: aload_1\n 18: putfield #24 // Field name:Ljava/lang/String;\n 21: aload_0\n 22: iload_2\n 23: putfield #28 // Field isLarge:Z\n 26: aload_0\n 27: aload_3\n 28: putfield #31 // Field connections:Ljava/util/List;\n 31: return\n\n public Day12$Node(java.lang.String, boolean, java.util.List, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload 4\n 2: iconst_2\n 3: iand\n 4: ifeq 9\n 7: iconst_0\n 8: istore_2\n 9: iload 4\n 11: iconst_4\n 12: iand\n 13: ifeq 27\n 16: new #36 // class java/util/ArrayList\n 19: dup\n 20: invokespecial #37 // Method java/util/ArrayList.\"<init>\":()V\n 23: checkcast #39 // class java/util/List\n 26: astore_3\n 27: aload_0\n 28: aload_1\n 29: iload_2\n 30: aload_3\n 31: invokespecial #41 // Method \"<init>\":(Ljava/lang/String;ZLjava/util/List;)V\n 34: return\n\n public final java.lang.String getName();\n Code:\n 0: aload_0\n 1: getfield #24 // Field name:Ljava/lang/String;\n 4: areturn\n\n public final boolean isLarge();\n Code:\n 0: aload_0\n 1: getfield #28 // Field isLarge:Z\n 4: ireturn\n\n public final java.util.List<Day12$Node> getConnections();\n Code:\n 0: aload_0\n 1: getfield #31 // Field connections:Ljava/util/List;\n 4: areturn\n\n public final void setConnections(java.util.List<Day12$Node>);\n Code:\n 0: aload_1\n 1: ldc #52 // String <set-?>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: putfield #31 // Field connections:Ljava/util/List;\n 11: return\n\n public final java.lang.String component1();\n Code:\n 0: aload_0\n 1: getfield #24 // Field name:Ljava/lang/String;\n 4: areturn\n\n public final boolean component2();\n Code:\n 0: aload_0\n 1: getfield #28 // Field isLarge:Z\n 4: ireturn\n\n public final java.util.List<Day12$Node> component3();\n Code:\n 0: aload_0\n 1: getfield #31 // Field connections:Ljava/util/List;\n 4: areturn\n\n public final Day12$Node copy(java.lang.String, boolean, java.util.List<Day12$Node>);\n Code:\n 0: aload_1\n 1: ldc #10 // String name\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_3\n 7: ldc #18 // String connections\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class Day12$Node\n 15: dup\n 16: aload_1\n 17: iload_2\n 18: aload_3\n 19: invokespecial #41 // Method \"<init>\":(Ljava/lang/String;ZLjava/util/List;)V\n 22: areturn\n\n public static Day12$Node copy$default(Day12$Node, java.lang.String, boolean, java.util.List, int, java.lang.Object);\n Code:\n 0: iload 4\n 2: iconst_1\n 3: iand\n 4: ifeq 12\n 7: aload_0\n 8: getfield #24 // Field name:Ljava/lang/String;\n 11: astore_1\n 12: iload 4\n 14: iconst_2\n 15: iand\n 16: ifeq 24\n 19: aload_0\n 20: getfield #28 // Field isLarge:Z\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 connections:Ljava/util/List;\n 35: astore_3\n 36: aload_0\n 37: aload_1\n 38: iload_2\n 39: aload_3\n 40: invokevirtual #62 // Method copy:(Ljava/lang/String;ZLjava/util/List;)LDay12$Node;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #65 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #66 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #68 // String Node(name=\n 9: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #24 // Field name:Ljava/lang/String;\n 16: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 19: ldc #74 // String , isLarge=\n 21: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #28 // Field isLarge:Z\n 28: invokevirtual #77 // Method java/lang/StringBuilder.append:(Z)Ljava/lang/StringBuilder;\n 31: ldc #79 // String , connections=\n 33: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #31 // Field connections:Ljava/util/List;\n 40: invokevirtual #82 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #85 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #87 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 51: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #24 // Field name:Ljava/lang/String;\n 4: invokevirtual #93 // Method java/lang/String.hashCode:()I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #28 // Field isLarge:Z\n 16: invokestatic #98 // Method java/lang/Boolean.hashCode:(Z)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 connections:Ljava/util/List;\n 29: invokevirtual #99 // 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 Day12$Node\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day12$Node\n 20: astore_2\n 21: aload_0\n 22: getfield #24 // Field name:Ljava/lang/String;\n 25: aload_2\n 26: getfield #24 // Field name:Ljava/lang/String;\n 29: invokestatic #108 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 32: ifne 37\n 35: iconst_0\n 36: ireturn\n 37: aload_0\n 38: getfield #28 // Field isLarge:Z\n 41: aload_2\n 42: getfield #28 // Field isLarge:Z\n 45: if_icmpeq 50\n 48: iconst_0\n 49: ireturn\n 50: aload_0\n 51: getfield #31 // Field connections:Ljava/util/List;\n 54: aload_2\n 55: getfield #31 // Field connections:Ljava/util/List;\n 58: invokestatic #108 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 61: ifne 66\n 64: iconst_0\n 65: ireturn\n 66: iconst_1\n 67: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day12.class",
"javap": "Compiled from \"day12.kt\"\npublic final class Day12 {\n public Day12();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final void part_1();\n Code:\n 0: new #13 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #14 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #16 // class java/util/Map\n 10: astore_1\n 11: new #18 // class java/io/File\n 14: dup\n 15: ldc #20 // String ../Input/day12.txt\n 17: invokespecial #23 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 20: aconst_null\n 21: iconst_1\n 22: aconst_null\n 23: invokestatic #29 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 26: checkcast #31 // class java/lang/Iterable\n 29: astore_2\n 30: iconst_0\n 31: istore_3\n 32: aload_2\n 33: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 4\n 40: aload 4\n 42: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 323\n 50: aload 4\n 52: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 5\n 59: aload 5\n 61: checkcast #47 // class java/lang/String\n 64: astore 6\n 66: iconst_0\n 67: istore 7\n 69: aload 6\n 71: checkcast #49 // class java/lang/CharSequence\n 74: iconst_1\n 75: anewarray #47 // class java/lang/String\n 78: astore 8\n 80: aload 8\n 82: iconst_0\n 83: ldc #51 // String -\n 85: aastore\n 86: aload 8\n 88: iconst_0\n 89: iconst_0\n 90: bipush 6\n 92: aconst_null\n 93: invokestatic #57 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 96: checkcast #31 // class java/lang/Iterable\n 99: astore 8\n 101: iconst_0\n 102: istore 9\n 104: aload 8\n 106: astore 10\n 108: new #59 // class java/util/ArrayList\n 111: dup\n 112: aload 8\n 114: bipush 10\n 116: invokestatic #65 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 119: invokespecial #68 // Method java/util/ArrayList.\"<init>\":(I)V\n 122: checkcast #70 // class java/util/Collection\n 125: astore 11\n 127: iconst_0\n 128: istore 12\n 130: aload 10\n 132: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 137: astore 13\n 139: aload 13\n 141: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 146: ifeq 236\n 149: aload 13\n 151: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 156: astore 14\n 158: aload 11\n 160: aload 14\n 162: checkcast #47 // class java/lang/String\n 165: astore 15\n 167: astore 16\n 169: iconst_0\n 170: istore 17\n 172: aload_1\n 173: aload 15\n 175: invokeinterface #74, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 180: ifne 209\n 183: aload_1\n 184: aload 15\n 186: new #76 // class Day12$Node\n 189: dup\n 190: aload 15\n 192: aload 15\n 194: invokestatic #82 // Method Day12Kt.access$isUpperCase:(Ljava/lang/String;)Z\n 197: aconst_null\n 198: iconst_4\n 199: aconst_null\n 200: invokespecial #85 // Method Day12$Node.\"<init>\":(Ljava/lang/String;ZLjava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 203: invokeinterface #89, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 208: pop\n 209: aload_1\n 210: aload 15\n 212: invokeinterface #93, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 217: dup\n 218: invokestatic #99 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 221: checkcast #76 // class Day12$Node\n 224: aload 16\n 226: swap\n 227: invokeinterface #102, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 232: pop\n 233: goto 139\n 236: aload 11\n 238: checkcast #104 // class java/util/List\n 241: nop\n 242: astore 18\n 244: aload 18\n 246: iconst_0\n 247: invokeinterface #107, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 252: checkcast #76 // class Day12$Node\n 255: astore 8\n 257: aload 8\n 259: aload 8\n 261: invokevirtual #111 // Method Day12$Node.getConnections:()Ljava/util/List;\n 264: checkcast #70 // class java/util/Collection\n 267: aload 18\n 269: iconst_1\n 270: invokeinterface #107, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 275: invokestatic #115 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 278: invokevirtual #119 // Method Day12$Node.setConnections:(Ljava/util/List;)V\n 281: aload 18\n 283: iconst_1\n 284: invokeinterface #107, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 289: checkcast #76 // class Day12$Node\n 292: astore 8\n 294: aload 8\n 296: aload 8\n 298: invokevirtual #111 // Method Day12$Node.getConnections:()Ljava/util/List;\n 301: checkcast #70 // class java/util/Collection\n 304: aload 18\n 306: iconst_0\n 307: invokeinterface #107, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 312: invokestatic #115 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 315: invokevirtual #119 // Method Day12$Node.setConnections:(Ljava/util/List;)V\n 318: nop\n 319: nop\n 320: goto 40\n 323: nop\n 324: aload_1\n 325: ldc #121 // String start\n 327: invokeinterface #93, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 332: dup\n 333: invokestatic #99 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 336: checkcast #76 // class Day12$Node\n 339: astore_2\n 340: aload_2\n 341: invokestatic #124 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 344: invokestatic #128 // Method part_1$followPaths:(LDay12$Node;Ljava/util/List;)Ljava/util/List;\n 347: checkcast #31 // class java/lang/Iterable\n 350: astore 4\n 352: iconst_0\n 353: istore 5\n 355: aload 4\n 357: astore 6\n 359: new #59 // class java/util/ArrayList\n 362: dup\n 363: invokespecial #129 // Method java/util/ArrayList.\"<init>\":()V\n 366: checkcast #70 // class java/util/Collection\n 369: astore 7\n 371: iconst_0\n 372: istore 8\n 374: aload 6\n 376: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 381: astore 9\n 383: aload 9\n 385: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 390: ifeq 444\n 393: aload 9\n 395: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 400: astore 10\n 402: aload 10\n 404: checkcast #104 // class java/util/List\n 407: astore 11\n 409: iconst_0\n 410: istore 12\n 412: aload 11\n 414: invokestatic #133 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 417: checkcast #76 // class Day12$Node\n 420: invokevirtual #137 // Method Day12$Node.getName:()Ljava/lang/String;\n 423: ldc #139 // String end\n 425: invokestatic #143 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 428: ifeq 383\n 431: aload 7\n 433: aload 10\n 435: invokeinterface #102, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 440: pop\n 441: goto 383\n 444: aload 7\n 446: checkcast #104 // class java/util/List\n 449: nop\n 450: astore_3\n 451: new #145 // class java/lang/StringBuilder\n 454: dup\n 455: invokespecial #146 // Method java/lang/StringBuilder.\"<init>\":()V\n 458: ldc #148 // String Puzzle 1:\n 460: invokevirtual #152 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 463: aload_3\n 464: invokeinterface #156, 1 // InterfaceMethod java/util/List.size:()I\n 469: invokevirtual #159 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 472: invokevirtual #162 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 475: getstatic #168 // Field java/lang/System.out:Ljava/io/PrintStream;\n 478: swap\n 479: invokevirtual #173 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 482: return\n\n public final void part_2();\n Code:\n 0: new #206 // class java/util/HashMap\n 3: dup\n 4: invokespecial #207 // Method java/util/HashMap.\"<init>\":()V\n 7: astore_1\n 8: new #18 // class java/io/File\n 11: dup\n 12: ldc #20 // String ../Input/day12.txt\n 14: invokespecial #23 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 17: aconst_null\n 18: iconst_1\n 19: aconst_null\n 20: invokestatic #29 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 23: checkcast #31 // class java/lang/Iterable\n 26: astore_2\n 27: iconst_0\n 28: istore_3\n 29: aload_2\n 30: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 35: astore 4\n 37: aload 4\n 39: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 44: ifeq 258\n 47: aload 4\n 49: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 54: astore 5\n 56: aload 5\n 58: checkcast #47 // class java/lang/String\n 61: astore 6\n 63: iconst_0\n 64: istore 7\n 66: aload 6\n 68: checkcast #49 // class java/lang/CharSequence\n 71: iconst_1\n 72: anewarray #47 // class java/lang/String\n 75: astore 8\n 77: aload 8\n 79: iconst_0\n 80: ldc #51 // String -\n 82: aastore\n 83: aload 8\n 85: iconst_0\n 86: iconst_0\n 87: bipush 6\n 89: aconst_null\n 90: invokestatic #57 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 93: astore 9\n 95: aload 9\n 97: iconst_0\n 98: invokeinterface #107, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 103: checkcast #47 // class java/lang/String\n 106: astore 8\n 108: aload 9\n 110: iconst_1\n 111: invokeinterface #107, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 116: checkcast #47 // class java/lang/String\n 119: astore 10\n 121: aload_1\n 122: checkcast #16 // class java/util/Map\n 125: astore 11\n 127: iconst_0\n 128: istore 12\n 130: aload 11\n 132: aload 8\n 134: invokeinterface #93, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 139: astore 13\n 141: aload 13\n 143: ifnonnull 175\n 146: iconst_0\n 147: istore 14\n 149: new #209 // class java/util/HashSet\n 152: dup\n 153: invokespecial #210 // Method java/util/HashSet.\"<init>\":()V\n 156: astore 14\n 158: aload 11\n 160: aload 8\n 162: aload 14\n 164: invokeinterface #89, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 169: pop\n 170: aload 14\n 172: goto 177\n 175: aload 13\n 177: nop\n 178: checkcast #209 // class java/util/HashSet\n 181: aload 10\n 183: invokevirtual #211 // Method java/util/HashSet.add:(Ljava/lang/Object;)Z\n 186: pop\n 187: aload_1\n 188: checkcast #16 // class java/util/Map\n 191: astore 11\n 193: iconst_0\n 194: istore 12\n 196: aload 11\n 198: aload 10\n 200: invokeinterface #93, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 205: astore 13\n 207: aload 13\n 209: ifnonnull 241\n 212: iconst_0\n 213: istore 14\n 215: new #209 // class java/util/HashSet\n 218: dup\n 219: invokespecial #210 // Method java/util/HashSet.\"<init>\":()V\n 222: astore 14\n 224: aload 11\n 226: aload 10\n 228: aload 14\n 230: invokeinterface #89, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 235: pop\n 236: aload 14\n 238: goto 243\n 241: aload 13\n 243: nop\n 244: checkcast #209 // class java/util/HashSet\n 247: aload 8\n 249: invokevirtual #211 // Method java/util/HashSet.add:(Ljava/lang/Object;)Z\n 252: pop\n 253: nop\n 254: nop\n 255: goto 37\n 258: nop\n 259: new #145 // class java/lang/StringBuilder\n 262: dup\n 263: invokespecial #146 // Method java/lang/StringBuilder.\"<init>\":()V\n 266: ldc #213 // String Puzzle 2:\n 268: invokevirtual #152 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 271: aload_1\n 272: aconst_null\n 273: iconst_2\n 274: aconst_null\n 275: invokestatic #217 // Method part_2$followPaths$12$default:(Ljava/util/HashMap;Ljava/util/List;ILjava/lang/Object;)Ljava/util/List;\n 278: invokeinterface #156, 1 // InterfaceMethod java/util/List.size:()I\n 283: invokevirtual #159 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 286: invokevirtual #162 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 289: getstatic #168 // Field java/lang/System.out:Ljava/io/PrintStream;\n 292: swap\n 293: invokevirtual #173 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 296: return\n\n private static final java.util.List<java.util.List<Day12$Node>> part_1$followPaths(Day12$Node, java.util.List<Day12$Node>);\n Code:\n 0: aload_1\n 1: checkcast #70 // class java/util/Collection\n 4: aload_0\n 5: invokestatic #115 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 8: astore_2\n 9: aload_0\n 10: invokevirtual #137 // Method Day12$Node.getName:()Ljava/lang/String;\n 13: ldc #139 // String end\n 15: invokestatic #143 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 18: ifne 38\n 21: aload_1\n 22: aload_0\n 23: invokeinterface #231, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 28: ifeq 45\n 31: aload_0\n 32: invokevirtual #234 // Method Day12$Node.isLarge:()Z\n 35: ifne 45\n 38: aload_2\n 39: invokestatic #238 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 42: goto 140\n 45: aload_0\n 46: invokevirtual #111 // Method Day12$Node.getConnections:()Ljava/util/List;\n 49: checkcast #31 // class java/lang/Iterable\n 52: astore_3\n 53: iconst_0\n 54: istore 4\n 56: aload_3\n 57: astore 5\n 59: new #59 // class java/util/ArrayList\n 62: dup\n 63: invokespecial #129 // Method java/util/ArrayList.\"<init>\":()V\n 66: checkcast #70 // class java/util/Collection\n 69: astore 6\n 71: iconst_0\n 72: istore 7\n 74: aload 5\n 76: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 81: astore 8\n 83: aload 8\n 85: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 90: ifeq 134\n 93: aload 8\n 95: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 100: astore 9\n 102: aload 9\n 104: checkcast #76 // class Day12$Node\n 107: astore 10\n 109: iconst_0\n 110: istore 11\n 112: aload 10\n 114: aload_2\n 115: invokestatic #128 // Method part_1$followPaths:(LDay12$Node;Ljava/util/List;)Ljava/util/List;\n 118: checkcast #31 // class java/lang/Iterable\n 121: astore 10\n 123: aload 6\n 125: aload 10\n 127: invokestatic #242 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 130: pop\n 131: goto 83\n 134: aload 6\n 136: checkcast #104 // class java/util/List\n 139: nop\n 140: areturn\n\n private static final boolean part_2$canVisit(java.lang.String, java.util.List<java.lang.String>);\n Code:\n 0: nop\n 1: aload_0\n 2: invokestatic #82 // Method Day12Kt.access$isUpperCase:(Ljava/lang/String;)Z\n 5: ifeq 12\n 8: iconst_1\n 9: goto 366\n 12: aload_0\n 13: ldc #121 // String start\n 15: invokestatic #143 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 18: ifeq 25\n 21: iconst_0\n 22: goto 366\n 25: aload_1\n 26: aload_0\n 27: invokeinterface #231, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 32: ifne 39\n 35: iconst_1\n 36: goto 366\n 39: aload_1\n 40: checkcast #31 // class java/lang/Iterable\n 43: astore_2\n 44: iconst_0\n 45: istore_3\n 46: aload_2\n 47: astore 4\n 49: new #59 // class java/util/ArrayList\n 52: dup\n 53: invokespecial #129 // Method java/util/ArrayList.\"<init>\":()V\n 56: checkcast #70 // class java/util/Collection\n 59: astore 5\n 61: iconst_0\n 62: istore 6\n 64: aload 4\n 66: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 71: astore 7\n 73: aload 7\n 75: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 80: ifeq 123\n 83: aload 7\n 85: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 90: astore 8\n 92: aload 8\n 94: checkcast #47 // class java/lang/String\n 97: astore 9\n 99: iconst_0\n 100: istore 10\n 102: aload 9\n 104: invokestatic #82 // Method Day12Kt.access$isUpperCase:(Ljava/lang/String;)Z\n 107: ifne 73\n 110: aload 5\n 112: aload 8\n 114: invokeinterface #102, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 119: pop\n 120: goto 73\n 123: aload 5\n 125: checkcast #104 // class java/util/List\n 128: nop\n 129: checkcast #31 // class java/lang/Iterable\n 132: astore_2\n 133: nop\n 134: iconst_0\n 135: istore_3\n 136: aload_2\n 137: astore 4\n 139: new #13 // class java/util/LinkedHashMap\n 142: dup\n 143: invokespecial #14 // Method java/util/LinkedHashMap.\"<init>\":()V\n 146: checkcast #16 // class java/util/Map\n 149: astore 5\n 151: iconst_0\n 152: istore 6\n 154: aload 4\n 156: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 161: astore 7\n 163: aload 7\n 165: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 170: ifeq 272\n 173: aload 7\n 175: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 180: astore 8\n 182: aload 8\n 184: checkcast #47 // class java/lang/String\n 187: astore 9\n 189: iconst_0\n 190: istore 10\n 192: aload 9\n 194: astore 11\n 196: aload 5\n 198: astore 12\n 200: iconst_0\n 201: istore 13\n 203: aload 12\n 205: aload 11\n 207: invokeinterface #93, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 212: astore 14\n 214: aload 14\n 216: ifnonnull 251\n 219: iconst_0\n 220: istore 15\n 222: new #59 // class java/util/ArrayList\n 225: dup\n 226: invokespecial #129 // Method java/util/ArrayList.\"<init>\":()V\n 229: checkcast #104 // class java/util/List\n 232: astore 15\n 234: aload 12\n 236: aload 11\n 238: aload 15\n 240: invokeinterface #89, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 245: pop\n 246: aload 15\n 248: goto 253\n 251: aload 14\n 253: nop\n 254: checkcast #104 // class java/util/List\n 257: astore 9\n 259: aload 9\n 261: aload 8\n 263: invokeinterface #254, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 268: pop\n 269: goto 163\n 272: aload 5\n 274: nop\n 275: astore_2\n 276: nop\n 277: iconst_0\n 278: istore_3\n 279: aload_2\n 280: invokeinterface #257, 1 // InterfaceMethod java/util/Map.isEmpty:()Z\n 285: ifeq 292\n 288: iconst_1\n 289: goto 366\n 292: aload_2\n 293: invokeinterface #261, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 298: invokeinterface #264, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 303: astore 4\n 305: aload 4\n 307: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 312: ifeq 365\n 315: aload 4\n 317: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 322: checkcast #266 // class java/util/Map$Entry\n 325: astore 5\n 327: aload 5\n 329: astore 6\n 331: iconst_0\n 332: istore 7\n 334: aload 6\n 336: invokeinterface #269, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 341: checkcast #104 // class java/util/List\n 344: invokeinterface #156, 1 // InterfaceMethod java/util/List.size:()I\n 349: iconst_2\n 350: if_icmpne 357\n 353: iconst_1\n 354: goto 358\n 357: iconst_0\n 358: ifeq 305\n 361: iconst_0\n 362: goto 366\n 365: iconst_1\n 366: ireturn\n\n private static final java.util.List<java.util.List<java.lang.String>> part_2$followPaths$12(java.util.HashMap<java.lang.String, java.util.HashSet<java.lang.String>>, java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: invokestatic #133 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 4: ldc #139 // String end\n 6: invokestatic #143 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 9: ifeq 19\n 12: aload_1\n 13: invokestatic #238 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 16: goto 219\n 19: aload_0\n 20: checkcast #16 // class java/util/Map\n 23: aload_1\n 24: invokestatic #133 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 27: invokestatic #297 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 30: checkcast #31 // class java/lang/Iterable\n 33: astore_2\n 34: nop\n 35: iconst_0\n 36: istore_3\n 37: aload_2\n 38: astore 4\n 40: new #59 // class java/util/ArrayList\n 43: dup\n 44: invokespecial #129 // Method java/util/ArrayList.\"<init>\":()V\n 47: checkcast #70 // class java/util/Collection\n 50: astore 5\n 52: iconst_0\n 53: istore 6\n 55: aload 4\n 57: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 62: astore 7\n 64: aload 7\n 66: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 71: ifeq 115\n 74: aload 7\n 76: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 81: astore 8\n 83: aload 8\n 85: checkcast #47 // class java/lang/String\n 88: astore 9\n 90: iconst_0\n 91: istore 10\n 93: aload 9\n 95: aload_1\n 96: invokestatic #299 // Method part_2$canVisit:(Ljava/lang/String;Ljava/util/List;)Z\n 99: ifeq 64\n 102: aload 5\n 104: aload 8\n 106: invokeinterface #102, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 111: pop\n 112: goto 64\n 115: aload 5\n 117: checkcast #104 // class java/util/List\n 120: nop\n 121: checkcast #31 // class java/lang/Iterable\n 124: astore_2\n 125: nop\n 126: iconst_0\n 127: istore_3\n 128: aload_2\n 129: astore 4\n 131: new #59 // class java/util/ArrayList\n 134: dup\n 135: invokespecial #129 // Method java/util/ArrayList.\"<init>\":()V\n 138: checkcast #70 // class java/util/Collection\n 141: astore 5\n 143: iconst_0\n 144: istore 6\n 146: aload 4\n 148: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 153: astore 7\n 155: aload 7\n 157: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 162: ifeq 213\n 165: aload 7\n 167: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 172: astore 8\n 174: aload 8\n 176: checkcast #47 // class java/lang/String\n 179: astore 9\n 181: iconst_0\n 182: istore 10\n 184: aload_0\n 185: aload_1\n 186: checkcast #70 // class java/util/Collection\n 189: aload 9\n 191: invokestatic #115 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 194: invokestatic #301 // Method part_2$followPaths$12:(Ljava/util/HashMap;Ljava/util/List;)Ljava/util/List;\n 197: checkcast #31 // class java/lang/Iterable\n 200: astore 9\n 202: aload 5\n 204: aload 9\n 206: invokestatic #242 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 209: pop\n 210: goto 155\n 213: aload 5\n 215: checkcast #104 // class java/util/List\n 218: nop\n 219: areturn\n\n static java.util.List part_2$followPaths$12$default(java.util.HashMap, java.util.List, int, java.lang.Object);\n Code:\n 0: iload_2\n 1: iconst_2\n 2: iand\n 3: ifeq 12\n 6: ldc #121 // String start\n 8: invokestatic #238 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 11: astore_1\n 12: aload_0\n 13: aload_1\n 14: invokestatic #301 // Method part_2$followPaths$12:(Ljava/util/HashMap;Ljava/util/List;)Ljava/util/List;\n 17: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day12Kt.class",
"javap": "Compiled from \"day12.kt\"\npublic final class Day12Kt {\n public static final void print_day_12();\n Code:\n 0: ldc #8 // String \\u001b[33m\n 2: astore_0\n 3: ldc #10 // String \\u001b[0m\n 5: astore_1\n 6: ldc #12 // String \\u001b[32m\n 8: astore_2\n 9: new #14 // class java/lang/StringBuilder\n 12: dup\n 13: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 16: aload_0\n 17: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: ldc #23 // String -\n 22: checkcast #25 // class java/lang/CharSequence\n 25: bipush 25\n 27: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 30: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 33: ldc #33 // String Advent of Code - Day 12\n 35: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 38: ldc #23 // String -\n 40: checkcast #25 // class java/lang/CharSequence\n 43: bipush 25\n 45: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 48: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: aload_1\n 52: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 55: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 58: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 61: swap\n 62: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 65: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: aload_2\n 69: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: invokestatic #55 // Method java/lang/Runtime.getRuntime:()Ljava/lang/Runtime;\n 75: ldc #57 // String figlet Passage Pathing -c -f small\n 77: invokevirtual #61 // Method java/lang/Runtime.exec:(Ljava/lang/String;)Ljava/lang/Process;\n 80: astore_3\n 81: new #63 // class java/io/BufferedReader\n 84: dup\n 85: new #65 // class java/io/InputStreamReader\n 88: dup\n 89: aload_3\n 90: invokevirtual #71 // Method java/lang/Process.getInputStream:()Ljava/io/InputStream;\n 93: invokespecial #74 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;)V\n 96: checkcast #76 // class java/io/Reader\n 99: invokespecial #79 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;)V\n 102: astore 4\n 104: aload 4\n 106: checkcast #76 // class java/io/Reader\n 109: invokedynamic #98, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 114: invokestatic #104 // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V\n 117: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 120: aload_1\n 121: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 124: new #14 // class java/lang/StringBuilder\n 127: dup\n 128: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 131: aload_0\n 132: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 135: ldc #23 // String -\n 137: checkcast #25 // class java/lang/CharSequence\n 140: bipush 33\n 142: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 145: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 148: ldc #106 // String Output\n 150: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 153: ldc #23 // String -\n 155: checkcast #25 // class java/lang/CharSequence\n 158: bipush 33\n 160: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 163: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 166: aload_1\n 167: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 170: bipush 10\n 172: invokevirtual #109 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 175: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 178: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 181: swap\n 182: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 185: return\n\n public static final void main();\n Code:\n 0: invokestatic #120 // Method print_day_12:()V\n 3: new #122 // class Day12\n 6: dup\n 7: invokespecial #123 // Method Day12.\"<init>\":()V\n 10: invokevirtual #126 // Method Day12.part_1:()V\n 13: new #122 // class Day12\n 16: dup\n 17: invokespecial #123 // Method Day12.\"<init>\":()V\n 20: invokevirtual #129 // Method Day12.part_2:()V\n 23: new #14 // class java/lang/StringBuilder\n 26: dup\n 27: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 30: ldc #131 // String \\n\\u001b[33m\n 32: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 35: ldc #133 // String =\n 37: checkcast #25 // class java/lang/CharSequence\n 40: bipush 72\n 42: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 45: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: ldc #135 // String \\u001b[0m\\n\n 50: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 53: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 56: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 59: swap\n 60: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 63: return\n\n private static final boolean isUpperCase(java.lang.String);\n Code:\n 0: aload_0\n 1: aload_0\n 2: getstatic #143 // Field java/util/Locale.ROOT:Ljava/util/Locale;\n 5: invokevirtual #149 // Method java/lang/String.toUpperCase:(Ljava/util/Locale;)Ljava/lang/String;\n 8: dup\n 9: ldc #151 // String toUpperCase(...)\n 11: invokestatic #157 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: invokestatic #161 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 17: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #165 // Method main:()V\n 3: return\n\n private static final kotlin.Unit print_day_12$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #169 // String it\n 3: invokestatic #172 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: aload_0\n 10: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 13: getstatic #178 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 16: areturn\n\n public static final boolean access$isUpperCase(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #181 // Method isUpperCase:(Ljava/lang/String;)Z\n 4: ireturn\n}\n",
"javap_err": ""
}
] |
Ad0lphus__AOC2021__02f219e/day07/Kotlin/day07.kt
|
import java.io.*
import kotlin.math.abs
fun print_day_7() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 7" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet The Treachery of Whales -c -f small")
val reader = BufferedReader(InputStreamReader(process.inputStream))
reader.forEachLine { println(it) }
println(reset)
println(yellow + "-".repeat(33) + "Output" + "-".repeat(33) + reset + "\n")
}
fun main() {
print_day_7()
Day7().part_1()
Day7().part_2()
println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}
class Day7 {
val crabs = File("../Input/day7.txt").readLines().first().split(",").map{it.toInt()}
fun part_1() {
val min = crabs.minOrNull()!!
val max = crabs.maxOrNull()!!
var lowest = Int.MAX_VALUE
for(i in min .. max) {
var fuelUsed = 0
for(crab in crabs) { fuelUsed += abs(crab - i) }
if (fuelUsed < lowest) {
lowest = fuelUsed
}
}
println("Puzzle 1: $lowest")
}
fun part_2() {
val min = crabs.minOrNull()!!
val max = crabs.maxOrNull()!!
var lowest = Int.MAX_VALUE
for(i in min .. max) {
var fuelUsed = 0
for(crab in crabs) { fuelUsed += calcFibIncrement(abs(crab - i)) }
if (fuelUsed < lowest) {
lowest = fuelUsed
}
}
println("Puzzle 2: $lowest")
}
fun calcFibIncrement(increment: Int, incrementBy: Int = 0): Int {
return if (increment == 0)
incrementBy
else
calcFibIncrement(increment - 1, incrementBy + 1) + incrementBy
}
}
|
[
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day07Kt.class",
"javap": "Compiled from \"day07.kt\"\npublic final class Day07Kt {\n public static final void print_day_7();\n Code:\n 0: ldc #8 // String \\u001b[33m\n 2: astore_0\n 3: ldc #10 // String \\u001b[0m\n 5: astore_1\n 6: ldc #12 // String \\u001b[32m\n 8: astore_2\n 9: new #14 // class java/lang/StringBuilder\n 12: dup\n 13: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 16: aload_0\n 17: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: ldc #23 // String -\n 22: checkcast #25 // class java/lang/CharSequence\n 25: bipush 25\n 27: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 30: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 33: ldc #33 // String Advent of Code - Day 7\n 35: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 38: ldc #23 // String -\n 40: checkcast #25 // class java/lang/CharSequence\n 43: bipush 25\n 45: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 48: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: aload_1\n 52: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 55: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 58: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 61: swap\n 62: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 65: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: aload_2\n 69: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: invokestatic #55 // Method java/lang/Runtime.getRuntime:()Ljava/lang/Runtime;\n 75: ldc #57 // String figlet The Treachery of Whales -c -f small\n 77: invokevirtual #61 // Method java/lang/Runtime.exec:(Ljava/lang/String;)Ljava/lang/Process;\n 80: astore_3\n 81: new #63 // class java/io/BufferedReader\n 84: dup\n 85: new #65 // class java/io/InputStreamReader\n 88: dup\n 89: aload_3\n 90: invokevirtual #71 // Method java/lang/Process.getInputStream:()Ljava/io/InputStream;\n 93: invokespecial #74 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;)V\n 96: checkcast #76 // class java/io/Reader\n 99: invokespecial #79 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;)V\n 102: astore 4\n 104: aload 4\n 106: checkcast #76 // class java/io/Reader\n 109: invokedynamic #98, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 114: invokestatic #104 // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V\n 117: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 120: aload_1\n 121: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 124: new #14 // class java/lang/StringBuilder\n 127: dup\n 128: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 131: aload_0\n 132: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 135: ldc #23 // String -\n 137: checkcast #25 // class java/lang/CharSequence\n 140: bipush 33\n 142: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 145: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 148: ldc #106 // String Output\n 150: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 153: ldc #23 // String -\n 155: checkcast #25 // class java/lang/CharSequence\n 158: bipush 33\n 160: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 163: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 166: aload_1\n 167: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 170: bipush 10\n 172: invokevirtual #109 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 175: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 178: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 181: swap\n 182: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 185: return\n\n public static final void main();\n Code:\n 0: invokestatic #120 // Method print_day_7:()V\n 3: new #122 // class Day7\n 6: dup\n 7: invokespecial #123 // Method Day7.\"<init>\":()V\n 10: invokevirtual #126 // Method Day7.part_1:()V\n 13: new #122 // class Day7\n 16: dup\n 17: invokespecial #123 // Method Day7.\"<init>\":()V\n 20: invokevirtual #129 // Method Day7.part_2:()V\n 23: new #14 // class java/lang/StringBuilder\n 26: dup\n 27: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 30: ldc #131 // String \\n\\u001b[33m\n 32: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 35: ldc #133 // String =\n 37: checkcast #25 // class java/lang/CharSequence\n 40: bipush 72\n 42: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 45: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: ldc #135 // String \\u001b[0m\\n\n 50: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 53: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 56: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 59: swap\n 60: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 63: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #138 // Method main:()V\n 3: return\n\n private static final kotlin.Unit print_day_7$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #142 // String it\n 3: invokestatic #148 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: aload_0\n 10: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 13: getstatic #154 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 16: areturn\n}\n",
"javap_err": ""
}
] |
Ad0lphus__AOC2021__02f219e/day10/Kotlin/day10.kt
|
import java.io.*
import java.util.*
fun print_day_10() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 10" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Syntax Scoring -c -f small")
val reader = BufferedReader(InputStreamReader(process.inputStream))
reader.forEachLine { println(it) }
println(reset)
println(yellow + "-".repeat(33) + "Output" + "-".repeat(33) + reset + "\n")
}
fun main() {
print_day_10()
Day10().part_1()
Day10().part_2()
println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}
class Day10 {
private val lines = File("../Input/day10.txt").readLines()
private val opening = arrayOf('{', '[', '(', '<')
private val bracketPairs = mapOf('{' to '}', '[' to ']', '(' to ')', '<' to '>')
private fun checkMatchingBrackets(stack: Stack<Char>, remainingChars: String): Int {
if (remainingChars.isEmpty()) return 0
val c = remainingChars.first()
if (c in opening) {
stack.push(c)
}
else {
val matchTo = stack.pop()
if (bracketPairs[matchTo] != c) {
return when(c) {
')' -> 3
']' -> 57
'}' -> 1197
'>' -> 25137
else -> 0
}
}
}
return checkMatchingBrackets(stack, remainingChars.substring(1))
}
fun part_1() {
val total = lines.sumOf {
checkMatchingBrackets(Stack<Char>(), it)
}
println("Puzzle 1: " + total)
}
fun part_2() {
val total = lines.map {
val stack = Stack<Char>()
if (checkMatchingBrackets(stack, it) == 0) {
stack.foldRight(0L) { c, acc ->
acc * 5 + when(bracketPairs[c]) {
')' -> 1
']' -> 2
'}' -> 3
'>' -> 4
else -> 0
}
}
}
else 0
}
.filterNot { it == 0L }
.sorted()
println("Puzzle 2: " + total[(total.size / 2)])
}
}
|
[
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day10.class",
"javap": "Compiled from \"day10.kt\"\npublic final class Day10 {\n private final java.util.List<java.lang.String> lines;\n\n private final java.lang.Character[] opening;\n\n private final java.util.Map<java.lang.Character, java.lang.Character> bracketPairs;\n\n public Day10();\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 java/io/File\n 8: dup\n 9: ldc #12 // String ../Input/day10.txt\n 11: invokespecial #15 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 14: aconst_null\n 15: iconst_1\n 16: aconst_null\n 17: invokestatic #21 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 20: putfield #25 // Field lines:Ljava/util/List;\n 23: aload_0\n 24: iconst_4\n 25: anewarray #27 // class java/lang/Character\n 28: astore_1\n 29: aload_1\n 30: iconst_0\n 31: bipush 123\n 33: invokestatic #31 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 36: aastore\n 37: aload_1\n 38: iconst_1\n 39: bipush 91\n 41: invokestatic #31 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 44: aastore\n 45: aload_1\n 46: iconst_2\n 47: bipush 40\n 49: invokestatic #31 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 52: aastore\n 53: aload_1\n 54: iconst_3\n 55: bipush 60\n 57: invokestatic #31 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 60: aastore\n 61: aload_1\n 62: putfield #35 // Field opening:[Ljava/lang/Character;\n 65: aload_0\n 66: iconst_4\n 67: anewarray #37 // class kotlin/Pair\n 70: astore_1\n 71: aload_1\n 72: iconst_0\n 73: bipush 123\n 75: invokestatic #31 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 78: bipush 125\n 80: invokestatic #31 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 83: invokestatic #43 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 86: aastore\n 87: aload_1\n 88: iconst_1\n 89: bipush 91\n 91: invokestatic #31 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 94: bipush 93\n 96: invokestatic #31 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 99: invokestatic #43 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 102: aastore\n 103: aload_1\n 104: iconst_2\n 105: bipush 40\n 107: invokestatic #31 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 110: bipush 41\n 112: invokestatic #31 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 115: invokestatic #43 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 118: aastore\n 119: aload_1\n 120: iconst_3\n 121: bipush 60\n 123: invokestatic #31 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 126: bipush 62\n 128: invokestatic #31 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 131: invokestatic #43 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 134: aastore\n 135: aload_1\n 136: invokestatic #49 // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 139: putfield #53 // Field bracketPairs:Ljava/util/Map;\n 142: return\n\n private final int checkMatchingBrackets(java.util.Stack<java.lang.Character>, java.lang.String);\n Code:\n 0: aload_2\n 1: checkcast #60 // class java/lang/CharSequence\n 4: invokeinterface #64, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 9: ifne 16\n 12: iconst_1\n 13: goto 17\n 16: iconst_0\n 17: ifeq 22\n 20: iconst_0\n 21: ireturn\n 22: aload_2\n 23: checkcast #60 // class java/lang/CharSequence\n 26: invokestatic #70 // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C\n 29: istore_3\n 30: aload_0\n 31: getfield #35 // Field opening:[Ljava/lang/Character;\n 34: iload_3\n 35: invokestatic #31 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 38: invokestatic #76 // Method kotlin/collections/ArraysKt.contains:([Ljava/lang/Object;Ljava/lang/Object;)Z\n 41: ifeq 56\n 44: aload_1\n 45: iload_3\n 46: invokestatic #31 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 49: invokevirtual #82 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 52: pop\n 53: goto 163\n 56: aload_1\n 57: invokevirtual #86 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 60: checkcast #27 // class java/lang/Character\n 63: astore 4\n 65: aload_0\n 66: getfield #53 // Field bracketPairs:Ljava/util/Map;\n 69: aload 4\n 71: invokeinterface #91, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 76: checkcast #27 // class java/lang/Character\n 79: iload_3\n 80: istore 5\n 82: dup\n 83: ifnonnull 90\n 86: pop\n 87: goto 98\n 90: invokevirtual #95 // Method java/lang/Character.charValue:()C\n 93: iload 5\n 95: if_icmpeq 163\n 98: iload_3\n 99: lookupswitch { // 4\n 41: 140\n 62: 155\n 93: 144\n 125: 149\n default: 161\n }\n 140: iconst_3\n 141: goto 162\n 144: bipush 57\n 146: goto 162\n 149: sipush 1197\n 152: goto 162\n 155: sipush 25137\n 158: goto 162\n 161: iconst_0\n 162: ireturn\n 163: aload_0\n 164: aload_1\n 165: aload_2\n 166: iconst_1\n 167: invokevirtual #101 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 170: dup\n 171: ldc #103 // String substring(...)\n 173: invokestatic #109 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 176: invokespecial #111 // Method checkMatchingBrackets:(Ljava/util/Stack;Ljava/lang/String;)I\n 179: ireturn\n\n public final void part_1();\n Code:\n 0: aload_0\n 1: getfield #25 // Field lines:Ljava/util/List;\n 4: checkcast #122 // class java/lang/Iterable\n 7: astore_2\n 8: iconst_0\n 9: istore_3\n 10: aload_2\n 11: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 16: astore 4\n 18: aload 4\n 20: invokeinterface #132, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 25: ifeq 74\n 28: aload 4\n 30: invokeinterface #135, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 35: astore 5\n 37: iload_3\n 38: aload 5\n 40: checkcast #97 // class java/lang/String\n 43: astore 6\n 45: istore 8\n 47: iconst_0\n 48: istore 7\n 50: aload_0\n 51: new #78 // class java/util/Stack\n 54: dup\n 55: invokespecial #136 // Method java/util/Stack.\"<init>\":()V\n 58: aload 6\n 60: invokespecial #111 // Method checkMatchingBrackets:(Ljava/util/Stack;Ljava/lang/String;)I\n 63: istore 9\n 65: iload 8\n 67: iload 9\n 69: iadd\n 70: istore_3\n 71: goto 18\n 74: iload_3\n 75: istore_1\n 76: new #138 // class java/lang/StringBuilder\n 79: dup\n 80: invokespecial #139 // Method java/lang/StringBuilder.\"<init>\":()V\n 83: ldc #141 // String Puzzle 1:\n 85: invokevirtual #145 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 88: iload_1\n 89: invokevirtual #148 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 92: invokevirtual #152 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 95: getstatic #158 // Field java/lang/System.out:Ljava/io/PrintStream;\n 98: swap\n 99: invokevirtual #164 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 102: return\n\n public final void part_2();\n Code:\n 0: aload_0\n 1: getfield #25 // Field lines:Ljava/util/List;\n 4: checkcast #122 // class java/lang/Iterable\n 7: astore_2\n 8: iconst_0\n 9: istore_3\n 10: aload_2\n 11: astore 4\n 13: new #171 // class java/util/ArrayList\n 16: dup\n 17: aload_2\n 18: bipush 10\n 20: invokestatic #177 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 23: invokespecial #180 // Method java/util/ArrayList.\"<init>\":(I)V\n 26: checkcast #182 // class java/util/Collection\n 29: astore 5\n 31: iconst_0\n 32: istore 6\n 34: aload 4\n 36: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 41: astore 7\n 43: aload 7\n 45: invokeinterface #132, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 50: ifeq 323\n 53: aload 7\n 55: invokeinterface #135, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 60: astore 8\n 62: aload 5\n 64: aload 8\n 66: checkcast #97 // class java/lang/String\n 69: astore 9\n 71: astore 25\n 73: iconst_0\n 74: istore 10\n 76: new #78 // class java/util/Stack\n 79: dup\n 80: invokespecial #136 // Method java/util/Stack.\"<init>\":()V\n 83: astore 11\n 85: aload_0\n 86: aload 11\n 88: aload 9\n 90: invokespecial #111 // Method checkMatchingBrackets:(Ljava/util/Stack;Ljava/lang/String;)I\n 93: ifne 307\n 96: aload 11\n 98: checkcast #184 // class java/util/List\n 101: astore 12\n 103: lconst_0\n 104: lstore 13\n 106: iconst_0\n 107: istore 15\n 109: lload 13\n 111: lstore 16\n 113: aload 12\n 115: invokeinterface #187, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 120: ifne 302\n 123: aload 12\n 125: aload 12\n 127: invokeinterface #190, 1 // InterfaceMethod java/util/List.size:()I\n 132: invokeinterface #194, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 137: astore 18\n 139: aload 18\n 141: invokeinterface #199, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 146: ifeq 302\n 149: aload 18\n 151: invokeinterface #202, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 156: lload 16\n 158: lstore 19\n 160: checkcast #27 // class java/lang/Character\n 163: astore 21\n 165: iconst_0\n 166: istore 22\n 168: lload 19\n 170: iconst_5\n 171: i2l\n 172: lmul\n 173: aload_0\n 174: getfield #53 // Field bracketPairs:Ljava/util/Map;\n 177: aload 21\n 179: invokeinterface #91, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 184: checkcast #27 // class java/lang/Character\n 187: astore 23\n 189: aload 23\n 191: bipush 41\n 193: istore 24\n 195: dup\n 196: ifnonnull 203\n 199: pop\n 200: goto 215\n 203: invokevirtual #95 // Method java/lang/Character.charValue:()C\n 206: iload 24\n 208: if_icmpne 215\n 211: iconst_1\n 212: goto 294\n 215: aload 23\n 217: bipush 93\n 219: istore 24\n 221: dup\n 222: ifnonnull 229\n 225: pop\n 226: goto 241\n 229: invokevirtual #95 // Method java/lang/Character.charValue:()C\n 232: iload 24\n 234: if_icmpne 241\n 237: iconst_2\n 238: goto 294\n 241: aload 23\n 243: bipush 125\n 245: istore 24\n 247: dup\n 248: ifnonnull 255\n 251: pop\n 252: goto 267\n 255: invokevirtual #95 // Method java/lang/Character.charValue:()C\n 258: iload 24\n 260: if_icmpne 267\n 263: iconst_3\n 264: goto 294\n 267: aload 23\n 269: bipush 62\n 271: istore 24\n 273: dup\n 274: ifnonnull 281\n 277: pop\n 278: goto 293\n 281: invokevirtual #95 // Method java/lang/Character.charValue:()C\n 284: iload 24\n 286: if_icmpne 293\n 289: iconst_4\n 290: goto 294\n 293: iconst_0\n 294: i2l\n 295: ladd\n 296: nop\n 297: lstore 16\n 299: goto 139\n 302: lload 16\n 304: goto 308\n 307: lconst_0\n 308: invokestatic #207 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 311: aload 25\n 313: swap\n 314: invokeinterface #211, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 319: pop\n 320: goto 43\n 323: aload 5\n 325: checkcast #184 // class java/util/List\n 328: nop\n 329: checkcast #122 // class java/lang/Iterable\n 332: astore_2\n 333: nop\n 334: iconst_0\n 335: istore_3\n 336: aload_2\n 337: astore 4\n 339: new #171 // class java/util/ArrayList\n 342: dup\n 343: invokespecial #212 // Method java/util/ArrayList.\"<init>\":()V\n 346: checkcast #182 // class java/util/Collection\n 349: astore 5\n 351: iconst_0\n 352: istore 6\n 354: aload 4\n 356: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 361: astore 7\n 363: aload 7\n 365: invokeinterface #132, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 370: ifeq 423\n 373: aload 7\n 375: invokeinterface #135, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 380: astore 8\n 382: aload 8\n 384: checkcast #214 // class java/lang/Number\n 387: invokevirtual #218 // Method java/lang/Number.longValue:()J\n 390: lstore 9\n 392: iconst_0\n 393: istore 11\n 395: lload 9\n 397: lconst_0\n 398: lcmp\n 399: ifne 406\n 402: iconst_1\n 403: goto 407\n 406: iconst_0\n 407: ifne 363\n 410: aload 5\n 412: aload 8\n 414: invokeinterface #211, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 419: pop\n 420: goto 363\n 423: aload 5\n 425: checkcast #184 // class java/util/List\n 428: nop\n 429: checkcast #122 // class java/lang/Iterable\n 432: invokestatic #222 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;\n 435: astore_1\n 436: new #138 // class java/lang/StringBuilder\n 439: dup\n 440: invokespecial #139 // Method java/lang/StringBuilder.\"<init>\":()V\n 443: ldc #224 // String Puzzle 2:\n 445: invokevirtual #145 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 448: aload_1\n 449: aload_1\n 450: invokeinterface #190, 1 // InterfaceMethod java/util/List.size:()I\n 455: iconst_2\n 456: idiv\n 457: invokeinterface #227, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 462: checkcast #214 // class java/lang/Number\n 465: invokevirtual #218 // Method java/lang/Number.longValue:()J\n 468: invokevirtual #230 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 471: invokevirtual #152 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 474: getstatic #158 // Field java/lang/System.out:Ljava/io/PrintStream;\n 477: swap\n 478: invokevirtual #164 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 481: return\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day10Kt.class",
"javap": "Compiled from \"day10.kt\"\npublic final class Day10Kt {\n public static final void print_day_10();\n Code:\n 0: ldc #8 // String \\u001b[33m\n 2: astore_0\n 3: ldc #10 // String \\u001b[0m\n 5: astore_1\n 6: ldc #12 // String \\u001b[32m\n 8: astore_2\n 9: new #14 // class java/lang/StringBuilder\n 12: dup\n 13: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 16: aload_0\n 17: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: ldc #23 // String -\n 22: checkcast #25 // class java/lang/CharSequence\n 25: bipush 25\n 27: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 30: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 33: ldc #33 // String Advent of Code - Day 10\n 35: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 38: ldc #23 // String -\n 40: checkcast #25 // class java/lang/CharSequence\n 43: bipush 25\n 45: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 48: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: aload_1\n 52: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 55: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 58: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 61: swap\n 62: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 65: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: aload_2\n 69: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: invokestatic #55 // Method java/lang/Runtime.getRuntime:()Ljava/lang/Runtime;\n 75: ldc #57 // String figlet Syntax Scoring -c -f small\n 77: invokevirtual #61 // Method java/lang/Runtime.exec:(Ljava/lang/String;)Ljava/lang/Process;\n 80: astore_3\n 81: new #63 // class java/io/BufferedReader\n 84: dup\n 85: new #65 // class java/io/InputStreamReader\n 88: dup\n 89: aload_3\n 90: invokevirtual #71 // Method java/lang/Process.getInputStream:()Ljava/io/InputStream;\n 93: invokespecial #74 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;)V\n 96: checkcast #76 // class java/io/Reader\n 99: invokespecial #79 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;)V\n 102: astore 4\n 104: aload 4\n 106: checkcast #76 // class java/io/Reader\n 109: invokedynamic #98, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 114: invokestatic #104 // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V\n 117: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 120: aload_1\n 121: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 124: new #14 // class java/lang/StringBuilder\n 127: dup\n 128: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 131: aload_0\n 132: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 135: ldc #23 // String -\n 137: checkcast #25 // class java/lang/CharSequence\n 140: bipush 33\n 142: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 145: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 148: ldc #106 // String Output\n 150: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 153: ldc #23 // String -\n 155: checkcast #25 // class java/lang/CharSequence\n 158: bipush 33\n 160: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 163: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 166: aload_1\n 167: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 170: bipush 10\n 172: invokevirtual #109 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 175: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 178: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 181: swap\n 182: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 185: return\n\n public static final void main();\n Code:\n 0: invokestatic #120 // Method print_day_10:()V\n 3: new #122 // class Day10\n 6: dup\n 7: invokespecial #123 // Method Day10.\"<init>\":()V\n 10: invokevirtual #126 // Method Day10.part_1:()V\n 13: new #122 // class Day10\n 16: dup\n 17: invokespecial #123 // Method Day10.\"<init>\":()V\n 20: invokevirtual #129 // Method Day10.part_2:()V\n 23: new #14 // class java/lang/StringBuilder\n 26: dup\n 27: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 30: ldc #131 // String \\n\\u001b[33m\n 32: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 35: ldc #133 // String =\n 37: checkcast #25 // class java/lang/CharSequence\n 40: bipush 72\n 42: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 45: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: ldc #135 // String \\u001b[0m\\n\n 50: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 53: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 56: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 59: swap\n 60: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 63: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #138 // Method main:()V\n 3: return\n\n private static final kotlin.Unit print_day_10$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #142 // String it\n 3: invokestatic #148 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: aload_0\n 10: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 13: getstatic #154 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 16: areturn\n}\n",
"javap_err": ""
}
] |
Ad0lphus__AOC2021__02f219e/day03/Kotlin/day03.kt
|
import java.io.*
fun print_day_3() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 3" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Binary Diagnostic -c -f small")
val reader = BufferedReader(InputStreamReader(process.inputStream))
reader.forEachLine { println(it) }
println(reset)
println(yellow + "-".repeat(33) + "Output" + "-".repeat(33) + reset + "\n")
}
fun main() {
print_day_3()
Day3().part_1()
Day3().part_2()
println("\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}
class Day3 {
val lines = File("../Input/day3.txt").readLines()
fun part_1() {
val matrix = lines.map { s -> s.toCharArray().map { c -> c.digitToInt() } }
var gamma = ""
var epsilon = ""
for(idx in matrix[0].indices) {
val res = matrix.partition { it[idx] == 1 }
gamma += if (res.first.count() > res.second.count()) "1" else "0"
epsilon += if (res.first.count() > res.second.count()) "0" else "1"
}
val answer = gamma.toInt(2) * epsilon.toInt(2)
println("Puzzle 1: " + answer)
}
fun part_2() {
fun splitAndRecurse(list: List<List<Int>>, index: Int, max: Boolean) : List<Int> {
if (list.size == 1) return list[0]
val res = list.partition { it[index] == 1 }
val keep =
if (res.first.count() >= res.second.count())
if (max) res.first else res.second
else
if (max) res.second else res.first
return splitAndRecurse(keep, index+1, max)
}
val matrix = lines.map { s -> s.toCharArray().map { c -> c.digitToInt() } }
val oxygen = splitAndRecurse(matrix, 0, true)
val co2 = splitAndRecurse(matrix, 0, false)
val oxygenDecimal = oxygen.joinToString("").toInt(2)
val co2Decimal = co2.joinToString("").toInt(2)
println("Puzzle 2: " + oxygenDecimal * co2Decimal +"\n")
}
}
|
[
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day03Kt.class",
"javap": "Compiled from \"day03.kt\"\npublic final class Day03Kt {\n public static final void print_day_3();\n Code:\n 0: ldc #8 // String \\u001b[33m\n 2: astore_0\n 3: ldc #10 // String \\u001b[0m\n 5: astore_1\n 6: ldc #12 // String \\u001b[32m\n 8: astore_2\n 9: new #14 // class java/lang/StringBuilder\n 12: dup\n 13: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 16: aload_0\n 17: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: ldc #23 // String -\n 22: checkcast #25 // class java/lang/CharSequence\n 25: bipush 25\n 27: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 30: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 33: ldc #33 // String Advent of Code - Day 3\n 35: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 38: ldc #23 // String -\n 40: checkcast #25 // class java/lang/CharSequence\n 43: bipush 25\n 45: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 48: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: aload_1\n 52: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 55: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 58: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 61: swap\n 62: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 65: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: aload_2\n 69: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: invokestatic #55 // Method java/lang/Runtime.getRuntime:()Ljava/lang/Runtime;\n 75: ldc #57 // String figlet Binary Diagnostic -c -f small\n 77: invokevirtual #61 // Method java/lang/Runtime.exec:(Ljava/lang/String;)Ljava/lang/Process;\n 80: astore_3\n 81: new #63 // class java/io/BufferedReader\n 84: dup\n 85: new #65 // class java/io/InputStreamReader\n 88: dup\n 89: aload_3\n 90: invokevirtual #71 // Method java/lang/Process.getInputStream:()Ljava/io/InputStream;\n 93: invokespecial #74 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;)V\n 96: checkcast #76 // class java/io/Reader\n 99: invokespecial #79 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;)V\n 102: astore 4\n 104: aload 4\n 106: checkcast #76 // class java/io/Reader\n 109: invokedynamic #98, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 114: invokestatic #104 // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V\n 117: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 120: aload_1\n 121: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 124: new #14 // class java/lang/StringBuilder\n 127: dup\n 128: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 131: aload_0\n 132: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 135: ldc #23 // String -\n 137: checkcast #25 // class java/lang/CharSequence\n 140: bipush 33\n 142: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 145: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 148: ldc #106 // String Output\n 150: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 153: ldc #23 // String -\n 155: checkcast #25 // class java/lang/CharSequence\n 158: bipush 33\n 160: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 163: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 166: aload_1\n 167: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 170: bipush 10\n 172: invokevirtual #109 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 175: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 178: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 181: swap\n 182: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 185: return\n\n public static final void main();\n Code:\n 0: invokestatic #120 // Method print_day_3:()V\n 3: new #122 // class Day3\n 6: dup\n 7: invokespecial #123 // Method Day3.\"<init>\":()V\n 10: invokevirtual #126 // Method Day3.part_1:()V\n 13: new #122 // class Day3\n 16: dup\n 17: invokespecial #123 // Method Day3.\"<init>\":()V\n 20: invokevirtual #129 // Method Day3.part_2:()V\n 23: new #14 // class java/lang/StringBuilder\n 26: dup\n 27: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 30: ldc #8 // String \\u001b[33m\n 32: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 35: ldc #131 // String =\n 37: checkcast #25 // class java/lang/CharSequence\n 40: bipush 72\n 42: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 45: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: ldc #133 // String \\u001b[0m\\n\n 50: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 53: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 56: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 59: swap\n 60: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 63: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #136 // Method main:()V\n 3: return\n\n private static final kotlin.Unit print_day_3$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #140 // String it\n 3: invokestatic #146 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: aload_0\n 10: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 13: getstatic #152 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 16: areturn\n}\n",
"javap_err": ""
}
] |
Ad0lphus__AOC2021__02f219e/day18/Kotlin/day18.kt
|
import java.io.*
fun print_day_18() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 18" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Snailfish -c -f small")
val reader = BufferedReader(InputStreamReader(process.inputStream))
reader.forEachLine { println(it) }
println(reset)
println(yellow + "-".repeat(33) + "Output" + "-".repeat(33) + reset + "\n")
}
fun main() {
print_day_18()
println("Puzzle 1: " + Day18().part_1())
println("Puzzle 2: " + Day18().part_2())
println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}
class Day18 {
private val input = File("../Input/day18.txt").readLines()
fun part_1() = input.map { parse(it) }.reduce { a, b -> a + b }.magnitude()
fun part_2() = input.indices.flatMap { i -> input.indices.map { j -> i to j}}.filter {(i,j) -> i != j }.maxOf { (i,j) -> (parse(input[i]) + parse(input[j])).magnitude() }
private fun parse(input: String): Num {
var cur = 0
fun _parse(): Num =
if (input[cur] == '[') {
cur++
val left = _parse()
cur++
val right = _parse()
cur++
Num.NumPair(left, right)
}
else Num.NumValue(input[cur].digitToInt()).also { cur++ }
return _parse()
}
sealed class Num {
var parent: NumPair? = null
class NumValue(var value: Int) : Num() {
override fun toString(): String = value.toString()
fun canSplit(): Boolean = value >= 10
fun split() {
val num = NumPair(NumValue(value / 2), NumValue((value + 1) / 2))
parent?.replaceWith(this, num)
}
}
class NumPair(var left: Num, var right: Num) : Num() {
init {
left.parent = this
right.parent = this
}
override fun toString(): String = "[$left,$right]"
fun explode() {
val x = if (left is NumValue) (left as NumValue).value else null
val y = if (right is NumValue) (right as NumValue).value else null
findValueToLeft()?.let { it.value += x!! }
findValueToRight()?.let { it.value += y!! }
parent?.replaceWith(this, NumValue(0))
}
fun replaceWith(child: Num, newValue: Num) {
if (left == child) { left = newValue }
else if (right == child){ right = newValue }
newValue.parent = this
}
}
fun magnitude(): Int = when(this) {
is NumValue -> value
is NumPair -> left.magnitude() * 3 + right.magnitude() * 2
}
operator fun plus(other: Num): Num =
NumPair(this, other).apply {
left.parent = this
right.parent = this
reduce()
}
fun reduce() {
do {
var exploded = false
var split = false
findNextExplode()?.apply {
explode()
exploded = true
}
if (!exploded) findNextToSplit()?.apply {
split()
split = true
}
} while (exploded || split)
}
fun findValueToRight(): NumValue? {
if (this is NumValue) return this
if (this == parent?.left) return parent!!.right.findValueFurthestLeft()
if (this == parent?.right) return parent!!.findValueToRight()
return null
}
fun findValueToLeft(): NumValue? {
if (this is NumValue) return this
if (this == parent?.left) return parent!!.findValueToLeft()
if (this == parent?.right) return parent!!.left.findValueFurthestRight()
return null
}
private fun findValueFurthestLeft(): NumValue? = when(this) {
is NumValue -> this
is NumPair -> this.left.findValueFurthestLeft()
}
private fun findValueFurthestRight(): NumValue? = when(this) {
is NumValue -> this
is NumPair -> this.right.findValueFurthestRight()
}
private fun findNextToSplit(): NumValue? =
if (this is NumValue && canSplit()) this
else if (this is NumPair) left.findNextToSplit() ?: right.findNextToSplit()
else null
private fun findNextExplode(depth: Int = 0): NumPair? =
if (this is NumPair) {
if (depth >= 4) this
else left.findNextExplode(depth + 1) ?: right.findNextExplode(depth + 1)
}
else null
}
}
|
[
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day18$Num.class",
"javap": "Compiled from \"day18.kt\"\npublic abstract class Day18$Num {\n private Day18$Num$NumPair parent;\n\n private Day18$Num();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final Day18$Num$NumPair getParent();\n Code:\n 0: aload_0\n 1: getfield #17 // Field parent:LDay18$Num$NumPair;\n 4: areturn\n\n public final void setParent(Day18$Num$NumPair);\n Code:\n 0: aload_0\n 1: aload_1\n 2: putfield #17 // Field parent:LDay18$Num$NumPair;\n 5: return\n\n public final int magnitude();\n Code:\n 0: aload_0\n 1: astore_1\n 2: aload_1\n 3: instanceof #24 // class Day18$Num$NumValue\n 6: ifeq 19\n 9: aload_0\n 10: checkcast #24 // class Day18$Num$NumValue\n 13: invokevirtual #27 // Method Day18$Num$NumValue.getValue:()I\n 16: goto 62\n 19: aload_1\n 20: instanceof #29 // class Day18$Num$NumPair\n 23: ifeq 54\n 26: aload_0\n 27: checkcast #29 // class Day18$Num$NumPair\n 30: invokevirtual #33 // Method Day18$Num$NumPair.getLeft:()LDay18$Num;\n 33: invokevirtual #35 // Method magnitude:()I\n 36: iconst_3\n 37: imul\n 38: aload_0\n 39: checkcast #29 // class Day18$Num$NumPair\n 42: invokevirtual #38 // Method Day18$Num$NumPair.getRight:()LDay18$Num;\n 45: invokevirtual #35 // Method magnitude:()I\n 48: iconst_2\n 49: imul\n 50: iadd\n 51: goto 62\n 54: new #40 // class kotlin/NoWhenBranchMatchedException\n 57: dup\n 58: invokespecial #41 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 61: athrow\n 62: ireturn\n\n public final Day18$Num plus(Day18$Num);\n Code:\n 0: aload_1\n 1: ldc #46 // String other\n 3: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #29 // class Day18$Num$NumPair\n 9: dup\n 10: aload_0\n 11: aload_1\n 12: invokespecial #55 // Method Day18$Num$NumPair.\"<init>\":(LDay18$Num;LDay18$Num;)V\n 15: astore_2\n 16: aload_2\n 17: astore_3\n 18: iconst_0\n 19: istore 4\n 21: aload_3\n 22: invokevirtual #33 // Method Day18$Num$NumPair.getLeft:()LDay18$Num;\n 25: aload_3\n 26: putfield #17 // Field parent:LDay18$Num$NumPair;\n 29: aload_3\n 30: invokevirtual #38 // Method Day18$Num$NumPair.getRight:()LDay18$Num;\n 33: aload_3\n 34: putfield #17 // Field parent:LDay18$Num$NumPair;\n 37: aload_3\n 38: invokevirtual #58 // Method Day18$Num$NumPair.reduce:()V\n 41: nop\n 42: aload_2\n 43: checkcast #2 // class Day18$Num\n 46: areturn\n\n public final void reduce();\n Code:\n 0: iconst_0\n 1: istore_1\n 2: iconst_0\n 3: istore_2\n 4: aload_0\n 5: iconst_0\n 6: iconst_1\n 7: aconst_null\n 8: invokestatic #65 // Method findNextExplode$default:(LDay18$Num;IILjava/lang/Object;)LDay18$Num$NumPair;\n 11: dup\n 12: ifnull 33\n 15: astore_3\n 16: aload_3\n 17: astore 4\n 19: iconst_0\n 20: istore 5\n 22: aload 4\n 24: invokevirtual #68 // Method Day18$Num$NumPair.explode:()V\n 27: iconst_1\n 28: istore_1\n 29: nop\n 30: goto 35\n 33: pop\n 34: nop\n 35: iload_1\n 36: ifne 67\n 39: aload_0\n 40: invokespecial #72 // Method findNextToSplit:()LDay18$Num$NumValue;\n 43: dup\n 44: ifnull 65\n 47: astore_3\n 48: aload_3\n 49: astore 4\n 51: iconst_0\n 52: istore 5\n 54: aload 4\n 56: invokevirtual #75 // Method Day18$Num$NumValue.split:()V\n 59: iconst_1\n 60: istore_2\n 61: nop\n 62: goto 67\n 65: pop\n 66: nop\n 67: iload_1\n 68: ifne 0\n 71: iload_2\n 72: ifne 0\n 75: return\n\n public final Day18$Num$NumValue findValueToRight();\n Code:\n 0: aload_0\n 1: instanceof #24 // class Day18$Num$NumValue\n 4: ifeq 12\n 7: aload_0\n 8: checkcast #24 // class Day18$Num$NumValue\n 11: areturn\n 12: aload_0\n 13: aload_0\n 14: getfield #17 // Field parent:LDay18$Num$NumPair;\n 17: dup\n 18: ifnull 27\n 21: invokevirtual #33 // Method Day18$Num$NumPair.getLeft:()LDay18$Num;\n 24: goto 29\n 27: pop\n 28: aconst_null\n 29: invokestatic #87 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 32: ifeq 50\n 35: aload_0\n 36: getfield #17 // Field parent:LDay18$Num$NumPair;\n 39: dup\n 40: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 43: invokevirtual #38 // Method Day18$Num$NumPair.getRight:()LDay18$Num;\n 46: invokespecial #94 // Method findValueFurthestLeft:()LDay18$Num$NumValue;\n 49: areturn\n 50: aload_0\n 51: aload_0\n 52: getfield #17 // Field parent:LDay18$Num$NumPair;\n 55: dup\n 56: ifnull 65\n 59: invokevirtual #38 // Method Day18$Num$NumPair.getRight:()LDay18$Num;\n 62: goto 67\n 65: pop\n 66: aconst_null\n 67: invokestatic #87 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 70: ifeq 85\n 73: aload_0\n 74: getfield #17 // Field parent:LDay18$Num$NumPair;\n 77: dup\n 78: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 81: invokevirtual #96 // Method Day18$Num$NumPair.findValueToRight:()LDay18$Num$NumValue;\n 84: areturn\n 85: aconst_null\n 86: areturn\n\n public final Day18$Num$NumValue findValueToLeft();\n Code:\n 0: aload_0\n 1: instanceof #24 // class Day18$Num$NumValue\n 4: ifeq 12\n 7: aload_0\n 8: checkcast #24 // class Day18$Num$NumValue\n 11: areturn\n 12: aload_0\n 13: aload_0\n 14: getfield #17 // Field parent:LDay18$Num$NumPair;\n 17: dup\n 18: ifnull 27\n 21: invokevirtual #33 // Method Day18$Num$NumPair.getLeft:()LDay18$Num;\n 24: goto 29\n 27: pop\n 28: aconst_null\n 29: invokestatic #87 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 32: ifeq 47\n 35: aload_0\n 36: getfield #17 // Field parent:LDay18$Num$NumPair;\n 39: dup\n 40: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 43: invokevirtual #99 // Method Day18$Num$NumPair.findValueToLeft:()LDay18$Num$NumValue;\n 46: areturn\n 47: aload_0\n 48: aload_0\n 49: getfield #17 // Field parent:LDay18$Num$NumPair;\n 52: dup\n 53: ifnull 62\n 56: invokevirtual #38 // Method Day18$Num$NumPair.getRight:()LDay18$Num;\n 59: goto 64\n 62: pop\n 63: aconst_null\n 64: invokestatic #87 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 67: ifeq 85\n 70: aload_0\n 71: getfield #17 // Field parent:LDay18$Num$NumPair;\n 74: dup\n 75: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 78: invokevirtual #33 // Method Day18$Num$NumPair.getLeft:()LDay18$Num;\n 81: invokespecial #102 // Method findValueFurthestRight:()LDay18$Num$NumValue;\n 84: areturn\n 85: aconst_null\n 86: areturn\n\n private final Day18$Num$NumValue findValueFurthestLeft();\n Code:\n 0: aload_0\n 1: astore_1\n 2: aload_1\n 3: instanceof #24 // class Day18$Num$NumValue\n 6: ifeq 16\n 9: aload_0\n 10: checkcast #24 // class Day18$Num$NumValue\n 13: goto 44\n 16: aload_1\n 17: instanceof #29 // class Day18$Num$NumPair\n 20: ifeq 36\n 23: aload_0\n 24: checkcast #29 // class Day18$Num$NumPair\n 27: invokevirtual #33 // Method Day18$Num$NumPair.getLeft:()LDay18$Num;\n 30: invokespecial #94 // Method findValueFurthestLeft:()LDay18$Num$NumValue;\n 33: goto 44\n 36: new #40 // class kotlin/NoWhenBranchMatchedException\n 39: dup\n 40: invokespecial #41 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 43: athrow\n 44: areturn\n\n private final Day18$Num$NumValue findValueFurthestRight();\n Code:\n 0: aload_0\n 1: astore_1\n 2: aload_1\n 3: instanceof #24 // class Day18$Num$NumValue\n 6: ifeq 16\n 9: aload_0\n 10: checkcast #24 // class Day18$Num$NumValue\n 13: goto 44\n 16: aload_1\n 17: instanceof #29 // class Day18$Num$NumPair\n 20: ifeq 36\n 23: aload_0\n 24: checkcast #29 // class Day18$Num$NumPair\n 27: invokevirtual #38 // Method Day18$Num$NumPair.getRight:()LDay18$Num;\n 30: invokespecial #102 // Method findValueFurthestRight:()LDay18$Num$NumValue;\n 33: goto 44\n 36: new #40 // class kotlin/NoWhenBranchMatchedException\n 39: dup\n 40: invokespecial #41 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 43: athrow\n 44: areturn\n\n private final Day18$Num$NumValue findNextToSplit();\n Code:\n 0: aload_0\n 1: instanceof #24 // class Day18$Num$NumValue\n 4: ifeq 24\n 7: aload_0\n 8: checkcast #24 // class Day18$Num$NumValue\n 11: invokevirtual #106 // Method Day18$Num$NumValue.canSplit:()Z\n 14: ifeq 24\n 17: aload_0\n 18: checkcast #24 // class Day18$Num$NumValue\n 21: goto 60\n 24: aload_0\n 25: instanceof #29 // class Day18$Num$NumPair\n 28: ifeq 59\n 31: aload_0\n 32: checkcast #29 // class Day18$Num$NumPair\n 35: invokevirtual #33 // Method Day18$Num$NumPair.getLeft:()LDay18$Num;\n 38: invokespecial #72 // Method findNextToSplit:()LDay18$Num$NumValue;\n 41: dup\n 42: ifnonnull 60\n 45: pop\n 46: aload_0\n 47: checkcast #29 // class Day18$Num$NumPair\n 50: invokevirtual #38 // Method Day18$Num$NumPair.getRight:()LDay18$Num;\n 53: invokespecial #72 // Method findNextToSplit:()LDay18$Num$NumValue;\n 56: goto 60\n 59: aconst_null\n 60: areturn\n\n private final Day18$Num$NumPair findNextExplode(int);\n Code:\n 0: aload_0\n 1: instanceof #29 // class Day18$Num$NumPair\n 4: ifeq 53\n 7: iload_1\n 8: iconst_4\n 9: if_icmplt 19\n 12: aload_0\n 13: checkcast #29 // class Day18$Num$NumPair\n 16: goto 54\n 19: aload_0\n 20: checkcast #29 // class Day18$Num$NumPair\n 23: invokevirtual #33 // Method Day18$Num$NumPair.getLeft:()LDay18$Num;\n 26: iload_1\n 27: iconst_1\n 28: iadd\n 29: invokespecial #110 // Method findNextExplode:(I)LDay18$Num$NumPair;\n 32: dup\n 33: ifnonnull 54\n 36: pop\n 37: aload_0\n 38: checkcast #29 // class Day18$Num$NumPair\n 41: invokevirtual #38 // Method Day18$Num$NumPair.getRight:()LDay18$Num;\n 44: iload_1\n 45: iconst_1\n 46: iadd\n 47: invokespecial #110 // Method findNextExplode:(I)LDay18$Num$NumPair;\n 50: goto 54\n 53: aconst_null\n 54: areturn\n\n static Day18$Num$NumPair findNextExplode$default(Day18$Num, int, int, java.lang.Object);\n Code:\n 0: aload_3\n 1: ifnull 14\n 4: new #113 // class java/lang/UnsupportedOperationException\n 7: dup\n 8: ldc #115 // String Super calls with default arguments not supported in this target, function: findNextExplode\n 10: invokespecial #118 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 13: athrow\n 14: iload_2\n 15: iconst_1\n 16: iand\n 17: ifeq 22\n 20: iconst_0\n 21: istore_1\n 22: aload_0\n 23: iload_1\n 24: invokespecial #110 // Method findNextExplode:(I)LDay18$Num$NumPair;\n 27: areturn\n\n public Day18$Num(kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: invokespecial #120 // Method \"<init>\":()V\n 4: return\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day18.class",
"javap": "Compiled from \"day18.kt\"\npublic final class Day18 {\n private final java.util.List<java.lang.String> input;\n\n public Day18();\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 java/io/File\n 8: dup\n 9: ldc #12 // String ../Input/day18.txt\n 11: invokespecial #15 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 14: aconst_null\n 15: iconst_1\n 16: aconst_null\n 17: invokestatic #21 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 20: putfield #25 // Field input:Ljava/util/List;\n 23: return\n\n public final int part_1();\n Code:\n 0: aload_0\n 1: getfield #25 // Field input:Ljava/util/List;\n 4: checkcast #31 // class java/lang/Iterable\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: astore_3\n 12: new #33 // class java/util/ArrayList\n 15: dup\n 16: aload_1\n 17: bipush 10\n 19: invokestatic #39 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 22: invokespecial #42 // Method java/util/ArrayList.\"<init>\":(I)V\n 25: checkcast #44 // class java/util/Collection\n 28: astore 4\n 30: iconst_0\n 31: istore 5\n 33: aload_3\n 34: invokeinterface #48, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 6\n 41: aload 6\n 43: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 92\n 51: aload 6\n 53: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 7\n 60: aload 4\n 62: aload 7\n 64: checkcast #60 // class java/lang/String\n 67: astore 8\n 69: astore 10\n 71: iconst_0\n 72: istore 9\n 74: aload_0\n 75: aload 8\n 77: invokespecial #64 // Method parse:(Ljava/lang/String;)LDay18$Num;\n 80: aload 10\n 82: swap\n 83: invokeinterface #68, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 88: pop\n 89: goto 41\n 92: aload 4\n 94: checkcast #70 // class java/util/List\n 97: nop\n 98: checkcast #31 // class java/lang/Iterable\n 101: astore_1\n 102: nop\n 103: iconst_0\n 104: istore_2\n 105: aload_1\n 106: invokeinterface #48, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 111: astore_3\n 112: aload_3\n 113: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 118: ifne 131\n 121: new #72 // class java/lang/UnsupportedOperationException\n 124: dup\n 125: ldc #74 // String Empty collection can\\'t be reduced.\n 127: invokespecial #75 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 130: athrow\n 131: aload_3\n 132: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 137: astore 4\n 139: aload_3\n 140: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 145: ifeq 181\n 148: aload 4\n 150: aload_3\n 151: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 156: checkcast #77 // class Day18$Num\n 159: astore 5\n 161: checkcast #77 // class Day18$Num\n 164: astore 6\n 166: iconst_0\n 167: istore 7\n 169: aload 6\n 171: aload 5\n 173: invokevirtual #81 // Method Day18$Num.plus:(LDay18$Num;)LDay18$Num;\n 176: astore 4\n 178: goto 139\n 181: aload 4\n 183: checkcast #77 // class Day18$Num\n 186: invokevirtual #84 // Method Day18$Num.magnitude:()I\n 189: ireturn\n\n public final int part_2();\n Code:\n 0: aload_0\n 1: getfield #25 // Field input:Ljava/util/List;\n 4: checkcast #44 // class java/util/Collection\n 7: invokestatic #111 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 10: checkcast #31 // class java/lang/Iterable\n 13: astore_1\n 14: iconst_0\n 15: istore_2\n 16: aload_1\n 17: astore_3\n 18: new #33 // class java/util/ArrayList\n 21: dup\n 22: invokespecial #112 // Method java/util/ArrayList.\"<init>\":()V\n 25: checkcast #44 // class java/util/Collection\n 28: astore 4\n 30: iconst_0\n 31: istore 5\n 33: aload_3\n 34: invokeinterface #48, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 6\n 41: aload 6\n 43: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 200\n 51: aload 6\n 53: checkcast #114 // class kotlin/collections/IntIterator\n 56: invokevirtual #117 // Method kotlin/collections/IntIterator.nextInt:()I\n 59: istore 7\n 61: iload 7\n 63: istore 8\n 65: iconst_0\n 66: istore 9\n 68: aload_0\n 69: getfield #25 // Field input:Ljava/util/List;\n 72: checkcast #44 // class java/util/Collection\n 75: invokestatic #111 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 78: checkcast #31 // class java/lang/Iterable\n 81: astore 10\n 83: iconst_0\n 84: istore 11\n 86: aload 10\n 88: astore 12\n 90: new #33 // class java/util/ArrayList\n 93: dup\n 94: aload 10\n 96: bipush 10\n 98: invokestatic #39 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 101: invokespecial #42 // Method java/util/ArrayList.\"<init>\":(I)V\n 104: checkcast #44 // class java/util/Collection\n 107: astore 13\n 109: iconst_0\n 110: istore 14\n 112: aload 12\n 114: invokeinterface #48, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 119: astore 15\n 121: aload 15\n 123: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 128: ifeq 177\n 131: aload 15\n 133: checkcast #114 // class kotlin/collections/IntIterator\n 136: invokevirtual #117 // Method kotlin/collections/IntIterator.nextInt:()I\n 139: istore 16\n 141: aload 13\n 143: iload 16\n 145: istore 17\n 147: astore 18\n 149: iconst_0\n 150: istore 19\n 152: iload 8\n 154: invokestatic #123 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 157: iload 17\n 159: invokestatic #123 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 162: invokestatic #129 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 165: aload 18\n 167: swap\n 168: invokeinterface #68, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 173: pop\n 174: goto 121\n 177: aload 13\n 179: checkcast #70 // class java/util/List\n 182: nop\n 183: checkcast #31 // class java/lang/Iterable\n 186: nop\n 187: astore 8\n 189: aload 4\n 191: aload 8\n 193: invokestatic #133 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 196: pop\n 197: goto 41\n 200: aload 4\n 202: checkcast #70 // class java/util/List\n 205: nop\n 206: checkcast #31 // class java/lang/Iterable\n 209: astore_1\n 210: nop\n 211: iconst_0\n 212: istore_2\n 213: aload_1\n 214: astore_3\n 215: new #33 // class java/util/ArrayList\n 218: dup\n 219: invokespecial #112 // Method java/util/ArrayList.\"<init>\":()V\n 222: checkcast #44 // class java/util/Collection\n 225: astore 4\n 227: iconst_0\n 228: istore 5\n 230: aload_3\n 231: invokeinterface #48, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 236: astore 6\n 238: aload 6\n 240: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 245: ifeq 321\n 248: aload 6\n 250: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 255: astore 7\n 257: aload 7\n 259: checkcast #135 // class kotlin/Pair\n 262: astore 8\n 264: iconst_0\n 265: istore 9\n 267: aload 8\n 269: invokevirtual #138 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 272: checkcast #140 // class java/lang/Number\n 275: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 278: istore 10\n 280: aload 8\n 282: invokevirtual #146 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 285: checkcast #140 // class java/lang/Number\n 288: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 291: istore 11\n 293: iload 10\n 295: iload 11\n 297: if_icmpeq 304\n 300: iconst_1\n 301: goto 305\n 304: iconst_0\n 305: ifeq 238\n 308: aload 4\n 310: aload 7\n 312: invokeinterface #68, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 317: pop\n 318: goto 238\n 321: aload 4\n 323: checkcast #70 // class java/util/List\n 326: nop\n 327: checkcast #31 // class java/lang/Iterable\n 330: invokeinterface #48, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 335: astore_2\n 336: aload_2\n 337: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 342: ifne 353\n 345: new #148 // class java/util/NoSuchElementException\n 348: dup\n 349: invokespecial #149 // Method java/util/NoSuchElementException.\"<init>\":()V\n 352: athrow\n 353: aload_2\n 354: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 359: checkcast #135 // class kotlin/Pair\n 362: astore_3\n 363: iconst_0\n 364: istore 4\n 366: aload_3\n 367: invokevirtual #138 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 370: checkcast #140 // class java/lang/Number\n 373: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 376: istore 5\n 378: aload_3\n 379: invokevirtual #146 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 382: checkcast #140 // class java/lang/Number\n 385: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 388: istore 6\n 390: aload_0\n 391: aload_0\n 392: getfield #25 // Field input:Ljava/util/List;\n 395: iload 5\n 397: invokeinterface #153, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 402: checkcast #60 // class java/lang/String\n 405: invokespecial #64 // Method parse:(Ljava/lang/String;)LDay18$Num;\n 408: aload_0\n 409: aload_0\n 410: getfield #25 // Field input:Ljava/util/List;\n 413: iload 6\n 415: invokeinterface #153, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 420: checkcast #60 // class java/lang/String\n 423: invokespecial #64 // Method parse:(Ljava/lang/String;)LDay18$Num;\n 426: invokevirtual #81 // Method Day18$Num.plus:(LDay18$Num;)LDay18$Num;\n 429: invokevirtual #84 // Method Day18$Num.magnitude:()I\n 432: istore_3\n 433: aload_2\n 434: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 439: ifeq 538\n 442: aload_2\n 443: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 448: checkcast #135 // class kotlin/Pair\n 451: astore 4\n 453: iconst_0\n 454: istore 5\n 456: aload 4\n 458: invokevirtual #138 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 461: checkcast #140 // class java/lang/Number\n 464: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 467: istore 6\n 469: aload 4\n 471: invokevirtual #146 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 474: checkcast #140 // class java/lang/Number\n 477: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 480: istore 7\n 482: aload_0\n 483: aload_0\n 484: getfield #25 // Field input:Ljava/util/List;\n 487: iload 6\n 489: invokeinterface #153, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 494: checkcast #60 // class java/lang/String\n 497: invokespecial #64 // Method parse:(Ljava/lang/String;)LDay18$Num;\n 500: aload_0\n 501: aload_0\n 502: getfield #25 // Field input:Ljava/util/List;\n 505: iload 7\n 507: invokeinterface #153, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 512: checkcast #60 // class java/lang/String\n 515: invokespecial #64 // Method parse:(Ljava/lang/String;)LDay18$Num;\n 518: invokevirtual #81 // Method Day18$Num.plus:(LDay18$Num;)LDay18$Num;\n 521: invokevirtual #84 // Method Day18$Num.magnitude:()I\n 524: istore 4\n 526: iload_3\n 527: iload 4\n 529: if_icmpge 433\n 532: iload 4\n 534: istore_3\n 535: goto 433\n 538: iload_3\n 539: ireturn\n\n private final Day18$Num parse(java.lang.String);\n Code:\n 0: new #171 // class kotlin/jvm/internal/Ref$IntRef\n 3: dup\n 4: invokespecial #172 // Method kotlin/jvm/internal/Ref$IntRef.\"<init>\":()V\n 7: astore_2\n 8: aload_1\n 9: aload_2\n 10: invokestatic #176 // Method parse$_parse:(Ljava/lang/String;Lkotlin/jvm/internal/Ref$IntRef;)LDay18$Num;\n 13: areturn\n\n private static final Day18$Num parse$_parse(java.lang.String, kotlin.jvm.internal.Ref$IntRef);\n Code:\n 0: aload_0\n 1: aload_1\n 2: getfield #181 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 5: invokevirtual #185 // Method java/lang/String.charAt:(I)C\n 8: bipush 91\n 10: if_icmpne 78\n 13: aload_1\n 14: getfield #181 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 17: istore_2\n 18: aload_1\n 19: iload_2\n 20: iconst_1\n 21: iadd\n 22: putfield #181 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 25: aload_0\n 26: aload_1\n 27: invokestatic #176 // Method parse$_parse:(Ljava/lang/String;Lkotlin/jvm/internal/Ref$IntRef;)LDay18$Num;\n 30: astore_2\n 31: aload_1\n 32: getfield #181 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 35: istore_3\n 36: aload_1\n 37: iload_3\n 38: iconst_1\n 39: iadd\n 40: putfield #181 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 43: aload_0\n 44: aload_1\n 45: invokestatic #176 // Method parse$_parse:(Ljava/lang/String;Lkotlin/jvm/internal/Ref$IntRef;)LDay18$Num;\n 48: astore_3\n 49: aload_1\n 50: getfield #181 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 53: istore 4\n 55: aload_1\n 56: iload 4\n 58: iconst_1\n 59: iadd\n 60: putfield #181 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 63: new #187 // class Day18$Num$NumPair\n 66: dup\n 67: aload_2\n 68: aload_3\n 69: invokespecial #190 // Method Day18$Num$NumPair.\"<init>\":(LDay18$Num;LDay18$Num;)V\n 72: checkcast #77 // class Day18$Num\n 75: goto 120\n 78: new #192 // class Day18$Num$NumValue\n 81: dup\n 82: aload_0\n 83: aload_1\n 84: getfield #181 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 87: invokevirtual #185 // Method java/lang/String.charAt:(I)C\n 90: invokestatic #198 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 93: invokespecial #199 // Method Day18$Num$NumValue.\"<init>\":(I)V\n 96: astore_2\n 97: aload_2\n 98: astore_3\n 99: iconst_0\n 100: istore 4\n 102: aload_1\n 103: getfield #181 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 106: istore 5\n 108: aload_1\n 109: iload 5\n 111: iconst_1\n 112: iadd\n 113: putfield #181 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 116: aload_2\n 117: checkcast #77 // class Day18$Num\n 120: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day18$Num$NumValue.class",
"javap": "Compiled from \"day18.kt\"\npublic final class Day18$Num$NumValue extends Day18$Num {\n private int value;\n\n public Day18$Num$NumValue(int);\n Code:\n 0: aload_0\n 1: aconst_null\n 2: invokespecial #9 // Method Day18$Num.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 5: aload_0\n 6: iload_1\n 7: putfield #13 // Field value:I\n 10: return\n\n public final int getValue();\n Code:\n 0: aload_0\n 1: getfield #13 // Field value:I\n 4: ireturn\n\n public final void setValue(int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: putfield #13 // Field value:I\n 5: return\n\n public java.lang.String toString();\n Code:\n 0: aload_0\n 1: getfield #13 // Field value:I\n 4: invokestatic #28 // Method java/lang/String.valueOf:(I)Ljava/lang/String;\n 7: areturn\n\n public final boolean canSplit();\n Code:\n 0: aload_0\n 1: getfield #13 // Field value:I\n 4: bipush 10\n 6: if_icmplt 13\n 9: iconst_1\n 10: goto 14\n 13: iconst_0\n 14: ireturn\n\n public final void split();\n Code:\n 0: new #34 // class Day18$Num$NumPair\n 3: dup\n 4: new #2 // class Day18$Num$NumValue\n 7: dup\n 8: aload_0\n 9: getfield #13 // Field value:I\n 12: iconst_2\n 13: idiv\n 14: invokespecial #36 // Method \"<init>\":(I)V\n 17: checkcast #4 // class Day18$Num\n 20: new #2 // class Day18$Num$NumValue\n 23: dup\n 24: aload_0\n 25: getfield #13 // Field value:I\n 28: iconst_1\n 29: iadd\n 30: iconst_2\n 31: idiv\n 32: invokespecial #36 // Method \"<init>\":(I)V\n 35: checkcast #4 // class Day18$Num\n 38: invokespecial #39 // Method Day18$Num$NumPair.\"<init>\":(LDay18$Num;LDay18$Num;)V\n 41: astore_1\n 42: aload_0\n 43: invokevirtual #43 // Method getParent:()LDay18$Num$NumPair;\n 46: dup\n 47: ifnull 64\n 50: aload_0\n 51: checkcast #4 // class Day18$Num\n 54: aload_1\n 55: checkcast #4 // class Day18$Num\n 58: invokevirtual #46 // Method Day18$Num$NumPair.replaceWith:(LDay18$Num;LDay18$Num;)V\n 61: goto 65\n 64: pop\n 65: return\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day18$Num$NumPair.class",
"javap": "Compiled from \"day18.kt\"\npublic final class Day18$Num$NumPair extends Day18$Num {\n private Day18$Num left;\n\n private Day18$Num right;\n\n public Day18$Num$NumPair(Day18$Num, Day18$Num);\n Code:\n 0: aload_1\n 1: ldc #9 // String left\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 right\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: aconst_null\n 14: invokespecial #20 // Method Day18$Num.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 17: aload_0\n 18: aload_1\n 19: putfield #23 // Field left:LDay18$Num;\n 22: aload_0\n 23: aload_2\n 24: putfield #25 // Field right:LDay18$Num;\n 27: nop\n 28: aload_0\n 29: getfield #23 // Field left:LDay18$Num;\n 32: aload_0\n 33: invokevirtual #29 // Method Day18$Num.setParent:(LDay18$Num$NumPair;)V\n 36: aload_0\n 37: getfield #25 // Field right:LDay18$Num;\n 40: aload_0\n 41: invokevirtual #29 // Method Day18$Num.setParent:(LDay18$Num$NumPair;)V\n 44: nop\n 45: return\n\n public final Day18$Num getLeft();\n Code:\n 0: aload_0\n 1: getfield #23 // Field left:LDay18$Num;\n 4: areturn\n\n public final void setLeft(Day18$Num);\n Code:\n 0: aload_1\n 1: ldc #37 // String <set-?>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: putfield #23 // Field left:LDay18$Num;\n 11: return\n\n public final Day18$Num getRight();\n Code:\n 0: aload_0\n 1: getfield #25 // Field right:LDay18$Num;\n 4: areturn\n\n public final void setRight(Day18$Num);\n Code:\n 0: aload_1\n 1: ldc #37 // String <set-?>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: putfield #25 // Field right:LDay18$Num;\n 11: return\n\n public java.lang.String toString();\n Code:\n 0: new #43 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #46 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: bipush 91\n 9: invokevirtual #50 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #23 // Field left:LDay18$Num;\n 16: invokevirtual #53 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: bipush 44\n 21: invokevirtual #50 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #25 // Field right:LDay18$Num;\n 28: invokevirtual #53 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: bipush 93\n 33: invokevirtual #50 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #55 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 39: areturn\n\n public final void explode();\n Code:\n 0: aload_0\n 1: getfield #23 // Field left:LDay18$Num;\n 4: instanceof #58 // class Day18$Num$NumValue\n 7: ifeq 32\n 10: aload_0\n 11: getfield #23 // Field left:LDay18$Num;\n 14: dup\n 15: ldc #60 // String null cannot be cast to non-null type <root>.Day18.Num.NumValue\n 17: invokestatic #63 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V\n 20: checkcast #58 // class Day18$Num$NumValue\n 23: invokevirtual #67 // Method Day18$Num$NumValue.getValue:()I\n 26: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 29: goto 33\n 32: aconst_null\n 33: astore_1\n 34: aload_0\n 35: getfield #25 // Field right:LDay18$Num;\n 38: instanceof #58 // class Day18$Num$NumValue\n 41: ifeq 66\n 44: aload_0\n 45: getfield #25 // Field right:LDay18$Num;\n 48: dup\n 49: ldc #60 // String null cannot be cast to non-null type <root>.Day18.Num.NumValue\n 51: invokestatic #63 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V\n 54: checkcast #58 // class Day18$Num$NumValue\n 57: invokevirtual #67 // Method Day18$Num$NumValue.getValue:()I\n 60: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 63: goto 67\n 66: aconst_null\n 67: astore_2\n 68: aload_0\n 69: invokevirtual #77 // Method findValueToLeft:()LDay18$Num$NumValue;\n 72: dup\n 73: ifnull 100\n 76: astore_3\n 77: iconst_0\n 78: istore 4\n 80: aload_3\n 81: aload_3\n 82: invokevirtual #67 // Method Day18$Num$NumValue.getValue:()I\n 85: aload_1\n 86: dup\n 87: invokestatic #80 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 90: invokevirtual #83 // Method java/lang/Integer.intValue:()I\n 93: iadd\n 94: invokevirtual #87 // Method Day18$Num$NumValue.setValue:(I)V\n 97: goto 102\n 100: pop\n 101: nop\n 102: aload_0\n 103: invokevirtual #90 // Method findValueToRight:()LDay18$Num$NumValue;\n 106: dup\n 107: ifnull 134\n 110: astore_3\n 111: iconst_0\n 112: istore 4\n 114: aload_3\n 115: aload_3\n 116: invokevirtual #67 // Method Day18$Num$NumValue.getValue:()I\n 119: aload_2\n 120: dup\n 121: invokestatic #80 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 124: invokevirtual #83 // Method java/lang/Integer.intValue:()I\n 127: iadd\n 128: invokevirtual #87 // Method Day18$Num$NumValue.setValue:(I)V\n 131: goto 136\n 134: pop\n 135: nop\n 136: aload_0\n 137: invokevirtual #94 // Method getParent:()LDay18$Num$NumPair;\n 140: dup\n 141: ifnull 165\n 144: aload_0\n 145: checkcast #4 // class Day18$Num\n 148: new #58 // class Day18$Num$NumValue\n 151: dup\n 152: iconst_0\n 153: invokespecial #96 // Method Day18$Num$NumValue.\"<init>\":(I)V\n 156: checkcast #4 // class Day18$Num\n 159: invokevirtual #99 // Method replaceWith:(LDay18$Num;LDay18$Num;)V\n 162: goto 166\n 165: pop\n 166: return\n\n public final void replaceWith(Day18$Num, Day18$Num);\n Code:\n 0: aload_1\n 1: ldc #109 // String child\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #111 // String newValue\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: getfield #23 // Field left:LDay18$Num;\n 16: aload_1\n 17: invokestatic #115 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 20: ifeq 31\n 23: aload_0\n 24: aload_2\n 25: putfield #23 // Field left:LDay18$Num;\n 28: goto 47\n 31: aload_0\n 32: getfield #25 // Field right:LDay18$Num;\n 35: aload_1\n 36: invokestatic #115 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 39: ifeq 47\n 42: aload_0\n 43: aload_2\n 44: putfield #25 // Field right:LDay18$Num;\n 47: aload_2\n 48: aload_0\n 49: invokevirtual #29 // Method Day18$Num.setParent:(LDay18$Num$NumPair;)V\n 52: return\n}\n",
"javap_err": ""
},
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day18Kt.class",
"javap": "Compiled from \"day18.kt\"\npublic final class Day18Kt {\n public static final void print_day_18();\n Code:\n 0: ldc #8 // String \\u001b[33m\n 2: astore_0\n 3: ldc #10 // String \\u001b[0m\n 5: astore_1\n 6: ldc #12 // String \\u001b[32m\n 8: astore_2\n 9: new #14 // class java/lang/StringBuilder\n 12: dup\n 13: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 16: aload_0\n 17: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: ldc #23 // String -\n 22: checkcast #25 // class java/lang/CharSequence\n 25: bipush 25\n 27: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 30: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 33: ldc #33 // String Advent of Code - Day 18\n 35: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 38: ldc #23 // String -\n 40: checkcast #25 // class java/lang/CharSequence\n 43: bipush 25\n 45: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 48: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: aload_1\n 52: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 55: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 58: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 61: swap\n 62: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 65: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: aload_2\n 69: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: invokestatic #55 // Method java/lang/Runtime.getRuntime:()Ljava/lang/Runtime;\n 75: ldc #57 // String figlet Snailfish -c -f small\n 77: invokevirtual #61 // Method java/lang/Runtime.exec:(Ljava/lang/String;)Ljava/lang/Process;\n 80: astore_3\n 81: new #63 // class java/io/BufferedReader\n 84: dup\n 85: new #65 // class java/io/InputStreamReader\n 88: dup\n 89: aload_3\n 90: invokevirtual #71 // Method java/lang/Process.getInputStream:()Ljava/io/InputStream;\n 93: invokespecial #74 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;)V\n 96: checkcast #76 // class java/io/Reader\n 99: invokespecial #79 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;)V\n 102: astore 4\n 104: aload 4\n 106: checkcast #76 // class java/io/Reader\n 109: invokedynamic #98, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 114: invokestatic #104 // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V\n 117: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 120: aload_1\n 121: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 124: new #14 // class java/lang/StringBuilder\n 127: dup\n 128: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 131: aload_0\n 132: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 135: ldc #23 // String -\n 137: checkcast #25 // class java/lang/CharSequence\n 140: bipush 33\n 142: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 145: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 148: ldc #106 // String Output\n 150: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 153: ldc #23 // String -\n 155: checkcast #25 // class java/lang/CharSequence\n 158: bipush 33\n 160: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 163: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 166: aload_1\n 167: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 170: bipush 10\n 172: invokevirtual #109 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 175: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 178: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 181: swap\n 182: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 185: return\n\n public static final void main();\n Code:\n 0: invokestatic #120 // Method print_day_18:()V\n 3: new #14 // class java/lang/StringBuilder\n 6: dup\n 7: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 10: ldc #122 // String Puzzle 1:\n 12: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 15: new #124 // class Day18\n 18: dup\n 19: invokespecial #125 // Method Day18.\"<init>\":()V\n 22: invokevirtual #129 // Method Day18.part_1:()I\n 25: invokevirtual #132 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 28: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 31: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 34: swap\n 35: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 38: new #14 // class java/lang/StringBuilder\n 41: dup\n 42: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 45: ldc #134 // String Puzzle 2:\n 47: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 50: new #124 // class Day18\n 53: dup\n 54: invokespecial #125 // Method Day18.\"<init>\":()V\n 57: invokevirtual #137 // Method Day18.part_2:()I\n 60: invokevirtual #132 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 63: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 66: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 69: swap\n 70: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 73: new #14 // class java/lang/StringBuilder\n 76: dup\n 77: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 80: ldc #139 // String \\n\\u001b[33m\n 82: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 85: ldc #141 // String =\n 87: checkcast #25 // class java/lang/CharSequence\n 90: bipush 72\n 92: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 95: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 98: ldc #143 // String \\u001b[0m\\n\n 100: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 103: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 106: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 109: swap\n 110: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 113: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #146 // Method main:()V\n 3: return\n\n private static final kotlin.Unit print_day_18$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #150 // String it\n 3: invokestatic #156 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: aload_0\n 10: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 13: getstatic #162 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 16: areturn\n}\n",
"javap_err": ""
}
] |
Ad0lphus__AOC2021__02f219e/day09/Kotlin/day09.kt
|
import java.io.*
fun print_day_9() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 9" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Smoke Basin -c -f small")
val reader = BufferedReader(InputStreamReader(process.inputStream))
reader.forEachLine { println(it) }
println(reset)
println(yellow + "-".repeat(33) + "Output" + "-".repeat(33) + reset + "\n")
}
fun main() {
print_day_9()
Day9().part_1()
Day9().part_2()
println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}
class Day9 {
data class Point(val x:Int, val y:Int) {
fun neighbours(xBoundary: Int, yBoundary: Int): List<Point> =
listOf(Point(x-1, y), Point(x+1, y), Point(x, y-1), Point(x, y+1) ).filter {
it.x in 0 until xBoundary && it.y in 0 until yBoundary
}
}
val heightmap = File("../Input/day9.txt").readLines().map { it.toCharArray().map { c -> c.digitToInt() } }
fun part_1() {
val total = heightmap.foldIndexed(0) { yIndex, acc, list ->
list.foldIndexed(acc) { xIndex, sum, height ->
if (Point(xIndex, yIndex).neighbours(heightmap[0].size, heightmap.size).count { heightmap[it.y][it.x] <= height } == 0)
sum + heightmap[yIndex][xIndex] + 1
else sum
}
}
println("Puzzle 1: $total")
}
fun part_2() {
fun getLowPoints() = heightmap.flatMapIndexed { yIndex, list ->
list.mapIndexed { xIndex, height ->
val smallerNeighbours = Point(xIndex, yIndex).neighbours(heightmap[0].size, heightmap.size).count { heightmap[it.y][it.x] <= height }
if (smallerNeighbours == 0) Point(xIndex, yIndex) else null
}.filterNotNull()
}
fun getBasinSize(p: Point): Int {
val visited = mutableSetOf(p)
val queue = mutableListOf(p)
while (queue.isNotEmpty()) {
val newNeighbors = queue.removeFirst()
.neighbours(heightmap[0].size, heightmap.size)
.filter { it !in visited }
.filter { heightmap[it.y][it.x] != 9 }
visited.addAll(newNeighbors)
queue.addAll(newNeighbors)
}
return visited.size
}
val answer = getLowPoints().map { getBasinSize(it) }
.sortedDescending()
.take(3)
.reduce { total, next -> total * next }
println("Puzzle 2: $answer")
}
}
|
[
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day09Kt.class",
"javap": "Compiled from \"day09.kt\"\npublic final class Day09Kt {\n public static final void print_day_9();\n Code:\n 0: ldc #8 // String \\u001b[33m\n 2: astore_0\n 3: ldc #10 // String \\u001b[0m\n 5: astore_1\n 6: ldc #12 // String \\u001b[32m\n 8: astore_2\n 9: new #14 // class java/lang/StringBuilder\n 12: dup\n 13: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 16: aload_0\n 17: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: ldc #23 // String -\n 22: checkcast #25 // class java/lang/CharSequence\n 25: bipush 25\n 27: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 30: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 33: ldc #33 // String Advent of Code - Day 9\n 35: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 38: ldc #23 // String -\n 40: checkcast #25 // class java/lang/CharSequence\n 43: bipush 25\n 45: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 48: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: aload_1\n 52: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 55: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 58: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 61: swap\n 62: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 65: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: aload_2\n 69: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: invokestatic #55 // Method java/lang/Runtime.getRuntime:()Ljava/lang/Runtime;\n 75: ldc #57 // String figlet Smoke Basin -c -f small\n 77: invokevirtual #61 // Method java/lang/Runtime.exec:(Ljava/lang/String;)Ljava/lang/Process;\n 80: astore_3\n 81: new #63 // class java/io/BufferedReader\n 84: dup\n 85: new #65 // class java/io/InputStreamReader\n 88: dup\n 89: aload_3\n 90: invokevirtual #71 // Method java/lang/Process.getInputStream:()Ljava/io/InputStream;\n 93: invokespecial #74 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;)V\n 96: checkcast #76 // class java/io/Reader\n 99: invokespecial #79 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;)V\n 102: astore 4\n 104: aload 4\n 106: checkcast #76 // class java/io/Reader\n 109: invokedynamic #98, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 114: invokestatic #104 // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V\n 117: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 120: aload_1\n 121: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 124: new #14 // class java/lang/StringBuilder\n 127: dup\n 128: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 131: aload_0\n 132: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 135: ldc #23 // String -\n 137: checkcast #25 // class java/lang/CharSequence\n 140: bipush 33\n 142: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 145: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 148: ldc #106 // String Output\n 150: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 153: ldc #23 // String -\n 155: checkcast #25 // class java/lang/CharSequence\n 158: bipush 33\n 160: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 163: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 166: aload_1\n 167: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 170: bipush 10\n 172: invokevirtual #109 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 175: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 178: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 181: swap\n 182: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 185: return\n\n public static final void main();\n Code:\n 0: invokestatic #120 // Method print_day_9:()V\n 3: new #122 // class Day9\n 6: dup\n 7: invokespecial #123 // Method Day9.\"<init>\":()V\n 10: invokevirtual #126 // Method Day9.part_1:()V\n 13: new #122 // class Day9\n 16: dup\n 17: invokespecial #123 // Method Day9.\"<init>\":()V\n 20: invokevirtual #129 // Method Day9.part_2:()V\n 23: new #14 // class java/lang/StringBuilder\n 26: dup\n 27: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 30: ldc #131 // String \\n\\u001b[33m\n 32: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 35: ldc #133 // String =\n 37: checkcast #25 // class java/lang/CharSequence\n 40: bipush 72\n 42: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 45: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: ldc #135 // String \\u001b[0m\\n\n 50: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 53: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 56: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 59: swap\n 60: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 63: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #138 // Method main:()V\n 3: return\n\n private static final kotlin.Unit print_day_9$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #142 // String it\n 3: invokestatic #148 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: aload_0\n 10: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 13: getstatic #154 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 16: areturn\n}\n",
"javap_err": ""
}
] |
Ad0lphus__AOC2021__02f219e/day08/Kotlin/day08.kt
|
import java.io.*
fun print_day_8() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 8" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Seven Segment Search -c -f small")
val reader = BufferedReader(InputStreamReader(process.inputStream))
reader.forEachLine { println(it) }
println(reset)
println(yellow + "-".repeat(33) + "Output" + "-".repeat(33) + reset + "\n")
}
fun main() {
print_day_8()
Day8().part_1()
Day8().part_2()
println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}
class Day8 {
private val lines = File("../Input/day8.txt").readLines().map { it.split("|")[0].trim() to it.split("|")[1].trim() }
fun part_1() {
val uniqueLengths = listOf(2, 3, 4, 7)
var totalUnique = 0
for((_, output) in lines) {
output.split(" ").forEach {
if(it.length in uniqueLengths) totalUnique++
}
}
println("Puzzle 1: " + totalUnique)
}
fun part_2() {
var total = 0
for((input, output) in lines) {
val displays = mutableMapOf<String, Int>()
val inputs = input.split(" ").map{ it.sortChars() }
val one = inputs.first { it.length == 2 }
val four = inputs.first { it.length == 4 }
val seven = inputs.first { it.length == 3 }
val eight = inputs.first { it.length == 7 }
val nine = inputs.first { it.length == 6 && it.containsAll(four) }
displays[one] = 1
displays[four] = 4
displays[seven] = 7
displays[eight] = 8
displays[nine] = 9
displays[inputs.first { it.length == 6 && it.containsAll(seven) && !it.containsAll(four) }] = 0
displays[inputs.first { it.length == 6 && !it.containsAll(one) }] = 6
displays[inputs.first { it.length == 5 && it.containsAll(one) }] = 3
displays[inputs.first { it.length == 5 && !it.containsAll(one) && nine.containsAll(it) }] = 5
displays[inputs.first { it.length == 5 && !it.containsAll(one) && !nine.containsAll(it) }] = 2
total += output.split(" ").fold("") { number, outputVal ->
number + displays[outputVal.sortChars()].toString()
}.toInt()
}
println("Puzzle 2: " + total)
}
private fun String.sortChars() = this.toCharArray().sorted().joinToString("")
private fun String.containsAll(chars: String) = this.toList().containsAll(chars.toList())
}
|
[
{
"class_path": "Ad0lphus__AOC2021__02f219e/Day08Kt.class",
"javap": "Compiled from \"day08.kt\"\npublic final class Day08Kt {\n public static final void print_day_8();\n Code:\n 0: ldc #8 // String \\u001b[33m\n 2: astore_0\n 3: ldc #10 // String \\u001b[0m\n 5: astore_1\n 6: ldc #12 // String \\u001b[32m\n 8: astore_2\n 9: new #14 // class java/lang/StringBuilder\n 12: dup\n 13: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 16: aload_0\n 17: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: ldc #23 // String -\n 22: checkcast #25 // class java/lang/CharSequence\n 25: bipush 25\n 27: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 30: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 33: ldc #33 // String Advent of Code - Day 8\n 35: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 38: ldc #23 // String -\n 40: checkcast #25 // class java/lang/CharSequence\n 43: bipush 25\n 45: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 48: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: aload_1\n 52: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 55: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 58: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 61: swap\n 62: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 65: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: aload_2\n 69: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: invokestatic #55 // Method java/lang/Runtime.getRuntime:()Ljava/lang/Runtime;\n 75: ldc #57 // String figlet Seven Segment Search -c -f small\n 77: invokevirtual #61 // Method java/lang/Runtime.exec:(Ljava/lang/String;)Ljava/lang/Process;\n 80: astore_3\n 81: new #63 // class java/io/BufferedReader\n 84: dup\n 85: new #65 // class java/io/InputStreamReader\n 88: dup\n 89: aload_3\n 90: invokevirtual #71 // Method java/lang/Process.getInputStream:()Ljava/io/InputStream;\n 93: invokespecial #74 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;)V\n 96: checkcast #76 // class java/io/Reader\n 99: invokespecial #79 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;)V\n 102: astore 4\n 104: aload 4\n 106: checkcast #76 // class java/io/Reader\n 109: invokedynamic #98, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 114: invokestatic #104 // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V\n 117: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 120: aload_1\n 121: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 124: new #14 // class java/lang/StringBuilder\n 127: dup\n 128: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 131: aload_0\n 132: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 135: ldc #23 // String -\n 137: checkcast #25 // class java/lang/CharSequence\n 140: bipush 33\n 142: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 145: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 148: ldc #106 // String Output\n 150: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 153: ldc #23 // String -\n 155: checkcast #25 // class java/lang/CharSequence\n 158: bipush 33\n 160: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 163: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 166: aload_1\n 167: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 170: bipush 10\n 172: invokevirtual #109 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 175: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 178: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 181: swap\n 182: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 185: return\n\n public static final void main();\n Code:\n 0: invokestatic #120 // Method print_day_8:()V\n 3: new #122 // class Day8\n 6: dup\n 7: invokespecial #123 // Method Day8.\"<init>\":()V\n 10: invokevirtual #126 // Method Day8.part_1:()V\n 13: new #122 // class Day8\n 16: dup\n 17: invokespecial #123 // Method Day8.\"<init>\":()V\n 20: invokevirtual #129 // Method Day8.part_2:()V\n 23: new #14 // class java/lang/StringBuilder\n 26: dup\n 27: invokespecial #17 // Method java/lang/StringBuilder.\"<init>\":()V\n 30: ldc #131 // String \\n\\u001b[33m\n 32: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 35: ldc #133 // String =\n 37: checkcast #25 // class java/lang/CharSequence\n 40: bipush 72\n 42: invokestatic #31 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 45: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: ldc #135 // String \\u001b[0m\\n\n 50: invokevirtual #21 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 53: invokevirtual #37 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 56: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 59: swap\n 60: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 63: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #138 // Method main:()V\n 3: return\n\n private static final kotlin.Unit print_day_8$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #142 // String it\n 3: invokestatic #148 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: aload_0\n 10: invokevirtual #49 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 13: getstatic #154 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 16: areturn\n}\n",
"javap_err": ""
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.