kt_path
stringlengths 35
167
| kt_source
stringlengths 626
28.9k
| classes
listlengths 1
17
|
|---|---|---|
iam-abbas__cs-algorithms__d04aa8f/Kotlin/merge_sort_in_kotlin.kt
|
fun merge(A: Array<Int>, p: Int, q: Int, r: Int) {
var left = A.copyOfRange(p, q + 1)
var right = A.copyOfRange(q + 1, r + 1)
var i = 0
var j = 0
for (k in p..r) {
if ((i <= left.size - 1) && ((j >= right.size) || (left[i] <= right[j]))) {
A[k] = left[i];
i++;
} else {
A[k] = right[j];
j++;
}
}
}
fun merge_sort(A: Array<Int>, p: Int, r: Int) {
if (p < r) {
var q = (p + r) / 2
merge_sort(A, p, q)
merge_sort(A, q + 1, r)
merge(A, p, q, r)
}
}
fun main(arg: Array<String>) {
print("Enter no. of elements :")
var n = readLine()!!.toInt()
println("Enter elements : ")
var A = Array(n, { 0 })
for (i in 0 until n)
A[i] = readLine()!!.toInt()
merge_sort(A, 0, A.size - 1)
println("Sorted array is : ")
for (i in 0 until n)
print("${A[i]} ")
}
|
[
{
"class_path": "iam-abbas__cs-algorithms__d04aa8f/Merge_sort_in_kotlinKt.class",
"javap": "Compiled from \"merge_sort_in_kotlin.kt\"\npublic final class Merge_sort_in_kotlinKt {\n public static final void merge(java.lang.Integer[], int, int, int);\n Code:\n 0: aload_0\n 1: ldc #9 // String A\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iload_1\n 8: iload_2\n 9: iconst_1\n 10: iadd\n 11: invokestatic #21 // Method kotlin/collections/ArraysKt.copyOfRange:([Ljava/lang/Object;II)[Ljava/lang/Object;\n 14: checkcast #23 // class \"[Ljava/lang/Integer;\"\n 17: astore 4\n 19: aload_0\n 20: iload_2\n 21: iconst_1\n 22: iadd\n 23: iload_3\n 24: iconst_1\n 25: iadd\n 26: invokestatic #21 // Method kotlin/collections/ArraysKt.copyOfRange:([Ljava/lang/Object;II)[Ljava/lang/Object;\n 29: checkcast #23 // class \"[Ljava/lang/Integer;\"\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: iconst_0\n 38: istore 7\n 40: iload_1\n 41: istore 8\n 43: iload 8\n 45: iload_3\n 46: if_icmpgt 125\n 49: iload 6\n 51: aload 4\n 53: arraylength\n 54: iconst_1\n 55: isub\n 56: if_icmpgt 101\n 59: iload 7\n 61: aload 5\n 63: arraylength\n 64: if_icmpge 86\n 67: aload 4\n 69: iload 6\n 71: aaload\n 72: invokevirtual #29 // Method java/lang/Integer.intValue:()I\n 75: aload 5\n 77: iload 7\n 79: aaload\n 80: invokevirtual #29 // Method java/lang/Integer.intValue:()I\n 83: if_icmpgt 101\n 86: aload_0\n 87: iload 8\n 89: aload 4\n 91: iload 6\n 93: aaload\n 94: aastore\n 95: iinc 6, 1\n 98: goto 113\n 101: aload_0\n 102: iload 8\n 104: aload 5\n 106: iload 7\n 108: aaload\n 109: aastore\n 110: iinc 7, 1\n 113: iload 8\n 115: iload_3\n 116: if_icmpeq 125\n 119: iinc 8, 1\n 122: goto 49\n 125: return\n\n public static final void merge_sort(java.lang.Integer[], int, int);\n Code:\n 0: aload_0\n 1: ldc #9 // String A\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iload_1\n 7: iload_2\n 8: if_icmpge 38\n 11: iload_1\n 12: iload_2\n 13: iadd\n 14: iconst_2\n 15: idiv\n 16: istore_3\n 17: aload_0\n 18: iload_1\n 19: iload_3\n 20: invokestatic #42 // Method merge_sort:([Ljava/lang/Integer;II)V\n 23: aload_0\n 24: iload_3\n 25: iconst_1\n 26: iadd\n 27: iload_2\n 28: invokestatic #42 // Method merge_sort:([Ljava/lang/Integer;II)V\n 31: aload_0\n 32: iload_1\n 33: iload_3\n 34: iload_2\n 35: invokestatic #44 // Method merge:([Ljava/lang/Integer;III)V\n 38: return\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #48 // String arg\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #50 // String Enter no. of elements :\n 8: getstatic #56 // Field java/lang/System.out:Ljava/io/PrintStream;\n 11: swap\n 12: invokevirtual #62 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 15: invokestatic #68 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 18: dup\n 19: invokestatic #71 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 22: invokestatic #75 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 25: istore_1\n 26: ldc #77 // String Enter elements :\n 28: getstatic #56 // Field java/lang/System.out:Ljava/io/PrintStream;\n 31: swap\n 32: invokevirtual #80 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 35: iconst_0\n 36: istore_3\n 37: iload_1\n 38: istore 4\n 40: iload 4\n 42: anewarray #25 // class java/lang/Integer\n 45: astore 5\n 47: iload_3\n 48: iload 4\n 50: if_icmpge 71\n 53: iload_3\n 54: istore 6\n 56: aload 5\n 58: iload 6\n 60: iconst_0\n 61: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 64: aastore\n 65: iinc 3, 1\n 68: goto 47\n 71: aload 5\n 73: astore_2\n 74: iconst_0\n 75: istore_3\n 76: iload_1\n 77: istore 4\n 79: iload_3\n 80: iload 4\n 82: if_icmpge 107\n 85: aload_2\n 86: iload_3\n 87: invokestatic #68 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 90: dup\n 91: invokestatic #71 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 94: invokestatic #75 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 97: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 100: aastore\n 101: iinc 3, 1\n 104: goto 79\n 107: aload_2\n 108: iconst_0\n 109: aload_2\n 110: arraylength\n 111: iconst_1\n 112: isub\n 113: invokestatic #42 // Method merge_sort:([Ljava/lang/Integer;II)V\n 116: ldc #86 // String Sorted array is :\n 118: getstatic #56 // Field java/lang/System.out:Ljava/io/PrintStream;\n 121: swap\n 122: invokevirtual #80 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 125: iconst_0\n 126: istore_3\n 127: iload_1\n 128: istore 4\n 130: iload_3\n 131: iload 4\n 133: if_icmpge 173\n 136: new #88 // class java/lang/StringBuilder\n 139: dup\n 140: invokespecial #92 // Method java/lang/StringBuilder.\"<init>\":()V\n 143: aload_2\n 144: iload_3\n 145: aaload\n 146: invokevirtual #29 // Method java/lang/Integer.intValue:()I\n 149: invokevirtual #96 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 152: ldc #98 // String\n 154: invokevirtual #101 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 157: invokevirtual #104 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 160: getstatic #56 // Field java/lang/System.out:Ljava/io/PrintStream;\n 163: swap\n 164: invokevirtual #62 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 167: iinc 3, 1\n 170: goto 130\n 173: return\n}\n",
"javap_err": ""
}
] |
dliszewski__advent-of-code-2022__76d5eea/src/main/kotlin/Day02.kt
|
class Day02 {
fun part1(input: List<String>): Int {
return input.map { it.split(" ") }
.map { (opponentCode, myCode) -> HandShape.fromOpponentCode(opponentCode) to HandShape.fromElfCode(myCode) }
.sumOf { (opponentHandShape, myHandShape) -> HandScorer.score(opponentHandShape, myHandShape) }
}
fun part2(input: List<String>): Int {
return input.map { it.split(" ") }
.map { (opponentCode, command) -> HandShape.fromOpponentCode(opponentCode) to command }
.sumOf { (opponentHandShape, command) ->
HandScorer.score(
opponentHandShape,
HandShape.decodeHand(opponentHandShape, command)
)
}
}
object HandScorer {
fun score(opponentHand: HandShape, myHandShape: HandShape): Int {
return myHandShape.score + resultScore(opponentHand, myHandShape)
}
private fun resultScore(opponentHand: HandShape, myHandShape: HandShape): Int {
return when (opponentHand) {
myHandShape -> 3
HandShape.defeats[myHandShape] -> 6
else -> 0
}
}
}
enum class HandShape(val opponentCode: String, val elfCode: String, val score: Int) {
ROCK("A", "X", 1),
PAPER("B", "Y", 2),
SCISSORS("C", "Z", 3);
companion object {
val defeats = mapOf(
ROCK to SCISSORS,
PAPER to ROCK,
SCISSORS to PAPER
)
fun fromOpponentCode(code: String) = values().first { it.opponentCode == code }
fun fromElfCode(code: String) = values().first { it.elfCode == code }
fun decodeHand(opponentHand: HandShape, command: String): HandShape {
return when (command) {
"X" -> defeats[opponentHand]!!
"Y" -> opponentHand
"Z" -> defeats.entries.first { it.value == opponentHand }.key
else -> throw IllegalStateException()
}
}
}
}
}
|
[
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day02$HandShape.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class Day02$HandShape extends java.lang.Enum<Day02$HandShape> {\n public static final Day02$HandShape$Companion Companion;\n\n private final java.lang.String opponentCode;\n\n private final java.lang.String elfCode;\n\n private final int score;\n\n private static final java.util.Map<Day02$HandShape, Day02$HandShape> defeats;\n\n public static final Day02$HandShape ROCK;\n\n public static final Day02$HandShape PAPER;\n\n public static final Day02$HandShape SCISSORS;\n\n private static final Day02$HandShape[] $VALUES;\n\n private static final kotlin.enums.EnumEntries $ENTRIES;\n\n private Day02$HandShape(java.lang.String, java.lang.String, int);\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: invokespecial #11 // Method java/lang/Enum.\"<init>\":(Ljava/lang/String;I)V\n 6: aload_0\n 7: aload_3\n 8: putfield #15 // Field opponentCode:Ljava/lang/String;\n 11: aload_0\n 12: aload 4\n 14: putfield #18 // Field elfCode:Ljava/lang/String;\n 17: aload_0\n 18: iload 5\n 20: putfield #22 // Field score:I\n 23: return\n\n public final java.lang.String getOpponentCode();\n Code:\n 0: aload_0\n 1: getfield #15 // Field opponentCode:Ljava/lang/String;\n 4: areturn\n\n public final java.lang.String getElfCode();\n Code:\n 0: aload_0\n 1: getfield #18 // Field elfCode:Ljava/lang/String;\n 4: areturn\n\n public final int getScore();\n Code:\n 0: aload_0\n 1: getfield #22 // Field score:I\n 4: ireturn\n\n public static Day02$HandShape[] values();\n Code:\n 0: getstatic #38 // Field $VALUES:[LDay02$HandShape;\n 3: invokevirtual #44 // Method java/lang/Object.clone:()Ljava/lang/Object;\n 6: checkcast #45 // class \"[LDay02$HandShape;\"\n 9: areturn\n\n public static Day02$HandShape valueOf(java.lang.String);\n Code:\n 0: ldc #2 // class Day02$HandShape\n 2: aload_0\n 3: invokestatic #50 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;\n 6: checkcast #2 // class Day02$HandShape\n 9: areturn\n\n public static kotlin.enums.EnumEntries<Day02$HandShape> getEntries();\n Code:\n 0: getstatic #58 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 3: areturn\n\n private static final Day02$HandShape[] $values();\n Code:\n 0: iconst_3\n 1: anewarray #2 // class Day02$HandShape\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: getstatic #62 // Field ROCK:LDay02$HandShape;\n 10: aastore\n 11: aload_0\n 12: iconst_1\n 13: getstatic #65 // Field PAPER:LDay02$HandShape;\n 16: aastore\n 17: aload_0\n 18: iconst_2\n 19: getstatic #68 // Field SCISSORS:LDay02$HandShape;\n 22: aastore\n 23: aload_0\n 24: areturn\n\n public static final java.util.Map access$getDefeats$cp();\n Code:\n 0: getstatic #74 // Field defeats:Ljava/util/Map;\n 3: areturn\n\n static {};\n Code:\n 0: new #2 // class Day02$HandShape\n 3: dup\n 4: ldc #77 // String ROCK\n 6: iconst_0\n 7: ldc #79 // String A\n 9: ldc #81 // String X\n 11: iconst_1\n 12: invokespecial #83 // Method \"<init>\":(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;I)V\n 15: putstatic #62 // Field ROCK:LDay02$HandShape;\n 18: new #2 // class Day02$HandShape\n 21: dup\n 22: ldc #84 // String PAPER\n 24: iconst_1\n 25: ldc #86 // String B\n 27: ldc #88 // String Y\n 29: iconst_2\n 30: invokespecial #83 // Method \"<init>\":(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;I)V\n 33: putstatic #65 // Field PAPER:LDay02$HandShape;\n 36: new #2 // class Day02$HandShape\n 39: dup\n 40: ldc #89 // String SCISSORS\n 42: iconst_2\n 43: ldc #91 // String C\n 45: ldc #93 // String Z\n 47: iconst_3\n 48: invokespecial #83 // Method \"<init>\":(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;I)V\n 51: putstatic #68 // Field SCISSORS:LDay02$HandShape;\n 54: invokestatic #95 // Method $values:()[LDay02$HandShape;\n 57: putstatic #38 // Field $VALUES:[LDay02$HandShape;\n 60: getstatic #38 // Field $VALUES:[LDay02$HandShape;\n 63: checkcast #97 // class \"[Ljava/lang/Enum;\"\n 66: invokestatic #103 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;\n 69: putstatic #58 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 72: new #105 // class Day02$HandShape$Companion\n 75: dup\n 76: aconst_null\n 77: invokespecial #108 // Method Day02$HandShape$Companion.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 80: putstatic #112 // Field Companion:LDay02$HandShape$Companion;\n 83: iconst_3\n 84: anewarray #114 // class kotlin/Pair\n 87: astore_0\n 88: aload_0\n 89: iconst_0\n 90: getstatic #62 // Field ROCK:LDay02$HandShape;\n 93: getstatic #68 // Field SCISSORS:LDay02$HandShape;\n 96: invokestatic #120 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 99: aastore\n 100: aload_0\n 101: iconst_1\n 102: getstatic #65 // Field PAPER:LDay02$HandShape;\n 105: getstatic #62 // Field ROCK:LDay02$HandShape;\n 108: invokestatic #120 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 111: aastore\n 112: aload_0\n 113: iconst_2\n 114: getstatic #68 // Field SCISSORS:LDay02$HandShape;\n 117: getstatic #65 // Field PAPER:LDay02$HandShape;\n 120: invokestatic #120 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 123: aastore\n 124: aload_0\n 125: invokestatic #126 // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 128: putstatic #74 // Field defeats:Ljava/util/Map;\n 131: return\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day02$HandShape$Companion.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class Day02$HandShape$Companion {\n private Day02$HandShape$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final java.util.Map<Day02$HandShape, Day02$HandShape> getDefeats();\n Code:\n 0: invokestatic #19 // Method Day02$HandShape.access$getDefeats$cp:()Ljava/util/Map;\n 3: areturn\n\n public final Day02$HandShape fromOpponentCode(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #23 // String code\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: invokestatic #33 // Method Day02$HandShape.values:()[LDay02$HandShape;\n 9: astore_2\n 10: iconst_0\n 11: istore_3\n 12: iconst_0\n 13: istore 4\n 15: aload_2\n 16: arraylength\n 17: istore 5\n 19: iload 4\n 21: iload 5\n 23: if_icmpge 62\n 26: aload_2\n 27: iload 4\n 29: aaload\n 30: astore 6\n 32: aload 6\n 34: astore 7\n 36: iconst_0\n 37: istore 8\n 39: aload 7\n 41: invokevirtual #37 // Method Day02$HandShape.getOpponentCode:()Ljava/lang/String;\n 44: aload_1\n 45: invokestatic #41 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 48: ifeq 56\n 51: aload 6\n 53: goto 72\n 56: iinc 4, 1\n 59: goto 19\n 62: new #43 // class java/util/NoSuchElementException\n 65: dup\n 66: ldc #45 // String Array contains no element matching the predicate.\n 68: invokespecial #48 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 71: athrow\n 72: areturn\n\n public final Day02$HandShape fromElfCode(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #23 // String code\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: invokestatic #33 // Method Day02$HandShape.values:()[LDay02$HandShape;\n 9: astore_2\n 10: iconst_0\n 11: istore_3\n 12: iconst_0\n 13: istore 4\n 15: aload_2\n 16: arraylength\n 17: istore 5\n 19: iload 4\n 21: iload 5\n 23: if_icmpge 62\n 26: aload_2\n 27: iload 4\n 29: aaload\n 30: astore 6\n 32: aload 6\n 34: astore 7\n 36: iconst_0\n 37: istore 8\n 39: aload 7\n 41: invokevirtual #66 // Method Day02$HandShape.getElfCode:()Ljava/lang/String;\n 44: aload_1\n 45: invokestatic #41 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 48: ifeq 56\n 51: aload 6\n 53: goto 72\n 56: iinc 4, 1\n 59: goto 19\n 62: new #43 // class java/util/NoSuchElementException\n 65: dup\n 66: ldc #45 // String Array contains no element matching the predicate.\n 68: invokespecial #48 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 71: athrow\n 72: areturn\n\n public final Day02$HandShape decodeHand(Day02$HandShape, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #71 // String opponentHand\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #73 // String command\n 9: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_2\n 13: astore_3\n 14: aload_3\n 15: invokevirtual #77 // Method java/lang/String.hashCode:()I\n 18: tableswitch { // 88 to 90\n 88: 44\n 89: 56\n 90: 68\n default: 207\n }\n 44: aload_3\n 45: ldc #79 // String X\n 47: invokevirtual #83 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 50: ifne 80\n 53: goto 207\n 56: aload_3\n 57: ldc #85 // String Y\n 59: invokevirtual #83 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 62: ifne 100\n 65: goto 207\n 68: aload_3\n 69: ldc #87 // String Z\n 71: invokevirtual #83 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 74: ifne 104\n 77: goto 207\n 80: aload_0\n 81: invokevirtual #89 // Method getDefeats:()Ljava/util/Map;\n 84: aload_1\n 85: invokeinterface #95, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 90: dup\n 91: invokestatic #99 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 94: checkcast #16 // class Day02$HandShape\n 97: goto 215\n 100: aload_1\n 101: goto 215\n 104: aload_0\n 105: invokevirtual #89 // Method getDefeats:()Ljava/util/Map;\n 108: invokeinterface #103, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 113: checkcast #105 // class java/lang/Iterable\n 116: astore 4\n 118: iconst_0\n 119: istore 5\n 121: aload 4\n 123: invokeinterface #109, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 128: astore 6\n 130: aload 6\n 132: invokeinterface #115, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 137: ifeq 183\n 140: aload 6\n 142: invokeinterface #119, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 147: astore 7\n 149: aload 7\n 151: checkcast #121 // class java/util/Map$Entry\n 154: astore 8\n 156: iconst_0\n 157: istore 9\n 159: aload 8\n 161: invokeinterface #124, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 166: aload_1\n 167: if_acmpne 174\n 170: iconst_1\n 171: goto 175\n 174: iconst_0\n 175: ifeq 130\n 178: aload 7\n 180: goto 193\n 183: new #43 // class java/util/NoSuchElementException\n 186: dup\n 187: ldc #126 // String Collection contains no element matching the predicate.\n 189: invokespecial #48 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 192: athrow\n 193: checkcast #121 // class java/util/Map$Entry\n 196: invokeinterface #129, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 201: checkcast #16 // class Day02$HandShape\n 204: goto 215\n 207: new #131 // class java/lang/IllegalStateException\n 210: dup\n 211: invokespecial #132 // Method java/lang/IllegalStateException.\"<init>\":()V\n 214: athrow\n 215: areturn\n\n public Day02$HandShape$Companion(kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: invokespecial #137 // Method \"<init>\":()V\n 4: return\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day02$HandScorer.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class Day02$HandScorer {\n public static final Day02$HandScorer INSTANCE;\n\n private Day02$HandScorer();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int score(Day02$HandShape, Day02$HandShape);\n Code:\n 0: aload_1\n 1: ldc #15 // String opponentHand\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #23 // String myHandShape\n 9: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_2\n 13: invokevirtual #29 // Method Day02$HandShape.getScore:()I\n 16: aload_0\n 17: aload_1\n 18: aload_2\n 19: invokespecial #32 // Method resultScore:(LDay02$HandShape;LDay02$HandShape;)I\n 22: iadd\n 23: ireturn\n\n private final int resultScore(Day02$HandShape, Day02$HandShape);\n Code:\n 0: aload_1\n 1: astore_3\n 2: aload_3\n 3: aload_2\n 4: if_acmpne 11\n 7: iconst_3\n 8: goto 33\n 11: aload_3\n 12: getstatic #37 // Field Day02$HandShape.Companion:LDay02$HandShape$Companion;\n 15: invokevirtual #43 // Method Day02$HandShape$Companion.getDefeats:()Ljava/util/Map;\n 18: aload_2\n 19: invokeinterface #49, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 24: if_acmpne 32\n 27: bipush 6\n 29: goto 33\n 32: iconst_0\n 33: ireturn\n\n static {};\n Code:\n 0: new #2 // class Day02$HandScorer\n 3: dup\n 4: invokespecial #51 // Method \"<init>\":()V\n 7: putstatic #54 // Field INSTANCE:LDay02$HandScorer;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day02.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class Day02 {\n public Day02();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #24 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: astore 4\n 16: new #26 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: bipush 10\n 23: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #37 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: aload 4\n 39: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 7\n 46: aload 7\n 48: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 118\n 56: aload 7\n 58: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 8\n 65: aload 5\n 67: aload 8\n 69: checkcast #53 // class java/lang/String\n 72: astore 9\n 74: astore 13\n 76: iconst_0\n 77: istore 10\n 79: aload 9\n 81: checkcast #55 // class java/lang/CharSequence\n 84: iconst_1\n 85: anewarray #53 // class java/lang/String\n 88: astore 11\n 90: aload 11\n 92: iconst_0\n 93: ldc #57 // String\n 95: aastore\n 96: aload 11\n 98: iconst_0\n 99: iconst_0\n 100: bipush 6\n 102: aconst_null\n 103: invokestatic #63 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 106: aload 13\n 108: swap\n 109: invokeinterface #67, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 114: pop\n 115: goto 46\n 118: aload 5\n 120: checkcast #69 // class java/util/List\n 123: nop\n 124: checkcast #24 // class java/lang/Iterable\n 127: astore_2\n 128: nop\n 129: iconst_0\n 130: istore_3\n 131: aload_2\n 132: astore 4\n 134: new #26 // class java/util/ArrayList\n 137: dup\n 138: aload_2\n 139: bipush 10\n 141: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 144: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 147: checkcast #37 // class java/util/Collection\n 150: astore 5\n 152: iconst_0\n 153: istore 6\n 155: aload 4\n 157: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 162: astore 7\n 164: aload 7\n 166: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 171: ifeq 254\n 174: aload 7\n 176: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 181: astore 8\n 183: aload 5\n 185: aload 8\n 187: checkcast #69 // class java/util/List\n 190: astore 9\n 192: astore 13\n 194: iconst_0\n 195: istore 10\n 197: aload 9\n 199: iconst_0\n 200: invokeinterface #73, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 205: checkcast #53 // class java/lang/String\n 208: astore 11\n 210: aload 9\n 212: iconst_1\n 213: invokeinterface #73, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 218: checkcast #53 // class java/lang/String\n 221: astore 12\n 223: getstatic #79 // Field Day02$HandShape.Companion:LDay02$HandShape$Companion;\n 226: aload 11\n 228: invokevirtual #85 // Method Day02$HandShape$Companion.fromOpponentCode:(Ljava/lang/String;)LDay02$HandShape;\n 231: getstatic #79 // Field Day02$HandShape.Companion:LDay02$HandShape$Companion;\n 234: aload 12\n 236: invokevirtual #88 // Method Day02$HandShape$Companion.fromElfCode:(Ljava/lang/String;)LDay02$HandShape;\n 239: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 242: aload 13\n 244: swap\n 245: invokeinterface #67, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 250: pop\n 251: goto 164\n 254: aload 5\n 256: checkcast #69 // class java/util/List\n 259: nop\n 260: checkcast #24 // class java/lang/Iterable\n 263: astore_2\n 264: iconst_0\n 265: istore_3\n 266: aload_2\n 267: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 272: astore 4\n 274: aload 4\n 276: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 281: ifeq 347\n 284: aload 4\n 286: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 291: astore 5\n 293: iload_3\n 294: aload 5\n 296: checkcast #96 // class kotlin/Pair\n 299: astore 6\n 301: istore 13\n 303: iconst_0\n 304: istore 7\n 306: aload 6\n 308: invokevirtual #99 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 311: checkcast #75 // class Day02$HandShape\n 314: astore 8\n 316: aload 6\n 318: invokevirtual #102 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 321: checkcast #75 // class Day02$HandShape\n 324: astore 9\n 326: getstatic #108 // Field Day02$HandScorer.INSTANCE:LDay02$HandScorer;\n 329: aload 8\n 331: aload 9\n 333: invokevirtual #112 // Method Day02$HandScorer.score:(LDay02$HandShape;LDay02$HandShape;)I\n 336: istore 14\n 338: iload 13\n 340: iload 14\n 342: iadd\n 343: istore_3\n 344: goto 274\n 347: iload_3\n 348: ireturn\n\n public final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #24 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: astore 4\n 16: new #26 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: bipush 10\n 23: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #37 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: aload 4\n 39: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 7\n 46: aload 7\n 48: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 118\n 56: aload 7\n 58: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 8\n 65: aload 5\n 67: aload 8\n 69: checkcast #53 // class java/lang/String\n 72: astore 9\n 74: astore 13\n 76: iconst_0\n 77: istore 10\n 79: aload 9\n 81: checkcast #55 // class java/lang/CharSequence\n 84: iconst_1\n 85: anewarray #53 // class java/lang/String\n 88: astore 11\n 90: aload 11\n 92: iconst_0\n 93: ldc #57 // String\n 95: aastore\n 96: aload 11\n 98: iconst_0\n 99: iconst_0\n 100: bipush 6\n 102: aconst_null\n 103: invokestatic #63 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 106: aload 13\n 108: swap\n 109: invokeinterface #67, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 114: pop\n 115: goto 46\n 118: aload 5\n 120: checkcast #69 // class java/util/List\n 123: nop\n 124: checkcast #24 // class java/lang/Iterable\n 127: astore_2\n 128: nop\n 129: iconst_0\n 130: istore_3\n 131: aload_2\n 132: astore 4\n 134: new #26 // class java/util/ArrayList\n 137: dup\n 138: aload_2\n 139: bipush 10\n 141: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 144: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 147: checkcast #37 // class java/util/Collection\n 150: astore 5\n 152: iconst_0\n 153: istore 6\n 155: aload 4\n 157: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 162: astore 7\n 164: aload 7\n 166: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 171: ifeq 248\n 174: aload 7\n 176: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 181: astore 8\n 183: aload 5\n 185: aload 8\n 187: checkcast #69 // class java/util/List\n 190: astore 9\n 192: astore 13\n 194: iconst_0\n 195: istore 10\n 197: aload 9\n 199: iconst_0\n 200: invokeinterface #73, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 205: checkcast #53 // class java/lang/String\n 208: astore 11\n 210: aload 9\n 212: iconst_1\n 213: invokeinterface #73, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 218: checkcast #53 // class java/lang/String\n 221: astore 12\n 223: getstatic #79 // Field Day02$HandShape.Companion:LDay02$HandShape$Companion;\n 226: aload 11\n 228: invokevirtual #85 // Method Day02$HandShape$Companion.fromOpponentCode:(Ljava/lang/String;)LDay02$HandShape;\n 231: aload 12\n 233: invokestatic #94 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 236: aload 13\n 238: swap\n 239: invokeinterface #67, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 244: pop\n 245: goto 164\n 248: aload 5\n 250: checkcast #69 // class java/util/List\n 253: nop\n 254: checkcast #24 // class java/lang/Iterable\n 257: astore_2\n 258: iconst_0\n 259: istore_3\n 260: aload_2\n 261: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 266: astore 4\n 268: aload 4\n 270: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 275: ifeq 350\n 278: aload 4\n 280: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 285: astore 5\n 287: iload_3\n 288: aload 5\n 290: checkcast #96 // class kotlin/Pair\n 293: astore 6\n 295: istore 13\n 297: iconst_0\n 298: istore 7\n 300: aload 6\n 302: invokevirtual #99 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 305: checkcast #75 // class Day02$HandShape\n 308: astore 8\n 310: aload 6\n 312: invokevirtual #102 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 315: checkcast #53 // class java/lang/String\n 318: astore 9\n 320: getstatic #108 // Field Day02$HandScorer.INSTANCE:LDay02$HandScorer;\n 323: aload 8\n 325: getstatic #79 // Field Day02$HandShape.Companion:LDay02$HandShape$Companion;\n 328: aload 8\n 330: aload 9\n 332: invokevirtual #138 // Method Day02$HandShape$Companion.decodeHand:(LDay02$HandShape;Ljava/lang/String;)LDay02$HandShape;\n 335: invokevirtual #112 // Method Day02$HandScorer.score:(LDay02$HandShape;LDay02$HandShape;)I\n 338: nop\n 339: istore 14\n 341: iload 13\n 343: iload 14\n 345: iadd\n 346: istore_3\n 347: goto 268\n 350: iload_3\n 351: ireturn\n}\n",
"javap_err": ""
}
] |
dliszewski__advent-of-code-2022__76d5eea/src/main/kotlin/Day15.kt
|
import kotlin.math.abs
class Day15 {
fun part1(input: List<String>, lookupRow: Int): Int {
val sensors = mapToSensors(input)
val minRange = sensors.minOf { sensor ->
minOf(
sensor.position.x,
sensor.beacon.x,
sensor.position.x - sensor.distanceToBeacon()
)
}
val maxRange = sensors.maxOf { sensor ->
maxOf(
sensor.position.x,
sensor.beacon.x,
sensor.position.x + sensor.distanceToBeacon()
)
}
return (minRange..maxRange).count { x ->
val point = Point(x, lookupRow)
sensors.any { sensor -> sensor.beacon != point && sensor.position.distance(point) <= sensor.distanceToBeacon() }
}
}
fun part2(input: List<String>, limit: Int): Long {
val sensors = mapToSensors(input)
val pointNotCovered = findPositionNotCoveredByBeacon(limit, sensors)
return pointNotCovered.x.toLong() * 4000000 + pointNotCovered.y.toLong()
}
private fun findPositionNotCoveredByBeacon(limit: Int, sensors: List<Sensor>): Point {
for (y in 0..limit) {
var point = Point(0, y)
while (point.x <= limit) {
val coveredBySensor = pointCoveredBySensor(sensors, point)
if (coveredBySensor == null) {
return point
} else {
val maxCovered = coveredBySensor.maxDistanceCovered(point.y)
point = Point(maxCovered.x + 1, maxCovered.y)
}
}
}
error("Should find one...")
}
private fun pointCoveredBySensor(sensors: List<Sensor>, point: Point): Sensor? {
return sensors.find { it.isInRange(point) }
}
private fun mapToSensors(input: List<String>) =
input.map { it.split(": closest beacon is at ") }
.map { (point1, point2) ->
Sensor(
point1.substringAfter("Sensor at ").mapToPoint(),
point2.mapToPoint()
)
}
data class Sensor(val position: Point, val beacon: Point) {
fun distanceToBeacon(): Int {
return position.distance(beacon)
}
fun isInRange(other: Point): Boolean {
return position.distance(other) <= position.distance(beacon)
}
fun maxDistanceCovered(row: Int): Point {
return Point(position.x + abs(distanceToBeacon() - abs(row - position.y)), row)
}
}
data class Point(val x: Int, val y: Int) {
fun distance(other: Point): Int {
return abs(other.x - x) + abs(other.y - y)
}
}
private fun String.mapToPoint(): Point {
val (x, y) = split(", ")
return Point(x.substringAfter("x=").toInt(), y.substringAfter("y=").toInt())
}
}
|
[
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/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 int part1(java.util.List<java.lang.String>, int);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokespecial #26 // Method mapToSensors:(Ljava/util/List;)Ljava/util/List;\n 11: astore_3\n 12: aload_3\n 13: checkcast #28 // class java/lang/Iterable\n 16: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 21: astore 6\n 23: aload 6\n 25: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 30: ifne 41\n 33: new #40 // class java/util/NoSuchElementException\n 36: dup\n 37: invokespecial #41 // Method java/util/NoSuchElementException.\"<init>\":()V\n 40: athrow\n 41: aload 6\n 43: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 48: checkcast #47 // class Day15$Sensor\n 51: astore 7\n 53: iconst_0\n 54: istore 8\n 56: nop\n 57: aload 7\n 59: invokevirtual #51 // Method Day15$Sensor.getPosition:()LDay15$Point;\n 62: invokevirtual #57 // Method Day15$Point.getX:()I\n 65: aload 7\n 67: invokevirtual #60 // Method Day15$Sensor.getBeacon:()LDay15$Point;\n 70: invokevirtual #57 // Method Day15$Point.getX:()I\n 73: aload 7\n 75: invokevirtual #51 // Method Day15$Sensor.getPosition:()LDay15$Point;\n 78: invokevirtual #57 // Method Day15$Point.getX:()I\n 81: aload 7\n 83: invokevirtual #63 // Method Day15$Sensor.distanceToBeacon:()I\n 86: isub\n 87: invokestatic #69 // Method java/lang/Math.min:(II)I\n 90: invokestatic #69 // Method java/lang/Math.min:(II)I\n 93: nop\n 94: istore 7\n 96: aload 6\n 98: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 103: ifeq 175\n 106: aload 6\n 108: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 113: checkcast #47 // class Day15$Sensor\n 116: astore 8\n 118: iconst_0\n 119: istore 9\n 121: nop\n 122: aload 8\n 124: invokevirtual #51 // Method Day15$Sensor.getPosition:()LDay15$Point;\n 127: invokevirtual #57 // Method Day15$Point.getX:()I\n 130: aload 8\n 132: invokevirtual #60 // Method Day15$Sensor.getBeacon:()LDay15$Point;\n 135: invokevirtual #57 // Method Day15$Point.getX:()I\n 138: aload 8\n 140: invokevirtual #51 // Method Day15$Sensor.getPosition:()LDay15$Point;\n 143: invokevirtual #57 // Method Day15$Point.getX:()I\n 146: aload 8\n 148: invokevirtual #63 // Method Day15$Sensor.distanceToBeacon:()I\n 151: isub\n 152: invokestatic #69 // Method java/lang/Math.min:(II)I\n 155: invokestatic #69 // Method java/lang/Math.min:(II)I\n 158: nop\n 159: istore 8\n 161: iload 7\n 163: iload 8\n 165: if_icmple 96\n 168: iload 8\n 170: istore 7\n 172: goto 96\n 175: iload 7\n 177: istore 4\n 179: aload_3\n 180: checkcast #28 // class java/lang/Iterable\n 183: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 188: astore 7\n 190: aload 7\n 192: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 197: ifne 208\n 200: new #40 // class java/util/NoSuchElementException\n 203: dup\n 204: invokespecial #41 // Method java/util/NoSuchElementException.\"<init>\":()V\n 207: athrow\n 208: aload 7\n 210: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 215: checkcast #47 // class Day15$Sensor\n 218: astore 8\n 220: iconst_0\n 221: istore 9\n 223: nop\n 224: aload 8\n 226: invokevirtual #51 // Method Day15$Sensor.getPosition:()LDay15$Point;\n 229: invokevirtual #57 // Method Day15$Point.getX:()I\n 232: aload 8\n 234: invokevirtual #60 // Method Day15$Sensor.getBeacon:()LDay15$Point;\n 237: invokevirtual #57 // Method Day15$Point.getX:()I\n 240: aload 8\n 242: invokevirtual #51 // Method Day15$Sensor.getPosition:()LDay15$Point;\n 245: invokevirtual #57 // Method Day15$Point.getX:()I\n 248: aload 8\n 250: invokevirtual #63 // Method Day15$Sensor.distanceToBeacon:()I\n 253: iadd\n 254: invokestatic #72 // Method java/lang/Math.max:(II)I\n 257: invokestatic #72 // Method java/lang/Math.max:(II)I\n 260: nop\n 261: istore 8\n 263: aload 7\n 265: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 270: ifeq 342\n 273: aload 7\n 275: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 280: checkcast #47 // class Day15$Sensor\n 283: astore 9\n 285: iconst_0\n 286: istore 10\n 288: nop\n 289: aload 9\n 291: invokevirtual #51 // Method Day15$Sensor.getPosition:()LDay15$Point;\n 294: invokevirtual #57 // Method Day15$Point.getX:()I\n 297: aload 9\n 299: invokevirtual #60 // Method Day15$Sensor.getBeacon:()LDay15$Point;\n 302: invokevirtual #57 // Method Day15$Point.getX:()I\n 305: aload 9\n 307: invokevirtual #51 // Method Day15$Sensor.getPosition:()LDay15$Point;\n 310: invokevirtual #57 // Method Day15$Point.getX:()I\n 313: aload 9\n 315: invokevirtual #63 // Method Day15$Sensor.distanceToBeacon:()I\n 318: iadd\n 319: invokestatic #72 // Method java/lang/Math.max:(II)I\n 322: invokestatic #72 // Method java/lang/Math.max:(II)I\n 325: nop\n 326: istore 9\n 328: iload 8\n 330: iload 9\n 332: if_icmpge 263\n 335: iload 9\n 337: istore 8\n 339: goto 263\n 342: iload 8\n 344: istore 5\n 346: new #74 // class kotlin/ranges/IntRange\n 349: dup\n 350: iload 4\n 352: iload 5\n 354: invokespecial #77 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 357: checkcast #28 // class java/lang/Iterable\n 360: astore 6\n 362: iconst_0\n 363: istore 7\n 365: aload 6\n 367: instanceof #79 // class java/util/Collection\n 370: ifeq 390\n 373: aload 6\n 375: checkcast #79 // class java/util/Collection\n 378: invokeinterface #82, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 383: ifeq 390\n 386: iconst_0\n 387: goto 577\n 390: iconst_0\n 391: istore 8\n 393: aload 6\n 395: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 400: astore 9\n 402: aload 9\n 404: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 409: ifeq 575\n 412: aload 9\n 414: checkcast #84 // class kotlin/collections/IntIterator\n 417: invokevirtual #87 // Method kotlin/collections/IntIterator.nextInt:()I\n 420: istore 10\n 422: iload 10\n 424: istore 11\n 426: iconst_0\n 427: istore 12\n 429: new #53 // class Day15$Point\n 432: dup\n 433: iload 11\n 435: iload_2\n 436: invokespecial #88 // Method Day15$Point.\"<init>\":(II)V\n 439: astore 13\n 441: aload_3\n 442: checkcast #28 // class java/lang/Iterable\n 445: astore 14\n 447: iconst_0\n 448: istore 15\n 450: aload 14\n 452: instanceof #79 // class java/util/Collection\n 455: ifeq 475\n 458: aload 14\n 460: checkcast #79 // class java/util/Collection\n 463: invokeinterface #82, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 468: ifeq 475\n 471: iconst_0\n 472: goto 557\n 475: aload 14\n 477: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 482: astore 16\n 484: aload 16\n 486: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 491: ifeq 556\n 494: aload 16\n 496: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 501: astore 17\n 503: aload 17\n 505: checkcast #47 // class Day15$Sensor\n 508: astore 18\n 510: iconst_0\n 511: istore 19\n 513: aload 18\n 515: invokevirtual #60 // Method Day15$Sensor.getBeacon:()LDay15$Point;\n 518: aload 13\n 520: invokestatic #92 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 523: ifne 548\n 526: aload 18\n 528: invokevirtual #51 // Method Day15$Sensor.getPosition:()LDay15$Point;\n 531: aload 13\n 533: invokevirtual #96 // Method Day15$Point.distance:(LDay15$Point;)I\n 536: aload 18\n 538: invokevirtual #63 // Method Day15$Sensor.distanceToBeacon:()I\n 541: if_icmpgt 548\n 544: iconst_1\n 545: goto 549\n 548: iconst_0\n 549: ifeq 484\n 552: iconst_1\n 553: goto 557\n 556: iconst_0\n 557: nop\n 558: ifeq 402\n 561: iinc 8, 1\n 564: iload 8\n 566: ifge 402\n 569: invokestatic #101 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 572: goto 402\n 575: iload 8\n 577: ireturn\n\n public final long part2(java.util.List<java.lang.String>, int);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokespecial #26 // Method mapToSensors:(Ljava/util/List;)Ljava/util/List;\n 11: astore_3\n 12: aload_0\n 13: iload_2\n 14: aload_3\n 15: invokespecial #133 // Method findPositionNotCoveredByBeacon:(ILjava/util/List;)LDay15$Point;\n 18: astore 4\n 20: aload 4\n 22: invokevirtual #57 // Method Day15$Point.getX:()I\n 25: i2l\n 26: ldc #134 // int 4000000\n 28: i2l\n 29: lmul\n 30: aload 4\n 32: invokevirtual #137 // Method Day15$Point.getY:()I\n 35: i2l\n 36: ladd\n 37: lreturn\n\n private final Day15$Point findPositionNotCoveredByBeacon(int, java.util.List<Day15$Sensor>);\n Code:\n 0: iconst_0\n 1: istore_3\n 2: iload_3\n 3: iload_1\n 4: if_icmpgt 91\n 7: new #53 // class Day15$Point\n 10: dup\n 11: iconst_0\n 12: iload_3\n 13: invokespecial #88 // Method Day15$Point.\"<init>\":(II)V\n 16: astore 4\n 18: aload 4\n 20: invokevirtual #57 // Method Day15$Point.getX:()I\n 23: iload_1\n 24: if_icmpgt 80\n 27: aload_0\n 28: aload_2\n 29: aload 4\n 31: invokespecial #144 // Method pointCoveredBySensor:(Ljava/util/List;LDay15$Point;)LDay15$Sensor;\n 34: astore 5\n 36: aload 5\n 38: ifnonnull 44\n 41: aload 4\n 43: areturn\n 44: aload 5\n 46: aload 4\n 48: invokevirtual #137 // Method Day15$Point.getY:()I\n 51: invokevirtual #148 // Method Day15$Sensor.maxDistanceCovered:(I)LDay15$Point;\n 54: astore 6\n 56: new #53 // class Day15$Point\n 59: dup\n 60: aload 6\n 62: invokevirtual #57 // Method Day15$Point.getX:()I\n 65: iconst_1\n 66: iadd\n 67: aload 6\n 69: invokevirtual #137 // Method Day15$Point.getY:()I\n 72: invokespecial #88 // Method Day15$Point.\"<init>\":(II)V\n 75: astore 4\n 77: goto 18\n 80: iload_3\n 81: iload_1\n 82: if_icmpeq 91\n 85: iinc 3, 1\n 88: goto 7\n 91: new #150 // class java/lang/IllegalStateException\n 94: dup\n 95: ldc #152 // String Should find one...\n 97: invokevirtual #156 // Method java/lang/Object.toString:()Ljava/lang/String;\n 100: invokespecial #159 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 103: athrow\n\n private final Day15$Sensor pointCoveredBySensor(java.util.List<Day15$Sensor>, Day15$Point);\n Code:\n 0: aload_1\n 1: checkcast #28 // class java/lang/Iterable\n 4: astore_3\n 5: aload_3\n 6: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 11: astore 4\n 13: aload 4\n 15: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 20: ifeq 56\n 23: aload 4\n 25: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 30: astore 5\n 32: aload 5\n 34: checkcast #47 // class Day15$Sensor\n 37: astore 6\n 39: iconst_0\n 40: istore 7\n 42: aload 6\n 44: aload_2\n 45: invokevirtual #167 // Method Day15$Sensor.isInRange:(LDay15$Point;)Z\n 48: ifeq 13\n 51: aload 5\n 53: goto 57\n 56: aconst_null\n 57: checkcast #47 // class Day15$Sensor\n 60: areturn\n\n private final java.util.List<Day15$Sensor> mapToSensors(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #28 // 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 #172 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: bipush 10\n 17: invokestatic #176 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #179 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #79 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 4\n 33: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 7\n 40: aload 7\n 42: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 112\n 50: aload 7\n 52: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 8\n 59: aload 5\n 61: aload 8\n 63: checkcast #181 // class java/lang/String\n 66: astore 9\n 68: astore 13\n 70: iconst_0\n 71: istore 10\n 73: aload 9\n 75: checkcast #183 // class java/lang/CharSequence\n 78: iconst_1\n 79: anewarray #181 // class java/lang/String\n 82: astore 11\n 84: aload 11\n 86: iconst_0\n 87: ldc #185 // String : closest beacon is at\n 89: aastore\n 90: aload 11\n 92: iconst_0\n 93: iconst_0\n 94: bipush 6\n 96: aconst_null\n 97: invokestatic #191 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 100: aload 13\n 102: swap\n 103: invokeinterface #195, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 108: pop\n 109: goto 40\n 112: aload 5\n 114: checkcast #126 // class java/util/List\n 117: nop\n 118: checkcast #28 // class java/lang/Iterable\n 121: astore_2\n 122: nop\n 123: iconst_0\n 124: istore_3\n 125: aload_2\n 126: astore 4\n 128: new #172 // class java/util/ArrayList\n 131: dup\n 132: aload_2\n 133: bipush 10\n 135: invokestatic #176 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 138: invokespecial #179 // Method java/util/ArrayList.\"<init>\":(I)V\n 141: checkcast #79 // class java/util/Collection\n 144: astore 5\n 146: iconst_0\n 147: istore 6\n 149: aload 4\n 151: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 156: astore 7\n 158: aload 7\n 160: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 165: ifeq 257\n 168: aload 7\n 170: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 175: astore 8\n 177: aload 5\n 179: aload 8\n 181: checkcast #126 // class java/util/List\n 184: astore 9\n 186: astore 13\n 188: iconst_0\n 189: istore 10\n 191: aload 9\n 193: iconst_0\n 194: invokeinterface #199, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 199: checkcast #181 // class java/lang/String\n 202: astore 11\n 204: aload 9\n 206: iconst_1\n 207: invokeinterface #199, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 212: checkcast #181 // class java/lang/String\n 215: astore 12\n 217: new #47 // class Day15$Sensor\n 220: dup\n 221: aload_0\n 222: aload 11\n 224: ldc #201 // String Sensor at\n 226: aconst_null\n 227: iconst_2\n 228: aconst_null\n 229: invokestatic #205 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 232: invokespecial #209 // Method mapToPoint:(Ljava/lang/String;)LDay15$Point;\n 235: aload_0\n 236: aload 12\n 238: invokespecial #209 // Method mapToPoint:(Ljava/lang/String;)LDay15$Point;\n 241: invokespecial #212 // Method Day15$Sensor.\"<init>\":(LDay15$Point;LDay15$Point;)V\n 244: nop\n 245: aload 13\n 247: swap\n 248: invokeinterface #195, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 253: pop\n 254: goto 158\n 257: aload 5\n 259: checkcast #126 // class java/util/List\n 262: nop\n 263: areturn\n\n private final Day15$Point mapToPoint(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #183 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #181 // class java/lang/String\n 8: astore_3\n 9: aload_3\n 10: iconst_0\n 11: ldc #226 // String ,\n 13: aastore\n 14: aload_3\n 15: iconst_0\n 16: iconst_0\n 17: bipush 6\n 19: aconst_null\n 20: invokestatic #191 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 23: astore_2\n 24: aload_2\n 25: iconst_0\n 26: invokeinterface #199, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 31: checkcast #181 // class java/lang/String\n 34: astore_3\n 35: aload_2\n 36: iconst_1\n 37: invokeinterface #199, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 42: checkcast #181 // class java/lang/String\n 45: astore 4\n 47: new #53 // class Day15$Point\n 50: dup\n 51: aload_3\n 52: ldc #228 // String x=\n 54: aconst_null\n 55: iconst_2\n 56: aconst_null\n 57: invokestatic #205 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 60: invokestatic #234 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 63: aload 4\n 65: ldc #236 // String y=\n 67: aconst_null\n 68: iconst_2\n 69: aconst_null\n 70: invokestatic #205 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 73: invokestatic #234 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 76: invokespecial #88 // Method Day15$Point.\"<init>\":(II)V\n 79: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day15$Sensor.class",
"javap": "Compiled from \"Day15.kt\"\npublic final class Day15$Sensor {\n private final Day15$Point position;\n\n private final Day15$Point beacon;\n\n public Day15$Sensor(Day15$Point, Day15$Point);\n Code:\n 0: aload_1\n 1: ldc #9 // String position\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 beacon\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 position:LDay15$Point;\n 21: aload_0\n 22: aload_2\n 23: putfield #25 // Field beacon:LDay15$Point;\n 26: return\n\n public final Day15$Point getPosition();\n Code:\n 0: aload_0\n 1: getfield #23 // Field position:LDay15$Point;\n 4: areturn\n\n public final Day15$Point getBeacon();\n Code:\n 0: aload_0\n 1: getfield #25 // Field beacon:LDay15$Point;\n 4: areturn\n\n public final int distanceToBeacon();\n Code:\n 0: aload_0\n 1: getfield #23 // Field position:LDay15$Point;\n 4: aload_0\n 5: getfield #25 // Field beacon:LDay15$Point;\n 8: invokevirtual #38 // Method Day15$Point.distance:(LDay15$Point;)I\n 11: ireturn\n\n public final boolean isInRange(Day15$Point);\n Code:\n 0: aload_1\n 1: ldc #42 // 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 #23 // Field position:LDay15$Point;\n 10: aload_1\n 11: invokevirtual #38 // Method Day15$Point.distance:(LDay15$Point;)I\n 14: aload_0\n 15: getfield #23 // Field position:LDay15$Point;\n 18: aload_0\n 19: getfield #25 // Field beacon:LDay15$Point;\n 22: invokevirtual #38 // Method Day15$Point.distance:(LDay15$Point;)I\n 25: if_icmpgt 32\n 28: iconst_1\n 29: goto 33\n 32: iconst_0\n 33: ireturn\n\n public final Day15$Point maxDistanceCovered(int);\n Code:\n 0: new #34 // class Day15$Point\n 3: dup\n 4: aload_0\n 5: getfield #23 // Field position:LDay15$Point;\n 8: invokevirtual #47 // Method Day15$Point.getX:()I\n 11: aload_0\n 12: invokevirtual #49 // Method distanceToBeacon:()I\n 15: iload_1\n 16: aload_0\n 17: getfield #23 // Field position:LDay15$Point;\n 20: invokevirtual #52 // Method Day15$Point.getY:()I\n 23: isub\n 24: invokestatic #58 // Method java/lang/Math.abs:(I)I\n 27: isub\n 28: invokestatic #58 // Method java/lang/Math.abs:(I)I\n 31: iadd\n 32: iload_1\n 33: invokespecial #61 // Method Day15$Point.\"<init>\":(II)V\n 36: areturn\n\n public final Day15$Point component1();\n Code:\n 0: aload_0\n 1: getfield #23 // Field position:LDay15$Point;\n 4: areturn\n\n public final Day15$Point component2();\n Code:\n 0: aload_0\n 1: getfield #25 // Field beacon:LDay15$Point;\n 4: areturn\n\n public final Day15$Sensor copy(Day15$Point, Day15$Point);\n Code:\n 0: aload_1\n 1: ldc #9 // String position\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 beacon\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class Day15$Sensor\n 15: dup\n 16: aload_1\n 17: aload_2\n 18: invokespecial #69 // Method \"<init>\":(LDay15$Point;LDay15$Point;)V\n 21: areturn\n\n public static Day15$Sensor copy$default(Day15$Sensor, Day15$Point, Day15$Point, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_1\n 2: iand\n 3: ifeq 11\n 6: aload_0\n 7: getfield #23 // Field position:LDay15$Point;\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 beacon:LDay15$Point;\n 21: astore_2\n 22: aload_0\n 23: aload_1\n 24: aload_2\n 25: invokevirtual #73 // Method copy:(LDay15$Point;LDay15$Point;)LDay15$Sensor;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #77 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #78 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #80 // String Sensor(position=\n 9: invokevirtual #84 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #23 // Field position:LDay15$Point;\n 16: invokevirtual #87 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #89 // String , beacon=\n 21: invokevirtual #84 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #25 // Field beacon:LDay15$Point;\n 28: invokevirtual #87 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #92 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #94 // 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 position:LDay15$Point;\n 4: invokevirtual #97 // Method Day15$Point.hashCode:()I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #25 // Field beacon:LDay15$Point;\n 16: invokevirtual #97 // Method Day15$Point.hashCode:()I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: ireturn\n\n public boolean equals(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: if_acmpne 7\n 5: iconst_1\n 6: ireturn\n 7: aload_1\n 8: instanceof #2 // class Day15$Sensor\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day15$Sensor\n 20: astore_2\n 21: aload_0\n 22: getfield #23 // Field position:LDay15$Point;\n 25: aload_2\n 26: getfield #23 // Field position:LDay15$Point;\n 29: invokestatic #105 // 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 beacon:LDay15$Point;\n 41: aload_2\n 42: getfield #25 // Field beacon:LDay15$Point;\n 45: invokestatic #105 // 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": "dliszewski__advent-of-code-2022__76d5eea/Day15$Point.class",
"javap": "Compiled from \"Day15.kt\"\npublic final class Day15$Point {\n private final int x;\n\n private final int y;\n\n public Day15$Point(int, int);\n Code:\n 0: aload_0\n 1: invokespecial #9 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #13 // Field x:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field y:I\n 14: return\n\n public final int getX();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: ireturn\n\n public final int getY();\n Code:\n 0: aload_0\n 1: getfield #16 // Field y:I\n 4: ireturn\n\n public final int distance(Day15$Point);\n Code:\n 0: aload_1\n 1: ldc #26 // String other\n 3: invokestatic #32 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: getfield #13 // Field x:I\n 10: aload_0\n 11: getfield #13 // Field x:I\n 14: isub\n 15: invokestatic #38 // Method java/lang/Math.abs:(I)I\n 18: aload_1\n 19: getfield #16 // Field y:I\n 22: aload_0\n 23: getfield #16 // Field y:I\n 26: isub\n 27: invokestatic #38 // Method java/lang/Math.abs:(I)I\n 30: iadd\n 31: 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 Day15$Point copy(int, int);\n Code:\n 0: new #2 // class Day15$Point\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: invokespecial #44 // Method \"<init>\":(II)V\n 9: areturn\n\n public static Day15$Point copy$default(Day15$Point, int, int, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_1\n 2: iand\n 3: ifeq 11\n 6: aload_0\n 7: getfield #13 // Field x:I\n 10: istore_1\n 11: iload_3\n 12: iconst_2\n 13: iand\n 14: ifeq 22\n 17: aload_0\n 18: getfield #16 // Field y:I\n 21: istore_2\n 22: aload_0\n 23: iload_1\n 24: iload_2\n 25: invokevirtual #48 // Method copy:(II)LDay15$Point;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #52 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #53 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #55 // String Point(x=\n 9: invokevirtual #59 // 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 #62 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #64 // String , y=\n 21: invokevirtual #59 // 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 #62 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #67 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #69 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 39: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: invokestatic #74 // Method java/lang/Integer.hashCode:(I)I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #16 // Field y:I\n 16: invokestatic #74 // 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 Day15$Point\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day15$Point\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field x:I\n 25: aload_2\n 26: getfield #13 // Field x:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field y:I\n 38: aload_2\n 39: getfield #16 // Field y:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: iconst_1\n 48: ireturn\n}\n",
"javap_err": ""
}
] |
dliszewski__advent-of-code-2022__76d5eea/src/main/kotlin/Day09.kt
|
import kotlin.math.abs
class Day09 {
fun part1(input: List<String>): Int {
val movement = input.map { it.split(" ") }
.flatMap { (direction, step) -> (1..step.toInt()).map { direction.toDirection() } }
return simulateMoves(movement, 2).size
}
fun part2(input: List<String>): Int {
val movement = input.map { it.split(" ") }
.flatMap { (direction, step) -> (1..step.toInt()).map { direction.toDirection() } }
return simulateMoves(movement, 10).size
}
private fun simulateMoves(moves: List<Direction>, knotsNumber: Int): Set<Point> {
val knots = MutableList(knotsNumber) { Point(0, 0) }
val visitedTail = mutableSetOf<Point>()
visitedTail.add(knots.last())
moves.forEach { direction ->
knots[0] = knots[0].move(direction)
for ((headIndex, tailIndex) in knots.indices.zipWithNext()) {
val head = knots[headIndex]
val tail = knots[tailIndex]
if (!tail.isAdjacentTo(head)) {
knots[tailIndex] = tail.moveTowards(head)
}
}
visitedTail.add(knots.last())
}
return visitedTail
}
private fun Point.move(direction: Direction): Point {
return when (direction) {
Direction.UP -> Point(x, y + 1)
Direction.DOWN -> Point(x, y - 1)
Direction.LEFT -> Point(x - 1, y)
Direction.RIGHT -> Point(x + 1, y)
}
}
private fun Point.isAdjacentTo(other: Point): Boolean {
return abs(x - other.x) <= 1 && abs(y - other.y) <= 1
}
private fun Point.moveTowards(head: Point): Point {
return Point(
x + (head.x - x).coerceIn(-1..1),
y + (head.y - y).coerceIn(-1..1)
)
}
data class Point(val x: Int, val y: Int)
enum class Direction { UP, DOWN, LEFT, RIGHT }
private fun String.toDirection(): Direction {
return when (this) {
"U" -> Direction.UP
"D" -> Direction.DOWN
"L" -> Direction.LEFT
"R" -> Direction.RIGHT
else -> error("wrong direction $this")
}
}
}
|
[
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day09$WhenMappings.class",
"javap": "Compiled from \"Day09.kt\"\npublic final class Day09$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method Day09$Direction.values:()[LDay09$Direction;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field Day09$Direction.UP:LDay09$Direction;\n 12: invokevirtual #22 // Method Day09$Direction.ordinal:()I\n 15: iconst_1\n 16: iastore\n 17: goto 21\n 20: astore_1\n 21: nop\n 22: aload_0\n 23: getstatic #25 // Field Day09$Direction.DOWN:LDay09$Direction;\n 26: invokevirtual #22 // Method Day09$Direction.ordinal:()I\n 29: iconst_2\n 30: iastore\n 31: goto 35\n 34: astore_1\n 35: nop\n 36: aload_0\n 37: getstatic #28 // Field Day09$Direction.LEFT:LDay09$Direction;\n 40: invokevirtual #22 // Method Day09$Direction.ordinal:()I\n 43: iconst_3\n 44: iastore\n 45: goto 49\n 48: astore_1\n 49: nop\n 50: aload_0\n 51: getstatic #31 // Field Day09$Direction.RIGHT:LDay09$Direction;\n 54: invokevirtual #22 // Method Day09$Direction.ordinal:()I\n 57: iconst_4\n 58: iastore\n 59: goto 63\n 62: astore_1\n 63: aload_0\n 64: putstatic #35 // Field $EnumSwitchMapping$0:[I\n 67: return\n Exception table:\n from to target type\n 7 17 20 Class java/lang/NoSuchFieldError\n 21 31 34 Class java/lang/NoSuchFieldError\n 35 45 48 Class java/lang/NoSuchFieldError\n 49 59 62 Class java/lang/NoSuchFieldError\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day09.class",
"javap": "Compiled from \"Day09.kt\"\npublic final class Day09 {\n public Day09();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #24 // class java/lang/Iterable\n 10: astore_3\n 11: iconst_0\n 12: istore 4\n 14: aload_3\n 15: astore 5\n 17: new #26 // class java/util/ArrayList\n 20: dup\n 21: aload_3\n 22: bipush 10\n 24: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 27: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 30: checkcast #37 // class java/util/Collection\n 33: astore 6\n 35: iconst_0\n 36: istore 7\n 38: aload 5\n 40: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 8\n 47: aload 8\n 49: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 119\n 57: aload 8\n 59: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 9\n 66: aload 6\n 68: aload 9\n 70: checkcast #53 // class java/lang/String\n 73: astore 10\n 75: astore 24\n 77: iconst_0\n 78: istore 11\n 80: aload 10\n 82: checkcast #55 // class java/lang/CharSequence\n 85: iconst_1\n 86: anewarray #53 // class java/lang/String\n 89: astore 12\n 91: aload 12\n 93: iconst_0\n 94: ldc #57 // String\n 96: aastore\n 97: aload 12\n 99: iconst_0\n 100: iconst_0\n 101: bipush 6\n 103: aconst_null\n 104: invokestatic #63 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 107: aload 24\n 109: swap\n 110: invokeinterface #67, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 115: pop\n 116: goto 47\n 119: aload 6\n 121: checkcast #69 // class java/util/List\n 124: nop\n 125: checkcast #24 // 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 #26 // class java/util/ArrayList\n 139: dup\n 140: invokespecial #70 // Method java/util/ArrayList.\"<init>\":()V\n 143: checkcast #37 // class java/util/Collection\n 146: astore 6\n 148: iconst_0\n 149: istore 7\n 151: aload 5\n 153: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 158: astore 8\n 160: aload 8\n 162: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 167: ifeq 343\n 170: aload 8\n 172: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 177: astore 9\n 179: aload 9\n 181: checkcast #69 // class java/util/List\n 184: astore 10\n 186: iconst_0\n 187: istore 11\n 189: aload 10\n 191: iconst_0\n 192: invokeinterface #74, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 197: checkcast #53 // class java/lang/String\n 200: astore 12\n 202: aload 10\n 204: iconst_1\n 205: invokeinterface #74, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 210: checkcast #53 // class java/lang/String\n 213: astore 13\n 215: new #76 // class kotlin/ranges/IntRange\n 218: dup\n 219: iconst_1\n 220: aload 13\n 222: invokestatic #82 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 225: invokespecial #85 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 228: checkcast #24 // class java/lang/Iterable\n 231: astore 14\n 233: iconst_0\n 234: istore 15\n 236: aload 14\n 238: astore 16\n 240: new #26 // class java/util/ArrayList\n 243: dup\n 244: aload 14\n 246: bipush 10\n 248: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 251: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 254: checkcast #37 // class java/util/Collection\n 257: astore 17\n 259: iconst_0\n 260: istore 18\n 262: aload 16\n 264: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 269: astore 19\n 271: aload 19\n 273: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 278: ifeq 320\n 281: aload 19\n 283: checkcast #87 // class kotlin/collections/IntIterator\n 286: invokevirtual #91 // Method kotlin/collections/IntIterator.nextInt:()I\n 289: istore 20\n 291: aload 17\n 293: iload 20\n 295: istore 21\n 297: astore 22\n 299: iconst_0\n 300: istore 23\n 302: aload_0\n 303: aload 12\n 305: invokespecial #95 // Method toDirection:(Ljava/lang/String;)LDay09$Direction;\n 308: aload 22\n 310: swap\n 311: invokeinterface #67, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 316: pop\n 317: goto 271\n 320: aload 17\n 322: checkcast #69 // class java/util/List\n 325: nop\n 326: checkcast #24 // class java/lang/Iterable\n 329: nop\n 330: astore 10\n 332: aload 6\n 334: aload 10\n 336: invokestatic #99 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 339: pop\n 340: goto 160\n 343: aload 6\n 345: checkcast #69 // class java/util/List\n 348: nop\n 349: astore_2\n 350: aload_0\n 351: aload_2\n 352: iconst_2\n 353: invokespecial #103 // Method simulateMoves:(Ljava/util/List;I)Ljava/util/Set;\n 356: invokeinterface #108, 1 // InterfaceMethod java/util/Set.size:()I\n 361: ireturn\n\n public final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #24 // class java/lang/Iterable\n 10: astore_3\n 11: iconst_0\n 12: istore 4\n 14: aload_3\n 15: astore 5\n 17: new #26 // class java/util/ArrayList\n 20: dup\n 21: aload_3\n 22: bipush 10\n 24: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 27: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 30: checkcast #37 // class java/util/Collection\n 33: astore 6\n 35: iconst_0\n 36: istore 7\n 38: aload 5\n 40: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 8\n 47: aload 8\n 49: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 119\n 57: aload 8\n 59: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 9\n 66: aload 6\n 68: aload 9\n 70: checkcast #53 // class java/lang/String\n 73: astore 10\n 75: astore 24\n 77: iconst_0\n 78: istore 11\n 80: aload 10\n 82: checkcast #55 // class java/lang/CharSequence\n 85: iconst_1\n 86: anewarray #53 // class java/lang/String\n 89: astore 12\n 91: aload 12\n 93: iconst_0\n 94: ldc #57 // String\n 96: aastore\n 97: aload 12\n 99: iconst_0\n 100: iconst_0\n 101: bipush 6\n 103: aconst_null\n 104: invokestatic #63 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 107: aload 24\n 109: swap\n 110: invokeinterface #67, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 115: pop\n 116: goto 47\n 119: aload 6\n 121: checkcast #69 // class java/util/List\n 124: nop\n 125: checkcast #24 // 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 #26 // class java/util/ArrayList\n 139: dup\n 140: invokespecial #70 // Method java/util/ArrayList.\"<init>\":()V\n 143: checkcast #37 // class java/util/Collection\n 146: astore 6\n 148: iconst_0\n 149: istore 7\n 151: aload 5\n 153: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 158: astore 8\n 160: aload 8\n 162: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 167: ifeq 343\n 170: aload 8\n 172: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 177: astore 9\n 179: aload 9\n 181: checkcast #69 // class java/util/List\n 184: astore 10\n 186: iconst_0\n 187: istore 11\n 189: aload 10\n 191: iconst_0\n 192: invokeinterface #74, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 197: checkcast #53 // class java/lang/String\n 200: astore 12\n 202: aload 10\n 204: iconst_1\n 205: invokeinterface #74, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 210: checkcast #53 // class java/lang/String\n 213: astore 13\n 215: new #76 // class kotlin/ranges/IntRange\n 218: dup\n 219: iconst_1\n 220: aload 13\n 222: invokestatic #82 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 225: invokespecial #85 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 228: checkcast #24 // class java/lang/Iterable\n 231: astore 14\n 233: iconst_0\n 234: istore 15\n 236: aload 14\n 238: astore 16\n 240: new #26 // class java/util/ArrayList\n 243: dup\n 244: aload 14\n 246: bipush 10\n 248: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 251: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 254: checkcast #37 // class java/util/Collection\n 257: astore 17\n 259: iconst_0\n 260: istore 18\n 262: aload 16\n 264: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 269: astore 19\n 271: aload 19\n 273: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 278: ifeq 320\n 281: aload 19\n 283: checkcast #87 // class kotlin/collections/IntIterator\n 286: invokevirtual #91 // Method kotlin/collections/IntIterator.nextInt:()I\n 289: istore 20\n 291: aload 17\n 293: iload 20\n 295: istore 21\n 297: astore 22\n 299: iconst_0\n 300: istore 23\n 302: aload_0\n 303: aload 12\n 305: invokespecial #95 // Method toDirection:(Ljava/lang/String;)LDay09$Direction;\n 308: aload 22\n 310: swap\n 311: invokeinterface #67, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 316: pop\n 317: goto 271\n 320: aload 17\n 322: checkcast #69 // class java/util/List\n 325: nop\n 326: checkcast #24 // class java/lang/Iterable\n 329: nop\n 330: astore 10\n 332: aload 6\n 334: aload 10\n 336: invokestatic #99 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 339: pop\n 340: goto 160\n 343: aload 6\n 345: checkcast #69 // class java/util/List\n 348: nop\n 349: astore_2\n 350: aload_0\n 351: aload_2\n 352: bipush 10\n 354: invokespecial #103 // Method simulateMoves:(Ljava/util/List;I)Ljava/util/Set;\n 357: invokeinterface #108, 1 // InterfaceMethod java/util/Set.size:()I\n 362: ireturn\n\n private final java.util.Set<Day09$Point> simulateMoves(java.util.List<? extends Day09$Direction>, int);\n Code:\n 0: new #26 // class java/util/ArrayList\n 3: dup\n 4: iload_2\n 5: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 8: astore 4\n 10: iconst_0\n 11: istore 5\n 13: iload 5\n 15: iload_2\n 16: if_icmpge 56\n 19: iload 5\n 21: istore 6\n 23: aload 4\n 25: iload 6\n 27: istore 7\n 29: astore 17\n 31: iconst_0\n 32: istore 8\n 34: new #140 // class Day09$Point\n 37: dup\n 38: iconst_0\n 39: iconst_0\n 40: invokespecial #141 // Method Day09$Point.\"<init>\":(II)V\n 43: aload 17\n 45: swap\n 46: invokevirtual #142 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 49: pop\n 50: iinc 5, 1\n 53: goto 13\n 56: aload 4\n 58: checkcast #69 // class java/util/List\n 61: astore_3\n 62: new #144 // class java/util/LinkedHashSet\n 65: dup\n 66: invokespecial #145 // Method java/util/LinkedHashSet.\"<init>\":()V\n 69: checkcast #105 // class java/util/Set\n 72: astore 4\n 74: aload 4\n 76: aload_3\n 77: invokestatic #149 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 80: invokeinterface #150, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 85: pop\n 86: aload_1\n 87: checkcast #24 // class java/lang/Iterable\n 90: astore 5\n 92: iconst_0\n 93: istore 6\n 95: aload 5\n 97: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 102: astore 7\n 104: aload 7\n 106: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 111: ifeq 299\n 114: aload 7\n 116: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 121: astore 8\n 123: aload 8\n 125: checkcast #152 // class Day09$Direction\n 128: astore 9\n 130: iconst_0\n 131: istore 10\n 133: aload_3\n 134: iconst_0\n 135: aload_0\n 136: aload_3\n 137: iconst_0\n 138: invokeinterface #74, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 143: checkcast #140 // class Day09$Point\n 146: aload 9\n 148: invokespecial #156 // Method move:(LDay09$Point;LDay09$Direction;)LDay09$Point;\n 151: invokeinterface #160, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 156: pop\n 157: aload_3\n 158: checkcast #37 // class java/util/Collection\n 161: invokestatic #164 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 164: checkcast #24 // class java/lang/Iterable\n 167: invokestatic #168 // Method kotlin/collections/CollectionsKt.zipWithNext:(Ljava/lang/Iterable;)Ljava/util/List;\n 170: invokeinterface #169, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 175: astore 11\n 177: aload 11\n 179: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 184: ifeq 282\n 187: aload 11\n 189: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 194: checkcast #171 // class kotlin/Pair\n 197: astore 12\n 199: aload 12\n 201: invokevirtual #174 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 204: checkcast #176 // class java/lang/Number\n 207: invokevirtual #179 // Method java/lang/Number.intValue:()I\n 210: istore 13\n 212: aload 12\n 214: invokevirtual #182 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 217: checkcast #176 // class java/lang/Number\n 220: invokevirtual #179 // Method java/lang/Number.intValue:()I\n 223: istore 14\n 225: aload_3\n 226: iload 13\n 228: invokeinterface #74, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 233: checkcast #140 // class Day09$Point\n 236: astore 15\n 238: aload_3\n 239: iload 14\n 241: invokeinterface #74, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 246: checkcast #140 // class Day09$Point\n 249: astore 16\n 251: aload_0\n 252: aload 16\n 254: aload 15\n 256: invokespecial #186 // Method isAdjacentTo:(LDay09$Point;LDay09$Point;)Z\n 259: ifne 177\n 262: aload_3\n 263: iload 14\n 265: aload_0\n 266: aload 16\n 268: aload 15\n 270: invokespecial #190 // Method moveTowards:(LDay09$Point;LDay09$Point;)LDay09$Point;\n 273: invokeinterface #160, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 278: pop\n 279: goto 177\n 282: aload 4\n 284: aload_3\n 285: invokestatic #149 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 288: invokeinterface #150, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 293: pop\n 294: nop\n 295: nop\n 296: goto 104\n 299: nop\n 300: aload 4\n 302: areturn\n\n private final Day09$Point move(Day09$Point, Day09$Direction);\n Code:\n 0: aload_2\n 1: getstatic #212 // Field Day09$WhenMappings.$EnumSwitchMapping$0:[I\n 4: swap\n 5: invokevirtual #215 // Method Day09$Direction.ordinal:()I\n 8: iaload\n 9: tableswitch { // 1 to 4\n 1: 40\n 2: 60\n 3: 80\n 4: 100\n default: 120\n }\n 40: new #140 // class Day09$Point\n 43: dup\n 44: aload_1\n 45: invokevirtual #218 // Method Day09$Point.getX:()I\n 48: aload_1\n 49: invokevirtual #221 // Method Day09$Point.getY:()I\n 52: iconst_1\n 53: iadd\n 54: invokespecial #141 // Method Day09$Point.\"<init>\":(II)V\n 57: goto 128\n 60: new #140 // class Day09$Point\n 63: dup\n 64: aload_1\n 65: invokevirtual #218 // Method Day09$Point.getX:()I\n 68: aload_1\n 69: invokevirtual #221 // Method Day09$Point.getY:()I\n 72: iconst_1\n 73: isub\n 74: invokespecial #141 // Method Day09$Point.\"<init>\":(II)V\n 77: goto 128\n 80: new #140 // class Day09$Point\n 83: dup\n 84: aload_1\n 85: invokevirtual #218 // Method Day09$Point.getX:()I\n 88: iconst_1\n 89: isub\n 90: aload_1\n 91: invokevirtual #221 // Method Day09$Point.getY:()I\n 94: invokespecial #141 // Method Day09$Point.\"<init>\":(II)V\n 97: goto 128\n 100: new #140 // class Day09$Point\n 103: dup\n 104: aload_1\n 105: invokevirtual #218 // Method Day09$Point.getX:()I\n 108: iconst_1\n 109: iadd\n 110: aload_1\n 111: invokevirtual #221 // Method Day09$Point.getY:()I\n 114: invokespecial #141 // Method Day09$Point.\"<init>\":(II)V\n 117: goto 128\n 120: new #223 // class kotlin/NoWhenBranchMatchedException\n 123: dup\n 124: invokespecial #224 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 127: athrow\n 128: areturn\n\n private final boolean isAdjacentTo(Day09$Point, Day09$Point);\n Code:\n 0: aload_1\n 1: invokevirtual #218 // Method Day09$Point.getX:()I\n 4: aload_2\n 5: invokevirtual #218 // Method Day09$Point.getX:()I\n 8: isub\n 9: invokestatic #231 // Method java/lang/Math.abs:(I)I\n 12: iconst_1\n 13: if_icmpgt 36\n 16: aload_1\n 17: invokevirtual #221 // Method Day09$Point.getY:()I\n 20: aload_2\n 21: invokevirtual #221 // Method Day09$Point.getY:()I\n 24: isub\n 25: invokestatic #231 // Method java/lang/Math.abs:(I)I\n 28: iconst_1\n 29: if_icmpgt 36\n 32: iconst_1\n 33: goto 37\n 36: iconst_0\n 37: ireturn\n\n private final Day09$Point moveTowards(Day09$Point, Day09$Point);\n Code:\n 0: new #140 // class Day09$Point\n 3: dup\n 4: aload_1\n 5: invokevirtual #218 // Method Day09$Point.getX:()I\n 8: aload_2\n 9: invokevirtual #218 // Method Day09$Point.getX:()I\n 12: aload_1\n 13: invokevirtual #218 // Method Day09$Point.getX:()I\n 16: isub\n 17: new #76 // class kotlin/ranges/IntRange\n 20: dup\n 21: iconst_m1\n 22: iconst_1\n 23: invokespecial #85 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 26: checkcast #235 // class kotlin/ranges/ClosedRange\n 29: invokestatic #241 // Method kotlin/ranges/RangesKt.coerceIn:(ILkotlin/ranges/ClosedRange;)I\n 32: iadd\n 33: aload_1\n 34: invokevirtual #221 // Method Day09$Point.getY:()I\n 37: aload_2\n 38: invokevirtual #221 // Method Day09$Point.getY:()I\n 41: aload_1\n 42: invokevirtual #221 // Method Day09$Point.getY:()I\n 45: isub\n 46: new #76 // class kotlin/ranges/IntRange\n 49: dup\n 50: iconst_m1\n 51: iconst_1\n 52: invokespecial #85 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 55: checkcast #235 // class kotlin/ranges/ClosedRange\n 58: invokestatic #241 // Method kotlin/ranges/RangesKt.coerceIn:(ILkotlin/ranges/ClosedRange;)I\n 61: iadd\n 62: invokespecial #141 // Method Day09$Point.\"<init>\":(II)V\n 65: areturn\n\n private final Day09$Direction toDirection(java.lang.String);\n Code:\n 0: aload_1\n 1: astore_2\n 2: aload_2\n 3: invokevirtual #245 // Method java/lang/String.hashCode:()I\n 6: lookupswitch { // 4\n 68: 60\n 76: 84\n 82: 48\n 85: 72\n default: 121\n }\n 48: aload_2\n 49: ldc #247 // String R\n 51: invokevirtual #250 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 54: ifne 115\n 57: goto 121\n 60: aload_2\n 61: ldc #252 // String D\n 63: invokevirtual #250 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 66: ifne 103\n 69: goto 121\n 72: aload_2\n 73: ldc #254 // String U\n 75: invokevirtual #250 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 78: ifne 97\n 81: goto 121\n 84: aload_2\n 85: ldc_w #256 // String L\n 88: invokevirtual #250 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 91: ifne 109\n 94: goto 121\n 97: getstatic #259 // Field Day09$Direction.UP:LDay09$Direction;\n 100: goto 152\n 103: getstatic #262 // Field Day09$Direction.DOWN:LDay09$Direction;\n 106: goto 152\n 109: getstatic #265 // Field Day09$Direction.LEFT:LDay09$Direction;\n 112: goto 152\n 115: getstatic #268 // Field Day09$Direction.RIGHT:LDay09$Direction;\n 118: goto 152\n 121: new #270 // class java/lang/IllegalStateException\n 124: dup\n 125: new #272 // class java/lang/StringBuilder\n 128: dup\n 129: invokespecial #273 // Method java/lang/StringBuilder.\"<init>\":()V\n 132: ldc_w #275 // String wrong direction\n 135: invokevirtual #279 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 138: aload_1\n 139: invokevirtual #279 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 142: invokevirtual #283 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 145: invokevirtual #284 // Method java/lang/Object.toString:()Ljava/lang/String;\n 148: invokespecial #287 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 151: athrow\n 152: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day09$Direction.class",
"javap": "Compiled from \"Day09.kt\"\npublic final class Day09$Direction extends java.lang.Enum<Day09$Direction> {\n public static final Day09$Direction UP;\n\n public static final Day09$Direction DOWN;\n\n public static final Day09$Direction LEFT;\n\n public static final Day09$Direction RIGHT;\n\n private static final Day09$Direction[] $VALUES;\n\n private static final kotlin.enums.EnumEntries $ENTRIES;\n\n private Day09$Direction();\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: invokespecial #10 // Method java/lang/Enum.\"<init>\":(Ljava/lang/String;I)V\n 6: return\n\n public static Day09$Direction[] values();\n Code:\n 0: getstatic #22 // Field $VALUES:[LDay09$Direction;\n 3: invokevirtual #28 // Method java/lang/Object.clone:()Ljava/lang/Object;\n 6: checkcast #29 // class \"[LDay09$Direction;\"\n 9: areturn\n\n public static Day09$Direction valueOf(java.lang.String);\n Code:\n 0: ldc #2 // class Day09$Direction\n 2: aload_0\n 3: invokestatic #34 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;\n 6: checkcast #2 // class Day09$Direction\n 9: areturn\n\n public static kotlin.enums.EnumEntries<Day09$Direction> getEntries();\n Code:\n 0: getstatic #43 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 3: areturn\n\n private static final Day09$Direction[] $values();\n Code:\n 0: iconst_4\n 1: anewarray #2 // class Day09$Direction\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: getstatic #47 // Field UP:LDay09$Direction;\n 10: aastore\n 11: aload_0\n 12: iconst_1\n 13: getstatic #50 // Field DOWN:LDay09$Direction;\n 16: aastore\n 17: aload_0\n 18: iconst_2\n 19: getstatic #53 // Field LEFT:LDay09$Direction;\n 22: aastore\n 23: aload_0\n 24: iconst_3\n 25: getstatic #56 // Field RIGHT:LDay09$Direction;\n 28: aastore\n 29: aload_0\n 30: areturn\n\n static {};\n Code:\n 0: new #2 // class Day09$Direction\n 3: dup\n 4: ldc #58 // String UP\n 6: iconst_0\n 7: invokespecial #59 // Method \"<init>\":(Ljava/lang/String;I)V\n 10: putstatic #47 // Field UP:LDay09$Direction;\n 13: new #2 // class Day09$Direction\n 16: dup\n 17: ldc #60 // String DOWN\n 19: iconst_1\n 20: invokespecial #59 // Method \"<init>\":(Ljava/lang/String;I)V\n 23: putstatic #50 // Field DOWN:LDay09$Direction;\n 26: new #2 // class Day09$Direction\n 29: dup\n 30: ldc #61 // String LEFT\n 32: iconst_2\n 33: invokespecial #59 // Method \"<init>\":(Ljava/lang/String;I)V\n 36: putstatic #53 // Field LEFT:LDay09$Direction;\n 39: new #2 // class Day09$Direction\n 42: dup\n 43: ldc #62 // String RIGHT\n 45: iconst_3\n 46: invokespecial #59 // Method \"<init>\":(Ljava/lang/String;I)V\n 49: putstatic #56 // Field RIGHT:LDay09$Direction;\n 52: invokestatic #64 // Method $values:()[LDay09$Direction;\n 55: putstatic #22 // Field $VALUES:[LDay09$Direction;\n 58: getstatic #22 // Field $VALUES:[LDay09$Direction;\n 61: checkcast #66 // class \"[Ljava/lang/Enum;\"\n 64: invokestatic #72 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;\n 67: putstatic #43 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 70: return\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day09$Point.class",
"javap": "Compiled from \"Day09.kt\"\npublic final class Day09$Point {\n private final int x;\n\n private final int y;\n\n public Day09$Point(int, int);\n Code:\n 0: aload_0\n 1: invokespecial #9 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #13 // Field x:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field y:I\n 14: return\n\n public final int getX();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: ireturn\n\n public final int getY();\n Code:\n 0: aload_0\n 1: getfield #16 // Field y:I\n 4: ireturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field y:I\n 4: ireturn\n\n public final Day09$Point copy(int, int);\n Code:\n 0: new #2 // class Day09$Point\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: invokespecial #28 // Method \"<init>\":(II)V\n 9: areturn\n\n public static Day09$Point copy$default(Day09$Point, int, int, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_1\n 2: iand\n 3: ifeq 11\n 6: aload_0\n 7: getfield #13 // Field x:I\n 10: istore_1\n 11: iload_3\n 12: iconst_2\n 13: iand\n 14: ifeq 22\n 17: aload_0\n 18: getfield #16 // Field y:I\n 21: istore_2\n 22: aload_0\n 23: iload_1\n 24: iload_2\n 25: invokevirtual #32 // Method copy:(II)LDay09$Point;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #36 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #37 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #39 // String Point(x=\n 9: invokevirtual #43 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field x:I\n 16: invokevirtual #46 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #48 // String , y=\n 21: invokevirtual #43 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #16 // Field y:I\n 28: invokevirtual #46 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #51 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #53 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 39: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: invokestatic #59 // Method java/lang/Integer.hashCode:(I)I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #16 // Field y:I\n 16: invokestatic #59 // Method java/lang/Integer.hashCode:(I)I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: ireturn\n\n public boolean equals(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: if_acmpne 7\n 5: iconst_1\n 6: ireturn\n 7: aload_1\n 8: instanceof #2 // class Day09$Point\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day09$Point\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field x:I\n 25: aload_2\n 26: getfield #13 // Field x:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field y:I\n 38: aload_2\n 39: getfield #16 // Field y:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: iconst_1\n 48: ireturn\n}\n",
"javap_err": ""
}
] |
dliszewski__advent-of-code-2022__76d5eea/src/main/kotlin/Day03.kt
|
class Day03 {
fun part1(input: List<String>): Int {
return input
.map { Rucksack(it) }
.flatMap { it.getCompartmentIntersection() }
.sumOf { it.toPriorityScore() }
}
fun part2(input: List<String>): Int {
return input
.chunked(3)
.map { (elf1, elf2, elf3) -> Triple(Rucksack(elf1), Rucksack(elf2), Rucksack(elf3)) }
.map { it.first.getCompartmentIntersectionFrom(it.second, it.third).single() }
.sumOf { it.toPriorityScore() }
}
class Rucksack(private val content: String) {
fun getCompartmentIntersection(): Set<Char> {
val splitIndex = if (content.length % 2 == 0) content.length / 2 else content.length / 2 + 1
val first = content.take(splitIndex).toSet()
val second = content.substring(splitIndex).toSet()
return first.intersect(second)
}
fun getCompartmentIntersectionFrom(other: Rucksack, another: Rucksack): Set<Char> {
return content.toSet()
.intersect(other.content.toSet())
.intersect(another.content.toSet())
}
}
private fun Char.toPriorityScore(): Int {
return when {
// Lowercase item types a through z have priorities 1 through 26.
isLowerCase() -> this - 'a' + 1
// Uppercase item types A through Z have priorities 27 through 52.
isUpperCase() -> this - 'A' + 27
else -> error("Wrong input")
}
}
}
|
[
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day03$Rucksack.class",
"javap": "Compiled from \"Day03.kt\"\npublic final class Day03$Rucksack {\n private final java.lang.String content;\n\n public Day03$Rucksack(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #9 // String content\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 content:Ljava/lang/String;\n 15: return\n\n public final java.util.Set<java.lang.Character> getCompartmentIntersection();\n Code:\n 0: aload_0\n 1: getfield #21 // Field content:Ljava/lang/String;\n 4: invokevirtual #32 // Method java/lang/String.length:()I\n 7: iconst_2\n 8: irem\n 9: ifne 24\n 12: aload_0\n 13: getfield #21 // Field content:Ljava/lang/String;\n 16: invokevirtual #32 // Method java/lang/String.length:()I\n 19: iconst_2\n 20: idiv\n 21: goto 35\n 24: aload_0\n 25: getfield #21 // Field content:Ljava/lang/String;\n 28: invokevirtual #32 // Method java/lang/String.length:()I\n 31: iconst_2\n 32: idiv\n 33: iconst_1\n 34: iadd\n 35: istore_1\n 36: aload_0\n 37: getfield #21 // Field content:Ljava/lang/String;\n 40: iload_1\n 41: invokestatic #38 // Method kotlin/text/StringsKt.take:(Ljava/lang/String;I)Ljava/lang/String;\n 44: checkcast #40 // class java/lang/CharSequence\n 47: invokestatic #44 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 50: astore_2\n 51: aload_0\n 52: getfield #21 // Field content:Ljava/lang/String;\n 55: iload_1\n 56: invokevirtual #48 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 59: dup\n 60: ldc #50 // String substring(...)\n 62: invokestatic #53 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 65: checkcast #40 // class java/lang/CharSequence\n 68: invokestatic #44 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 71: astore_3\n 72: aload_2\n 73: checkcast #55 // class java/lang/Iterable\n 76: aload_3\n 77: checkcast #55 // class java/lang/Iterable\n 80: invokestatic #61 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 83: areturn\n\n public final java.util.Set<java.lang.Character> getCompartmentIntersectionFrom(Day03$Rucksack, Day03$Rucksack);\n Code:\n 0: aload_1\n 1: ldc #71 // String other\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #73 // String another\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: getfield #21 // Field content:Ljava/lang/String;\n 16: checkcast #40 // class java/lang/CharSequence\n 19: invokestatic #44 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 22: checkcast #55 // class java/lang/Iterable\n 25: aload_1\n 26: getfield #21 // Field content:Ljava/lang/String;\n 29: checkcast #40 // class java/lang/CharSequence\n 32: invokestatic #44 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 35: checkcast #55 // class java/lang/Iterable\n 38: invokestatic #61 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 41: checkcast #55 // class java/lang/Iterable\n 44: aload_2\n 45: getfield #21 // Field content:Ljava/lang/String;\n 48: checkcast #40 // class java/lang/CharSequence\n 51: invokestatic #44 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 54: checkcast #55 // class java/lang/Iterable\n 57: invokestatic #61 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 60: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day03.class",
"javap": "Compiled from \"Day03.kt\"\npublic final class Day03 {\n public Day03();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #24 // class java/lang/Iterable\n 10: astore_2\n 11: nop\n 12: iconst_0\n 13: istore_3\n 14: aload_2\n 15: astore 4\n 17: new #26 // class java/util/ArrayList\n 20: dup\n 21: aload_2\n 22: bipush 10\n 24: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 27: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 30: checkcast #37 // class java/util/Collection\n 33: astore 5\n 35: iconst_0\n 36: istore 6\n 38: aload 4\n 40: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 7\n 47: aload 7\n 49: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 101\n 57: aload 7\n 59: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 8\n 66: aload 5\n 68: aload 8\n 70: checkcast #53 // class java/lang/String\n 73: astore 9\n 75: astore 11\n 77: iconst_0\n 78: istore 10\n 80: new #55 // class Day03$Rucksack\n 83: dup\n 84: aload 9\n 86: invokespecial #58 // Method Day03$Rucksack.\"<init>\":(Ljava/lang/String;)V\n 89: aload 11\n 91: swap\n 92: invokeinterface #62, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 97: pop\n 98: goto 47\n 101: aload 5\n 103: checkcast #64 // class java/util/List\n 106: nop\n 107: checkcast #24 // class java/lang/Iterable\n 110: astore_2\n 111: nop\n 112: iconst_0\n 113: istore_3\n 114: aload_2\n 115: astore 4\n 117: new #26 // class java/util/ArrayList\n 120: dup\n 121: invokespecial #65 // Method java/util/ArrayList.\"<init>\":()V\n 124: checkcast #37 // class java/util/Collection\n 127: astore 5\n 129: iconst_0\n 130: istore 6\n 132: aload 4\n 134: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 139: astore 7\n 141: aload 7\n 143: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 148: ifeq 191\n 151: aload 7\n 153: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 158: astore 8\n 160: aload 8\n 162: checkcast #55 // class Day03$Rucksack\n 165: astore 9\n 167: iconst_0\n 168: istore 10\n 170: aload 9\n 172: invokevirtual #69 // Method Day03$Rucksack.getCompartmentIntersection:()Ljava/util/Set;\n 175: checkcast #24 // class java/lang/Iterable\n 178: astore 9\n 180: aload 5\n 182: aload 9\n 184: invokestatic #73 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 187: pop\n 188: goto 141\n 191: aload 5\n 193: checkcast #64 // class java/util/List\n 196: nop\n 197: checkcast #24 // class java/lang/Iterable\n 200: astore_2\n 201: iconst_0\n 202: istore_3\n 203: aload_2\n 204: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 209: astore 4\n 211: aload 4\n 213: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 218: ifeq 263\n 221: aload 4\n 223: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 228: astore 5\n 230: iload_3\n 231: aload 5\n 233: checkcast #75 // class java/lang/Character\n 236: invokevirtual #79 // Method java/lang/Character.charValue:()C\n 239: istore 6\n 241: istore 11\n 243: iconst_0\n 244: istore 7\n 246: aload_0\n 247: iload 6\n 249: invokespecial #83 // Method toPriorityScore:(C)I\n 252: istore 12\n 254: iload 11\n 256: iload 12\n 258: iadd\n 259: istore_3\n 260: goto 211\n 263: iload_3\n 264: ireturn\n\n public final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #24 // class java/lang/Iterable\n 10: iconst_3\n 11: invokestatic #112 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;\n 14: checkcast #24 // class java/lang/Iterable\n 17: astore_2\n 18: nop\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 #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 34: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 37: checkcast #37 // class java/util/Collection\n 40: astore 5\n 42: iconst_0\n 43: istore 6\n 45: aload 4\n 47: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 52: astore 7\n 54: aload 7\n 56: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 61: ifeq 172\n 64: aload 7\n 66: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 71: astore 8\n 73: aload 5\n 75: aload 8\n 77: checkcast #64 // class java/util/List\n 80: astore 9\n 82: astore 14\n 84: iconst_0\n 85: istore 10\n 87: aload 9\n 89: iconst_0\n 90: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 95: checkcast #53 // class java/lang/String\n 98: astore 11\n 100: aload 9\n 102: iconst_1\n 103: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 108: checkcast #53 // class java/lang/String\n 111: astore 12\n 113: aload 9\n 115: iconst_2\n 116: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 121: checkcast #53 // class java/lang/String\n 124: astore 13\n 126: new #118 // class kotlin/Triple\n 129: dup\n 130: new #55 // class Day03$Rucksack\n 133: dup\n 134: aload 11\n 136: invokespecial #58 // Method Day03$Rucksack.\"<init>\":(Ljava/lang/String;)V\n 139: new #55 // class Day03$Rucksack\n 142: dup\n 143: aload 12\n 145: invokespecial #58 // Method Day03$Rucksack.\"<init>\":(Ljava/lang/String;)V\n 148: new #55 // class Day03$Rucksack\n 151: dup\n 152: aload 13\n 154: invokespecial #58 // Method Day03$Rucksack.\"<init>\":(Ljava/lang/String;)V\n 157: invokespecial #121 // Method kotlin/Triple.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V\n 160: aload 14\n 162: swap\n 163: invokeinterface #62, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 168: pop\n 169: goto 54\n 172: aload 5\n 174: checkcast #64 // class java/util/List\n 177: nop\n 178: checkcast #24 // class java/lang/Iterable\n 181: astore_2\n 182: nop\n 183: iconst_0\n 184: istore_3\n 185: aload_2\n 186: astore 4\n 188: new #26 // class java/util/ArrayList\n 191: dup\n 192: aload_2\n 193: bipush 10\n 195: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 198: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 201: checkcast #37 // class java/util/Collection\n 204: astore 5\n 206: iconst_0\n 207: istore 6\n 209: aload 4\n 211: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 216: astore 7\n 218: aload 7\n 220: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 225: ifeq 305\n 228: aload 7\n 230: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 235: astore 8\n 237: aload 5\n 239: aload 8\n 241: checkcast #118 // class kotlin/Triple\n 244: astore 9\n 246: astore 14\n 248: iconst_0\n 249: istore 10\n 251: aload 9\n 253: invokevirtual #124 // Method kotlin/Triple.getFirst:()Ljava/lang/Object;\n 256: checkcast #55 // class Day03$Rucksack\n 259: aload 9\n 261: invokevirtual #127 // Method kotlin/Triple.getSecond:()Ljava/lang/Object;\n 264: checkcast #55 // class Day03$Rucksack\n 267: aload 9\n 269: invokevirtual #130 // Method kotlin/Triple.getThird:()Ljava/lang/Object;\n 272: checkcast #55 // class Day03$Rucksack\n 275: invokevirtual #134 // Method Day03$Rucksack.getCompartmentIntersectionFrom:(LDay03$Rucksack;LDay03$Rucksack;)Ljava/util/Set;\n 278: checkcast #24 // class java/lang/Iterable\n 281: invokestatic #138 // Method kotlin/collections/CollectionsKt.single:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 284: checkcast #75 // class java/lang/Character\n 287: invokevirtual #79 // Method java/lang/Character.charValue:()C\n 290: invokestatic #142 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 293: aload 14\n 295: swap\n 296: invokeinterface #62, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 301: pop\n 302: goto 218\n 305: aload 5\n 307: checkcast #64 // class java/util/List\n 310: nop\n 311: checkcast #24 // class java/lang/Iterable\n 314: astore_2\n 315: iconst_0\n 316: istore_3\n 317: aload_2\n 318: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 323: astore 4\n 325: aload 4\n 327: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 332: ifeq 377\n 335: aload 4\n 337: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 342: astore 5\n 344: iload_3\n 345: aload 5\n 347: checkcast #75 // class java/lang/Character\n 350: invokevirtual #79 // Method java/lang/Character.charValue:()C\n 353: istore 6\n 355: istore 14\n 357: iconst_0\n 358: istore 7\n 360: aload_0\n 361: iload 6\n 363: invokespecial #83 // Method toPriorityScore:(C)I\n 366: istore 15\n 368: iload 14\n 370: iload 15\n 372: iadd\n 373: istore_3\n 374: goto 325\n 377: iload_3\n 378: ireturn\n\n private final int toPriorityScore(char);\n Code:\n 0: nop\n 1: iload_1\n 2: invokestatic #153 // Method java/lang/Character.isLowerCase:(C)Z\n 5: ifeq 17\n 8: iload_1\n 9: bipush 97\n 11: isub\n 12: iconst_1\n 13: iadd\n 14: goto 47\n 17: iload_1\n 18: invokestatic #156 // Method java/lang/Character.isUpperCase:(C)Z\n 21: ifeq 34\n 24: iload_1\n 25: bipush 65\n 27: isub\n 28: bipush 27\n 30: iadd\n 31: goto 47\n 34: new #158 // class java/lang/IllegalStateException\n 37: dup\n 38: ldc #160 // String Wrong input\n 40: invokevirtual #164 // Method java/lang/Object.toString:()Ljava/lang/String;\n 43: invokespecial #165 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 46: athrow\n 47: ireturn\n}\n",
"javap_err": ""
}
] |
dliszewski__advent-of-code-2022__76d5eea/src/main/kotlin/Day05.kt
|
import kotlin.collections.HashMap
class Day05 {
fun part1(input: String): String {
return getTopCrates(input, CrateMoverModel.CrateMover9000)
}
fun part2(input: String): String {
return getTopCrates(input, CrateMoverModel.CrateMover9001)
}
private fun getTopCrates(input: String, modelType: CrateMoverModel): String {
val (cranes, instructions) = input.split("\n\n")
val cranesNumber = cranes.parseCranesNumber()
val boxes = cranes.lines().dropLast(1).flatMap { line -> line.mapToBoxes(cranesNumber) }
val craneOperator = CraneOperator(cranesNumber, modelType, boxes)
val craneInstructions = instructions.parseToCommands()
craneOperator.executeCommands(craneInstructions)
return craneOperator.getTopCrates()
}
private fun String.parseCranesNumber() = lines()
.last()
.split(" ")
.filter { it.isNotEmpty() }
.map { it.toInt() }
.count()
private fun String.parseToCommands() = lines().map {
val (p1, p2) = it.split(" from ")
val moveQuantity = p1.replace("move ", "").toInt()
val (from, to) = p2.split(" to ")
CraneCommand(moveQuantity, from.toInt(), to.toInt())
}
data class Box(val index: Int, val content: String)
data class CraneCommand(val quantity: Int, val from: Int, val to: Int)
enum class CrateMoverModel { CrateMover9000, CrateMover9001 }
private fun String.mapToBoxes(size: Int): List<Box> {
return (1..size)
.map { craneNumber -> Box(craneNumber, this.parseBoxFromCraneNumber(craneNumber)) }
.filter { it.content.isNotBlank() }
}
private fun String.parseBoxFromCraneNumber(n: Int): String {
val craneRow = n - 1
return substring(4 * craneRow + 1, 4 * craneRow + 2)
}
private class CraneOperator(numberOfCranes: Int, private val modelType: CrateMoverModel, boxes: List<Box>) {
private val boxStacks: HashMap<Int, ArrayDeque<String>> = HashMap()
init {
(1..numberOfCranes).forEach { boxStacks[it] = ArrayDeque() }
boxes.forEach { putBoxInCrane(it) }
}
private fun putBoxInCrane(box: Box) {
boxStacks[box.index]?.addFirst(box.content)
}
fun executeCommands(commands: List<CraneCommand>) {
commands.forEach { command ->
val toMove = (1..command.quantity).map { boxStacks[command.from]?.removeLast()!! }
when (modelType) {
CrateMoverModel.CrateMover9000 -> {
boxStacks[command.to]?.addAll(toMove)
}
CrateMoverModel.CrateMover9001 -> {
boxStacks[command.to]?.addAll(toMove.reversed())
}
}
}
}
fun getTopCrates(): String {
return boxStacks.values.joinToString(separator = "") { it.last() }
}
}
}
|
[
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day05$CraneOperator$WhenMappings.class",
"javap": "Compiled from \"Day05.kt\"\npublic final class Day05$CraneOperator$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method Day05$CrateMoverModel.values:()[LDay05$CrateMoverModel;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field Day05$CrateMoverModel.CrateMover9000:LDay05$CrateMoverModel;\n 12: invokevirtual #22 // Method Day05$CrateMoverModel.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 Day05$CrateMoverModel.CrateMover9001:LDay05$CrateMoverModel;\n 26: invokevirtual #22 // Method Day05$CrateMoverModel.ordinal:()I\n 29: iconst_2\n 30: iastore\n 31: goto 35\n 34: astore_1\n 35: aload_0\n 36: putstatic #29 // Field $EnumSwitchMapping$0:[I\n 39: return\n Exception table:\n from to target type\n 7 17 20 Class java/lang/NoSuchFieldError\n 21 31 34 Class java/lang/NoSuchFieldError\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day05$Box.class",
"javap": "Compiled from \"Day05.kt\"\npublic final class Day05$Box {\n private final int index;\n\n private final java.lang.String content;\n\n public Day05$Box(int, java.lang.String);\n Code:\n 0: aload_2\n 1: ldc #9 // String content\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokespecial #18 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: iload_1\n 12: putfield #22 // Field index:I\n 15: aload_0\n 16: aload_2\n 17: putfield #25 // Field content:Ljava/lang/String;\n 20: return\n\n public final int getIndex();\n Code:\n 0: aload_0\n 1: getfield #22 // Field index:I\n 4: ireturn\n\n public final java.lang.String getContent();\n Code:\n 0: aload_0\n 1: getfield #25 // Field content:Ljava/lang/String;\n 4: areturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #22 // Field index:I\n 4: ireturn\n\n public final java.lang.String component2();\n Code:\n 0: aload_0\n 1: getfield #25 // Field content:Ljava/lang/String;\n 4: areturn\n\n public final Day05$Box copy(int, java.lang.String);\n Code:\n 0: aload_2\n 1: ldc #9 // String content\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class Day05$Box\n 9: dup\n 10: iload_1\n 11: aload_2\n 12: invokespecial #37 // Method \"<init>\":(ILjava/lang/String;)V\n 15: areturn\n\n public static Day05$Box copy$default(Day05$Box, int, java.lang.String, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_1\n 2: iand\n 3: ifeq 11\n 6: aload_0\n 7: getfield #22 // Field index:I\n 10: istore_1\n 11: iload_3\n 12: iconst_2\n 13: iand\n 14: ifeq 22\n 17: aload_0\n 18: getfield #25 // Field content:Ljava/lang/String;\n 21: astore_2\n 22: aload_0\n 23: iload_1\n 24: aload_2\n 25: invokevirtual #41 // Method copy:(ILjava/lang/String;)LDay05$Box;\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 Box(index=\n 9: invokevirtual #51 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #22 // Field index:I\n 16: invokevirtual #54 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #56 // String , content=\n 21: invokevirtual #51 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #25 // Field content:Ljava/lang/String;\n 28: invokevirtual #51 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)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 #22 // Field index: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 #25 // Field content:Ljava/lang/String;\n 16: invokevirtual #71 // Method java/lang/String.hashCode:()I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: ireturn\n\n public boolean equals(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: if_acmpne 7\n 5: iconst_1\n 6: ireturn\n 7: aload_1\n 8: instanceof #2 // class Day05$Box\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day05$Box\n 20: astore_2\n 21: aload_0\n 22: getfield #22 // Field index:I\n 25: aload_2\n 26: getfield #22 // Field index:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #25 // Field content:Ljava/lang/String;\n 38: aload_2\n 39: getfield #25 // Field content:Ljava/lang/String;\n 42: invokestatic #79 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 45: ifne 50\n 48: iconst_0\n 49: ireturn\n 50: iconst_1\n 51: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day05.class",
"javap": "Compiled from \"Day05.kt\"\npublic final class Day05 {\n public Day05();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final java.lang.String part1(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String input\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: getstatic #27 // Field Day05$CrateMoverModel.CrateMover9000:LDay05$CrateMoverModel;\n 11: invokespecial #31 // Method getTopCrates:(Ljava/lang/String;LDay05$CrateMoverModel;)Ljava/lang/String;\n 14: areturn\n\n public final java.lang.String part2(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String input\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: getstatic #36 // Field Day05$CrateMoverModel.CrateMover9001:LDay05$CrateMoverModel;\n 11: invokespecial #31 // Method getTopCrates:(Ljava/lang/String;LDay05$CrateMoverModel;)Ljava/lang/String;\n 14: areturn\n\n private final java.lang.String getTopCrates(java.lang.String, Day05$CrateMoverModel);\n Code:\n 0: aload_1\n 1: checkcast #38 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #40 // class java/lang/String\n 8: astore 4\n 10: aload 4\n 12: iconst_0\n 13: ldc #42 // String \\n\\n\n 15: aastore\n 16: aload 4\n 18: iconst_0\n 19: iconst_0\n 20: bipush 6\n 22: aconst_null\n 23: invokestatic #48 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 26: astore_3\n 27: aload_3\n 28: iconst_0\n 29: invokeinterface #54, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 34: checkcast #40 // class java/lang/String\n 37: astore 4\n 39: aload_3\n 40: iconst_1\n 41: invokeinterface #54, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 46: checkcast #40 // class java/lang/String\n 49: astore 5\n 51: aload_0\n 52: aload 4\n 54: invokespecial #58 // Method parseCranesNumber:(Ljava/lang/String;)I\n 57: istore 6\n 59: aload 4\n 61: checkcast #38 // class java/lang/CharSequence\n 64: invokestatic #62 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 67: iconst_1\n 68: invokestatic #68 // Method kotlin/collections/CollectionsKt.dropLast:(Ljava/util/List;I)Ljava/util/List;\n 71: checkcast #70 // class java/lang/Iterable\n 74: astore 8\n 76: iconst_0\n 77: istore 9\n 79: aload 8\n 81: astore 10\n 83: new #72 // class java/util/ArrayList\n 86: dup\n 87: invokespecial #73 // Method java/util/ArrayList.\"<init>\":()V\n 90: checkcast #75 // class java/util/Collection\n 93: astore 11\n 95: iconst_0\n 96: istore 12\n 98: aload 10\n 100: invokeinterface #79, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 105: astore 13\n 107: aload 13\n 109: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 114: ifeq 160\n 117: aload 13\n 119: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 124: astore 14\n 126: aload 14\n 128: checkcast #40 // class java/lang/String\n 131: astore 15\n 133: iconst_0\n 134: istore 16\n 136: aload_0\n 137: aload 15\n 139: iload 6\n 141: invokespecial #93 // Method mapToBoxes:(Ljava/lang/String;I)Ljava/util/List;\n 144: checkcast #70 // class java/lang/Iterable\n 147: astore 15\n 149: aload 11\n 151: aload 15\n 153: invokestatic #97 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 156: pop\n 157: goto 107\n 160: aload 11\n 162: checkcast #50 // class java/util/List\n 165: nop\n 166: astore 7\n 168: new #99 // class Day05$CraneOperator\n 171: dup\n 172: iload 6\n 174: aload_2\n 175: aload 7\n 177: invokespecial #102 // Method Day05$CraneOperator.\"<init>\":(ILDay05$CrateMoverModel;Ljava/util/List;)V\n 180: astore 8\n 182: aload_0\n 183: aload 5\n 185: invokespecial #106 // Method parseToCommands:(Ljava/lang/String;)Ljava/util/List;\n 188: astore 9\n 190: aload 8\n 192: aload 9\n 194: invokevirtual #110 // Method Day05$CraneOperator.executeCommands:(Ljava/util/List;)V\n 197: aload 8\n 199: invokevirtual #113 // Method Day05$CraneOperator.getTopCrates:()Ljava/lang/String;\n 202: areturn\n\n private final int parseCranesNumber(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #38 // class java/lang/CharSequence\n 4: invokestatic #62 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 7: invokestatic #139 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 10: checkcast #38 // class java/lang/CharSequence\n 13: iconst_1\n 14: anewarray #40 // class java/lang/String\n 17: astore_2\n 18: aload_2\n 19: iconst_0\n 20: ldc #141 // String\n 22: aastore\n 23: aload_2\n 24: iconst_0\n 25: iconst_0\n 26: bipush 6\n 28: aconst_null\n 29: invokestatic #48 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 32: checkcast #70 // class java/lang/Iterable\n 35: astore_2\n 36: nop\n 37: iconst_0\n 38: istore_3\n 39: aload_2\n 40: astore 4\n 42: new #72 // class java/util/ArrayList\n 45: dup\n 46: invokespecial #73 // Method java/util/ArrayList.\"<init>\":()V\n 49: checkcast #75 // class java/util/Collection\n 52: astore 5\n 54: iconst_0\n 55: istore 6\n 57: aload 4\n 59: invokeinterface #79, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 64: astore 7\n 66: aload 7\n 68: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 73: ifeq 130\n 76: aload 7\n 78: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 83: astore 8\n 85: aload 8\n 87: checkcast #40 // class java/lang/String\n 90: astore 9\n 92: iconst_0\n 93: istore 10\n 95: aload 9\n 97: checkcast #38 // class java/lang/CharSequence\n 100: invokeinterface #145, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 105: ifle 112\n 108: iconst_1\n 109: goto 113\n 112: iconst_0\n 113: nop\n 114: ifeq 66\n 117: aload 5\n 119: aload 8\n 121: invokeinterface #149, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 126: pop\n 127: goto 66\n 130: aload 5\n 132: checkcast #50 // class java/util/List\n 135: nop\n 136: checkcast #70 // class java/lang/Iterable\n 139: astore_2\n 140: nop\n 141: iconst_0\n 142: istore_3\n 143: aload_2\n 144: astore 4\n 146: new #72 // class java/util/ArrayList\n 149: dup\n 150: aload_2\n 151: bipush 10\n 153: invokestatic #153 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 156: invokespecial #156 // Method java/util/ArrayList.\"<init>\":(I)V\n 159: checkcast #75 // class java/util/Collection\n 162: astore 5\n 164: iconst_0\n 165: istore 6\n 167: aload 4\n 169: invokeinterface #79, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 174: astore 7\n 176: aload 7\n 178: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 183: ifeq 230\n 186: aload 7\n 188: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 193: astore 8\n 195: aload 5\n 197: aload 8\n 199: checkcast #40 // class java/lang/String\n 202: astore 9\n 204: astore 11\n 206: iconst_0\n 207: istore 10\n 209: aload 9\n 211: invokestatic #161 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 214: nop\n 215: invokestatic #165 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 218: aload 11\n 220: swap\n 221: invokeinterface #149, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 226: pop\n 227: goto 176\n 230: aload 5\n 232: checkcast #50 // class java/util/List\n 235: nop\n 236: checkcast #75 // class java/util/Collection\n 239: invokeinterface #168, 1 // InterfaceMethod java/util/Collection.size:()I\n 244: ireturn\n\n private final java.util.List<Day05$CraneCommand> parseToCommands(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #38 // class java/lang/CharSequence\n 4: invokestatic #62 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 7: checkcast #70 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: astore 4\n 16: new #72 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: bipush 10\n 23: invokestatic #153 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #156 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #75 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: aload 4\n 39: invokeinterface #79, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 7\n 46: aload 7\n 48: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 237\n 56: aload 7\n 58: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 8\n 65: aload 5\n 67: aload 8\n 69: checkcast #40 // class java/lang/String\n 72: astore 9\n 74: astore 18\n 76: iconst_0\n 77: istore 10\n 79: aload 9\n 81: checkcast #38 // class java/lang/CharSequence\n 84: iconst_1\n 85: anewarray #40 // class java/lang/String\n 88: astore 11\n 90: aload 11\n 92: iconst_0\n 93: ldc #184 // String from\n 95: aastore\n 96: aload 11\n 98: iconst_0\n 99: iconst_0\n 100: bipush 6\n 102: aconst_null\n 103: invokestatic #48 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 106: astore 12\n 108: aload 12\n 110: iconst_0\n 111: invokeinterface #54, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 116: checkcast #40 // class java/lang/String\n 119: astore 11\n 121: aload 12\n 123: iconst_1\n 124: invokeinterface #54, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 129: checkcast #40 // class java/lang/String\n 132: astore 13\n 134: aload 11\n 136: ldc #186 // String move\n 138: ldc #188 // String\n 140: iconst_0\n 141: iconst_4\n 142: aconst_null\n 143: invokestatic #192 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 146: invokestatic #161 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 149: istore 14\n 151: aload 13\n 153: checkcast #38 // class java/lang/CharSequence\n 156: iconst_1\n 157: anewarray #40 // class java/lang/String\n 160: astore 15\n 162: aload 15\n 164: iconst_0\n 165: ldc #194 // String to\n 167: aastore\n 168: aload 15\n 170: iconst_0\n 171: iconst_0\n 172: bipush 6\n 174: aconst_null\n 175: invokestatic #48 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 178: astore 16\n 180: aload 16\n 182: iconst_0\n 183: invokeinterface #54, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 188: checkcast #40 // class java/lang/String\n 191: astore 15\n 193: aload 16\n 195: iconst_1\n 196: invokeinterface #54, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 201: checkcast #40 // class java/lang/String\n 204: astore 17\n 206: new #196 // class Day05$CraneCommand\n 209: dup\n 210: iload 14\n 212: aload 15\n 214: invokestatic #161 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 217: aload 17\n 219: invokestatic #161 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 222: invokespecial #199 // Method Day05$CraneCommand.\"<init>\":(III)V\n 225: aload 18\n 227: swap\n 228: invokeinterface #149, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 233: pop\n 234: goto 46\n 237: aload 5\n 239: checkcast #50 // class java/util/List\n 242: nop\n 243: areturn\n\n private final java.util.List<Day05$Box> mapToBoxes(java.lang.String, int);\n Code:\n 0: new #209 // class kotlin/ranges/IntRange\n 3: dup\n 4: iconst_1\n 5: iload_2\n 6: invokespecial #212 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 9: checkcast #70 // class java/lang/Iterable\n 12: astore_3\n 13: nop\n 14: iconst_0\n 15: istore 4\n 17: aload_3\n 18: astore 5\n 20: new #72 // class java/util/ArrayList\n 23: dup\n 24: aload_3\n 25: bipush 10\n 27: invokestatic #153 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 30: invokespecial #156 // Method java/util/ArrayList.\"<init>\":(I)V\n 33: checkcast #75 // class java/util/Collection\n 36: astore 6\n 38: iconst_0\n 39: istore 7\n 41: aload 5\n 43: invokeinterface #79, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 48: astore 8\n 50: aload 8\n 52: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 57: ifeq 109\n 60: aload 8\n 62: checkcast #214 // class kotlin/collections/IntIterator\n 65: invokevirtual #217 // Method kotlin/collections/IntIterator.nextInt:()I\n 68: istore 9\n 70: aload 6\n 72: iload 9\n 74: istore 10\n 76: astore 12\n 78: iconst_0\n 79: istore 11\n 81: new #219 // class Day05$Box\n 84: dup\n 85: iload 10\n 87: aload_0\n 88: aload_1\n 89: iload 10\n 91: invokespecial #223 // Method parseBoxFromCraneNumber:(Ljava/lang/String;I)Ljava/lang/String;\n 94: invokespecial #226 // Method Day05$Box.\"<init>\":(ILjava/lang/String;)V\n 97: aload 12\n 99: swap\n 100: invokeinterface #149, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 105: pop\n 106: goto 50\n 109: aload 6\n 111: checkcast #50 // class java/util/List\n 114: nop\n 115: checkcast #70 // class java/lang/Iterable\n 118: astore_3\n 119: nop\n 120: iconst_0\n 121: istore 4\n 123: aload_3\n 124: astore 5\n 126: new #72 // class java/util/ArrayList\n 129: dup\n 130: invokespecial #73 // Method java/util/ArrayList.\"<init>\":()V\n 133: checkcast #75 // class java/util/Collection\n 136: astore 6\n 138: iconst_0\n 139: istore 7\n 141: aload 5\n 143: invokeinterface #79, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 148: astore 8\n 150: aload 8\n 152: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 157: ifeq 215\n 160: aload 8\n 162: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 167: astore 9\n 169: aload 9\n 171: checkcast #219 // class Day05$Box\n 174: astore 10\n 176: iconst_0\n 177: istore 11\n 179: aload 10\n 181: invokevirtual #229 // Method Day05$Box.getContent:()Ljava/lang/String;\n 184: checkcast #38 // class java/lang/CharSequence\n 187: invokestatic #233 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 190: ifne 197\n 193: iconst_1\n 194: goto 198\n 197: iconst_0\n 198: nop\n 199: ifeq 150\n 202: aload 6\n 204: aload 9\n 206: invokeinterface #149, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 211: pop\n 212: goto 150\n 215: aload 6\n 217: checkcast #50 // class java/util/List\n 220: nop\n 221: areturn\n\n private final java.lang.String parseBoxFromCraneNumber(java.lang.String, int);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: isub\n 3: istore_3\n 4: aload_1\n 5: iconst_4\n 6: iload_3\n 7: imul\n 8: iconst_1\n 9: iadd\n 10: iconst_4\n 11: iload_3\n 12: imul\n 13: iconst_2\n 14: iadd\n 15: invokevirtual #242 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 18: dup\n 19: ldc #244 // String substring(...)\n 21: invokestatic #247 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 24: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day05$CraneOperator.class",
"javap": "Compiled from \"Day05.kt\"\nfinal class Day05$CraneOperator {\n private final Day05$CrateMoverModel modelType;\n\n private final java.util.HashMap<java.lang.Integer, kotlin.collections.ArrayDeque<java.lang.String>> boxStacks;\n\n public Day05$CraneOperator(int, Day05$CrateMoverModel, java.util.List<Day05$Box>);\n Code:\n 0: aload_2\n 1: ldc #10 // String modelType\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 boxes\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_2\n 18: putfield #24 // Field modelType:LDay05$CrateMoverModel;\n 21: aload_0\n 22: new #26 // class java/util/HashMap\n 25: dup\n 26: invokespecial #27 // Method java/util/HashMap.\"<init>\":()V\n 29: putfield #31 // Field boxStacks:Ljava/util/HashMap;\n 32: nop\n 33: new #33 // class kotlin/ranges/IntRange\n 36: dup\n 37: iconst_1\n 38: iload_1\n 39: invokespecial #36 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 42: checkcast #38 // class java/lang/Iterable\n 45: astore 4\n 47: iconst_0\n 48: istore 5\n 50: aload 4\n 52: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 57: astore 6\n 59: aload 6\n 61: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 66: ifeq 120\n 69: aload 6\n 71: checkcast #50 // class kotlin/collections/IntIterator\n 74: invokevirtual #54 // Method kotlin/collections/IntIterator.nextInt:()I\n 77: istore 7\n 79: iload 7\n 81: istore 8\n 83: iconst_0\n 84: istore 9\n 86: iload 8\n 88: invokestatic #60 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 91: astore 10\n 93: aload_0\n 94: getfield #31 // Field boxStacks:Ljava/util/HashMap;\n 97: checkcast #62 // class java/util/Map\n 100: aload 10\n 102: new #64 // class kotlin/collections/ArrayDeque\n 105: dup\n 106: invokespecial #65 // Method kotlin/collections/ArrayDeque.\"<init>\":()V\n 109: invokeinterface #69, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 114: pop\n 115: nop\n 116: nop\n 117: goto 59\n 120: nop\n 121: aload_3\n 122: checkcast #38 // class java/lang/Iterable\n 125: astore 4\n 127: iconst_0\n 128: istore 5\n 130: aload 4\n 132: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 137: astore 6\n 139: aload 6\n 141: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 146: ifeq 178\n 149: aload 6\n 151: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 156: astore 7\n 158: aload 7\n 160: checkcast #75 // class Day05$Box\n 163: astore 8\n 165: iconst_0\n 166: istore 9\n 168: aload_0\n 169: aload 8\n 171: invokespecial #79 // Method putBoxInCrane:(LDay05$Box;)V\n 174: nop\n 175: goto 139\n 178: nop\n 179: nop\n 180: return\n\n private final void putBoxInCrane(Day05$Box);\n Code:\n 0: aload_0\n 1: getfield #31 // Field boxStacks:Ljava/util/HashMap;\n 4: aload_1\n 5: invokevirtual #100 // Method Day05$Box.getIndex:()I\n 8: invokestatic #60 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 11: invokevirtual #104 // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 14: checkcast #64 // class kotlin/collections/ArrayDeque\n 17: dup\n 18: ifnull 31\n 21: aload_1\n 22: invokevirtual #108 // Method Day05$Box.getContent:()Ljava/lang/String;\n 25: invokevirtual #112 // Method kotlin/collections/ArrayDeque.addFirst:(Ljava/lang/Object;)V\n 28: goto 32\n 31: pop\n 32: return\n\n public final void executeCommands(java.util.List<Day05$CraneCommand>);\n Code:\n 0: aload_1\n 1: ldc #118 // String commands\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #38 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 19: astore 4\n 21: aload 4\n 23: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 28: ifeq 323\n 31: aload 4\n 33: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 38: astore 5\n 40: aload 5\n 42: checkcast #120 // class Day05$CraneCommand\n 45: astore 6\n 47: iconst_0\n 48: istore 7\n 50: new #33 // class kotlin/ranges/IntRange\n 53: dup\n 54: iconst_1\n 55: aload 6\n 57: invokevirtual #123 // Method Day05$CraneCommand.getQuantity:()I\n 60: invokespecial #36 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 63: checkcast #38 // class java/lang/Iterable\n 66: astore 8\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: astore 10\n 75: new #125 // class java/util/ArrayList\n 78: dup\n 79: aload 8\n 81: bipush 10\n 83: invokestatic #131 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 86: invokespecial #134 // Method java/util/ArrayList.\"<init>\":(I)V\n 89: checkcast #136 // class java/util/Collection\n 92: astore 11\n 94: iconst_0\n 95: istore 12\n 97: aload 10\n 99: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 104: astore 13\n 106: aload 13\n 108: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 113: ifeq 186\n 116: aload 13\n 118: checkcast #50 // class kotlin/collections/IntIterator\n 121: invokevirtual #54 // Method kotlin/collections/IntIterator.nextInt:()I\n 124: istore 14\n 126: aload 11\n 128: iload 14\n 130: istore 15\n 132: astore 16\n 134: iconst_0\n 135: istore 17\n 137: aload_0\n 138: getfield #31 // Field boxStacks:Ljava/util/HashMap;\n 141: aload 6\n 143: invokevirtual #139 // Method Day05$CraneCommand.getFrom:()I\n 146: invokestatic #60 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 149: invokevirtual #104 // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 152: checkcast #64 // class kotlin/collections/ArrayDeque\n 155: dup\n 156: ifnull 168\n 159: invokevirtual #142 // Method kotlin/collections/ArrayDeque.removeLast:()Ljava/lang/Object;\n 162: checkcast #144 // class java/lang/String\n 165: goto 170\n 168: pop\n 169: aconst_null\n 170: dup\n 171: invokestatic #147 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 174: aload 16\n 176: swap\n 177: invokeinterface #151, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 182: pop\n 183: goto 106\n 186: aload 11\n 188: checkcast #97 // class java/util/List\n 191: nop\n 192: astore 18\n 194: aload_0\n 195: getfield #24 // Field modelType:LDay05$CrateMoverModel;\n 198: getstatic #157 // Field Day05$CraneOperator$WhenMappings.$EnumSwitchMapping$0:[I\n 201: swap\n 202: invokevirtual #160 // Method Day05$CrateMoverModel.ordinal:()I\n 205: iaload\n 206: tableswitch { // 1 to 2\n 1: 228\n 2: 266\n default: 310\n }\n 228: aload_0\n 229: getfield #31 // Field boxStacks:Ljava/util/HashMap;\n 232: aload 6\n 234: invokevirtual #163 // Method Day05$CraneCommand.getTo:()I\n 237: invokestatic #60 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 240: invokevirtual #104 // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 243: checkcast #64 // class kotlin/collections/ArrayDeque\n 246: dup\n 247: ifnull 262\n 250: aload 18\n 252: checkcast #136 // class java/util/Collection\n 255: invokevirtual #167 // Method kotlin/collections/ArrayDeque.addAll:(Ljava/util/Collection;)Z\n 258: pop\n 259: goto 318\n 262: pop\n 263: goto 318\n 266: aload_0\n 267: getfield #31 // Field boxStacks:Ljava/util/HashMap;\n 270: aload 6\n 272: invokevirtual #163 // Method Day05$CraneCommand.getTo:()I\n 275: invokestatic #60 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 278: invokevirtual #104 // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 281: checkcast #64 // class kotlin/collections/ArrayDeque\n 284: dup\n 285: ifnull 306\n 288: aload 18\n 290: checkcast #38 // class java/lang/Iterable\n 293: invokestatic #171 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 296: checkcast #136 // class java/util/Collection\n 299: invokevirtual #167 // Method kotlin/collections/ArrayDeque.addAll:(Ljava/util/Collection;)Z\n 302: pop\n 303: goto 318\n 306: pop\n 307: goto 318\n 310: new #173 // class kotlin/NoWhenBranchMatchedException\n 313: dup\n 314: invokespecial #174 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 317: athrow\n 318: nop\n 319: nop\n 320: goto 21\n 323: nop\n 324: return\n\n public final java.lang.String getTopCrates();\n Code:\n 0: aload_0\n 1: getfield #31 // Field boxStacks:Ljava/util/HashMap;\n 4: invokevirtual #191 // Method java/util/HashMap.values:()Ljava/util/Collection;\n 7: dup\n 8: ldc #193 // String <get-values>(...)\n 10: invokestatic #196 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 13: checkcast #38 // class java/lang/Iterable\n 16: ldc #198 // String\n 18: checkcast #200 // class java/lang/CharSequence\n 21: aconst_null\n 22: aconst_null\n 23: iconst_0\n 24: aconst_null\n 25: invokedynamic #218, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 30: bipush 30\n 32: aconst_null\n 33: invokestatic #222 // 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 36: areturn\n\n private static final java.lang.CharSequence getTopCrates$lambda$4(kotlin.collections.ArrayDeque);\n Code:\n 0: aload_0\n 1: ldc #223 // String it\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokevirtual #226 // Method kotlin/collections/ArrayDeque.last:()Ljava/lang/Object;\n 10: checkcast #200 // class java/lang/CharSequence\n 13: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day05$CraneCommand.class",
"javap": "Compiled from \"Day05.kt\"\npublic final class Day05$CraneCommand {\n private final int quantity;\n\n private final int from;\n\n private final int to;\n\n public Day05$CraneCommand(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 quantity:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field from:I\n 14: aload_0\n 15: iload_3\n 16: putfield #19 // Field to:I\n 19: return\n\n public final int getQuantity();\n Code:\n 0: aload_0\n 1: getfield #13 // Field quantity:I\n 4: ireturn\n\n public final int getFrom();\n Code:\n 0: aload_0\n 1: getfield #16 // Field from:I\n 4: ireturn\n\n public final int getTo();\n Code:\n 0: aload_0\n 1: getfield #19 // Field to:I\n 4: ireturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field quantity:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field from:I\n 4: ireturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #19 // Field to:I\n 4: ireturn\n\n public final Day05$CraneCommand copy(int, int, int);\n Code:\n 0: new #2 // class Day05$CraneCommand\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 Day05$CraneCommand copy$default(Day05$CraneCommand, 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 quantity:I\n 11: istore_1\n 12: iload 4\n 14: iconst_2\n 15: iand\n 16: ifeq 24\n 19: aload_0\n 20: getfield #16 // Field from:I\n 23: istore_2\n 24: iload 4\n 26: iconst_4\n 27: iand\n 28: ifeq 36\n 31: aload_0\n 32: getfield #19 // Field to:I\n 35: istore_3\n 36: aload_0\n 37: iload_1\n 38: iload_2\n 39: iload_3\n 40: invokevirtual #37 // Method copy:(III)LDay05$CraneCommand;\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 CraneCommand(quantity=\n 9: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field quantity:I\n 16: invokevirtual #51 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #53 // String , from=\n 21: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #16 // Field from:I\n 28: invokevirtual #51 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #55 // String , to=\n 33: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #19 // Field to:I\n 40: invokevirtual #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 quantity: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 from: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 to: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 Day05$CraneCommand\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day05$CraneCommand\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field quantity:I\n 25: aload_2\n 26: getfield #13 // Field quantity:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field from:I\n 38: aload_2\n 39: getfield #16 // Field from:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: aload_0\n 48: getfield #19 // Field to:I\n 51: aload_2\n 52: getfield #19 // Field to:I\n 55: if_icmpeq 60\n 58: iconst_0\n 59: ireturn\n 60: iconst_1\n 61: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day05$CrateMoverModel.class",
"javap": "Compiled from \"Day05.kt\"\npublic final class Day05$CrateMoverModel extends java.lang.Enum<Day05$CrateMoverModel> {\n public static final Day05$CrateMoverModel CrateMover9000;\n\n public static final Day05$CrateMoverModel CrateMover9001;\n\n private static final Day05$CrateMoverModel[] $VALUES;\n\n private static final kotlin.enums.EnumEntries $ENTRIES;\n\n private Day05$CrateMoverModel();\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: invokespecial #10 // Method java/lang/Enum.\"<init>\":(Ljava/lang/String;I)V\n 6: return\n\n public static Day05$CrateMoverModel[] values();\n Code:\n 0: getstatic #22 // Field $VALUES:[LDay05$CrateMoverModel;\n 3: invokevirtual #28 // Method java/lang/Object.clone:()Ljava/lang/Object;\n 6: checkcast #29 // class \"[LDay05$CrateMoverModel;\"\n 9: areturn\n\n public static Day05$CrateMoverModel valueOf(java.lang.String);\n Code:\n 0: ldc #2 // class Day05$CrateMoverModel\n 2: aload_0\n 3: invokestatic #34 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;\n 6: checkcast #2 // class Day05$CrateMoverModel\n 9: areturn\n\n public static kotlin.enums.EnumEntries<Day05$CrateMoverModel> getEntries();\n Code:\n 0: getstatic #43 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 3: areturn\n\n private static final Day05$CrateMoverModel[] $values();\n Code:\n 0: iconst_2\n 1: anewarray #2 // class Day05$CrateMoverModel\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: getstatic #47 // Field CrateMover9000:LDay05$CrateMoverModel;\n 10: aastore\n 11: aload_0\n 12: iconst_1\n 13: getstatic #50 // Field CrateMover9001:LDay05$CrateMoverModel;\n 16: aastore\n 17: aload_0\n 18: areturn\n\n static {};\n Code:\n 0: new #2 // class Day05$CrateMoverModel\n 3: dup\n 4: ldc #52 // String CrateMover9000\n 6: iconst_0\n 7: invokespecial #53 // Method \"<init>\":(Ljava/lang/String;I)V\n 10: putstatic #47 // Field CrateMover9000:LDay05$CrateMoverModel;\n 13: new #2 // class Day05$CrateMoverModel\n 16: dup\n 17: ldc #54 // String CrateMover9001\n 19: iconst_1\n 20: invokespecial #53 // Method \"<init>\":(Ljava/lang/String;I)V\n 23: putstatic #50 // Field CrateMover9001:LDay05$CrateMoverModel;\n 26: invokestatic #56 // Method $values:()[LDay05$CrateMoverModel;\n 29: putstatic #22 // Field $VALUES:[LDay05$CrateMoverModel;\n 32: getstatic #22 // Field $VALUES:[LDay05$CrateMoverModel;\n 35: checkcast #58 // class \"[Ljava/lang/Enum;\"\n 38: invokestatic #64 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;\n 41: putstatic #43 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 44: return\n}\n",
"javap_err": ""
}
] |
dliszewski__advent-of-code-2022__76d5eea/src/main/kotlin/Day12.kt
|
import java.util.*
class Day12 {
fun part1(input: List<String>): Int {
val area = mapToArea(input)
return area.traverseFromStart()
}
fun part2(input: List<String>): Int {
return mapToArea(input).traverseFromEnd()
}
private fun mapToArea(input: List<String>): Area {
var finishPoint: Point? = null
var startingPoint: Point? = null
val field: Map<Point, Int> = input.flatMapIndexed { y, row ->
row.mapIndexed { x, heightCode ->
val point = Point(x, y)
val height = heightCode.decodeHeight()
when (heightCode) {
'E' -> point to height.also { finishPoint = point }
'S' -> point to height.also { startingPoint = point }
else -> point to height
}
}
}.toMap()
return Area(startingPoint!!, finishPoint!!, field)
}
private fun Char.decodeHeight(): Int {
return when (this) {
'S' -> 'a' - 'a'
'E' -> 'z' - 'a'
in 'a'..'z' -> this - 'a'
else -> error("Wrong level value $this")
}
}
data class Area(
val startingPoint: Point,
val destination: Point,
val field: Map<Point, Int>
) {
fun traverseFromStart(): Int {
val canMove: (Int, Int) -> Boolean = { nextPlace, currentPlace -> nextPlace - currentPlace <= 1 }
val isDestination: (Path) -> Boolean = { it.point == destination }
return traverse(canMove, isDestination, startingPoint)
}
fun traverseFromEnd(): Int {
val canMove: (Int, Int) -> Boolean = { nextPlace, currentPlace -> currentPlace - nextPlace <= 1 }
val isDestination: (Path) -> Boolean = { field[it.point] == 0 }
return traverse(canMove, isDestination, destination)
}
private fun traverse(
canMove: (Int, Int) -> Boolean,
isDestination: (Path) -> Boolean,
startingPoint: Point
): Int {
val toBeEvaluated = PriorityQueue<Path>().apply { add(Path(startingPoint, 0)) }
val visited = mutableSetOf<Point>()
while (toBeEvaluated.isNotEmpty()) {
val currentPlace = toBeEvaluated.poll()
if (isDestination(currentPlace)) {
return currentPlace.distanceSoFar
}
if (currentPlace.point !in visited) {
visited.add(currentPlace.point)
currentPlace.point
.neighbors()
.filter { nextPlace -> nextPlace in field }
.filter { nextPlace -> canMove(field.getValue(nextPlace), field.getValue(currentPlace.point)) }
.map { nextPlace -> Path(nextPlace, currentPlace.distanceSoFar + 1) }
.forEach { path -> toBeEvaluated.offer(path) }
}
}
error("No path found to destination")
}
}
data class Path(val point: Point, val distanceSoFar: Int) : Comparable<Path> {
override fun compareTo(other: Path): Int {
return distanceSoFar - other.distanceSoFar
}
}
data class Point(val x: Int, val y: Int) {
fun neighbors(): List<Point> {
return listOf(
Point(x, y + 1),
Point(x, y - 1),
Point(x + 1, y),
Point(x - 1, y)
)
}
}
}
|
[
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day12$Area.class",
"javap": "Compiled from \"Day12.kt\"\npublic final class Day12$Area {\n private final Day12$Point startingPoint;\n\n private final Day12$Point destination;\n\n private final java.util.Map<Day12$Point, java.lang.Integer> field;\n\n public Day12$Area(Day12$Point, Day12$Point, java.util.Map<Day12$Point, java.lang.Integer>);\n Code:\n 0: aload_1\n 1: ldc #10 // String startingPoint\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #18 // String destination\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_3\n 13: ldc #20 // String field\n 15: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: aload_0\n 19: invokespecial #23 // Method java/lang/Object.\"<init>\":()V\n 22: aload_0\n 23: aload_1\n 24: putfield #26 // Field startingPoint:LDay12$Point;\n 27: aload_0\n 28: aload_2\n 29: putfield #28 // Field destination:LDay12$Point;\n 32: aload_0\n 33: aload_3\n 34: putfield #31 // Field field:Ljava/util/Map;\n 37: return\n\n public final Day12$Point getStartingPoint();\n Code:\n 0: aload_0\n 1: getfield #26 // Field startingPoint:LDay12$Point;\n 4: areturn\n\n public final Day12$Point getDestination();\n Code:\n 0: aload_0\n 1: getfield #28 // Field destination:LDay12$Point;\n 4: areturn\n\n public final java.util.Map<Day12$Point, java.lang.Integer> getField();\n Code:\n 0: aload_0\n 1: getfield #31 // Field field:Ljava/util/Map;\n 4: areturn\n\n public final int traverseFromStart();\n Code:\n 0: invokedynamic #61, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;\n 5: astore_1\n 6: aload_0\n 7: invokedynamic #73, 0 // InvokeDynamic #1:invoke:(LDay12$Area;)Lkotlin/jvm/functions/Function1;\n 12: astore_2\n 13: aload_0\n 14: aload_1\n 15: aload_2\n 16: aload_0\n 17: getfield #26 // Field startingPoint:LDay12$Point;\n 20: invokespecial #77 // Method traverse:(Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;LDay12$Point;)I\n 23: ireturn\n\n public final int traverseFromEnd();\n Code:\n 0: invokedynamic #87, 0 // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function2;\n 5: astore_1\n 6: aload_0\n 7: invokedynamic #92, 0 // InvokeDynamic #3:invoke:(LDay12$Area;)Lkotlin/jvm/functions/Function1;\n 12: astore_2\n 13: aload_0\n 14: aload_1\n 15: aload_2\n 16: aload_0\n 17: getfield #28 // Field destination:LDay12$Point;\n 20: invokespecial #77 // Method traverse:(Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;LDay12$Point;)I\n 23: ireturn\n\n private final int traverse(kotlin.jvm.functions.Function2<? super java.lang.Integer, ? super java.lang.Integer, java.lang.Boolean>, kotlin.jvm.functions.Function1<? super Day12$Path, java.lang.Boolean>, Day12$Point);\n Code:\n 0: new #95 // class java/util/PriorityQueue\n 3: dup\n 4: invokespecial #96 // Method java/util/PriorityQueue.\"<init>\":()V\n 7: astore 5\n 9: aload 5\n 11: astore 6\n 13: iconst_0\n 14: istore 7\n 16: aload 6\n 18: new #98 // class Day12$Path\n 21: dup\n 22: aload_3\n 23: iconst_0\n 24: invokespecial #101 // Method Day12$Path.\"<init>\":(LDay12$Point;I)V\n 27: invokevirtual #105 // Method java/util/PriorityQueue.add:(Ljava/lang/Object;)Z\n 30: pop\n 31: aload 5\n 33: astore 4\n 35: new #107 // class java/util/LinkedHashSet\n 38: dup\n 39: invokespecial #108 // Method java/util/LinkedHashSet.\"<init>\":()V\n 42: checkcast #110 // class java/util/Set\n 45: astore 5\n 47: aload 4\n 49: checkcast #112 // class java/util/Collection\n 52: invokeinterface #116, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 57: ifne 64\n 60: iconst_1\n 61: goto 65\n 64: iconst_0\n 65: ifeq 537\n 68: aload 4\n 70: invokevirtual #120 // Method java/util/PriorityQueue.poll:()Ljava/lang/Object;\n 73: checkcast #98 // class Day12$Path\n 76: astore 6\n 78: aload_2\n 79: aload 6\n 81: invokestatic #124 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 84: aload 6\n 86: invokeinterface #128, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 91: checkcast #130 // class java/lang/Boolean\n 94: invokevirtual #133 // Method java/lang/Boolean.booleanValue:()Z\n 97: ifeq 106\n 100: aload 6\n 102: invokevirtual #136 // Method Day12$Path.getDistanceSoFar:()I\n 105: ireturn\n 106: aload 5\n 108: aload 6\n 110: invokevirtual #139 // Method Day12$Path.getPoint:()LDay12$Point;\n 113: invokeinterface #142, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 118: ifne 47\n 121: aload 5\n 123: aload 6\n 125: invokevirtual #139 // Method Day12$Path.getPoint:()LDay12$Point;\n 128: invokeinterface #143, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 133: pop\n 134: aload 6\n 136: invokevirtual #139 // Method Day12$Path.getPoint:()LDay12$Point;\n 139: invokevirtual #149 // Method Day12$Point.neighbors:()Ljava/util/List;\n 142: checkcast #151 // class java/lang/Iterable\n 145: astore 7\n 147: nop\n 148: iconst_0\n 149: istore 8\n 151: aload 7\n 153: astore 9\n 155: new #153 // class java/util/ArrayList\n 158: dup\n 159: invokespecial #154 // Method java/util/ArrayList.\"<init>\":()V\n 162: checkcast #112 // class java/util/Collection\n 165: astore 10\n 167: iconst_0\n 168: istore 11\n 170: aload 9\n 172: invokeinterface #158, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 177: astore 12\n 179: aload 12\n 181: invokeinterface #163, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 186: ifeq 236\n 189: aload 12\n 191: invokeinterface #166, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 196: astore 13\n 198: aload 13\n 200: checkcast #145 // class Day12$Point\n 203: astore 14\n 205: iconst_0\n 206: istore 15\n 208: aload_0\n 209: getfield #31 // Field field:Ljava/util/Map;\n 212: aload 14\n 214: invokeinterface #171, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 219: nop\n 220: ifeq 179\n 223: aload 10\n 225: aload 13\n 227: invokeinterface #172, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 232: pop\n 233: goto 179\n 236: aload 10\n 238: checkcast #174 // class java/util/List\n 241: nop\n 242: checkcast #151 // class java/lang/Iterable\n 245: astore 7\n 247: nop\n 248: iconst_0\n 249: istore 8\n 251: aload 7\n 253: astore 9\n 255: new #153 // class java/util/ArrayList\n 258: dup\n 259: invokespecial #154 // Method java/util/ArrayList.\"<init>\":()V\n 262: checkcast #112 // class java/util/Collection\n 265: astore 10\n 267: iconst_0\n 268: istore 11\n 270: aload 9\n 272: invokeinterface #158, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 277: astore 12\n 279: aload 12\n 281: invokeinterface #163, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 286: ifeq 357\n 289: aload 12\n 291: invokeinterface #166, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 296: astore 13\n 298: aload 13\n 300: checkcast #145 // class Day12$Point\n 303: astore 14\n 305: iconst_0\n 306: istore 15\n 308: aload_1\n 309: aload_0\n 310: getfield #31 // Field field:Ljava/util/Map;\n 313: aload 14\n 315: invokestatic #180 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 318: aload_0\n 319: getfield #31 // Field field:Ljava/util/Map;\n 322: aload 6\n 324: invokevirtual #139 // Method Day12$Path.getPoint:()LDay12$Point;\n 327: invokestatic #180 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 330: invokeinterface #184, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 335: checkcast #130 // class java/lang/Boolean\n 338: invokevirtual #133 // Method java/lang/Boolean.booleanValue:()Z\n 341: ifeq 279\n 344: aload 10\n 346: aload 13\n 348: invokeinterface #172, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 353: pop\n 354: goto 279\n 357: aload 10\n 359: checkcast #174 // class java/util/List\n 362: nop\n 363: checkcast #151 // class java/lang/Iterable\n 366: astore 7\n 368: nop\n 369: iconst_0\n 370: istore 8\n 372: aload 7\n 374: astore 9\n 376: new #153 // class java/util/ArrayList\n 379: dup\n 380: aload 7\n 382: bipush 10\n 384: invokestatic #190 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 387: invokespecial #193 // Method java/util/ArrayList.\"<init>\":(I)V\n 390: checkcast #112 // class java/util/Collection\n 393: astore 10\n 395: iconst_0\n 396: istore 11\n 398: aload 9\n 400: invokeinterface #158, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 405: astore 12\n 407: aload 12\n 409: invokeinterface #163, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 414: ifeq 468\n 417: aload 12\n 419: invokeinterface #166, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 424: astore 13\n 426: aload 10\n 428: aload 13\n 430: checkcast #145 // class Day12$Point\n 433: astore 14\n 435: astore 16\n 437: iconst_0\n 438: istore 15\n 440: new #98 // class Day12$Path\n 443: dup\n 444: aload 14\n 446: aload 6\n 448: invokevirtual #136 // Method Day12$Path.getDistanceSoFar:()I\n 451: iconst_1\n 452: iadd\n 453: invokespecial #101 // Method Day12$Path.\"<init>\":(LDay12$Point;I)V\n 456: aload 16\n 458: swap\n 459: invokeinterface #172, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 464: pop\n 465: goto 407\n 468: aload 10\n 470: checkcast #174 // class java/util/List\n 473: nop\n 474: checkcast #151 // class java/lang/Iterable\n 477: astore 7\n 479: nop\n 480: iconst_0\n 481: istore 8\n 483: aload 7\n 485: invokeinterface #158, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 490: astore 9\n 492: aload 9\n 494: invokeinterface #163, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 499: ifeq 533\n 502: aload 9\n 504: invokeinterface #166, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 509: astore 10\n 511: aload 10\n 513: checkcast #98 // class Day12$Path\n 516: astore 11\n 518: iconst_0\n 519: istore 12\n 521: aload 4\n 523: aload 11\n 525: invokevirtual #196 // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z\n 528: pop\n 529: nop\n 530: goto 492\n 533: nop\n 534: goto 47\n 537: new #198 // class java/lang/IllegalStateException\n 540: dup\n 541: ldc #200 // String No path found to destination\n 543: invokevirtual #204 // Method java/lang/Object.toString:()Ljava/lang/String;\n 546: invokespecial #207 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 549: athrow\n\n public final Day12$Point component1();\n Code:\n 0: aload_0\n 1: getfield #26 // Field startingPoint:LDay12$Point;\n 4: areturn\n\n public final Day12$Point component2();\n Code:\n 0: aload_0\n 1: getfield #28 // Field destination:LDay12$Point;\n 4: areturn\n\n public final java.util.Map<Day12$Point, java.lang.Integer> component3();\n Code:\n 0: aload_0\n 1: getfield #31 // Field field:Ljava/util/Map;\n 4: areturn\n\n public final Day12$Area copy(Day12$Point, Day12$Point, java.util.Map<Day12$Point, java.lang.Integer>);\n Code:\n 0: aload_1\n 1: ldc #10 // String startingPoint\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #18 // String destination\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_3\n 13: ldc #20 // String field\n 15: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: new #2 // class Day12$Area\n 21: dup\n 22: aload_1\n 23: aload_2\n 24: aload_3\n 25: invokespecial #247 // Method \"<init>\":(LDay12$Point;LDay12$Point;Ljava/util/Map;)V\n 28: areturn\n\n public static Day12$Area copy$default(Day12$Area, Day12$Point, Day12$Point, java.util.Map, 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 #26 // Field startingPoint:LDay12$Point;\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 destination:LDay12$Point;\n 23: astore_2\n 24: iload 4\n 26: iconst_4\n 27: iand\n 28: ifeq 36\n 31: aload_0\n 32: getfield #31 // Field field:Ljava/util/Map;\n 35: astore_3\n 36: aload_0\n 37: aload_1\n 38: aload_2\n 39: aload_3\n 40: invokevirtual #251 // Method copy:(LDay12$Point;LDay12$Point;Ljava/util/Map;)LDay12$Area;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #253 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #254 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc_w #256 // String Area(startingPoint=\n 10: invokevirtual #260 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 13: aload_0\n 14: getfield #26 // Field startingPoint:LDay12$Point;\n 17: invokevirtual #263 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 20: ldc_w #265 // String , destination=\n 23: invokevirtual #260 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 26: aload_0\n 27: getfield #28 // Field destination:LDay12$Point;\n 30: invokevirtual #263 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 33: ldc_w #267 // String , field=\n 36: invokevirtual #260 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 39: aload_0\n 40: getfield #31 // Field field:Ljava/util/Map;\n 43: invokevirtual #263 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 46: bipush 41\n 48: invokevirtual #270 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 51: invokevirtual #271 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 54: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #26 // Field startingPoint:LDay12$Point;\n 4: invokevirtual #274 // Method Day12$Point.hashCode:()I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #28 // Field destination:LDay12$Point;\n 16: invokevirtual #274 // Method Day12$Point.hashCode:()I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: bipush 31\n 24: imul\n 25: aload_0\n 26: getfield #31 // Field field:Ljava/util/Map;\n 29: invokevirtual #275 // 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$Area\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day12$Area\n 20: astore_2\n 21: aload_0\n 22: getfield #26 // Field startingPoint:LDay12$Point;\n 25: aload_2\n 26: getfield #26 // Field startingPoint:LDay12$Point;\n 29: invokestatic #282 // 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 destination:LDay12$Point;\n 41: aload_2\n 42: getfield #28 // Field destination:LDay12$Point;\n 45: invokestatic #282 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 48: ifne 53\n 51: iconst_0\n 52: ireturn\n 53: aload_0\n 54: getfield #31 // Field field:Ljava/util/Map;\n 57: aload_2\n 58: getfield #31 // Field field:Ljava/util/Map;\n 61: invokestatic #282 // 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 private static final boolean traverseFromStart$lambda$0(int, int);\n Code:\n 0: iload_0\n 1: iload_1\n 2: isub\n 3: iconst_1\n 4: if_icmpgt 11\n 7: iconst_1\n 8: goto 12\n 11: iconst_0\n 12: ireturn\n\n private static final boolean traverseFromStart$lambda$1(Day12$Area, Day12$Path);\n Code:\n 0: aload_1\n 1: ldc_w #285 // String it\n 4: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: invokevirtual #139 // Method Day12$Path.getPoint:()LDay12$Point;\n 11: aload_0\n 12: getfield #28 // Field destination:LDay12$Point;\n 15: invokestatic #282 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 18: ireturn\n\n private static final boolean traverseFromEnd$lambda$2(int, int);\n Code:\n 0: iload_1\n 1: iload_0\n 2: isub\n 3: iconst_1\n 4: if_icmpgt 11\n 7: iconst_1\n 8: goto 12\n 11: iconst_0\n 12: ireturn\n\n private static final boolean traverseFromEnd$lambda$3(Day12$Area, Day12$Path);\n Code:\n 0: aload_1\n 1: ldc_w #285 // 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: getfield #31 // Field field:Ljava/util/Map;\n 11: aload_1\n 12: invokevirtual #139 // Method Day12$Path.getPoint:()LDay12$Point;\n 15: invokeinterface #289, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 20: checkcast #291 // class java/lang/Integer\n 23: dup\n 24: ifnonnull 31\n 27: pop\n 28: goto 41\n 31: invokevirtual #294 // Method java/lang/Integer.intValue:()I\n 34: ifne 41\n 37: iconst_1\n 38: goto 42\n 41: iconst_0\n 42: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day12$Path.class",
"javap": "Compiled from \"Day12.kt\"\npublic final class Day12$Path implements java.lang.Comparable<Day12$Path> {\n private final Day12$Point point;\n\n private final int distanceSoFar;\n\n public Day12$Path(Day12$Point, int);\n Code:\n 0: aload_1\n 1: ldc #12 // String point\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokespecial #21 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: aload_1\n 12: putfield #24 // Field point:LDay12$Point;\n 15: aload_0\n 16: iload_2\n 17: putfield #28 // Field distanceSoFar:I\n 20: return\n\n public final Day12$Point getPoint();\n Code:\n 0: aload_0\n 1: getfield #24 // Field point:LDay12$Point;\n 4: areturn\n\n public final int getDistanceSoFar();\n Code:\n 0: aload_0\n 1: getfield #28 // Field distanceSoFar:I\n 4: ireturn\n\n public int compareTo(Day12$Path);\n Code:\n 0: aload_1\n 1: ldc #38 // String other\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getfield #28 // Field distanceSoFar:I\n 10: aload_1\n 11: getfield #28 // Field distanceSoFar:I\n 14: isub\n 15: ireturn\n\n public final Day12$Point component1();\n Code:\n 0: aload_0\n 1: getfield #24 // Field point:LDay12$Point;\n 4: areturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #28 // Field distanceSoFar:I\n 4: ireturn\n\n public final Day12$Path copy(Day12$Point, int);\n Code:\n 0: aload_1\n 1: ldc #12 // String point\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class Day12$Path\n 9: dup\n 10: aload_1\n 11: iload_2\n 12: invokespecial #44 // Method \"<init>\":(LDay12$Point;I)V\n 15: areturn\n\n public static Day12$Path copy$default(Day12$Path, Day12$Point, 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 #24 // Field point:LDay12$Point;\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 #28 // Field distanceSoFar:I\n 21: istore_2\n 22: aload_0\n 23: aload_1\n 24: iload_2\n 25: invokevirtual #48 // Method copy:(LDay12$Point;I)LDay12$Path;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #52 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #53 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #55 // String Path(point=\n 9: invokevirtual #59 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #24 // Field point:LDay12$Point;\n 16: invokevirtual #62 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #64 // String , distanceSoFar=\n 21: invokevirtual #59 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #28 // Field distanceSoFar:I\n 28: invokevirtual #67 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #70 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #72 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 39: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #24 // Field point:LDay12$Point;\n 4: invokevirtual #77 // Method Day12$Point.hashCode:()I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #28 // Field distanceSoFar:I\n 16: invokestatic #82 // Method java/lang/Integer.hashCode:(I)I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: 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$Path\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day12$Path\n 20: astore_2\n 21: aload_0\n 22: getfield #24 // Field point:LDay12$Point;\n 25: aload_2\n 26: getfield #24 // Field point:LDay12$Point;\n 29: invokestatic #90 // 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 distanceSoFar:I\n 41: aload_2\n 42: getfield #28 // Field distanceSoFar:I\n 45: if_icmpeq 50\n 48: iconst_0\n 49: ireturn\n 50: iconst_1\n 51: ireturn\n\n public int compareTo(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #2 // class Day12$Path\n 5: invokevirtual #94 // Method compareTo:(LDay12$Path;)I\n 8: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/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 int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokespecial #26 // Method mapToArea:(Ljava/util/List;)LDay12$Area;\n 11: astore_2\n 12: aload_2\n 13: invokevirtual #32 // Method Day12$Area.traverseFromStart:()I\n 16: ireturn\n\n public final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokespecial #26 // Method mapToArea:(Ljava/util/List;)LDay12$Area;\n 11: invokevirtual #39 // Method Day12$Area.traverseFromEnd:()I\n 14: ireturn\n\n private final Day12$Area mapToArea(java.util.List<java.lang.String>);\n Code:\n 0: aconst_null\n 1: astore_2\n 2: aconst_null\n 3: astore_3\n 4: aload_1\n 5: checkcast #42 // class java/lang/Iterable\n 8: astore 5\n 10: new #44 // class java/util/ArrayList\n 13: dup\n 14: invokespecial #45 // Method java/util/ArrayList.\"<init>\":()V\n 17: checkcast #47 // class java/util/Collection\n 20: astore 6\n 22: iconst_0\n 23: istore 7\n 25: aload 5\n 27: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 32: astore 8\n 34: aload 8\n 36: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 41: ifeq 336\n 44: aload 8\n 46: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 51: astore 9\n 53: iload 7\n 55: iinc 7, 1\n 58: istore 10\n 60: iload 10\n 62: ifge 68\n 65: invokestatic #66 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 68: iload 10\n 70: aload 9\n 72: checkcast #68 // class java/lang/String\n 75: astore 11\n 77: istore 12\n 79: iconst_0\n 80: istore 13\n 82: aload 11\n 84: checkcast #70 // class java/lang/CharSequence\n 87: astore 14\n 89: iconst_0\n 90: istore 15\n 92: aload 14\n 94: astore 16\n 96: new #44 // class java/util/ArrayList\n 99: dup\n 100: aload 14\n 102: invokeinterface #73, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 107: invokespecial #76 // Method java/util/ArrayList.\"<init>\":(I)V\n 110: checkcast #47 // class java/util/Collection\n 113: astore 17\n 115: iconst_0\n 116: istore 18\n 118: iconst_0\n 119: istore 19\n 121: iconst_0\n 122: istore 20\n 124: iload 20\n 126: aload 16\n 128: invokeinterface #73, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 133: if_icmpge 316\n 136: aload 16\n 138: iload 20\n 140: invokeinterface #80, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 145: istore 21\n 147: aload 17\n 149: iload 19\n 151: iinc 19, 1\n 154: iload 21\n 156: istore 22\n 158: istore 23\n 160: astore 24\n 162: iconst_0\n 163: istore 25\n 165: new #82 // class Day12$Point\n 168: dup\n 169: iload 23\n 171: iload 12\n 173: invokespecial #85 // Method Day12$Point.\"<init>\":(II)V\n 176: astore 26\n 178: aload_0\n 179: iload 22\n 181: invokespecial #89 // Method decodeHeight:(C)I\n 184: istore 27\n 186: iload 22\n 188: lookupswitch { // 2\n 69: 216\n 83: 253\n default: 290\n }\n 216: aload 26\n 218: iload 27\n 220: invokestatic #95 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 223: astore 28\n 225: aload 28\n 227: checkcast #97 // class java/lang/Number\n 230: invokevirtual #100 // Method java/lang/Number.intValue:()I\n 233: istore 29\n 235: astore 30\n 237: iconst_0\n 238: istore 31\n 240: aload 26\n 242: astore_2\n 243: aload 30\n 245: aload 28\n 247: invokestatic #106 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 250: goto 300\n 253: aload 26\n 255: iload 27\n 257: invokestatic #95 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 260: astore 28\n 262: aload 28\n 264: checkcast #97 // class java/lang/Number\n 267: invokevirtual #100 // Method java/lang/Number.intValue:()I\n 270: istore 29\n 272: astore 30\n 274: iconst_0\n 275: istore 31\n 277: aload 26\n 279: astore_3\n 280: aload 30\n 282: aload 28\n 284: invokestatic #106 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 287: goto 300\n 290: aload 26\n 292: iload 27\n 294: invokestatic #95 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 297: invokestatic #106 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 300: nop\n 301: aload 24\n 303: swap\n 304: invokeinterface #110, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 309: pop\n 310: iinc 20, 1\n 313: goto 124\n 316: aload 17\n 318: checkcast #112 // class java/util/List\n 321: nop\n 322: checkcast #42 // class java/lang/Iterable\n 325: nop\n 326: aload 6\n 328: swap\n 329: invokestatic #116 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 332: pop\n 333: goto 34\n 336: aload 6\n 338: checkcast #112 // class java/util/List\n 341: checkcast #42 // class java/lang/Iterable\n 344: invokestatic #122 // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;\n 347: astore 4\n 349: new #28 // class Day12$Area\n 352: dup\n 353: aload_3\n 354: dup\n 355: invokestatic #126 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 358: aload_2\n 359: dup\n 360: invokestatic #126 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 363: aload 4\n 365: invokespecial #129 // Method Day12$Area.\"<init>\":(LDay12$Point;LDay12$Point;Ljava/util/Map;)V\n 368: areturn\n\n private final int decodeHeight(char);\n Code:\n 0: iload_1\n 1: istore_2\n 2: iload_2\n 3: bipush 83\n 5: if_icmpne 12\n 8: iconst_0\n 9: goto 84\n 12: iload_2\n 13: bipush 69\n 15: if_icmpne 23\n 18: bipush 25\n 20: goto 84\n 23: bipush 97\n 25: iload_2\n 26: if_icmpgt 43\n 29: iload_2\n 30: bipush 123\n 32: if_icmpge 39\n 35: iconst_1\n 36: goto 44\n 39: iconst_0\n 40: goto 44\n 43: iconst_0\n 44: ifeq 54\n 47: iload_1\n 48: bipush 97\n 50: isub\n 51: goto 84\n 54: new #162 // class java/lang/IllegalStateException\n 57: dup\n 58: new #164 // class java/lang/StringBuilder\n 61: dup\n 62: invokespecial #165 // Method java/lang/StringBuilder.\"<init>\":()V\n 65: ldc #167 // String Wrong level value\n 67: invokevirtual #171 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 70: iload_1\n 71: invokevirtual #174 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 74: invokevirtual #178 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 77: invokevirtual #179 // Method java/lang/Object.toString:()Ljava/lang/String;\n 80: invokespecial #182 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 83: athrow\n 84: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day12$Point.class",
"javap": "Compiled from \"Day12.kt\"\npublic final class Day12$Point {\n private final int x;\n\n private final int y;\n\n public Day12$Point(int, int);\n Code:\n 0: aload_0\n 1: invokespecial #9 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #13 // Field x:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field y:I\n 14: return\n\n public final int getX();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: ireturn\n\n public final int getY();\n Code:\n 0: aload_0\n 1: getfield #16 // Field y:I\n 4: ireturn\n\n public final java.util.List<Day12$Point> neighbors();\n Code:\n 0: iconst_4\n 1: anewarray #2 // class Day12$Point\n 4: astore_1\n 5: aload_1\n 6: iconst_0\n 7: new #2 // class Day12$Point\n 10: dup\n 11: aload_0\n 12: getfield #13 // Field x:I\n 15: aload_0\n 16: getfield #16 // Field y:I\n 19: iconst_1\n 20: iadd\n 21: invokespecial #27 // Method \"<init>\":(II)V\n 24: aastore\n 25: aload_1\n 26: iconst_1\n 27: new #2 // class Day12$Point\n 30: dup\n 31: aload_0\n 32: getfield #13 // Field x:I\n 35: aload_0\n 36: getfield #16 // Field y:I\n 39: iconst_1\n 40: isub\n 41: invokespecial #27 // Method \"<init>\":(II)V\n 44: aastore\n 45: aload_1\n 46: iconst_2\n 47: new #2 // class Day12$Point\n 50: dup\n 51: aload_0\n 52: getfield #13 // Field x:I\n 55: iconst_1\n 56: iadd\n 57: aload_0\n 58: getfield #16 // Field y:I\n 61: invokespecial #27 // Method \"<init>\":(II)V\n 64: aastore\n 65: aload_1\n 66: iconst_3\n 67: new #2 // class Day12$Point\n 70: dup\n 71: aload_0\n 72: getfield #13 // Field x:I\n 75: iconst_1\n 76: isub\n 77: aload_0\n 78: getfield #16 // Field y:I\n 81: invokespecial #27 // Method \"<init>\":(II)V\n 84: aastore\n 85: aload_1\n 86: invokestatic #33 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 89: 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 Day12$Point copy(int, int);\n Code:\n 0: new #2 // class Day12$Point\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: invokespecial #27 // Method \"<init>\":(II)V\n 9: areturn\n\n public static Day12$Point copy$default(Day12$Point, int, int, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_1\n 2: iand\n 3: ifeq 11\n 6: aload_0\n 7: getfield #13 // Field x:I\n 10: istore_1\n 11: iload_3\n 12: iconst_2\n 13: iand\n 14: ifeq 22\n 17: aload_0\n 18: getfield #16 // Field y:I\n 21: istore_2\n 22: aload_0\n 23: iload_1\n 24: iload_2\n 25: invokevirtual #41 // Method copy:(II)LDay12$Point;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #45 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #46 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #48 // String Point(x=\n 9: invokevirtual #52 // 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 #55 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #57 // String , y=\n 21: invokevirtual #52 // 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 #55 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #60 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #62 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 39: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: invokestatic #68 // Method java/lang/Integer.hashCode:(I)I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #16 // Field y:I\n 16: invokestatic #68 // Method java/lang/Integer.hashCode:(I)I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: 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$Point\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day12$Point\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field x:I\n 25: aload_2\n 26: getfield #13 // Field x:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field y:I\n 38: aload_2\n 39: getfield #16 // Field y:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: iconst_1\n 48: ireturn\n}\n",
"javap_err": ""
}
] |
dliszewski__advent-of-code-2022__76d5eea/src/main/kotlin/Day13.kt
|
class Day13 {
fun part1(input: String): Int {
return input.split("\n\n").map { it.lines() }
.map { (packet, other) -> packet.mapToPacketData() to other.mapToPacketData() }
.mapIndexed { index, pair -> if (pair.first.compareTo(pair.second) < 1) index + 1 else 0 }
.sum()
}
fun part2(input: String): Int {
val packets = input.split("\n\n").map { it.lines() }
.flatMap { (packet, other) -> listOf(packet.mapToPacketData(), other.mapToPacketData()) }
val dividerPacket2 = "[[6]]".mapToPacketData()
val dividerPacket1 = "[[2]]".mapToPacketData()
val ordered = (packets + dividerPacket1 + dividerPacket2).sorted()
return (ordered.indexOf(dividerPacket1) + 1) * (ordered.indexOf(dividerPacket2) + 1)
}
private fun String.mapToPacketData(): PacketData {
val bracketsAndNumbers = split(Regex("((?<=[\\[\\],])|(?=[\\[\\],]))"))
.filter { it.isNotBlank() }
.filter { it != "," }
.iterator()
return mapIteratorToPacketData(bracketsAndNumbers)
}
private fun mapIteratorToPacketData(input: Iterator<String>): PacketData {
val packets = mutableListOf<PacketData>()
while (input.hasNext()) {
when (val symbol = input.next()) {
"]" -> return ListPacketData(packets)
"[" -> packets.add(mapIteratorToPacketData(input))
else -> packets.add(IntPacketData(symbol.toInt()))
}
}
return ListPacketData(packets)
}
sealed class PacketData : Comparable<PacketData>
data class IntPacketData(val data: Int) : PacketData() {
override fun compareTo(other: PacketData): Int {
return when (other) {
is IntPacketData -> data.compareTo(other.data)
is ListPacketData -> ListPacketData(listOf(this)).compareTo(other)
}
}
}
data class ListPacketData(val data: List<PacketData>) : PacketData() {
override fun compareTo(other: PacketData): Int {
return when (other) {
is IntPacketData -> compareTo(ListPacketData(listOf(other)))
is ListPacketData -> data.zip(other.data)
.map { (packet1, packet2) -> packet1.compareTo(packet2) }
.firstOrNull { it != 0 } ?: data.size.compareTo(other.data.size)
}
}
}
}
|
[
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day13.class",
"javap": "Compiled from \"Day13.kt\"\npublic final class Day13 {\n public Day13();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int part1(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String input\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #23 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #25 // class java/lang/String\n 14: astore_2\n 15: aload_2\n 16: iconst_0\n 17: ldc #27 // String \\n\\n\n 19: aastore\n 20: aload_2\n 21: iconst_0\n 22: iconst_0\n 23: bipush 6\n 25: aconst_null\n 26: invokestatic #33 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: checkcast #35 // class java/lang/Iterable\n 32: astore_2\n 33: iconst_0\n 34: istore_3\n 35: aload_2\n 36: astore 4\n 38: new #37 // class java/util/ArrayList\n 41: dup\n 42: aload_2\n 43: bipush 10\n 45: invokestatic #43 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 48: invokespecial #46 // Method java/util/ArrayList.\"<init>\":(I)V\n 51: checkcast #48 // class java/util/Collection\n 54: astore 5\n 56: iconst_0\n 57: istore 6\n 59: aload 4\n 61: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 66: astore 7\n 68: aload 7\n 70: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 75: ifeq 121\n 78: aload 7\n 80: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 85: astore 8\n 87: aload 5\n 89: aload 8\n 91: checkcast #25 // class java/lang/String\n 94: astore 9\n 96: astore 14\n 98: iconst_0\n 99: istore 10\n 101: aload 9\n 103: checkcast #23 // class java/lang/CharSequence\n 106: invokestatic #66 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 109: aload 14\n 111: swap\n 112: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 117: pop\n 118: goto 68\n 121: aload 5\n 123: checkcast #72 // class java/util/List\n 126: nop\n 127: checkcast #35 // class java/lang/Iterable\n 130: astore_2\n 131: nop\n 132: iconst_0\n 133: istore_3\n 134: aload_2\n 135: astore 4\n 137: new #37 // class java/util/ArrayList\n 140: dup\n 141: aload_2\n 142: bipush 10\n 144: invokestatic #43 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 147: invokespecial #46 // Method java/util/ArrayList.\"<init>\":(I)V\n 150: checkcast #48 // class java/util/Collection\n 153: astore 5\n 155: iconst_0\n 156: istore 6\n 158: aload 4\n 160: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 165: astore 7\n 167: aload 7\n 169: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 174: ifeq 253\n 177: aload 7\n 179: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 184: astore 8\n 186: aload 5\n 188: aload 8\n 190: checkcast #72 // class java/util/List\n 193: astore 9\n 195: astore 14\n 197: iconst_0\n 198: istore 10\n 200: aload 9\n 202: iconst_0\n 203: invokeinterface #76, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 208: checkcast #25 // class java/lang/String\n 211: astore 11\n 213: aload 9\n 215: iconst_1\n 216: invokeinterface #76, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 221: checkcast #25 // class java/lang/String\n 224: astore 12\n 226: aload_0\n 227: aload 11\n 229: invokespecial #80 // Method mapToPacketData:(Ljava/lang/String;)LDay13$PacketData;\n 232: aload_0\n 233: aload 12\n 235: invokespecial #80 // Method mapToPacketData:(Ljava/lang/String;)LDay13$PacketData;\n 238: invokestatic #86 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 241: aload 14\n 243: swap\n 244: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 249: pop\n 250: goto 167\n 253: aload 5\n 255: checkcast #72 // class java/util/List\n 258: nop\n 259: checkcast #35 // class java/lang/Iterable\n 262: astore_2\n 263: nop\n 264: iconst_0\n 265: istore_3\n 266: aload_2\n 267: astore 4\n 269: new #37 // class java/util/ArrayList\n 272: dup\n 273: aload_2\n 274: bipush 10\n 276: invokestatic #43 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 279: invokespecial #46 // Method java/util/ArrayList.\"<init>\":(I)V\n 282: checkcast #48 // class java/util/Collection\n 285: astore 5\n 287: iconst_0\n 288: istore 6\n 290: iconst_0\n 291: istore 7\n 293: aload 4\n 295: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 300: astore 8\n 302: aload 8\n 304: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 309: ifeq 397\n 312: aload 8\n 314: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 319: astore 9\n 321: aload 5\n 323: iload 7\n 325: iinc 7, 1\n 328: istore 10\n 330: iload 10\n 332: ifge 338\n 335: invokestatic #89 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 338: iload 10\n 340: aload 9\n 342: checkcast #91 // class kotlin/Pair\n 345: astore 11\n 347: istore 12\n 349: astore 14\n 351: iconst_0\n 352: istore 13\n 354: aload 11\n 356: invokevirtual #94 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 359: checkcast #96 // class Day13$PacketData\n 362: aload 11\n 364: invokevirtual #99 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 367: invokevirtual #103 // Method Day13$PacketData.compareTo:(Ljava/lang/Object;)I\n 370: iconst_1\n 371: if_icmpge 381\n 374: iload 12\n 376: iconst_1\n 377: iadd\n 378: goto 382\n 381: iconst_0\n 382: invokestatic #109 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 385: aload 14\n 387: swap\n 388: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 393: pop\n 394: goto 302\n 397: aload 5\n 399: checkcast #72 // class java/util/List\n 402: nop\n 403: checkcast #35 // class java/lang/Iterable\n 406: invokestatic #113 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 409: ireturn\n\n public final int part2(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String input\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #23 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #25 // class java/lang/String\n 14: astore_3\n 15: aload_3\n 16: iconst_0\n 17: ldc #27 // String \\n\\n\n 19: aastore\n 20: aload_3\n 21: iconst_0\n 22: iconst_0\n 23: bipush 6\n 25: aconst_null\n 26: invokestatic #33 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: checkcast #35 // class java/lang/Iterable\n 32: astore_3\n 33: iconst_0\n 34: istore 4\n 36: aload_3\n 37: astore 5\n 39: new #37 // class java/util/ArrayList\n 42: dup\n 43: aload_3\n 44: bipush 10\n 46: invokestatic #43 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 49: invokespecial #46 // Method java/util/ArrayList.\"<init>\":(I)V\n 52: checkcast #48 // class java/util/Collection\n 55: astore 6\n 57: iconst_0\n 58: istore 7\n 60: aload 5\n 62: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 67: astore 8\n 69: aload 8\n 71: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 76: ifeq 122\n 79: aload 8\n 81: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 86: astore 9\n 88: aload 6\n 90: aload 9\n 92: checkcast #25 // class java/lang/String\n 95: astore 10\n 97: astore 15\n 99: iconst_0\n 100: istore 11\n 102: aload 10\n 104: checkcast #23 // class java/lang/CharSequence\n 107: invokestatic #66 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 110: aload 15\n 112: swap\n 113: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 118: pop\n 119: goto 69\n 122: aload 6\n 124: checkcast #72 // class java/util/List\n 127: nop\n 128: checkcast #35 // class java/lang/Iterable\n 131: astore_3\n 132: nop\n 133: iconst_0\n 134: istore 4\n 136: aload_3\n 137: astore 5\n 139: new #37 // class java/util/ArrayList\n 142: dup\n 143: invokespecial #140 // Method java/util/ArrayList.\"<init>\":()V\n 146: checkcast #48 // class java/util/Collection\n 149: astore 6\n 151: iconst_0\n 152: istore 7\n 154: aload 5\n 156: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 161: astore 8\n 163: aload 8\n 165: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 170: ifeq 265\n 173: aload 8\n 175: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 180: astore 9\n 182: aload 9\n 184: checkcast #72 // class java/util/List\n 187: astore 10\n 189: iconst_0\n 190: istore 11\n 192: aload 10\n 194: iconst_0\n 195: invokeinterface #76, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 200: checkcast #25 // class java/lang/String\n 203: astore 12\n 205: aload 10\n 207: iconst_1\n 208: invokeinterface #76, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 213: checkcast #25 // class java/lang/String\n 216: astore 13\n 218: iconst_2\n 219: anewarray #96 // class Day13$PacketData\n 222: astore 14\n 224: aload 14\n 226: iconst_0\n 227: aload_0\n 228: aload 12\n 230: invokespecial #80 // Method mapToPacketData:(Ljava/lang/String;)LDay13$PacketData;\n 233: aastore\n 234: aload 14\n 236: iconst_1\n 237: aload_0\n 238: aload 13\n 240: invokespecial #80 // Method mapToPacketData:(Ljava/lang/String;)LDay13$PacketData;\n 243: aastore\n 244: aload 14\n 246: invokestatic #144 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 249: checkcast #35 // class java/lang/Iterable\n 252: astore 10\n 254: aload 6\n 256: aload 10\n 258: invokestatic #148 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 261: pop\n 262: goto 163\n 265: aload 6\n 267: checkcast #72 // class java/util/List\n 270: nop\n 271: astore_2\n 272: aload_0\n 273: ldc #150 // String [[6]]\n 275: invokespecial #80 // Method mapToPacketData:(Ljava/lang/String;)LDay13$PacketData;\n 278: astore_3\n 279: aload_0\n 280: ldc #152 // String [[2]]\n 282: invokespecial #80 // Method mapToPacketData:(Ljava/lang/String;)LDay13$PacketData;\n 285: astore 4\n 287: aload_2\n 288: checkcast #48 // class java/util/Collection\n 291: aload 4\n 293: invokestatic #156 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 296: checkcast #48 // class java/util/Collection\n 299: aload_3\n 300: invokestatic #156 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 303: checkcast #35 // class java/lang/Iterable\n 306: invokestatic #160 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;\n 309: astore 5\n 311: aload 5\n 313: aload 4\n 315: invokeinterface #163, 2 // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I\n 320: iconst_1\n 321: iadd\n 322: aload 5\n 324: aload_3\n 325: invokeinterface #163, 2 // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I\n 330: iconst_1\n 331: iadd\n 332: imul\n 333: ireturn\n\n private final Day13$PacketData mapToPacketData(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #23 // class java/lang/CharSequence\n 4: astore_3\n 5: new #179 // class kotlin/text/Regex\n 8: dup\n 9: ldc #181 // String ((?<=[\\\\[\\\\],])|(?=[\\\\[\\\\],]))\n 11: invokespecial #184 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 14: astore 4\n 16: iconst_0\n 17: istore 5\n 19: aload 4\n 21: aload_3\n 22: iload 5\n 24: invokevirtual #188 // Method kotlin/text/Regex.split:(Ljava/lang/CharSequence;I)Ljava/util/List;\n 27: checkcast #35 // class java/lang/Iterable\n 30: astore_3\n 31: nop\n 32: iconst_0\n 33: istore 4\n 35: aload_3\n 36: astore 5\n 38: new #37 // class java/util/ArrayList\n 41: dup\n 42: invokespecial #140 // Method java/util/ArrayList.\"<init>\":()V\n 45: checkcast #48 // class java/util/Collection\n 48: astore 6\n 50: iconst_0\n 51: istore 7\n 53: aload 5\n 55: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 60: astore 8\n 62: aload 8\n 64: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 69: ifeq 124\n 72: aload 8\n 74: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 79: astore 9\n 81: aload 9\n 83: checkcast #25 // class java/lang/String\n 86: astore 10\n 88: iconst_0\n 89: istore 11\n 91: aload 10\n 93: checkcast #23 // class java/lang/CharSequence\n 96: invokestatic #192 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 99: ifne 106\n 102: iconst_1\n 103: goto 107\n 106: iconst_0\n 107: nop\n 108: ifeq 62\n 111: aload 6\n 113: aload 9\n 115: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 120: pop\n 121: goto 62\n 124: aload 6\n 126: checkcast #72 // class java/util/List\n 129: nop\n 130: checkcast #35 // class java/lang/Iterable\n 133: astore_3\n 134: nop\n 135: iconst_0\n 136: istore 4\n 138: aload_3\n 139: astore 5\n 141: new #37 // class java/util/ArrayList\n 144: dup\n 145: invokespecial #140 // Method java/util/ArrayList.\"<init>\":()V\n 148: checkcast #48 // class java/util/Collection\n 151: astore 6\n 153: iconst_0\n 154: istore 7\n 156: aload 5\n 158: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 163: astore 8\n 165: aload 8\n 167: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 172: ifeq 225\n 175: aload 8\n 177: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 182: astore 9\n 184: aload 9\n 186: checkcast #25 // class java/lang/String\n 189: astore 10\n 191: iconst_0\n 192: istore 11\n 194: aload 10\n 196: ldc #194 // String ,\n 198: invokestatic #198 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 201: ifne 208\n 204: iconst_1\n 205: goto 209\n 208: iconst_0\n 209: ifeq 165\n 212: aload 6\n 214: aload 9\n 216: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 221: pop\n 222: goto 165\n 225: aload 6\n 227: checkcast #72 // class java/util/List\n 230: nop\n 231: invokeinterface #199, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 236: astore_2\n 237: aload_0\n 238: aload_2\n 239: invokespecial #203 // Method mapIteratorToPacketData:(Ljava/util/Iterator;)LDay13$PacketData;\n 242: areturn\n\n private final Day13$PacketData mapIteratorToPacketData(java.util.Iterator<java.lang.String>);\n Code:\n 0: new #37 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #140 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #72 // class java/util/List\n 10: astore_2\n 11: aload_1\n 12: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 17: ifeq 95\n 20: aload_1\n 21: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 26: checkcast #25 // class java/lang/String\n 29: astore_3\n 30: aload_3\n 31: ldc #215 // String ]\n 33: invokestatic #198 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 36: ifeq 51\n 39: new #217 // class Day13$ListPacketData\n 42: dup\n 43: aload_2\n 44: invokespecial #220 // Method Day13$ListPacketData.\"<init>\":(Ljava/util/List;)V\n 47: checkcast #96 // class Day13$PacketData\n 50: areturn\n 51: aload_3\n 52: ldc #222 // String [\n 54: invokestatic #198 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 57: ifeq 74\n 60: aload_2\n 61: aload_0\n 62: aload_1\n 63: invokespecial #203 // Method mapIteratorToPacketData:(Ljava/util/Iterator;)LDay13$PacketData;\n 66: invokeinterface #223, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 71: goto 91\n 74: aload_2\n 75: new #225 // class Day13$IntPacketData\n 78: dup\n 79: aload_3\n 80: invokestatic #228 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 83: invokespecial #229 // Method Day13$IntPacketData.\"<init>\":(I)V\n 86: invokeinterface #223, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 91: pop\n 92: goto 11\n 95: new #217 // class Day13$ListPacketData\n 98: dup\n 99: aload_2\n 100: invokespecial #220 // Method Day13$ListPacketData.\"<init>\":(Ljava/util/List;)V\n 103: checkcast #96 // class Day13$PacketData\n 106: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day13$IntPacketData.class",
"javap": "Compiled from \"Day13.kt\"\npublic final class Day13$IntPacketData extends Day13$PacketData {\n private final int data;\n\n public Day13$IntPacketData(int);\n Code:\n 0: aload_0\n 1: aconst_null\n 2: invokespecial #9 // Method Day13$PacketData.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 5: aload_0\n 6: iload_1\n 7: putfield #13 // Field data:I\n 10: return\n\n public final int getData();\n Code:\n 0: aload_0\n 1: getfield #13 // Field data:I\n 4: ireturn\n\n public int compareTo(Day13$PacketData);\n Code:\n 0: aload_1\n 1: ldc #22 // String other\n 3: invokestatic #28 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: astore_2\n 8: aload_2\n 9: instanceof #2 // class Day13$IntPacketData\n 12: ifeq 32\n 15: aload_0\n 16: getfield #13 // Field data:I\n 19: aload_1\n 20: checkcast #2 // class Day13$IntPacketData\n 23: getfield #13 // Field data:I\n 26: invokestatic #32 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 29: goto 65\n 32: aload_2\n 33: instanceof #34 // class Day13$ListPacketData\n 36: ifeq 57\n 39: new #34 // class Day13$ListPacketData\n 42: dup\n 43: aload_0\n 44: invokestatic #40 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 47: invokespecial #43 // Method Day13$ListPacketData.\"<init>\":(Ljava/util/List;)V\n 50: aload_1\n 51: invokevirtual #45 // Method Day13$ListPacketData.compareTo:(LDay13$PacketData;)I\n 54: goto 65\n 57: new #47 // class kotlin/NoWhenBranchMatchedException\n 60: dup\n 61: invokespecial #50 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 64: athrow\n 65: ireturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field data:I\n 4: ireturn\n\n public final Day13$IntPacketData copy(int);\n Code:\n 0: new #2 // class Day13$IntPacketData\n 3: dup\n 4: iload_1\n 5: invokespecial #56 // Method \"<init>\":(I)V\n 8: areturn\n\n public static Day13$IntPacketData copy$default(Day13$IntPacketData, int, int, java.lang.Object);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: iand\n 3: ifeq 11\n 6: aload_0\n 7: getfield #13 // Field data:I\n 10: istore_1\n 11: aload_0\n 12: iload_1\n 13: invokevirtual #60 // Method copy:(I)LDay13$IntPacketData;\n 16: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #64 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #65 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #67 // String IntPacketData(data=\n 9: invokevirtual #71 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field data:I\n 16: invokevirtual #74 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: bipush 41\n 21: invokevirtual #77 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 24: invokevirtual #79 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 27: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #13 // Field data:I\n 4: invokestatic #85 // Method java/lang/Integer.hashCode:(I)I\n 7: ireturn\n\n public boolean equals(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: if_acmpne 7\n 5: iconst_1\n 6: ireturn\n 7: aload_1\n 8: instanceof #2 // class Day13$IntPacketData\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day13$IntPacketData\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field data:I\n 25: aload_2\n 26: getfield #13 // Field data:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: iconst_1\n 35: ireturn\n\n public int compareTo(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #4 // class Day13$PacketData\n 5: invokevirtual #91 // Method compareTo:(LDay13$PacketData;)I\n 8: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day13$PacketData.class",
"javap": "Compiled from \"Day13.kt\"\npublic abstract class Day13$PacketData implements java.lang.Comparable<Day13$PacketData> {\n private Day13$PacketData();\n Code:\n 0: aload_0\n 1: invokespecial #11 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public Day13$PacketData(kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: invokespecial #15 // Method \"<init>\":()V\n 4: return\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day13$ListPacketData.class",
"javap": "Compiled from \"Day13.kt\"\npublic final class Day13$ListPacketData extends Day13$PacketData {\n private final java.util.List<Day13$PacketData> data;\n\n public Day13$ListPacketData(java.util.List<? extends Day13$PacketData>);\n Code:\n 0: aload_1\n 1: ldc #10 // String data\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aconst_null\n 8: invokespecial #19 // Method Day13$PacketData.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 11: aload_0\n 12: aload_1\n 13: putfield #22 // Field data:Ljava/util/List;\n 16: return\n\n public final java.util.List<Day13$PacketData> getData();\n Code:\n 0: aload_0\n 1: getfield #22 // Field data:Ljava/util/List;\n 4: areturn\n\n public int compareTo(Day13$PacketData);\n Code:\n 0: aload_1\n 1: ldc #31 // String other\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: astore_2\n 8: aload_2\n 9: instanceof #33 // class Day13$IntPacketData\n 12: ifeq 36\n 15: aload_0\n 16: new #2 // class Day13$ListPacketData\n 19: dup\n 20: aload_1\n 21: invokestatic #39 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 24: invokespecial #41 // Method \"<init>\":(Ljava/util/List;)V\n 27: checkcast #4 // class Day13$PacketData\n 30: invokevirtual #43 // Method compareTo:(LDay13$PacketData;)I\n 33: goto 301\n 36: aload_2\n 37: instanceof #2 // class Day13$ListPacketData\n 40: ifeq 293\n 43: aload_0\n 44: getfield #22 // Field data:Ljava/util/List;\n 47: checkcast #45 // class java/lang/Iterable\n 50: aload_1\n 51: checkcast #2 // class Day13$ListPacketData\n 54: getfield #22 // Field data:Ljava/util/List;\n 57: checkcast #45 // class java/lang/Iterable\n 60: invokestatic #49 // Method kotlin/collections/CollectionsKt.zip:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;\n 63: checkcast #45 // class java/lang/Iterable\n 66: astore_3\n 67: nop\n 68: iconst_0\n 69: istore 4\n 71: aload_3\n 72: astore 5\n 74: new #51 // class java/util/ArrayList\n 77: dup\n 78: aload_3\n 79: bipush 10\n 81: invokestatic #55 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 84: invokespecial #58 // Method java/util/ArrayList.\"<init>\":(I)V\n 87: checkcast #60 // class java/util/Collection\n 90: astore 6\n 92: iconst_0\n 93: istore 7\n 95: aload 5\n 97: invokeinterface #64, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 102: astore 8\n 104: aload 8\n 106: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 111: ifeq 179\n 114: aload 8\n 116: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 121: astore 9\n 123: aload 6\n 125: aload 9\n 127: checkcast #76 // class kotlin/Pair\n 130: astore 10\n 132: astore 14\n 134: iconst_0\n 135: istore 11\n 137: aload 10\n 139: invokevirtual #79 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 142: checkcast #4 // class Day13$PacketData\n 145: astore 12\n 147: aload 10\n 149: invokevirtual #82 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 152: checkcast #4 // class Day13$PacketData\n 155: astore 13\n 157: aload 12\n 159: aload 13\n 161: invokevirtual #85 // Method Day13$PacketData.compareTo:(Ljava/lang/Object;)I\n 164: invokestatic #91 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 167: aload 14\n 169: swap\n 170: invokeinterface #95, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 175: pop\n 176: goto 104\n 179: aload 6\n 181: checkcast #97 // class java/util/List\n 184: nop\n 185: checkcast #45 // class java/lang/Iterable\n 188: astore_3\n 189: nop\n 190: iconst_0\n 191: istore 4\n 193: aload_3\n 194: invokeinterface #64, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 199: astore 5\n 201: aload 5\n 203: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 208: ifeq 251\n 211: aload 5\n 213: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 218: astore 6\n 220: aload 6\n 222: checkcast #99 // class java/lang/Number\n 225: invokevirtual #103 // Method java/lang/Number.intValue:()I\n 228: istore 7\n 230: iconst_0\n 231: istore 8\n 233: iload 7\n 235: ifeq 242\n 238: iconst_1\n 239: goto 243\n 242: iconst_0\n 243: ifeq 201\n 246: aload 6\n 248: goto 252\n 251: aconst_null\n 252: checkcast #87 // class java/lang/Integer\n 255: dup\n 256: ifnull 265\n 259: invokevirtual #104 // Method java/lang/Integer.intValue:()I\n 262: goto 301\n 265: pop\n 266: aload_0\n 267: getfield #22 // Field data:Ljava/util/List;\n 270: invokeinterface #107, 1 // InterfaceMethod java/util/List.size:()I\n 275: aload_1\n 276: checkcast #2 // class Day13$ListPacketData\n 279: getfield #22 // Field data:Ljava/util/List;\n 282: invokeinterface #107, 1 // InterfaceMethod java/util/List.size:()I\n 287: invokestatic #111 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 290: goto 301\n 293: new #113 // class kotlin/NoWhenBranchMatchedException\n 296: dup\n 297: invokespecial #116 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 300: athrow\n 301: ireturn\n\n public final java.util.List<Day13$PacketData> component1();\n Code:\n 0: aload_0\n 1: getfield #22 // Field data:Ljava/util/List;\n 4: areturn\n\n public final Day13$ListPacketData copy(java.util.List<? extends Day13$PacketData>);\n Code:\n 0: aload_1\n 1: ldc #10 // String data\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class Day13$ListPacketData\n 9: dup\n 10: aload_1\n 11: invokespecial #41 // Method \"<init>\":(Ljava/util/List;)V\n 14: areturn\n\n public static Day13$ListPacketData copy$default(Day13$ListPacketData, java.util.List, int, java.lang.Object);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: iand\n 3: ifeq 11\n 6: aload_0\n 7: getfield #22 // Field data:Ljava/util/List;\n 10: astore_1\n 11: aload_0\n 12: aload_1\n 13: invokevirtual #144 // Method copy:(Ljava/util/List;)LDay13$ListPacketData;\n 16: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #148 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #149 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #151 // String ListPacketData(data=\n 9: invokevirtual #155 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #22 // Field data:Ljava/util/List;\n 16: invokevirtual #158 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: bipush 41\n 21: invokevirtual #161 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 24: invokevirtual #163 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 27: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #22 // Field data:Ljava/util/List;\n 4: invokevirtual #166 // Method java/lang/Object.hashCode:()I\n 7: ireturn\n\n public boolean equals(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: if_acmpne 7\n 5: iconst_1\n 6: ireturn\n 7: aload_1\n 8: instanceof #2 // class Day13$ListPacketData\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day13$ListPacketData\n 20: astore_2\n 21: aload_0\n 22: getfield #22 // Field data:Ljava/util/List;\n 25: aload_2\n 26: getfield #22 // Field data:Ljava/util/List;\n 29: invokestatic #172 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 32: ifne 37\n 35: iconst_0\n 36: ireturn\n 37: iconst_1\n 38: ireturn\n\n public int compareTo(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #4 // class Day13$PacketData\n 5: invokevirtual #43 // Method compareTo:(LDay13$PacketData;)I\n 8: ireturn\n}\n",
"javap_err": ""
}
] |
dliszewski__advent-of-code-2022__76d5eea/src/main/kotlin/Day14.kt
|
class Day14 {
fun part1(input: List<String>): Int {
val rocks = mapToRocks(input)
return Cave(rocks).dropSand()
}
fun part2(input: List<String>): Int {
val rocks = mapToRocks(input)
return Cave(rocks, true).dropSandWithFloor()
}
private fun mapToRocks(input: List<String>) = input.flatMap {
it.split(" -> ")
.windowed(2)
.flatMap { (line1, line2) -> mapToPoints(line1, line2) }
}.toSet()
private fun mapToPoints(line1: String, line2: String): List<Point> {
val (p1x, p1y) = line1.split(",").map { it.toInt() }
val (p2x, p2y) = line2.split(",").map { it.toInt() }
val xRange = if (p1x <= p2x) p1x..p2x else p2x..p1x
val yRange = if (p1y <= p2y) p1y..p2y else p2y..p1y
return (xRange).flatMap { x -> (yRange).map { y -> Point(x, y) } }
}
data class Point(val x: Int, val y: Int) {
fun possibleMovesDown(): List<Point> {
return listOf(
Point(x, y + 1),
Point(x - 1, y + 1),
Point(x + 1, y + 1)
)
}
}
class Cave(rocks: Set<Point>, withFloor: Boolean = false) {
private val sandPoint = Point(500, 0)
private val rocksAndFloor = mutableSetOf<Point>()
private val sand = mutableSetOf<Point>()
private var lowestRock = 0
init {
rocksAndFloor.addAll(rocks)
lowestRock = if (withFloor) {
val floorLevel = rocks.map { it.y }.max() + 2
val floor = createFloor(rocks, floorLevel)
rocksAndFloor.addAll(floor)
floorLevel
} else {
rocks.map { it.y }.max()
}
}
private fun createFloor(rocks: Set<Point>, floorLevel: Int): List<Point> {
val offset = rocks.map { it.y }.max()
val minX = rocks.map { it.x }.min() - offset
val maxX = rocks.map { it.x }.max() + offset
return (minX..maxX).map { Point(it, floorLevel) }
}
fun dropSand(): Int {
var nextSpot = findLandingPlace(sandPoint)
while (nextSpot != null && nextSpot != sandPoint) {
sand.add(nextSpot)
nextSpot = findLandingPlace(sandPoint)
}
draw()
return sand.size
}
fun dropSandWithFloor(): Int {
return dropSand() + 1
}
private fun findLandingPlace(current: Point): Point? {
if (current.y > lowestRock) return null
val nextPoint = current.possibleMovesDown().firstOrNull { it !in rocksAndFloor && it !in sand }
return when (nextPoint) {
null -> current
else -> findLandingPlace(nextPoint)
}
}
private fun draw() {
val all = mutableListOf<Point>().apply {
addAll(rocksAndFloor)
addAll(sand)
}
val minX = all.map { it.x }.min()
val maxX = all.map { it.x }.max()
val maxY = all.map { it.y }.max()
for (y in 0..maxY) {
for (x in minX..maxX) {
when (Point(x, y)) {
Point(500, 0) -> print('+')
in rocksAndFloor -> print('#')
in sand -> print('o')
else -> print('.')
}
if (x == maxX) {
println()
}
}
}
}
}
}
|
[
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day14$Cave.class",
"javap": "Compiled from \"Day14.kt\"\npublic final class Day14$Cave {\n private final Day14$Point sandPoint;\n\n private final java.util.Set<Day14$Point> rocksAndFloor;\n\n private final java.util.Set<Day14$Point> sand;\n\n private int lowestRock;\n\n public Day14$Cave(java.util.Set<Day14$Point>, boolean);\n Code:\n 0: aload_1\n 1: ldc #10 // String rocks\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokespecial #19 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: new #21 // class Day14$Point\n 14: dup\n 15: sipush 500\n 18: iconst_0\n 19: invokespecial #24 // Method Day14$Point.\"<init>\":(II)V\n 22: putfield #28 // Field sandPoint:LDay14$Point;\n 25: aload_0\n 26: new #30 // class java/util/LinkedHashSet\n 29: dup\n 30: invokespecial #31 // Method java/util/LinkedHashSet.\"<init>\":()V\n 33: checkcast #33 // class java/util/Set\n 36: putfield #37 // Field rocksAndFloor:Ljava/util/Set;\n 39: aload_0\n 40: new #30 // class java/util/LinkedHashSet\n 43: dup\n 44: invokespecial #31 // Method java/util/LinkedHashSet.\"<init>\":()V\n 47: checkcast #33 // class java/util/Set\n 50: putfield #40 // Field sand:Ljava/util/Set;\n 53: nop\n 54: aload_0\n 55: getfield #37 // Field rocksAndFloor:Ljava/util/Set;\n 58: aload_1\n 59: checkcast #42 // class java/util/Collection\n 62: invokeinterface #46, 2 // InterfaceMethod java/util/Set.addAll:(Ljava/util/Collection;)Z\n 67: pop\n 68: aload_0\n 69: iload_2\n 70: ifeq 223\n 73: aload_1\n 74: checkcast #48 // class java/lang/Iterable\n 77: astore 4\n 79: astore 13\n 81: iconst_0\n 82: istore 5\n 84: aload 4\n 86: astore 6\n 88: new #50 // class java/util/ArrayList\n 91: dup\n 92: aload 4\n 94: bipush 10\n 96: invokestatic #56 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 99: invokespecial #59 // Method java/util/ArrayList.\"<init>\":(I)V\n 102: checkcast #42 // class java/util/Collection\n 105: astore 7\n 107: iconst_0\n 108: istore 8\n 110: aload 6\n 112: invokeinterface #63, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 117: astore 9\n 119: aload 9\n 121: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 126: ifeq 172\n 129: aload 9\n 131: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 136: astore 10\n 138: aload 7\n 140: aload 10\n 142: checkcast #21 // class Day14$Point\n 145: astore 11\n 147: astore 14\n 149: iconst_0\n 150: istore 12\n 152: aload 11\n 154: invokevirtual #77 // Method Day14$Point.getY:()I\n 157: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 160: aload 14\n 162: swap\n 163: invokeinterface #87, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 168: pop\n 169: goto 119\n 172: aload 7\n 174: checkcast #89 // class java/util/List\n 177: nop\n 178: aload 13\n 180: swap\n 181: checkcast #48 // class java/lang/Iterable\n 184: invokestatic #93 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 187: checkcast #95 // class java/lang/Number\n 190: invokevirtual #98 // Method java/lang/Number.intValue:()I\n 193: iconst_2\n 194: iadd\n 195: istore_3\n 196: aload_0\n 197: aload_1\n 198: iload_3\n 199: invokespecial #102 // Method createFloor:(Ljava/util/Set;I)Ljava/util/List;\n 202: astore 4\n 204: aload_0\n 205: getfield #37 // Field rocksAndFloor:Ljava/util/Set;\n 208: aload 4\n 210: checkcast #42 // class java/util/Collection\n 213: invokeinterface #46, 2 // InterfaceMethod java/util/Set.addAll:(Ljava/util/Collection;)Z\n 218: pop\n 219: iload_3\n 220: goto 340\n 223: aload_1\n 224: checkcast #48 // class java/lang/Iterable\n 227: astore_3\n 228: astore 13\n 230: iconst_0\n 231: istore 4\n 233: aload_3\n 234: astore 5\n 236: new #50 // class java/util/ArrayList\n 239: dup\n 240: aload_3\n 241: bipush 10\n 243: invokestatic #56 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 246: invokespecial #59 // Method java/util/ArrayList.\"<init>\":(I)V\n 249: checkcast #42 // class java/util/Collection\n 252: astore 6\n 254: iconst_0\n 255: istore 7\n 257: aload 5\n 259: invokeinterface #63, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 264: astore 8\n 266: aload 8\n 268: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 273: ifeq 319\n 276: aload 8\n 278: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 283: astore 9\n 285: aload 6\n 287: aload 9\n 289: checkcast #21 // class Day14$Point\n 292: astore 10\n 294: astore 14\n 296: iconst_0\n 297: istore 11\n 299: aload 10\n 301: invokevirtual #77 // Method Day14$Point.getY:()I\n 304: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 307: aload 14\n 309: swap\n 310: invokeinterface #87, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 315: pop\n 316: goto 266\n 319: aload 6\n 321: checkcast #89 // class java/util/List\n 324: nop\n 325: aload 13\n 327: swap\n 328: checkcast #48 // class java/lang/Iterable\n 331: invokestatic #93 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 334: checkcast #95 // class java/lang/Number\n 337: invokevirtual #98 // Method java/lang/Number.intValue:()I\n 340: putfield #106 // Field lowestRock:I\n 343: nop\n 344: return\n\n public Day14$Cave(java.util.Set, boolean, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload_3\n 1: iconst_2\n 2: iand\n 3: ifeq 8\n 6: iconst_0\n 7: istore_2\n 8: aload_0\n 9: aload_1\n 10: iload_2\n 11: invokespecial #128 // Method \"<init>\":(Ljava/util/Set;Z)V\n 14: return\n\n private final java.util.List<Day14$Point> createFloor(java.util.Set<Day14$Point>, int);\n Code:\n 0: aload_1\n 1: checkcast #48 // class java/lang/Iterable\n 4: astore 4\n 6: iconst_0\n 7: istore 5\n 9: aload 4\n 11: astore 6\n 13: new #50 // class java/util/ArrayList\n 16: dup\n 17: aload 4\n 19: bipush 10\n 21: invokestatic #56 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 24: invokespecial #59 // Method java/util/ArrayList.\"<init>\":(I)V\n 27: checkcast #42 // class java/util/Collection\n 30: astore 7\n 32: iconst_0\n 33: istore 8\n 35: aload 6\n 37: invokeinterface #63, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 9\n 44: aload 9\n 46: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 97\n 54: aload 9\n 56: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 10\n 63: aload 7\n 65: aload 10\n 67: checkcast #21 // class Day14$Point\n 70: astore 11\n 72: astore 15\n 74: iconst_0\n 75: istore 12\n 77: aload 11\n 79: invokevirtual #77 // Method Day14$Point.getY:()I\n 82: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 85: aload 15\n 87: swap\n 88: invokeinterface #87, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 93: pop\n 94: goto 44\n 97: aload 7\n 99: checkcast #89 // class java/util/List\n 102: nop\n 103: checkcast #48 // class java/lang/Iterable\n 106: invokestatic #93 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 109: checkcast #95 // class java/lang/Number\n 112: invokevirtual #98 // Method java/lang/Number.intValue:()I\n 115: istore_3\n 116: aload_1\n 117: checkcast #48 // class java/lang/Iterable\n 120: astore 5\n 122: iconst_0\n 123: istore 6\n 125: aload 5\n 127: astore 7\n 129: new #50 // class java/util/ArrayList\n 132: dup\n 133: aload 5\n 135: bipush 10\n 137: invokestatic #56 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 140: invokespecial #59 // Method java/util/ArrayList.\"<init>\":(I)V\n 143: checkcast #42 // class java/util/Collection\n 146: astore 8\n 148: iconst_0\n 149: istore 9\n 151: aload 7\n 153: invokeinterface #63, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 158: astore 10\n 160: aload 10\n 162: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 167: ifeq 213\n 170: aload 10\n 172: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 177: astore 11\n 179: aload 8\n 181: aload 11\n 183: checkcast #21 // class Day14$Point\n 186: astore 12\n 188: astore 15\n 190: iconst_0\n 191: istore 13\n 193: aload 12\n 195: invokevirtual #132 // Method Day14$Point.getX:()I\n 198: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 201: aload 15\n 203: swap\n 204: invokeinterface #87, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 209: pop\n 210: goto 160\n 213: aload 8\n 215: checkcast #89 // class java/util/List\n 218: nop\n 219: checkcast #48 // class java/lang/Iterable\n 222: invokestatic #135 // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 225: checkcast #95 // class java/lang/Number\n 228: invokevirtual #98 // Method java/lang/Number.intValue:()I\n 231: iload_3\n 232: isub\n 233: istore 4\n 235: aload_1\n 236: checkcast #48 // class java/lang/Iterable\n 239: astore 6\n 241: iconst_0\n 242: istore 7\n 244: aload 6\n 246: astore 8\n 248: new #50 // class java/util/ArrayList\n 251: dup\n 252: aload 6\n 254: bipush 10\n 256: invokestatic #56 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 259: invokespecial #59 // Method java/util/ArrayList.\"<init>\":(I)V\n 262: checkcast #42 // class java/util/Collection\n 265: astore 9\n 267: iconst_0\n 268: istore 10\n 270: aload 8\n 272: invokeinterface #63, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 277: astore 11\n 279: aload 11\n 281: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 286: ifeq 332\n 289: aload 11\n 291: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 296: astore 12\n 298: aload 9\n 300: aload 12\n 302: checkcast #21 // class Day14$Point\n 305: astore 13\n 307: astore 15\n 309: iconst_0\n 310: istore 14\n 312: aload 13\n 314: invokevirtual #132 // Method Day14$Point.getX:()I\n 317: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 320: aload 15\n 322: swap\n 323: invokeinterface #87, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 328: pop\n 329: goto 279\n 332: aload 9\n 334: checkcast #89 // class java/util/List\n 337: nop\n 338: checkcast #48 // class java/lang/Iterable\n 341: invokestatic #93 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 344: checkcast #95 // class java/lang/Number\n 347: invokevirtual #98 // Method java/lang/Number.intValue:()I\n 350: iload_3\n 351: iadd\n 352: istore 5\n 354: new #137 // class kotlin/ranges/IntRange\n 357: dup\n 358: iload 4\n 360: iload 5\n 362: invokespecial #138 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 365: checkcast #48 // class java/lang/Iterable\n 368: astore 6\n 370: iconst_0\n 371: istore 7\n 373: aload 6\n 375: astore 8\n 377: new #50 // class java/util/ArrayList\n 380: dup\n 381: aload 6\n 383: bipush 10\n 385: invokestatic #56 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 388: invokespecial #59 // Method java/util/ArrayList.\"<init>\":(I)V\n 391: checkcast #42 // class java/util/Collection\n 394: astore 9\n 396: iconst_0\n 397: istore 10\n 399: aload 8\n 401: invokeinterface #63, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 406: astore 11\n 408: aload 11\n 410: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 415: ifeq 461\n 418: aload 11\n 420: checkcast #140 // class kotlin/collections/IntIterator\n 423: invokevirtual #143 // Method kotlin/collections/IntIterator.nextInt:()I\n 426: istore 12\n 428: aload 9\n 430: iload 12\n 432: istore 13\n 434: astore 15\n 436: iconst_0\n 437: istore 14\n 439: new #21 // class Day14$Point\n 442: dup\n 443: iload 13\n 445: iload_2\n 446: invokespecial #24 // Method Day14$Point.\"<init>\":(II)V\n 449: aload 15\n 451: swap\n 452: invokeinterface #87, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 457: pop\n 458: goto 408\n 461: aload 9\n 463: checkcast #89 // class java/util/List\n 466: nop\n 467: areturn\n\n public final int dropSand();\n Code:\n 0: aload_0\n 1: aload_0\n 2: getfield #28 // Field sandPoint:LDay14$Point;\n 5: invokespecial #155 // Method findLandingPlace:(LDay14$Point;)LDay14$Point;\n 8: astore_1\n 9: aload_1\n 10: ifnull 47\n 13: aload_1\n 14: aload_0\n 15: getfield #28 // Field sandPoint:LDay14$Point;\n 18: invokestatic #159 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 21: ifne 47\n 24: aload_0\n 25: getfield #40 // Field sand:Ljava/util/Set;\n 28: aload_1\n 29: invokeinterface #160, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 34: pop\n 35: aload_0\n 36: aload_0\n 37: getfield #28 // Field sandPoint:LDay14$Point;\n 40: invokespecial #155 // Method findLandingPlace:(LDay14$Point;)LDay14$Point;\n 43: astore_1\n 44: goto 9\n 47: aload_0\n 48: invokespecial #163 // Method draw:()V\n 51: aload_0\n 52: getfield #40 // Field sand:Ljava/util/Set;\n 55: invokeinterface #166, 1 // InterfaceMethod java/util/Set.size:()I\n 60: ireturn\n\n public final int dropSandWithFloor();\n Code:\n 0: aload_0\n 1: invokevirtual #170 // Method dropSand:()I\n 4: iconst_1\n 5: iadd\n 6: ireturn\n\n private final Day14$Point findLandingPlace(Day14$Point);\n Code:\n 0: aload_1\n 1: invokevirtual #77 // Method Day14$Point.getY:()I\n 4: aload_0\n 5: getfield #106 // Field lowestRock:I\n 8: if_icmple 13\n 11: aconst_null\n 12: areturn\n 13: aload_1\n 14: invokevirtual #174 // Method Day14$Point.possibleMovesDown:()Ljava/util/List;\n 17: checkcast #48 // class java/lang/Iterable\n 20: astore_3\n 21: iconst_0\n 22: istore 4\n 24: aload_3\n 25: invokeinterface #63, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 30: astore 5\n 32: aload 5\n 34: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 39: ifeq 102\n 42: aload 5\n 44: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 49: astore 6\n 51: aload 6\n 53: checkcast #21 // class Day14$Point\n 56: astore 7\n 58: iconst_0\n 59: istore 8\n 61: aload_0\n 62: getfield #37 // Field rocksAndFloor:Ljava/util/Set;\n 65: aload 7\n 67: invokeinterface #177, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 72: ifne 93\n 75: aload_0\n 76: getfield #40 // Field sand:Ljava/util/Set;\n 79: aload 7\n 81: invokeinterface #177, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 86: ifne 93\n 89: iconst_1\n 90: goto 94\n 93: iconst_0\n 94: ifeq 32\n 97: aload 6\n 99: goto 103\n 102: aconst_null\n 103: checkcast #21 // class Day14$Point\n 106: astore_2\n 107: aload_2\n 108: ifnonnull 115\n 111: aload_1\n 112: goto 120\n 115: aload_0\n 116: aload_2\n 117: invokespecial #155 // Method findLandingPlace:(LDay14$Point;)LDay14$Point;\n 120: areturn\n\n private final void draw();\n Code:\n 0: new #50 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #184 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #89 // 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: aload_3\n 17: aload_0\n 18: getfield #37 // Field rocksAndFloor:Ljava/util/Set;\n 21: checkcast #42 // class java/util/Collection\n 24: invokeinterface #185, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 29: pop\n 30: aload_3\n 31: aload_0\n 32: getfield #40 // Field sand:Ljava/util/Set;\n 35: checkcast #42 // class java/util/Collection\n 38: invokeinterface #185, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 43: pop\n 44: nop\n 45: aload_2\n 46: astore_1\n 47: aload_1\n 48: checkcast #48 // class java/lang/Iterable\n 51: astore_3\n 52: iconst_0\n 53: istore 4\n 55: aload_3\n 56: astore 5\n 58: new #50 // class java/util/ArrayList\n 61: dup\n 62: aload_3\n 63: bipush 10\n 65: invokestatic #56 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 68: invokespecial #59 // Method java/util/ArrayList.\"<init>\":(I)V\n 71: checkcast #42 // class java/util/Collection\n 74: astore 6\n 76: iconst_0\n 77: istore 7\n 79: aload 5\n 81: invokeinterface #63, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 86: astore 8\n 88: aload 8\n 90: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 95: ifeq 141\n 98: aload 8\n 100: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 105: astore 9\n 107: aload 6\n 109: aload 9\n 111: checkcast #21 // class Day14$Point\n 114: astore 10\n 116: astore 14\n 118: iconst_0\n 119: istore 11\n 121: aload 10\n 123: invokevirtual #132 // Method Day14$Point.getX:()I\n 126: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 129: aload 14\n 131: swap\n 132: invokeinterface #87, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 137: pop\n 138: goto 88\n 141: aload 6\n 143: checkcast #89 // class java/util/List\n 146: nop\n 147: checkcast #48 // class java/lang/Iterable\n 150: invokestatic #135 // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 153: checkcast #95 // class java/lang/Number\n 156: invokevirtual #98 // Method java/lang/Number.intValue:()I\n 159: istore_2\n 160: aload_1\n 161: checkcast #48 // class java/lang/Iterable\n 164: astore 4\n 166: iconst_0\n 167: istore 5\n 169: aload 4\n 171: astore 6\n 173: new #50 // class java/util/ArrayList\n 176: dup\n 177: aload 4\n 179: bipush 10\n 181: invokestatic #56 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 184: invokespecial #59 // Method java/util/ArrayList.\"<init>\":(I)V\n 187: checkcast #42 // class java/util/Collection\n 190: astore 7\n 192: iconst_0\n 193: istore 8\n 195: aload 6\n 197: invokeinterface #63, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 202: astore 9\n 204: aload 9\n 206: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 211: ifeq 257\n 214: aload 9\n 216: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 221: astore 10\n 223: aload 7\n 225: aload 10\n 227: checkcast #21 // class Day14$Point\n 230: astore 11\n 232: astore 14\n 234: iconst_0\n 235: istore 12\n 237: aload 11\n 239: invokevirtual #132 // Method Day14$Point.getX:()I\n 242: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 245: aload 14\n 247: swap\n 248: invokeinterface #87, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 253: pop\n 254: goto 204\n 257: aload 7\n 259: checkcast #89 // class java/util/List\n 262: nop\n 263: checkcast #48 // class java/lang/Iterable\n 266: invokestatic #93 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 269: checkcast #95 // class java/lang/Number\n 272: invokevirtual #98 // Method java/lang/Number.intValue:()I\n 275: istore_3\n 276: aload_1\n 277: checkcast #48 // class java/lang/Iterable\n 280: astore 5\n 282: iconst_0\n 283: istore 6\n 285: aload 5\n 287: astore 7\n 289: new #50 // class java/util/ArrayList\n 292: dup\n 293: aload 5\n 295: bipush 10\n 297: invokestatic #56 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 300: invokespecial #59 // Method java/util/ArrayList.\"<init>\":(I)V\n 303: checkcast #42 // class java/util/Collection\n 306: astore 8\n 308: iconst_0\n 309: istore 9\n 311: aload 7\n 313: invokeinterface #63, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 318: astore 10\n 320: aload 10\n 322: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 327: ifeq 373\n 330: aload 10\n 332: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 337: astore 11\n 339: aload 8\n 341: aload 11\n 343: checkcast #21 // class Day14$Point\n 346: astore 12\n 348: astore 14\n 350: iconst_0\n 351: istore 13\n 353: aload 12\n 355: invokevirtual #77 // Method Day14$Point.getY:()I\n 358: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 361: aload 14\n 363: swap\n 364: invokeinterface #87, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 369: pop\n 370: goto 320\n 373: aload 8\n 375: checkcast #89 // class java/util/List\n 378: nop\n 379: checkcast #48 // class java/lang/Iterable\n 382: invokestatic #93 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 385: checkcast #95 // class java/lang/Number\n 388: invokevirtual #98 // Method java/lang/Number.intValue:()I\n 391: istore 4\n 393: iconst_0\n 394: istore 5\n 396: iload 5\n 398: iload 4\n 400: if_icmpgt 566\n 403: iload_2\n 404: istore 6\n 406: iload 6\n 408: iload_3\n 409: if_icmpgt 553\n 412: new #21 // class Day14$Point\n 415: dup\n 416: iload 6\n 418: iload 5\n 420: invokespecial #24 // Method Day14$Point.\"<init>\":(II)V\n 423: astore 7\n 425: aload 7\n 427: new #21 // class Day14$Point\n 430: dup\n 431: sipush 500\n 434: iconst_0\n 435: invokespecial #24 // Method Day14$Point.\"<init>\":(II)V\n 438: invokestatic #159 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 441: ifeq 459\n 444: bipush 43\n 446: istore 8\n 448: getstatic #191 // Field java/lang/System.out:Ljava/io/PrintStream;\n 451: iload 8\n 453: invokevirtual #197 // Method java/io/PrintStream.print:(C)V\n 456: goto 529\n 459: aload_0\n 460: getfield #37 // Field rocksAndFloor:Ljava/util/Set;\n 463: aload 7\n 465: invokeinterface #177, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 470: ifeq 488\n 473: bipush 35\n 475: istore 8\n 477: getstatic #191 // Field java/lang/System.out:Ljava/io/PrintStream;\n 480: iload 8\n 482: invokevirtual #197 // Method java/io/PrintStream.print:(C)V\n 485: goto 529\n 488: aload_0\n 489: getfield #40 // Field sand:Ljava/util/Set;\n 492: aload 7\n 494: invokeinterface #177, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 499: ifeq 517\n 502: bipush 111\n 504: istore 8\n 506: getstatic #191 // Field java/lang/System.out:Ljava/io/PrintStream;\n 509: iload 8\n 511: invokevirtual #197 // Method java/io/PrintStream.print:(C)V\n 514: goto 529\n 517: bipush 46\n 519: istore 8\n 521: getstatic #191 // Field java/lang/System.out:Ljava/io/PrintStream;\n 524: iload 8\n 526: invokevirtual #197 // Method java/io/PrintStream.print:(C)V\n 529: iload 6\n 531: iload_3\n 532: if_icmpne 541\n 535: getstatic #191 // Field java/lang/System.out:Ljava/io/PrintStream;\n 538: invokevirtual #200 // Method java/io/PrintStream.println:()V\n 541: iload 6\n 543: iload_3\n 544: if_icmpeq 553\n 547: iinc 6, 1\n 550: goto 412\n 553: iload 5\n 555: iload 4\n 557: if_icmpeq 566\n 560: iinc 5, 1\n 563: goto 403\n 566: return\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day14$Point.class",
"javap": "Compiled from \"Day14.kt\"\npublic final class Day14$Point {\n private final int x;\n\n private final int y;\n\n public Day14$Point(int, int);\n Code:\n 0: aload_0\n 1: invokespecial #9 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #13 // Field x:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field y:I\n 14: return\n\n public final int getX();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: ireturn\n\n public final int getY();\n Code:\n 0: aload_0\n 1: getfield #16 // Field y:I\n 4: ireturn\n\n public final java.util.List<Day14$Point> possibleMovesDown();\n Code:\n 0: iconst_3\n 1: anewarray #2 // class Day14$Point\n 4: astore_1\n 5: aload_1\n 6: iconst_0\n 7: new #2 // class Day14$Point\n 10: dup\n 11: aload_0\n 12: getfield #13 // Field x:I\n 15: aload_0\n 16: getfield #16 // Field y:I\n 19: iconst_1\n 20: iadd\n 21: invokespecial #27 // Method \"<init>\":(II)V\n 24: aastore\n 25: aload_1\n 26: iconst_1\n 27: new #2 // class Day14$Point\n 30: dup\n 31: aload_0\n 32: getfield #13 // Field x:I\n 35: iconst_1\n 36: isub\n 37: aload_0\n 38: getfield #16 // Field y:I\n 41: iconst_1\n 42: iadd\n 43: invokespecial #27 // Method \"<init>\":(II)V\n 46: aastore\n 47: aload_1\n 48: iconst_2\n 49: new #2 // class Day14$Point\n 52: dup\n 53: aload_0\n 54: getfield #13 // Field x:I\n 57: iconst_1\n 58: iadd\n 59: aload_0\n 60: getfield #16 // Field y:I\n 63: iconst_1\n 64: iadd\n 65: invokespecial #27 // Method \"<init>\":(II)V\n 68: aastore\n 69: aload_1\n 70: invokestatic #33 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 73: 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 Day14$Point copy(int, int);\n Code:\n 0: new #2 // class Day14$Point\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: invokespecial #27 // Method \"<init>\":(II)V\n 9: areturn\n\n public static Day14$Point copy$default(Day14$Point, int, int, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_1\n 2: iand\n 3: ifeq 11\n 6: aload_0\n 7: getfield #13 // Field x:I\n 10: istore_1\n 11: iload_3\n 12: iconst_2\n 13: iand\n 14: ifeq 22\n 17: aload_0\n 18: getfield #16 // Field y:I\n 21: istore_2\n 22: aload_0\n 23: iload_1\n 24: iload_2\n 25: invokevirtual #41 // Method copy:(II)LDay14$Point;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #45 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #46 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #48 // String Point(x=\n 9: invokevirtual #52 // 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 #55 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #57 // String , y=\n 21: invokevirtual #52 // 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 #55 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #60 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #62 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 39: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: invokestatic #68 // Method java/lang/Integer.hashCode:(I)I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #16 // Field y:I\n 16: invokestatic #68 // Method java/lang/Integer.hashCode:(I)I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: 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 Day14$Point\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day14$Point\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field x:I\n 25: aload_2\n 26: getfield #13 // Field x:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field y:I\n 38: aload_2\n 39: getfield #16 // Field y:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: iconst_1\n 48: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day14.class",
"javap": "Compiled from \"Day14.kt\"\npublic final class Day14 {\n public Day14();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokespecial #26 // Method mapToRocks:(Ljava/util/List;)Ljava/util/Set;\n 11: astore_2\n 12: new #28 // class Day14$Cave\n 15: dup\n 16: aload_2\n 17: iconst_0\n 18: iconst_2\n 19: aconst_null\n 20: invokespecial #31 // Method Day14$Cave.\"<init>\":(Ljava/util/Set;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 23: invokevirtual #35 // Method Day14$Cave.dropSand:()I\n 26: ireturn\n\n public final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokespecial #26 // Method mapToRocks:(Ljava/util/List;)Ljava/util/Set;\n 11: astore_2\n 12: new #28 // class Day14$Cave\n 15: dup\n 16: aload_2\n 17: iconst_1\n 18: invokespecial #42 // Method Day14$Cave.\"<init>\":(Ljava/util/Set;Z)V\n 21: invokevirtual #45 // Method Day14$Cave.dropSandWithFloor:()I\n 24: ireturn\n\n private final java.util.Set<Day14$Point> mapToRocks(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #48 // 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 #50 // class java/util/ArrayList\n 13: dup\n 14: invokespecial #51 // Method java/util/ArrayList.\"<init>\":()V\n 17: checkcast #53 // class java/util/Collection\n 20: astore 5\n 22: iconst_0\n 23: istore 6\n 25: aload 4\n 27: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 32: astore 7\n 34: aload 7\n 36: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 41: ifeq 241\n 44: aload 7\n 46: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 51: astore 8\n 53: aload 8\n 55: checkcast #69 // class java/lang/String\n 58: astore 9\n 60: iconst_0\n 61: istore 10\n 63: aload 9\n 65: checkcast #71 // class java/lang/CharSequence\n 68: iconst_1\n 69: anewarray #69 // class java/lang/String\n 72: astore 11\n 74: aload 11\n 76: iconst_0\n 77: ldc #73 // String ->\n 79: aastore\n 80: aload 11\n 82: iconst_0\n 83: iconst_0\n 84: bipush 6\n 86: aconst_null\n 87: invokestatic #79 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 90: checkcast #48 // class java/lang/Iterable\n 93: iconst_2\n 94: iconst_0\n 95: iconst_0\n 96: bipush 6\n 98: aconst_null\n 99: invokestatic #85 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;\n 102: checkcast #48 // class java/lang/Iterable\n 105: astore 11\n 107: nop\n 108: iconst_0\n 109: istore 12\n 111: aload 11\n 113: astore 13\n 115: new #50 // class java/util/ArrayList\n 118: dup\n 119: invokespecial #51 // Method java/util/ArrayList.\"<init>\":()V\n 122: checkcast #53 // class java/util/Collection\n 125: astore 14\n 127: iconst_0\n 128: istore 15\n 130: aload 13\n 132: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 137: astore 16\n 139: aload 16\n 141: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 146: ifeq 218\n 149: aload 16\n 151: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 156: astore 17\n 158: aload 17\n 160: checkcast #87 // class java/util/List\n 163: astore 18\n 165: iconst_0\n 166: istore 19\n 168: aload 18\n 170: iconst_0\n 171: invokeinterface #91, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 176: checkcast #69 // class java/lang/String\n 179: astore 20\n 181: aload 18\n 183: iconst_1\n 184: invokeinterface #91, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 189: checkcast #69 // class java/lang/String\n 192: astore 21\n 194: aload_0\n 195: aload 20\n 197: aload 21\n 199: invokespecial #95 // Method mapToPoints:(Ljava/lang/String;Ljava/lang/String;)Ljava/util/List;\n 202: checkcast #48 // class java/lang/Iterable\n 205: astore 18\n 207: aload 14\n 209: aload 18\n 211: invokestatic #99 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 214: pop\n 215: goto 139\n 218: aload 14\n 220: checkcast #87 // class java/util/List\n 223: nop\n 224: checkcast #48 // class java/lang/Iterable\n 227: nop\n 228: astore 9\n 230: aload 5\n 232: aload 9\n 234: invokestatic #99 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 237: pop\n 238: goto 34\n 241: aload 5\n 243: checkcast #87 // class java/util/List\n 246: nop\n 247: checkcast #48 // class java/lang/Iterable\n 250: invokestatic #103 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 253: areturn\n\n private final java.util.List<Day14$Point> mapToPoints(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #71 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #69 // class java/lang/String\n 8: astore 4\n 10: aload 4\n 12: iconst_0\n 13: ldc #123 // String ,\n 15: aastore\n 16: aload 4\n 18: iconst_0\n 19: iconst_0\n 20: bipush 6\n 22: aconst_null\n 23: invokestatic #79 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 26: checkcast #48 // class java/lang/Iterable\n 29: astore 4\n 31: iconst_0\n 32: istore 5\n 34: aload 4\n 36: astore 6\n 38: new #50 // class java/util/ArrayList\n 41: dup\n 42: aload 4\n 44: bipush 10\n 46: invokestatic #127 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 49: invokespecial #130 // Method java/util/ArrayList.\"<init>\":(I)V\n 52: checkcast #53 // class java/util/Collection\n 55: astore 7\n 57: iconst_0\n 58: istore 8\n 60: aload 6\n 62: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 67: astore 9\n 69: aload 9\n 71: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 76: ifeq 123\n 79: aload 9\n 81: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 86: astore 10\n 88: aload 7\n 90: aload 10\n 92: checkcast #69 // class java/lang/String\n 95: astore 11\n 97: astore 30\n 99: iconst_0\n 100: istore 12\n 102: aload 11\n 104: invokestatic #136 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 107: nop\n 108: invokestatic #140 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 111: aload 30\n 113: swap\n 114: invokeinterface #144, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 119: pop\n 120: goto 69\n 123: aload 7\n 125: checkcast #87 // class java/util/List\n 128: nop\n 129: astore_3\n 130: aload_3\n 131: iconst_0\n 132: invokeinterface #91, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 137: checkcast #146 // class java/lang/Number\n 140: invokevirtual #149 // Method java/lang/Number.intValue:()I\n 143: istore 4\n 145: aload_3\n 146: iconst_1\n 147: invokeinterface #91, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 152: checkcast #146 // class java/lang/Number\n 155: invokevirtual #149 // Method java/lang/Number.intValue:()I\n 158: istore 5\n 160: aload_2\n 161: checkcast #71 // class java/lang/CharSequence\n 164: iconst_1\n 165: anewarray #69 // class java/lang/String\n 168: astore 7\n 170: aload 7\n 172: iconst_0\n 173: ldc #123 // String ,\n 175: aastore\n 176: aload 7\n 178: iconst_0\n 179: iconst_0\n 180: bipush 6\n 182: aconst_null\n 183: invokestatic #79 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 186: checkcast #48 // class java/lang/Iterable\n 189: astore 7\n 191: iconst_0\n 192: istore 8\n 194: aload 7\n 196: astore 9\n 198: new #50 // class java/util/ArrayList\n 201: dup\n 202: aload 7\n 204: bipush 10\n 206: invokestatic #127 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 209: invokespecial #130 // Method java/util/ArrayList.\"<init>\":(I)V\n 212: checkcast #53 // class java/util/Collection\n 215: astore 10\n 217: iconst_0\n 218: istore 11\n 220: aload 9\n 222: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 227: astore 12\n 229: aload 12\n 231: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 236: ifeq 283\n 239: aload 12\n 241: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 246: astore 13\n 248: aload 10\n 250: aload 13\n 252: checkcast #69 // class java/lang/String\n 255: astore 14\n 257: astore 30\n 259: iconst_0\n 260: istore 15\n 262: aload 14\n 264: invokestatic #136 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 267: nop\n 268: invokestatic #140 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 271: aload 30\n 273: swap\n 274: invokeinterface #144, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 279: pop\n 280: goto 229\n 283: aload 10\n 285: checkcast #87 // class java/util/List\n 288: nop\n 289: astore 6\n 291: aload 6\n 293: iconst_0\n 294: invokeinterface #91, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 299: checkcast #146 // class java/lang/Number\n 302: invokevirtual #149 // Method java/lang/Number.intValue:()I\n 305: istore 7\n 307: aload 6\n 309: iconst_1\n 310: invokeinterface #91, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 315: checkcast #146 // class java/lang/Number\n 318: invokevirtual #149 // Method java/lang/Number.intValue:()I\n 321: istore 8\n 323: iload 4\n 325: iload 7\n 327: if_icmpgt 344\n 330: new #151 // class kotlin/ranges/IntRange\n 333: dup\n 334: iload 4\n 336: iload 7\n 338: invokespecial #154 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 341: goto 355\n 344: new #151 // class kotlin/ranges/IntRange\n 347: dup\n 348: iload 7\n 350: iload 4\n 352: invokespecial #154 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 355: astore 9\n 357: iload 5\n 359: iload 8\n 361: if_icmpgt 378\n 364: new #151 // class kotlin/ranges/IntRange\n 367: dup\n 368: iload 5\n 370: iload 8\n 372: invokespecial #154 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 375: goto 389\n 378: new #151 // class kotlin/ranges/IntRange\n 381: dup\n 382: iload 8\n 384: iload 5\n 386: invokespecial #154 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 389: astore 10\n 391: aload 9\n 393: checkcast #48 // class java/lang/Iterable\n 396: astore 11\n 398: iconst_0\n 399: istore 12\n 401: aload 11\n 403: astore 13\n 405: new #50 // class java/util/ArrayList\n 408: dup\n 409: invokespecial #51 // Method java/util/ArrayList.\"<init>\":()V\n 412: checkcast #53 // class java/util/Collection\n 415: astore 14\n 417: iconst_0\n 418: istore 15\n 420: aload 13\n 422: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 427: astore 16\n 429: aload 16\n 431: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 436: ifeq 578\n 439: aload 16\n 441: checkcast #156 // class kotlin/collections/IntIterator\n 444: invokevirtual #159 // Method kotlin/collections/IntIterator.nextInt:()I\n 447: istore 17\n 449: iload 17\n 451: istore 18\n 453: iconst_0\n 454: istore 19\n 456: aload 10\n 458: checkcast #48 // class java/lang/Iterable\n 461: astore 20\n 463: iconst_0\n 464: istore 21\n 466: aload 20\n 468: astore 22\n 470: new #50 // class java/util/ArrayList\n 473: dup\n 474: aload 20\n 476: bipush 10\n 478: invokestatic #127 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 481: invokespecial #130 // Method java/util/ArrayList.\"<init>\":(I)V\n 484: checkcast #53 // class java/util/Collection\n 487: astore 23\n 489: iconst_0\n 490: istore 24\n 492: aload 22\n 494: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 499: astore 25\n 501: aload 25\n 503: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 508: ifeq 555\n 511: aload 25\n 513: checkcast #156 // class kotlin/collections/IntIterator\n 516: invokevirtual #159 // Method kotlin/collections/IntIterator.nextInt:()I\n 519: istore 26\n 521: aload 23\n 523: iload 26\n 525: istore 27\n 527: astore 28\n 529: iconst_0\n 530: istore 29\n 532: new #161 // class Day14$Point\n 535: dup\n 536: iload 18\n 538: iload 27\n 540: invokespecial #162 // Method Day14$Point.\"<init>\":(II)V\n 543: aload 28\n 545: swap\n 546: invokeinterface #144, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 551: pop\n 552: goto 501\n 555: aload 23\n 557: checkcast #87 // class java/util/List\n 560: nop\n 561: checkcast #48 // class java/lang/Iterable\n 564: nop\n 565: astore 18\n 567: aload 14\n 569: aload 18\n 571: invokestatic #99 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 574: pop\n 575: goto 429\n 578: aload 14\n 580: checkcast #87 // class java/util/List\n 583: nop\n 584: areturn\n}\n",
"javap_err": ""
}
] |
dliszewski__advent-of-code-2022__76d5eea/src/main/kotlin/Day08.kt
|
class Day08 {
fun part1(input: List<String>): Int {
return TreeArea(input).getVisibleTrees()
}
fun part2(input: List<String>): Int {
return TreeArea(input).getBestScore()
}
class TreeArea(input: List<String>) {
private val trees: Array<Array<Tree>>
private val size: Int
init {
val arr: Array<Array<Tree>> = parseTreeArea(input)
this.trees = arr
this.size = trees.size - 1
}
private fun parseTreeArea(input: List<String>): Array<Array<Tree>> {
return input.mapIndexed { rowId, row ->
row.mapIndexed { columnId, height ->
Tree(columnId, rowId, height.digitToInt())
}.toTypedArray()
}.toTypedArray()
}
fun getVisibleTrees(): Int {
return trees.flatMap { row -> row.map { isTreeVisible(it) } }.count { it }
}
fun getBestScore(): Int {
return trees.flatMap { row -> row.map { getTreeScore(it) } }.max()
}
private fun isTreeVisible(tree: Tree): Boolean = isVisibleVertically(tree) || isVisibleHorizontally(tree)
private fun isVisibleVertically(tree: Tree): Boolean {
return if (tree.rowId == 0 || tree.rowId == size) {
true
} else {
val visibleTop = (tree.rowId - 1 downTo 0).all { tree.height > trees[it][tree.columnId].height }
val visibleBottom = (tree.rowId + 1..size).all { tree.height > trees[it][tree.columnId].height }
visibleTop || visibleBottom
}
}
private fun isVisibleHorizontally(tree: Tree): Boolean {
return if (tree.columnId == 0 || tree.columnId == size) {
true
} else {
val visibleLeft = (tree.columnId - 1 downTo 0).all { tree.height > trees[tree.rowId][it].height }
val visibleRight = (tree.columnId + 1..size).all { tree.height > trees[tree.rowId][it].height }
visibleLeft || visibleRight
}
}
private fun getTreeScore(tree: Tree): Int = getScoreVertically(tree) * getScoreHorizontally(tree)
private fun getScoreVertically(tree: Tree): Int {
return if (tree.rowId == 0 || tree.rowId == size) {
1
} else {
val scoreTop = (tree.rowId - 1 downTo 0)
.map { trees[it][tree.columnId] }
.takeUntil { it.height >= tree.height }.count()
val scoreBottom = (tree.rowId + 1..size)
.map { trees[it][tree.columnId] }
.takeUntil { it.height >= tree.height }.count()
scoreTop * scoreBottom
}
}
private fun getScoreHorizontally(tree: Tree): Int {
return if (tree.columnId == 0 || tree.columnId == size) {
1
} else {
val scoreLeft = (tree.columnId - 1 downTo 0)
.map { trees[tree.rowId][it] }
.takeUntil { it.height >= tree.height }.count()
val scoreRight = (tree.columnId + 1..size)
.map { trees[tree.rowId][it] }
.takeUntil { it.height >= tree.height }.count()
scoreLeft * scoreRight
}
}
}
data class Tree(val columnId: Int, val rowId: Int, val height: Int)
}
private fun <T> Iterable<T>.takeUntil(predicate: (T) -> Boolean): List<T> {
val list = ArrayList<T>()
for (item in this) {
list.add(item)
if (predicate(item))
break
}
return list
}
|
[
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day08.class",
"javap": "Compiled from \"Day08.kt\"\npublic final class Day08 {\n public Day08();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #24 // class Day08$TreeArea\n 9: dup\n 10: aload_1\n 11: invokespecial #27 // Method Day08$TreeArea.\"<init>\":(Ljava/util/List;)V\n 14: invokevirtual #31 // Method Day08$TreeArea.getVisibleTrees:()I\n 17: ireturn\n\n public final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #24 // class Day08$TreeArea\n 9: dup\n 10: aload_1\n 11: invokespecial #27 // Method Day08$TreeArea.\"<init>\":(Ljava/util/List;)V\n 14: invokevirtual #36 // Method Day08$TreeArea.getBestScore:()I\n 17: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day08$Tree.class",
"javap": "Compiled from \"Day08.kt\"\npublic final class Day08$Tree {\n private final int columnId;\n\n private final int rowId;\n\n private final int height;\n\n public Day08$Tree(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 columnId:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field rowId:I\n 14: aload_0\n 15: iload_3\n 16: putfield #19 // Field height:I\n 19: return\n\n public final int getColumnId();\n Code:\n 0: aload_0\n 1: getfield #13 // Field columnId:I\n 4: ireturn\n\n public final int getRowId();\n Code:\n 0: aload_0\n 1: getfield #16 // Field rowId:I\n 4: ireturn\n\n public final int getHeight();\n Code:\n 0: aload_0\n 1: getfield #19 // Field height:I\n 4: ireturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field columnId:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field rowId:I\n 4: ireturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #19 // Field height:I\n 4: ireturn\n\n public final Day08$Tree copy(int, int, int);\n Code:\n 0: new #2 // class Day08$Tree\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 Day08$Tree copy$default(Day08$Tree, 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 columnId: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 rowId: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 height: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)LDay08$Tree;\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 Tree(columnId=\n 9: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field columnId:I\n 16: invokevirtual #51 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #53 // String , rowId=\n 21: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #16 // Field rowId:I\n 28: invokevirtual #51 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #55 // String , height=\n 33: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #19 // Field height: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 columnId: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 rowId: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 height: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 Day08$Tree\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day08$Tree\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field columnId:I\n 25: aload_2\n 26: getfield #13 // Field columnId:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field rowId:I\n 38: aload_2\n 39: getfield #16 // Field rowId:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: aload_0\n 48: getfield #19 // Field height:I\n 51: aload_2\n 52: getfield #19 // Field height: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": "dliszewski__advent-of-code-2022__76d5eea/Day08Kt.class",
"javap": "Compiled from \"Day08.kt\"\npublic final class Day08Kt {\n private static final <T> java.util.List<T> takeUntil(java.lang.Iterable<? extends T>, kotlin.jvm.functions.Function1<? super T, java.lang.Boolean>);\n Code:\n 0: new #9 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #13 // Method java/util/ArrayList.\"<init>\":()V\n 7: astore_2\n 8: aload_0\n 9: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 14: astore_3\n 15: aload_3\n 16: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 21: ifeq 59\n 24: aload_3\n 25: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 30: astore 4\n 32: aload_2\n 33: aload 4\n 35: invokevirtual #33 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 38: pop\n 39: aload_1\n 40: aload 4\n 42: invokeinterface #39, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 47: checkcast #41 // class java/lang/Boolean\n 50: invokevirtual #44 // Method java/lang/Boolean.booleanValue:()Z\n 53: ifeq 15\n 56: goto 59\n 59: aload_2\n 60: checkcast #46 // class java/util/List\n 63: areturn\n\n public static final java.util.List access$takeUntil(java.lang.Iterable, kotlin.jvm.functions.Function1);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #57 // Method takeUntil:(Ljava/lang/Iterable;Lkotlin/jvm/functions/Function1;)Ljava/util/List;\n 5: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day08$TreeArea.class",
"javap": "Compiled from \"Day08.kt\"\npublic final class Day08$TreeArea {\n private final Day08$Tree[][] trees;\n\n private final int size;\n\n public Day08$TreeArea(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokespecial #19 // Method java/lang/Object.\"<init>\":()V\n 10: nop\n 11: aload_0\n 12: aload_1\n 13: invokespecial #23 // Method parseTreeArea:(Ljava/util/List;)[[LDay08$Tree;\n 16: astore_2\n 17: aload_0\n 18: aload_2\n 19: putfield #27 // Field trees:[[LDay08$Tree;\n 22: aload_0\n 23: aload_0\n 24: getfield #27 // Field trees:[[LDay08$Tree;\n 27: checkcast #29 // class \"[Ljava/lang/Object;\"\n 30: arraylength\n 31: iconst_1\n 32: isub\n 33: putfield #33 // Field size:I\n 36: nop\n 37: return\n\n private final Day08$Tree[][] parseTreeArea(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #40 // 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 #42 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: bipush 10\n 17: invokestatic #48 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #51 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #53 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: iconst_0\n 32: istore 7\n 34: aload 4\n 36: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 41: astore 8\n 43: aload 8\n 45: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 50: ifeq 255\n 53: aload 8\n 55: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 60: astore 9\n 62: aload 5\n 64: iload 7\n 66: iinc 7, 1\n 69: istore 10\n 71: iload 10\n 73: ifge 79\n 76: invokestatic #70 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 79: iload 10\n 81: aload 9\n 83: checkcast #72 // class java/lang/String\n 86: astore 11\n 88: istore 12\n 90: astore 26\n 92: iconst_0\n 93: istore 13\n 95: aload 11\n 97: checkcast #74 // class java/lang/CharSequence\n 100: astore 14\n 102: iconst_0\n 103: istore 15\n 105: aload 14\n 107: astore 16\n 109: new #42 // class java/util/ArrayList\n 112: dup\n 113: aload 14\n 115: invokeinterface #78, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 120: invokespecial #51 // Method java/util/ArrayList.\"<init>\":(I)V\n 123: checkcast #53 // class java/util/Collection\n 126: astore 17\n 128: iconst_0\n 129: istore 18\n 131: iconst_0\n 132: istore 19\n 134: iconst_0\n 135: istore 20\n 137: iload 20\n 139: aload 16\n 141: invokeinterface #78, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 146: if_icmpge 209\n 149: aload 16\n 151: iload 20\n 153: invokeinterface #82, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 158: istore 21\n 160: aload 17\n 162: iload 19\n 164: iinc 19, 1\n 167: iload 21\n 169: istore 22\n 171: istore 23\n 173: astore 24\n 175: iconst_0\n 176: istore 25\n 178: new #84 // class Day08$Tree\n 181: dup\n 182: iload 23\n 184: iload 12\n 186: iload 22\n 188: invokestatic #90 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 191: invokespecial #93 // Method Day08$Tree.\"<init>\":(III)V\n 194: aload 24\n 196: swap\n 197: invokeinterface #97, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 202: pop\n 203: iinc 20, 1\n 206: goto 137\n 209: aload 17\n 211: checkcast #99 // class java/util/List\n 214: nop\n 215: checkcast #53 // class java/util/Collection\n 218: astore 14\n 220: nop\n 221: iconst_0\n 222: istore 15\n 224: aload 14\n 226: astore 16\n 228: aload 16\n 230: iconst_0\n 231: anewarray #84 // class Day08$Tree\n 234: invokeinterface #103, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 239: checkcast #105 // class \"[LDay08$Tree;\"\n 242: nop\n 243: aload 26\n 245: swap\n 246: invokeinterface #97, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 251: pop\n 252: goto 43\n 255: aload 5\n 257: checkcast #99 // class java/util/List\n 260: nop\n 261: checkcast #53 // class java/util/Collection\n 264: astore_2\n 265: nop\n 266: iconst_0\n 267: istore_3\n 268: aload_2\n 269: astore 4\n 271: aload 4\n 273: iconst_0\n 274: anewarray #105 // class \"[LDay08$Tree;\"\n 277: invokeinterface #103, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 282: checkcast #106 // class \"[[LDay08$Tree;\"\n 285: areturn\n\n public final int getVisibleTrees();\n Code:\n 0: aload_0\n 1: getfield #27 // Field trees:[[LDay08$Tree;\n 4: checkcast #29 // class \"[Ljava/lang/Object;\"\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: astore_3\n 12: new #42 // class java/util/ArrayList\n 15: dup\n 16: invokespecial #130 // Method java/util/ArrayList.\"<init>\":()V\n 19: checkcast #53 // class java/util/Collection\n 22: astore 4\n 24: iconst_0\n 25: istore 5\n 27: iconst_0\n 28: istore 6\n 30: aload_3\n 31: arraylength\n 32: istore 7\n 34: iload 6\n 36: iload 7\n 38: if_icmpge 169\n 41: aload_3\n 42: iload 6\n 44: aaload\n 45: astore 8\n 47: aload 8\n 49: checkcast #105 // class \"[LDay08$Tree;\"\n 52: astore 9\n 54: iconst_0\n 55: istore 10\n 57: aload 9\n 59: astore 11\n 61: iconst_0\n 62: istore 12\n 64: aload 11\n 66: astore 13\n 68: new #42 // class java/util/ArrayList\n 71: dup\n 72: aload 11\n 74: arraylength\n 75: invokespecial #51 // Method java/util/ArrayList.\"<init>\":(I)V\n 78: checkcast #53 // class java/util/Collection\n 81: astore 14\n 83: iconst_0\n 84: istore 15\n 86: iconst_0\n 87: istore 16\n 89: aload 13\n 91: arraylength\n 92: istore 17\n 94: iload 16\n 96: iload 17\n 98: if_icmpge 143\n 101: aload 13\n 103: iload 16\n 105: aaload\n 106: astore 18\n 108: aload 14\n 110: aload 18\n 112: astore 19\n 114: astore 20\n 116: iconst_0\n 117: istore 21\n 119: aload_0\n 120: aload 19\n 122: invokespecial #134 // Method isTreeVisible:(LDay08$Tree;)Z\n 125: invokestatic #140 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 128: aload 20\n 130: swap\n 131: invokeinterface #97, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 136: pop\n 137: iinc 16, 1\n 140: goto 94\n 143: aload 14\n 145: checkcast #99 // class java/util/List\n 148: nop\n 149: checkcast #40 // class java/lang/Iterable\n 152: nop\n 153: astore 9\n 155: aload 4\n 157: aload 9\n 159: invokestatic #144 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 162: pop\n 163: iinc 6, 1\n 166: goto 34\n 169: aload 4\n 171: checkcast #99 // class java/util/List\n 174: nop\n 175: checkcast #40 // class java/lang/Iterable\n 178: astore_1\n 179: nop\n 180: iconst_0\n 181: istore_2\n 182: aload_1\n 183: instanceof #53 // class java/util/Collection\n 186: ifeq 205\n 189: aload_1\n 190: checkcast #53 // class java/util/Collection\n 193: invokeinterface #147, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 198: ifeq 205\n 201: iconst_0\n 202: goto 266\n 205: iconst_0\n 206: istore_3\n 207: aload_1\n 208: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 213: astore 4\n 215: aload 4\n 217: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 222: ifeq 265\n 225: aload 4\n 227: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 232: astore 5\n 234: aload 5\n 236: checkcast #136 // class java/lang/Boolean\n 239: invokevirtual #150 // Method java/lang/Boolean.booleanValue:()Z\n 242: istore 6\n 244: iconst_0\n 245: istore 7\n 247: iload 6\n 249: ifeq 215\n 252: iinc 3, 1\n 255: iload_3\n 256: ifge 215\n 259: invokestatic #153 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 262: goto 215\n 265: iload_3\n 266: ireturn\n\n public final int getBestScore();\n Code:\n 0: aload_0\n 1: getfield #27 // Field trees:[[LDay08$Tree;\n 4: checkcast #29 // class \"[Ljava/lang/Object;\"\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: astore_3\n 12: new #42 // class java/util/ArrayList\n 15: dup\n 16: invokespecial #130 // Method java/util/ArrayList.\"<init>\":()V\n 19: checkcast #53 // class java/util/Collection\n 22: astore 4\n 24: iconst_0\n 25: istore 5\n 27: iconst_0\n 28: istore 6\n 30: aload_3\n 31: arraylength\n 32: istore 7\n 34: iload 6\n 36: iload 7\n 38: if_icmpge 169\n 41: aload_3\n 42: iload 6\n 44: aaload\n 45: astore 8\n 47: aload 8\n 49: checkcast #105 // class \"[LDay08$Tree;\"\n 52: astore 9\n 54: iconst_0\n 55: istore 10\n 57: aload 9\n 59: astore 11\n 61: iconst_0\n 62: istore 12\n 64: aload 11\n 66: astore 13\n 68: new #42 // class java/util/ArrayList\n 71: dup\n 72: aload 11\n 74: arraylength\n 75: invokespecial #51 // Method java/util/ArrayList.\"<init>\":(I)V\n 78: checkcast #53 // class java/util/Collection\n 81: astore 14\n 83: iconst_0\n 84: istore 15\n 86: iconst_0\n 87: istore 16\n 89: aload 13\n 91: arraylength\n 92: istore 17\n 94: iload 16\n 96: iload 17\n 98: if_icmpge 143\n 101: aload 13\n 103: iload 16\n 105: aaload\n 106: astore 18\n 108: aload 14\n 110: aload 18\n 112: astore 19\n 114: astore 20\n 116: iconst_0\n 117: istore 21\n 119: aload_0\n 120: aload 19\n 122: invokespecial #178 // Method getTreeScore:(LDay08$Tree;)I\n 125: invokestatic #183 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 128: aload 20\n 130: swap\n 131: invokeinterface #97, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 136: pop\n 137: iinc 16, 1\n 140: goto 94\n 143: aload 14\n 145: checkcast #99 // class java/util/List\n 148: nop\n 149: checkcast #40 // class java/lang/Iterable\n 152: nop\n 153: astore 9\n 155: aload 4\n 157: aload 9\n 159: invokestatic #144 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 162: pop\n 163: iinc 6, 1\n 166: goto 34\n 169: aload 4\n 171: checkcast #99 // class java/util/List\n 174: nop\n 175: checkcast #40 // class java/lang/Iterable\n 178: invokestatic #187 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 181: checkcast #189 // class java/lang/Number\n 184: invokevirtual #192 // Method java/lang/Number.intValue:()I\n 187: ireturn\n\n private final boolean isTreeVisible(Day08$Tree);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #197 // Method isVisibleVertically:(LDay08$Tree;)Z\n 5: ifne 16\n 8: aload_0\n 9: aload_1\n 10: invokespecial #200 // Method isVisibleHorizontally:(LDay08$Tree;)Z\n 13: ifeq 20\n 16: iconst_1\n 17: goto 21\n 20: iconst_0\n 21: ireturn\n\n private final boolean isVisibleVertically(Day08$Tree);\n Code:\n 0: aload_1\n 1: invokevirtual #204 // Method Day08$Tree.getRowId:()I\n 4: ifeq 18\n 7: aload_1\n 8: invokevirtual #204 // Method Day08$Tree.getRowId:()I\n 11: aload_0\n 12: getfield #33 // Field size:I\n 15: if_icmpne 22\n 18: iconst_1\n 19: goto 268\n 22: aload_1\n 23: invokevirtual #204 // Method Day08$Tree.getRowId:()I\n 26: iconst_1\n 27: isub\n 28: iconst_0\n 29: invokestatic #210 // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;\n 32: checkcast #40 // class java/lang/Iterable\n 35: astore_3\n 36: iconst_0\n 37: istore 4\n 39: aload_3\n 40: instanceof #53 // class java/util/Collection\n 43: ifeq 62\n 46: aload_3\n 47: checkcast #53 // class java/util/Collection\n 50: invokeinterface #147, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 55: ifeq 62\n 58: iconst_1\n 59: goto 132\n 62: aload_3\n 63: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 68: astore 5\n 70: aload 5\n 72: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 77: ifeq 131\n 80: aload 5\n 82: checkcast #212 // class kotlin/collections/IntIterator\n 85: invokevirtual #215 // Method kotlin/collections/IntIterator.nextInt:()I\n 88: istore 6\n 90: iload 6\n 92: istore 7\n 94: iconst_0\n 95: istore 8\n 97: aload_1\n 98: invokevirtual #218 // Method Day08$Tree.getHeight:()I\n 101: aload_0\n 102: getfield #27 // Field trees:[[LDay08$Tree;\n 105: iload 7\n 107: aaload\n 108: aload_1\n 109: invokevirtual #221 // Method Day08$Tree.getColumnId:()I\n 112: aaload\n 113: invokevirtual #218 // Method Day08$Tree.getHeight:()I\n 116: if_icmple 123\n 119: iconst_1\n 120: goto 124\n 123: iconst_0\n 124: ifne 70\n 127: iconst_0\n 128: goto 132\n 131: iconst_1\n 132: istore_2\n 133: new #223 // class kotlin/ranges/IntRange\n 136: dup\n 137: aload_1\n 138: invokevirtual #204 // Method Day08$Tree.getRowId:()I\n 141: iconst_1\n 142: iadd\n 143: aload_0\n 144: getfield #33 // Field size:I\n 147: invokespecial #226 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 150: checkcast #40 // class java/lang/Iterable\n 153: astore 4\n 155: iconst_0\n 156: istore 5\n 158: aload 4\n 160: instanceof #53 // class java/util/Collection\n 163: ifeq 183\n 166: aload 4\n 168: checkcast #53 // class java/util/Collection\n 171: invokeinterface #147, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 176: ifeq 183\n 179: iconst_1\n 180: goto 254\n 183: aload 4\n 185: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 190: astore 6\n 192: aload 6\n 194: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 199: ifeq 253\n 202: aload 6\n 204: checkcast #212 // class kotlin/collections/IntIterator\n 207: invokevirtual #215 // Method kotlin/collections/IntIterator.nextInt:()I\n 210: istore 7\n 212: iload 7\n 214: istore 8\n 216: iconst_0\n 217: istore 9\n 219: aload_1\n 220: invokevirtual #218 // Method Day08$Tree.getHeight:()I\n 223: aload_0\n 224: getfield #27 // Field trees:[[LDay08$Tree;\n 227: iload 8\n 229: aaload\n 230: aload_1\n 231: invokevirtual #221 // Method Day08$Tree.getColumnId:()I\n 234: aaload\n 235: invokevirtual #218 // Method Day08$Tree.getHeight:()I\n 238: if_icmple 245\n 241: iconst_1\n 242: goto 246\n 245: iconst_0\n 246: ifne 192\n 249: iconst_0\n 250: goto 254\n 253: iconst_1\n 254: istore_3\n 255: iload_2\n 256: ifne 263\n 259: iload_3\n 260: ifeq 267\n 263: iconst_1\n 264: goto 268\n 267: iconst_0\n 268: ireturn\n\n private final boolean isVisibleHorizontally(Day08$Tree);\n Code:\n 0: aload_1\n 1: invokevirtual #221 // Method Day08$Tree.getColumnId:()I\n 4: ifeq 18\n 7: aload_1\n 8: invokevirtual #221 // Method Day08$Tree.getColumnId:()I\n 11: aload_0\n 12: getfield #33 // Field size:I\n 15: if_icmpne 22\n 18: iconst_1\n 19: goto 268\n 22: aload_1\n 23: invokevirtual #221 // Method Day08$Tree.getColumnId:()I\n 26: iconst_1\n 27: isub\n 28: iconst_0\n 29: invokestatic #210 // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;\n 32: checkcast #40 // class java/lang/Iterable\n 35: astore_3\n 36: iconst_0\n 37: istore 4\n 39: aload_3\n 40: instanceof #53 // class java/util/Collection\n 43: ifeq 62\n 46: aload_3\n 47: checkcast #53 // class java/util/Collection\n 50: invokeinterface #147, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 55: ifeq 62\n 58: iconst_1\n 59: goto 132\n 62: aload_3\n 63: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 68: astore 5\n 70: aload 5\n 72: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 77: ifeq 131\n 80: aload 5\n 82: checkcast #212 // class kotlin/collections/IntIterator\n 85: invokevirtual #215 // Method kotlin/collections/IntIterator.nextInt:()I\n 88: istore 6\n 90: iload 6\n 92: istore 7\n 94: iconst_0\n 95: istore 8\n 97: aload_1\n 98: invokevirtual #218 // Method Day08$Tree.getHeight:()I\n 101: aload_0\n 102: getfield #27 // Field trees:[[LDay08$Tree;\n 105: aload_1\n 106: invokevirtual #204 // Method Day08$Tree.getRowId:()I\n 109: aaload\n 110: iload 7\n 112: aaload\n 113: invokevirtual #218 // Method Day08$Tree.getHeight:()I\n 116: if_icmple 123\n 119: iconst_1\n 120: goto 124\n 123: iconst_0\n 124: ifne 70\n 127: iconst_0\n 128: goto 132\n 131: iconst_1\n 132: istore_2\n 133: new #223 // class kotlin/ranges/IntRange\n 136: dup\n 137: aload_1\n 138: invokevirtual #221 // Method Day08$Tree.getColumnId:()I\n 141: iconst_1\n 142: iadd\n 143: aload_0\n 144: getfield #33 // Field size:I\n 147: invokespecial #226 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 150: checkcast #40 // class java/lang/Iterable\n 153: astore 4\n 155: iconst_0\n 156: istore 5\n 158: aload 4\n 160: instanceof #53 // class java/util/Collection\n 163: ifeq 183\n 166: aload 4\n 168: checkcast #53 // class java/util/Collection\n 171: invokeinterface #147, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 176: ifeq 183\n 179: iconst_1\n 180: goto 254\n 183: aload 4\n 185: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 190: astore 6\n 192: aload 6\n 194: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 199: ifeq 253\n 202: aload 6\n 204: checkcast #212 // class kotlin/collections/IntIterator\n 207: invokevirtual #215 // Method kotlin/collections/IntIterator.nextInt:()I\n 210: istore 7\n 212: iload 7\n 214: istore 8\n 216: iconst_0\n 217: istore 9\n 219: aload_1\n 220: invokevirtual #218 // Method Day08$Tree.getHeight:()I\n 223: aload_0\n 224: getfield #27 // Field trees:[[LDay08$Tree;\n 227: aload_1\n 228: invokevirtual #204 // Method Day08$Tree.getRowId:()I\n 231: aaload\n 232: iload 8\n 234: aaload\n 235: invokevirtual #218 // Method Day08$Tree.getHeight:()I\n 238: if_icmple 245\n 241: iconst_1\n 242: goto 246\n 245: iconst_0\n 246: ifne 192\n 249: iconst_0\n 250: goto 254\n 253: iconst_1\n 254: istore_3\n 255: iload_2\n 256: ifne 263\n 259: iload_3\n 260: ifeq 267\n 263: iconst_1\n 264: goto 268\n 267: iconst_0\n 268: ireturn\n\n private final int getTreeScore(Day08$Tree);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #239 // Method getScoreVertically:(LDay08$Tree;)I\n 5: aload_0\n 6: aload_1\n 7: invokespecial #242 // Method getScoreHorizontally:(LDay08$Tree;)I\n 10: imul\n 11: ireturn\n\n private final int getScoreVertically(Day08$Tree);\n Code:\n 0: aload_1\n 1: invokevirtual #204 // Method Day08$Tree.getRowId:()I\n 4: ifeq 18\n 7: aload_1\n 8: invokevirtual #204 // Method Day08$Tree.getRowId:()I\n 11: aload_0\n 12: getfield #33 // Field size:I\n 15: if_icmpne 22\n 18: iconst_1\n 19: goto 301\n 22: aload_1\n 23: invokevirtual #204 // Method Day08$Tree.getRowId:()I\n 26: iconst_1\n 27: isub\n 28: iconst_0\n 29: invokestatic #210 // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;\n 32: checkcast #40 // 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: astore 5\n 43: new #42 // class java/util/ArrayList\n 46: dup\n 47: aload_3\n 48: bipush 10\n 50: invokestatic #48 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 53: invokespecial #51 // Method java/util/ArrayList.\"<init>\":(I)V\n 56: checkcast #53 // class java/util/Collection\n 59: astore 6\n 61: iconst_0\n 62: istore 7\n 64: aload 5\n 66: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 71: astore 8\n 73: aload 8\n 75: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 80: ifeq 128\n 83: aload 8\n 85: checkcast #212 // class kotlin/collections/IntIterator\n 88: invokevirtual #215 // Method kotlin/collections/IntIterator.nextInt:()I\n 91: istore 9\n 93: aload 6\n 95: iload 9\n 97: istore 10\n 99: astore 13\n 101: iconst_0\n 102: istore 11\n 104: aload_0\n 105: getfield #27 // Field trees:[[LDay08$Tree;\n 108: iload 10\n 110: aaload\n 111: aload_1\n 112: invokevirtual #221 // Method Day08$Tree.getColumnId:()I\n 115: aaload\n 116: aload 13\n 118: swap\n 119: invokeinterface #97, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 124: pop\n 125: goto 73\n 128: aload 6\n 130: checkcast #99 // class java/util/List\n 133: nop\n 134: checkcast #40 // class java/lang/Iterable\n 137: aload_1\n 138: invokedynamic #262, 0 // InvokeDynamic #0:invoke:(LDay08$Tree;)Lkotlin/jvm/functions/Function1;\n 143: invokestatic #268 // Method Day08Kt.access$takeUntil:(Ljava/lang/Iterable;Lkotlin/jvm/functions/Function1;)Ljava/util/List;\n 146: checkcast #53 // class java/util/Collection\n 149: invokeinterface #270, 1 // InterfaceMethod java/util/Collection.size:()I\n 154: istore_2\n 155: new #223 // class kotlin/ranges/IntRange\n 158: dup\n 159: aload_1\n 160: invokevirtual #204 // Method Day08$Tree.getRowId:()I\n 163: iconst_1\n 164: iadd\n 165: aload_0\n 166: getfield #33 // Field size:I\n 169: invokespecial #226 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 172: checkcast #40 // class java/lang/Iterable\n 175: astore 4\n 177: nop\n 178: iconst_0\n 179: istore 5\n 181: aload 4\n 183: astore 6\n 185: new #42 // class java/util/ArrayList\n 188: dup\n 189: aload 4\n 191: bipush 10\n 193: invokestatic #48 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 196: invokespecial #51 // Method java/util/ArrayList.\"<init>\":(I)V\n 199: checkcast #53 // class java/util/Collection\n 202: astore 7\n 204: iconst_0\n 205: istore 8\n 207: aload 6\n 209: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 214: astore 9\n 216: aload 9\n 218: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 223: ifeq 271\n 226: aload 9\n 228: checkcast #212 // class kotlin/collections/IntIterator\n 231: invokevirtual #215 // Method kotlin/collections/IntIterator.nextInt:()I\n 234: istore 10\n 236: aload 7\n 238: iload 10\n 240: istore 11\n 242: astore 13\n 244: iconst_0\n 245: istore 12\n 247: aload_0\n 248: getfield #27 // Field trees:[[LDay08$Tree;\n 251: iload 11\n 253: aaload\n 254: aload_1\n 255: invokevirtual #221 // Method Day08$Tree.getColumnId:()I\n 258: aaload\n 259: aload 13\n 261: swap\n 262: invokeinterface #97, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 267: pop\n 268: goto 216\n 271: aload 7\n 273: checkcast #99 // class java/util/List\n 276: nop\n 277: checkcast #40 // class java/lang/Iterable\n 280: aload_1\n 281: invokedynamic #275, 0 // InvokeDynamic #1:invoke:(LDay08$Tree;)Lkotlin/jvm/functions/Function1;\n 286: invokestatic #268 // Method Day08Kt.access$takeUntil:(Ljava/lang/Iterable;Lkotlin/jvm/functions/Function1;)Ljava/util/List;\n 289: checkcast #53 // class java/util/Collection\n 292: invokeinterface #270, 1 // InterfaceMethod java/util/Collection.size:()I\n 297: istore_3\n 298: iload_2\n 299: iload_3\n 300: imul\n 301: ireturn\n\n private final int getScoreHorizontally(Day08$Tree);\n Code:\n 0: aload_1\n 1: invokevirtual #221 // Method Day08$Tree.getColumnId:()I\n 4: ifeq 18\n 7: aload_1\n 8: invokevirtual #221 // Method Day08$Tree.getColumnId:()I\n 11: aload_0\n 12: getfield #33 // Field size:I\n 15: if_icmpne 22\n 18: iconst_1\n 19: goto 301\n 22: aload_1\n 23: invokevirtual #221 // Method Day08$Tree.getColumnId:()I\n 26: iconst_1\n 27: isub\n 28: iconst_0\n 29: invokestatic #210 // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;\n 32: checkcast #40 // 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: astore 5\n 43: new #42 // class java/util/ArrayList\n 46: dup\n 47: aload_3\n 48: bipush 10\n 50: invokestatic #48 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 53: invokespecial #51 // Method java/util/ArrayList.\"<init>\":(I)V\n 56: checkcast #53 // class java/util/Collection\n 59: astore 6\n 61: iconst_0\n 62: istore 7\n 64: aload 5\n 66: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 71: astore 8\n 73: aload 8\n 75: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 80: ifeq 128\n 83: aload 8\n 85: checkcast #212 // class kotlin/collections/IntIterator\n 88: invokevirtual #215 // Method kotlin/collections/IntIterator.nextInt:()I\n 91: istore 9\n 93: aload 6\n 95: iload 9\n 97: istore 10\n 99: astore 13\n 101: iconst_0\n 102: istore 11\n 104: aload_0\n 105: getfield #27 // Field trees:[[LDay08$Tree;\n 108: aload_1\n 109: invokevirtual #204 // Method Day08$Tree.getRowId:()I\n 112: aaload\n 113: iload 10\n 115: aaload\n 116: aload 13\n 118: swap\n 119: invokeinterface #97, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 124: pop\n 125: goto 73\n 128: aload 6\n 130: checkcast #99 // class java/util/List\n 133: nop\n 134: checkcast #40 // class java/lang/Iterable\n 137: aload_1\n 138: invokedynamic #284, 0 // InvokeDynamic #2:invoke:(LDay08$Tree;)Lkotlin/jvm/functions/Function1;\n 143: invokestatic #268 // Method Day08Kt.access$takeUntil:(Ljava/lang/Iterable;Lkotlin/jvm/functions/Function1;)Ljava/util/List;\n 146: checkcast #53 // class java/util/Collection\n 149: invokeinterface #270, 1 // InterfaceMethod java/util/Collection.size:()I\n 154: istore_2\n 155: new #223 // class kotlin/ranges/IntRange\n 158: dup\n 159: aload_1\n 160: invokevirtual #221 // Method Day08$Tree.getColumnId:()I\n 163: iconst_1\n 164: iadd\n 165: aload_0\n 166: getfield #33 // Field size:I\n 169: invokespecial #226 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 172: checkcast #40 // class java/lang/Iterable\n 175: astore 4\n 177: nop\n 178: iconst_0\n 179: istore 5\n 181: aload 4\n 183: astore 6\n 185: new #42 // class java/util/ArrayList\n 188: dup\n 189: aload 4\n 191: bipush 10\n 193: invokestatic #48 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 196: invokespecial #51 // Method java/util/ArrayList.\"<init>\":(I)V\n 199: checkcast #53 // class java/util/Collection\n 202: astore 7\n 204: iconst_0\n 205: istore 8\n 207: aload 6\n 209: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 214: astore 9\n 216: aload 9\n 218: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 223: ifeq 271\n 226: aload 9\n 228: checkcast #212 // class kotlin/collections/IntIterator\n 231: invokevirtual #215 // Method kotlin/collections/IntIterator.nextInt:()I\n 234: istore 10\n 236: aload 7\n 238: iload 10\n 240: istore 11\n 242: astore 13\n 244: iconst_0\n 245: istore 12\n 247: aload_0\n 248: getfield #27 // Field trees:[[LDay08$Tree;\n 251: aload_1\n 252: invokevirtual #204 // Method Day08$Tree.getRowId:()I\n 255: aaload\n 256: iload 11\n 258: aaload\n 259: aload 13\n 261: swap\n 262: invokeinterface #97, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 267: pop\n 268: goto 216\n 271: aload 7\n 273: checkcast #99 // class java/util/List\n 276: nop\n 277: checkcast #40 // class java/lang/Iterable\n 280: aload_1\n 281: invokedynamic #289, 0 // InvokeDynamic #3:invoke:(LDay08$Tree;)Lkotlin/jvm/functions/Function1;\n 286: invokestatic #268 // Method Day08Kt.access$takeUntil:(Ljava/lang/Iterable;Lkotlin/jvm/functions/Function1;)Ljava/util/List;\n 289: checkcast #53 // class java/util/Collection\n 292: invokeinterface #270, 1 // InterfaceMethod java/util/Collection.size:()I\n 297: istore_3\n 298: iload_2\n 299: iload_3\n 300: imul\n 301: ireturn\n\n private static final boolean getScoreVertically$lambda$12(Day08$Tree, Day08$Tree);\n Code:\n 0: aload_1\n 1: ldc_w #294 // String it\n 4: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: invokevirtual #218 // Method Day08$Tree.getHeight:()I\n 11: aload_0\n 12: invokevirtual #218 // Method Day08$Tree.getHeight:()I\n 15: if_icmplt 22\n 18: iconst_1\n 19: goto 23\n 22: iconst_0\n 23: ireturn\n\n private static final boolean getScoreVertically$lambda$14(Day08$Tree, Day08$Tree);\n Code:\n 0: aload_1\n 1: ldc_w #294 // String it\n 4: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: invokevirtual #218 // Method Day08$Tree.getHeight:()I\n 11: aload_0\n 12: invokevirtual #218 // Method Day08$Tree.getHeight:()I\n 15: if_icmplt 22\n 18: iconst_1\n 19: goto 23\n 22: iconst_0\n 23: ireturn\n\n private static final boolean getScoreHorizontally$lambda$16(Day08$Tree, Day08$Tree);\n Code:\n 0: aload_1\n 1: ldc_w #294 // String it\n 4: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: invokevirtual #218 // Method Day08$Tree.getHeight:()I\n 11: aload_0\n 12: invokevirtual #218 // Method Day08$Tree.getHeight:()I\n 15: if_icmplt 22\n 18: iconst_1\n 19: goto 23\n 22: iconst_0\n 23: ireturn\n\n private static final boolean getScoreHorizontally$lambda$18(Day08$Tree, Day08$Tree);\n Code:\n 0: aload_1\n 1: ldc_w #294 // String it\n 4: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: invokevirtual #218 // Method Day08$Tree.getHeight:()I\n 11: aload_0\n 12: invokevirtual #218 // Method Day08$Tree.getHeight:()I\n 15: if_icmplt 22\n 18: iconst_1\n 19: goto 23\n 22: iconst_0\n 23: ireturn\n}\n",
"javap_err": ""
}
] |
dliszewski__advent-of-code-2022__76d5eea/src/main/kotlin/Day07.kt
|
class Day07 {
fun part1(input: List<String>): Long {
val hashMapOf = directoriesMap(input)
return hashMapOf.values.filter { it <= 100_000 }.sum()
}
private fun directoriesMap(input: List<String>): MutableMap<String, Long> {
val hashMapOf = mutableMapOf<String, Long>()
var path = ""
for (line in input) {
when (line.getTyp()) {
CommandType.COMMAND_CD_ROOT -> path = ""
CommandType.COMMAND_CD_UP -> {
path = path.substringBeforeLast("/")
}
CommandType.COMMAND_CD -> {
val tempPath = line.substringAfter("$ cd ")
path = "$path/$tempPath"
}
CommandType.COMMAND_DIR -> ""
CommandType.DIR -> ""
CommandType.SIZE -> {
val tempSize = line.substringBefore(" ").toInt()
var tempDir = path
while (true) {
val previous = hashMapOf.getOrDefault(tempDir, 0)
hashMapOf[tempDir] = previous + tempSize
if (tempDir.isEmpty()) break
tempDir = tempDir.substringBeforeLast("/", "")
}
}
}
}
return hashMapOf
}
private enum class CommandType { COMMAND_CD_ROOT, COMMAND_CD, COMMAND_CD_UP, COMMAND_DIR, DIR, SIZE }
private fun String.getTyp(): CommandType {
return when {
this.startsWith("$ cd /") -> CommandType.COMMAND_CD_ROOT
this.startsWith("$ cd ..") -> CommandType.COMMAND_CD_UP
this.startsWith("$ cd ") -> CommandType.COMMAND_CD
this.startsWith("$ ls") -> CommandType.COMMAND_DIR
this.startsWith("dir ") -> CommandType.DIR
else -> CommandType.SIZE
}
}
fun part2(input: List<String>): Long {
val total = 70_000_000
val required = 30_000_000
val directoriesMap = directoriesMap(input)
val used = directoriesMap.getOrDefault("", 0)
val unusedSpace = total - used
val deficit = required - unusedSpace
return directoriesMap.values.filter { it >= deficit }.min()
}
}
|
[
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day07$WhenMappings.class",
"javap": "Compiled from \"Day07.kt\"\npublic final class Day07$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method Day07$CommandType.values:()[LDay07$CommandType;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field Day07$CommandType.COMMAND_CD_ROOT:LDay07$CommandType;\n 12: invokevirtual #22 // Method Day07$CommandType.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 Day07$CommandType.COMMAND_CD_UP:LDay07$CommandType;\n 26: invokevirtual #22 // Method Day07$CommandType.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 Day07$CommandType.COMMAND_CD:LDay07$CommandType;\n 40: invokevirtual #22 // Method Day07$CommandType.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 Day07$CommandType.COMMAND_DIR:LDay07$CommandType;\n 54: invokevirtual #22 // Method Day07$CommandType.ordinal:()I\n 57: iconst_4\n 58: iastore\n 59: goto 63\n 62: astore_1\n 63: nop\n 64: aload_0\n 65: getstatic #34 // Field Day07$CommandType.DIR:LDay07$CommandType;\n 68: invokevirtual #22 // Method Day07$CommandType.ordinal:()I\n 71: iconst_5\n 72: iastore\n 73: goto 77\n 76: astore_1\n 77: nop\n 78: aload_0\n 79: getstatic #37 // Field Day07$CommandType.SIZE:LDay07$CommandType;\n 82: invokevirtual #22 // Method Day07$CommandType.ordinal:()I\n 85: bipush 6\n 87: iastore\n 88: goto 92\n 91: astore_1\n 92: aload_0\n 93: putstatic #41 // Field $EnumSwitchMapping$0:[I\n 96: return\n Exception table:\n from to target type\n 7 17 20 Class java/lang/NoSuchFieldError\n 21 31 34 Class java/lang/NoSuchFieldError\n 35 45 48 Class java/lang/NoSuchFieldError\n 49 59 62 Class java/lang/NoSuchFieldError\n 63 73 76 Class java/lang/NoSuchFieldError\n 77 88 91 Class java/lang/NoSuchFieldError\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day07$CommandType.class",
"javap": "Compiled from \"Day07.kt\"\nfinal class Day07$CommandType extends java.lang.Enum<Day07$CommandType> {\n public static final Day07$CommandType COMMAND_CD_ROOT;\n\n public static final Day07$CommandType COMMAND_CD;\n\n public static final Day07$CommandType COMMAND_CD_UP;\n\n public static final Day07$CommandType COMMAND_DIR;\n\n public static final Day07$CommandType DIR;\n\n public static final Day07$CommandType SIZE;\n\n private static final Day07$CommandType[] $VALUES;\n\n private static final kotlin.enums.EnumEntries $ENTRIES;\n\n private Day07$CommandType();\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: invokespecial #10 // Method java/lang/Enum.\"<init>\":(Ljava/lang/String;I)V\n 6: return\n\n public static Day07$CommandType[] values();\n Code:\n 0: getstatic #22 // Field $VALUES:[LDay07$CommandType;\n 3: invokevirtual #28 // Method java/lang/Object.clone:()Ljava/lang/Object;\n 6: checkcast #29 // class \"[LDay07$CommandType;\"\n 9: areturn\n\n public static Day07$CommandType valueOf(java.lang.String);\n Code:\n 0: ldc #2 // class Day07$CommandType\n 2: aload_0\n 3: invokestatic #34 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;\n 6: checkcast #2 // class Day07$CommandType\n 9: areturn\n\n public static kotlin.enums.EnumEntries<Day07$CommandType> getEntries();\n Code:\n 0: getstatic #43 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 3: areturn\n\n private static final Day07$CommandType[] $values();\n Code:\n 0: bipush 6\n 2: anewarray #2 // class Day07$CommandType\n 5: astore_0\n 6: aload_0\n 7: iconst_0\n 8: getstatic #47 // Field COMMAND_CD_ROOT:LDay07$CommandType;\n 11: aastore\n 12: aload_0\n 13: iconst_1\n 14: getstatic #50 // Field COMMAND_CD:LDay07$CommandType;\n 17: aastore\n 18: aload_0\n 19: iconst_2\n 20: getstatic #53 // Field COMMAND_CD_UP:LDay07$CommandType;\n 23: aastore\n 24: aload_0\n 25: iconst_3\n 26: getstatic #56 // Field COMMAND_DIR:LDay07$CommandType;\n 29: aastore\n 30: aload_0\n 31: iconst_4\n 32: getstatic #59 // Field DIR:LDay07$CommandType;\n 35: aastore\n 36: aload_0\n 37: iconst_5\n 38: getstatic #62 // Field SIZE:LDay07$CommandType;\n 41: aastore\n 42: aload_0\n 43: areturn\n\n static {};\n Code:\n 0: new #2 // class Day07$CommandType\n 3: dup\n 4: ldc #64 // String COMMAND_CD_ROOT\n 6: iconst_0\n 7: invokespecial #65 // Method \"<init>\":(Ljava/lang/String;I)V\n 10: putstatic #47 // Field COMMAND_CD_ROOT:LDay07$CommandType;\n 13: new #2 // class Day07$CommandType\n 16: dup\n 17: ldc #66 // String COMMAND_CD\n 19: iconst_1\n 20: invokespecial #65 // Method \"<init>\":(Ljava/lang/String;I)V\n 23: putstatic #50 // Field COMMAND_CD:LDay07$CommandType;\n 26: new #2 // class Day07$CommandType\n 29: dup\n 30: ldc #67 // String COMMAND_CD_UP\n 32: iconst_2\n 33: invokespecial #65 // Method \"<init>\":(Ljava/lang/String;I)V\n 36: putstatic #53 // Field COMMAND_CD_UP:LDay07$CommandType;\n 39: new #2 // class Day07$CommandType\n 42: dup\n 43: ldc #68 // String COMMAND_DIR\n 45: iconst_3\n 46: invokespecial #65 // Method \"<init>\":(Ljava/lang/String;I)V\n 49: putstatic #56 // Field COMMAND_DIR:LDay07$CommandType;\n 52: new #2 // class Day07$CommandType\n 55: dup\n 56: ldc #69 // String DIR\n 58: iconst_4\n 59: invokespecial #65 // Method \"<init>\":(Ljava/lang/String;I)V\n 62: putstatic #59 // Field DIR:LDay07$CommandType;\n 65: new #2 // class Day07$CommandType\n 68: dup\n 69: ldc #70 // String SIZE\n 71: iconst_5\n 72: invokespecial #65 // Method \"<init>\":(Ljava/lang/String;I)V\n 75: putstatic #62 // Field SIZE:LDay07$CommandType;\n 78: invokestatic #72 // Method $values:()[LDay07$CommandType;\n 81: putstatic #22 // Field $VALUES:[LDay07$CommandType;\n 84: getstatic #22 // Field $VALUES:[LDay07$CommandType;\n 87: checkcast #74 // class \"[Ljava/lang/Enum;\"\n 90: invokestatic #80 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;\n 93: putstatic #43 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 96: return\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day07.class",
"javap": "Compiled from \"Day07.kt\"\npublic final class Day07 {\n public Day07();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final long part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokespecial #26 // Method directoriesMap:(Ljava/util/List;)Ljava/util/Map;\n 11: astore_2\n 12: aload_2\n 13: invokeinterface #32, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 18: checkcast #34 // class java/lang/Iterable\n 21: astore_3\n 22: iconst_0\n 23: istore 4\n 25: aload_3\n 26: astore 5\n 28: new #36 // class java/util/ArrayList\n 31: dup\n 32: invokespecial #37 // Method java/util/ArrayList.\"<init>\":()V\n 35: checkcast #39 // class java/util/Collection\n 38: astore 6\n 40: iconst_0\n 41: istore 7\n 43: aload 5\n 45: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 50: astore 8\n 52: aload 8\n 54: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 114\n 62: aload 8\n 64: invokeinterface #53, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 69: astore 9\n 71: aload 9\n 73: checkcast #55 // class java/lang/Number\n 76: invokevirtual #59 // Method java/lang/Number.longValue:()J\n 79: lstore 10\n 81: iconst_0\n 82: istore 12\n 84: lload 10\n 86: ldc2_w #60 // long 100000l\n 89: lcmp\n 90: ifgt 97\n 93: iconst_1\n 94: goto 98\n 97: iconst_0\n 98: ifeq 52\n 101: aload 6\n 103: aload 9\n 105: invokeinterface #65, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 110: pop\n 111: goto 52\n 114: aload 6\n 116: checkcast #67 // class java/util/List\n 119: nop\n 120: checkcast #34 // class java/lang/Iterable\n 123: invokestatic #73 // Method kotlin/collections/CollectionsKt.sumOfLong:(Ljava/lang/Iterable;)J\n 126: lreturn\n\n private final java.util.Map<java.lang.String, java.lang.Long> directoriesMap(java.util.List<java.lang.String>);\n Code:\n 0: new #92 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #93 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #28 // class java/util/Map\n 10: astore_2\n 11: ldc #95 // String\n 13: astore_3\n 14: aload_1\n 15: invokeinterface #96, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 20: astore 4\n 22: aload 4\n 24: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 29: ifeq 261\n 32: aload 4\n 34: invokeinterface #53, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 39: checkcast #98 // class java/lang/String\n 42: astore 5\n 44: aload_0\n 45: aload 5\n 47: invokespecial #102 // Method getTyp:(Ljava/lang/String;)LDay07$CommandType;\n 50: getstatic #108 // Field Day07$WhenMappings.$EnumSwitchMapping$0:[I\n 53: swap\n 54: invokevirtual #114 // Method Day07$CommandType.ordinal:()I\n 57: iaload\n 58: tableswitch { // 1 to 6\n 1: 96\n 2: 102\n 3: 115\n 4: 155\n 5: 158\n 6: 161\n default: 253\n }\n 96: ldc #95 // String\n 98: astore_3\n 99: goto 22\n 102: aload_3\n 103: ldc #116 // String /\n 105: aconst_null\n 106: iconst_2\n 107: aconst_null\n 108: invokestatic #122 // Method kotlin/text/StringsKt.substringBeforeLast$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 111: astore_3\n 112: goto 22\n 115: aload 5\n 117: ldc #124 // String $ cd\n 119: aconst_null\n 120: iconst_2\n 121: aconst_null\n 122: invokestatic #127 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 125: astore 6\n 127: new #129 // class java/lang/StringBuilder\n 130: dup\n 131: invokespecial #130 // Method java/lang/StringBuilder.\"<init>\":()V\n 134: aload_3\n 135: invokevirtual #134 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 138: bipush 47\n 140: invokevirtual #137 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 143: aload 6\n 145: invokevirtual #134 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 148: invokevirtual #141 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 151: astore_3\n 152: goto 22\n 155: goto 22\n 158: goto 22\n 161: aload 5\n 163: ldc #143 // String\n 165: aconst_null\n 166: iconst_2\n 167: aconst_null\n 168: invokestatic #146 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 171: invokestatic #152 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 174: istore 6\n 176: aload_3\n 177: astore 7\n 179: nop\n 180: aload_2\n 181: aload 7\n 183: lconst_0\n 184: invokestatic #158 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 187: invokeinterface #162, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 192: checkcast #55 // class java/lang/Number\n 195: invokevirtual #59 // Method java/lang/Number.longValue:()J\n 198: lstore 8\n 200: aload_2\n 201: aload 7\n 203: lload 8\n 205: iload 6\n 207: i2l\n 208: ladd\n 209: invokestatic #158 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 212: invokeinterface #165, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 217: pop\n 218: aload 7\n 220: checkcast #167 // class java/lang/CharSequence\n 223: invokeinterface #170, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 228: ifne 235\n 231: iconst_1\n 232: goto 236\n 235: iconst_0\n 236: ifne 22\n 239: aload 7\n 241: ldc #116 // String /\n 243: ldc #95 // String\n 245: invokestatic #174 // Method kotlin/text/StringsKt.substringBeforeLast:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;\n 248: astore 7\n 250: goto 179\n 253: new #176 // class kotlin/NoWhenBranchMatchedException\n 256: dup\n 257: invokespecial #177 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 260: athrow\n 261: aload_2\n 262: areturn\n\n private final Day07$CommandType getTyp(java.lang.String);\n Code:\n 0: nop\n 1: aload_1\n 2: ldc #186 // String $ cd /\n 4: iconst_0\n 5: iconst_2\n 6: aconst_null\n 7: invokestatic #190 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 10: ifeq 19\n 13: getstatic #194 // Field Day07$CommandType.COMMAND_CD_ROOT:LDay07$CommandType;\n 16: goto 94\n 19: aload_1\n 20: ldc #196 // String $ cd ..\n 22: iconst_0\n 23: iconst_2\n 24: aconst_null\n 25: invokestatic #190 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 28: ifeq 37\n 31: getstatic #199 // Field Day07$CommandType.COMMAND_CD_UP:LDay07$CommandType;\n 34: goto 94\n 37: aload_1\n 38: ldc #124 // String $ cd\n 40: iconst_0\n 41: iconst_2\n 42: aconst_null\n 43: invokestatic #190 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 46: ifeq 55\n 49: getstatic #202 // Field Day07$CommandType.COMMAND_CD:LDay07$CommandType;\n 52: goto 94\n 55: aload_1\n 56: ldc #204 // String $ ls\n 58: iconst_0\n 59: iconst_2\n 60: aconst_null\n 61: invokestatic #190 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 64: ifeq 73\n 67: getstatic #207 // Field Day07$CommandType.COMMAND_DIR:LDay07$CommandType;\n 70: goto 94\n 73: aload_1\n 74: ldc #209 // String dir\n 76: iconst_0\n 77: iconst_2\n 78: aconst_null\n 79: invokestatic #190 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 82: ifeq 91\n 85: getstatic #212 // Field Day07$CommandType.DIR:LDay07$CommandType;\n 88: goto 94\n 91: getstatic #215 // Field Day07$CommandType.SIZE:LDay07$CommandType;\n 94: areturn\n\n public final long part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #218 // int 70000000\n 8: istore_2\n 9: ldc #219 // int 30000000\n 11: istore_3\n 12: aload_0\n 13: aload_1\n 14: invokespecial #26 // Method directoriesMap:(Ljava/util/List;)Ljava/util/Map;\n 17: astore 4\n 19: aload 4\n 21: ldc #95 // String\n 23: lconst_0\n 24: invokestatic #158 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 27: invokeinterface #162, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 32: checkcast #55 // class java/lang/Number\n 35: invokevirtual #59 // Method java/lang/Number.longValue:()J\n 38: lstore 5\n 40: iload_2\n 41: i2l\n 42: lload 5\n 44: lsub\n 45: lstore 7\n 47: iload_3\n 48: i2l\n 49: lload 7\n 51: lsub\n 52: lstore 9\n 54: aload 4\n 56: invokeinterface #32, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 61: checkcast #34 // class java/lang/Iterable\n 64: astore 11\n 66: iconst_0\n 67: istore 12\n 69: aload 11\n 71: astore 13\n 73: new #36 // class java/util/ArrayList\n 76: dup\n 77: invokespecial #37 // Method java/util/ArrayList.\"<init>\":()V\n 80: checkcast #39 // class java/util/Collection\n 83: astore 14\n 85: iconst_0\n 86: istore 15\n 88: aload 13\n 90: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 95: astore 16\n 97: aload 16\n 99: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 104: ifeq 158\n 107: aload 16\n 109: invokeinterface #53, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 114: astore 17\n 116: aload 17\n 118: checkcast #55 // class java/lang/Number\n 121: invokevirtual #59 // Method java/lang/Number.longValue:()J\n 124: lstore 18\n 126: iconst_0\n 127: istore 20\n 129: lload 18\n 131: lload 9\n 133: lcmp\n 134: iflt 141\n 137: iconst_1\n 138: goto 142\n 141: iconst_0\n 142: ifeq 97\n 145: aload 14\n 147: aload 17\n 149: invokeinterface #65, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 154: pop\n 155: goto 97\n 158: aload 14\n 160: checkcast #67 // class java/util/List\n 163: nop\n 164: checkcast #34 // class java/lang/Iterable\n 167: invokestatic #223 // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 170: checkcast #55 // class java/lang/Number\n 173: invokevirtual #59 // Method java/lang/Number.longValue:()J\n 176: lreturn\n}\n",
"javap_err": ""
}
] |
dliszewski__advent-of-code-2022__76d5eea/src/main/kotlin/Day11.kt
|
class Day11 {
fun part1(input: String): Long {
val monkeys = input.split("\n\n").map { it.toMonkey() }.toTypedArray()
val rounds = 20
val stressReducerFormula: (Long) -> Long = { it / 3 }
repeat(rounds) { round ->
monkeys.forEach {
it.handleItems(stressReducerFormula).forEach {
(item, monkey) -> monkeys[monkey].passItem(item)
}
}
}
return monkeys.map { it.handledItemsCount }.sortedDescending().take(2).reduce { acc, i -> acc * i }
}
fun part2(input: String): Long {
val monkeys = input.split("\n\n").map { it.toMonkey() }.toTypedArray()
val rounds = 10000
val lcm = monkeys.map { it.divisor.toLong() }.reduce(Long::times)
val stressReducerFormula: (Long) -> Long = { it % lcm }
repeat(rounds) {
monkeys.forEach {
it.handleItems(stressReducerFormula).forEach { (itemToPass, monkeyNumber) ->
monkeys[monkeyNumber].passItem(itemToPass)
}
}
}
val map = monkeys.map { it.handledItemsCount }
return map.sortedDescending().take(2).reduce { acc, i -> acc * i }
}
data class Monkey(
private val items: MutableList<Long>,
private val newStressLevelFormula: (Long) -> Long,
val divisor: Int,
private val passToOnSuccess: Int,
private val passToOnFailure: Int,
var handledItemsCount: Long = 0L
) {
fun handleItems(stressReducerFormula: (Long) -> Long): List<Pair<Long, Int>> {
val handledItems = items.map {
handledItemsCount++
handleItem(it, stressReducerFormula)
}
items.clear()
return handledItems
}
private fun handleItem(item: Long, stressReducerFormula: (Long) -> Long): Pair<Long, Int> {
val newStressLevel = newStressLevelFormula(item)
val levelAfterBoredMonkey = stressReducerFormula(newStressLevel)
return levelAfterBoredMonkey to if (levelAfterBoredMonkey % divisor == 0L) passToOnSuccess else passToOnFailure
}
fun passItem(item: Long) {
items.add(item)
}
}
private fun String.toMonkey(): Monkey {
val lines = split("\n")
val monkeyNumber = lines[0].toMonkeyNumber()
val items = lines[1].toItems()
val operation = lines[2].mapToOperation()
val divisor = lines[3].toDivisor()
val passToOnSuccess = lines[4].toSuccessMonkey()
val passToOnFailure = lines[5].toFailureMonkey()
return Monkey(items, operation, divisor, passToOnSuccess, passToOnFailure)
}
private fun String.toMonkeyNumber() = substringAfter("Monkey ").dropLast(1).toInt()
private fun String.toItems() = trim()
.substringAfter("Starting items: ")
.split(", ")
.map { it.toLong() }
.toMutableList()
private fun String.toDivisor() = trim().substringAfter("Test: divisible by ").toInt()
private fun String.toSuccessMonkey() = trim().substringAfter("If true: throw to monkey ").toInt()
private fun String.toFailureMonkey() = trim().substringAfter("If false: throw to monkey ").toInt()
private fun String.mapToOperation(): (Long) -> Long {
val (sign, value) = trim().substringAfter("Operation: new = old ").split(" ")
return when (sign) {
"*" -> { old -> old * if (value == "old") old else value.toLong() }
"+" -> { old -> old + if (value == "old") old else value.toLong() }
else -> error("wrong operation $this")
}
}
}
|
[
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day11.class",
"javap": "Compiled from \"Day11.kt\"\npublic final class Day11 {\n public Day11();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final long part1(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String input\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #23 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #25 // class java/lang/String\n 14: astore_3\n 15: aload_3\n 16: iconst_0\n 17: ldc #27 // String \\n\\n\n 19: aastore\n 20: aload_3\n 21: iconst_0\n 22: iconst_0\n 23: bipush 6\n 25: aconst_null\n 26: invokestatic #33 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: checkcast #35 // class java/lang/Iterable\n 32: astore_3\n 33: iconst_0\n 34: istore 4\n 36: aload_3\n 37: astore 5\n 39: new #37 // class java/util/ArrayList\n 42: dup\n 43: aload_3\n 44: bipush 10\n 46: invokestatic #43 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 49: invokespecial #46 // Method java/util/ArrayList.\"<init>\":(I)V\n 52: checkcast #48 // class java/util/Collection\n 55: astore 6\n 57: iconst_0\n 58: istore 7\n 60: aload 5\n 62: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 67: astore 8\n 69: aload 8\n 71: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 76: ifeq 120\n 79: aload 8\n 81: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 86: astore 9\n 88: aload 6\n 90: aload 9\n 92: checkcast #25 // class java/lang/String\n 95: astore 10\n 97: astore 24\n 99: iconst_0\n 100: istore 11\n 102: aload_0\n 103: aload 10\n 105: invokespecial #66 // Method toMonkey:(Ljava/lang/String;)LDay11$Monkey;\n 108: aload 24\n 110: swap\n 111: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 116: pop\n 117: goto 69\n 120: aload 6\n 122: checkcast #72 // class java/util/List\n 125: nop\n 126: checkcast #48 // class java/util/Collection\n 129: astore_3\n 130: nop\n 131: iconst_0\n 132: istore 4\n 134: aload_3\n 135: astore 5\n 137: aload 5\n 139: iconst_0\n 140: anewarray #74 // class Day11$Monkey\n 143: invokeinterface #78, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 148: checkcast #80 // class \"[LDay11$Monkey;\"\n 151: astore_2\n 152: bipush 20\n 154: istore_3\n 155: invokedynamic #100, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 160: astore 4\n 162: iconst_0\n 163: istore 5\n 165: iload 5\n 167: iload_3\n 168: if_icmpge 323\n 171: iload 5\n 173: istore 6\n 175: iconst_0\n 176: istore 7\n 178: aload_2\n 179: astore 8\n 181: iconst_0\n 182: istore 9\n 184: iconst_0\n 185: istore 10\n 187: aload 8\n 189: arraylength\n 190: istore 11\n 192: iload 10\n 194: iload 11\n 196: if_icmpge 315\n 199: aload 8\n 201: iload 10\n 203: aaload\n 204: astore 12\n 206: aload 12\n 208: astore 13\n 210: iconst_0\n 211: istore 14\n 213: aload 13\n 215: aload 4\n 217: invokevirtual #104 // Method Day11$Monkey.handleItems:(Lkotlin/jvm/functions/Function1;)Ljava/util/List;\n 220: checkcast #35 // class java/lang/Iterable\n 223: astore 15\n 225: iconst_0\n 226: istore 16\n 228: aload 15\n 230: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 235: astore 17\n 237: aload 17\n 239: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 244: ifeq 306\n 247: aload 17\n 249: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 254: astore 18\n 256: aload 18\n 258: checkcast #106 // class kotlin/Pair\n 261: astore 19\n 263: iconst_0\n 264: istore 20\n 266: aload 19\n 268: invokevirtual #109 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 271: checkcast #111 // class java/lang/Number\n 274: invokevirtual #115 // Method java/lang/Number.longValue:()J\n 277: lstore 21\n 279: aload 19\n 281: invokevirtual #118 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 284: checkcast #111 // class java/lang/Number\n 287: invokevirtual #122 // Method java/lang/Number.intValue:()I\n 290: istore 23\n 292: aload_2\n 293: iload 23\n 295: aaload\n 296: lload 21\n 298: invokevirtual #126 // Method Day11$Monkey.passItem:(J)V\n 301: nop\n 302: nop\n 303: goto 237\n 306: nop\n 307: nop\n 308: nop\n 309: iinc 10, 1\n 312: goto 192\n 315: nop\n 316: nop\n 317: iinc 5, 1\n 320: goto 165\n 323: aload_2\n 324: astore 5\n 326: iconst_0\n 327: istore 6\n 329: aload 5\n 331: astore 7\n 333: new #37 // class java/util/ArrayList\n 336: dup\n 337: aload 5\n 339: arraylength\n 340: invokespecial #46 // Method java/util/ArrayList.\"<init>\":(I)V\n 343: checkcast #48 // class java/util/Collection\n 346: astore 8\n 348: iconst_0\n 349: istore 9\n 351: iconst_0\n 352: istore 10\n 354: aload 7\n 356: arraylength\n 357: istore 11\n 359: iload 10\n 361: iload 11\n 363: if_icmpge 407\n 366: aload 7\n 368: iload 10\n 370: aaload\n 371: astore 12\n 373: aload 8\n 375: aload 12\n 377: astore 13\n 379: astore 24\n 381: iconst_0\n 382: istore 14\n 384: aload 13\n 386: invokevirtual #129 // Method Day11$Monkey.getHandledItemsCount:()J\n 389: invokestatic #135 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 392: aload 24\n 394: swap\n 395: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 400: pop\n 401: iinc 10, 1\n 404: goto 359\n 407: aload 8\n 409: checkcast #72 // class java/util/List\n 412: nop\n 413: checkcast #35 // class java/lang/Iterable\n 416: invokestatic #139 // Method kotlin/collections/CollectionsKt.sortedDescending:(Ljava/lang/Iterable;)Ljava/util/List;\n 419: checkcast #35 // class java/lang/Iterable\n 422: iconst_2\n 423: invokestatic #143 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 426: checkcast #35 // class java/lang/Iterable\n 429: astore 5\n 431: iconst_0\n 432: istore 6\n 434: aload 5\n 436: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 441: astore 7\n 443: aload 7\n 445: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 450: ifne 463\n 453: new #145 // class java/lang/UnsupportedOperationException\n 456: dup\n 457: ldc #147 // String Empty collection can\\'t be reduced.\n 459: invokespecial #150 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 462: athrow\n 463: aload 7\n 465: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 470: astore 8\n 472: aload 7\n 474: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 479: ifeq 523\n 482: aload 8\n 484: aload 7\n 486: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 491: checkcast #111 // class java/lang/Number\n 494: invokevirtual #115 // Method java/lang/Number.longValue:()J\n 497: lstore 9\n 499: checkcast #111 // class java/lang/Number\n 502: invokevirtual #115 // Method java/lang/Number.longValue:()J\n 505: lstore 11\n 507: iconst_0\n 508: istore 13\n 510: lload 11\n 512: lload 9\n 514: lmul\n 515: invokestatic #135 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 518: astore 8\n 520: goto 472\n 523: aload 8\n 525: checkcast #111 // class java/lang/Number\n 528: invokevirtual #115 // Method java/lang/Number.longValue:()J\n 531: lreturn\n\n public final long part2(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String input\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #23 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #25 // class java/lang/String\n 14: astore_3\n 15: aload_3\n 16: iconst_0\n 17: ldc #27 // String \\n\\n\n 19: aastore\n 20: aload_3\n 21: iconst_0\n 22: iconst_0\n 23: bipush 6\n 25: aconst_null\n 26: invokestatic #33 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: checkcast #35 // class java/lang/Iterable\n 32: astore_3\n 33: iconst_0\n 34: istore 4\n 36: aload_3\n 37: astore 5\n 39: new #37 // class java/util/ArrayList\n 42: dup\n 43: aload_3\n 44: bipush 10\n 46: invokestatic #43 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 49: invokespecial #46 // Method java/util/ArrayList.\"<init>\":(I)V\n 52: checkcast #48 // class java/util/Collection\n 55: astore 6\n 57: iconst_0\n 58: istore 7\n 60: aload 5\n 62: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 67: astore 8\n 69: aload 8\n 71: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 76: ifeq 120\n 79: aload 8\n 81: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 86: astore 9\n 88: aload 6\n 90: aload 9\n 92: checkcast #25 // class java/lang/String\n 95: astore 10\n 97: astore 26\n 99: iconst_0\n 100: istore 11\n 102: aload_0\n 103: aload 10\n 105: invokespecial #66 // Method toMonkey:(Ljava/lang/String;)LDay11$Monkey;\n 108: aload 26\n 110: swap\n 111: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 116: pop\n 117: goto 69\n 120: aload 6\n 122: checkcast #72 // class java/util/List\n 125: nop\n 126: checkcast #48 // class java/util/Collection\n 129: astore_3\n 130: nop\n 131: iconst_0\n 132: istore 4\n 134: aload_3\n 135: astore 5\n 137: aload 5\n 139: iconst_0\n 140: anewarray #74 // class Day11$Monkey\n 143: invokeinterface #78, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 148: checkcast #80 // class \"[LDay11$Monkey;\"\n 151: astore_2\n 152: sipush 10000\n 155: istore_3\n 156: aload_2\n 157: astore 6\n 159: iconst_0\n 160: istore 7\n 162: aload 6\n 164: astore 8\n 166: new #37 // class java/util/ArrayList\n 169: dup\n 170: aload 6\n 172: arraylength\n 173: invokespecial #46 // Method java/util/ArrayList.\"<init>\":(I)V\n 176: checkcast #48 // class java/util/Collection\n 179: astore 9\n 181: iconst_0\n 182: istore 10\n 184: iconst_0\n 185: istore 11\n 187: aload 8\n 189: arraylength\n 190: istore 12\n 192: iload 11\n 194: iload 12\n 196: if_icmpge 241\n 199: aload 8\n 201: iload 11\n 203: aaload\n 204: astore 13\n 206: aload 9\n 208: aload 13\n 210: astore 14\n 212: astore 26\n 214: iconst_0\n 215: istore 15\n 217: aload 14\n 219: invokevirtual #197 // Method Day11$Monkey.getDivisor:()I\n 222: i2l\n 223: invokestatic #135 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 226: aload 26\n 228: swap\n 229: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 234: pop\n 235: iinc 11, 1\n 238: goto 192\n 241: aload 9\n 243: checkcast #72 // class java/util/List\n 246: nop\n 247: checkcast #35 // class java/lang/Iterable\n 250: astore 6\n 252: nop\n 253: iconst_0\n 254: istore 7\n 256: aload 6\n 258: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 263: astore 8\n 265: aload 8\n 267: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 272: ifne 285\n 275: new #145 // class java/lang/UnsupportedOperationException\n 278: dup\n 279: ldc #147 // String Empty collection can\\'t be reduced.\n 281: invokespecial #150 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 284: athrow\n 285: aload 8\n 287: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 292: astore 9\n 294: aload 8\n 296: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 301: ifeq 345\n 304: aload 9\n 306: aload 8\n 308: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 313: checkcast #111 // class java/lang/Number\n 316: invokevirtual #115 // Method java/lang/Number.longValue:()J\n 319: lstore 10\n 321: checkcast #111 // class java/lang/Number\n 324: invokevirtual #115 // Method java/lang/Number.longValue:()J\n 327: lstore 12\n 329: iconst_0\n 330: istore 14\n 332: lload 12\n 334: lload 10\n 336: lmul\n 337: invokestatic #135 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 340: astore 9\n 342: goto 294\n 345: aload 9\n 347: checkcast #111 // class java/lang/Number\n 350: invokevirtual #115 // Method java/lang/Number.longValue:()J\n 353: lstore 4\n 355: lload 4\n 357: invokedynamic #205, 0 // InvokeDynamic #1:invoke:(J)Lkotlin/jvm/functions/Function1;\n 362: astore 6\n 364: iconst_0\n 365: istore 7\n 367: iload 7\n 369: iload_3\n 370: if_icmpge 525\n 373: iload 7\n 375: istore 8\n 377: iconst_0\n 378: istore 9\n 380: aload_2\n 381: astore 10\n 383: iconst_0\n 384: istore 11\n 386: iconst_0\n 387: istore 12\n 389: aload 10\n 391: arraylength\n 392: istore 13\n 394: iload 12\n 396: iload 13\n 398: if_icmpge 517\n 401: aload 10\n 403: iload 12\n 405: aaload\n 406: astore 14\n 408: aload 14\n 410: astore 15\n 412: iconst_0\n 413: istore 16\n 415: aload 15\n 417: aload 6\n 419: invokevirtual #104 // Method Day11$Monkey.handleItems:(Lkotlin/jvm/functions/Function1;)Ljava/util/List;\n 422: checkcast #35 // class java/lang/Iterable\n 425: astore 17\n 427: iconst_0\n 428: istore 18\n 430: aload 17\n 432: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 437: astore 19\n 439: aload 19\n 441: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 446: ifeq 508\n 449: aload 19\n 451: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 456: astore 20\n 458: aload 20\n 460: checkcast #106 // class kotlin/Pair\n 463: astore 21\n 465: iconst_0\n 466: istore 22\n 468: aload 21\n 470: invokevirtual #109 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 473: checkcast #111 // class java/lang/Number\n 476: invokevirtual #115 // Method java/lang/Number.longValue:()J\n 479: lstore 23\n 481: aload 21\n 483: invokevirtual #118 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 486: checkcast #111 // class java/lang/Number\n 489: invokevirtual #122 // Method java/lang/Number.intValue:()I\n 492: istore 25\n 494: aload_2\n 495: iload 25\n 497: aaload\n 498: lload 23\n 500: invokevirtual #126 // Method Day11$Monkey.passItem:(J)V\n 503: nop\n 504: nop\n 505: goto 439\n 508: nop\n 509: nop\n 510: nop\n 511: iinc 12, 1\n 514: goto 394\n 517: nop\n 518: nop\n 519: iinc 7, 1\n 522: goto 367\n 525: aload_2\n 526: astore 8\n 528: iconst_0\n 529: istore 9\n 531: aload 8\n 533: astore 10\n 535: new #37 // class java/util/ArrayList\n 538: dup\n 539: aload 8\n 541: arraylength\n 542: invokespecial #46 // Method java/util/ArrayList.\"<init>\":(I)V\n 545: checkcast #48 // class java/util/Collection\n 548: astore 11\n 550: iconst_0\n 551: istore 12\n 553: iconst_0\n 554: istore 13\n 556: aload 10\n 558: arraylength\n 559: istore 14\n 561: iload 13\n 563: iload 14\n 565: if_icmpge 609\n 568: aload 10\n 570: iload 13\n 572: aaload\n 573: astore 15\n 575: aload 11\n 577: aload 15\n 579: astore 16\n 581: astore 26\n 583: iconst_0\n 584: istore 17\n 586: aload 16\n 588: invokevirtual #129 // Method Day11$Monkey.getHandledItemsCount:()J\n 591: invokestatic #135 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 594: aload 26\n 596: swap\n 597: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 602: pop\n 603: iinc 13, 1\n 606: goto 561\n 609: aload 11\n 611: checkcast #72 // class java/util/List\n 614: nop\n 615: astore 7\n 617: aload 7\n 619: checkcast #35 // class java/lang/Iterable\n 622: invokestatic #139 // Method kotlin/collections/CollectionsKt.sortedDescending:(Ljava/lang/Iterable;)Ljava/util/List;\n 625: checkcast #35 // class java/lang/Iterable\n 628: iconst_2\n 629: invokestatic #143 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 632: checkcast #35 // class java/lang/Iterable\n 635: astore 8\n 637: iconst_0\n 638: istore 9\n 640: aload 8\n 642: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 647: astore 10\n 649: aload 10\n 651: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 656: ifne 669\n 659: new #145 // class java/lang/UnsupportedOperationException\n 662: dup\n 663: ldc #147 // String Empty collection can\\'t be reduced.\n 665: invokespecial #150 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 668: athrow\n 669: aload 10\n 671: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 676: astore 11\n 678: aload 10\n 680: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 685: ifeq 729\n 688: aload 11\n 690: aload 10\n 692: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 697: checkcast #111 // class java/lang/Number\n 700: invokevirtual #115 // Method java/lang/Number.longValue:()J\n 703: lstore 12\n 705: checkcast #111 // class java/lang/Number\n 708: invokevirtual #115 // Method java/lang/Number.longValue:()J\n 711: lstore 14\n 713: iconst_0\n 714: istore 16\n 716: lload 14\n 718: lload 12\n 720: lmul\n 721: invokestatic #135 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 724: astore 11\n 726: goto 678\n 729: aload 11\n 731: checkcast #111 // class java/lang/Number\n 734: invokevirtual #115 // Method java/lang/Number.longValue:()J\n 737: lreturn\n\n private final Day11$Monkey toMonkey(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #23 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #25 // class java/lang/String\n 8: astore_3\n 9: aload_3\n 10: iconst_0\n 11: ldc #222 // String \\n\n 13: aastore\n 14: aload_3\n 15: iconst_0\n 16: iconst_0\n 17: bipush 6\n 19: aconst_null\n 20: invokestatic #33 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 23: astore_2\n 24: aload_0\n 25: aload_2\n 26: iconst_0\n 27: invokeinterface #226, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 32: checkcast #25 // class java/lang/String\n 35: invokespecial #230 // Method toMonkeyNumber:(Ljava/lang/String;)I\n 38: istore_3\n 39: aload_0\n 40: aload_2\n 41: iconst_1\n 42: invokeinterface #226, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 47: checkcast #25 // class java/lang/String\n 50: invokespecial #234 // Method toItems:(Ljava/lang/String;)Ljava/util/List;\n 53: astore 4\n 55: aload_0\n 56: aload_2\n 57: iconst_2\n 58: invokeinterface #226, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 63: checkcast #25 // class java/lang/String\n 66: invokespecial #238 // Method mapToOperation:(Ljava/lang/String;)Lkotlin/jvm/functions/Function1;\n 69: astore 5\n 71: aload_0\n 72: aload_2\n 73: iconst_3\n 74: invokeinterface #226, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 79: checkcast #25 // class java/lang/String\n 82: invokespecial #241 // Method toDivisor:(Ljava/lang/String;)I\n 85: istore 6\n 87: aload_0\n 88: aload_2\n 89: iconst_4\n 90: invokeinterface #226, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 95: checkcast #25 // class java/lang/String\n 98: invokespecial #244 // Method toSuccessMonkey:(Ljava/lang/String;)I\n 101: istore 7\n 103: aload_0\n 104: aload_2\n 105: iconst_5\n 106: invokeinterface #226, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 111: checkcast #25 // class java/lang/String\n 114: invokespecial #247 // Method toFailureMonkey:(Ljava/lang/String;)I\n 117: istore 8\n 119: new #74 // class Day11$Monkey\n 122: dup\n 123: aload 4\n 125: aload 5\n 127: iload 6\n 129: iload 7\n 131: iload 8\n 133: lconst_0\n 134: bipush 32\n 136: aconst_null\n 137: invokespecial #250 // Method Day11$Monkey.\"<init>\":(Ljava/util/List;Lkotlin/jvm/functions/Function1;IIIJILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 140: areturn\n\n private final int toMonkeyNumber(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc_w #259 // String Monkey\n 4: aconst_null\n 5: iconst_2\n 6: aconst_null\n 7: invokestatic #263 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 10: iconst_1\n 11: invokestatic #267 // Method kotlin/text/StringsKt.dropLast:(Ljava/lang/String;I)Ljava/lang/String;\n 14: invokestatic #272 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 17: ireturn\n\n private final java.util.List<java.lang.Long> toItems(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #23 // class java/lang/CharSequence\n 4: invokestatic #278 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 7: invokevirtual #282 // Method java/lang/Object.toString:()Ljava/lang/String;\n 10: ldc_w #284 // String Starting items:\n 13: aconst_null\n 14: iconst_2\n 15: aconst_null\n 16: invokestatic #263 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 19: checkcast #23 // class java/lang/CharSequence\n 22: iconst_1\n 23: anewarray #25 // class java/lang/String\n 26: astore_2\n 27: aload_2\n 28: iconst_0\n 29: ldc_w #286 // String ,\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 #33 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 42: checkcast #35 // class java/lang/Iterable\n 45: astore_2\n 46: nop\n 47: iconst_0\n 48: istore_3\n 49: aload_2\n 50: astore 4\n 52: new #37 // class java/util/ArrayList\n 55: dup\n 56: aload_2\n 57: bipush 10\n 59: invokestatic #43 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 62: invokespecial #46 // Method java/util/ArrayList.\"<init>\":(I)V\n 65: checkcast #48 // class java/util/Collection\n 68: astore 5\n 70: iconst_0\n 71: istore 6\n 73: aload 4\n 75: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 80: astore 7\n 82: aload 7\n 84: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 89: ifeq 136\n 92: aload 7\n 94: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 99: astore 8\n 101: aload 5\n 103: aload 8\n 105: checkcast #25 // class java/lang/String\n 108: astore 9\n 110: astore 11\n 112: iconst_0\n 113: istore 10\n 115: aload 9\n 117: invokestatic #289 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 120: nop\n 121: invokestatic #135 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 124: aload 11\n 126: swap\n 127: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 132: pop\n 133: goto 82\n 136: aload 5\n 138: checkcast #72 // class java/util/List\n 141: nop\n 142: checkcast #48 // class java/util/Collection\n 145: invokestatic #293 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 148: areturn\n\n private final int toDivisor(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #23 // class java/lang/CharSequence\n 4: invokestatic #278 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 7: invokevirtual #282 // Method java/lang/Object.toString:()Ljava/lang/String;\n 10: ldc_w #297 // String Test: divisible by\n 13: aconst_null\n 14: iconst_2\n 15: aconst_null\n 16: invokestatic #263 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 19: invokestatic #272 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 22: ireturn\n\n private final int toSuccessMonkey(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #23 // class java/lang/CharSequence\n 4: invokestatic #278 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 7: invokevirtual #282 // Method java/lang/Object.toString:()Ljava/lang/String;\n 10: ldc_w #300 // String If true: throw to monkey\n 13: aconst_null\n 14: iconst_2\n 15: aconst_null\n 16: invokestatic #263 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 19: invokestatic #272 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 22: ireturn\n\n private final int toFailureMonkey(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #23 // class java/lang/CharSequence\n 4: invokestatic #278 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 7: invokevirtual #282 // Method java/lang/Object.toString:()Ljava/lang/String;\n 10: ldc_w #303 // String If false: throw to monkey\n 13: aconst_null\n 14: iconst_2\n 15: aconst_null\n 16: invokestatic #263 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 19: invokestatic #272 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 22: ireturn\n\n private final kotlin.jvm.functions.Function1<java.lang.Long, java.lang.Long> mapToOperation(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #23 // class java/lang/CharSequence\n 4: invokestatic #278 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 7: invokevirtual #282 // Method java/lang/Object.toString:()Ljava/lang/String;\n 10: ldc_w #307 // String Operation: new = old\n 13: aconst_null\n 14: iconst_2\n 15: aconst_null\n 16: invokestatic #263 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 19: checkcast #23 // class java/lang/CharSequence\n 22: iconst_1\n 23: anewarray #25 // class java/lang/String\n 26: astore_3\n 27: aload_3\n 28: iconst_0\n 29: ldc_w #309 // String\n 32: aastore\n 33: aload_3\n 34: iconst_0\n 35: iconst_0\n 36: bipush 6\n 38: aconst_null\n 39: invokestatic #33 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 42: astore_2\n 43: aload_2\n 44: iconst_0\n 45: invokeinterface #226, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 50: checkcast #25 // class java/lang/String\n 53: astore_3\n 54: aload_2\n 55: iconst_1\n 56: invokeinterface #226, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 61: checkcast #25 // class java/lang/String\n 64: astore 4\n 66: aload_3\n 67: astore 5\n 69: aload 5\n 71: ldc_w #311 // String *\n 74: invokestatic #315 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 77: ifeq 90\n 80: aload 4\n 82: invokedynamic #322, 0 // InvokeDynamic #2:invoke:(Ljava/lang/String;)Lkotlin/jvm/functions/Function1;\n 87: goto 142\n 90: aload 5\n 92: ldc_w #324 // String +\n 95: invokestatic #315 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 98: ifeq 111\n 101: aload 4\n 103: invokedynamic #329, 0 // InvokeDynamic #3:invoke:(Ljava/lang/String;)Lkotlin/jvm/functions/Function1;\n 108: goto 142\n 111: new #331 // class java/lang/IllegalStateException\n 114: dup\n 115: new #333 // class java/lang/StringBuilder\n 118: dup\n 119: invokespecial #334 // Method java/lang/StringBuilder.\"<init>\":()V\n 122: ldc_w #336 // String wrong operation\n 125: invokevirtual #340 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 128: aload_1\n 129: invokevirtual #340 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 132: invokevirtual #341 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 135: invokevirtual #282 // Method java/lang/Object.toString:()Ljava/lang/String;\n 138: invokespecial #342 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 141: athrow\n 142: areturn\n\n private static final long part1$lambda$1(long);\n Code:\n 0: lload_0\n 1: iconst_3\n 2: i2l\n 3: ldiv\n 4: lreturn\n\n private static final long part2$lambda$9(long, long);\n Code:\n 0: lload_2\n 1: lload_0\n 2: lrem\n 3: lreturn\n\n private static final long mapToOperation$lambda$16(java.lang.String, long);\n Code:\n 0: lload_1\n 1: aload_0\n 2: ldc_w #348 // String old\n 5: invokestatic #315 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 8: ifeq 15\n 11: lload_1\n 12: goto 19\n 15: aload_0\n 16: invokestatic #289 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 19: lmul\n 20: lreturn\n\n private static final long mapToOperation$lambda$17(java.lang.String, long);\n Code:\n 0: lload_1\n 1: aload_0\n 2: ldc_w #348 // String old\n 5: invokestatic #315 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 8: ifeq 15\n 11: lload_1\n 12: goto 19\n 15: aload_0\n 16: invokestatic #289 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 19: ladd\n 20: lreturn\n}\n",
"javap_err": ""
},
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day11$Monkey.class",
"javap": "Compiled from \"Day11.kt\"\npublic final class Day11$Monkey {\n private final java.util.List<java.lang.Long> items;\n\n private final kotlin.jvm.functions.Function1<java.lang.Long, java.lang.Long> newStressLevelFormula;\n\n private final int divisor;\n\n private final int passToOnSuccess;\n\n private final int passToOnFailure;\n\n private long handledItemsCount;\n\n public Day11$Monkey(java.util.List<java.lang.Long>, kotlin.jvm.functions.Function1<? super java.lang.Long, java.lang.Long>, int, int, int, long);\n Code:\n 0: aload_1\n 1: ldc #10 // String items\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #18 // String newStressLevelFormula\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 items:Ljava/util/List;\n 21: aload_0\n 22: aload_2\n 23: putfield #27 // Field newStressLevelFormula:Lkotlin/jvm/functions/Function1;\n 26: aload_0\n 27: iload_3\n 28: putfield #31 // Field divisor:I\n 31: aload_0\n 32: iload 4\n 34: putfield #34 // Field passToOnSuccess:I\n 37: aload_0\n 38: iload 5\n 40: putfield #37 // Field passToOnFailure:I\n 43: aload_0\n 44: lload 6\n 46: putfield #41 // Field handledItemsCount:J\n 49: return\n\n public Day11$Monkey(java.util.List, kotlin.jvm.functions.Function1, int, int, int, long, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload 8\n 2: bipush 32\n 4: iand\n 5: ifeq 11\n 8: lconst_0\n 9: lstore 6\n 11: aload_0\n 12: aload_1\n 13: aload_2\n 14: iload_3\n 15: iload 4\n 17: iload 5\n 19: lload 6\n 21: invokespecial #46 // Method \"<init>\":(Ljava/util/List;Lkotlin/jvm/functions/Function1;IIIJ)V\n 24: return\n\n public final int getDivisor();\n Code:\n 0: aload_0\n 1: getfield #31 // Field divisor:I\n 4: ireturn\n\n public final long getHandledItemsCount();\n Code:\n 0: aload_0\n 1: getfield #41 // Field handledItemsCount:J\n 4: lreturn\n\n public final void setHandledItemsCount(long);\n Code:\n 0: aload_0\n 1: lload_1\n 2: putfield #41 // Field handledItemsCount:J\n 5: return\n\n public final java.util.List<kotlin.Pair<java.lang.Long, java.lang.Integer>> handleItems(kotlin.jvm.functions.Function1<? super java.lang.Long, java.lang.Long>);\n Code:\n 0: aload_1\n 1: ldc #58 // String stressReducerFormula\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getfield #24 // Field items:Ljava/util/List;\n 10: checkcast #60 // class java/lang/Iterable\n 13: astore_3\n 14: iconst_0\n 15: istore 4\n 17: aload_3\n 18: astore 5\n 20: new #62 // class java/util/ArrayList\n 23: dup\n 24: aload_3\n 25: bipush 10\n 27: invokestatic #68 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 30: invokespecial #71 // Method java/util/ArrayList.\"<init>\":(I)V\n 33: checkcast #73 // class java/util/Collection\n 36: astore 6\n 38: iconst_0\n 39: istore 7\n 41: aload 5\n 43: invokeinterface #77, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 48: astore 8\n 50: aload 8\n 52: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 57: ifeq 119\n 60: aload 8\n 62: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 67: astore 9\n 69: aload 6\n 71: aload 9\n 73: checkcast #89 // class java/lang/Number\n 76: invokevirtual #92 // Method java/lang/Number.longValue:()J\n 79: lstore 10\n 81: astore 15\n 83: iconst_0\n 84: istore 12\n 86: aload_0\n 87: getfield #41 // Field handledItemsCount:J\n 90: lstore 13\n 92: aload_0\n 93: lload 13\n 95: lconst_1\n 96: ladd\n 97: putfield #41 // Field handledItemsCount:J\n 100: aload_0\n 101: lload 10\n 103: aload_1\n 104: invokespecial #96 // Method handleItem:(JLkotlin/jvm/functions/Function1;)Lkotlin/Pair;\n 107: aload 15\n 109: swap\n 110: invokeinterface #100, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 115: pop\n 116: goto 50\n 119: aload 6\n 121: checkcast #102 // class java/util/List\n 124: nop\n 125: astore_2\n 126: aload_0\n 127: getfield #24 // Field items:Ljava/util/List;\n 130: invokeinterface #105, 1 // InterfaceMethod java/util/List.clear:()V\n 135: aload_2\n 136: areturn\n\n private final kotlin.Pair<java.lang.Long, java.lang.Integer> handleItem(long, kotlin.jvm.functions.Function1<? super java.lang.Long, java.lang.Long>);\n Code:\n 0: aload_0\n 1: getfield #27 // Field newStressLevelFormula:Lkotlin/jvm/functions/Function1;\n 4: lload_1\n 5: invokestatic #126 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 8: invokeinterface #130, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 13: checkcast #89 // class java/lang/Number\n 16: invokevirtual #92 // Method java/lang/Number.longValue:()J\n 19: lstore 4\n 21: aload_3\n 22: lload 4\n 24: invokestatic #126 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 27: invokeinterface #130, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 32: checkcast #89 // class java/lang/Number\n 35: invokevirtual #92 // Method java/lang/Number.longValue:()J\n 38: lstore 6\n 40: lload 6\n 42: invokestatic #126 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 45: lload 6\n 47: aload_0\n 48: getfield #31 // Field divisor:I\n 51: i2l\n 52: lrem\n 53: lconst_0\n 54: lcmp\n 55: ifne 65\n 58: aload_0\n 59: getfield #34 // Field passToOnSuccess:I\n 62: goto 69\n 65: aload_0\n 66: getfield #37 // Field passToOnFailure:I\n 69: invokestatic #135 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 72: invokestatic #141 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 75: areturn\n\n public final void passItem(long);\n Code:\n 0: aload_0\n 1: getfield #24 // Field items:Ljava/util/List;\n 4: lload_1\n 5: invokestatic #126 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 8: invokeinterface #146, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 13: pop\n 14: return\n\n private final java.util.List<java.lang.Long> component1();\n Code:\n 0: aload_0\n 1: getfield #24 // Field items:Ljava/util/List;\n 4: areturn\n\n private final kotlin.jvm.functions.Function1<java.lang.Long, java.lang.Long> component2();\n Code:\n 0: aload_0\n 1: getfield #27 // Field newStressLevelFormula:Lkotlin/jvm/functions/Function1;\n 4: areturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #31 // Field divisor:I\n 4: ireturn\n\n private final int component4();\n Code:\n 0: aload_0\n 1: getfield #34 // Field passToOnSuccess:I\n 4: ireturn\n\n private final int component5();\n Code:\n 0: aload_0\n 1: getfield #37 // Field passToOnFailure:I\n 4: ireturn\n\n public final long component6();\n Code:\n 0: aload_0\n 1: getfield #41 // Field handledItemsCount:J\n 4: lreturn\n\n public final Day11$Monkey copy(java.util.List<java.lang.Long>, kotlin.jvm.functions.Function1<? super java.lang.Long, java.lang.Long>, int, int, int, long);\n Code:\n 0: aload_1\n 1: ldc #10 // String items\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #18 // String newStressLevelFormula\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class Day11$Monkey\n 15: dup\n 16: aload_1\n 17: aload_2\n 18: iload_3\n 19: iload 4\n 21: iload 5\n 23: lload 6\n 25: invokespecial #46 // Method \"<init>\":(Ljava/util/List;Lkotlin/jvm/functions/Function1;IIIJ)V\n 28: areturn\n\n public static Day11$Monkey copy$default(Day11$Monkey, java.util.List, kotlin.jvm.functions.Function1, int, int, int, long, int, java.lang.Object);\n Code:\n 0: iload 8\n 2: iconst_1\n 3: iand\n 4: ifeq 12\n 7: aload_0\n 8: getfield #24 // Field items:Ljava/util/List;\n 11: astore_1\n 12: iload 8\n 14: iconst_2\n 15: iand\n 16: ifeq 24\n 19: aload_0\n 20: getfield #27 // Field newStressLevelFormula:Lkotlin/jvm/functions/Function1;\n 23: astore_2\n 24: iload 8\n 26: iconst_4\n 27: iand\n 28: ifeq 36\n 31: aload_0\n 32: getfield #31 // Field divisor:I\n 35: istore_3\n 36: iload 8\n 38: bipush 8\n 40: iand\n 41: ifeq 50\n 44: aload_0\n 45: getfield #34 // Field passToOnSuccess:I\n 48: istore 4\n 50: iload 8\n 52: bipush 16\n 54: iand\n 55: ifeq 64\n 58: aload_0\n 59: getfield #37 // Field passToOnFailure:I\n 62: istore 5\n 64: iload 8\n 66: bipush 32\n 68: iand\n 69: ifeq 78\n 72: aload_0\n 73: getfield #41 // Field handledItemsCount:J\n 76: lstore 6\n 78: aload_0\n 79: aload_1\n 80: aload_2\n 81: iload_3\n 82: iload 4\n 84: iload 5\n 86: lload 6\n 88: invokevirtual #163 // Method copy:(Ljava/util/List;Lkotlin/jvm/functions/Function1;IIIJ)LDay11$Monkey;\n 91: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #167 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #168 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #170 // String Monkey(items=\n 9: invokevirtual #174 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #24 // Field items:Ljava/util/List;\n 16: invokevirtual #177 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #179 // String , newStressLevelFormula=\n 21: invokevirtual #174 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #27 // Field newStressLevelFormula:Lkotlin/jvm/functions/Function1;\n 28: invokevirtual #177 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: ldc #181 // String , divisor=\n 33: invokevirtual #174 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #31 // Field divisor:I\n 40: invokevirtual #184 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 43: ldc #186 // String , passToOnSuccess=\n 45: invokevirtual #174 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: aload_0\n 49: getfield #34 // Field passToOnSuccess:I\n 52: invokevirtual #184 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 55: ldc #188 // String , passToOnFailure=\n 57: invokevirtual #174 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 60: aload_0\n 61: getfield #37 // Field passToOnFailure:I\n 64: invokevirtual #184 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 67: ldc #190 // String , handledItemsCount=\n 69: invokevirtual #174 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 72: aload_0\n 73: getfield #41 // Field handledItemsCount:J\n 76: invokevirtual #193 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 79: bipush 41\n 81: invokevirtual #196 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 84: invokevirtual #198 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 87: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #24 // Field items:Ljava/util/List;\n 4: invokevirtual #201 // Method java/lang/Object.hashCode:()I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #27 // Field newStressLevelFormula:Lkotlin/jvm/functions/Function1;\n 16: invokevirtual #201 // Method java/lang/Object.hashCode:()I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: bipush 31\n 24: imul\n 25: aload_0\n 26: getfield #31 // Field divisor:I\n 29: invokestatic #204 // 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 #34 // Field passToOnSuccess:I\n 42: invokestatic #204 // Method java/lang/Integer.hashCode:(I)I\n 45: iadd\n 46: istore_1\n 47: iload_1\n 48: bipush 31\n 50: imul\n 51: aload_0\n 52: getfield #37 // Field passToOnFailure:I\n 55: invokestatic #204 // Method java/lang/Integer.hashCode:(I)I\n 58: iadd\n 59: istore_1\n 60: iload_1\n 61: bipush 31\n 63: imul\n 64: aload_0\n 65: getfield #41 // Field handledItemsCount:J\n 68: invokestatic #207 // Method java/lang/Long.hashCode:(J)I\n 71: iadd\n 72: istore_1\n 73: iload_1\n 74: ireturn\n\n public boolean equals(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: if_acmpne 7\n 5: iconst_1\n 6: ireturn\n 7: aload_1\n 8: instanceof #2 // class Day11$Monkey\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day11$Monkey\n 20: astore_2\n 21: aload_0\n 22: getfield #24 // Field items:Ljava/util/List;\n 25: aload_2\n 26: getfield #24 // Field items:Ljava/util/List;\n 29: invokestatic #214 // 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 newStressLevelFormula:Lkotlin/jvm/functions/Function1;\n 41: aload_2\n 42: getfield #27 // Field newStressLevelFormula:Lkotlin/jvm/functions/Function1;\n 45: invokestatic #214 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 48: ifne 53\n 51: iconst_0\n 52: ireturn\n 53: aload_0\n 54: getfield #31 // Field divisor:I\n 57: aload_2\n 58: getfield #31 // Field divisor:I\n 61: if_icmpeq 66\n 64: iconst_0\n 65: ireturn\n 66: aload_0\n 67: getfield #34 // Field passToOnSuccess:I\n 70: aload_2\n 71: getfield #34 // Field passToOnSuccess:I\n 74: if_icmpeq 79\n 77: iconst_0\n 78: ireturn\n 79: aload_0\n 80: getfield #37 // Field passToOnFailure:I\n 83: aload_2\n 84: getfield #37 // Field passToOnFailure:I\n 87: if_icmpeq 92\n 90: iconst_0\n 91: ireturn\n 92: aload_0\n 93: getfield #41 // Field handledItemsCount:J\n 96: aload_2\n 97: getfield #41 // Field handledItemsCount:J\n 100: lcmp\n 101: ifeq 106\n 104: iconst_0\n 105: ireturn\n 106: iconst_1\n 107: ireturn\n}\n",
"javap_err": ""
}
] |
dliszewski__advent-of-code-2022__76d5eea/src/main/kotlin/Day10.kt
|
import java.lang.StringBuilder
class Day10 {
fun part1(input: List<String>): Int {
val cyclesToCheck = (20..220 step 40).toList()
var result = 0
val instructions = listOf(1) + input.flatMap { it.toOperation() }
instructions.reduceIndexed { cycle, acc, instruction ->
if (cycle in cyclesToCheck) {
result += cycle * acc
}
acc + instruction
}
return result
}
fun part2(input: List<String>): String {
val crtCyclesToCheck = (40..220 step 40).toList()
var spritePosition = 0
val instructions = listOf(1) + input.flatMap { it.toOperation() }
val crtScreen = StringBuilder()
instructions.reduceIndexed { cycle, acc, instruction ->
crtScreen.append(if ((cycle - 1) % 40 in spritePosition - 1 .. spritePosition + 1) '#' else '.')
if (cycle in crtCyclesToCheck) {
crtScreen.appendLine()
}
spritePosition = acc + instruction
acc + instruction
}
val screen = crtScreen.toString()
println("====== Result ======")
println(screen)
println("====================")
return screen
}
private fun String.toOperation(): List<Int> {
return when {
this == "noop" -> listOf(0)
this.startsWith("addx") -> listOf(0, this.substringAfter("addx ").toInt())
else -> error("wrong operation $this")
}
}
}
|
[
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day10.class",
"javap": "Compiled from \"Day10.kt\"\npublic final class Day10 {\n public Day10();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #24 // class kotlin/ranges/IntRange\n 9: dup\n 10: bipush 20\n 12: sipush 220\n 15: invokespecial #27 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 18: checkcast #29 // class kotlin/ranges/IntProgression\n 21: bipush 40\n 23: invokestatic #35 // Method kotlin/ranges/RangesKt.step:(Lkotlin/ranges/IntProgression;I)Lkotlin/ranges/IntProgression;\n 26: checkcast #37 // class java/lang/Iterable\n 29: invokestatic #43 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 32: astore_2\n 33: iconst_0\n 34: istore_3\n 35: iconst_1\n 36: invokestatic #49 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 39: invokestatic #53 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 42: checkcast #55 // class java/util/Collection\n 45: aload_1\n 46: checkcast #37 // class java/lang/Iterable\n 49: astore 5\n 51: astore 15\n 53: iconst_0\n 54: istore 6\n 56: aload 5\n 58: astore 7\n 60: new #57 // class java/util/ArrayList\n 63: dup\n 64: invokespecial #58 // Method java/util/ArrayList.\"<init>\":()V\n 67: checkcast #55 // class java/util/Collection\n 70: astore 8\n 72: iconst_0\n 73: istore 9\n 75: aload 7\n 77: invokeinterface #62, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 82: astore 10\n 84: aload 10\n 86: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 91: ifeq 135\n 94: aload 10\n 96: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 101: astore 11\n 103: aload 11\n 105: checkcast #74 // class java/lang/String\n 108: astore 12\n 110: iconst_0\n 111: istore 13\n 113: aload_0\n 114: aload 12\n 116: invokespecial #78 // Method toOperation:(Ljava/lang/String;)Ljava/util/List;\n 119: checkcast #37 // class java/lang/Iterable\n 122: astore 12\n 124: aload 8\n 126: aload 12\n 128: invokestatic #82 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 131: pop\n 132: goto 84\n 135: aload 8\n 137: checkcast #84 // class java/util/List\n 140: nop\n 141: aload 15\n 143: swap\n 144: checkcast #37 // class java/lang/Iterable\n 147: invokestatic #88 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 150: astore 4\n 152: aload 4\n 154: checkcast #37 // class java/lang/Iterable\n 157: astore 5\n 159: iconst_0\n 160: istore 6\n 162: aload 5\n 164: invokeinterface #62, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 169: astore 7\n 171: aload 7\n 173: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 178: ifne 191\n 181: new #90 // class java/lang/UnsupportedOperationException\n 184: dup\n 185: ldc #92 // String Empty collection can\\'t be reduced.\n 187: invokespecial #95 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 190: athrow\n 191: iconst_1\n 192: istore 8\n 194: aload 7\n 196: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 201: astore 9\n 203: aload 7\n 205: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 210: ifeq 295\n 213: iload 8\n 215: iinc 8, 1\n 218: istore 10\n 220: iload 10\n 222: ifge 228\n 225: invokestatic #98 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 228: iload 10\n 230: aload 9\n 232: aload 7\n 234: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 239: checkcast #100 // class java/lang/Number\n 242: invokevirtual #104 // Method java/lang/Number.intValue:()I\n 245: istore 11\n 247: checkcast #100 // class java/lang/Number\n 250: invokevirtual #104 // Method java/lang/Number.intValue:()I\n 253: istore 12\n 255: istore 13\n 257: iconst_0\n 258: istore 14\n 260: aload_2\n 261: iload 13\n 263: invokestatic #49 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 266: invokeinterface #108, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 271: ifeq 282\n 274: iload_3\n 275: iload 13\n 277: iload 12\n 279: imul\n 280: iadd\n 281: istore_3\n 282: iload 12\n 284: iload 11\n 286: iadd\n 287: invokestatic #49 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 290: astore 9\n 292: goto 203\n 295: nop\n 296: iload_3\n 297: ireturn\n\n public final java.lang.String part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #24 // class kotlin/ranges/IntRange\n 9: dup\n 10: bipush 40\n 12: sipush 220\n 15: invokespecial #27 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 18: checkcast #29 // class kotlin/ranges/IntProgression\n 21: bipush 40\n 23: invokestatic #35 // Method kotlin/ranges/RangesKt.step:(Lkotlin/ranges/IntProgression;I)Lkotlin/ranges/IntProgression;\n 26: checkcast #37 // class java/lang/Iterable\n 29: invokestatic #43 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 32: astore_2\n 33: iconst_0\n 34: istore_3\n 35: iconst_1\n 36: invokestatic #49 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 39: invokestatic #53 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 42: checkcast #55 // class java/util/Collection\n 45: aload_1\n 46: checkcast #37 // class java/lang/Iterable\n 49: astore 5\n 51: astore 19\n 53: iconst_0\n 54: istore 6\n 56: aload 5\n 58: astore 7\n 60: new #57 // class java/util/ArrayList\n 63: dup\n 64: invokespecial #58 // Method java/util/ArrayList.\"<init>\":()V\n 67: checkcast #55 // class java/util/Collection\n 70: astore 8\n 72: iconst_0\n 73: istore 9\n 75: aload 7\n 77: invokeinterface #62, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 82: astore 10\n 84: aload 10\n 86: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 91: ifeq 135\n 94: aload 10\n 96: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 101: astore 11\n 103: aload 11\n 105: checkcast #74 // class java/lang/String\n 108: astore 12\n 110: iconst_0\n 111: istore 13\n 113: aload_0\n 114: aload 12\n 116: invokespecial #78 // Method toOperation:(Ljava/lang/String;)Ljava/util/List;\n 119: checkcast #37 // class java/lang/Iterable\n 122: astore 12\n 124: aload 8\n 126: aload 12\n 128: invokestatic #82 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 131: pop\n 132: goto 84\n 135: aload 8\n 137: checkcast #84 // class java/util/List\n 140: nop\n 141: aload 19\n 143: swap\n 144: checkcast #37 // class java/lang/Iterable\n 147: invokestatic #88 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 150: astore 4\n 152: new #141 // class java/lang/StringBuilder\n 155: dup\n 156: invokespecial #142 // Method java/lang/StringBuilder.\"<init>\":()V\n 159: astore 5\n 161: aload 4\n 163: checkcast #37 // class java/lang/Iterable\n 166: astore 6\n 168: iconst_0\n 169: istore 7\n 171: aload 6\n 173: invokeinterface #62, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 178: astore 8\n 180: aload 8\n 182: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 187: ifne 200\n 190: new #90 // class java/lang/UnsupportedOperationException\n 193: dup\n 194: ldc #92 // String Empty collection can\\'t be reduced.\n 196: invokespecial #95 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 199: athrow\n 200: iconst_1\n 201: istore 9\n 203: aload 8\n 205: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 210: astore 10\n 212: aload 8\n 214: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 219: ifeq 368\n 222: iload 9\n 224: iinc 9, 1\n 227: istore 11\n 229: iload 11\n 231: ifge 237\n 234: invokestatic #98 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 237: iload 11\n 239: aload 10\n 241: aload 8\n 243: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 248: checkcast #100 // class java/lang/Number\n 251: invokevirtual #104 // Method java/lang/Number.intValue:()I\n 254: istore 12\n 256: checkcast #100 // class java/lang/Number\n 259: invokevirtual #104 // Method java/lang/Number.intValue:()I\n 262: istore 13\n 264: istore 14\n 266: iconst_0\n 267: istore 15\n 269: aload 5\n 271: iload_3\n 272: iconst_1\n 273: isub\n 274: istore 16\n 276: iload_3\n 277: iconst_1\n 278: iadd\n 279: istore 17\n 281: iload 14\n 283: iconst_1\n 284: isub\n 285: bipush 40\n 287: irem\n 288: istore 18\n 290: iload 16\n 292: iload 18\n 294: if_icmpgt 312\n 297: iload 18\n 299: iload 17\n 301: if_icmpgt 308\n 304: iconst_1\n 305: goto 313\n 308: iconst_0\n 309: goto 313\n 312: iconst_0\n 313: ifeq 321\n 316: bipush 35\n 318: goto 323\n 321: bipush 46\n 323: invokevirtual #146 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 326: pop\n 327: aload_2\n 328: iload 14\n 330: invokestatic #49 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 333: invokeinterface #108, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 338: ifeq 349\n 341: aload 5\n 343: bipush 10\n 345: invokevirtual #146 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 348: pop\n 349: iload 13\n 351: iload 12\n 353: iadd\n 354: istore_3\n 355: iload 13\n 357: iload 12\n 359: iadd\n 360: invokestatic #49 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 363: astore 10\n 365: goto 212\n 368: nop\n 369: aload 5\n 371: invokevirtual #150 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 374: dup\n 375: ldc #152 // String toString(...)\n 377: invokestatic #155 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 380: astore 6\n 382: ldc #157 // String ====== Result ======\n 384: getstatic #163 // Field java/lang/System.out:Ljava/io/PrintStream;\n 387: swap\n 388: invokevirtual #169 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 391: getstatic #163 // Field java/lang/System.out:Ljava/io/PrintStream;\n 394: aload 6\n 396: invokevirtual #169 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 399: ldc #171 // String ====================\n 401: getstatic #163 // Field java/lang/System.out:Ljava/io/PrintStream;\n 404: swap\n 405: invokevirtual #169 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 408: aload 6\n 410: areturn\n\n private final java.util.List<java.lang.Integer> toOperation(java.lang.String);\n Code:\n 0: nop\n 1: aload_1\n 2: ldc #181 // String noop\n 4: invokestatic #185 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 7: ifeq 20\n 10: iconst_0\n 11: invokestatic #49 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 14: invokestatic #53 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 17: goto 99\n 20: aload_1\n 21: ldc #187 // String addx\n 23: iconst_0\n 24: iconst_2\n 25: aconst_null\n 26: invokestatic #193 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 29: ifeq 69\n 32: iconst_2\n 33: anewarray #45 // class java/lang/Integer\n 36: astore_2\n 37: aload_2\n 38: iconst_0\n 39: iconst_0\n 40: invokestatic #49 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 43: aastore\n 44: aload_2\n 45: iconst_1\n 46: aload_1\n 47: ldc #195 // String addx\n 49: aconst_null\n 50: iconst_2\n 51: aconst_null\n 52: invokestatic #199 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 55: invokestatic #203 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 58: invokestatic #49 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 61: aastore\n 62: aload_2\n 63: invokestatic #206 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 66: goto 99\n 69: new #208 // class java/lang/IllegalStateException\n 72: dup\n 73: new #141 // class java/lang/StringBuilder\n 76: dup\n 77: invokespecial #142 // Method java/lang/StringBuilder.\"<init>\":()V\n 80: ldc #210 // String wrong operation\n 82: invokevirtual #213 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 85: aload_1\n 86: invokevirtual #213 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 89: invokevirtual #150 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 92: invokevirtual #214 // Method java/lang/Object.toString:()Ljava/lang/String;\n 95: invokespecial #215 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 98: athrow\n 99: areturn\n}\n",
"javap_err": ""
}
] |
dliszewski__advent-of-code-2022__76d5eea/src/main/kotlin/Day04.kt
|
class Day04 {
fun part1(input: List<String>): Int {
return input
.map { it.toRanges() }
.count { (range1, range2) -> range1 includeRange range2 }
}
fun part2(input: List<String>): Int {
return input
.map { it.toRanges() }
.count { (range1, range2) -> range1 overlapRange range2 }
}
private fun String.toRanges(): Pair<IntRange, IntRange> {
val (range1, range2) = split(",")
return Pair(range1.toRange(), range2.toRange())
}
private infix fun IntRange.includeRange(other: IntRange): Boolean {
return (first <= other.first && last >= other.last)
|| (other.first <= first && other.last >= last)
}
private infix fun IntRange.overlapRange(other: IntRange): Boolean {
return (first <= other.last && other.first <= last)
|| (first <= other.last && other.first <= last)
}
private fun String.toRange(): IntRange {
val (from, to) = split("-")
return from.toInt()..to.toInt()
}
}
|
[
{
"class_path": "dliszewski__advent-of-code-2022__76d5eea/Day04.class",
"javap": "Compiled from \"Day04.kt\"\npublic final class Day04 {\n public Day04();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #24 // class java/lang/Iterable\n 10: astore_2\n 11: nop\n 12: iconst_0\n 13: istore_3\n 14: aload_2\n 15: astore 4\n 17: new #26 // class java/util/ArrayList\n 20: dup\n 21: aload_2\n 22: bipush 10\n 24: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 27: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 30: checkcast #37 // class java/util/Collection\n 33: astore 5\n 35: iconst_0\n 36: istore 6\n 38: aload 4\n 40: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 7\n 47: aload 7\n 49: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 98\n 57: aload 7\n 59: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 8\n 66: aload 5\n 68: aload 8\n 70: checkcast #53 // class java/lang/String\n 73: astore 9\n 75: astore 11\n 77: iconst_0\n 78: istore 10\n 80: aload_0\n 81: aload 9\n 83: invokespecial #57 // Method toRanges:(Ljava/lang/String;)Lkotlin/Pair;\n 86: aload 11\n 88: swap\n 89: invokeinterface #61, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 94: pop\n 95: goto 47\n 98: aload 5\n 100: checkcast #63 // class java/util/List\n 103: nop\n 104: checkcast #24 // class java/lang/Iterable\n 107: astore_2\n 108: nop\n 109: iconst_0\n 110: istore_3\n 111: aload_2\n 112: instanceof #37 // class java/util/Collection\n 115: ifeq 134\n 118: aload_2\n 119: checkcast #37 // class java/util/Collection\n 122: invokeinterface #66, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 127: ifeq 134\n 130: iconst_0\n 131: goto 221\n 134: iconst_0\n 135: istore 4\n 137: aload_2\n 138: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 143: astore 5\n 145: aload 5\n 147: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 152: ifeq 219\n 155: aload 5\n 157: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 162: astore 6\n 164: aload 6\n 166: checkcast #68 // class kotlin/Pair\n 169: astore 7\n 171: iconst_0\n 172: istore 8\n 174: aload 7\n 176: invokevirtual #71 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 179: checkcast #73 // class kotlin/ranges/IntRange\n 182: astore 9\n 184: aload 7\n 186: invokevirtual #76 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 189: checkcast #73 // class kotlin/ranges/IntRange\n 192: astore 10\n 194: aload_0\n 195: aload 9\n 197: aload 10\n 199: invokespecial #80 // Method includeRange:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z\n 202: ifeq 145\n 205: iinc 4, 1\n 208: iload 4\n 210: ifge 145\n 213: invokestatic #83 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 216: goto 145\n 219: iload 4\n 221: ireturn\n\n public final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #24 // class java/lang/Iterable\n 10: astore_2\n 11: nop\n 12: iconst_0\n 13: istore_3\n 14: aload_2\n 15: astore 4\n 17: new #26 // class java/util/ArrayList\n 20: dup\n 21: aload_2\n 22: bipush 10\n 24: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 27: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 30: checkcast #37 // class java/util/Collection\n 33: astore 5\n 35: iconst_0\n 36: istore 6\n 38: aload 4\n 40: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 7\n 47: aload 7\n 49: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 98\n 57: aload 7\n 59: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 8\n 66: aload 5\n 68: aload 8\n 70: checkcast #53 // class java/lang/String\n 73: astore 9\n 75: astore 11\n 77: iconst_0\n 78: istore 10\n 80: aload_0\n 81: aload 9\n 83: invokespecial #57 // Method toRanges:(Ljava/lang/String;)Lkotlin/Pair;\n 86: aload 11\n 88: swap\n 89: invokeinterface #61, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 94: pop\n 95: goto 47\n 98: aload 5\n 100: checkcast #63 // class java/util/List\n 103: nop\n 104: checkcast #24 // class java/lang/Iterable\n 107: astore_2\n 108: nop\n 109: iconst_0\n 110: istore_3\n 111: aload_2\n 112: instanceof #37 // class java/util/Collection\n 115: ifeq 134\n 118: aload_2\n 119: checkcast #37 // class java/util/Collection\n 122: invokeinterface #66, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 127: ifeq 134\n 130: iconst_0\n 131: goto 221\n 134: iconst_0\n 135: istore 4\n 137: aload_2\n 138: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 143: astore 5\n 145: aload 5\n 147: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 152: ifeq 219\n 155: aload 5\n 157: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 162: astore 6\n 164: aload 6\n 166: checkcast #68 // class kotlin/Pair\n 169: astore 7\n 171: iconst_0\n 172: istore 8\n 174: aload 7\n 176: invokevirtual #71 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 179: checkcast #73 // class kotlin/ranges/IntRange\n 182: astore 9\n 184: aload 7\n 186: invokevirtual #76 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 189: checkcast #73 // class kotlin/ranges/IntRange\n 192: astore 10\n 194: aload_0\n 195: aload 9\n 197: aload 10\n 199: invokespecial #109 // Method overlapRange:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z\n 202: ifeq 145\n 205: iinc 4, 1\n 208: iload 4\n 210: ifge 145\n 213: invokestatic #83 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 216: goto 145\n 219: iload 4\n 221: ireturn\n\n private final kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange> toRanges(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #114 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #53 // class java/lang/String\n 8: astore_3\n 9: aload_3\n 10: iconst_0\n 11: ldc #116 // String ,\n 13: aastore\n 14: aload_3\n 15: iconst_0\n 16: iconst_0\n 17: bipush 6\n 19: aconst_null\n 20: invokestatic #122 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 23: astore_2\n 24: aload_2\n 25: iconst_0\n 26: invokeinterface #126, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 31: checkcast #53 // class java/lang/String\n 34: astore_3\n 35: aload_2\n 36: iconst_1\n 37: invokeinterface #126, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 42: checkcast #53 // class java/lang/String\n 45: astore 4\n 47: new #68 // class kotlin/Pair\n 50: dup\n 51: aload_0\n 52: aload_3\n 53: invokespecial #130 // Method toRange:(Ljava/lang/String;)Lkotlin/ranges/IntRange;\n 56: aload_0\n 57: aload 4\n 59: invokespecial #130 // Method toRange:(Ljava/lang/String;)Lkotlin/ranges/IntRange;\n 62: invokespecial #133 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 65: areturn\n\n private final boolean includeRange(kotlin.ranges.IntRange, kotlin.ranges.IntRange);\n Code:\n 0: aload_1\n 1: invokevirtual #138 // Method kotlin/ranges/IntRange.getFirst:()I\n 4: aload_2\n 5: invokevirtual #138 // Method kotlin/ranges/IntRange.getFirst:()I\n 8: if_icmpgt 22\n 11: aload_1\n 12: invokevirtual #141 // Method kotlin/ranges/IntRange.getLast:()I\n 15: aload_2\n 16: invokevirtual #141 // Method kotlin/ranges/IntRange.getLast:()I\n 19: if_icmpge 44\n 22: aload_2\n 23: invokevirtual #138 // Method kotlin/ranges/IntRange.getFirst:()I\n 26: aload_1\n 27: invokevirtual #138 // Method kotlin/ranges/IntRange.getFirst:()I\n 30: if_icmpgt 48\n 33: aload_2\n 34: invokevirtual #141 // Method kotlin/ranges/IntRange.getLast:()I\n 37: aload_1\n 38: invokevirtual #141 // Method kotlin/ranges/IntRange.getLast:()I\n 41: if_icmplt 48\n 44: iconst_1\n 45: goto 49\n 48: iconst_0\n 49: ireturn\n\n private final boolean overlapRange(kotlin.ranges.IntRange, kotlin.ranges.IntRange);\n Code:\n 0: aload_1\n 1: invokevirtual #138 // Method kotlin/ranges/IntRange.getFirst:()I\n 4: aload_2\n 5: invokevirtual #141 // Method kotlin/ranges/IntRange.getLast:()I\n 8: if_icmpgt 22\n 11: aload_2\n 12: invokevirtual #138 // Method kotlin/ranges/IntRange.getFirst:()I\n 15: aload_1\n 16: invokevirtual #141 // Method kotlin/ranges/IntRange.getLast:()I\n 19: if_icmple 44\n 22: aload_1\n 23: invokevirtual #138 // Method kotlin/ranges/IntRange.getFirst:()I\n 26: aload_2\n 27: invokevirtual #141 // Method kotlin/ranges/IntRange.getLast:()I\n 30: if_icmpgt 48\n 33: aload_2\n 34: invokevirtual #138 // Method kotlin/ranges/IntRange.getFirst:()I\n 37: aload_1\n 38: invokevirtual #141 // Method kotlin/ranges/IntRange.getLast:()I\n 41: if_icmpgt 48\n 44: iconst_1\n 45: goto 49\n 48: iconst_0\n 49: ireturn\n\n private final kotlin.ranges.IntRange toRange(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #114 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #53 // class java/lang/String\n 8: astore_3\n 9: aload_3\n 10: iconst_0\n 11: ldc #146 // String -\n 13: aastore\n 14: aload_3\n 15: iconst_0\n 16: iconst_0\n 17: bipush 6\n 19: aconst_null\n 20: invokestatic #122 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 23: astore_2\n 24: aload_2\n 25: iconst_0\n 26: invokeinterface #126, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 31: checkcast #53 // class java/lang/String\n 34: astore_3\n 35: aload_2\n 36: iconst_1\n 37: invokeinterface #126, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 42: checkcast #53 // class java/lang/String\n 45: astore 4\n 47: new #73 // class kotlin/ranges/IntRange\n 50: dup\n 51: aload_3\n 52: invokestatic #152 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 55: aload 4\n 57: invokestatic #152 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 60: invokespecial #155 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 63: areturn\n}\n",
"javap_err": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Utils.kt
|
import java.io.File
import kotlin.math.max
import kotlin.math.min
fun readInput(name: String) = File("src", "$name.txt")
.readLines()
fun <T> assert(actual: T, expected: T) {
if (actual == expected) {
return
}
throw Exception("Actual $actual Expected $expected")
}
data class Interval(val start: Int, val end: Int) {
companion object {
fun merge(intervals: List<Interval>): List<Interval> {
var sorted = intervals.sortedBy { i -> i.start }
var hasOverlap = true
while (hasOverlap && sorted.size > 1) {
hasOverlap = false
val bucket = sorted.toMutableList<Interval?>()
var i = 0
while (i < bucket.size - 1) {
if (bucket[i] != null && bucket[i + 1] != null && bucket[i]!!.hasOverlap(bucket[i + 1]!!)) {
hasOverlap = true
val merged = bucket[i]!!.merge(bucket[i + 1]!!)
bucket[i] = null
bucket[i + 1] = merged
}
i += 1
}
sorted = bucket.filterNotNull()
}
return sorted
}
}
fun hasFullOverlap(other: Interval): Boolean {
return hasFullOverlap(this, other) || hasFullOverlap(other, this)
}
fun hasOverlap(other: Interval): Boolean {
return hasOverlap(this, other) || hasOverlap(other, this)
}
fun merge(other: Interval): Interval {
return Interval(min(this.start, other.start), max(this.end, other.end))
}
private fun hasFullOverlap(x: Interval, y: Interval): Boolean {
return x.start >= y.start && x.end <= y.end
}
private fun hasOverlap(x: Interval, y: Interval): Boolean {
return x.start >= y.start && x.start <= y.end
}
fun countPoints(excludePoints: Set<Int>? = null): Int {
var count = end - start + 1
if (excludePoints == null) {
return count
}
for (p in excludePoints) {
if (p in start..end) {
--count
}
}
return count
}
fun minStart(x: Int): Interval {
if (x < start) {
return Interval(x, end)
}
return this
}
fun maxEnd(x: Int): Interval {
if (x > end) {
return Interval(start, x)
}
return this
}
fun isInside(t: Int): Boolean {
return t in start..end
}
}
data class Point(val x: Int, val y: Int) {
fun sum(other: Point): Point {
return Point(this.x + other.x, this.y + other.y)
}
}
enum class Direction {
Up,
Down,
Left,
Right
}
object DirectionManager {
private val directions = arrayOf(Direction.Up, Direction.Right, Direction.Down, Direction.Left)
fun turn(current: Direction, target: Direction): Direction {
if (target == Direction.Down || target == Direction.Up) {
throw RuntimeException("Illegal action $current -> $target")
}
val d = if (target == Direction.Left) -1 else 1
val index = (directions.indexOf(current) + d + directions.size) % directions.size
return directions[index]
}
}
enum class Sign {
Eq,
Less,
More
}
enum class ExecutionMode {
Test1,
Test2,
Exec1,
Exec2
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/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 <T> void assert(T, T);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #53 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 5: ifeq 9\n 8: return\n 9: new #55 // class java/lang/Exception\n 12: dup\n 13: new #22 // class java/lang/StringBuilder\n 16: dup\n 17: invokespecial #26 // Method java/lang/StringBuilder.\"<init>\":()V\n 20: ldc #57 // String Actual\n 22: invokevirtual #30 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 25: aload_0\n 26: invokevirtual #60 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 29: ldc #62 // String Expected\n 31: invokevirtual #30 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 34: aload_1\n 35: invokevirtual #60 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 38: invokevirtual #36 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 41: invokespecial #65 // Method java/lang/Exception.\"<init>\":(Ljava/lang/String;)V\n 44: athrow\n}\n",
"javap_err": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day14.kt
|
import kotlin.math.max
import kotlin.math.min
enum class CaveCell {
Air,
Rock,
Sand
}
enum class SandFallResult {
Stuck,
Fall
}
val caveSize = 1000
fun main() {
class Cave(val map: Array<Array<CaveCell>>) {
fun getBounds(): Pair<Point, Point> {
var minX = caveSize
var minY = caveSize
var maxX = 0
var maxY = 0
for (y in 0 until caveSize) {
for (x in 0 until caveSize) {
if (map[x][y] != CaveCell.Air) {
minX = min(minX, x)
minY = min(minY, y)
maxX = max(maxX, x)
maxY = max(maxY, y)
}
}
}
return Point(minX, minY) to Point(maxX, maxY)
}
}
fun parse(input: List<String>): Cave {
val cave = Cave(Array(caveSize) { _ -> Array(caveSize) { _ -> CaveCell.Air } })
val pointBlocks = input.map { line ->
line
.split('-')
.map { pair ->
val parts = pair.split(',')
Point(parts[0].toInt(), parts[1].toInt())
}
}
for (pointBlock in pointBlocks) {
for (i in 0..pointBlock.size - 2) {
val left = pointBlock[i]
val right = pointBlock[i + 1]
if (left.x != right.x && left.y != right.y) {
println("Unexpected $left -> $right")
throw RuntimeException()
}
if (left.x == right.x) {
val x = left.x
for (dy in min(left.y, right.y)..max(left.y, right.y)) {
cave.map[x][dy] = CaveCell.Rock
}
}
if (left.y == right.y) {
val y = left.y
for (dx in min(left.x, right.x)..max(left.x, right.x)) {
cave.map[dx][y] = CaveCell.Rock
}
}
}
}
return cave
}
fun print(cave: Cave) {
val window = 0
val (minPoint, maxPoint) = cave.getBounds()
for (y in (minPoint.y - window)..(maxPoint.y + window)) {
for (x in (minPoint.x - window)..(maxPoint.x + window)) {
val sign = when (cave.map[x][y]) {
CaveCell.Air -> '.'
CaveCell.Rock -> '#'
CaveCell.Sand -> 'o'
}
print(sign)
}
println()
}
}
fun playSand(cave: Cave): SandFallResult {
val (_, maxPoint) = cave.getBounds()
var sx = 500
var sy = 0
while (sy < maxPoint.y) {
if (cave.map[sx][sy + 1] == CaveCell.Air) {
++sy
} else if (cave.map[sx - 1][sy + 1] == CaveCell.Air) {
--sx
++sy
} else if (cave.map[sx + 1][sy + 1] == CaveCell.Air) {
++sx
++sy
} else {
cave.map[sx][sy] = CaveCell.Sand
return SandFallResult.Stuck
}
}
return SandFallResult.Fall
}
fun play1(cave: Cave): Int {
var counter = 0
while (playSand(cave) != SandFallResult.Fall) {
// print(cave)
++counter
}
return counter
}
fun play2(cave: Cave): Int {
val (_, maxPoint) = cave.getBounds()
for (x in 0 until caveSize) {
cave.map[x][maxPoint.y + 2] = CaveCell.Rock
}
var counter = 0
while (playSand(cave) != SandFallResult.Fall && cave.map[500][0] != CaveCell.Sand) {
++counter
}
return counter + 1
}
fun part1(input: List<String>): Int {
val cave = parse(input)
return play1(cave)
}
fun part2(input: List<String>): Int {
val cave = parse(input)
return play2(cave)
}
val testInput = readInput("Day14_test")
assert(part1(testInput), 24)
assert(part2(testInput), 93)
val input = readInput("Day14")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day14Kt.class",
"javap": "Compiled from \"Day14.kt\"\npublic final class Day14Kt {\n private static final int caveSize;\n\n public static final int getCaveSize();\n Code:\n 0: getstatic #10 // Field caveSize:I\n 3: ireturn\n\n public static final void main();\n Code:\n 0: ldc #14 // String Day14_test\n 2: invokestatic #20 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #24 // Method main$part1:(Ljava/util/List;)I\n 10: invokestatic #30 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 13: bipush 24\n 15: invokestatic #30 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 18: invokestatic #34 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 21: aload_0\n 22: invokestatic #37 // Method main$part2:(Ljava/util/List;)I\n 25: invokestatic #30 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 28: bipush 93\n 30: invokestatic #30 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 33: invokestatic #34 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 36: ldc #39 // String Day14\n 38: invokestatic #20 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 41: astore_1\n 42: aload_1\n 43: invokestatic #24 // Method main$part1:(Ljava/util/List;)I\n 46: istore_2\n 47: getstatic #45 // Field java/lang/System.out:Ljava/io/PrintStream;\n 50: iload_2\n 51: invokevirtual #51 // Method java/io/PrintStream.println:(I)V\n 54: aload_1\n 55: invokestatic #37 // Method main$part2:(Ljava/util/List;)I\n 58: istore_2\n 59: getstatic #45 // Field java/lang/System.out:Ljava/io/PrintStream;\n 62: iload_2\n 63: invokevirtual #51 // Method java/io/PrintStream.println:(I)V\n 66: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #57 // Method main:()V\n 3: return\n\n private static final Day14Kt$main$Cave main$parse(java.util.List<java.lang.String>);\n Code:\n 0: iconst_0\n 1: istore_2\n 2: getstatic #10 // Field caveSize:I\n 5: istore_3\n 6: iload_3\n 7: anewarray #64 // class \"[LCaveCell;\"\n 10: astore 4\n 12: iload_2\n 13: iload_3\n 14: if_icmpge 81\n 17: iload_2\n 18: istore 5\n 20: aload 4\n 22: iload 5\n 24: iconst_0\n 25: istore 6\n 27: getstatic #10 // Field caveSize:I\n 30: istore 7\n 32: iload 7\n 34: anewarray #66 // class CaveCell\n 37: astore 8\n 39: istore 26\n 41: astore 25\n 43: iload 6\n 45: iload 7\n 47: if_icmpge 68\n 50: iload 6\n 52: istore 9\n 54: aload 8\n 56: iload 9\n 58: getstatic #70 // Field CaveCell.Air:LCaveCell;\n 61: aastore\n 62: iinc 6, 1\n 65: goto 43\n 68: aload 25\n 70: iload 26\n 72: aload 8\n 74: aastore\n 75: iinc 2, 1\n 78: goto 12\n 81: aload 4\n 83: astore 27\n 85: new #72 // class Day14Kt$main$Cave\n 88: dup\n 89: aload 27\n 91: invokespecial #76 // Method Day14Kt$main$Cave.\"<init>\":([[LCaveCell;)V\n 94: astore_1\n 95: aload_0\n 96: checkcast #78 // class java/lang/Iterable\n 99: astore_3\n 100: iconst_0\n 101: istore 4\n 103: aload_3\n 104: astore 5\n 106: new #80 // class java/util/ArrayList\n 109: dup\n 110: aload_3\n 111: bipush 10\n 113: invokestatic #86 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 116: invokespecial #88 // Method java/util/ArrayList.\"<init>\":(I)V\n 119: checkcast #90 // class java/util/Collection\n 122: astore 6\n 124: iconst_0\n 125: istore 7\n 127: aload 5\n 129: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 134: astore 8\n 136: aload 8\n 138: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 143: ifeq 366\n 146: aload 8\n 148: invokeinterface #104, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 153: astore 9\n 155: aload 6\n 157: aload 9\n 159: checkcast #106 // class java/lang/String\n 162: astore 10\n 164: astore 24\n 166: iconst_0\n 167: istore 11\n 169: aload 10\n 171: checkcast #108 // class java/lang/CharSequence\n 174: iconst_1\n 175: newarray char\n 177: astore 12\n 179: aload 12\n 181: iconst_0\n 182: bipush 45\n 184: castore\n 185: aload 12\n 187: iconst_0\n 188: iconst_0\n 189: bipush 6\n 191: aconst_null\n 192: invokestatic #114 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 195: checkcast #78 // class java/lang/Iterable\n 198: astore 12\n 200: nop\n 201: iconst_0\n 202: istore 13\n 204: aload 12\n 206: astore 14\n 208: new #80 // class java/util/ArrayList\n 211: dup\n 212: aload 12\n 214: bipush 10\n 216: invokestatic #86 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 219: invokespecial #88 // Method java/util/ArrayList.\"<init>\":(I)V\n 222: checkcast #90 // class java/util/Collection\n 225: astore 15\n 227: iconst_0\n 228: istore 16\n 230: aload 14\n 232: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 237: astore 17\n 239: aload 17\n 241: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 246: ifeq 347\n 249: aload 17\n 251: invokeinterface #104, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 256: astore 18\n 258: aload 15\n 260: aload 18\n 262: checkcast #106 // class java/lang/String\n 265: astore 19\n 267: astore 20\n 269: iconst_0\n 270: istore 21\n 272: aload 19\n 274: checkcast #108 // class java/lang/CharSequence\n 277: iconst_1\n 278: newarray char\n 280: astore 22\n 282: aload 22\n 284: iconst_0\n 285: bipush 44\n 287: castore\n 288: aload 22\n 290: iconst_0\n 291: iconst_0\n 292: bipush 6\n 294: aconst_null\n 295: invokestatic #114 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 298: astore 23\n 300: new #116 // class Point\n 303: dup\n 304: aload 23\n 306: iconst_0\n 307: invokeinterface #122, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 312: checkcast #106 // class java/lang/String\n 315: invokestatic #126 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 318: aload 23\n 320: iconst_1\n 321: invokeinterface #122, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 326: checkcast #106 // class java/lang/String\n 329: invokestatic #126 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 332: invokespecial #129 // Method Point.\"<init>\":(II)V\n 335: aload 20\n 337: swap\n 338: invokeinterface #133, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 343: pop\n 344: goto 239\n 347: aload 15\n 349: checkcast #118 // class java/util/List\n 352: nop\n 353: nop\n 354: aload 24\n 356: swap\n 357: invokeinterface #133, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 362: pop\n 363: goto 136\n 366: aload 6\n 368: checkcast #118 // class java/util/List\n 371: nop\n 372: astore_2\n 373: aload_2\n 374: invokeinterface #134, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 379: astore_3\n 380: aload_3\n 381: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 386: ifeq 701\n 389: aload_3\n 390: invokeinterface #104, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 395: checkcast #118 // class java/util/List\n 398: astore 4\n 400: iconst_0\n 401: istore 5\n 403: aload 4\n 405: invokeinterface #137, 1 // InterfaceMethod java/util/List.size:()I\n 410: iconst_2\n 411: isub\n 412: istore 6\n 414: iload 5\n 416: iload 6\n 418: if_icmpgt 380\n 421: aload 4\n 423: iload 5\n 425: invokeinterface #122, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 430: checkcast #116 // class Point\n 433: astore 7\n 435: aload 4\n 437: iload 5\n 439: iconst_1\n 440: iadd\n 441: invokeinterface #122, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 446: checkcast #116 // class Point\n 449: astore 8\n 451: aload 7\n 453: invokevirtual #140 // Method Point.getX:()I\n 456: aload 8\n 458: invokevirtual #140 // Method Point.getX:()I\n 461: if_icmpeq 522\n 464: aload 7\n 466: invokevirtual #143 // Method Point.getY:()I\n 469: aload 8\n 471: invokevirtual #143 // Method Point.getY:()I\n 474: if_icmpeq 522\n 477: new #145 // class java/lang/StringBuilder\n 480: dup\n 481: invokespecial #147 // Method java/lang/StringBuilder.\"<init>\":()V\n 484: ldc #149 // String Unexpected\n 486: invokevirtual #153 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 489: aload 7\n 491: invokevirtual #156 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 494: ldc #158 // String ->\n 496: invokevirtual #153 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 499: aload 8\n 501: invokevirtual #156 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 504: invokevirtual #162 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 507: getstatic #45 // Field java/lang/System.out:Ljava/io/PrintStream;\n 510: swap\n 511: invokevirtual #165 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 514: new #167 // class java/lang/RuntimeException\n 517: dup\n 518: invokespecial #168 // Method java/lang/RuntimeException.\"<init>\":()V\n 521: athrow\n 522: aload 7\n 524: invokevirtual #140 // Method Point.getX:()I\n 527: aload 8\n 529: invokevirtual #140 // Method Point.getX:()I\n 532: if_icmpne 605\n 535: aload 7\n 537: invokevirtual #140 // Method Point.getX:()I\n 540: istore 9\n 542: aload 7\n 544: invokevirtual #143 // Method Point.getY:()I\n 547: aload 8\n 549: invokevirtual #143 // Method Point.getY:()I\n 552: invokestatic #174 // Method java/lang/Math.min:(II)I\n 555: istore 10\n 557: aload 7\n 559: invokevirtual #143 // Method Point.getY:()I\n 562: aload 8\n 564: invokevirtual #143 // Method Point.getY:()I\n 567: invokestatic #177 // Method java/lang/Math.max:(II)I\n 570: istore 11\n 572: iload 10\n 574: iload 11\n 576: if_icmpgt 605\n 579: aload_1\n 580: invokevirtual #181 // Method Day14Kt$main$Cave.getMap:()[[LCaveCell;\n 583: iload 9\n 585: aaload\n 586: iload 10\n 588: getstatic #184 // Field CaveCell.Rock:LCaveCell;\n 591: aastore\n 592: iload 10\n 594: iload 11\n 596: if_icmpeq 605\n 599: iinc 10, 1\n 602: goto 579\n 605: aload 7\n 607: invokevirtual #143 // Method Point.getY:()I\n 610: aload 8\n 612: invokevirtual #143 // Method Point.getY:()I\n 615: if_icmpne 688\n 618: aload 7\n 620: invokevirtual #143 // Method Point.getY:()I\n 623: istore 9\n 625: aload 7\n 627: invokevirtual #140 // Method Point.getX:()I\n 630: aload 8\n 632: invokevirtual #140 // Method Point.getX:()I\n 635: invokestatic #174 // Method java/lang/Math.min:(II)I\n 638: istore 10\n 640: aload 7\n 642: invokevirtual #140 // Method Point.getX:()I\n 645: aload 8\n 647: invokevirtual #140 // Method Point.getX:()I\n 650: invokestatic #177 // Method java/lang/Math.max:(II)I\n 653: istore 11\n 655: iload 10\n 657: iload 11\n 659: if_icmpgt 688\n 662: aload_1\n 663: invokevirtual #181 // Method Day14Kt$main$Cave.getMap:()[[LCaveCell;\n 666: iload 10\n 668: aaload\n 669: iload 9\n 671: getstatic #184 // Field CaveCell.Rock:LCaveCell;\n 674: aastore\n 675: iload 10\n 677: iload 11\n 679: if_icmpeq 688\n 682: iinc 10, 1\n 685: goto 662\n 688: iload 5\n 690: iload 6\n 692: if_icmpeq 380\n 695: iinc 5, 1\n 698: goto 421\n 701: aload_1\n 702: areturn\n\n private static final void main$print(Day14Kt$main$Cave);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: aload_0\n 3: invokevirtual #219 // Method Day14Kt$main$Cave.getBounds:()Lkotlin/Pair;\n 6: astore_2\n 7: aload_2\n 8: invokevirtual #224 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 11: checkcast #116 // class Point\n 14: astore_3\n 15: aload_2\n 16: invokevirtual #227 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 19: checkcast #116 // class Point\n 22: astore 4\n 24: aload_3\n 25: invokevirtual #143 // Method Point.getY:()I\n 28: iload_1\n 29: isub\n 30: istore 5\n 32: aload 4\n 34: invokevirtual #143 // Method Point.getY:()I\n 37: iload_1\n 38: iadd\n 39: istore 6\n 41: iload 5\n 43: iload 6\n 45: if_icmpgt 181\n 48: aload_3\n 49: invokevirtual #140 // Method Point.getX:()I\n 52: iload_1\n 53: isub\n 54: istore 7\n 56: aload 4\n 58: invokevirtual #140 // Method Point.getX:()I\n 61: iload_1\n 62: iadd\n 63: istore 8\n 65: iload 7\n 67: iload 8\n 69: if_icmpgt 162\n 72: aload_0\n 73: invokevirtual #181 // Method Day14Kt$main$Cave.getMap:()[[LCaveCell;\n 76: iload 7\n 78: aaload\n 79: iload 5\n 81: aaload\n 82: getstatic #233 // Field Day14Kt$WhenMappings.$EnumSwitchMapping$0:[I\n 85: swap\n 86: invokevirtual #236 // Method CaveCell.ordinal:()I\n 89: iaload\n 90: tableswitch { // 1 to 3\n 1: 116\n 2: 121\n 3: 126\n default: 131\n }\n 116: bipush 46\n 118: goto 139\n 121: bipush 35\n 123: goto 139\n 126: bipush 111\n 128: goto 139\n 131: new #238 // class kotlin/NoWhenBranchMatchedException\n 134: dup\n 135: invokespecial #239 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 138: athrow\n 139: istore 9\n 141: getstatic #45 // Field java/lang/System.out:Ljava/io/PrintStream;\n 144: iload 9\n 146: invokevirtual #243 // Method java/io/PrintStream.print:(C)V\n 149: iload 7\n 151: iload 8\n 153: if_icmpeq 162\n 156: iinc 7, 1\n 159: goto 72\n 162: getstatic #45 // Field java/lang/System.out:Ljava/io/PrintStream;\n 165: invokevirtual #245 // Method java/io/PrintStream.println:()V\n 168: iload 5\n 170: iload 6\n 172: if_icmpeq 181\n 175: iinc 5, 1\n 178: goto 48\n 181: return\n\n private static final SandFallResult main$playSand(Day14Kt$main$Cave);\n Code:\n 0: aload_0\n 1: invokevirtual #219 // Method Day14Kt$main$Cave.getBounds:()Lkotlin/Pair;\n 4: invokevirtual #227 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 7: checkcast #116 // class Point\n 10: astore_1\n 11: sipush 500\n 14: istore_2\n 15: iconst_0\n 16: istore_3\n 17: iload_3\n 18: aload_1\n 19: invokevirtual #143 // Method Point.getY:()I\n 22: if_icmpge 116\n 25: aload_0\n 26: invokevirtual #181 // Method Day14Kt$main$Cave.getMap:()[[LCaveCell;\n 29: iload_2\n 30: aaload\n 31: iload_3\n 32: iconst_1\n 33: iadd\n 34: aaload\n 35: getstatic #70 // Field CaveCell.Air:LCaveCell;\n 38: if_acmpne 47\n 41: iinc 3, 1\n 44: goto 17\n 47: aload_0\n 48: invokevirtual #181 // Method Day14Kt$main$Cave.getMap:()[[LCaveCell;\n 51: iload_2\n 52: iconst_1\n 53: isub\n 54: aaload\n 55: iload_3\n 56: iconst_1\n 57: iadd\n 58: aaload\n 59: getstatic #70 // Field CaveCell.Air:LCaveCell;\n 62: if_acmpne 74\n 65: iinc 2, -1\n 68: iinc 3, 1\n 71: goto 17\n 74: aload_0\n 75: invokevirtual #181 // Method Day14Kt$main$Cave.getMap:()[[LCaveCell;\n 78: iload_2\n 79: iconst_1\n 80: iadd\n 81: aaload\n 82: iload_3\n 83: iconst_1\n 84: iadd\n 85: aaload\n 86: getstatic #70 // Field CaveCell.Air:LCaveCell;\n 89: if_acmpne 101\n 92: iinc 2, 1\n 95: iinc 3, 1\n 98: goto 17\n 101: aload_0\n 102: invokevirtual #181 // Method Day14Kt$main$Cave.getMap:()[[LCaveCell;\n 105: iload_2\n 106: aaload\n 107: iload_3\n 108: getstatic #255 // Field CaveCell.Sand:LCaveCell;\n 111: aastore\n 112: getstatic #261 // Field SandFallResult.Stuck:LSandFallResult;\n 115: areturn\n 116: getstatic #264 // Field SandFallResult.Fall:LSandFallResult;\n 119: areturn\n\n private static final int main$play1(Day14Kt$main$Cave);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: aload_0\n 3: invokestatic #270 // Method main$playSand:(LDay14Kt$main$Cave;)LSandFallResult;\n 6: getstatic #264 // Field SandFallResult.Fall:LSandFallResult;\n 9: if_acmpeq 18\n 12: iinc 1, 1\n 15: goto 2\n 18: iload_1\n 19: ireturn\n\n private static final int main$play2(Day14Kt$main$Cave);\n Code:\n 0: aload_0\n 1: invokevirtual #219 // Method Day14Kt$main$Cave.getBounds:()Lkotlin/Pair;\n 4: invokevirtual #227 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 7: checkcast #116 // class Point\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: getstatic #10 // Field caveSize:I\n 16: istore_3\n 17: iload_2\n 18: iload_3\n 19: if_icmpge 44\n 22: aload_0\n 23: invokevirtual #181 // Method Day14Kt$main$Cave.getMap:()[[LCaveCell;\n 26: iload_2\n 27: aaload\n 28: aload_1\n 29: invokevirtual #143 // Method Point.getY:()I\n 32: iconst_2\n 33: iadd\n 34: getstatic #184 // Field CaveCell.Rock:LCaveCell;\n 37: aastore\n 38: iinc 2, 1\n 41: goto 17\n 44: iconst_0\n 45: istore_2\n 46: aload_0\n 47: invokestatic #270 // Method main$playSand:(LDay14Kt$main$Cave;)LSandFallResult;\n 50: getstatic #264 // Field SandFallResult.Fall:LSandFallResult;\n 53: if_acmpeq 78\n 56: aload_0\n 57: invokevirtual #181 // Method Day14Kt$main$Cave.getMap:()[[LCaveCell;\n 60: sipush 500\n 63: aaload\n 64: iconst_0\n 65: aaload\n 66: getstatic #255 // Field CaveCell.Sand:LCaveCell;\n 69: if_acmpeq 78\n 72: iinc 2, 1\n 75: goto 46\n 78: iload_2\n 79: iconst_1\n 80: iadd\n 81: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #275 // Method main$parse:(Ljava/util/List;)LDay14Kt$main$Cave;\n 4: astore_1\n 5: aload_1\n 6: invokestatic #277 // Method main$play1:(LDay14Kt$main$Cave;)I\n 9: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #275 // Method main$parse:(Ljava/util/List;)LDay14Kt$main$Cave;\n 4: astore_1\n 5: aload_1\n 6: invokestatic #279 // Method main$play2:(LDay14Kt$main$Cave;)I\n 9: ireturn\n\n static {};\n Code:\n 0: sipush 1000\n 3: putstatic #10 // Field caveSize:I\n 6: return\n}\n",
"javap_err": ""
},
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day14Kt$main$Cave.class",
"javap": "Compiled from \"Day14.kt\"\npublic final class Day14Kt$main$Cave {\n private final CaveCell[][] map;\n\n public Day14Kt$main$Cave(CaveCell[][]);\n Code:\n 0: aload_1\n 1: ldc #8 // String map\n 3: invokestatic #14 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokespecial #17 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: aload_1\n 12: putfield #20 // Field map:[[LCaveCell;\n 15: return\n\n public final CaveCell[][] getMap();\n Code:\n 0: aload_0\n 1: getfield #20 // Field map:[[LCaveCell;\n 4: areturn\n\n public final kotlin.Pair<Point, Point> getBounds();\n Code:\n 0: invokestatic #33 // Method Day14Kt.getCaveSize:()I\n 3: istore_1\n 4: invokestatic #33 // Method Day14Kt.getCaveSize:()I\n 7: istore_2\n 8: iconst_0\n 9: istore_3\n 10: iconst_0\n 11: istore 4\n 13: iconst_0\n 14: istore 5\n 16: invokestatic #33 // Method Day14Kt.getCaveSize:()I\n 19: istore 6\n 21: iload 5\n 23: iload 6\n 25: if_icmpge 101\n 28: iconst_0\n 29: istore 7\n 31: invokestatic #33 // Method Day14Kt.getCaveSize:()I\n 34: istore 8\n 36: iload 7\n 38: iload 8\n 40: if_icmpge 95\n 43: aload_0\n 44: getfield #20 // Field map:[[LCaveCell;\n 47: iload 7\n 49: aaload\n 50: iload 5\n 52: aaload\n 53: getstatic #39 // Field CaveCell.Air:LCaveCell;\n 56: if_acmpeq 89\n 59: iload_1\n 60: iload 7\n 62: invokestatic #45 // Method java/lang/Math.min:(II)I\n 65: istore_1\n 66: iload_2\n 67: iload 5\n 69: invokestatic #45 // Method java/lang/Math.min:(II)I\n 72: istore_2\n 73: iload_3\n 74: iload 7\n 76: invokestatic #48 // Method java/lang/Math.max:(II)I\n 79: istore_3\n 80: iload 4\n 82: iload 5\n 84: invokestatic #48 // Method java/lang/Math.max:(II)I\n 87: istore 4\n 89: iinc 7, 1\n 92: goto 36\n 95: iinc 5, 1\n 98: goto 21\n 101: new #50 // class Point\n 104: dup\n 105: iload_1\n 106: iload_2\n 107: invokespecial #53 // Method Point.\"<init>\":(II)V\n 110: new #50 // class Point\n 113: dup\n 114: iload_3\n 115: iload 4\n 117: invokespecial #53 // Method Point.\"<init>\":(II)V\n 120: invokestatic #59 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 123: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day14Kt$WhenMappings.class",
"javap": "Compiled from \"Day14.kt\"\npublic final class Day14Kt$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method CaveCell.values:()[LCaveCell;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field CaveCell.Air:LCaveCell;\n 12: invokevirtual #22 // Method CaveCell.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 CaveCell.Rock:LCaveCell;\n 26: invokevirtual #22 // Method CaveCell.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 CaveCell.Sand:LCaveCell;\n 40: invokevirtual #22 // Method CaveCell.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": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day04.kt
|
fun main() {
fun parse(lines: List<String>): List<Pair<Interval, Interval>> {
return lines.map { line ->
val intervals = line
.split(',')
.map { range ->
val rangeParts = range.split('-')
Interval(rangeParts[0].toInt(), rangeParts[1].toInt())
}
intervals[0]to intervals[1]
}
}
fun part1(input: List<String>): Int {
return parse(input)
.filter { (left, right) -> left.hasFullOverlap(right) }
.size
}
fun part2(input: List<String>): Int {
return parse(input)
.filter { (left, right) -> left.hasOverlap(right) }
.size
}
val testInput = readInput("Day04_test")
assert(part1(testInput), 2)
assert(part2(testInput), 4)
val input = readInput("Day04")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/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 #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: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 13: iconst_2\n 14: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 17: invokestatic #28 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 20: aload_0\n 21: invokestatic #31 // Method main$part2:(Ljava/util/List;)I\n 24: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 27: iconst_4\n 28: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 31: invokestatic #28 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 34: ldc #33 // String Day04\n 36: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 39: astore_1\n 40: aload_1\n 41: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 44: istore_2\n 45: getstatic #39 // Field java/lang/System.out:Ljava/io/PrintStream;\n 48: iload_2\n 49: invokevirtual #45 // Method java/io/PrintStream.println:(I)V\n 52: aload_1\n 53: invokestatic #31 // Method main$part2:(Ljava/util/List;)I\n 56: istore_2\n 57: getstatic #39 // Field java/lang/System.out:Ljava/io/PrintStream;\n 60: iload_2\n 61: invokevirtual #45 // Method java/io/PrintStream.println:(I)V\n 64: 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 java.util.List<kotlin.Pair<Interval, Interval>> main$parse(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #58 // 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 #60 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #66 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #69 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #71 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 288\n 48: aload 6\n 50: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #87 // class java/lang/String\n 64: astore 8\n 66: astore 23\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: checkcast #89 // class java/lang/CharSequence\n 76: iconst_1\n 77: newarray char\n 79: astore 10\n 81: aload 10\n 83: iconst_0\n 84: bipush 44\n 86: castore\n 87: aload 10\n 89: iconst_0\n 90: iconst_0\n 91: bipush 6\n 93: aconst_null\n 94: invokestatic #95 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 97: checkcast #58 // class java/lang/Iterable\n 100: astore 10\n 102: nop\n 103: iconst_0\n 104: istore 11\n 106: aload 10\n 108: astore 12\n 110: new #60 // class java/util/ArrayList\n 113: dup\n 114: aload 10\n 116: bipush 10\n 118: invokestatic #66 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 121: invokespecial #69 // Method java/util/ArrayList.\"<init>\":(I)V\n 124: checkcast #71 // class java/util/Collection\n 127: astore 13\n 129: iconst_0\n 130: istore 14\n 132: aload 12\n 134: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 139: astore 15\n 141: aload 15\n 143: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 148: ifeq 249\n 151: aload 15\n 153: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 158: astore 16\n 160: aload 13\n 162: aload 16\n 164: checkcast #87 // class java/lang/String\n 167: astore 17\n 169: astore 18\n 171: iconst_0\n 172: istore 19\n 174: aload 17\n 176: checkcast #89 // class java/lang/CharSequence\n 179: iconst_1\n 180: newarray char\n 182: astore 20\n 184: aload 20\n 186: iconst_0\n 187: bipush 45\n 189: castore\n 190: aload 20\n 192: iconst_0\n 193: iconst_0\n 194: bipush 6\n 196: aconst_null\n 197: invokestatic #95 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 200: astore 21\n 202: new #97 // class Interval\n 205: dup\n 206: aload 21\n 208: iconst_0\n 209: invokeinterface #103, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 214: checkcast #87 // class java/lang/String\n 217: invokestatic #107 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 220: aload 21\n 222: iconst_1\n 223: invokeinterface #103, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 228: checkcast #87 // class java/lang/String\n 231: invokestatic #107 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 234: invokespecial #110 // Method Interval.\"<init>\":(II)V\n 237: aload 18\n 239: swap\n 240: invokeinterface #114, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 245: pop\n 246: goto 141\n 249: aload 13\n 251: checkcast #99 // class java/util/List\n 254: nop\n 255: astore 22\n 257: aload 22\n 259: iconst_0\n 260: invokeinterface #103, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 265: aload 22\n 267: iconst_1\n 268: invokeinterface #103, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 273: invokestatic #120 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 276: aload 23\n 278: swap\n 279: invokeinterface #114, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 284: pop\n 285: goto 38\n 288: aload 4\n 290: checkcast #99 // class java/util/List\n 293: nop\n 294: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #141 // Method main$parse:(Ljava/util/List;)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: invokespecial #143 // Method java/util/ArrayList.\"<init>\":()V\n 20: checkcast #71 // class java/util/Collection\n 23: astore 4\n 25: iconst_0\n 26: istore 5\n 28: aload_3\n 29: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 34: astore 6\n 36: aload 6\n 38: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 43: ifeq 108\n 46: aload 6\n 48: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 53: astore 7\n 55: aload 7\n 57: checkcast #145 // class kotlin/Pair\n 60: astore 8\n 62: iconst_0\n 63: istore 9\n 65: aload 8\n 67: invokevirtual #148 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 70: checkcast #97 // class Interval\n 73: astore 10\n 75: aload 8\n 77: invokevirtual #151 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 80: checkcast #97 // class Interval\n 83: astore 11\n 85: aload 10\n 87: aload 11\n 89: invokevirtual #155 // Method Interval.hasFullOverlap:(LInterval;)Z\n 92: ifeq 36\n 95: aload 4\n 97: aload 7\n 99: invokeinterface #114, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 104: pop\n 105: goto 36\n 108: aload 4\n 110: checkcast #99 // class java/util/List\n 113: nop\n 114: invokeinterface #159, 1 // InterfaceMethod java/util/List.size:()I\n 119: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #141 // Method main$parse:(Ljava/util/List;)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: invokespecial #143 // Method java/util/ArrayList.\"<init>\":()V\n 20: checkcast #71 // class java/util/Collection\n 23: astore 4\n 25: iconst_0\n 26: istore 5\n 28: aload_3\n 29: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 34: astore 6\n 36: aload 6\n 38: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 43: ifeq 108\n 46: aload 6\n 48: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 53: astore 7\n 55: aload 7\n 57: checkcast #145 // class kotlin/Pair\n 60: astore 8\n 62: iconst_0\n 63: istore 9\n 65: aload 8\n 67: invokevirtual #148 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 70: checkcast #97 // class Interval\n 73: astore 10\n 75: aload 8\n 77: invokevirtual #151 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 80: checkcast #97 // class Interval\n 83: astore 11\n 85: aload 10\n 87: aload 11\n 89: invokevirtual #171 // Method Interval.hasOverlap:(LInterval;)Z\n 92: ifeq 36\n 95: aload 4\n 97: aload 7\n 99: invokeinterface #114, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 104: pop\n 105: goto 36\n 108: aload 4\n 110: checkcast #99 // class java/util/List\n 113: nop\n 114: invokeinterface #159, 1 // InterfaceMethod java/util/List.size:()I\n 119: ireturn\n}\n",
"javap_err": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day18.kt
|
import kotlin.time.ExperimentalTime
import kotlin.time.measureTime
class Day18 {
data class Point(val xs: Array<Int>) {
fun isBetween(minPoint: Point, maxPoint: Point): Boolean {
return xs
.zip(minPoint.xs)
.zip(maxPoint.xs)
.all { p ->
val x = p.first.first
val min = p.first.second
val max = p.second
x in min..max
}
}
fun add(index: Int, value: Int): Point {
val new = xs.copyOf()
new[index] += value
return Point(new)
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as Point
if (!xs.contentEquals(other.xs)) return false
return true
}
override fun hashCode(): Int {
return xs.contentHashCode()
}
}
fun parse(input: List<String>): Set<Point> {
return input.map { line ->
val xs = line.split(',').map { it.toInt() }.toTypedArray()
Point(xs)
}.toSet()
}
fun getNeighbors(point: Point): Set<Point> {
val range = listOf(-1, 1)
return point.xs.flatMapIndexed { index, _ -> range.map { dx -> point.add(index, dx) } }.toSet()
}
fun part1(input: List<String>): String {
val points = parse(input)
var result = 0L
for (point in points) {
var coverage = 6
val neighbors = getNeighbors(point)
coverage -= neighbors.count { points.contains(it) }
result += coverage
}
return result.toString()
}
fun part2(input: List<String>): String {
val points = parse(input)
var result = 0L
val dimension = points.first().xs.size
val max = (0 until dimension).map { d -> points.maxOf { p -> p.xs[d] } }
val min = (0 until dimension).map { d -> points.minOf { p -> p.xs[d] } }
val maxPoint = Point(max.map { it + 1 }.toTypedArray())
val minPoint = Point(min.map { it - 1 }.toTypedArray())
val visited = mutableSetOf<Point>()
val q = ArrayDeque(listOf(minPoint))
while (q.isNotEmpty()) {
val point = q.removeFirst()
val neighbors = getNeighbors(point).filter { n -> n.isBetween(minPoint, maxPoint) }
for (neighbor in neighbors) {
if (neighbor in points) {
++result
} else if (neighbor !in visited) {
visited.add(neighbor)
q.addLast(neighbor)
}
}
}
return result.toString()
}
}
@OptIn(ExperimentalTime::class)
@Suppress("DuplicatedCode")
fun main() {
val solution = Day18()
val name = solution.javaClass.name
fun test() {
val expected1 = "64"
val expected2 = "58"
val testInput = readInput("${name}_test")
println("Test part 1")
assert(solution.part1(testInput), expected1)
println("> Passed")
println("Test part 2")
assert(solution.part2(testInput), expected2)
println("> Passed")
println()
println("=================================")
println()
}
fun run() {
val input = readInput(name)
val elapsed1 = measureTime {
println("Part 1: " + solution.part1(input))
}
println("Elapsed: $elapsed1")
println()
val elapsed2 = measureTime {
println("Part 2: " + solution.part2(input))
}
println("Elapsed: $elapsed2")
println()
}
test()
run()
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day18$Point.class",
"javap": "Compiled from \"Day18.kt\"\npublic final class Day18$Point {\n private final java.lang.Integer[] xs;\n\n public Day18$Point(java.lang.Integer[]);\n Code:\n 0: aload_1\n 1: ldc #9 // String xs\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 xs:[Ljava/lang/Integer;\n 15: return\n\n public final java.lang.Integer[] getXs();\n Code:\n 0: aload_0\n 1: getfield #21 // Field xs:[Ljava/lang/Integer;\n 4: areturn\n\n public final boolean isBetween(Day18$Point, Day18$Point);\n Code:\n 0: aload_1\n 1: ldc #29 // String minPoint\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #31 // String maxPoint\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: getfield #21 // Field xs:[Ljava/lang/Integer;\n 16: aload_1\n 17: getfield #21 // Field xs:[Ljava/lang/Integer;\n 20: invokestatic #37 // Method kotlin/collections/ArraysKt.zip:([Ljava/lang/Object;[Ljava/lang/Object;)Ljava/util/List;\n 23: checkcast #39 // class java/lang/Iterable\n 26: aload_2\n 27: getfield #21 // Field xs:[Ljava/lang/Integer;\n 30: invokestatic #44 // Method kotlin/collections/CollectionsKt.zip:(Ljava/lang/Iterable;[Ljava/lang/Object;)Ljava/util/List;\n 33: checkcast #39 // class java/lang/Iterable\n 36: astore_3\n 37: nop\n 38: iconst_0\n 39: istore 4\n 41: aload_3\n 42: instanceof #46 // class java/util/Collection\n 45: ifeq 64\n 48: aload_3\n 49: checkcast #46 // class java/util/Collection\n 52: invokeinterface #50, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 57: ifeq 64\n 60: iconst_1\n 61: goto 183\n 64: aload_3\n 65: invokeinterface #54, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 70: astore 5\n 72: aload 5\n 74: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 79: ifeq 182\n 82: aload 5\n 84: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 89: astore 6\n 91: aload 6\n 93: checkcast #65 // class kotlin/Pair\n 96: astore 7\n 98: iconst_0\n 99: istore 8\n 101: aload 7\n 103: invokevirtual #68 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 106: checkcast #65 // class kotlin/Pair\n 109: invokevirtual #68 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 112: checkcast #70 // class java/lang/Number\n 115: invokevirtual #74 // Method java/lang/Number.intValue:()I\n 118: istore 9\n 120: aload 7\n 122: invokevirtual #68 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 125: checkcast #65 // class kotlin/Pair\n 128: invokevirtual #77 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 131: checkcast #70 // class java/lang/Number\n 134: invokevirtual #74 // Method java/lang/Number.intValue:()I\n 137: istore 10\n 139: aload 7\n 141: invokevirtual #77 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 144: checkcast #70 // class java/lang/Number\n 147: invokevirtual #74 // Method java/lang/Number.intValue:()I\n 150: istore 11\n 152: iload 10\n 154: iload 9\n 156: if_icmpgt 174\n 159: iload 9\n 161: iload 11\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: ifne 72\n 178: iconst_0\n 179: goto 183\n 182: iconst_1\n 183: ireturn\n\n public final Day18$Point add(int, int);\n Code:\n 0: aload_0\n 1: getfield #21 // Field xs:[Ljava/lang/Integer;\n 4: dup\n 5: arraylength\n 6: invokestatic #97 // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;\n 9: dup\n 10: ldc #99 // String copyOf(...)\n 12: invokestatic #102 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 15: checkcast #103 // class \"[Ljava/lang/Integer;\"\n 18: astore_3\n 19: aload_3\n 20: iload_1\n 21: aload_3\n 22: iload_1\n 23: aaload\n 24: invokevirtual #106 // Method java/lang/Integer.intValue:()I\n 27: iload_2\n 28: iadd\n 29: invokestatic #110 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 32: aastore\n 33: new #2 // class Day18$Point\n 36: dup\n 37: aload_3\n 38: invokespecial #112 // Method \"<init>\":([Ljava/lang/Integer;)V\n 41: areturn\n\n public boolean equals(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: if_acmpne 7\n 5: iconst_1\n 6: ireturn\n 7: aload_0\n 8: invokevirtual #122 // Method java/lang/Object.getClass:()Ljava/lang/Class;\n 11: aload_1\n 12: dup\n 13: ifnull 22\n 16: invokevirtual #122 // Method java/lang/Object.getClass:()Ljava/lang/Class;\n 19: goto 24\n 22: pop\n 23: aconst_null\n 24: invokestatic #126 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 27: ifne 32\n 30: iconst_0\n 31: ireturn\n 32: aload_1\n 33: ldc #128 // String null cannot be cast to non-null type <root>.Day18.Point\n 35: invokestatic #131 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V\n 38: aload_1\n 39: checkcast #2 // class Day18$Point\n 42: pop\n 43: aload_0\n 44: getfield #21 // Field xs:[Ljava/lang/Integer;\n 47: aload_1\n 48: checkcast #2 // class Day18$Point\n 51: getfield #21 // Field xs:[Ljava/lang/Integer;\n 54: invokestatic #134 // Method java/util/Arrays.equals:([Ljava/lang/Object;[Ljava/lang/Object;)Z\n 57: ifne 62\n 60: iconst_0\n 61: ireturn\n 62: iconst_1\n 63: ireturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #21 // Field xs:[Ljava/lang/Integer;\n 4: invokestatic #141 // Method java/util/Arrays.hashCode:([Ljava/lang/Object;)I\n 7: ireturn\n\n public final java.lang.Integer[] component1();\n Code:\n 0: aload_0\n 1: getfield #21 // Field xs:[Ljava/lang/Integer;\n 4: areturn\n\n public final Day18$Point copy(java.lang.Integer[]);\n Code:\n 0: aload_1\n 1: ldc #9 // String xs\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class Day18$Point\n 9: dup\n 10: aload_1\n 11: invokespecial #112 // Method \"<init>\":([Ljava/lang/Integer;)V\n 14: areturn\n\n public static Day18$Point copy$default(Day18$Point, java.lang.Integer[], int, java.lang.Object);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: iand\n 3: ifeq 11\n 6: aload_0\n 7: getfield #21 // Field xs:[Ljava/lang/Integer;\n 10: astore_1\n 11: aload_0\n 12: aload_1\n 13: invokevirtual #148 // Method copy:([Ljava/lang/Integer;)LDay18$Point;\n 16: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #152 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #153 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #155 // String Point(xs=\n 9: invokevirtual #159 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #21 // Field xs:[Ljava/lang/Integer;\n 16: invokestatic #162 // Method java/util/Arrays.toString:([Ljava/lang/Object;)Ljava/lang/String;\n 19: invokevirtual #159 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 22: bipush 41\n 24: invokevirtual #165 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 27: invokevirtual #167 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 30: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day18.class",
"javap": "Compiled from \"Day18.kt\"\npublic final class Day18 {\n public Day18();\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.Set<Day18$Point> parse(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #24 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: astore 4\n 16: new #26 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: bipush 10\n 23: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #37 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: aload 4\n 39: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 7\n 46: aload 7\n 48: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 258\n 56: aload 7\n 58: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 8\n 65: aload 5\n 67: aload 8\n 69: checkcast #53 // class java/lang/String\n 72: astore 9\n 74: astore 22\n 76: iconst_0\n 77: istore 10\n 79: aload 9\n 81: checkcast #55 // class java/lang/CharSequence\n 84: iconst_1\n 85: newarray char\n 87: astore 11\n 89: aload 11\n 91: iconst_0\n 92: bipush 44\n 94: castore\n 95: aload 11\n 97: iconst_0\n 98: iconst_0\n 99: bipush 6\n 101: aconst_null\n 102: invokestatic #61 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 105: checkcast #24 // class java/lang/Iterable\n 108: astore 11\n 110: iconst_0\n 111: istore 12\n 113: aload 11\n 115: astore 13\n 117: new #26 // class java/util/ArrayList\n 120: dup\n 121: aload 11\n 123: bipush 10\n 125: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 128: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 131: checkcast #37 // class java/util/Collection\n 134: astore 14\n 136: iconst_0\n 137: istore 15\n 139: aload 13\n 141: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 146: astore 16\n 148: aload 16\n 150: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 155: ifeq 202\n 158: aload 16\n 160: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 165: astore 17\n 167: aload 14\n 169: aload 17\n 171: checkcast #53 // class java/lang/String\n 174: astore 18\n 176: astore 19\n 178: iconst_0\n 179: istore 20\n 181: aload 18\n 183: invokestatic #67 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 186: nop\n 187: invokestatic #71 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 190: aload 19\n 192: swap\n 193: invokeinterface #75, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 198: pop\n 199: goto 148\n 202: aload 14\n 204: checkcast #77 // class java/util/List\n 207: nop\n 208: checkcast #37 // class java/util/Collection\n 211: astore 11\n 213: nop\n 214: iconst_0\n 215: istore 12\n 217: aload 11\n 219: astore 13\n 221: aload 13\n 223: iconst_0\n 224: anewarray #63 // class java/lang/Integer\n 227: invokeinterface #81, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 232: checkcast #83 // class \"[Ljava/lang/Integer;\"\n 235: astore 21\n 237: new #85 // class Day18$Point\n 240: dup\n 241: aload 21\n 243: invokespecial #88 // Method Day18$Point.\"<init>\":([Ljava/lang/Integer;)V\n 246: aload 22\n 248: swap\n 249: invokeinterface #75, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 254: pop\n 255: goto 46\n 258: aload 5\n 260: checkcast #77 // class java/util/List\n 263: nop\n 264: checkcast #24 // class java/lang/Iterable\n 267: invokestatic #92 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 270: areturn\n\n public final java.util.Set<Day18$Point> getNeighbors(Day18$Point);\n Code:\n 0: aload_1\n 1: ldc #117 // String point\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_2\n 7: anewarray #63 // class java/lang/Integer\n 10: astore_3\n 11: aload_3\n 12: iconst_0\n 13: iconst_m1\n 14: invokestatic #71 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 17: aastore\n 18: aload_3\n 19: iconst_1\n 20: iconst_1\n 21: invokestatic #71 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 24: aastore\n 25: aload_3\n 26: invokestatic #121 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 29: astore_2\n 30: aload_1\n 31: invokevirtual #125 // Method Day18$Point.getXs:()[Ljava/lang/Integer;\n 34: astore 4\n 36: new #26 // class java/util/ArrayList\n 39: dup\n 40: invokespecial #126 // Method java/util/ArrayList.\"<init>\":()V\n 43: checkcast #37 // class java/util/Collection\n 46: astore 5\n 48: iconst_0\n 49: istore 6\n 51: iconst_0\n 52: istore 7\n 54: aload 4\n 56: arraylength\n 57: istore 8\n 59: iload 7\n 61: iload 8\n 63: if_icmpge 215\n 66: aload 4\n 68: iload 7\n 70: aaload\n 71: astore 9\n 73: iload 6\n 75: iinc 6, 1\n 78: aload 9\n 80: checkcast #128 // class java/lang/Number\n 83: invokevirtual #132 // Method java/lang/Number.intValue:()I\n 86: pop\n 87: istore 10\n 89: iconst_0\n 90: istore 11\n 92: aload_2\n 93: checkcast #24 // class java/lang/Iterable\n 96: astore 12\n 98: iconst_0\n 99: istore 13\n 101: aload 12\n 103: astore 14\n 105: new #26 // class java/util/ArrayList\n 108: dup\n 109: aload 12\n 111: bipush 10\n 113: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 116: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 119: checkcast #37 // class java/util/Collection\n 122: astore 15\n 124: iconst_0\n 125: istore 16\n 127: aload 14\n 129: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 134: astore 17\n 136: aload 17\n 138: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 143: ifeq 192\n 146: aload 17\n 148: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 153: astore 18\n 155: aload 15\n 157: aload 18\n 159: checkcast #128 // class java/lang/Number\n 162: invokevirtual #132 // Method java/lang/Number.intValue:()I\n 165: istore 19\n 167: astore 20\n 169: iconst_0\n 170: istore 21\n 172: aload_1\n 173: iload 10\n 175: iload 19\n 177: invokevirtual #135 // Method Day18$Point.add:(II)LDay18$Point;\n 180: aload 20\n 182: swap\n 183: invokeinterface #75, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 188: pop\n 189: goto 136\n 192: aload 15\n 194: checkcast #77 // class java/util/List\n 197: nop\n 198: checkcast #24 // class java/lang/Iterable\n 201: nop\n 202: aload 5\n 204: swap\n 205: invokestatic #139 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 208: pop\n 209: iinc 7, 1\n 212: goto 59\n 215: aload 5\n 217: checkcast #77 // class java/util/List\n 220: checkcast #24 // class java/lang/Iterable\n 223: invokestatic #92 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 226: areturn\n\n public final java.lang.String part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokevirtual #150 // Method parse:(Ljava/util/List;)Ljava/util/Set;\n 11: astore_2\n 12: lconst_0\n 13: lstore_3\n 14: aload_2\n 15: invokeinterface #153, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 20: astore 5\n 22: aload 5\n 24: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 29: ifeq 181\n 32: aload 5\n 34: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 39: checkcast #85 // class Day18$Point\n 42: astore 6\n 44: bipush 6\n 46: istore 7\n 48: aload_0\n 49: aload 6\n 51: invokevirtual #155 // Method getNeighbors:(LDay18$Point;)Ljava/util/Set;\n 54: astore 8\n 56: iload 7\n 58: aload 8\n 60: checkcast #24 // class java/lang/Iterable\n 63: astore 9\n 65: istore 16\n 67: iconst_0\n 68: istore 10\n 70: aload 9\n 72: instanceof #37 // class java/util/Collection\n 75: ifeq 95\n 78: aload 9\n 80: checkcast #37 // class java/util/Collection\n 83: invokeinterface #158, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 88: ifeq 95\n 91: iconst_0\n 92: goto 163\n 95: iconst_0\n 96: istore 11\n 98: aload 9\n 100: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 105: astore 12\n 107: aload 12\n 109: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 114: ifeq 161\n 117: aload 12\n 119: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 124: astore 13\n 126: aload 13\n 128: checkcast #85 // class Day18$Point\n 131: astore 14\n 133: iconst_0\n 134: istore 15\n 136: aload_2\n 137: aload 14\n 139: invokeinterface #161, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 144: ifeq 107\n 147: iinc 11, 1\n 150: iload 11\n 152: ifge 107\n 155: invokestatic #164 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 158: goto 107\n 161: iload 11\n 163: istore 17\n 165: iload 16\n 167: iload 17\n 169: isub\n 170: istore 7\n 172: lload_3\n 173: iload 7\n 175: i2l\n 176: ladd\n 177: lstore_3\n 178: goto 22\n 181: lload_3\n 182: invokestatic #167 // Method java/lang/String.valueOf:(J)Ljava/lang/String;\n 185: areturn\n\n public final java.lang.String part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokevirtual #150 // Method parse:(Ljava/util/List;)Ljava/util/Set;\n 11: astore_2\n 12: lconst_0\n 13: lstore_3\n 14: aload_2\n 15: checkcast #24 // class java/lang/Iterable\n 18: invokestatic #183 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 21: checkcast #85 // class Day18$Point\n 24: invokevirtual #125 // Method Day18$Point.getXs:()[Ljava/lang/Integer;\n 27: arraylength\n 28: istore 5\n 30: iconst_0\n 31: iload 5\n 33: invokestatic #189 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 36: checkcast #24 // class java/lang/Iterable\n 39: astore 7\n 41: iconst_0\n 42: istore 8\n 44: aload 7\n 46: astore 9\n 48: new #26 // class java/util/ArrayList\n 51: dup\n 52: aload 7\n 54: bipush 10\n 56: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 59: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 62: checkcast #37 // class java/util/Collection\n 65: astore 10\n 67: iconst_0\n 68: istore 11\n 70: aload 9\n 72: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 77: astore 12\n 79: aload 12\n 81: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 86: ifeq 237\n 89: aload 12\n 91: checkcast #191 // class kotlin/collections/IntIterator\n 94: invokevirtual #194 // Method kotlin/collections/IntIterator.nextInt:()I\n 97: istore 13\n 99: aload 10\n 101: iload 13\n 103: istore 14\n 105: astore 23\n 107: iconst_0\n 108: istore 15\n 110: aload_2\n 111: checkcast #24 // class java/lang/Iterable\n 114: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 119: astore 16\n 121: aload 16\n 123: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 128: ifne 139\n 131: new #196 // class java/util/NoSuchElementException\n 134: dup\n 135: invokespecial #197 // Method java/util/NoSuchElementException.\"<init>\":()V\n 138: athrow\n 139: aload 16\n 141: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 146: checkcast #85 // class Day18$Point\n 149: astore 17\n 151: iconst_0\n 152: istore 18\n 154: aload 17\n 156: invokevirtual #125 // Method Day18$Point.getXs:()[Ljava/lang/Integer;\n 159: iload 14\n 161: aaload\n 162: invokevirtual #198 // Method java/lang/Integer.intValue:()I\n 165: istore 17\n 167: aload 16\n 169: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 174: ifeq 219\n 177: aload 16\n 179: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 184: checkcast #85 // class Day18$Point\n 187: astore 18\n 189: iconst_0\n 190: istore 19\n 192: aload 18\n 194: invokevirtual #125 // Method Day18$Point.getXs:()[Ljava/lang/Integer;\n 197: iload 14\n 199: aaload\n 200: invokevirtual #198 // Method java/lang/Integer.intValue:()I\n 203: istore 18\n 205: iload 17\n 207: iload 18\n 209: if_icmpge 167\n 212: iload 18\n 214: istore 17\n 216: goto 167\n 219: iload 17\n 221: nop\n 222: invokestatic #71 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 225: aload 23\n 227: swap\n 228: invokeinterface #75, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 233: pop\n 234: goto 79\n 237: aload 10\n 239: checkcast #77 // class java/util/List\n 242: nop\n 243: astore 6\n 245: iconst_0\n 246: iload 5\n 248: invokestatic #189 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 251: checkcast #24 // class java/lang/Iterable\n 254: astore 8\n 256: iconst_0\n 257: istore 9\n 259: aload 8\n 261: astore 10\n 263: new #26 // class java/util/ArrayList\n 266: dup\n 267: aload 8\n 269: bipush 10\n 271: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 274: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 277: checkcast #37 // class java/util/Collection\n 280: astore 11\n 282: iconst_0\n 283: istore 12\n 285: aload 10\n 287: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 292: astore 13\n 294: aload 13\n 296: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 301: ifeq 452\n 304: aload 13\n 306: checkcast #191 // class kotlin/collections/IntIterator\n 309: invokevirtual #194 // Method kotlin/collections/IntIterator.nextInt:()I\n 312: istore 14\n 314: aload 11\n 316: iload 14\n 318: istore 15\n 320: astore 23\n 322: iconst_0\n 323: istore 16\n 325: aload_2\n 326: checkcast #24 // class java/lang/Iterable\n 329: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 334: astore 17\n 336: aload 17\n 338: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 343: ifne 354\n 346: new #196 // class java/util/NoSuchElementException\n 349: dup\n 350: invokespecial #197 // Method java/util/NoSuchElementException.\"<init>\":()V\n 353: athrow\n 354: aload 17\n 356: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 361: checkcast #85 // class Day18$Point\n 364: astore 18\n 366: iconst_0\n 367: istore 19\n 369: aload 18\n 371: invokevirtual #125 // Method Day18$Point.getXs:()[Ljava/lang/Integer;\n 374: iload 15\n 376: aaload\n 377: invokevirtual #198 // Method java/lang/Integer.intValue:()I\n 380: istore 18\n 382: aload 17\n 384: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 389: ifeq 434\n 392: aload 17\n 394: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 399: checkcast #85 // class Day18$Point\n 402: astore 19\n 404: iconst_0\n 405: istore 20\n 407: aload 19\n 409: invokevirtual #125 // Method Day18$Point.getXs:()[Ljava/lang/Integer;\n 412: iload 15\n 414: aaload\n 415: invokevirtual #198 // Method java/lang/Integer.intValue:()I\n 418: istore 19\n 420: iload 18\n 422: iload 19\n 424: if_icmple 382\n 427: iload 19\n 429: istore 18\n 431: goto 382\n 434: iload 18\n 436: nop\n 437: invokestatic #71 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 440: aload 23\n 442: swap\n 443: invokeinterface #75, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 448: pop\n 449: goto 294\n 452: aload 11\n 454: checkcast #77 // class java/util/List\n 457: nop\n 458: astore 7\n 460: aload 6\n 462: checkcast #24 // class java/lang/Iterable\n 465: astore 9\n 467: iconst_0\n 468: istore 10\n 470: aload 9\n 472: astore 11\n 474: new #26 // class java/util/ArrayList\n 477: dup\n 478: aload 9\n 480: bipush 10\n 482: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 485: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 488: checkcast #37 // class java/util/Collection\n 491: astore 12\n 493: iconst_0\n 494: istore 13\n 496: aload 11\n 498: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 503: astore 14\n 505: aload 14\n 507: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 512: ifeq 560\n 515: aload 14\n 517: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 522: astore 15\n 524: aload 12\n 526: aload 15\n 528: checkcast #128 // class java/lang/Number\n 531: invokevirtual #132 // Method java/lang/Number.intValue:()I\n 534: istore 16\n 536: astore 24\n 538: iconst_0\n 539: istore 17\n 541: iload 16\n 543: iconst_1\n 544: iadd\n 545: invokestatic #71 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 548: aload 24\n 550: swap\n 551: invokeinterface #75, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 556: pop\n 557: goto 505\n 560: aload 12\n 562: checkcast #77 // class java/util/List\n 565: nop\n 566: checkcast #37 // class java/util/Collection\n 569: astore 9\n 571: nop\n 572: iconst_0\n 573: istore 10\n 575: aload 9\n 577: astore 11\n 579: aload 11\n 581: iconst_0\n 582: anewarray #63 // class java/lang/Integer\n 585: invokeinterface #81, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 590: checkcast #83 // class \"[Ljava/lang/Integer;\"\n 593: astore 25\n 595: new #85 // class Day18$Point\n 598: dup\n 599: aload 25\n 601: invokespecial #88 // Method Day18$Point.\"<init>\":([Ljava/lang/Integer;)V\n 604: astore 8\n 606: aload 7\n 608: checkcast #24 // class java/lang/Iterable\n 611: astore 10\n 613: iconst_0\n 614: istore 11\n 616: aload 10\n 618: astore 12\n 620: new #26 // class java/util/ArrayList\n 623: dup\n 624: aload 10\n 626: bipush 10\n 628: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 631: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 634: checkcast #37 // class java/util/Collection\n 637: astore 13\n 639: iconst_0\n 640: istore 14\n 642: aload 12\n 644: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 649: astore 15\n 651: aload 15\n 653: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 658: ifeq 706\n 661: aload 15\n 663: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 668: astore 16\n 670: aload 13\n 672: aload 16\n 674: checkcast #128 // class java/lang/Number\n 677: invokevirtual #132 // Method java/lang/Number.intValue:()I\n 680: istore 17\n 682: astore 24\n 684: iconst_0\n 685: istore 18\n 687: iload 17\n 689: iconst_1\n 690: isub\n 691: invokestatic #71 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 694: aload 24\n 696: swap\n 697: invokeinterface #75, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 702: pop\n 703: goto 651\n 706: aload 13\n 708: checkcast #77 // class java/util/List\n 711: nop\n 712: checkcast #37 // class java/util/Collection\n 715: astore 10\n 717: nop\n 718: iconst_0\n 719: istore 11\n 721: aload 10\n 723: astore 12\n 725: aload 12\n 727: iconst_0\n 728: anewarray #63 // class java/lang/Integer\n 731: invokeinterface #81, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 736: checkcast #83 // class \"[Ljava/lang/Integer;\"\n 739: astore 26\n 741: new #85 // class Day18$Point\n 744: dup\n 745: aload 26\n 747: invokespecial #88 // Method Day18$Point.\"<init>\":([Ljava/lang/Integer;)V\n 750: astore 9\n 752: new #200 // class java/util/LinkedHashSet\n 755: dup\n 756: invokespecial #201 // Method java/util/LinkedHashSet.\"<init>\":()V\n 759: checkcast #152 // class java/util/Set\n 762: astore 10\n 764: new #203 // class kotlin/collections/ArrayDeque\n 767: dup\n 768: aload 9\n 770: invokestatic #206 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 773: checkcast #37 // class java/util/Collection\n 776: invokespecial #209 // Method kotlin/collections/ArrayDeque.\"<init>\":(Ljava/util/Collection;)V\n 779: astore 11\n 781: aload 11\n 783: checkcast #37 // class java/util/Collection\n 786: invokeinterface #158, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 791: ifne 798\n 794: iconst_1\n 795: goto 799\n 798: iconst_0\n 799: ifeq 997\n 802: aload 11\n 804: invokevirtual #212 // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;\n 807: checkcast #85 // class Day18$Point\n 810: astore 12\n 812: aload_0\n 813: aload 12\n 815: invokevirtual #155 // Method getNeighbors:(LDay18$Point;)Ljava/util/Set;\n 818: checkcast #24 // class java/lang/Iterable\n 821: astore 14\n 823: iconst_0\n 824: istore 15\n 826: aload 14\n 828: astore 16\n 830: new #26 // class java/util/ArrayList\n 833: dup\n 834: invokespecial #126 // Method java/util/ArrayList.\"<init>\":()V\n 837: checkcast #37 // class java/util/Collection\n 840: astore 17\n 842: iconst_0\n 843: istore 18\n 845: aload 16\n 847: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 852: astore 19\n 854: aload 19\n 856: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 861: ifeq 908\n 864: aload 19\n 866: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 871: astore 20\n 873: aload 20\n 875: checkcast #85 // class Day18$Point\n 878: astore 21\n 880: iconst_0\n 881: istore 22\n 883: aload 21\n 885: aload 9\n 887: aload 8\n 889: invokevirtual #216 // Method Day18$Point.isBetween:(LDay18$Point;LDay18$Point;)Z\n 892: ifeq 854\n 895: aload 17\n 897: aload 20\n 899: invokeinterface #75, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 904: pop\n 905: goto 854\n 908: aload 17\n 910: checkcast #77 // class java/util/List\n 913: nop\n 914: astore 13\n 916: aload 13\n 918: invokeinterface #217, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 923: astore 14\n 925: aload 14\n 927: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 932: ifeq 781\n 935: aload 14\n 937: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 942: checkcast #85 // class Day18$Point\n 945: astore 15\n 947: aload_2\n 948: aload 15\n 950: invokeinterface #161, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 955: ifeq 965\n 958: lload_3\n 959: lconst_1\n 960: ladd\n 961: lstore_3\n 962: goto 925\n 965: aload 10\n 967: aload 15\n 969: invokeinterface #161, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 974: ifne 925\n 977: aload 10\n 979: aload 15\n 981: invokeinterface #218, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 986: pop\n 987: aload 11\n 989: aload 15\n 991: invokevirtual #222 // Method kotlin/collections/ArrayDeque.addLast:(Ljava/lang/Object;)V\n 994: goto 925\n 997: lload_3\n 998: invokestatic #167 // Method java/lang/String.valueOf:(J)Ljava/lang/String;\n 1001: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day18Kt.class",
"javap": "Compiled from \"Day18.kt\"\npublic final class Day18Kt {\n public static final void main();\n Code:\n 0: new #8 // class Day18\n 3: dup\n 4: invokespecial #11 // Method Day18.\"<init>\":()V\n 7: astore_0\n 8: aload_0\n 9: invokevirtual #15 // Method java/lang/Object.getClass:()Ljava/lang/Class;\n 12: invokevirtual #21 // Method java/lang/Class.getName:()Ljava/lang/String;\n 15: astore_1\n 16: aload_1\n 17: aload_0\n 18: invokestatic #25 // Method main$test:(Ljava/lang/String;LDay18;)V\n 21: aload_1\n 22: aload_0\n 23: invokestatic #28 // Method main$run:(Ljava/lang/String;LDay18;)V\n 26: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #35 // Method main:()V\n 3: return\n\n private static final void main$test(java.lang.String, Day18);\n Code:\n 0: ldc #39 // String 64\n 2: astore_2\n 3: ldc #41 // String 58\n 5: astore_3\n 6: new #43 // class java/lang/StringBuilder\n 9: dup\n 10: invokespecial #44 // Method java/lang/StringBuilder.\"<init>\":()V\n 13: aload_0\n 14: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 17: ldc #50 // String _test\n 19: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 22: invokevirtual #53 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 25: invokestatic #59 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 28: astore 4\n 30: ldc #61 // String Test part 1\n 32: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 35: swap\n 36: invokevirtual #73 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 39: aload_1\n 40: aload 4\n 42: invokevirtual #77 // Method Day18.part1:(Ljava/util/List;)Ljava/lang/String;\n 45: aload_2\n 46: invokestatic #81 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 49: ldc #83 // String > Passed\n 51: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 54: swap\n 55: invokevirtual #73 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 58: ldc #85 // String Test part 2\n 60: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 63: swap\n 64: invokevirtual #73 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 67: aload_1\n 68: aload 4\n 70: invokevirtual #88 // Method Day18.part2:(Ljava/util/List;)Ljava/lang/String;\n 73: aload_3\n 74: invokestatic #81 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 77: ldc #83 // String > Passed\n 79: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 82: swap\n 83: invokevirtual #73 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 86: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 89: invokevirtual #90 // Method java/io/PrintStream.println:()V\n 92: ldc #92 // String =================================\n 94: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 97: swap\n 98: invokevirtual #73 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 101: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 104: invokevirtual #90 // Method java/io/PrintStream.println:()V\n 107: return\n\n private static final void main$run(java.lang.String, Day18);\n Code:\n 0: aload_0\n 1: invokestatic #101 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 4: aload_0\n 5: invokestatic #59 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 8: astore_2\n 9: iconst_0\n 10: istore 5\n 12: getstatic #107 // Field kotlin/time/TimeSource$Monotonic.INSTANCE:Lkotlin/time/TimeSource$Monotonic;\n 15: astore 6\n 17: iconst_0\n 18: istore 7\n 20: aload 6\n 22: invokevirtual #111 // Method kotlin/time/TimeSource$Monotonic.\"markNow-z9LOYto\":()J\n 25: lstore 8\n 27: iconst_0\n 28: istore 10\n 30: new #43 // class java/lang/StringBuilder\n 33: dup\n 34: invokespecial #44 // Method java/lang/StringBuilder.\"<init>\":()V\n 37: ldc #113 // String Part 1:\n 39: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 42: aload_1\n 43: aload_2\n 44: invokevirtual #77 // Method Day18.part1:(Ljava/util/List;)Ljava/lang/String;\n 47: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 50: invokevirtual #53 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 53: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 56: swap\n 57: invokevirtual #73 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 60: nop\n 61: nop\n 62: lload 8\n 64: invokestatic #119 // Method kotlin/time/TimeSource$Monotonic$ValueTimeMark.\"elapsedNow-UwyO8pc\":(J)J\n 67: nop\n 68: lstore_3\n 69: new #43 // class java/lang/StringBuilder\n 72: dup\n 73: invokespecial #44 // Method java/lang/StringBuilder.\"<init>\":()V\n 76: ldc #121 // String Elapsed:\n 78: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 81: lload_3\n 82: invokestatic #127 // Method kotlin/time/Duration.\"toString-impl\":(J)Ljava/lang/String;\n 85: invokevirtual #130 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 88: invokevirtual #53 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 91: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 94: swap\n 95: invokevirtual #73 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 98: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 101: invokevirtual #90 // Method java/io/PrintStream.println:()V\n 104: iconst_0\n 105: istore 7\n 107: getstatic #107 // Field kotlin/time/TimeSource$Monotonic.INSTANCE:Lkotlin/time/TimeSource$Monotonic;\n 110: astore 8\n 112: iconst_0\n 113: istore 9\n 115: aload 8\n 117: invokevirtual #111 // Method kotlin/time/TimeSource$Monotonic.\"markNow-z9LOYto\":()J\n 120: lstore 10\n 122: iconst_0\n 123: istore 12\n 125: new #43 // class java/lang/StringBuilder\n 128: dup\n 129: invokespecial #44 // Method java/lang/StringBuilder.\"<init>\":()V\n 132: ldc #132 // String Part 2:\n 134: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 137: aload_1\n 138: aload_2\n 139: invokevirtual #88 // Method Day18.part2:(Ljava/util/List;)Ljava/lang/String;\n 142: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 145: invokevirtual #53 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 148: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 151: swap\n 152: invokevirtual #73 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 155: nop\n 156: nop\n 157: lload 10\n 159: invokestatic #119 // Method kotlin/time/TimeSource$Monotonic$ValueTimeMark.\"elapsedNow-UwyO8pc\":(J)J\n 162: nop\n 163: lstore 5\n 165: new #43 // class java/lang/StringBuilder\n 168: dup\n 169: invokespecial #44 // Method java/lang/StringBuilder.\"<init>\":()V\n 172: ldc #121 // String Elapsed:\n 174: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 177: lload 5\n 179: invokestatic #127 // Method kotlin/time/Duration.\"toString-impl\":(J)Ljava/lang/String;\n 182: invokevirtual #130 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 185: invokevirtual #53 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 188: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 191: swap\n 192: invokevirtual #73 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 195: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 198: invokevirtual #90 // Method java/io/PrintStream.println:()V\n 201: return\n}\n",
"javap_err": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day24.kt
|
import kotlin.time.ExperimentalTime
import kotlin.time.measureTime
class Day24 {
data class Valley(val blizzards: Map<Point, List<Direction>>, val maxY: Int, val maxX: Int)
data class Moment(val expedition: Point, val minutesSpent: Int)
fun parse(input: List<String>): Valley {
val blizzards = mutableMapOf<Point, List<Direction>>()
val walls = mutableSetOf<Point>()
for ((y, line) in input.withIndex()) {
for ((x, cell) in line.withIndex()) {
when (cell) {
'#' -> walls.add(Point(x, y))
'>' -> blizzards[Point(x, y)] = listOf(Direction.Right)
'<' -> blizzards[Point(x, y)] = listOf(Direction.Left)
'^' -> blizzards[Point(x, y)] = listOf(Direction.Up)
'v' -> blizzards[Point(x, y)] = listOf(Direction.Down)
}
}
}
return Valley(blizzards, input.size - 1, input[0].length - 1)
}
fun nextPosition(direction: Direction, position: Point, valley: Valley): Point {
val d = when (direction) {
Direction.Up -> Point(0, -1)
Direction.Down -> Point(0, 1)
Direction.Left -> Point(-1, 0)
Direction.Right -> Point(1, 0)
}
val newPosition = position.sum(d)
if (newPosition.x <= 0) {
return Point(valley.maxX - 1, newPosition.y)
}
if (newPosition.x >= valley.maxX) {
return Point(1, newPosition.y)
}
if (newPosition.y <= 0) {
return Point(newPosition.x, valley.maxY - 1)
}
if (newPosition.y >= valley.maxY) {
return Point(newPosition.x, 1)
}
return newPosition
}
fun print(valley: Valley) {
for (y in 0..valley.maxY) {
for (x in 0..valley.maxX) {
val point = Point(x, y)
if (x == 0 || x == valley.maxX || y == 0 || y == valley.maxY) {
print('#')
} else if (point !in valley.blizzards.keys) {
print('.')
} else {
val directions = valley.blizzards[point]!!
if (directions.size == 1) {
when (directions.first()) {
Direction.Up -> print('^')
Direction.Down -> print('v')
Direction.Left -> print('<')
Direction.Right -> print('>')
}
} else {
print(directions.size)
}
}
}
println()
}
println()
}
fun next(valley: Valley): Valley {
val blizzards = valley.blizzards.flatMap { blizzard ->
blizzard.value.map { direction -> nextPosition(direction, blizzard.key, valley) to direction }
}.groupBy({ x -> x.first }, { x -> x.second })
val newValley = Valley(blizzards, valley.maxY, valley.maxX)
return newValley
}
fun getAvailableMoves(current: Point, start: Point, target: Point, valley: Valley): Set<Point> {
return listOf(
Point(0, 0), // wait
Point(0, -1),
Point(0, 1),
Point(-1, 0),
Point(1, 0)
)
.map { p -> p.sum(current) }
.filter { p ->
(p.x > 0 && p.x < valley.maxX && p.y > 0 && p.y < valley.maxY) ||
p == target || p == start
}
.filter { p -> !valley.blizzards.containsKey(p) }
.toSet()
}
fun search(start: Point, target: Point, initValleyState: Valley): Pair<Int, Valley> {
val valleyStates = mutableListOf(initValleyState)
print(initValleyState)
val q = ArrayDeque<Moment>()
val visited = mutableSetOf<Moment>()
val initMoment = Moment(start, 0)
q.addLast(initMoment)
visited.add(initMoment)
while (q.isNotEmpty()) {
val moment = q.removeFirst()
val nextMinute = moment.minutesSpent + 1
val nextValleyState = if (valleyStates.size > nextMinute) {
valleyStates[nextMinute]
} else {
valleyStates.add(next(valleyStates.last()))
valleyStates.last()
}
val availableMoves = getAvailableMoves(moment.expedition, start, target, nextValleyState)
if (target in availableMoves) {
return nextMinute to nextValleyState
}
for (move in availableMoves) {
val nextMoment = Moment(move, nextMinute)
if (nextMoment !in visited) {
visited.add(nextMoment)
q.addLast(nextMoment)
}
}
}
return -1 to initValleyState
}
fun part1(input: List<String>): String {
val valley = parse(input)
val start = Point(1, 0)
val target = Point(valley.maxX - 1, valley.maxY)
val count = search(start, target, valley).first
return count.toString()
}
fun part2(input: List<String>): String {
val valley = parse(input)
val start = Point(1, 0)
val target = Point(valley.maxX - 1, valley.maxY)
val forward = search(start, target, valley)
val r1 = forward.first
println("R1 $r1")
val reward = search(target, start, forward.second)
val r2 = reward.first
println("R2 $r2")
val again = search(start, target, reward.second)
val r3 = again.first
println("R3 $r3")
return (r1 + r2 + r3).toString()
}
}
@OptIn(ExperimentalTime::class)
@Suppress("DuplicatedCode")
fun main() {
val solution = Day24()
val name = solution.javaClass.name
val execution = setOf(
ExecutionMode.Test1,
ExecutionMode.Test2,
ExecutionMode.Exec1,
ExecutionMode.Exec2
)
fun test() {
val expected1 = "18"
val expected2 = "54"
val testInput = readInput("${name}_test")
if (execution.contains(ExecutionMode.Test1)) {
println("Test part 1")
assert(solution.part1(testInput), expected1)
println("> Passed")
}
if (execution.contains(ExecutionMode.Test2)) {
println("Test part 2")
assert(solution.part2(testInput), expected2)
println("> Passed")
println()
}
println("=================================")
println()
}
fun run() {
val input = readInput(name)
if (execution.contains(ExecutionMode.Exec1)) {
val elapsed1 = measureTime {
println("Part 1: " + solution.part1(input))
}
println("Elapsed: $elapsed1")
println()
}
if (execution.contains(ExecutionMode.Exec2)) {
val elapsed2 = measureTime {
println("Part 2: " + solution.part2(input))
}
println("Elapsed: $elapsed2")
println()
}
}
test()
run()
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day24$WhenMappings.class",
"javap": "Compiled from \"Day24.kt\"\npublic final class Day24$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method Direction.values:()[LDirection;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field Direction.Up:LDirection;\n 12: invokevirtual #22 // Method Direction.ordinal:()I\n 15: iconst_1\n 16: iastore\n 17: goto 21\n 20: astore_1\n 21: nop\n 22: aload_0\n 23: getstatic #25 // Field Direction.Down:LDirection;\n 26: invokevirtual #22 // Method Direction.ordinal:()I\n 29: iconst_2\n 30: iastore\n 31: goto 35\n 34: astore_1\n 35: nop\n 36: aload_0\n 37: getstatic #28 // Field Direction.Left:LDirection;\n 40: invokevirtual #22 // Method Direction.ordinal:()I\n 43: iconst_3\n 44: iastore\n 45: goto 49\n 48: astore_1\n 49: nop\n 50: aload_0\n 51: getstatic #31 // Field Direction.Right:LDirection;\n 54: invokevirtual #22 // Method Direction.ordinal:()I\n 57: iconst_4\n 58: iastore\n 59: goto 63\n 62: astore_1\n 63: aload_0\n 64: putstatic #35 // Field $EnumSwitchMapping$0:[I\n 67: return\n Exception table:\n from to target type\n 7 17 20 Class java/lang/NoSuchFieldError\n 21 31 34 Class java/lang/NoSuchFieldError\n 35 45 48 Class java/lang/NoSuchFieldError\n 49 59 62 Class java/lang/NoSuchFieldError\n}\n",
"javap_err": ""
},
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day24$Moment.class",
"javap": "Compiled from \"Day24.kt\"\npublic final class Day24$Moment {\n private final Point expedition;\n\n private final int minutesSpent;\n\n public Day24$Moment(Point, int);\n Code:\n 0: aload_1\n 1: ldc #9 // String expedition\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 expedition:LPoint;\n 15: aload_0\n 16: iload_2\n 17: putfield #25 // Field minutesSpent:I\n 20: return\n\n public final Point getExpedition();\n Code:\n 0: aload_0\n 1: getfield #21 // Field expedition:LPoint;\n 4: areturn\n\n public final int getMinutesSpent();\n Code:\n 0: aload_0\n 1: getfield #25 // Field minutesSpent:I\n 4: ireturn\n\n public final Point component1();\n Code:\n 0: aload_0\n 1: getfield #21 // Field expedition:LPoint;\n 4: areturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #25 // Field minutesSpent:I\n 4: ireturn\n\n public final Day24$Moment copy(Point, int);\n Code:\n 0: aload_1\n 1: ldc #9 // String expedition\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class Day24$Moment\n 9: dup\n 10: aload_1\n 11: iload_2\n 12: invokespecial #37 // Method \"<init>\":(LPoint;I)V\n 15: areturn\n\n public static Day24$Moment copy$default(Day24$Moment, Point, int, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_1\n 2: iand\n 3: ifeq 11\n 6: aload_0\n 7: getfield #21 // Field expedition:LPoint;\n 10: astore_1\n 11: iload_3\n 12: iconst_2\n 13: iand\n 14: ifeq 22\n 17: aload_0\n 18: getfield #25 // Field minutesSpent:I\n 21: istore_2\n 22: aload_0\n 23: aload_1\n 24: iload_2\n 25: invokevirtual #41 // Method copy:(LPoint;I)LDay24$Moment;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #45 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #46 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #48 // String Moment(expedition=\n 9: invokevirtual #52 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #21 // Field expedition:LPoint;\n 16: invokevirtual #55 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #57 // String , minutesSpent=\n 21: invokevirtual #52 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #25 // Field minutesSpent:I\n 28: invokevirtual #60 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #63 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #65 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 39: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #21 // Field expedition:LPoint;\n 4: invokevirtual #70 // Method Point.hashCode:()I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #25 // Field minutesSpent:I\n 16: invokestatic #75 // Method java/lang/Integer.hashCode:(I)I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: ireturn\n\n public boolean equals(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: if_acmpne 7\n 5: iconst_1\n 6: ireturn\n 7: aload_1\n 8: instanceof #2 // class Day24$Moment\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day24$Moment\n 20: astore_2\n 21: aload_0\n 22: getfield #21 // Field expedition:LPoint;\n 25: aload_2\n 26: getfield #21 // Field expedition:LPoint;\n 29: invokestatic #83 // 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 minutesSpent:I\n 41: aload_2\n 42: getfield #25 // Field minutesSpent:I\n 45: if_icmpeq 50\n 48: iconst_0\n 49: ireturn\n 50: iconst_1\n 51: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day24Kt.class",
"javap": "Compiled from \"Day24.kt\"\npublic final class Day24Kt {\n public static final void main();\n Code:\n 0: new #8 // class Day24\n 3: dup\n 4: invokespecial #11 // Method Day24.\"<init>\":()V\n 7: astore_0\n 8: aload_0\n 9: invokevirtual #15 // Method java/lang/Object.getClass:()Ljava/lang/Class;\n 12: invokevirtual #21 // Method java/lang/Class.getName:()Ljava/lang/String;\n 15: astore_1\n 16: iconst_4\n 17: anewarray #23 // class ExecutionMode\n 20: astore_3\n 21: aload_3\n 22: iconst_0\n 23: getstatic #27 // Field ExecutionMode.Test1:LExecutionMode;\n 26: aastore\n 27: aload_3\n 28: iconst_1\n 29: getstatic #30 // Field ExecutionMode.Test2:LExecutionMode;\n 32: aastore\n 33: aload_3\n 34: iconst_2\n 35: getstatic #33 // Field ExecutionMode.Exec1:LExecutionMode;\n 38: aastore\n 39: aload_3\n 40: iconst_3\n 41: getstatic #36 // Field ExecutionMode.Exec2:LExecutionMode;\n 44: aastore\n 45: aload_3\n 46: invokestatic #42 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 49: astore_2\n 50: aload_1\n 51: aload_2\n 52: aload_0\n 53: invokestatic #46 // Method main$test:(Ljava/lang/String;Ljava/util/Set;LDay24;)V\n 56: aload_1\n 57: aload_2\n 58: aload_0\n 59: invokestatic #49 // Method main$run:(Ljava/lang/String;Ljava/util/Set;LDay24;)V\n 62: return\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 void main$test(java.lang.String, java.util.Set<? extends ExecutionMode>, Day24);\n Code:\n 0: ldc #63 // String 18\n 2: astore_3\n 3: ldc #65 // String 54\n 5: astore 4\n 7: new #67 // class java/lang/StringBuilder\n 10: dup\n 11: invokespecial #68 // Method java/lang/StringBuilder.\"<init>\":()V\n 14: aload_0\n 15: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 18: ldc #74 // String _test\n 20: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 23: invokevirtual #77 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 26: invokestatic #83 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 29: astore 5\n 31: aload_1\n 32: getstatic #27 // Field ExecutionMode.Test1:LExecutionMode;\n 35: invokeinterface #89, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 40: ifeq 71\n 43: ldc #91 // String Test part 1\n 45: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 48: swap\n 49: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 52: aload_2\n 53: aload 5\n 55: invokevirtual #107 // Method Day24.part1:(Ljava/util/List;)Ljava/lang/String;\n 58: aload_3\n 59: invokestatic #111 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 62: ldc #113 // String > Passed\n 64: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 67: swap\n 68: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 71: aload_1\n 72: getstatic #30 // Field ExecutionMode.Test2:LExecutionMode;\n 75: invokeinterface #89, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 80: ifeq 118\n 83: ldc #115 // String Test part 2\n 85: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 88: swap\n 89: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 92: aload_2\n 93: aload 5\n 95: invokevirtual #118 // Method Day24.part2:(Ljava/util/List;)Ljava/lang/String;\n 98: aload 4\n 100: invokestatic #111 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 103: ldc #113 // String > Passed\n 105: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 108: swap\n 109: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 112: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 115: invokevirtual #120 // Method java/io/PrintStream.println:()V\n 118: ldc #122 // String =================================\n 120: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 123: swap\n 124: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 127: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 130: invokevirtual #120 // Method java/io/PrintStream.println:()V\n 133: return\n\n private static final void main$run(java.lang.String, java.util.Set<? extends ExecutionMode>, Day24);\n Code:\n 0: aload_0\n 1: invokestatic #135 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 4: aload_0\n 5: invokestatic #83 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 8: astore_3\n 9: aload_1\n 10: getstatic #33 // Field ExecutionMode.Exec1:LExecutionMode;\n 13: invokeinterface #89, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 18: ifeq 118\n 21: iconst_0\n 22: istore 6\n 24: getstatic #141 // Field kotlin/time/TimeSource$Monotonic.INSTANCE:Lkotlin/time/TimeSource$Monotonic;\n 27: astore 7\n 29: iconst_0\n 30: istore 8\n 32: aload 7\n 34: invokevirtual #145 // Method kotlin/time/TimeSource$Monotonic.\"markNow-z9LOYto\":()J\n 37: lstore 9\n 39: iconst_0\n 40: istore 11\n 42: new #67 // class java/lang/StringBuilder\n 45: dup\n 46: invokespecial #68 // Method java/lang/StringBuilder.\"<init>\":()V\n 49: ldc #147 // String Part 1:\n 51: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 54: aload_2\n 55: aload_3\n 56: invokevirtual #107 // Method Day24.part1:(Ljava/util/List;)Ljava/lang/String;\n 59: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 62: invokevirtual #77 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 65: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: swap\n 69: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: nop\n 73: nop\n 74: lload 9\n 76: invokestatic #153 // Method kotlin/time/TimeSource$Monotonic$ValueTimeMark.\"elapsedNow-UwyO8pc\":(J)J\n 79: nop\n 80: lstore 4\n 82: new #67 // class java/lang/StringBuilder\n 85: dup\n 86: invokespecial #68 // Method java/lang/StringBuilder.\"<init>\":()V\n 89: ldc #155 // String Elapsed:\n 91: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 94: lload 4\n 96: invokestatic #161 // Method kotlin/time/Duration.\"toString-impl\":(J)Ljava/lang/String;\n 99: invokevirtual #164 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 102: invokevirtual #77 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 105: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 108: swap\n 109: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 112: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 115: invokevirtual #120 // Method java/io/PrintStream.println:()V\n 118: aload_1\n 119: getstatic #36 // Field ExecutionMode.Exec2:LExecutionMode;\n 122: invokeinterface #89, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 127: ifeq 227\n 130: iconst_0\n 131: istore 6\n 133: getstatic #141 // Field kotlin/time/TimeSource$Monotonic.INSTANCE:Lkotlin/time/TimeSource$Monotonic;\n 136: astore 7\n 138: iconst_0\n 139: istore 8\n 141: aload 7\n 143: invokevirtual #145 // Method kotlin/time/TimeSource$Monotonic.\"markNow-z9LOYto\":()J\n 146: lstore 9\n 148: iconst_0\n 149: istore 11\n 151: new #67 // class java/lang/StringBuilder\n 154: dup\n 155: invokespecial #68 // Method java/lang/StringBuilder.\"<init>\":()V\n 158: ldc #166 // String Part 2:\n 160: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 163: aload_2\n 164: aload_3\n 165: invokevirtual #118 // Method Day24.part2:(Ljava/util/List;)Ljava/lang/String;\n 168: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 171: invokevirtual #77 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 174: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 177: swap\n 178: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 181: nop\n 182: nop\n 183: lload 9\n 185: invokestatic #153 // Method kotlin/time/TimeSource$Monotonic$ValueTimeMark.\"elapsedNow-UwyO8pc\":(J)J\n 188: nop\n 189: lstore 4\n 191: new #67 // class java/lang/StringBuilder\n 194: dup\n 195: invokespecial #68 // Method java/lang/StringBuilder.\"<init>\":()V\n 198: ldc #155 // String Elapsed:\n 200: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 203: lload 4\n 205: invokestatic #161 // Method kotlin/time/Duration.\"toString-impl\":(J)Ljava/lang/String;\n 208: invokevirtual #164 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 211: invokevirtual #77 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 214: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 217: swap\n 218: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 221: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 224: invokevirtual #120 // Method java/io/PrintStream.println:()V\n 227: return\n}\n",
"javap_err": ""
},
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day24$Valley.class",
"javap": "Compiled from \"Day24.kt\"\npublic final class Day24$Valley {\n private final java.util.Map<Point, java.util.List<Direction>> blizzards;\n\n private final int maxY;\n\n private final int maxX;\n\n public Day24$Valley(java.util.Map<Point, ? extends java.util.List<? extends Direction>>, int, int);\n Code:\n 0: aload_1\n 1: ldc #10 // String blizzards\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokespecial #19 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: aload_1\n 12: putfield #22 // Field blizzards:Ljava/util/Map;\n 15: aload_0\n 16: iload_2\n 17: putfield #26 // Field maxY:I\n 20: aload_0\n 21: iload_3\n 22: putfield #29 // Field maxX:I\n 25: return\n\n public final java.util.Map<Point, java.util.List<Direction>> getBlizzards();\n Code:\n 0: aload_0\n 1: getfield #22 // Field blizzards:Ljava/util/Map;\n 4: areturn\n\n public final int getMaxY();\n Code:\n 0: aload_0\n 1: getfield #26 // Field maxY:I\n 4: ireturn\n\n public final int getMaxX();\n Code:\n 0: aload_0\n 1: getfield #29 // Field maxX:I\n 4: ireturn\n\n public final java.util.Map<Point, java.util.List<Direction>> component1();\n Code:\n 0: aload_0\n 1: getfield #22 // Field blizzards:Ljava/util/Map;\n 4: areturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #26 // Field maxY:I\n 4: ireturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #29 // Field maxX:I\n 4: ireturn\n\n public final Day24$Valley copy(java.util.Map<Point, ? extends java.util.List<? extends Direction>>, int, int);\n Code:\n 0: aload_1\n 1: ldc #10 // String blizzards\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class Day24$Valley\n 9: dup\n 10: aload_1\n 11: iload_2\n 12: iload_3\n 13: invokespecial #45 // Method \"<init>\":(Ljava/util/Map;II)V\n 16: areturn\n\n public static Day24$Valley copy$default(Day24$Valley, java.util.Map, 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 #22 // Field blizzards:Ljava/util/Map;\n 11: astore_1\n 12: iload 4\n 14: iconst_2\n 15: iand\n 16: ifeq 24\n 19: aload_0\n 20: getfield #26 // Field maxY: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 #29 // Field maxX:I\n 35: istore_3\n 36: aload_0\n 37: aload_1\n 38: iload_2\n 39: iload_3\n 40: invokevirtual #49 // Method copy:(Ljava/util/Map;II)LDay24$Valley;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #53 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #54 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #56 // String Valley(blizzards=\n 9: invokevirtual #60 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #22 // Field blizzards:Ljava/util/Map;\n 16: invokevirtual #63 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #65 // String , maxY=\n 21: invokevirtual #60 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #26 // Field maxY:I\n 28: invokevirtual #68 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #70 // String , maxX=\n 33: invokevirtual #60 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #29 // Field maxX:I\n 40: invokevirtual #68 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #73 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #75 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 51: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #22 // Field blizzards:Ljava/util/Map;\n 4: invokevirtual #78 // Method java/lang/Object.hashCode:()I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #26 // Field maxY:I\n 16: invokestatic #83 // 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 #29 // Field maxX:I\n 29: invokestatic #83 // 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 Day24$Valley\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day24$Valley\n 20: astore_2\n 21: aload_0\n 22: getfield #22 // Field blizzards:Ljava/util/Map;\n 25: aload_2\n 26: getfield #22 // Field blizzards:Ljava/util/Map;\n 29: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 32: ifne 37\n 35: iconst_0\n 36: ireturn\n 37: aload_0\n 38: getfield #26 // Field maxY:I\n 41: aload_2\n 42: getfield #26 // Field maxY:I\n 45: if_icmpeq 50\n 48: iconst_0\n 49: ireturn\n 50: aload_0\n 51: getfield #29 // Field maxX:I\n 54: aload_2\n 55: getfield #29 // Field maxX:I\n 58: if_icmpeq 63\n 61: iconst_0\n 62: ireturn\n 63: iconst_1\n 64: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day24.class",
"javap": "Compiled from \"Day24.kt\"\npublic final class Day24 {\n public Day24();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final Day24$Valley parse(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #24 // class java/util/LinkedHashMap\n 9: dup\n 10: invokespecial #25 // Method java/util/LinkedHashMap.\"<init>\":()V\n 13: checkcast #27 // class java/util/Map\n 16: astore_2\n 17: new #29 // class java/util/LinkedHashSet\n 20: dup\n 21: invokespecial #30 // Method java/util/LinkedHashSet.\"<init>\":()V\n 24: checkcast #32 // class java/util/Set\n 27: astore_3\n 28: aload_1\n 29: checkcast #34 // class java/lang/Iterable\n 32: invokeinterface #38, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 37: astore 4\n 39: iconst_0\n 40: istore 5\n 42: aload 4\n 44: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 49: ifeq 288\n 52: iload 5\n 54: istore 6\n 56: iload 5\n 58: iconst_1\n 59: iadd\n 60: istore 5\n 62: aload 4\n 64: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 69: checkcast #50 // class java/lang/String\n 72: astore 7\n 74: iconst_0\n 75: istore 8\n 77: aload 7\n 79: invokevirtual #54 // Method java/lang/String.length:()I\n 82: istore 9\n 84: iload 8\n 86: iload 9\n 88: if_icmpge 42\n 91: iload 8\n 93: istore 10\n 95: aload 7\n 97: iload 8\n 99: invokevirtual #58 // Method java/lang/String.charAt:(I)C\n 102: istore 11\n 104: iload 11\n 106: lookupswitch { // 5\n 35: 156\n 60: 204\n 62: 177\n 94: 231\n 118: 258\n default: 282\n }\n 156: aload_3\n 157: new #60 // class Point\n 160: dup\n 161: iload 10\n 163: iload 6\n 165: invokespecial #63 // Method Point.\"<init>\":(II)V\n 168: invokeinterface #67, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 173: pop\n 174: goto 282\n 177: aload_2\n 178: new #60 // class Point\n 181: dup\n 182: iload 10\n 184: iload 6\n 186: invokespecial #63 // Method Point.\"<init>\":(II)V\n 189: getstatic #73 // Field Direction.Right:LDirection;\n 192: invokestatic #79 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 195: invokeinterface #83, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 200: pop\n 201: goto 282\n 204: aload_2\n 205: new #60 // class Point\n 208: dup\n 209: iload 10\n 211: iload 6\n 213: invokespecial #63 // Method Point.\"<init>\":(II)V\n 216: getstatic #86 // Field Direction.Left:LDirection;\n 219: invokestatic #79 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 222: invokeinterface #83, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 227: pop\n 228: goto 282\n 231: aload_2\n 232: new #60 // class Point\n 235: dup\n 236: iload 10\n 238: iload 6\n 240: invokespecial #63 // Method Point.\"<init>\":(II)V\n 243: getstatic #89 // Field Direction.Up:LDirection;\n 246: invokestatic #79 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 249: invokeinterface #83, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 254: pop\n 255: goto 282\n 258: aload_2\n 259: new #60 // class Point\n 262: dup\n 263: iload 10\n 265: iload 6\n 267: invokespecial #63 // Method Point.\"<init>\":(II)V\n 270: getstatic #92 // Field Direction.Down:LDirection;\n 273: invokestatic #79 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 276: invokeinterface #83, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 281: pop\n 282: iinc 8, 1\n 285: goto 84\n 288: new #94 // class Day24$Valley\n 291: dup\n 292: aload_2\n 293: aload_1\n 294: invokeinterface #99, 1 // InterfaceMethod java/util/List.size:()I\n 299: iconst_1\n 300: isub\n 301: aload_1\n 302: iconst_0\n 303: invokeinterface #103, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 308: checkcast #50 // class java/lang/String\n 311: invokevirtual #54 // Method java/lang/String.length:()I\n 314: iconst_1\n 315: isub\n 316: invokespecial #106 // Method Day24$Valley.\"<init>\":(Ljava/util/Map;II)V\n 319: areturn\n\n public final Point nextPosition(Direction, Point, Day24$Valley);\n Code:\n 0: aload_1\n 1: ldc #122 // String direction\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #124 // String position\n 9: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_3\n 13: ldc #126 // String valley\n 15: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: aload_1\n 19: getstatic #132 // Field Day24$WhenMappings.$EnumSwitchMapping$0:[I\n 22: swap\n 23: invokevirtual #135 // Method Direction.ordinal:()I\n 26: iaload\n 27: tableswitch { // 1 to 4\n 1: 56\n 2: 68\n 3: 80\n 4: 92\n default: 104\n }\n 56: new #60 // class Point\n 59: dup\n 60: iconst_0\n 61: iconst_m1\n 62: invokespecial #63 // Method Point.\"<init>\":(II)V\n 65: goto 112\n 68: new #60 // class Point\n 71: dup\n 72: iconst_0\n 73: iconst_1\n 74: invokespecial #63 // Method Point.\"<init>\":(II)V\n 77: goto 112\n 80: new #60 // class Point\n 83: dup\n 84: iconst_m1\n 85: iconst_0\n 86: invokespecial #63 // Method Point.\"<init>\":(II)V\n 89: goto 112\n 92: new #60 // class Point\n 95: dup\n 96: iconst_1\n 97: iconst_0\n 98: invokespecial #63 // Method Point.\"<init>\":(II)V\n 101: goto 112\n 104: new #137 // class kotlin/NoWhenBranchMatchedException\n 107: dup\n 108: invokespecial #138 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 111: athrow\n 112: astore 4\n 114: aload_2\n 115: aload 4\n 117: invokevirtual #142 // Method Point.sum:(LPoint;)LPoint;\n 120: astore 5\n 122: aload 5\n 124: invokevirtual #145 // Method Point.getX:()I\n 127: ifgt 149\n 130: new #60 // class Point\n 133: dup\n 134: aload_3\n 135: invokevirtual #148 // Method Day24$Valley.getMaxX:()I\n 138: iconst_1\n 139: isub\n 140: aload 5\n 142: invokevirtual #151 // Method Point.getY:()I\n 145: invokespecial #63 // Method Point.\"<init>\":(II)V\n 148: areturn\n 149: aload 5\n 151: invokevirtual #145 // Method Point.getX:()I\n 154: aload_3\n 155: invokevirtual #148 // Method Day24$Valley.getMaxX:()I\n 158: if_icmplt 175\n 161: new #60 // class Point\n 164: dup\n 165: iconst_1\n 166: aload 5\n 168: invokevirtual #151 // Method Point.getY:()I\n 171: invokespecial #63 // Method Point.\"<init>\":(II)V\n 174: areturn\n 175: aload 5\n 177: invokevirtual #151 // Method Point.getY:()I\n 180: ifgt 202\n 183: new #60 // class Point\n 186: dup\n 187: aload 5\n 189: invokevirtual #145 // Method Point.getX:()I\n 192: aload_3\n 193: invokevirtual #154 // Method Day24$Valley.getMaxY:()I\n 196: iconst_1\n 197: isub\n 198: invokespecial #63 // Method Point.\"<init>\":(II)V\n 201: areturn\n 202: aload 5\n 204: invokevirtual #151 // Method Point.getY:()I\n 207: aload_3\n 208: invokevirtual #154 // Method Day24$Valley.getMaxY:()I\n 211: if_icmplt 228\n 214: new #60 // class Point\n 217: dup\n 218: aload 5\n 220: invokevirtual #145 // Method Point.getX:()I\n 223: iconst_1\n 224: invokespecial #63 // Method Point.\"<init>\":(II)V\n 227: areturn\n 228: aload 5\n 230: areturn\n\n public final void print(Day24$Valley);\n Code:\n 0: aload_1\n 1: ldc #126 // String valley\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_2\n 8: aload_1\n 9: invokevirtual #154 // Method Day24$Valley.getMaxY:()I\n 12: istore_3\n 13: iload_2\n 14: iload_3\n 15: if_icmpgt 315\n 18: iconst_0\n 19: istore 4\n 21: aload_1\n 22: invokevirtual #148 // Method Day24$Valley.getMaxX:()I\n 25: istore 5\n 27: iload 4\n 29: iload 5\n 31: if_icmpgt 298\n 34: new #60 // class Point\n 37: dup\n 38: iload 4\n 40: iload_2\n 41: invokespecial #63 // Method Point.\"<init>\":(II)V\n 44: astore 6\n 46: iload 4\n 48: ifeq 72\n 51: iload 4\n 53: aload_1\n 54: invokevirtual #148 // Method Day24$Valley.getMaxX:()I\n 57: if_icmpeq 72\n 60: iload_2\n 61: ifeq 72\n 64: iload_2\n 65: aload_1\n 66: invokevirtual #154 // Method Day24$Valley.getMaxY:()I\n 69: if_icmpne 87\n 72: bipush 35\n 74: istore 7\n 76: getstatic #166 // Field java/lang/System.out:Ljava/io/PrintStream;\n 79: iload 7\n 81: invokevirtual #171 // Method java/io/PrintStream.print:(C)V\n 84: goto 285\n 87: aload_1\n 88: invokevirtual #175 // Method Day24$Valley.getBlizzards:()Ljava/util/Map;\n 91: invokeinterface #179, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 96: aload 6\n 98: invokeinterface #182, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 103: ifne 121\n 106: bipush 46\n 108: istore 7\n 110: getstatic #166 // Field java/lang/System.out:Ljava/io/PrintStream;\n 113: iload 7\n 115: invokevirtual #171 // Method java/io/PrintStream.print:(C)V\n 118: goto 285\n 121: aload_1\n 122: invokevirtual #175 // Method Day24$Valley.getBlizzards:()Ljava/util/Map;\n 125: aload 6\n 127: invokeinterface #185, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 132: dup\n 133: invokestatic #189 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 136: checkcast #96 // class java/util/List\n 139: astore 7\n 141: aload 7\n 143: invokeinterface #99, 1 // InterfaceMethod java/util/List.size:()I\n 148: iconst_1\n 149: if_icmpne 268\n 152: aload 7\n 154: invokestatic #193 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 157: checkcast #69 // class Direction\n 160: getstatic #132 // Field Day24$WhenMappings.$EnumSwitchMapping$0:[I\n 163: swap\n 164: invokevirtual #135 // Method Direction.ordinal:()I\n 167: iaload\n 168: tableswitch { // 1 to 4\n 1: 200\n 2: 215\n 3: 230\n 4: 245\n default: 260\n }\n 200: bipush 94\n 202: istore 9\n 204: getstatic #166 // Field java/lang/System.out:Ljava/io/PrintStream;\n 207: iload 9\n 209: invokevirtual #171 // Method java/io/PrintStream.print:(C)V\n 212: goto 285\n 215: bipush 118\n 217: istore 9\n 219: getstatic #166 // Field java/lang/System.out:Ljava/io/PrintStream;\n 222: iload 9\n 224: invokevirtual #171 // Method java/io/PrintStream.print:(C)V\n 227: goto 285\n 230: bipush 60\n 232: istore 9\n 234: getstatic #166 // Field java/lang/System.out:Ljava/io/PrintStream;\n 237: iload 9\n 239: invokevirtual #171 // Method java/io/PrintStream.print:(C)V\n 242: goto 285\n 245: bipush 62\n 247: istore 9\n 249: getstatic #166 // Field java/lang/System.out:Ljava/io/PrintStream;\n 252: iload 9\n 254: invokevirtual #171 // Method java/io/PrintStream.print:(C)V\n 257: goto 285\n 260: new #137 // class kotlin/NoWhenBranchMatchedException\n 263: dup\n 264: invokespecial #138 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 267: athrow\n 268: aload 7\n 270: invokeinterface #99, 1 // InterfaceMethod java/util/List.size:()I\n 275: istore 8\n 277: getstatic #166 // Field java/lang/System.out:Ljava/io/PrintStream;\n 280: iload 8\n 282: invokevirtual #196 // Method java/io/PrintStream.print:(I)V\n 285: iload 4\n 287: iload 5\n 289: if_icmpeq 298\n 292: iinc 4, 1\n 295: goto 34\n 298: getstatic #166 // Field java/lang/System.out:Ljava/io/PrintStream;\n 301: invokevirtual #199 // Method java/io/PrintStream.println:()V\n 304: iload_2\n 305: iload_3\n 306: if_icmpeq 315\n 309: iinc 2, 1\n 312: goto 18\n 315: getstatic #166 // Field java/lang/System.out:Ljava/io/PrintStream;\n 318: invokevirtual #199 // Method java/io/PrintStream.println:()V\n 321: return\n\n public final Day24$Valley next(Day24$Valley);\n Code:\n 0: aload_1\n 1: ldc #126 // String valley\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokevirtual #175 // Method Day24$Valley.getBlizzards:()Ljava/util/Map;\n 10: astore_3\n 11: iconst_0\n 12: istore 4\n 14: aload_3\n 15: astore 5\n 17: new #204 // class java/util/ArrayList\n 20: dup\n 21: invokespecial #205 // Method java/util/ArrayList.\"<init>\":()V\n 24: checkcast #207 // class java/util/Collection\n 27: astore 6\n 29: iconst_0\n 30: istore 7\n 32: aload 5\n 34: invokeinterface #210, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 39: invokeinterface #211, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 44: astore 8\n 46: aload 8\n 48: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 215\n 56: aload 8\n 58: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: checkcast #213 // class java/util/Map$Entry\n 66: astore 9\n 68: aload 9\n 70: astore 10\n 72: iconst_0\n 73: istore 11\n 75: aload 10\n 77: invokeinterface #216, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 82: checkcast #34 // class java/lang/Iterable\n 85: astore 12\n 87: iconst_0\n 88: istore 13\n 90: aload 12\n 92: astore 14\n 94: new #204 // class java/util/ArrayList\n 97: dup\n 98: aload 12\n 100: bipush 10\n 102: invokestatic #220 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 105: invokespecial #222 // Method java/util/ArrayList.\"<init>\":(I)V\n 108: checkcast #207 // class java/util/Collection\n 111: astore 15\n 113: iconst_0\n 114: istore 16\n 116: aload 14\n 118: invokeinterface #38, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 123: astore 17\n 125: aload 17\n 127: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 132: ifeq 192\n 135: aload 17\n 137: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 142: astore 18\n 144: aload 15\n 146: aload 18\n 148: checkcast #69 // class Direction\n 151: astore 19\n 153: astore 20\n 155: iconst_0\n 156: istore 21\n 158: aload_0\n 159: aload 19\n 161: aload 10\n 163: invokeinterface #225, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 168: checkcast #60 // class Point\n 171: aload_1\n 172: invokevirtual #227 // Method nextPosition:(LDirection;LPoint;LDay24$Valley;)LPoint;\n 175: aload 19\n 177: invokestatic #233 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 180: aload 20\n 182: swap\n 183: invokeinterface #234, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 188: pop\n 189: goto 125\n 192: aload 15\n 194: checkcast #96 // class java/util/List\n 197: nop\n 198: checkcast #34 // class java/lang/Iterable\n 201: nop\n 202: astore 10\n 204: aload 6\n 206: aload 10\n 208: invokestatic #238 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 211: pop\n 212: goto 46\n 215: aload 6\n 217: checkcast #96 // class java/util/List\n 220: nop\n 221: checkcast #34 // class java/lang/Iterable\n 224: astore_3\n 225: nop\n 226: iconst_0\n 227: istore 4\n 229: aload_3\n 230: astore 5\n 232: new #24 // class java/util/LinkedHashMap\n 235: dup\n 236: invokespecial #25 // Method java/util/LinkedHashMap.\"<init>\":()V\n 239: checkcast #27 // class java/util/Map\n 242: astore 6\n 244: iconst_0\n 245: istore 7\n 247: aload 5\n 249: invokeinterface #38, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 254: astore 8\n 256: aload 8\n 258: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 263: ifeq 392\n 266: aload 8\n 268: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 273: astore 9\n 275: aload 9\n 277: checkcast #240 // class kotlin/Pair\n 280: astore 10\n 282: iconst_0\n 283: istore 11\n 285: aload 10\n 287: invokevirtual #243 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 290: checkcast #60 // class Point\n 293: astore 12\n 295: aload 6\n 297: astore 13\n 299: iconst_0\n 300: istore 14\n 302: aload 13\n 304: aload 12\n 306: invokeinterface #185, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 311: astore 15\n 313: aload 15\n 315: ifnonnull 350\n 318: iconst_0\n 319: istore 16\n 321: new #204 // class java/util/ArrayList\n 324: dup\n 325: invokespecial #205 // Method java/util/ArrayList.\"<init>\":()V\n 328: checkcast #96 // class java/util/List\n 331: astore 16\n 333: aload 13\n 335: aload 12\n 337: aload 16\n 339: invokeinterface #83, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 344: pop\n 345: aload 16\n 347: goto 352\n 350: aload 15\n 352: nop\n 353: checkcast #96 // class java/util/List\n 356: astore 10\n 358: aload 10\n 360: aload 9\n 362: checkcast #240 // class kotlin/Pair\n 365: astore 11\n 367: astore 22\n 369: iconst_0\n 370: istore 17\n 372: aload 11\n 374: invokevirtual #246 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 377: checkcast #69 // class Direction\n 380: aload 22\n 382: swap\n 383: invokeinterface #247, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 388: pop\n 389: goto 256\n 392: aload 6\n 394: nop\n 395: astore_2\n 396: new #94 // class Day24$Valley\n 399: dup\n 400: aload_2\n 401: aload_1\n 402: invokevirtual #154 // Method Day24$Valley.getMaxY:()I\n 405: aload_1\n 406: invokevirtual #148 // Method Day24$Valley.getMaxX:()I\n 409: invokespecial #106 // Method Day24$Valley.\"<init>\":(Ljava/util/Map;II)V\n 412: astore_3\n 413: aload_3\n 414: areturn\n\n public final java.util.Set<Point> getAvailableMoves(Point, Point, Point, Day24$Valley);\n Code:\n 0: aload_1\n 1: ldc_w #285 // String current\n 4: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_2\n 8: ldc_w #287 // String start\n 11: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: aload_3\n 15: ldc_w #289 // String target\n 18: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 21: aload 4\n 23: ldc #126 // String valley\n 25: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 28: iconst_5\n 29: anewarray #60 // class Point\n 32: astore 5\n 34: aload 5\n 36: iconst_0\n 37: new #60 // class Point\n 40: dup\n 41: iconst_0\n 42: iconst_0\n 43: invokespecial #63 // Method Point.\"<init>\":(II)V\n 46: aastore\n 47: aload 5\n 49: iconst_1\n 50: new #60 // class Point\n 53: dup\n 54: iconst_0\n 55: iconst_m1\n 56: invokespecial #63 // Method Point.\"<init>\":(II)V\n 59: aastore\n 60: aload 5\n 62: iconst_2\n 63: new #60 // class Point\n 66: dup\n 67: iconst_0\n 68: iconst_1\n 69: invokespecial #63 // Method Point.\"<init>\":(II)V\n 72: aastore\n 73: aload 5\n 75: iconst_3\n 76: new #60 // class Point\n 79: dup\n 80: iconst_m1\n 81: iconst_0\n 82: invokespecial #63 // Method Point.\"<init>\":(II)V\n 85: aastore\n 86: aload 5\n 88: iconst_4\n 89: new #60 // class Point\n 92: dup\n 93: iconst_1\n 94: iconst_0\n 95: invokespecial #63 // Method Point.\"<init>\":(II)V\n 98: aastore\n 99: aload 5\n 101: invokestatic #292 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 104: checkcast #34 // class java/lang/Iterable\n 107: astore 5\n 109: nop\n 110: iconst_0\n 111: istore 6\n 113: aload 5\n 115: astore 7\n 117: new #204 // class java/util/ArrayList\n 120: dup\n 121: aload 5\n 123: bipush 10\n 125: invokestatic #220 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 128: invokespecial #222 // Method java/util/ArrayList.\"<init>\":(I)V\n 131: checkcast #207 // class java/util/Collection\n 134: astore 8\n 136: iconst_0\n 137: istore 9\n 139: aload 7\n 141: invokeinterface #38, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 146: astore 10\n 148: aload 10\n 150: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 155: ifeq 199\n 158: aload 10\n 160: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 165: astore 11\n 167: aload 8\n 169: aload 11\n 171: checkcast #60 // class Point\n 174: astore 12\n 176: astore 14\n 178: iconst_0\n 179: istore 13\n 181: aload 12\n 183: aload_1\n 184: invokevirtual #142 // Method Point.sum:(LPoint;)LPoint;\n 187: aload 14\n 189: swap\n 190: invokeinterface #234, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 195: pop\n 196: goto 148\n 199: aload 8\n 201: checkcast #96 // class java/util/List\n 204: nop\n 205: checkcast #34 // class java/lang/Iterable\n 208: astore 5\n 210: nop\n 211: iconst_0\n 212: istore 6\n 214: aload 5\n 216: astore 7\n 218: new #204 // class java/util/ArrayList\n 221: dup\n 222: invokespecial #205 // Method java/util/ArrayList.\"<init>\":()V\n 225: checkcast #207 // class java/util/Collection\n 228: astore 8\n 230: iconst_0\n 231: istore 9\n 233: aload 7\n 235: invokeinterface #38, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 240: astore 10\n 242: aload 10\n 244: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 249: ifeq 352\n 252: aload 10\n 254: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 259: astore 11\n 261: aload 11\n 263: checkcast #60 // class Point\n 266: astore 12\n 268: iconst_0\n 269: istore 13\n 271: aload 12\n 273: invokevirtual #145 // Method Point.getX:()I\n 276: ifle 313\n 279: aload 12\n 281: invokevirtual #145 // Method Point.getX:()I\n 284: aload 4\n 286: invokevirtual #148 // Method Day24$Valley.getMaxX:()I\n 289: if_icmpge 313\n 292: aload 12\n 294: invokevirtual #151 // Method Point.getY:()I\n 297: ifle 313\n 300: aload 12\n 302: invokevirtual #151 // Method Point.getY:()I\n 305: aload 4\n 307: invokevirtual #154 // Method Day24$Valley.getMaxY:()I\n 310: if_icmplt 331\n 313: aload 12\n 315: aload_3\n 316: invokestatic #296 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 319: ifne 331\n 322: aload 12\n 324: aload_2\n 325: invokestatic #296 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 328: ifeq 335\n 331: iconst_1\n 332: goto 336\n 335: iconst_0\n 336: ifeq 242\n 339: aload 8\n 341: aload 11\n 343: invokeinterface #234, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 348: pop\n 349: goto 242\n 352: aload 8\n 354: checkcast #96 // class java/util/List\n 357: nop\n 358: checkcast #34 // class java/lang/Iterable\n 361: astore 5\n 363: nop\n 364: iconst_0\n 365: istore 6\n 367: aload 5\n 369: astore 7\n 371: new #204 // class java/util/ArrayList\n 374: dup\n 375: invokespecial #205 // Method java/util/ArrayList.\"<init>\":()V\n 378: checkcast #207 // class java/util/Collection\n 381: astore 8\n 383: iconst_0\n 384: istore 9\n 386: aload 7\n 388: invokeinterface #38, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 393: astore 10\n 395: aload 10\n 397: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 402: ifeq 460\n 405: aload 10\n 407: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 412: astore 11\n 414: aload 11\n 416: checkcast #60 // class Point\n 419: astore 12\n 421: iconst_0\n 422: istore 13\n 424: aload 4\n 426: invokevirtual #175 // Method Day24$Valley.getBlizzards:()Ljava/util/Map;\n 429: aload 12\n 431: invokeinterface #299, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 436: ifne 443\n 439: iconst_1\n 440: goto 444\n 443: iconst_0\n 444: ifeq 395\n 447: aload 8\n 449: aload 11\n 451: invokeinterface #234, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 456: pop\n 457: goto 395\n 460: aload 8\n 462: checkcast #96 // class java/util/List\n 465: nop\n 466: checkcast #34 // class java/lang/Iterable\n 469: invokestatic #303 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 472: areturn\n\n public final kotlin.Pair<java.lang.Integer, Day24$Valley> search(Point, Point, Day24$Valley);\n Code:\n 0: aload_1\n 1: ldc_w #287 // String start\n 4: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_2\n 8: ldc_w #289 // String target\n 11: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: aload_3\n 15: ldc_w #316 // String initValleyState\n 18: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 21: iconst_1\n 22: anewarray #94 // class Day24$Valley\n 25: astore 5\n 27: aload 5\n 29: iconst_0\n 30: aload_3\n 31: aastore\n 32: aload 5\n 34: invokestatic #319 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 37: astore 4\n 39: aload_0\n 40: aload_3\n 41: invokevirtual #321 // Method print:(LDay24$Valley;)V\n 44: new #323 // class kotlin/collections/ArrayDeque\n 47: dup\n 48: invokespecial #324 // Method kotlin/collections/ArrayDeque.\"<init>\":()V\n 51: astore 5\n 53: new #29 // class java/util/LinkedHashSet\n 56: dup\n 57: invokespecial #30 // Method java/util/LinkedHashSet.\"<init>\":()V\n 60: checkcast #32 // class java/util/Set\n 63: astore 6\n 65: new #326 // class Day24$Moment\n 68: dup\n 69: aload_1\n 70: iconst_0\n 71: invokespecial #329 // Method Day24$Moment.\"<init>\":(LPoint;I)V\n 74: astore 7\n 76: aload 5\n 78: aload 7\n 80: invokevirtual #332 // Method kotlin/collections/ArrayDeque.addLast:(Ljava/lang/Object;)V\n 83: aload 6\n 85: aload 7\n 87: invokeinterface #67, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 92: pop\n 93: aload 5\n 95: checkcast #207 // class java/util/Collection\n 98: invokeinterface #335, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 103: ifne 110\n 106: iconst_1\n 107: goto 111\n 110: iconst_0\n 111: ifeq 303\n 114: aload 5\n 116: invokevirtual #338 // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;\n 119: checkcast #326 // class Day24$Moment\n 122: astore 8\n 124: aload 8\n 126: invokevirtual #341 // Method Day24$Moment.getMinutesSpent:()I\n 129: iconst_1\n 130: iadd\n 131: istore 9\n 133: aload 4\n 135: invokeinterface #99, 1 // InterfaceMethod java/util/List.size:()I\n 140: iload 9\n 142: if_icmple 160\n 145: aload 4\n 147: iload 9\n 149: invokeinterface #103, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 154: checkcast #94 // class Day24$Valley\n 157: goto 188\n 160: aload 4\n 162: aload_0\n 163: aload 4\n 165: invokestatic #344 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 168: checkcast #94 // class Day24$Valley\n 171: invokevirtual #346 // Method next:(LDay24$Valley;)LDay24$Valley;\n 174: invokeinterface #247, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 179: pop\n 180: aload 4\n 182: invokestatic #344 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 185: checkcast #94 // class Day24$Valley\n 188: astore 10\n 190: aload_0\n 191: aload 8\n 193: invokevirtual #350 // Method Day24$Moment.getExpedition:()LPoint;\n 196: aload_1\n 197: aload_2\n 198: aload 10\n 200: invokevirtual #352 // Method getAvailableMoves:(LPoint;LPoint;LPoint;LDay24$Valley;)Ljava/util/Set;\n 203: astore 11\n 205: aload 11\n 207: aload_2\n 208: invokeinterface #182, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 213: ifeq 227\n 216: iload 9\n 218: invokestatic #358 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 221: aload 10\n 223: invokestatic #233 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 226: areturn\n 227: aload 11\n 229: invokeinterface #211, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 234: astore 12\n 236: aload 12\n 238: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 243: ifeq 93\n 246: aload 12\n 248: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 253: checkcast #60 // class Point\n 256: astore 13\n 258: new #326 // class Day24$Moment\n 261: dup\n 262: aload 13\n 264: iload 9\n 266: invokespecial #329 // Method Day24$Moment.\"<init>\":(LPoint;I)V\n 269: astore 14\n 271: aload 6\n 273: aload 14\n 275: invokeinterface #182, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 280: ifne 236\n 283: aload 6\n 285: aload 14\n 287: invokeinterface #67, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 292: pop\n 293: aload 5\n 295: aload 14\n 297: invokevirtual #332 // Method kotlin/collections/ArrayDeque.addLast:(Ljava/lang/Object;)V\n 300: goto 236\n 303: iconst_m1\n 304: invokestatic #358 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 307: aload_3\n 308: invokestatic #233 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 311: areturn\n\n public final java.lang.String part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokevirtual #375 // Method parse:(Ljava/util/List;)LDay24$Valley;\n 11: astore_2\n 12: new #60 // class Point\n 15: dup\n 16: iconst_1\n 17: iconst_0\n 18: invokespecial #63 // Method Point.\"<init>\":(II)V\n 21: astore_3\n 22: new #60 // class Point\n 25: dup\n 26: aload_2\n 27: invokevirtual #148 // Method Day24$Valley.getMaxX:()I\n 30: iconst_1\n 31: isub\n 32: aload_2\n 33: invokevirtual #154 // Method Day24$Valley.getMaxY:()I\n 36: invokespecial #63 // Method Point.\"<init>\":(II)V\n 39: astore 4\n 41: aload_0\n 42: aload_3\n 43: aload 4\n 45: aload_2\n 46: invokevirtual #377 // Method search:(LPoint;LPoint;LDay24$Valley;)Lkotlin/Pair;\n 49: invokevirtual #243 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 52: checkcast #379 // class java/lang/Number\n 55: invokevirtual #382 // Method java/lang/Number.intValue:()I\n 58: istore 5\n 60: iload 5\n 62: invokestatic #385 // Method java/lang/String.valueOf:(I)Ljava/lang/String;\n 65: areturn\n\n public final java.lang.String part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokevirtual #375 // Method parse:(Ljava/util/List;)LDay24$Valley;\n 11: astore_2\n 12: new #60 // class Point\n 15: dup\n 16: iconst_1\n 17: iconst_0\n 18: invokespecial #63 // Method Point.\"<init>\":(II)V\n 21: astore_3\n 22: new #60 // class Point\n 25: dup\n 26: aload_2\n 27: invokevirtual #148 // Method Day24$Valley.getMaxX:()I\n 30: iconst_1\n 31: isub\n 32: aload_2\n 33: invokevirtual #154 // Method Day24$Valley.getMaxY:()I\n 36: invokespecial #63 // Method Point.\"<init>\":(II)V\n 39: astore 4\n 41: aload_0\n 42: aload_3\n 43: aload 4\n 45: aload_2\n 46: invokevirtual #377 // Method search:(LPoint;LPoint;LDay24$Valley;)Lkotlin/Pair;\n 49: astore 5\n 51: aload 5\n 53: invokevirtual #243 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 56: checkcast #379 // class java/lang/Number\n 59: invokevirtual #382 // Method java/lang/Number.intValue:()I\n 62: istore 6\n 64: new #389 // class java/lang/StringBuilder\n 67: dup\n 68: invokespecial #390 // Method java/lang/StringBuilder.\"<init>\":()V\n 71: ldc_w #392 // String R1\n 74: invokevirtual #396 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 77: iload 6\n 79: invokevirtual #399 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 82: invokevirtual #403 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 85: getstatic #166 // Field java/lang/System.out:Ljava/io/PrintStream;\n 88: swap\n 89: invokevirtual #405 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 92: aload_0\n 93: aload 4\n 95: aload_3\n 96: aload 5\n 98: invokevirtual #246 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 101: checkcast #94 // class Day24$Valley\n 104: invokevirtual #377 // Method search:(LPoint;LPoint;LDay24$Valley;)Lkotlin/Pair;\n 107: astore 7\n 109: aload 7\n 111: invokevirtual #243 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 114: checkcast #379 // class java/lang/Number\n 117: invokevirtual #382 // Method java/lang/Number.intValue:()I\n 120: istore 8\n 122: new #389 // class java/lang/StringBuilder\n 125: dup\n 126: invokespecial #390 // Method java/lang/StringBuilder.\"<init>\":()V\n 129: ldc_w #407 // String R2\n 132: invokevirtual #396 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 135: iload 8\n 137: invokevirtual #399 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 140: invokevirtual #403 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 143: getstatic #166 // Field java/lang/System.out:Ljava/io/PrintStream;\n 146: swap\n 147: invokevirtual #405 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 150: aload_0\n 151: aload_3\n 152: aload 4\n 154: aload 7\n 156: invokevirtual #246 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 159: checkcast #94 // class Day24$Valley\n 162: invokevirtual #377 // Method search:(LPoint;LPoint;LDay24$Valley;)Lkotlin/Pair;\n 165: astore 9\n 167: aload 9\n 169: invokevirtual #243 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 172: checkcast #379 // class java/lang/Number\n 175: invokevirtual #382 // Method java/lang/Number.intValue:()I\n 178: istore 10\n 180: new #389 // class java/lang/StringBuilder\n 183: dup\n 184: invokespecial #390 // Method java/lang/StringBuilder.\"<init>\":()V\n 187: ldc_w #409 // String R3\n 190: invokevirtual #396 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 193: iload 10\n 195: invokevirtual #399 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 198: invokevirtual #403 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 201: getstatic #166 // Field java/lang/System.out:Ljava/io/PrintStream;\n 204: swap\n 205: invokevirtual #405 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 208: iload 6\n 210: iload 8\n 212: iadd\n 213: iload 10\n 215: iadd\n 216: invokestatic #385 // Method java/lang/String.valueOf:(I)Ljava/lang/String;\n 219: areturn\n}\n",
"javap_err": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day23.kt
|
import kotlin.time.ExperimentalTime
import kotlin.time.measureTime
class Day23 {
fun parse(input: List<String>): Set<Point> {
return input.flatMapIndexed { y, line ->
line.mapIndexed { x, c ->
if (c == '#') {
Point(x, y)
} else {
null
}
}
}.filterNotNull().toSet()
}
private val directions = arrayOf(Direction.Up, Direction.Down, Direction.Left, Direction.Right)
fun getNext(direction: Direction): Direction {
val index = (directions.indexOf(direction) + 1 + directions.size) % directions.size
return directions[index]
}
fun getNeighbors(point: Point): List<Point> {
return (-1..1)
.flatMap { x ->
(-1..1)
.map { y -> Point(point.x + x, point.y + y) }
}
.filter { p -> p != point }
}
fun canMove(point: Point, neighbors: List<Point>, direction: Direction): Point? {
return when (direction) {
Direction.Up -> if (neighbors.none { p -> p.y == point.y - 1 }) Point(point.x, point.y - 1) else null
Direction.Down -> if (neighbors.none { p -> p.y == point.y + 1 }) Point(point.x, point.y + 1) else null
Direction.Left -> if (neighbors.none { p -> p.x == point.x - 1 }) Point(point.x - 1, point.y) else null
Direction.Right -> if (neighbors.none { p -> p.x == point.x + 1 }) Point(point.x + 1, point.y) else null
}
}
fun move(points: Set<Point>, direction: Direction): Set<Point> {
val proposals = mutableMapOf<Point, Point>()
for (point in points) {
val neighbors = getNeighbors(point).filter { it in points }
if (neighbors.isEmpty()) {
continue
}
var cursor = direction
while (true) {
val target = canMove(point, neighbors, cursor)
if (target != null) {
proposals[point] = target
break
}
cursor = getNext(cursor)
if (cursor == direction) {
break
}
}
}
val reverseMap = proposals.asIterable().groupBy({ pair -> pair.value }, { pair -> pair.key })
val moves = reverseMap.filter { it.value.size == 1 }.map { it.value[0] to it.key }.toMap()
return points
.filter { p -> !moves.containsKey(p) }
.union(moves.values)
.toSet()
}
fun play1(points: Set<Point>): Set<Point> {
var direction = Direction.Up
var cursor = points
for (i in 1..10) {
cursor = move(cursor, direction)
direction = getNext(direction)
}
return cursor
}
fun play2(points: Set<Point>): Int {
var direction = Direction.Up
var cursor = points
var i = 0
do {
val newCursor = move(cursor, direction)
direction = getNext(direction)
val same = newCursor == cursor
cursor = newCursor
++i
} while (!same)
return i
}
fun print(points: Set<Point>) {
val maxX = points.maxOf { p -> p.x }
val maxY = points.maxOf { p -> p.y }
val minX = points.minOf { p -> p.x }
val minY = points.minOf { p -> p.y }
for (y in (minY - 1)..(maxY + 1)) {
for (x in (minX - 1)..(maxX + 1)) {
if (Point(x, y) in points) {
print('#')
} else {
print('.')
}
}
println()
}
println()
}
fun part1(input: List<String>): String {
val points = parse(input)
val result = play1(points)
return calc(result)
}
private fun calc(result: Set<Point>): String {
val maxX = result.maxOf { p -> p.x }
val maxY = result.maxOf { p -> p.y }
val minX = result.minOf { p -> p.x }
val minY = result.minOf { p -> p.y }
val dx = maxX - minX + 1
val dy = maxY - minY + 1
println("dx $dx dy $dy size ${result.size}")
val answer = dx * dy - result.size
return answer.toString()
}
fun part2(input: List<String>): String {
val points = parse(input)
val result = play2(points)
return result.toString()
}
}
@OptIn(ExperimentalTime::class)
@Suppress("DuplicatedCode")
fun main() {
val solution = Day23()
val name = solution.javaClass.name
val execution = setOf(
ExecutionMode.Test1,
ExecutionMode.Test2,
ExecutionMode.Exec1,
ExecutionMode.Exec2
)
fun test() {
val expected1 = "110"
val expected2 = "20"
val testInput = readInput("${name}_test")
if (execution.contains(ExecutionMode.Test1)) {
println("Test part 1")
assert(solution.part1(testInput), expected1)
println("> Passed")
}
if (execution.contains(ExecutionMode.Test2)) {
println("Test part 2")
assert(solution.part2(testInput), expected2)
println("> Passed")
println()
}
println("=================================")
println()
}
fun run() {
val input = readInput(name)
if (execution.contains(ExecutionMode.Exec1)) {
val elapsed1 = measureTime {
println("Part 1: " + solution.part1(input))
}
println("Elapsed: $elapsed1")
println()
}
if (execution.contains(ExecutionMode.Exec2)) {
val elapsed2 = measureTime {
println("Part 2: " + solution.part2(input))
}
println("Elapsed: $elapsed2")
println()
}
}
test()
run()
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day23Kt.class",
"javap": "Compiled from \"Day23.kt\"\npublic final class Day23Kt {\n public static final void main();\n Code:\n 0: new #8 // class Day23\n 3: dup\n 4: invokespecial #11 // Method Day23.\"<init>\":()V\n 7: astore_0\n 8: aload_0\n 9: invokevirtual #15 // Method java/lang/Object.getClass:()Ljava/lang/Class;\n 12: invokevirtual #21 // Method java/lang/Class.getName:()Ljava/lang/String;\n 15: astore_1\n 16: iconst_4\n 17: anewarray #23 // class ExecutionMode\n 20: astore_3\n 21: aload_3\n 22: iconst_0\n 23: getstatic #27 // Field ExecutionMode.Test1:LExecutionMode;\n 26: aastore\n 27: aload_3\n 28: iconst_1\n 29: getstatic #30 // Field ExecutionMode.Test2:LExecutionMode;\n 32: aastore\n 33: aload_3\n 34: iconst_2\n 35: getstatic #33 // Field ExecutionMode.Exec1:LExecutionMode;\n 38: aastore\n 39: aload_3\n 40: iconst_3\n 41: getstatic #36 // Field ExecutionMode.Exec2:LExecutionMode;\n 44: aastore\n 45: aload_3\n 46: invokestatic #42 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 49: astore_2\n 50: aload_1\n 51: aload_2\n 52: aload_0\n 53: invokestatic #46 // Method main$test:(Ljava/lang/String;Ljava/util/Set;LDay23;)V\n 56: aload_1\n 57: aload_2\n 58: aload_0\n 59: invokestatic #49 // Method main$run:(Ljava/lang/String;Ljava/util/Set;LDay23;)V\n 62: return\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 void main$test(java.lang.String, java.util.Set<? extends ExecutionMode>, Day23);\n Code:\n 0: ldc #63 // String 110\n 2: astore_3\n 3: ldc #65 // String 20\n 5: astore 4\n 7: new #67 // class java/lang/StringBuilder\n 10: dup\n 11: invokespecial #68 // Method java/lang/StringBuilder.\"<init>\":()V\n 14: aload_0\n 15: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 18: ldc #74 // String _test\n 20: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 23: invokevirtual #77 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 26: invokestatic #83 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 29: astore 5\n 31: aload_1\n 32: getstatic #27 // Field ExecutionMode.Test1:LExecutionMode;\n 35: invokeinterface #89, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 40: ifeq 71\n 43: ldc #91 // String Test part 1\n 45: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 48: swap\n 49: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 52: aload_2\n 53: aload 5\n 55: invokevirtual #107 // Method Day23.part1:(Ljava/util/List;)Ljava/lang/String;\n 58: aload_3\n 59: invokestatic #111 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 62: ldc #113 // String > Passed\n 64: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 67: swap\n 68: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 71: aload_1\n 72: getstatic #30 // Field ExecutionMode.Test2:LExecutionMode;\n 75: invokeinterface #89, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 80: ifeq 118\n 83: ldc #115 // String Test part 2\n 85: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 88: swap\n 89: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 92: aload_2\n 93: aload 5\n 95: invokevirtual #118 // Method Day23.part2:(Ljava/util/List;)Ljava/lang/String;\n 98: aload 4\n 100: invokestatic #111 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 103: ldc #113 // String > Passed\n 105: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 108: swap\n 109: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 112: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 115: invokevirtual #120 // Method java/io/PrintStream.println:()V\n 118: ldc #122 // String =================================\n 120: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 123: swap\n 124: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 127: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 130: invokevirtual #120 // Method java/io/PrintStream.println:()V\n 133: return\n\n private static final void main$run(java.lang.String, java.util.Set<? extends ExecutionMode>, Day23);\n Code:\n 0: aload_0\n 1: invokestatic #135 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 4: aload_0\n 5: invokestatic #83 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 8: astore_3\n 9: aload_1\n 10: getstatic #33 // Field ExecutionMode.Exec1:LExecutionMode;\n 13: invokeinterface #89, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 18: ifeq 118\n 21: iconst_0\n 22: istore 6\n 24: getstatic #141 // Field kotlin/time/TimeSource$Monotonic.INSTANCE:Lkotlin/time/TimeSource$Monotonic;\n 27: astore 7\n 29: iconst_0\n 30: istore 8\n 32: aload 7\n 34: invokevirtual #145 // Method kotlin/time/TimeSource$Monotonic.\"markNow-z9LOYto\":()J\n 37: lstore 9\n 39: iconst_0\n 40: istore 11\n 42: new #67 // class java/lang/StringBuilder\n 45: dup\n 46: invokespecial #68 // Method java/lang/StringBuilder.\"<init>\":()V\n 49: ldc #147 // String Part 1:\n 51: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 54: aload_2\n 55: aload_3\n 56: invokevirtual #107 // Method Day23.part1:(Ljava/util/List;)Ljava/lang/String;\n 59: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 62: invokevirtual #77 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 65: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: swap\n 69: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: nop\n 73: nop\n 74: lload 9\n 76: invokestatic #153 // Method kotlin/time/TimeSource$Monotonic$ValueTimeMark.\"elapsedNow-UwyO8pc\":(J)J\n 79: nop\n 80: lstore 4\n 82: new #67 // class java/lang/StringBuilder\n 85: dup\n 86: invokespecial #68 // Method java/lang/StringBuilder.\"<init>\":()V\n 89: ldc #155 // String Elapsed:\n 91: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 94: lload 4\n 96: invokestatic #161 // Method kotlin/time/Duration.\"toString-impl\":(J)Ljava/lang/String;\n 99: invokevirtual #164 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 102: invokevirtual #77 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 105: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 108: swap\n 109: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 112: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 115: invokevirtual #120 // Method java/io/PrintStream.println:()V\n 118: aload_1\n 119: getstatic #36 // Field ExecutionMode.Exec2:LExecutionMode;\n 122: invokeinterface #89, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 127: ifeq 227\n 130: iconst_0\n 131: istore 6\n 133: getstatic #141 // Field kotlin/time/TimeSource$Monotonic.INSTANCE:Lkotlin/time/TimeSource$Monotonic;\n 136: astore 7\n 138: iconst_0\n 139: istore 8\n 141: aload 7\n 143: invokevirtual #145 // Method kotlin/time/TimeSource$Monotonic.\"markNow-z9LOYto\":()J\n 146: lstore 9\n 148: iconst_0\n 149: istore 11\n 151: new #67 // class java/lang/StringBuilder\n 154: dup\n 155: invokespecial #68 // Method java/lang/StringBuilder.\"<init>\":()V\n 158: ldc #166 // String Part 2:\n 160: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 163: aload_2\n 164: aload_3\n 165: invokevirtual #118 // Method Day23.part2:(Ljava/util/List;)Ljava/lang/String;\n 168: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 171: invokevirtual #77 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 174: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 177: swap\n 178: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 181: nop\n 182: nop\n 183: lload 9\n 185: invokestatic #153 // Method kotlin/time/TimeSource$Monotonic$ValueTimeMark.\"elapsedNow-UwyO8pc\":(J)J\n 188: nop\n 189: lstore 4\n 191: new #67 // class java/lang/StringBuilder\n 194: dup\n 195: invokespecial #68 // Method java/lang/StringBuilder.\"<init>\":()V\n 198: ldc #155 // String Elapsed:\n 200: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 203: lload 4\n 205: invokestatic #161 // Method kotlin/time/Duration.\"toString-impl\":(J)Ljava/lang/String;\n 208: invokevirtual #164 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 211: invokevirtual #77 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 214: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 217: swap\n 218: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 221: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 224: invokevirtual #120 // Method java/io/PrintStream.println:()V\n 227: return\n}\n",
"javap_err": ""
},
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day23$WhenMappings.class",
"javap": "Compiled from \"Day23.kt\"\npublic final class Day23$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method Direction.values:()[LDirection;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field Direction.Up:LDirection;\n 12: invokevirtual #22 // Method Direction.ordinal:()I\n 15: iconst_1\n 16: iastore\n 17: goto 21\n 20: astore_1\n 21: nop\n 22: aload_0\n 23: getstatic #25 // Field Direction.Down:LDirection;\n 26: invokevirtual #22 // Method Direction.ordinal:()I\n 29: iconst_2\n 30: iastore\n 31: goto 35\n 34: astore_1\n 35: nop\n 36: aload_0\n 37: getstatic #28 // Field Direction.Left:LDirection;\n 40: invokevirtual #22 // Method Direction.ordinal:()I\n 43: iconst_3\n 44: iastore\n 45: goto 49\n 48: astore_1\n 49: nop\n 50: aload_0\n 51: getstatic #31 // Field Direction.Right:LDirection;\n 54: invokevirtual #22 // Method Direction.ordinal:()I\n 57: iconst_4\n 58: iastore\n 59: goto 63\n 62: astore_1\n 63: aload_0\n 64: putstatic #35 // Field $EnumSwitchMapping$0:[I\n 67: return\n Exception table:\n from to target type\n 7 17 20 Class java/lang/NoSuchFieldError\n 21 31 34 Class java/lang/NoSuchFieldError\n 35 45 48 Class java/lang/NoSuchFieldError\n 49 59 62 Class java/lang/NoSuchFieldError\n}\n",
"javap_err": ""
},
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day23.class",
"javap": "Compiled from \"Day23.kt\"\npublic final class Day23 {\n private final Direction[] directions;\n\n public Day23();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iconst_4\n 6: anewarray #10 // class Direction\n 9: astore_1\n 10: aload_1\n 11: iconst_0\n 12: getstatic #14 // Field Direction.Up:LDirection;\n 15: aastore\n 16: aload_1\n 17: iconst_1\n 18: getstatic #17 // Field Direction.Down:LDirection;\n 21: aastore\n 22: aload_1\n 23: iconst_2\n 24: getstatic #20 // Field Direction.Left:LDirection;\n 27: aastore\n 28: aload_1\n 29: iconst_3\n 30: getstatic #23 // Field Direction.Right:LDirection;\n 33: aastore\n 34: aload_1\n 35: putfield #27 // Field directions:[LDirection;\n 38: return\n\n public final java.util.Set<Point> parse(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #35 // String input\n 3: invokestatic #41 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #43 // class java/lang/Iterable\n 10: astore_2\n 11: new #45 // class java/util/ArrayList\n 14: dup\n 15: invokespecial #46 // Method java/util/ArrayList.\"<init>\":()V\n 18: checkcast #48 // class java/util/Collection\n 21: astore_3\n 22: iconst_0\n 23: istore 4\n 25: aload_2\n 26: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 31: astore 5\n 33: aload 5\n 35: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 40: ifeq 221\n 43: aload 5\n 45: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 50: astore 6\n 52: iload 4\n 54: iinc 4, 1\n 57: istore 7\n 59: iload 7\n 61: ifge 67\n 64: invokestatic #67 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 67: iload 7\n 69: aload 6\n 71: checkcast #69 // class java/lang/String\n 74: astore 8\n 76: istore 9\n 78: iconst_0\n 79: istore 10\n 81: aload 8\n 83: checkcast #71 // class java/lang/CharSequence\n 86: astore 11\n 88: iconst_0\n 89: istore 12\n 91: aload 11\n 93: astore 13\n 95: new #45 // class java/util/ArrayList\n 98: dup\n 99: aload 11\n 101: invokeinterface #75, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 106: invokespecial #78 // Method java/util/ArrayList.\"<init>\":(I)V\n 109: checkcast #48 // class java/util/Collection\n 112: astore 14\n 114: iconst_0\n 115: istore 15\n 117: iconst_0\n 118: istore 16\n 120: iconst_0\n 121: istore 17\n 123: iload 17\n 125: aload 13\n 127: invokeinterface #75, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 132: if_icmpge 202\n 135: aload 13\n 137: iload 17\n 139: invokeinterface #82, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 144: istore 18\n 146: aload 14\n 148: iload 16\n 150: iinc 16, 1\n 153: iload 18\n 155: istore 19\n 157: istore 20\n 159: astore 21\n 161: iconst_0\n 162: istore 22\n 164: iload 19\n 166: bipush 35\n 168: if_icmpne 185\n 171: new #84 // class Point\n 174: dup\n 175: iload 20\n 177: iload 9\n 179: invokespecial #87 // Method Point.\"<init>\":(II)V\n 182: goto 186\n 185: aconst_null\n 186: nop\n 187: aload 21\n 189: swap\n 190: invokeinterface #91, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 195: pop\n 196: iinc 17, 1\n 199: goto 123\n 202: aload 14\n 204: checkcast #93 // class java/util/List\n 207: nop\n 208: checkcast #43 // class java/lang/Iterable\n 211: nop\n 212: aload_3\n 213: swap\n 214: invokestatic #97 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 217: pop\n 218: goto 33\n 221: aload_3\n 222: checkcast #93 // class java/util/List\n 225: checkcast #43 // class java/lang/Iterable\n 228: invokestatic #101 // Method kotlin/collections/CollectionsKt.filterNotNull:(Ljava/lang/Iterable;)Ljava/util/List;\n 231: checkcast #43 // class java/lang/Iterable\n 234: invokestatic #105 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 237: areturn\n\n public final Direction getNext(Direction);\n Code:\n 0: aload_1\n 1: ldc #128 // String direction\n 3: invokestatic #41 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getfield #27 // Field directions:[LDirection;\n 10: aload_1\n 11: invokestatic #134 // Method kotlin/collections/ArraysKt.indexOf:([Ljava/lang/Object;Ljava/lang/Object;)I\n 14: iconst_1\n 15: iadd\n 16: aload_0\n 17: getfield #27 // Field directions:[LDirection;\n 20: arraylength\n 21: iadd\n 22: aload_0\n 23: getfield #27 // Field directions:[LDirection;\n 26: arraylength\n 27: irem\n 28: istore_2\n 29: aload_0\n 30: getfield #27 // Field directions:[LDirection;\n 33: iload_2\n 34: aaload\n 35: areturn\n\n public final java.util.List<Point> getNeighbors(Point);\n Code:\n 0: aload_1\n 1: ldc #140 // String point\n 3: invokestatic #41 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #142 // class kotlin/ranges/IntRange\n 9: dup\n 10: iconst_m1\n 11: iconst_1\n 12: invokespecial #143 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 15: checkcast #43 // class java/lang/Iterable\n 18: astore_2\n 19: nop\n 20: iconst_0\n 21: istore_3\n 22: aload_2\n 23: astore 4\n 25: new #45 // class java/util/ArrayList\n 28: dup\n 29: invokespecial #46 // Method java/util/ArrayList.\"<init>\":()V\n 32: checkcast #48 // class java/util/Collection\n 35: astore 5\n 37: iconst_0\n 38: istore 6\n 40: aload 4\n 42: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 47: astore 7\n 49: aload 7\n 51: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 56: ifeq 216\n 59: aload 7\n 61: checkcast #145 // class kotlin/collections/IntIterator\n 64: invokevirtual #148 // Method kotlin/collections/IntIterator.nextInt:()I\n 67: istore 8\n 69: iload 8\n 71: istore 9\n 73: iconst_0\n 74: istore 10\n 76: new #142 // class kotlin/ranges/IntRange\n 79: dup\n 80: iconst_m1\n 81: iconst_1\n 82: invokespecial #143 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 85: checkcast #43 // class java/lang/Iterable\n 88: astore 11\n 90: nop\n 91: iconst_0\n 92: istore 12\n 94: aload 11\n 96: astore 13\n 98: new #45 // class java/util/ArrayList\n 101: dup\n 102: aload 11\n 104: bipush 10\n 106: invokestatic #152 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 109: invokespecial #78 // Method java/util/ArrayList.\"<init>\":(I)V\n 112: checkcast #48 // class java/util/Collection\n 115: astore 14\n 117: iconst_0\n 118: istore 15\n 120: aload 13\n 122: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 127: astore 16\n 129: aload 16\n 131: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 136: ifeq 193\n 139: aload 16\n 141: checkcast #145 // class kotlin/collections/IntIterator\n 144: invokevirtual #148 // Method kotlin/collections/IntIterator.nextInt:()I\n 147: istore 17\n 149: aload 14\n 151: iload 17\n 153: istore 18\n 155: astore 19\n 157: iconst_0\n 158: istore 20\n 160: new #84 // class Point\n 163: dup\n 164: aload_1\n 165: invokevirtual #155 // Method Point.getX:()I\n 168: iload 9\n 170: iadd\n 171: aload_1\n 172: invokevirtual #158 // Method Point.getY:()I\n 175: iload 18\n 177: iadd\n 178: invokespecial #87 // Method Point.\"<init>\":(II)V\n 181: aload 19\n 183: swap\n 184: invokeinterface #91, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 189: pop\n 190: goto 129\n 193: aload 14\n 195: checkcast #93 // class java/util/List\n 198: nop\n 199: checkcast #43 // class java/lang/Iterable\n 202: nop\n 203: astore 9\n 205: aload 5\n 207: aload 9\n 209: invokestatic #97 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 212: pop\n 213: goto 49\n 216: aload 5\n 218: checkcast #93 // class java/util/List\n 221: nop\n 222: checkcast #43 // class java/lang/Iterable\n 225: astore_2\n 226: nop\n 227: iconst_0\n 228: istore_3\n 229: aload_2\n 230: astore 4\n 232: new #45 // class java/util/ArrayList\n 235: dup\n 236: invokespecial #46 // Method java/util/ArrayList.\"<init>\":()V\n 239: checkcast #48 // class java/util/Collection\n 242: astore 5\n 244: iconst_0\n 245: istore 6\n 247: aload 4\n 249: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 254: astore 7\n 256: aload 7\n 258: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 263: ifeq 315\n 266: aload 7\n 268: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 273: astore 8\n 275: aload 8\n 277: checkcast #84 // class Point\n 280: astore 9\n 282: iconst_0\n 283: istore 10\n 285: aload 9\n 287: aload_1\n 288: invokestatic #162 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 291: ifne 298\n 294: iconst_1\n 295: goto 299\n 298: iconst_0\n 299: ifeq 256\n 302: aload 5\n 304: aload 8\n 306: invokeinterface #91, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 311: pop\n 312: goto 256\n 315: aload 5\n 317: checkcast #93 // class java/util/List\n 320: nop\n 321: areturn\n\n public final Point canMove(Point, java.util.List<Point>, Direction);\n Code:\n 0: aload_1\n 1: ldc #140 // String point\n 3: invokestatic #41 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #189 // String neighbors\n 9: invokestatic #41 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_3\n 13: ldc #128 // String direction\n 15: invokestatic #41 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: aload_3\n 19: getstatic #195 // Field Day23$WhenMappings.$EnumSwitchMapping$0:[I\n 22: swap\n 23: invokevirtual #198 // Method Direction.ordinal:()I\n 26: iaload\n 27: tableswitch { // 1 to 4\n 1: 56\n 2: 182\n 3: 308\n 4: 434\n default: 560\n }\n 56: aload_2\n 57: checkcast #43 // class java/lang/Iterable\n 60: astore 4\n 62: iconst_0\n 63: istore 5\n 65: aload 4\n 67: instanceof #48 // class java/util/Collection\n 70: ifeq 90\n 73: aload 4\n 75: checkcast #48 // class java/util/Collection\n 78: invokeinterface #201, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 83: ifeq 90\n 86: iconst_1\n 87: goto 155\n 90: aload 4\n 92: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 97: astore 6\n 99: aload 6\n 101: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 106: ifeq 154\n 109: aload 6\n 111: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 116: astore 7\n 118: aload 7\n 120: checkcast #84 // class Point\n 123: astore 8\n 125: iconst_0\n 126: istore 9\n 128: aload 8\n 130: invokevirtual #158 // Method Point.getY:()I\n 133: aload_1\n 134: invokevirtual #158 // Method Point.getY:()I\n 137: iconst_1\n 138: isub\n 139: if_icmpne 146\n 142: iconst_1\n 143: goto 147\n 146: iconst_0\n 147: ifeq 99\n 150: iconst_0\n 151: goto 155\n 154: iconst_1\n 155: ifeq 178\n 158: new #84 // class Point\n 161: dup\n 162: aload_1\n 163: invokevirtual #155 // Method Point.getX:()I\n 166: aload_1\n 167: invokevirtual #158 // Method Point.getY:()I\n 170: iconst_1\n 171: isub\n 172: invokespecial #87 // Method Point.\"<init>\":(II)V\n 175: goto 568\n 178: aconst_null\n 179: goto 568\n 182: aload_2\n 183: checkcast #43 // class java/lang/Iterable\n 186: astore 4\n 188: iconst_0\n 189: istore 5\n 191: aload 4\n 193: instanceof #48 // class java/util/Collection\n 196: ifeq 216\n 199: aload 4\n 201: checkcast #48 // class java/util/Collection\n 204: invokeinterface #201, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 209: ifeq 216\n 212: iconst_1\n 213: goto 281\n 216: aload 4\n 218: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 223: astore 6\n 225: aload 6\n 227: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 232: ifeq 280\n 235: aload 6\n 237: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 242: astore 7\n 244: aload 7\n 246: checkcast #84 // class Point\n 249: astore 8\n 251: iconst_0\n 252: istore 9\n 254: aload 8\n 256: invokevirtual #158 // Method Point.getY:()I\n 259: aload_1\n 260: invokevirtual #158 // Method Point.getY:()I\n 263: iconst_1\n 264: iadd\n 265: if_icmpne 272\n 268: iconst_1\n 269: goto 273\n 272: iconst_0\n 273: ifeq 225\n 276: iconst_0\n 277: goto 281\n 280: iconst_1\n 281: ifeq 304\n 284: new #84 // class Point\n 287: dup\n 288: aload_1\n 289: invokevirtual #155 // Method Point.getX:()I\n 292: aload_1\n 293: invokevirtual #158 // Method Point.getY:()I\n 296: iconst_1\n 297: iadd\n 298: invokespecial #87 // Method Point.\"<init>\":(II)V\n 301: goto 568\n 304: aconst_null\n 305: goto 568\n 308: aload_2\n 309: checkcast #43 // class java/lang/Iterable\n 312: astore 4\n 314: iconst_0\n 315: istore 5\n 317: aload 4\n 319: instanceof #48 // class java/util/Collection\n 322: ifeq 342\n 325: aload 4\n 327: checkcast #48 // class java/util/Collection\n 330: invokeinterface #201, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 335: ifeq 342\n 338: iconst_1\n 339: goto 407\n 342: aload 4\n 344: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 349: astore 6\n 351: aload 6\n 353: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 358: ifeq 406\n 361: aload 6\n 363: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 368: astore 7\n 370: aload 7\n 372: checkcast #84 // class Point\n 375: astore 8\n 377: iconst_0\n 378: istore 9\n 380: aload 8\n 382: invokevirtual #155 // Method Point.getX:()I\n 385: aload_1\n 386: invokevirtual #155 // Method Point.getX:()I\n 389: iconst_1\n 390: isub\n 391: if_icmpne 398\n 394: iconst_1\n 395: goto 399\n 398: iconst_0\n 399: ifeq 351\n 402: iconst_0\n 403: goto 407\n 406: iconst_1\n 407: ifeq 430\n 410: new #84 // class Point\n 413: dup\n 414: aload_1\n 415: invokevirtual #155 // Method Point.getX:()I\n 418: iconst_1\n 419: isub\n 420: aload_1\n 421: invokevirtual #158 // Method Point.getY:()I\n 424: invokespecial #87 // Method Point.\"<init>\":(II)V\n 427: goto 568\n 430: aconst_null\n 431: goto 568\n 434: aload_2\n 435: checkcast #43 // class java/lang/Iterable\n 438: astore 4\n 440: iconst_0\n 441: istore 5\n 443: aload 4\n 445: instanceof #48 // class java/util/Collection\n 448: ifeq 468\n 451: aload 4\n 453: checkcast #48 // class java/util/Collection\n 456: invokeinterface #201, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 461: ifeq 468\n 464: iconst_1\n 465: goto 533\n 468: aload 4\n 470: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 475: astore 6\n 477: aload 6\n 479: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 484: ifeq 532\n 487: aload 6\n 489: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 494: astore 7\n 496: aload 7\n 498: checkcast #84 // class Point\n 501: astore 8\n 503: iconst_0\n 504: istore 9\n 506: aload 8\n 508: invokevirtual #155 // Method Point.getX:()I\n 511: aload_1\n 512: invokevirtual #155 // Method Point.getX:()I\n 515: iconst_1\n 516: iadd\n 517: if_icmpne 524\n 520: iconst_1\n 521: goto 525\n 524: iconst_0\n 525: ifeq 477\n 528: iconst_0\n 529: goto 533\n 532: iconst_1\n 533: ifeq 556\n 536: new #84 // class Point\n 539: dup\n 540: aload_1\n 541: invokevirtual #155 // Method Point.getX:()I\n 544: iconst_1\n 545: iadd\n 546: aload_1\n 547: invokevirtual #158 // Method Point.getY:()I\n 550: invokespecial #87 // Method Point.\"<init>\":(II)V\n 553: goto 568\n 556: aconst_null\n 557: goto 568\n 560: new #203 // class kotlin/NoWhenBranchMatchedException\n 563: dup\n 564: invokespecial #204 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 567: athrow\n 568: areturn\n\n public final java.util.Set<Point> move(java.util.Set<Point>, Direction);\n Code:\n 0: aload_1\n 1: ldc #216 // String points\n 3: invokestatic #41 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #128 // String direction\n 9: invokestatic #41 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #218 // class java/util/LinkedHashMap\n 15: dup\n 16: invokespecial #219 // Method java/util/LinkedHashMap.\"<init>\":()V\n 19: checkcast #221 // class java/util/Map\n 22: astore_3\n 23: aload_1\n 24: invokeinterface #224, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 29: astore 4\n 31: aload 4\n 33: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 38: ifeq 221\n 41: aload 4\n 43: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 48: checkcast #84 // class Point\n 51: astore 5\n 53: aload_0\n 54: aload 5\n 56: invokevirtual #226 // Method getNeighbors:(LPoint;)Ljava/util/List;\n 59: checkcast #43 // class java/lang/Iterable\n 62: astore 7\n 64: iconst_0\n 65: istore 8\n 67: aload 7\n 69: astore 9\n 71: new #45 // class java/util/ArrayList\n 74: dup\n 75: invokespecial #46 // Method java/util/ArrayList.\"<init>\":()V\n 78: checkcast #48 // class java/util/Collection\n 81: astore 10\n 83: iconst_0\n 84: istore 11\n 86: aload 9\n 88: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 93: astore 12\n 95: aload 12\n 97: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 102: ifeq 148\n 105: aload 12\n 107: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 112: astore 13\n 114: aload 13\n 116: checkcast #84 // class Point\n 119: astore 14\n 121: iconst_0\n 122: istore 15\n 124: aload_1\n 125: aload 14\n 127: invokeinterface #229, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 132: ifeq 95\n 135: aload 10\n 137: aload 13\n 139: invokeinterface #91, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 144: pop\n 145: goto 95\n 148: aload 10\n 150: checkcast #93 // class java/util/List\n 153: nop\n 154: astore 6\n 156: aload 6\n 158: invokeinterface #230, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 163: ifeq 169\n 166: goto 31\n 169: aload_2\n 170: astore 7\n 172: nop\n 173: aload_0\n 174: aload 5\n 176: aload 6\n 178: aload 7\n 180: invokevirtual #232 // Method canMove:(LPoint;Ljava/util/List;LDirection;)LPoint;\n 183: astore 8\n 185: aload 8\n 187: ifnull 204\n 190: aload_3\n 191: aload 5\n 193: aload 8\n 195: invokeinterface #236, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 200: pop\n 201: goto 31\n 204: aload_0\n 205: aload 7\n 207: invokevirtual #238 // Method getNext:(LDirection;)LDirection;\n 210: astore 7\n 212: aload 7\n 214: aload_2\n 215: if_acmpne 172\n 218: goto 31\n 221: aload_3\n 222: invokeinterface #242, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 227: checkcast #43 // class java/lang/Iterable\n 230: astore 5\n 232: nop\n 233: iconst_0\n 234: istore 6\n 236: aload 5\n 238: astore 7\n 240: new #218 // class java/util/LinkedHashMap\n 243: dup\n 244: invokespecial #219 // Method java/util/LinkedHashMap.\"<init>\":()V\n 247: checkcast #221 // class java/util/Map\n 250: astore 8\n 252: iconst_0\n 253: istore 9\n 255: aload 7\n 257: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 262: astore 10\n 264: aload 10\n 266: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 271: ifeq 404\n 274: aload 10\n 276: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 281: astore 11\n 283: aload 11\n 285: checkcast #244 // class java/util/Map$Entry\n 288: astore 12\n 290: iconst_0\n 291: istore 13\n 293: aload 12\n 295: invokeinterface #247, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 300: checkcast #84 // class Point\n 303: astore 14\n 305: aload 8\n 307: astore 15\n 309: iconst_0\n 310: istore 16\n 312: aload 15\n 314: aload 14\n 316: invokeinterface #251, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 321: astore 17\n 323: aload 17\n 325: ifnonnull 360\n 328: iconst_0\n 329: istore 18\n 331: new #45 // class java/util/ArrayList\n 334: dup\n 335: invokespecial #46 // Method java/util/ArrayList.\"<init>\":()V\n 338: checkcast #93 // class java/util/List\n 341: astore 18\n 343: aload 15\n 345: aload 14\n 347: aload 18\n 349: invokeinterface #236, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 354: pop\n 355: aload 18\n 357: goto 362\n 360: aload 17\n 362: nop\n 363: checkcast #93 // class java/util/List\n 366: astore 12\n 368: aload 12\n 370: aload 11\n 372: checkcast #244 // class java/util/Map$Entry\n 375: astore 13\n 377: astore 20\n 379: iconst_0\n 380: istore 19\n 382: aload 13\n 384: invokeinterface #254, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 389: checkcast #84 // class Point\n 392: aload 20\n 394: swap\n 395: invokeinterface #255, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 400: pop\n 401: goto 264\n 404: aload 8\n 406: nop\n 407: astore 4\n 409: aload 4\n 411: astore 6\n 413: iconst_0\n 414: istore 7\n 416: aload 6\n 418: astore 8\n 420: new #218 // class java/util/LinkedHashMap\n 423: dup\n 424: invokespecial #219 // Method java/util/LinkedHashMap.\"<init>\":()V\n 427: checkcast #221 // class java/util/Map\n 430: astore 9\n 432: iconst_0\n 433: istore 10\n 435: aload 8\n 437: invokeinterface #242, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 442: invokeinterface #224, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 447: astore 11\n 449: aload 11\n 451: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 456: ifeq 530\n 459: aload 11\n 461: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 466: checkcast #244 // class java/util/Map$Entry\n 469: astore 12\n 471: aload 12\n 473: astore 13\n 475: iconst_0\n 476: istore 14\n 478: aload 13\n 480: invokeinterface #247, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 485: checkcast #93 // class java/util/List\n 488: invokeinterface #258, 1 // InterfaceMethod java/util/List.size:()I\n 493: iconst_1\n 494: if_icmpne 501\n 497: iconst_1\n 498: goto 502\n 501: iconst_0\n 502: ifeq 449\n 505: aload 9\n 507: aload 12\n 509: invokeinterface #254, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 514: aload 12\n 516: invokeinterface #247, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 521: invokeinterface #236, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 526: pop\n 527: goto 449\n 530: aload 9\n 532: nop\n 533: astore 6\n 535: nop\n 536: iconst_0\n 537: istore 7\n 539: aload 6\n 541: astore 8\n 543: new #45 // class java/util/ArrayList\n 546: dup\n 547: aload 6\n 549: invokeinterface #259, 1 // InterfaceMethod java/util/Map.size:()I\n 554: invokespecial #78 // Method java/util/ArrayList.\"<init>\":(I)V\n 557: checkcast #48 // class java/util/Collection\n 560: astore 9\n 562: iconst_0\n 563: istore 10\n 565: aload 8\n 567: invokeinterface #242, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 572: invokeinterface #224, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 577: astore 11\n 579: aload 11\n 581: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 586: ifeq 650\n 589: aload 11\n 591: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 596: checkcast #244 // class java/util/Map$Entry\n 599: astore 12\n 601: aload 9\n 603: aload 12\n 605: astore 13\n 607: astore 20\n 609: iconst_0\n 610: istore 14\n 612: aload 13\n 614: invokeinterface #247, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 619: checkcast #93 // class java/util/List\n 622: iconst_0\n 623: invokeinterface #262, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 628: aload 13\n 630: invokeinterface #254, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 635: invokestatic #268 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 638: aload 20\n 640: swap\n 641: invokeinterface #91, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 646: pop\n 647: goto 579\n 650: aload 9\n 652: checkcast #93 // class java/util/List\n 655: nop\n 656: checkcast #43 // class java/lang/Iterable\n 659: invokestatic #274 // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;\n 662: astore 5\n 664: aload_1\n 665: checkcast #43 // class java/lang/Iterable\n 668: astore 6\n 670: nop\n 671: iconst_0\n 672: istore 7\n 674: aload 6\n 676: astore 8\n 678: new #45 // class java/util/ArrayList\n 681: dup\n 682: invokespecial #46 // Method java/util/ArrayList.\"<init>\":()V\n 685: checkcast #48 // class java/util/Collection\n 688: astore 9\n 690: iconst_0\n 691: istore 10\n 693: aload 8\n 695: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 700: astore 11\n 702: aload 11\n 704: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 709: ifeq 764\n 712: aload 11\n 714: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 719: astore 12\n 721: aload 12\n 723: checkcast #84 // class Point\n 726: astore 13\n 728: iconst_0\n 729: istore 14\n 731: aload 5\n 733: aload 13\n 735: invokeinterface #277, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 740: ifne 747\n 743: iconst_1\n 744: goto 748\n 747: iconst_0\n 748: ifeq 702\n 751: aload 9\n 753: aload 12\n 755: invokeinterface #91, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 760: pop\n 761: goto 702\n 764: aload 9\n 766: checkcast #93 // class java/util/List\n 769: nop\n 770: checkcast #43 // class java/lang/Iterable\n 773: aload 5\n 775: invokeinterface #281, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 780: checkcast #43 // class java/lang/Iterable\n 783: invokestatic #285 // Method kotlin/collections/CollectionsKt.union:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 786: checkcast #43 // class java/lang/Iterable\n 789: invokestatic #105 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 792: areturn\n\n public final java.util.Set<Point> play1(java.util.Set<Point>);\n Code:\n 0: aload_1\n 1: ldc #216 // String points\n 3: invokestatic #41 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #14 // Field Direction.Up:LDirection;\n 9: astore_2\n 10: aload_1\n 11: astore_3\n 12: iconst_1\n 13: istore 4\n 15: iload 4\n 17: bipush 11\n 19: if_icmpge 41\n 22: aload_0\n 23: aload_3\n 24: aload_2\n 25: invokevirtual #316 // Method move:(Ljava/util/Set;LDirection;)Ljava/util/Set;\n 28: astore_3\n 29: aload_0\n 30: aload_2\n 31: invokevirtual #238 // Method getNext:(LDirection;)LDirection;\n 34: astore_2\n 35: iinc 4, 1\n 38: goto 15\n 41: aload_3\n 42: areturn\n\n public final int play2(java.util.Set<Point>);\n Code:\n 0: aload_1\n 1: ldc #216 // String points\n 3: invokestatic #41 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #14 // Field Direction.Up:LDirection;\n 9: astore_2\n 10: aload_1\n 11: astore_3\n 12: iconst_0\n 13: istore 4\n 15: aload_0\n 16: aload_3\n 17: aload_2\n 18: invokevirtual #316 // Method move:(Ljava/util/Set;LDirection;)Ljava/util/Set;\n 21: astore 5\n 23: aload_0\n 24: aload_2\n 25: invokevirtual #238 // Method getNext:(LDirection;)LDirection;\n 28: astore_2\n 29: aload 5\n 31: aload_3\n 32: invokestatic #162 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 35: istore 6\n 37: aload 5\n 39: astore_3\n 40: iinc 4, 1\n 43: iload 6\n 45: ifeq 15\n 48: iload 4\n 50: ireturn\n\n public final void print(java.util.Set<Point>);\n Code:\n 0: aload_1\n 1: ldc #216 // String points\n 3: invokestatic #41 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #43 // class java/lang/Iterable\n 10: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 15: astore 4\n 17: aload 4\n 19: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 24: ifne 35\n 27: new #328 // class java/util/NoSuchElementException\n 30: dup\n 31: invokespecial #329 // Method java/util/NoSuchElementException.\"<init>\":()V\n 34: athrow\n 35: aload 4\n 37: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 42: checkcast #84 // class Point\n 45: astore 5\n 47: iconst_0\n 48: istore 6\n 50: aload 5\n 52: invokevirtual #155 // Method Point.getX:()I\n 55: istore 5\n 57: aload 4\n 59: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 64: ifeq 103\n 67: aload 4\n 69: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 74: checkcast #84 // class Point\n 77: astore 6\n 79: iconst_0\n 80: istore 7\n 82: aload 6\n 84: invokevirtual #155 // Method Point.getX:()I\n 87: istore 6\n 89: iload 5\n 91: iload 6\n 93: if_icmpge 57\n 96: iload 6\n 98: istore 5\n 100: goto 57\n 103: iload 5\n 105: istore_2\n 106: aload_1\n 107: checkcast #43 // class java/lang/Iterable\n 110: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 115: astore 5\n 117: aload 5\n 119: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 124: ifne 135\n 127: new #328 // class java/util/NoSuchElementException\n 130: dup\n 131: invokespecial #329 // Method java/util/NoSuchElementException.\"<init>\":()V\n 134: athrow\n 135: aload 5\n 137: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 142: checkcast #84 // class Point\n 145: astore 6\n 147: iconst_0\n 148: istore 7\n 150: aload 6\n 152: invokevirtual #158 // Method Point.getY:()I\n 155: istore 6\n 157: aload 5\n 159: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 164: ifeq 203\n 167: aload 5\n 169: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 174: checkcast #84 // class Point\n 177: astore 7\n 179: iconst_0\n 180: istore 8\n 182: aload 7\n 184: invokevirtual #158 // Method Point.getY:()I\n 187: istore 7\n 189: iload 6\n 191: iload 7\n 193: if_icmpge 157\n 196: iload 7\n 198: istore 6\n 200: goto 157\n 203: iload 6\n 205: istore_3\n 206: aload_1\n 207: checkcast #43 // class java/lang/Iterable\n 210: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 215: astore 6\n 217: aload 6\n 219: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 224: ifne 235\n 227: new #328 // class java/util/NoSuchElementException\n 230: dup\n 231: invokespecial #329 // Method java/util/NoSuchElementException.\"<init>\":()V\n 234: athrow\n 235: aload 6\n 237: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 242: checkcast #84 // class Point\n 245: astore 7\n 247: iconst_0\n 248: istore 8\n 250: aload 7\n 252: invokevirtual #155 // Method Point.getX:()I\n 255: istore 7\n 257: aload 6\n 259: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 264: ifeq 303\n 267: aload 6\n 269: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 274: checkcast #84 // class Point\n 277: astore 8\n 279: iconst_0\n 280: istore 9\n 282: aload 8\n 284: invokevirtual #155 // Method Point.getX:()I\n 287: istore 8\n 289: iload 7\n 291: iload 8\n 293: if_icmple 257\n 296: iload 8\n 298: istore 7\n 300: goto 257\n 303: iload 7\n 305: istore 4\n 307: aload_1\n 308: checkcast #43 // class java/lang/Iterable\n 311: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 316: astore 7\n 318: aload 7\n 320: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 325: ifne 336\n 328: new #328 // class java/util/NoSuchElementException\n 331: dup\n 332: invokespecial #329 // Method java/util/NoSuchElementException.\"<init>\":()V\n 335: athrow\n 336: aload 7\n 338: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 343: checkcast #84 // class Point\n 346: astore 8\n 348: iconst_0\n 349: istore 9\n 351: aload 8\n 353: invokevirtual #158 // Method Point.getY:()I\n 356: istore 8\n 358: aload 7\n 360: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 365: ifeq 404\n 368: aload 7\n 370: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 375: checkcast #84 // class Point\n 378: astore 9\n 380: iconst_0\n 381: istore 10\n 383: aload 9\n 385: invokevirtual #158 // Method Point.getY:()I\n 388: istore 9\n 390: iload 8\n 392: iload 9\n 394: if_icmple 358\n 397: iload 9\n 399: istore 8\n 401: goto 358\n 404: iload 8\n 406: istore 5\n 408: iload 5\n 410: iconst_1\n 411: isub\n 412: istore 6\n 414: iload_3\n 415: iconst_1\n 416: iadd\n 417: istore 7\n 419: iload 6\n 421: iload 7\n 423: if_icmpgt 523\n 426: iload 4\n 428: iconst_1\n 429: isub\n 430: istore 8\n 432: iload_2\n 433: iconst_1\n 434: iadd\n 435: istore 9\n 437: iload 8\n 439: iload 9\n 441: if_icmpgt 504\n 444: aload_1\n 445: new #84 // class Point\n 448: dup\n 449: iload 8\n 451: iload 6\n 453: invokespecial #87 // Method Point.\"<init>\":(II)V\n 456: invokeinterface #229, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 461: ifeq 479\n 464: bipush 35\n 466: istore 10\n 468: getstatic #335 // Field java/lang/System.out:Ljava/io/PrintStream;\n 471: iload 10\n 473: invokevirtual #340 // Method java/io/PrintStream.print:(C)V\n 476: goto 491\n 479: bipush 46\n 481: istore 10\n 483: getstatic #335 // Field java/lang/System.out:Ljava/io/PrintStream;\n 486: iload 10\n 488: invokevirtual #340 // Method java/io/PrintStream.print:(C)V\n 491: iload 8\n 493: iload 9\n 495: if_icmpeq 504\n 498: iinc 8, 1\n 501: goto 444\n 504: getstatic #335 // Field java/lang/System.out:Ljava/io/PrintStream;\n 507: invokevirtual #343 // Method java/io/PrintStream.println:()V\n 510: iload 6\n 512: iload 7\n 514: if_icmpeq 523\n 517: iinc 6, 1\n 520: goto 426\n 523: getstatic #335 // Field java/lang/System.out:Ljava/io/PrintStream;\n 526: invokevirtual #343 // Method java/io/PrintStream.println:()V\n 529: return\n\n public final java.lang.String part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #35 // String input\n 3: invokestatic #41 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokevirtual #356 // Method parse:(Ljava/util/List;)Ljava/util/Set;\n 11: astore_2\n 12: aload_0\n 13: aload_2\n 14: invokevirtual #358 // Method play1:(Ljava/util/Set;)Ljava/util/Set;\n 17: astore_3\n 18: aload_0\n 19: aload_3\n 20: invokespecial #362 // Method calc:(Ljava/util/Set;)Ljava/lang/String;\n 23: areturn\n\n private final java.lang.String calc(java.util.Set<Point>);\n Code:\n 0: aload_1\n 1: checkcast #43 // class java/lang/Iterable\n 4: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 9: astore 4\n 11: aload 4\n 13: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 18: ifne 29\n 21: new #328 // class java/util/NoSuchElementException\n 24: dup\n 25: invokespecial #329 // Method java/util/NoSuchElementException.\"<init>\":()V\n 28: athrow\n 29: aload 4\n 31: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 36: checkcast #84 // class Point\n 39: astore 5\n 41: iconst_0\n 42: istore 6\n 44: aload 5\n 46: invokevirtual #155 // Method Point.getX:()I\n 49: istore 5\n 51: aload 4\n 53: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 58: ifeq 97\n 61: aload 4\n 63: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 68: checkcast #84 // class Point\n 71: astore 6\n 73: iconst_0\n 74: istore 7\n 76: aload 6\n 78: invokevirtual #155 // Method Point.getX:()I\n 81: istore 6\n 83: iload 5\n 85: iload 6\n 87: if_icmpge 51\n 90: iload 6\n 92: istore 5\n 94: goto 51\n 97: iload 5\n 99: istore_2\n 100: aload_1\n 101: checkcast #43 // class java/lang/Iterable\n 104: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 109: astore 5\n 111: aload 5\n 113: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 118: ifne 129\n 121: new #328 // class java/util/NoSuchElementException\n 124: dup\n 125: invokespecial #329 // Method java/util/NoSuchElementException.\"<init>\":()V\n 128: athrow\n 129: aload 5\n 131: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 136: checkcast #84 // class Point\n 139: astore 6\n 141: iconst_0\n 142: istore 7\n 144: aload 6\n 146: invokevirtual #158 // Method Point.getY:()I\n 149: istore 6\n 151: aload 5\n 153: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 158: ifeq 197\n 161: aload 5\n 163: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 168: checkcast #84 // class Point\n 171: astore 7\n 173: iconst_0\n 174: istore 8\n 176: aload 7\n 178: invokevirtual #158 // Method Point.getY:()I\n 181: istore 7\n 183: iload 6\n 185: iload 7\n 187: if_icmpge 151\n 190: iload 7\n 192: istore 6\n 194: goto 151\n 197: iload 6\n 199: istore_3\n 200: aload_1\n 201: checkcast #43 // class java/lang/Iterable\n 204: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 209: astore 6\n 211: aload 6\n 213: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 218: ifne 229\n 221: new #328 // class java/util/NoSuchElementException\n 224: dup\n 225: invokespecial #329 // Method java/util/NoSuchElementException.\"<init>\":()V\n 228: athrow\n 229: aload 6\n 231: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 236: checkcast #84 // class Point\n 239: astore 7\n 241: iconst_0\n 242: istore 8\n 244: aload 7\n 246: invokevirtual #155 // Method Point.getX:()I\n 249: istore 7\n 251: aload 6\n 253: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 258: ifeq 297\n 261: aload 6\n 263: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 268: checkcast #84 // class Point\n 271: astore 8\n 273: iconst_0\n 274: istore 9\n 276: aload 8\n 278: invokevirtual #155 // Method Point.getX:()I\n 281: istore 8\n 283: iload 7\n 285: iload 8\n 287: if_icmple 251\n 290: iload 8\n 292: istore 7\n 294: goto 251\n 297: iload 7\n 299: istore 4\n 301: aload_1\n 302: checkcast #43 // class java/lang/Iterable\n 305: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 310: astore 7\n 312: aload 7\n 314: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 319: ifne 330\n 322: new #328 // class java/util/NoSuchElementException\n 325: dup\n 326: invokespecial #329 // Method java/util/NoSuchElementException.\"<init>\":()V\n 329: athrow\n 330: aload 7\n 332: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 337: checkcast #84 // class Point\n 340: astore 8\n 342: iconst_0\n 343: istore 9\n 345: aload 8\n 347: invokevirtual #158 // Method Point.getY:()I\n 350: istore 8\n 352: aload 7\n 354: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 359: ifeq 398\n 362: aload 7\n 364: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 369: checkcast #84 // class Point\n 372: astore 9\n 374: iconst_0\n 375: istore 10\n 377: aload 9\n 379: invokevirtual #158 // Method Point.getY:()I\n 382: istore 9\n 384: iload 8\n 386: iload 9\n 388: if_icmple 352\n 391: iload 9\n 393: istore 8\n 395: goto 352\n 398: iload 8\n 400: istore 5\n 402: iload_2\n 403: iload 4\n 405: isub\n 406: iconst_1\n 407: iadd\n 408: istore 6\n 410: iload_3\n 411: iload 5\n 413: isub\n 414: iconst_1\n 415: iadd\n 416: istore 7\n 418: new #366 // class java/lang/StringBuilder\n 421: dup\n 422: invokespecial #367 // Method java/lang/StringBuilder.\"<init>\":()V\n 425: ldc_w #369 // String dx\n 428: invokevirtual #373 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 431: iload 6\n 433: invokevirtual #376 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 436: ldc_w #378 // String dy\n 439: invokevirtual #373 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 442: iload 7\n 444: invokevirtual #376 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 447: ldc_w #380 // String size\n 450: invokevirtual #373 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 453: aload_1\n 454: invokeinterface #381, 1 // InterfaceMethod java/util/Set.size:()I\n 459: invokevirtual #376 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 462: invokevirtual #385 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 465: getstatic #335 // Field java/lang/System.out:Ljava/io/PrintStream;\n 468: swap\n 469: invokevirtual #388 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 472: iload 6\n 474: iload 7\n 476: imul\n 477: aload_1\n 478: invokeinterface #381, 1 // InterfaceMethod java/util/Set.size:()I\n 483: isub\n 484: istore 8\n 486: iload 8\n 488: invokestatic #392 // Method java/lang/String.valueOf:(I)Ljava/lang/String;\n 491: areturn\n\n public final java.lang.String part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #35 // String input\n 3: invokestatic #41 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokevirtual #356 // Method parse:(Ljava/util/List;)Ljava/util/Set;\n 11: astore_2\n 12: aload_0\n 13: aload_2\n 14: invokevirtual #402 // Method play2:(Ljava/util/Set;)I\n 17: istore_3\n 18: iload_3\n 19: invokestatic #392 // Method java/lang/String.valueOf:(I)Ljava/lang/String;\n 22: areturn\n}\n",
"javap_err": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day13.kt
|
import java.util.Comparator
fun main() {
class TreeNode(
val value: Int?,
val parent: TreeNode?,
val str: String?,
var children: MutableList<TreeNode> = mutableListOf()
)
class TreeNodeComparator(val f: (o1: TreeNode?, o2: TreeNode?) -> Int) : Comparator<TreeNode> {
override fun compare(o1: TreeNode?, o2: TreeNode?): Int {
return f(o1, o2)
}
}
fun parseTree(input: String): TreeNode {
val root = TreeNode(null, null, input)
var currentNode = root
var level = 0
val size = input.length
var i = 0
while (i < size) {
var c = input[i]
when (c) {
'[' -> {
val child = TreeNode(null, currentNode, null)
currentNode.children.add(child)
currentNode = child
level++
}
']' -> {
currentNode = currentNode.parent!!
level--
}
',' -> {
}
in '0'..'9' -> {
var number = ""
while (c in '0'..'9') {
number += c
++i
c = input[i]
}
--i
val child = TreeNode(number.toInt(), currentNode, null)
currentNode.children.add(child)
}
}
++i
}
return root
}
fun parse(input: List<String>): List<Pair<TreeNode, TreeNode>> {
return input
.chunked(3)
.map { chunk ->
parseTree(chunk[0]) to parseTree(chunk[1])
}
}
fun compare(left: Int, right: Int): Boolean? {
if (left == right) {
return null
}
return left < right
}
fun compare(left: TreeNode, right: TreeNode): Boolean? {
if (left.value != null && right.value != null) {
return compare(left.value, right.value)
}
if (left.value == null && right.value == null) {
var i = 0
while (i < left.children.size || i < right.children.size) {
if (left.children.size < right.children.size && i >= left.children.size) {
return true
}
if (left.children.size > right.children.size && i >= right.children.size) {
return false
}
val leftChild = left.children[i]
val rightChild = right.children[i]
val result = compare(leftChild, rightChild)
if (result != null) {
return result
}
++i
}
}
if (left.value != null) {
val subNode = TreeNode(null, left.parent, null)
val subChild = TreeNode(left.value, subNode, null)
subNode.children.add(subChild)
return compare(subNode, right)
}
if (right.value != null) {
val subNode = TreeNode(null, right.parent, null)
val subChild = TreeNode(right.value, subNode, null)
subNode.children.add(subChild)
return compare(left, subNode)
}
return null
}
fun part1(input: List<String>): Int {
val pairs = parse(input)
return pairs
.map { item -> compare(item.first, item.second) }
.mapIndexed { index, r -> if (r == true) index + 1 else 0 }
.sum()
}
fun part2(input: List<String>): Int {
val input1 = input.toMutableList()
input1.add("\n")
input1.add("[[2]]")
input1.add("[[6]]")
input1.add("\n")
val pairs = parse(input1)
val comparator = TreeNodeComparator { o1, o2 ->
when (compare(o1!!, o2!!)) {
true -> -1
false -> 1
else -> 0
}
}
return pairs
.flatMap { item -> listOf(item.first, item.second) }
.sortedWith(comparator)
.mapIndexed { index, treeNode ->
if (treeNode.str == "[[2]]" || treeNode.str == "[[6]]") {
index + 1
} else {
1
}
}
.reduce { acc, i -> acc * i }
}
val testInput = readInput("Day13_test")
assert(part1(testInput), 13)
assert(part2(testInput), 140)
val input = readInput("Day13")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day13Kt$main$TreeNodeComparator.class",
"javap": "Compiled from \"Day13.kt\"\npublic final class Day13Kt$main$TreeNodeComparator implements java.util.Comparator<Day13Kt$main$TreeNode> {\n private final kotlin.jvm.functions.Function2<Day13Kt$main$TreeNode, Day13Kt$main$TreeNode, java.lang.Integer> f;\n\n public Day13Kt$main$TreeNodeComparator(kotlin.jvm.functions.Function2<? super Day13Kt$main$TreeNode, ? super Day13Kt$main$TreeNode, java.lang.Integer>);\n Code:\n 0: aload_1\n 1: ldc #12 // String f\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokespecial #21 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: aload_1\n 12: putfield #24 // Field f:Lkotlin/jvm/functions/Function2;\n 15: return\n\n public final kotlin.jvm.functions.Function2<Day13Kt$main$TreeNode, Day13Kt$main$TreeNode, java.lang.Integer> getF();\n Code:\n 0: aload_0\n 1: getfield #24 // Field f:Lkotlin/jvm/functions/Function2;\n 4: areturn\n\n public int compare(Day13Kt$main$TreeNode, Day13Kt$main$TreeNode);\n Code:\n 0: aload_0\n 1: getfield #24 // Field f:Lkotlin/jvm/functions/Function2;\n 4: aload_1\n 5: aload_2\n 6: invokeinterface #37, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 11: checkcast #39 // class java/lang/Number\n 14: invokevirtual #43 // Method java/lang/Number.intValue:()I\n 17: ireturn\n\n public int compare(java.lang.Object, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #49 // class Day13Kt$main$TreeNode\n 5: aload_2\n 6: checkcast #49 // class Day13Kt$main$TreeNode\n 9: invokevirtual #51 // Method compare:(LDay13Kt$main$TreeNode;LDay13Kt$main$TreeNode;)I\n 12: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day13Kt.class",
"javap": "Compiled from \"Day13.kt\"\npublic final class Day13Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day13_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 10: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 13: bipush 13\n 15: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 18: invokestatic #28 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 21: aload_0\n 22: invokestatic #31 // Method main$part2:(Ljava/util/List;)I\n 25: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 28: sipush 140\n 31: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 34: invokestatic #28 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 37: ldc #33 // String Day13\n 39: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 42: astore_1\n 43: aload_1\n 44: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 47: istore_2\n 48: getstatic #39 // Field java/lang/System.out:Ljava/io/PrintStream;\n 51: iload_2\n 52: invokevirtual #45 // Method java/io/PrintStream.println:(I)V\n 55: aload_1\n 56: invokestatic #31 // Method main$part2:(Ljava/util/List;)I\n 59: istore_2\n 60: getstatic #39 // Field java/lang/System.out:Ljava/io/PrintStream;\n 63: iload_2\n 64: invokevirtual #45 // Method java/io/PrintStream.println:(I)V\n 67: 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 Day13Kt$main$TreeNode main$parseTree(java.lang.String);\n Code:\n 0: new #57 // class Day13Kt$main$TreeNode\n 3: dup\n 4: aconst_null\n 5: aconst_null\n 6: aload_0\n 7: aconst_null\n 8: bipush 8\n 10: aconst_null\n 11: invokespecial #61 // Method Day13Kt$main$TreeNode.\"<init>\":(Ljava/lang/Integer;LDay13Kt$main$TreeNode;Ljava/lang/String;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 14: astore_1\n 15: aload_1\n 16: astore_2\n 17: iconst_0\n 18: istore_3\n 19: aload_0\n 20: invokevirtual #67 // Method java/lang/String.length:()I\n 23: istore 4\n 25: iconst_0\n 26: istore 5\n 28: iload 5\n 30: iload 4\n 32: if_icmpge 256\n 35: aload_0\n 36: iload 5\n 38: invokevirtual #71 // Method java/lang/String.charAt:(I)C\n 41: istore 6\n 43: iload 6\n 45: istore 7\n 47: iload 7\n 49: bipush 91\n 51: if_icmpne 91\n 54: new #57 // class Day13Kt$main$TreeNode\n 57: dup\n 58: aconst_null\n 59: aload_2\n 60: aconst_null\n 61: aconst_null\n 62: bipush 8\n 64: aconst_null\n 65: invokespecial #61 // Method Day13Kt$main$TreeNode.\"<init>\":(Ljava/lang/Integer;LDay13Kt$main$TreeNode;Ljava/lang/String;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 68: astore 8\n 70: aload_2\n 71: invokevirtual #75 // Method Day13Kt$main$TreeNode.getChildren:()Ljava/util/List;\n 74: aload 8\n 76: invokeinterface #81, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 81: pop\n 82: aload 8\n 84: astore_2\n 85: iinc 3, 1\n 88: goto 250\n 91: iload 7\n 93: bipush 93\n 95: if_icmpne 113\n 98: aload_2\n 99: invokevirtual #85 // Method Day13Kt$main$TreeNode.getParent:()LDay13Kt$main$TreeNode;\n 102: dup\n 103: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 106: astore_2\n 107: iinc 3, -1\n 110: goto 250\n 113: iload 7\n 115: bipush 44\n 117: if_icmpeq 250\n 120: bipush 48\n 122: iload 7\n 124: if_icmpgt 142\n 127: iload 7\n 129: bipush 58\n 131: if_icmpge 138\n 134: iconst_1\n 135: goto 143\n 138: iconst_0\n 139: goto 143\n 142: iconst_0\n 143: ifeq 250\n 146: ldc #93 // String\n 148: astore 8\n 150: bipush 48\n 152: iload 6\n 154: if_icmpgt 172\n 157: iload 6\n 159: bipush 58\n 161: if_icmpge 168\n 164: iconst_1\n 165: goto 173\n 168: iconst_0\n 169: goto 173\n 172: iconst_0\n 173: ifeq 212\n 176: new #95 // class java/lang/StringBuilder\n 179: dup\n 180: invokespecial #97 // Method java/lang/StringBuilder.\"<init>\":()V\n 183: aload 8\n 185: invokevirtual #101 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 188: iload 6\n 190: invokevirtual #104 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 193: invokevirtual #108 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 196: astore 8\n 198: iinc 5, 1\n 201: aload_0\n 202: iload 5\n 204: invokevirtual #71 // Method java/lang/String.charAt:(I)C\n 207: istore 6\n 209: goto 150\n 212: iinc 5, -1\n 215: new #57 // class Day13Kt$main$TreeNode\n 218: dup\n 219: aload 8\n 221: invokestatic #112 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 224: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 227: aload_2\n 228: aconst_null\n 229: aconst_null\n 230: bipush 8\n 232: aconst_null\n 233: invokespecial #61 // Method Day13Kt$main$TreeNode.\"<init>\":(Ljava/lang/Integer;LDay13Kt$main$TreeNode;Ljava/lang/String;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 236: astore 9\n 238: aload_2\n 239: invokevirtual #75 // Method Day13Kt$main$TreeNode.getChildren:()Ljava/util/List;\n 242: aload 9\n 244: invokeinterface #81, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 249: pop\n 250: iinc 5, 1\n 253: goto 28\n 256: aload_1\n 257: areturn\n\n private static final java.util.List<kotlin.Pair<Day13Kt$main$TreeNode, Day13Kt$main$TreeNode>> main$parse(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #129 // class java/lang/Iterable\n 4: iconst_3\n 5: invokestatic #135 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;\n 8: checkcast #129 // 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 #137 // class java/util/ArrayList\n 20: dup\n 21: aload_1\n 22: bipush 10\n 24: invokestatic #141 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 27: invokespecial #143 // Method java/util/ArrayList.\"<init>\":(I)V\n 30: checkcast #145 // class java/util/Collection\n 33: astore 4\n 35: iconst_0\n 36: istore 5\n 38: aload_3\n 39: invokeinterface #149, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 6\n 46: aload 6\n 48: invokeinterface #155, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 122\n 56: aload 6\n 58: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 7\n 65: aload 4\n 67: aload 7\n 69: checkcast #77 // 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 #163, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 87: checkcast #63 // class java/lang/String\n 90: invokestatic #165 // Method main$parseTree:(Ljava/lang/String;)LDay13Kt$main$TreeNode;\n 93: aload 8\n 95: iconst_1\n 96: invokeinterface #163, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 101: checkcast #63 // class java/lang/String\n 104: invokestatic #165 // Method main$parseTree:(Ljava/lang/String;)LDay13Kt$main$TreeNode;\n 107: invokestatic #171 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 110: aload 10\n 112: swap\n 113: invokeinterface #172, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 118: pop\n 119: goto 46\n 122: aload 4\n 124: checkcast #77 // class java/util/List\n 127: nop\n 128: areturn\n\n private static final java.lang.Boolean main$compare(int, int);\n Code:\n 0: iload_0\n 1: iload_1\n 2: if_icmpne 7\n 5: aconst_null\n 6: areturn\n 7: iload_0\n 8: iload_1\n 9: if_icmpge 16\n 12: iconst_1\n 13: goto 17\n 16: iconst_0\n 17: invokestatic #190 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 20: areturn\n\n private static final java.lang.Boolean main$compare$1(Day13Kt$main$TreeNode, Day13Kt$main$TreeNode);\n Code:\n 0: aload_0\n 1: invokevirtual #198 // Method Day13Kt$main$TreeNode.getValue:()Ljava/lang/Integer;\n 4: ifnull 32\n 7: aload_1\n 8: invokevirtual #198 // Method Day13Kt$main$TreeNode.getValue:()Ljava/lang/Integer;\n 11: ifnull 32\n 14: aload_0\n 15: invokevirtual #198 // Method Day13Kt$main$TreeNode.getValue:()Ljava/lang/Integer;\n 18: invokevirtual #201 // Method java/lang/Integer.intValue:()I\n 21: aload_1\n 22: invokevirtual #198 // Method Day13Kt$main$TreeNode.getValue:()Ljava/lang/Integer;\n 25: invokevirtual #201 // Method java/lang/Integer.intValue:()I\n 28: invokestatic #203 // Method main$compare:(II)Ljava/lang/Boolean;\n 31: areturn\n 32: aload_0\n 33: invokevirtual #198 // Method Day13Kt$main$TreeNode.getValue:()Ljava/lang/Integer;\n 36: ifnonnull 203\n 39: aload_1\n 40: invokevirtual #198 // Method Day13Kt$main$TreeNode.getValue:()Ljava/lang/Integer;\n 43: ifnonnull 203\n 46: iconst_0\n 47: istore_2\n 48: iload_2\n 49: aload_0\n 50: invokevirtual #75 // Method Day13Kt$main$TreeNode.getChildren:()Ljava/util/List;\n 53: invokeinterface #205, 1 // InterfaceMethod java/util/List.size:()I\n 58: if_icmplt 74\n 61: iload_2\n 62: aload_1\n 63: invokevirtual #75 // Method Day13Kt$main$TreeNode.getChildren:()Ljava/util/List;\n 66: invokeinterface #205, 1 // InterfaceMethod java/util/List.size:()I\n 71: if_icmpge 203\n 74: aload_0\n 75: invokevirtual #75 // Method Day13Kt$main$TreeNode.getChildren:()Ljava/util/List;\n 78: invokeinterface #205, 1 // InterfaceMethod java/util/List.size:()I\n 83: aload_1\n 84: invokevirtual #75 // Method Day13Kt$main$TreeNode.getChildren:()Ljava/util/List;\n 87: invokeinterface #205, 1 // InterfaceMethod java/util/List.size:()I\n 92: if_icmpge 113\n 95: iload_2\n 96: aload_0\n 97: invokevirtual #75 // Method Day13Kt$main$TreeNode.getChildren:()Ljava/util/List;\n 100: invokeinterface #205, 1 // InterfaceMethod java/util/List.size:()I\n 105: if_icmplt 113\n 108: iconst_1\n 109: invokestatic #190 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 112: areturn\n 113: aload_0\n 114: invokevirtual #75 // Method Day13Kt$main$TreeNode.getChildren:()Ljava/util/List;\n 117: invokeinterface #205, 1 // InterfaceMethod java/util/List.size:()I\n 122: aload_1\n 123: invokevirtual #75 // Method Day13Kt$main$TreeNode.getChildren:()Ljava/util/List;\n 126: invokeinterface #205, 1 // InterfaceMethod java/util/List.size:()I\n 131: if_icmple 152\n 134: iload_2\n 135: aload_1\n 136: invokevirtual #75 // Method Day13Kt$main$TreeNode.getChildren:()Ljava/util/List;\n 139: invokeinterface #205, 1 // InterfaceMethod java/util/List.size:()I\n 144: if_icmplt 152\n 147: iconst_0\n 148: invokestatic #190 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 151: areturn\n 152: aload_0\n 153: invokevirtual #75 // Method Day13Kt$main$TreeNode.getChildren:()Ljava/util/List;\n 156: iload_2\n 157: invokeinterface #163, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 162: checkcast #57 // class Day13Kt$main$TreeNode\n 165: astore_3\n 166: aload_1\n 167: invokevirtual #75 // Method Day13Kt$main$TreeNode.getChildren:()Ljava/util/List;\n 170: iload_2\n 171: invokeinterface #163, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 176: checkcast #57 // class Day13Kt$main$TreeNode\n 179: astore 4\n 181: aload_3\n 182: aload 4\n 184: invokestatic #207 // Method main$compare$1:(LDay13Kt$main$TreeNode;LDay13Kt$main$TreeNode;)Ljava/lang/Boolean;\n 187: astore 5\n 189: aload 5\n 191: ifnull 197\n 194: aload 5\n 196: areturn\n 197: iinc 2, 1\n 200: goto 48\n 203: aload_0\n 204: invokevirtual #198 // Method Day13Kt$main$TreeNode.getValue:()Ljava/lang/Integer;\n 207: ifnull 263\n 210: new #57 // class Day13Kt$main$TreeNode\n 213: dup\n 214: aconst_null\n 215: aload_0\n 216: invokevirtual #85 // Method Day13Kt$main$TreeNode.getParent:()LDay13Kt$main$TreeNode;\n 219: aconst_null\n 220: aconst_null\n 221: bipush 8\n 223: aconst_null\n 224: invokespecial #61 // Method Day13Kt$main$TreeNode.\"<init>\":(Ljava/lang/Integer;LDay13Kt$main$TreeNode;Ljava/lang/String;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 227: astore_2\n 228: new #57 // class Day13Kt$main$TreeNode\n 231: dup\n 232: aload_0\n 233: invokevirtual #198 // Method Day13Kt$main$TreeNode.getValue:()Ljava/lang/Integer;\n 236: aload_2\n 237: aconst_null\n 238: aconst_null\n 239: bipush 8\n 241: aconst_null\n 242: invokespecial #61 // Method Day13Kt$main$TreeNode.\"<init>\":(Ljava/lang/Integer;LDay13Kt$main$TreeNode;Ljava/lang/String;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 245: astore_3\n 246: aload_2\n 247: invokevirtual #75 // Method Day13Kt$main$TreeNode.getChildren:()Ljava/util/List;\n 250: aload_3\n 251: invokeinterface #81, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 256: pop\n 257: aload_2\n 258: aload_1\n 259: invokestatic #207 // Method main$compare$1:(LDay13Kt$main$TreeNode;LDay13Kt$main$TreeNode;)Ljava/lang/Boolean;\n 262: areturn\n 263: aload_1\n 264: invokevirtual #198 // Method Day13Kt$main$TreeNode.getValue:()Ljava/lang/Integer;\n 267: ifnull 323\n 270: new #57 // class Day13Kt$main$TreeNode\n 273: dup\n 274: aconst_null\n 275: aload_1\n 276: invokevirtual #85 // Method Day13Kt$main$TreeNode.getParent:()LDay13Kt$main$TreeNode;\n 279: aconst_null\n 280: aconst_null\n 281: bipush 8\n 283: aconst_null\n 284: invokespecial #61 // Method Day13Kt$main$TreeNode.\"<init>\":(Ljava/lang/Integer;LDay13Kt$main$TreeNode;Ljava/lang/String;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 287: astore_2\n 288: new #57 // class Day13Kt$main$TreeNode\n 291: dup\n 292: aload_1\n 293: invokevirtual #198 // Method Day13Kt$main$TreeNode.getValue:()Ljava/lang/Integer;\n 296: aload_2\n 297: aconst_null\n 298: aconst_null\n 299: bipush 8\n 301: aconst_null\n 302: invokespecial #61 // Method Day13Kt$main$TreeNode.\"<init>\":(Ljava/lang/Integer;LDay13Kt$main$TreeNode;Ljava/lang/String;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 305: astore_3\n 306: aload_2\n 307: invokevirtual #75 // Method Day13Kt$main$TreeNode.getChildren:()Ljava/util/List;\n 310: aload_3\n 311: invokeinterface #81, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 316: pop\n 317: aload_0\n 318: aload_2\n 319: invokestatic #207 // Method main$compare$1:(LDay13Kt$main$TreeNode;LDay13Kt$main$TreeNode;)Ljava/lang/Boolean;\n 322: areturn\n 323: aconst_null\n 324: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #216 // Method main$parse:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: aload_1\n 6: checkcast #129 // class java/lang/Iterable\n 9: astore_2\n 10: nop\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: astore 4\n 16: new #137 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: bipush 10\n 23: invokestatic #141 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #143 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #145 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: aload 4\n 39: invokeinterface #149, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 7\n 46: aload 7\n 48: invokeinterface #155, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 110\n 56: aload 7\n 58: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 8\n 65: aload 5\n 67: aload 8\n 69: checkcast #218 // class kotlin/Pair\n 72: astore 9\n 74: astore 14\n 76: iconst_0\n 77: istore 10\n 79: aload 9\n 81: invokevirtual #221 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 84: checkcast #57 // class Day13Kt$main$TreeNode\n 87: aload 9\n 89: invokevirtual #224 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 92: checkcast #57 // class Day13Kt$main$TreeNode\n 95: invokestatic #207 // Method main$compare$1:(LDay13Kt$main$TreeNode;LDay13Kt$main$TreeNode;)Ljava/lang/Boolean;\n 98: aload 14\n 100: swap\n 101: invokeinterface #172, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 106: pop\n 107: goto 46\n 110: aload 5\n 112: checkcast #77 // class java/util/List\n 115: nop\n 116: checkcast #129 // class java/lang/Iterable\n 119: astore_2\n 120: nop\n 121: iconst_0\n 122: istore_3\n 123: aload_2\n 124: astore 4\n 126: new #137 // class java/util/ArrayList\n 129: dup\n 130: aload_2\n 131: bipush 10\n 133: invokestatic #141 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 136: invokespecial #143 // Method java/util/ArrayList.\"<init>\":(I)V\n 139: checkcast #145 // class java/util/Collection\n 142: astore 5\n 144: iconst_0\n 145: istore 6\n 147: iconst_0\n 148: istore 7\n 150: aload 4\n 152: invokeinterface #149, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 157: astore 8\n 159: aload 8\n 161: invokeinterface #155, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 166: ifeq 246\n 169: aload 8\n 171: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 176: astore 9\n 178: aload 5\n 180: iload 7\n 182: iinc 7, 1\n 185: istore 10\n 187: iload 10\n 189: ifge 195\n 192: invokestatic #227 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 195: iload 10\n 197: aload 9\n 199: checkcast #187 // class java/lang/Boolean\n 202: astore 11\n 204: istore 12\n 206: astore 14\n 208: iconst_0\n 209: istore 13\n 211: aload 11\n 213: iconst_1\n 214: invokestatic #190 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 217: invokestatic #231 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 220: ifeq 230\n 223: iload 12\n 225: iconst_1\n 226: iadd\n 227: goto 231\n 230: iconst_0\n 231: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 234: aload 14\n 236: swap\n 237: invokeinterface #172, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 242: pop\n 243: goto 159\n 246: aload 5\n 248: checkcast #77 // class java/util/List\n 251: nop\n 252: checkcast #129 // class java/lang/Iterable\n 255: invokestatic #235 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 258: ireturn\n\n private static final int main$part2$lambda$4(Day13Kt$main$TreeNode, Day13Kt$main$TreeNode);\n Code:\n 0: aload_0\n 1: dup\n 2: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 5: aload_1\n 6: dup\n 7: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 10: invokestatic #207 // Method main$compare$1:(LDay13Kt$main$TreeNode;LDay13Kt$main$TreeNode;)Ljava/lang/Boolean;\n 13: astore_2\n 14: aload_2\n 15: iconst_1\n 16: invokestatic #190 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 19: invokestatic #231 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 22: ifeq 29\n 25: iconst_m1\n 26: goto 45\n 29: aload_2\n 30: iconst_0\n 31: invokestatic #190 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 34: invokestatic #231 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 37: ifeq 44\n 40: iconst_1\n 41: goto 45\n 44: iconst_0\n 45: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #145 // class java/util/Collection\n 4: invokestatic #255 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 7: astore_1\n 8: aload_1\n 9: ldc_w #257 // String \\n\n 12: invokeinterface #81, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 17: pop\n 18: aload_1\n 19: ldc_w #259 // String [[2]]\n 22: invokeinterface #81, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 27: pop\n 28: aload_1\n 29: ldc_w #261 // String [[6]]\n 32: invokeinterface #81, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 37: pop\n 38: aload_1\n 39: ldc_w #257 // String \\n\n 42: invokeinterface #81, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 47: pop\n 48: aload_1\n 49: invokestatic #216 // Method main$parse:(Ljava/util/List;)Ljava/util/List;\n 52: astore_2\n 53: new #263 // class Day13Kt$main$TreeNodeComparator\n 56: dup\n 57: invokedynamic #281, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;\n 62: invokespecial #284 // Method Day13Kt$main$TreeNodeComparator.\"<init>\":(Lkotlin/jvm/functions/Function2;)V\n 65: astore_3\n 66: aload_2\n 67: checkcast #129 // class java/lang/Iterable\n 70: astore 4\n 72: nop\n 73: iconst_0\n 74: istore 5\n 76: aload 4\n 78: astore 6\n 80: new #137 // class java/util/ArrayList\n 83: dup\n 84: invokespecial #285 // Method java/util/ArrayList.\"<init>\":()V\n 87: checkcast #145 // class java/util/Collection\n 90: astore 7\n 92: iconst_0\n 93: istore 8\n 95: aload 6\n 97: invokeinterface #149, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 102: astore 9\n 104: aload 9\n 106: invokeinterface #155, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 111: ifeq 178\n 114: aload 9\n 116: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 121: astore 10\n 123: aload 10\n 125: checkcast #218 // class kotlin/Pair\n 128: astore 11\n 130: iconst_0\n 131: istore 12\n 133: iconst_2\n 134: anewarray #57 // class Day13Kt$main$TreeNode\n 137: astore 13\n 139: aload 13\n 141: iconst_0\n 142: aload 11\n 144: invokevirtual #221 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 147: aastore\n 148: aload 13\n 150: iconst_1\n 151: aload 11\n 153: invokevirtual #224 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 156: aastore\n 157: aload 13\n 159: invokestatic #289 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 162: checkcast #129 // class java/lang/Iterable\n 165: astore 11\n 167: aload 7\n 169: aload 11\n 171: invokestatic #293 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 174: pop\n 175: goto 104\n 178: aload 7\n 180: checkcast #77 // class java/util/List\n 183: nop\n 184: checkcast #129 // class java/lang/Iterable\n 187: aload_3\n 188: checkcast #295 // class java/util/Comparator\n 191: invokestatic #299 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 194: checkcast #129 // class java/lang/Iterable\n 197: astore 4\n 199: nop\n 200: iconst_0\n 201: istore 5\n 203: aload 4\n 205: astore 6\n 207: new #137 // class java/util/ArrayList\n 210: dup\n 211: aload 4\n 213: bipush 10\n 215: invokestatic #141 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 218: invokespecial #143 // Method java/util/ArrayList.\"<init>\":(I)V\n 221: checkcast #145 // class java/util/Collection\n 224: astore 7\n 226: iconst_0\n 227: istore 8\n 229: iconst_0\n 230: istore 9\n 232: aload 6\n 234: invokeinterface #149, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 239: astore 10\n 241: aload 10\n 243: invokeinterface #155, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 248: ifeq 345\n 251: aload 10\n 253: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 258: astore 11\n 260: aload 7\n 262: iload 9\n 264: iinc 9, 1\n 267: istore 12\n 269: iload 12\n 271: ifge 277\n 274: invokestatic #227 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 277: iload 12\n 279: aload 11\n 281: checkcast #57 // class Day13Kt$main$TreeNode\n 284: astore 13\n 286: istore 14\n 288: astore 16\n 290: iconst_0\n 291: istore 15\n 293: aload 13\n 295: invokevirtual #302 // Method Day13Kt$main$TreeNode.getStr:()Ljava/lang/String;\n 298: ldc_w #259 // String [[2]]\n 301: invokestatic #231 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 304: ifne 321\n 307: aload 13\n 309: invokevirtual #302 // Method Day13Kt$main$TreeNode.getStr:()Ljava/lang/String;\n 312: ldc_w #261 // String [[6]]\n 315: invokestatic #231 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 318: ifeq 328\n 321: iload 14\n 323: iconst_1\n 324: iadd\n 325: goto 329\n 328: iconst_1\n 329: nop\n 330: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 333: aload 16\n 335: swap\n 336: invokeinterface #172, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 341: pop\n 342: goto 241\n 345: aload 7\n 347: checkcast #77 // class java/util/List\n 350: nop\n 351: checkcast #129 // class java/lang/Iterable\n 354: astore 4\n 356: nop\n 357: iconst_0\n 358: istore 5\n 360: aload 4\n 362: invokeinterface #149, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 367: astore 6\n 369: aload 6\n 371: invokeinterface #155, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 376: ifne 390\n 379: new #304 // class java/lang/UnsupportedOperationException\n 382: dup\n 383: ldc_w #306 // String Empty collection can\\'t be reduced.\n 386: invokespecial #309 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 389: athrow\n 390: aload 6\n 392: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 397: astore 7\n 399: aload 6\n 401: invokeinterface #155, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 406: ifeq 450\n 409: aload 7\n 411: aload 6\n 413: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 418: checkcast #311 // class java/lang/Number\n 421: invokevirtual #312 // Method java/lang/Number.intValue:()I\n 424: istore 8\n 426: checkcast #311 // class java/lang/Number\n 429: invokevirtual #312 // Method java/lang/Number.intValue:()I\n 432: istore 9\n 434: iconst_0\n 435: istore 10\n 437: iload 9\n 439: iload 8\n 441: imul\n 442: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 445: astore 7\n 447: goto 399\n 450: aload 7\n 452: checkcast #311 // class java/lang/Number\n 455: invokevirtual #312 // Method java/lang/Number.intValue:()I\n 458: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day13Kt$main$TreeNode.class",
"javap": "Compiled from \"Day13.kt\"\npublic final class Day13Kt$main$TreeNode {\n private final java.lang.Integer value;\n\n private final Day13Kt$main$TreeNode parent;\n\n private final java.lang.String str;\n\n private java.util.List<Day13Kt$main$TreeNode> children;\n\n public Day13Kt$main$TreeNode(java.lang.Integer, Day13Kt$main$TreeNode, java.lang.String, java.util.List<Day13Kt$main$TreeNode>);\n Code:\n 0: aload 4\n 2: ldc #9 // String children\n 4: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokespecial #18 // Method java/lang/Object.\"<init>\":()V\n 11: aload_0\n 12: aload_1\n 13: putfield #22 // Field value:Ljava/lang/Integer;\n 16: aload_0\n 17: aload_2\n 18: putfield #26 // Field parent:LDay13Kt$main$TreeNode;\n 21: aload_0\n 22: aload_3\n 23: putfield #30 // Field str:Ljava/lang/String;\n 26: aload_0\n 27: aload 4\n 29: putfield #33 // Field children:Ljava/util/List;\n 32: return\n\n public Day13Kt$main$TreeNode(java.lang.Integer, Day13Kt$main$TreeNode, java.lang.String, java.util.List, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload 5\n 2: bipush 8\n 4: iand\n 5: ifeq 20\n 8: new #37 // class java/util/ArrayList\n 11: dup\n 12: invokespecial #38 // Method java/util/ArrayList.\"<init>\":()V\n 15: checkcast #40 // class java/util/List\n 18: astore 4\n 20: aload_0\n 21: aload_1\n 22: aload_2\n 23: aload_3\n 24: aload 4\n 26: invokespecial #42 // Method \"<init>\":(Ljava/lang/Integer;LDay13Kt$main$TreeNode;Ljava/lang/String;Ljava/util/List;)V\n 29: return\n\n public final java.lang.Integer getValue();\n Code:\n 0: aload_0\n 1: getfield #22 // Field value:Ljava/lang/Integer;\n 4: areturn\n\n public final Day13Kt$main$TreeNode getParent();\n Code:\n 0: aload_0\n 1: getfield #26 // Field parent:LDay13Kt$main$TreeNode;\n 4: areturn\n\n public final java.lang.String getStr();\n Code:\n 0: aload_0\n 1: getfield #30 // Field str:Ljava/lang/String;\n 4: areturn\n\n public final java.util.List<Day13Kt$main$TreeNode> getChildren();\n Code:\n 0: aload_0\n 1: getfield #33 // Field children:Ljava/util/List;\n 4: areturn\n\n public final void setChildren(java.util.List<Day13Kt$main$TreeNode>);\n Code:\n 0: aload_1\n 1: ldc #56 // String <set-?>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: putfield #33 // Field children:Ljava/util/List;\n 11: return\n}\n",
"javap_err": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day05.kt
|
import java.util.Stack
class CrateStack(val crates: Stack<Char>)
class Move(val quantity: Int, val startIdx: Int, val endIdx: Int)
class State(val stacks: Array<CrateStack>, val moves: Array<Move>) {
fun applyMoves() {
for (move in moves) {
for (i in 1..move.quantity) {
val crate = stacks[move.startIdx].crates.pop()
stacks[move.endIdx].crates.push(crate)
}
}
}
fun applyMoves2() {
for (move in moves) {
val batch = mutableListOf<Char>()
for (i in 1..move.quantity) {
val crate = stacks[move.startIdx].crates.pop()
batch.add(crate)
}
batch.asReversed().forEach { crate ->
stacks[move.endIdx].crates.push(crate)
}
}
}
fun getTops(): String {
return String(stacks.map { it.crates.peek() }.toCharArray())
}
}
fun main() {
fun parseStacks(input: List<String>): Array<CrateStack> {
val idxs = mutableListOf<Int>()
val idxInput = input.last()
for ((index, item) in idxInput.toCharArray().withIndex()) {
if (item != ' ') {
idxs.add(index)
}
}
val result = Array(idxs.size) { _ -> CrateStack(Stack<Char>()) }
val cratesInput = input.asReversed().slice(1 until input.size)
for (line in cratesInput) {
for ((localIdx, idx) in idxs.withIndex()) {
if (line.length > idx && line[idx] != ' ') {
result[localIdx].crates.push(line[idx])
}
}
}
return result
}
fun parseMoves(input: List<String>): Array<Move> {
return input
.map { line ->
val parts = line.split(' ')
Move(parts[1].toInt(), parts[3].toInt() - 1, parts[5].toInt() - 1)
}.toTypedArray()
}
fun parse(input: List<String>): State {
val separatorIdx = input.lastIndexOf("")
val stacksInput = input.slice(0 until separatorIdx)
val movesInput = input.slice(separatorIdx + 1 until input.size)
return State(parseStacks(stacksInput), parseMoves(movesInput))
}
fun part1(input: List<String>): String {
val state = parse(input)
state.applyMoves()
return state.getTops()
}
fun part2(input: List<String>): String {
val state = parse(input)
state.applyMoves2()
return state.getTops()
}
val testInput = readInput("Day05_test")
assert(part1(testInput), "CMZ")
assert(part2(testInput), "MCD")
val input = readInput("Day05")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/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 #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method main$part1:(Ljava/util/List;)Ljava/lang/String;\n 10: ldc #20 // String CMZ\n 12: invokestatic #24 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 15: aload_0\n 16: invokestatic #27 // Method main$part2:(Ljava/util/List;)Ljava/lang/String;\n 19: ldc #29 // String MCD\n 21: invokestatic #24 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 24: ldc #31 // String Day05\n 26: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 29: astore_1\n 30: aload_1\n 31: invokestatic #18 // Method main$part1:(Ljava/util/List;)Ljava/lang/String;\n 34: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 37: swap\n 38: invokevirtual #43 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 41: aload_1\n 42: invokestatic #27 // Method main$part2:(Ljava/util/List;)Ljava/lang/String;\n 45: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 48: swap\n 49: invokevirtual #43 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 52: 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 CrateStack[] main$parseStacks(java.util.List<java.lang.String>);\n Code:\n 0: new #56 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #59 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #61 // class java/util/List\n 10: astore_1\n 11: aload_0\n 12: invokestatic #67 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 15: checkcast #69 // class java/lang/String\n 18: astore_2\n 19: aload_2\n 20: invokevirtual #73 // Method java/lang/String.toCharArray:()[C\n 23: dup\n 24: ldc #75 // String toCharArray(...)\n 26: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 29: astore_3\n 30: iconst_0\n 31: istore 4\n 33: aload_3\n 34: arraylength\n 35: istore 5\n 37: iload 4\n 39: iload 5\n 41: if_icmpge 79\n 44: iload 4\n 46: istore 6\n 48: aload_3\n 49: iload 4\n 51: caload\n 52: istore 7\n 54: iload 7\n 56: bipush 32\n 58: if_icmpeq 73\n 61: aload_1\n 62: iload 6\n 64: invokestatic #87 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 67: invokeinterface #91, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 72: pop\n 73: iinc 4, 1\n 76: goto 37\n 79: iconst_0\n 80: istore 4\n 82: aload_1\n 83: invokeinterface #95, 1 // InterfaceMethod java/util/List.size:()I\n 88: istore 5\n 90: iload 5\n 92: anewarray #97 // class CrateStack\n 95: astore 6\n 97: iload 4\n 99: iload 5\n 101: if_icmpge 133\n 104: iload 4\n 106: istore 7\n 108: aload 6\n 110: iload 7\n 112: new #97 // class CrateStack\n 115: dup\n 116: new #99 // class java/util/Stack\n 119: dup\n 120: invokespecial #100 // Method java/util/Stack.\"<init>\":()V\n 123: invokespecial #103 // Method CrateStack.\"<init>\":(Ljava/util/Stack;)V\n 126: aastore\n 127: iinc 4, 1\n 130: goto 97\n 133: aload 6\n 135: astore_3\n 136: aload_0\n 137: invokestatic #107 // Method kotlin/collections/CollectionsKt.asReversed:(Ljava/util/List;)Ljava/util/List;\n 140: iconst_1\n 141: aload_0\n 142: invokeinterface #95, 1 // InterfaceMethod java/util/List.size:()I\n 147: invokestatic #113 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 150: invokestatic #117 // Method kotlin/collections/CollectionsKt.slice:(Ljava/util/List;Lkotlin/ranges/IntRange;)Ljava/util/List;\n 153: astore 4\n 155: aload 4\n 157: invokeinterface #121, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 162: astore 5\n 164: aload 5\n 166: invokeinterface #127, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 171: ifeq 281\n 174: aload 5\n 176: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 181: checkcast #69 // class java/lang/String\n 184: astore 6\n 186: aload_1\n 187: checkcast #133 // class java/lang/Iterable\n 190: invokeinterface #134, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 195: astore 7\n 197: iconst_0\n 198: istore 8\n 200: aload 7\n 202: invokeinterface #127, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 207: ifeq 164\n 210: iload 8\n 212: istore 9\n 214: iload 8\n 216: iconst_1\n 217: iadd\n 218: istore 8\n 220: aload 7\n 222: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 227: checkcast #136 // class java/lang/Number\n 230: invokevirtual #139 // Method java/lang/Number.intValue:()I\n 233: istore 10\n 235: aload 6\n 237: invokevirtual #142 // Method java/lang/String.length:()I\n 240: iload 10\n 242: if_icmple 200\n 245: aload 6\n 247: iload 10\n 249: invokevirtual #146 // Method java/lang/String.charAt:(I)C\n 252: bipush 32\n 254: if_icmpeq 200\n 257: aload_3\n 258: iload 9\n 260: aaload\n 261: invokevirtual #150 // Method CrateStack.getCrates:()Ljava/util/Stack;\n 264: aload 6\n 266: iload 10\n 268: invokevirtual #146 // Method java/lang/String.charAt:(I)C\n 271: invokestatic #155 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 274: invokevirtual #159 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 277: pop\n 278: goto 200\n 281: aload_3\n 282: areturn\n\n private static final Move[] main$parseMoves(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #133 // class java/lang/Iterable\n 4: astore_1\n 5: nop\n 6: iconst_0\n 7: istore_2\n 8: aload_1\n 9: astore_3\n 10: new #56 // class java/util/ArrayList\n 13: dup\n 14: aload_1\n 15: bipush 10\n 17: invokestatic #182 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #185 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #187 // class java/util/Collection\n 26: astore 4\n 28: iconst_0\n 29: istore 5\n 31: aload_3\n 32: invokeinterface #134, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 37: astore 6\n 39: aload 6\n 41: invokeinterface #127, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 46: ifeq 165\n 49: aload 6\n 51: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 56: astore 7\n 58: aload 4\n 60: aload 7\n 62: checkcast #69 // class java/lang/String\n 65: astore 8\n 67: astore 12\n 69: iconst_0\n 70: istore 9\n 72: aload 8\n 74: checkcast #189 // class java/lang/CharSequence\n 77: iconst_1\n 78: newarray char\n 80: astore 10\n 82: aload 10\n 84: iconst_0\n 85: bipush 32\n 87: castore\n 88: aload 10\n 90: iconst_0\n 91: iconst_0\n 92: bipush 6\n 94: aconst_null\n 95: invokestatic #195 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 98: astore 11\n 100: new #197 // class Move\n 103: dup\n 104: aload 11\n 106: iconst_1\n 107: invokeinterface #201, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 112: checkcast #69 // class java/lang/String\n 115: invokestatic #205 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 118: aload 11\n 120: iconst_3\n 121: invokeinterface #201, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 126: checkcast #69 // class java/lang/String\n 129: invokestatic #205 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 132: iconst_1\n 133: isub\n 134: aload 11\n 136: iconst_5\n 137: invokeinterface #201, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 142: checkcast #69 // class java/lang/String\n 145: invokestatic #205 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 148: iconst_1\n 149: isub\n 150: invokespecial #208 // Method Move.\"<init>\":(III)V\n 153: aload 12\n 155: swap\n 156: invokeinterface #209, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 161: pop\n 162: goto 39\n 165: aload 4\n 167: checkcast #61 // class java/util/List\n 170: nop\n 171: checkcast #187 // class java/util/Collection\n 174: astore_1\n 175: nop\n 176: iconst_0\n 177: istore_2\n 178: aload_1\n 179: astore_3\n 180: aload_3\n 181: iconst_0\n 182: anewarray #197 // class Move\n 185: invokeinterface #213, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 190: checkcast #215 // class \"[LMove;\"\n 193: areturn\n\n private static final State main$parse(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #234 // String\n 3: invokeinterface #238, 2 // InterfaceMethod java/util/List.lastIndexOf:(Ljava/lang/Object;)I\n 8: istore_1\n 9: aload_0\n 10: iconst_0\n 11: iload_1\n 12: invokestatic #113 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 15: invokestatic #117 // Method kotlin/collections/CollectionsKt.slice:(Ljava/util/List;Lkotlin/ranges/IntRange;)Ljava/util/List;\n 18: astore_2\n 19: aload_0\n 20: iload_1\n 21: iconst_1\n 22: iadd\n 23: aload_0\n 24: invokeinterface #95, 1 // InterfaceMethod java/util/List.size:()I\n 29: invokestatic #113 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 32: invokestatic #117 // Method kotlin/collections/CollectionsKt.slice:(Ljava/util/List;Lkotlin/ranges/IntRange;)Ljava/util/List;\n 35: astore_3\n 36: new #240 // class State\n 39: dup\n 40: aload_2\n 41: invokestatic #242 // Method main$parseStacks:(Ljava/util/List;)[LCrateStack;\n 44: aload_3\n 45: invokestatic #244 // Method main$parseMoves:(Ljava/util/List;)[LMove;\n 48: invokespecial #247 // Method State.\"<init>\":([LCrateStack;[LMove;)V\n 51: areturn\n\n private static final java.lang.String main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #253 // Method main$parse:(Ljava/util/List;)LState;\n 4: astore_1\n 5: aload_1\n 6: invokevirtual #256 // Method State.applyMoves:()V\n 9: aload_1\n 10: invokevirtual #260 // Method State.getTops:()Ljava/lang/String;\n 13: areturn\n\n private static final java.lang.String main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #253 // Method main$parse:(Ljava/util/List;)LState;\n 4: astore_1\n 5: aload_1\n 6: invokevirtual #265 // Method State.applyMoves2:()V\n 9: aload_1\n 10: invokevirtual #260 // Method State.getTops:()Ljava/lang/String;\n 13: areturn\n}\n",
"javap_err": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day15.kt
|
import kotlin.math.abs
fun main() {
data class Signal(val sensor: Point, val beacon: Point) {
fun getDistance(): Int {
return abs(sensor.x - beacon.x) + abs(sensor.y - beacon.y)
}
}
fun parse(input: List<String>): List<Signal> {
val regex = """Sensor at x=(-?\d+), y=(-?\d+): closest beacon is at x=(-?\d+), y=(-?\d+)""".toRegex()
return input.map { line ->
val (sensorX, sensorY, beaconX, beaconY) = regex
.matchEntire(line)
?.destructured
?: throw IllegalArgumentException("Incorrect input line $line")
Signal(Point(sensorX.toInt(), sensorY.toInt()), Point(beaconX.toInt(), beaconY.toInt()))
}
}
fun getIntervals(
signals: List<Signal>,
row: Int
): List<Interval> {
val intervals = mutableListOf<Interval>()
for (signal in signals) {
val distance = signal.getDistance()
val diff = abs(signal.sensor.y - row)
if (diff <= distance) {
val delta = distance - diff
val interval = Interval(signal.sensor.x - delta, signal.sensor.x + delta)
// println("$signal diff: $diff delta: $delta distance: $distance interval: $interval")
intervals.add(interval)
}
}
val merged = Interval.merge(intervals)
// println("Merged: $merged")
return merged
}
fun part1(signals: List<Signal>, row: Int): Int {
val merged = getIntervals(signals, row)
val points = signals
.flatMap { s -> listOf(s.beacon, s.sensor) }
.filter { p -> p.y == row }
.map { p -> p.x }
.toSet()
return merged.sumOf { i -> i.countPoints(points) }
}
fun part2(signals: List<Signal>, limit: Int): Long {
for (row in 0..limit) {
val intervals = getIntervals(signals, row)
if (intervals.size == 2) {
val left = intervals[0]
val right = intervals[1]
if (left.end + 1 == right.start - 1) {
return (left.end + 1) * 4000000L + row
} else {
println("Error: $left $right $row")
throw RuntimeException()
}
}
if (intervals.size != 1) {
println("Error: ${intervals.size} $row")
throw RuntimeException()
}
}
return -1
}
val testInput = readInput("Day15_test")
assert(part1(parse(testInput), 10), 26)
assert(part2(parse(testInput), 20), 56000011L)
val input = readInput("Day15")
println(part1(parse(input), 2000000))
println(part2(parse(input), 4000000))
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day15Kt.class",
"javap": "Compiled from \"Day15.kt\"\npublic final class Day15Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day15_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$parse:(Ljava/util/List;)Ljava/util/List;\n 10: bipush 10\n 12: invokestatic #22 // Method main$part1:(Ljava/util/List;I)I\n 15: invokestatic #28 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 18: bipush 26\n 20: invokestatic #28 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 23: invokestatic #32 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 26: aload_0\n 27: invokestatic #18 // Method main$parse:(Ljava/util/List;)Ljava/util/List;\n 30: bipush 20\n 32: invokestatic #36 // Method main$part2:(Ljava/util/List;I)J\n 35: invokestatic #41 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 38: ldc2_w #42 // long 56000011l\n 41: invokestatic #41 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 44: invokestatic #32 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 47: ldc #45 // String Day15\n 49: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 52: astore_1\n 53: aload_1\n 54: invokestatic #18 // Method main$parse:(Ljava/util/List;)Ljava/util/List;\n 57: ldc #46 // int 2000000\n 59: invokestatic #22 // Method main$part1:(Ljava/util/List;I)I\n 62: istore_2\n 63: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 66: iload_2\n 67: invokevirtual #58 // Method java/io/PrintStream.println:(I)V\n 70: aload_1\n 71: invokestatic #18 // Method main$parse:(Ljava/util/List;)Ljava/util/List;\n 74: ldc #59 // int 4000000\n 76: invokestatic #36 // Method main$part2:(Ljava/util/List;I)J\n 79: lstore_2\n 80: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 83: lload_2\n 84: invokevirtual #62 // Method java/io/PrintStream.println:(J)V\n 87: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #68 // Method main:()V\n 3: return\n\n private static final java.util.List<Day15Kt$main$Signal> main$parse(java.util.List<java.lang.String>);\n Code:\n 0: new #73 // class kotlin/text/Regex\n 3: dup\n 4: ldc #75 // String Sensor at x=(-?\\\\d+), y=(-?\\\\d+): closest beacon is at x=(-?\\\\d+), y=(-?\\\\d+)\n 6: invokespecial #79 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 9: astore_1\n 10: aload_0\n 11: checkcast #81 // 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 #83 // class java/util/ArrayList\n 23: dup\n 24: aload_2\n 25: bipush 10\n 27: invokestatic #89 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 30: invokespecial #91 // Method java/util/ArrayList.\"<init>\":(I)V\n 33: checkcast #93 // class java/util/Collection\n 36: astore 5\n 38: iconst_0\n 39: istore 6\n 41: aload 4\n 43: invokeinterface #97, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 48: astore 7\n 50: aload 7\n 52: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 57: ifeq 285\n 60: aload 7\n 62: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 67: astore 8\n 69: aload 5\n 71: aload 8\n 73: checkcast #109 // class java/lang/String\n 76: astore 9\n 78: astore 16\n 80: iconst_0\n 81: istore 10\n 83: aload_1\n 84: aload 9\n 86: checkcast #111 // class java/lang/CharSequence\n 89: invokevirtual #115 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;\n 92: astore 11\n 94: aload 11\n 96: ifnull 118\n 99: aload 11\n 101: invokeinterface #121, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 106: astore 12\n 108: aload 12\n 110: ifnull 118\n 113: aload 12\n 115: goto 146\n 118: new #123 // class java/lang/IllegalArgumentException\n 121: dup\n 122: new #125 // class java/lang/StringBuilder\n 125: dup\n 126: invokespecial #127 // Method java/lang/StringBuilder.\"<init>\":()V\n 129: ldc #129 // String Incorrect input line\n 131: invokevirtual #133 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 134: aload 9\n 136: invokevirtual #133 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 139: invokevirtual #137 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 142: invokespecial #138 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 145: athrow\n 146: astore 13\n 148: aload 13\n 150: invokevirtual #144 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 153: invokeinterface #148, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 158: iconst_1\n 159: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 164: checkcast #109 // class java/lang/String\n 167: astore 11\n 169: aload 13\n 171: invokevirtual #144 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 174: invokeinterface #148, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 179: iconst_2\n 180: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 185: checkcast #109 // class java/lang/String\n 188: astore 12\n 190: aload 13\n 192: invokevirtual #144 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 195: invokeinterface #148, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 200: iconst_3\n 201: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 206: checkcast #109 // class java/lang/String\n 209: astore 14\n 211: aload 13\n 213: invokevirtual #144 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 216: invokeinterface #148, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 221: iconst_4\n 222: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 227: checkcast #109 // class java/lang/String\n 230: astore 15\n 232: new #156 // class Day15Kt$main$Signal\n 235: dup\n 236: new #158 // class Point\n 239: dup\n 240: aload 11\n 242: invokestatic #162 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 245: aload 12\n 247: invokestatic #162 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 250: invokespecial #165 // Method Point.\"<init>\":(II)V\n 253: new #158 // class Point\n 256: dup\n 257: aload 14\n 259: invokestatic #162 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 262: aload 15\n 264: invokestatic #162 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 267: invokespecial #165 // Method Point.\"<init>\":(II)V\n 270: invokespecial #168 // Method Day15Kt$main$Signal.\"<init>\":(LPoint;LPoint;)V\n 273: aload 16\n 275: swap\n 276: invokeinterface #172, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 281: pop\n 282: goto 50\n 285: aload 5\n 287: checkcast #150 // class java/util/List\n 290: nop\n 291: areturn\n\n private static final java.util.List<Interval> main$getIntervals(java.util.List<Day15Kt$main$Signal>, int);\n Code:\n 0: new #83 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #195 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #150 // class java/util/List\n 10: astore_2\n 11: aload_0\n 12: invokeinterface #196, 1 // InterfaceMethod java/util/List.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 117\n 27: aload_3\n 28: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 33: checkcast #156 // class Day15Kt$main$Signal\n 36: astore 4\n 38: aload 4\n 40: invokevirtual #200 // Method Day15Kt$main$Signal.getDistance:()I\n 43: istore 5\n 45: aload 4\n 47: invokevirtual #204 // Method Day15Kt$main$Signal.getSensor:()LPoint;\n 50: invokevirtual #207 // Method Point.getY:()I\n 53: iload_1\n 54: isub\n 55: invokestatic #213 // Method java/lang/Math.abs:(I)I\n 58: istore 6\n 60: iload 6\n 62: iload 5\n 64: if_icmpgt 18\n 67: iload 5\n 69: iload 6\n 71: isub\n 72: istore 7\n 74: new #215 // class Interval\n 77: dup\n 78: aload 4\n 80: invokevirtual #204 // Method Day15Kt$main$Signal.getSensor:()LPoint;\n 83: invokevirtual #218 // Method Point.getX:()I\n 86: iload 7\n 88: isub\n 89: aload 4\n 91: invokevirtual #204 // Method Day15Kt$main$Signal.getSensor:()LPoint;\n 94: invokevirtual #218 // Method Point.getX:()I\n 97: iload 7\n 99: iadd\n 100: invokespecial #219 // Method Interval.\"<init>\":(II)V\n 103: astore 8\n 105: aload_2\n 106: aload 8\n 108: invokeinterface #220, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 113: pop\n 114: goto 18\n 117: getstatic #224 // Field Interval.Companion:LInterval$Companion;\n 120: aload_2\n 121: invokevirtual #229 // Method Interval$Companion.merge:(Ljava/util/List;)Ljava/util/List;\n 124: astore_3\n 125: aload_3\n 126: areturn\n\n private static final int main$part1(java.util.List<Day15Kt$main$Signal>, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: invokestatic #243 // Method main$getIntervals:(Ljava/util/List;I)Ljava/util/List;\n 5: astore_2\n 6: aload_0\n 7: checkcast #81 // class java/lang/Iterable\n 10: astore 4\n 12: nop\n 13: iconst_0\n 14: istore 5\n 16: aload 4\n 18: astore 6\n 20: new #83 // class java/util/ArrayList\n 23: dup\n 24: invokespecial #195 // Method java/util/ArrayList.\"<init>\":()V\n 27: checkcast #93 // class java/util/Collection\n 30: astore 7\n 32: iconst_0\n 33: istore 8\n 35: aload 6\n 37: invokeinterface #97, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 9\n 44: aload 9\n 46: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 118\n 54: aload 9\n 56: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 10\n 63: aload 10\n 65: checkcast #156 // class Day15Kt$main$Signal\n 68: astore 11\n 70: iconst_0\n 71: istore 12\n 73: iconst_2\n 74: anewarray #158 // class Point\n 77: astore 13\n 79: aload 13\n 81: iconst_0\n 82: aload 11\n 84: invokevirtual #246 // Method Day15Kt$main$Signal.getBeacon:()LPoint;\n 87: aastore\n 88: aload 13\n 90: iconst_1\n 91: aload 11\n 93: invokevirtual #204 // Method Day15Kt$main$Signal.getSensor:()LPoint;\n 96: aastore\n 97: aload 13\n 99: invokestatic #250 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 102: checkcast #81 // class java/lang/Iterable\n 105: astore 11\n 107: aload 7\n 109: aload 11\n 111: invokestatic #254 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 114: pop\n 115: goto 44\n 118: aload 7\n 120: checkcast #150 // class java/util/List\n 123: nop\n 124: checkcast #81 // class java/lang/Iterable\n 127: astore 4\n 129: nop\n 130: iconst_0\n 131: istore 5\n 133: aload 4\n 135: astore 6\n 137: new #83 // class java/util/ArrayList\n 140: dup\n 141: invokespecial #195 // Method java/util/ArrayList.\"<init>\":()V\n 144: checkcast #93 // class java/util/Collection\n 147: astore 7\n 149: iconst_0\n 150: istore 8\n 152: aload 6\n 154: invokeinterface #97, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 159: astore 9\n 161: aload 9\n 163: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 168: ifeq 220\n 171: aload 9\n 173: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 178: astore 10\n 180: aload 10\n 182: checkcast #158 // class Point\n 185: astore 11\n 187: iconst_0\n 188: istore 12\n 190: aload 11\n 192: invokevirtual #207 // Method Point.getY:()I\n 195: iload_1\n 196: if_icmpne 203\n 199: iconst_1\n 200: goto 204\n 203: iconst_0\n 204: ifeq 161\n 207: aload 7\n 209: aload 10\n 211: invokeinterface #172, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 216: pop\n 217: goto 161\n 220: aload 7\n 222: checkcast #150 // class java/util/List\n 225: nop\n 226: checkcast #81 // class java/lang/Iterable\n 229: astore 4\n 231: nop\n 232: iconst_0\n 233: istore 5\n 235: aload 4\n 237: astore 6\n 239: new #83 // class java/util/ArrayList\n 242: dup\n 243: aload 4\n 245: bipush 10\n 247: invokestatic #89 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 250: invokespecial #91 // Method java/util/ArrayList.\"<init>\":(I)V\n 253: checkcast #93 // class java/util/Collection\n 256: astore 7\n 258: iconst_0\n 259: istore 8\n 261: aload 6\n 263: invokeinterface #97, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 268: astore 9\n 270: aload 9\n 272: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 277: ifeq 323\n 280: aload 9\n 282: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 287: astore 10\n 289: aload 7\n 291: aload 10\n 293: checkcast #158 // class Point\n 296: astore 11\n 298: astore 14\n 300: iconst_0\n 301: istore 12\n 303: aload 11\n 305: invokevirtual #218 // Method Point.getX:()I\n 308: invokestatic #28 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 311: aload 14\n 313: swap\n 314: invokeinterface #172, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 319: pop\n 320: goto 270\n 323: aload 7\n 325: checkcast #150 // class java/util/List\n 328: nop\n 329: checkcast #81 // class java/lang/Iterable\n 332: invokestatic #258 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 335: astore_3\n 336: aload_2\n 337: checkcast #81 // class java/lang/Iterable\n 340: astore 4\n 342: iconst_0\n 343: istore 5\n 345: aload 4\n 347: invokeinterface #97, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 352: astore 6\n 354: aload 6\n 356: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 361: ifeq 405\n 364: aload 6\n 366: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 371: astore 7\n 373: iload 5\n 375: aload 7\n 377: checkcast #215 // class Interval\n 380: astore 8\n 382: istore 14\n 384: iconst_0\n 385: istore 9\n 387: aload 8\n 389: aload_3\n 390: invokevirtual #262 // Method Interval.countPoints:(Ljava/util/Set;)I\n 393: istore 15\n 395: iload 14\n 397: iload 15\n 399: iadd\n 400: istore 5\n 402: goto 354\n 405: iload 5\n 407: ireturn\n\n private static final long main$part2(java.util.List<Day15Kt$main$Signal>, int);\n Code:\n 0: iconst_0\n 1: istore_2\n 2: iload_2\n 3: iload_1\n 4: if_icmpgt 205\n 7: aload_0\n 8: iload_2\n 9: invokestatic #243 // Method main$getIntervals:(Ljava/util/List;I)Ljava/util/List;\n 12: astore_3\n 13: aload_3\n 14: invokeinterface #288, 1 // InterfaceMethod java/util/List.size:()I\n 19: iconst_2\n 20: if_icmpne 135\n 23: aload_3\n 24: iconst_0\n 25: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 30: checkcast #215 // class Interval\n 33: astore 4\n 35: aload_3\n 36: iconst_1\n 37: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 42: checkcast #215 // class Interval\n 45: astore 5\n 47: aload 4\n 49: invokevirtual #291 // Method Interval.getEnd:()I\n 52: iconst_1\n 53: iadd\n 54: aload 5\n 56: invokevirtual #294 // Method Interval.getStart:()I\n 59: iconst_1\n 60: isub\n 61: if_icmpne 80\n 64: aload 4\n 66: invokevirtual #291 // Method Interval.getEnd:()I\n 69: iconst_1\n 70: iadd\n 71: i2l\n 72: ldc2_w #295 // long 4000000l\n 75: lmul\n 76: iload_2\n 77: i2l\n 78: ladd\n 79: lreturn\n 80: new #125 // class java/lang/StringBuilder\n 83: dup\n 84: invokespecial #127 // Method java/lang/StringBuilder.\"<init>\":()V\n 87: ldc_w #298 // String Error:\n 90: invokevirtual #133 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 93: aload 4\n 95: invokevirtual #301 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 98: bipush 32\n 100: invokevirtual #304 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 103: aload 5\n 105: invokevirtual #301 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 108: bipush 32\n 110: invokevirtual #304 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 113: iload_2\n 114: invokevirtual #307 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 117: invokevirtual #137 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 120: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 123: swap\n 124: invokevirtual #310 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 127: new #312 // class java/lang/RuntimeException\n 130: dup\n 131: invokespecial #313 // Method java/lang/RuntimeException.\"<init>\":()V\n 134: athrow\n 135: aload_3\n 136: invokeinterface #288, 1 // InterfaceMethod java/util/List.size:()I\n 141: iconst_1\n 142: if_icmpeq 194\n 145: new #125 // class java/lang/StringBuilder\n 148: dup\n 149: invokespecial #127 // Method java/lang/StringBuilder.\"<init>\":()V\n 152: ldc_w #298 // String Error:\n 155: invokevirtual #133 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 158: aload_3\n 159: invokeinterface #288, 1 // InterfaceMethod java/util/List.size:()I\n 164: invokevirtual #307 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 167: bipush 32\n 169: invokevirtual #304 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 172: iload_2\n 173: invokevirtual #307 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 176: invokevirtual #137 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 179: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 182: swap\n 183: invokevirtual #310 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 186: new #312 // class java/lang/RuntimeException\n 189: dup\n 190: invokespecial #313 // Method java/lang/RuntimeException.\"<init>\":()V\n 193: athrow\n 194: iload_2\n 195: iload_1\n 196: if_icmpeq 205\n 199: iinc 2, 1\n 202: goto 7\n 205: ldc2_w #314 // long -1l\n 208: lreturn\n}\n",
"javap_err": ""
},
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day15Kt$main$Signal.class",
"javap": "Compiled from \"Day15.kt\"\npublic final class Day15Kt$main$Signal {\n private final Point sensor;\n\n private final Point beacon;\n\n public Day15Kt$main$Signal(Point, Point);\n Code:\n 0: aload_1\n 1: ldc #8 // String sensor\n 3: invokestatic #14 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #16 // String beacon\n 9: invokestatic #14 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokespecial #19 // Method java/lang/Object.\"<init>\":()V\n 16: aload_0\n 17: aload_1\n 18: putfield #22 // Field sensor:LPoint;\n 21: aload_0\n 22: aload_2\n 23: putfield #24 // Field beacon:LPoint;\n 26: return\n\n public final Point getSensor();\n Code:\n 0: aload_0\n 1: getfield #22 // Field sensor:LPoint;\n 4: areturn\n\n public final Point getBeacon();\n Code:\n 0: aload_0\n 1: getfield #24 // Field beacon:LPoint;\n 4: areturn\n\n public final int getDistance();\n Code:\n 0: aload_0\n 1: getfield #22 // Field sensor:LPoint;\n 4: invokevirtual #36 // Method Point.getX:()I\n 7: aload_0\n 8: getfield #24 // Field beacon:LPoint;\n 11: invokevirtual #36 // Method Point.getX:()I\n 14: isub\n 15: invokestatic #42 // Method java/lang/Math.abs:(I)I\n 18: aload_0\n 19: getfield #22 // Field sensor:LPoint;\n 22: invokevirtual #45 // Method Point.getY:()I\n 25: aload_0\n 26: getfield #24 // Field beacon:LPoint;\n 29: invokevirtual #45 // Method Point.getY:()I\n 32: isub\n 33: invokestatic #42 // Method java/lang/Math.abs:(I)I\n 36: iadd\n 37: ireturn\n\n public final Point component1();\n Code:\n 0: aload_0\n 1: getfield #22 // Field sensor:LPoint;\n 4: areturn\n\n public final Point component2();\n Code:\n 0: aload_0\n 1: getfield #24 // Field beacon:LPoint;\n 4: areturn\n\n public final Day15Kt$main$Signal copy(Point, Point);\n Code:\n 0: aload_1\n 1: ldc #8 // String sensor\n 3: invokestatic #14 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #16 // String beacon\n 9: invokestatic #14 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class Day15Kt$main$Signal\n 15: dup\n 16: aload_1\n 17: aload_2\n 18: invokespecial #51 // Method \"<init>\":(LPoint;LPoint;)V\n 21: areturn\n\n public static Day15Kt$main$Signal copy$default(Day15Kt$main$Signal, Point, Point, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_1\n 2: iand\n 3: ifeq 11\n 6: aload_0\n 7: getfield #22 // Field sensor:LPoint;\n 10: astore_1\n 11: iload_3\n 12: iconst_2\n 13: iand\n 14: ifeq 22\n 17: aload_0\n 18: getfield #24 // Field beacon:LPoint;\n 21: astore_2\n 22: aload_0\n 23: aload_1\n 24: aload_2\n 25: invokevirtual #55 // Method copy:(LPoint;LPoint;)LDay15Kt$main$Signal;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #59 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #60 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #62 // String Signal(sensor=\n 9: invokevirtual #66 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #22 // Field sensor:LPoint;\n 16: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #71 // String , beacon=\n 21: invokevirtual #66 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #24 // Field beacon:LPoint;\n 28: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #74 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #76 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 39: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #22 // Field sensor:LPoint;\n 4: invokevirtual #79 // Method Point.hashCode:()I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #24 // Field beacon:LPoint;\n 16: invokevirtual #79 // Method Point.hashCode:()I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: ireturn\n\n public boolean equals(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: if_acmpne 7\n 5: iconst_1\n 6: ireturn\n 7: aload_1\n 8: instanceof #2 // class Day15Kt$main$Signal\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day15Kt$main$Signal\n 20: astore_2\n 21: aload_0\n 22: getfield #22 // Field sensor:LPoint;\n 25: aload_2\n 26: getfield #22 // Field sensor:LPoint;\n 29: invokestatic #87 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 32: ifne 37\n 35: iconst_0\n 36: ireturn\n 37: aload_0\n 38: getfield #24 // Field beacon:LPoint;\n 41: aload_2\n 42: getfield #24 // Field beacon:LPoint;\n 45: invokestatic #87 // 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": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day21.kt
|
import kotlin.time.ExperimentalTime
import kotlin.time.measureTime
enum class MathOperator {
Plus,
Minus,
Multiply,
Divide
}
class Day21 {
data class Monkey(val name: String, var value: Long?, val left: String?, val right: String?, val op: MathOperator?)
fun parseOperator(value: String): MathOperator {
return when (value) {
"*" -> MathOperator.Multiply
"+" -> MathOperator.Plus
"-" -> MathOperator.Minus
"/" -> MathOperator.Divide
else -> throw RuntimeException("Unknown op $value")
}
}
fun parse(input: List<String>): List<Monkey> {
return input.map { line ->
val parts = line.split(' ')
if (parts.size == 4) {
Monkey(parts[0], null, parts[1], parts[3], parseOperator(parts[2]))
} else {
Monkey(parts[0], parts[1].toLong(), null, null, null)
}
}
}
fun calc1(name: String, map: Map<String, Monkey>): Long {
val monkey = map.getValue(name)
if (monkey.value != null) {
return monkey.value!!
}
val left = calc1(monkey.left!!, map)
val right = calc1(monkey.right!!, map)
val result = when (monkey.op!!) {
MathOperator.Plus -> left + right
MathOperator.Minus -> left - right
MathOperator.Multiply -> left * right
MathOperator.Divide -> left / right
}
monkey.value = result
return result
}
fun calc2(name: String, map: Map<String, Monkey>): Long {
val monkey = map.getValue(name)
if (monkey.value != null) {
return monkey.value!!
}
val left = calc2(monkey.left!!, map)
val right = calc2(monkey.right!!, map)
if (monkey.name == "root") {
return right - left
}
val result = when (monkey.op!!) {
MathOperator.Plus -> left + right
MathOperator.Minus -> left - right
MathOperator.Multiply -> left * right
MathOperator.Divide -> left / right
}
monkey.value = result
return result
}
fun part1(input: List<String>): String {
val monkeys = parse(input)
val monkeyMap = monkeys.associateBy { it.name }
val result = calc1("root", monkeyMap)
return result.toString()
}
fun part2(input: List<String>): String {
var r = 5000000000000L
var l = 0L
while (r - l > 1) {
val h = (r + l) / 2
val monkeys = parse(input)
val monkeyMap = monkeys.associateBy { it.name }
monkeyMap["humn"]!!.value = h
val result = calc2("root", monkeyMap)
if (result != 0L) {
if (result < 0) {
l = h
} else {
r = h
}
continue
}
return h.toString()
}
return "Not Found"
}
}
@OptIn(ExperimentalTime::class)
@Suppress("DuplicatedCode")
fun main() {
val solution = Day21()
val name = solution.javaClass.name
val execution = setOf(
ExecutionMode.Test1,
ExecutionMode.Test2,
ExecutionMode.Exec1,
ExecutionMode.Exec2
)
fun test() {
val expected1 = "152"
val expected2 = "301"
val testInput = readInput("${name}_test")
if (execution.contains(ExecutionMode.Test1)) {
println("Test part 1")
assert(solution.part1(testInput), expected1)
println("> Passed")
}
if (execution.contains(ExecutionMode.Test2)) {
println("Test part 2")
assert(solution.part2(testInput), expected2)
println("> Passed")
println()
}
println("=================================")
println()
}
fun run() {
val input = readInput(name)
if (execution.contains(ExecutionMode.Exec1)) {
val elapsed1 = measureTime {
println("Part 1: " + solution.part1(input))
}
println("Elapsed: $elapsed1")
println()
}
if (execution.contains(ExecutionMode.Exec2)) {
val elapsed2 = measureTime {
println("Part 2: " + solution.part2(input))
}
println("Elapsed: $elapsed2")
println()
}
}
test()
run()
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day21Kt.class",
"javap": "Compiled from \"Day21.kt\"\npublic final class Day21Kt {\n public static final void main();\n Code:\n 0: new #8 // class Day21\n 3: dup\n 4: invokespecial #11 // Method Day21.\"<init>\":()V\n 7: astore_0\n 8: aload_0\n 9: invokevirtual #15 // Method java/lang/Object.getClass:()Ljava/lang/Class;\n 12: invokevirtual #21 // Method java/lang/Class.getName:()Ljava/lang/String;\n 15: astore_1\n 16: iconst_4\n 17: anewarray #23 // class ExecutionMode\n 20: astore_3\n 21: aload_3\n 22: iconst_0\n 23: getstatic #27 // Field ExecutionMode.Test1:LExecutionMode;\n 26: aastore\n 27: aload_3\n 28: iconst_1\n 29: getstatic #30 // Field ExecutionMode.Test2:LExecutionMode;\n 32: aastore\n 33: aload_3\n 34: iconst_2\n 35: getstatic #33 // Field ExecutionMode.Exec1:LExecutionMode;\n 38: aastore\n 39: aload_3\n 40: iconst_3\n 41: getstatic #36 // Field ExecutionMode.Exec2:LExecutionMode;\n 44: aastore\n 45: aload_3\n 46: invokestatic #42 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 49: astore_2\n 50: aload_1\n 51: aload_2\n 52: aload_0\n 53: invokestatic #46 // Method main$test:(Ljava/lang/String;Ljava/util/Set;LDay21;)V\n 56: aload_1\n 57: aload_2\n 58: aload_0\n 59: invokestatic #49 // Method main$run:(Ljava/lang/String;Ljava/util/Set;LDay21;)V\n 62: return\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 void main$test(java.lang.String, java.util.Set<? extends ExecutionMode>, Day21);\n Code:\n 0: ldc #63 // String 152\n 2: astore_3\n 3: ldc #65 // String 301\n 5: astore 4\n 7: new #67 // class java/lang/StringBuilder\n 10: dup\n 11: invokespecial #68 // Method java/lang/StringBuilder.\"<init>\":()V\n 14: aload_0\n 15: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 18: ldc #74 // String _test\n 20: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 23: invokevirtual #77 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 26: invokestatic #83 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 29: astore 5\n 31: aload_1\n 32: getstatic #27 // Field ExecutionMode.Test1:LExecutionMode;\n 35: invokeinterface #89, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 40: ifeq 71\n 43: ldc #91 // String Test part 1\n 45: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 48: swap\n 49: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 52: aload_2\n 53: aload 5\n 55: invokevirtual #107 // Method Day21.part1:(Ljava/util/List;)Ljava/lang/String;\n 58: aload_3\n 59: invokestatic #111 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 62: ldc #113 // String > Passed\n 64: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 67: swap\n 68: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 71: aload_1\n 72: getstatic #30 // Field ExecutionMode.Test2:LExecutionMode;\n 75: invokeinterface #89, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 80: ifeq 118\n 83: ldc #115 // String Test part 2\n 85: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 88: swap\n 89: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 92: aload_2\n 93: aload 5\n 95: invokevirtual #118 // Method Day21.part2:(Ljava/util/List;)Ljava/lang/String;\n 98: aload 4\n 100: invokestatic #111 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 103: ldc #113 // String > Passed\n 105: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 108: swap\n 109: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 112: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 115: invokevirtual #120 // Method java/io/PrintStream.println:()V\n 118: ldc #122 // String =================================\n 120: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 123: swap\n 124: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 127: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 130: invokevirtual #120 // Method java/io/PrintStream.println:()V\n 133: return\n\n private static final void main$run(java.lang.String, java.util.Set<? extends ExecutionMode>, Day21);\n Code:\n 0: aload_0\n 1: invokestatic #135 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 4: aload_0\n 5: invokestatic #83 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 8: astore_3\n 9: aload_1\n 10: getstatic #33 // Field ExecutionMode.Exec1:LExecutionMode;\n 13: invokeinterface #89, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 18: ifeq 118\n 21: iconst_0\n 22: istore 6\n 24: getstatic #141 // Field kotlin/time/TimeSource$Monotonic.INSTANCE:Lkotlin/time/TimeSource$Monotonic;\n 27: astore 7\n 29: iconst_0\n 30: istore 8\n 32: aload 7\n 34: invokevirtual #145 // Method kotlin/time/TimeSource$Monotonic.\"markNow-z9LOYto\":()J\n 37: lstore 9\n 39: iconst_0\n 40: istore 11\n 42: new #67 // class java/lang/StringBuilder\n 45: dup\n 46: invokespecial #68 // Method java/lang/StringBuilder.\"<init>\":()V\n 49: ldc #147 // String Part 1:\n 51: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 54: aload_2\n 55: aload_3\n 56: invokevirtual #107 // Method Day21.part1:(Ljava/util/List;)Ljava/lang/String;\n 59: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 62: invokevirtual #77 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 65: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: swap\n 69: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: nop\n 73: nop\n 74: lload 9\n 76: invokestatic #153 // Method kotlin/time/TimeSource$Monotonic$ValueTimeMark.\"elapsedNow-UwyO8pc\":(J)J\n 79: nop\n 80: lstore 4\n 82: new #67 // class java/lang/StringBuilder\n 85: dup\n 86: invokespecial #68 // Method java/lang/StringBuilder.\"<init>\":()V\n 89: ldc #155 // String Elapsed:\n 91: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 94: lload 4\n 96: invokestatic #161 // Method kotlin/time/Duration.\"toString-impl\":(J)Ljava/lang/String;\n 99: invokevirtual #164 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 102: invokevirtual #77 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 105: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 108: swap\n 109: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 112: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 115: invokevirtual #120 // Method java/io/PrintStream.println:()V\n 118: aload_1\n 119: getstatic #36 // Field ExecutionMode.Exec2:LExecutionMode;\n 122: invokeinterface #89, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 127: ifeq 227\n 130: iconst_0\n 131: istore 6\n 133: getstatic #141 // Field kotlin/time/TimeSource$Monotonic.INSTANCE:Lkotlin/time/TimeSource$Monotonic;\n 136: astore 7\n 138: iconst_0\n 139: istore 8\n 141: aload 7\n 143: invokevirtual #145 // Method kotlin/time/TimeSource$Monotonic.\"markNow-z9LOYto\":()J\n 146: lstore 9\n 148: iconst_0\n 149: istore 11\n 151: new #67 // class java/lang/StringBuilder\n 154: dup\n 155: invokespecial #68 // Method java/lang/StringBuilder.\"<init>\":()V\n 158: ldc #166 // String Part 2:\n 160: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 163: aload_2\n 164: aload_3\n 165: invokevirtual #118 // Method Day21.part2:(Ljava/util/List;)Ljava/lang/String;\n 168: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 171: invokevirtual #77 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 174: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 177: swap\n 178: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 181: nop\n 182: nop\n 183: lload 9\n 185: invokestatic #153 // Method kotlin/time/TimeSource$Monotonic$ValueTimeMark.\"elapsedNow-UwyO8pc\":(J)J\n 188: nop\n 189: lstore 4\n 191: new #67 // class java/lang/StringBuilder\n 194: dup\n 195: invokespecial #68 // Method java/lang/StringBuilder.\"<init>\":()V\n 198: ldc #155 // String Elapsed:\n 200: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 203: lload 4\n 205: invokestatic #161 // Method kotlin/time/Duration.\"toString-impl\":(J)Ljava/lang/String;\n 208: invokevirtual #164 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 211: invokevirtual #77 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 214: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 217: swap\n 218: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 221: getstatic #97 // Field java/lang/System.out:Ljava/io/PrintStream;\n 224: invokevirtual #120 // Method java/io/PrintStream.println:()V\n 227: return\n}\n",
"javap_err": ""
},
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day21$WhenMappings.class",
"javap": "Compiled from \"Day21.kt\"\npublic final class Day21$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method MathOperator.values:()[LMathOperator;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field MathOperator.Plus:LMathOperator;\n 12: invokevirtual #22 // Method MathOperator.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 MathOperator.Minus:LMathOperator;\n 26: invokevirtual #22 // Method MathOperator.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 MathOperator.Multiply:LMathOperator;\n 40: invokevirtual #22 // Method MathOperator.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 MathOperator.Divide:LMathOperator;\n 54: invokevirtual #22 // Method MathOperator.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": "kipwoker__aoc2022__d8aeea8/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 MathOperator parseOperator(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String value\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: astore_2\n 8: aload_2\n 9: invokevirtual #27 // Method java/lang/String.hashCode:()I\n 12: tableswitch { // 42 to 47\n 42: 52\n 43: 64\n 44: 124\n 45: 76\n 46: 124\n 47: 88\n default: 124\n }\n 52: aload_2\n 53: ldc #29 // String *\n 55: invokevirtual #33 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 58: ifne 100\n 61: goto 124\n 64: aload_2\n 65: ldc #35 // String +\n 67: invokevirtual #33 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 70: ifne 106\n 73: goto 124\n 76: aload_2\n 77: ldc #37 // String -\n 79: invokevirtual #33 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 82: ifne 112\n 85: goto 124\n 88: aload_2\n 89: ldc #39 // String /\n 91: invokevirtual #33 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 94: ifne 118\n 97: goto 124\n 100: getstatic #45 // Field MathOperator.Multiply:LMathOperator;\n 103: goto 151\n 106: getstatic #48 // Field MathOperator.Plus:LMathOperator;\n 109: goto 151\n 112: getstatic #51 // Field MathOperator.Minus:LMathOperator;\n 115: goto 151\n 118: getstatic #54 // Field MathOperator.Divide:LMathOperator;\n 121: goto 151\n 124: new #56 // class java/lang/RuntimeException\n 127: dup\n 128: new #58 // class java/lang/StringBuilder\n 131: dup\n 132: invokespecial #59 // Method java/lang/StringBuilder.\"<init>\":()V\n 135: ldc #61 // String Unknown op\n 137: invokevirtual #65 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 140: aload_1\n 141: invokevirtual #65 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 144: invokevirtual #69 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 147: invokespecial #72 // Method java/lang/RuntimeException.\"<init>\":(Ljava/lang/String;)V\n 150: athrow\n 151: areturn\n\n public final java.util.List<Day21$Monkey> parse(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #78 // String input\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #80 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: astore 4\n 16: new #82 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: bipush 10\n 23: invokestatic #88 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #91 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #93 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: aload 4\n 39: invokeinterface #97, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 7\n 46: aload 7\n 48: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 228\n 56: aload 7\n 58: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 8\n 65: aload 5\n 67: aload 8\n 69: checkcast #23 // class java/lang/String\n 72: astore 9\n 74: astore 13\n 76: iconst_0\n 77: istore 10\n 79: aload 9\n 81: checkcast #109 // class java/lang/CharSequence\n 84: iconst_1\n 85: newarray char\n 87: astore 11\n 89: aload 11\n 91: iconst_0\n 92: bipush 32\n 94: castore\n 95: aload 11\n 97: iconst_0\n 98: iconst_0\n 99: bipush 6\n 101: aconst_null\n 102: invokestatic #115 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 105: astore 12\n 107: aload 12\n 109: invokeinterface #120, 1 // InterfaceMethod java/util/List.size:()I\n 114: iconst_4\n 115: if_icmpne 177\n 118: new #122 // class Day21$Monkey\n 121: dup\n 122: aload 12\n 124: iconst_0\n 125: invokeinterface #126, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 130: checkcast #23 // class java/lang/String\n 133: aconst_null\n 134: aload 12\n 136: iconst_1\n 137: invokeinterface #126, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 142: checkcast #23 // class java/lang/String\n 145: aload 12\n 147: iconst_3\n 148: invokeinterface #126, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 153: checkcast #23 // class java/lang/String\n 156: aload_0\n 157: aload 12\n 159: iconst_2\n 160: invokeinterface #126, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 165: checkcast #23 // class java/lang/String\n 168: invokevirtual #128 // Method parseOperator:(Ljava/lang/String;)LMathOperator;\n 171: invokespecial #131 // Method Day21$Monkey.\"<init>\":(Ljava/lang/String;Ljava/lang/Long;Ljava/lang/String;Ljava/lang/String;LMathOperator;)V\n 174: goto 215\n 177: new #122 // class Day21$Monkey\n 180: dup\n 181: aload 12\n 183: iconst_0\n 184: invokeinterface #126, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 189: checkcast #23 // class java/lang/String\n 192: aload 12\n 194: iconst_1\n 195: invokeinterface #126, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 200: checkcast #23 // class java/lang/String\n 203: invokestatic #137 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 206: invokestatic #141 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 209: aconst_null\n 210: aconst_null\n 211: aconst_null\n 212: invokespecial #131 // Method Day21$Monkey.\"<init>\":(Ljava/lang/String;Ljava/lang/Long;Ljava/lang/String;Ljava/lang/String;LMathOperator;)V\n 215: nop\n 216: aload 13\n 218: swap\n 219: invokeinterface #144, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 224: pop\n 225: goto 46\n 228: aload 5\n 230: checkcast #117 // class java/util/List\n 233: nop\n 234: areturn\n\n public final long calc1(java.lang.String, java.util.Map<java.lang.String, Day21$Monkey>);\n Code:\n 0: aload_1\n 1: ldc #165 // String name\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #167 // String map\n 9: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_2\n 13: aload_1\n 14: invokestatic #173 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 17: checkcast #122 // class Day21$Monkey\n 20: astore_3\n 21: aload_3\n 22: invokevirtual #176 // Method Day21$Monkey.getValue:()Ljava/lang/Long;\n 25: ifnull 40\n 28: aload_3\n 29: invokevirtual #176 // Method Day21$Monkey.getValue:()Ljava/lang/Long;\n 32: dup\n 33: invokestatic #180 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 36: invokevirtual #184 // Method java/lang/Long.longValue:()J\n 39: lreturn\n 40: aload_0\n 41: aload_3\n 42: invokevirtual #187 // Method Day21$Monkey.getLeft:()Ljava/lang/String;\n 45: dup\n 46: invokestatic #180 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 49: aload_2\n 50: invokevirtual #189 // Method calc1:(Ljava/lang/String;Ljava/util/Map;)J\n 53: lstore 4\n 55: aload_0\n 56: aload_3\n 57: invokevirtual #192 // Method Day21$Monkey.getRight:()Ljava/lang/String;\n 60: dup\n 61: invokestatic #180 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 64: aload_2\n 65: invokevirtual #189 // Method calc1:(Ljava/lang/String;Ljava/util/Map;)J\n 68: lstore 6\n 70: aload_3\n 71: invokevirtual #196 // Method Day21$Monkey.getOp:()LMathOperator;\n 74: dup\n 75: invokestatic #180 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 78: getstatic #202 // Field Day21$WhenMappings.$EnumSwitchMapping$0:[I\n 81: swap\n 82: invokevirtual #205 // Method MathOperator.ordinal:()I\n 85: iaload\n 86: tableswitch { // 1 to 4\n 1: 116\n 2: 124\n 3: 132\n 4: 140\n default: 148\n }\n 116: lload 4\n 118: lload 6\n 120: ladd\n 121: goto 156\n 124: lload 4\n 126: lload 6\n 128: lsub\n 129: goto 156\n 132: lload 4\n 134: lload 6\n 136: lmul\n 137: goto 156\n 140: lload 4\n 142: lload 6\n 144: ldiv\n 145: goto 156\n 148: new #207 // class kotlin/NoWhenBranchMatchedException\n 151: dup\n 152: invokespecial #208 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 155: athrow\n 156: lstore 8\n 158: aload_3\n 159: lload 8\n 161: invokestatic #141 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 164: invokevirtual #212 // Method Day21$Monkey.setValue:(Ljava/lang/Long;)V\n 167: lload 8\n 169: lreturn\n\n public final long calc2(java.lang.String, java.util.Map<java.lang.String, Day21$Monkey>);\n Code:\n 0: aload_1\n 1: ldc #165 // String name\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #167 // String map\n 9: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_2\n 13: aload_1\n 14: invokestatic #173 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 17: checkcast #122 // class Day21$Monkey\n 20: astore_3\n 21: aload_3\n 22: invokevirtual #176 // Method Day21$Monkey.getValue:()Ljava/lang/Long;\n 25: ifnull 40\n 28: aload_3\n 29: invokevirtual #176 // Method Day21$Monkey.getValue:()Ljava/lang/Long;\n 32: dup\n 33: invokestatic #180 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 36: invokevirtual #184 // Method java/lang/Long.longValue:()J\n 39: lreturn\n 40: aload_0\n 41: aload_3\n 42: invokevirtual #187 // Method Day21$Monkey.getLeft:()Ljava/lang/String;\n 45: dup\n 46: invokestatic #180 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 49: aload_2\n 50: invokevirtual #222 // Method calc2:(Ljava/lang/String;Ljava/util/Map;)J\n 53: lstore 4\n 55: aload_0\n 56: aload_3\n 57: invokevirtual #192 // Method Day21$Monkey.getRight:()Ljava/lang/String;\n 60: dup\n 61: invokestatic #180 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 64: aload_2\n 65: invokevirtual #222 // Method calc2:(Ljava/lang/String;Ljava/util/Map;)J\n 68: lstore 6\n 70: aload_3\n 71: invokevirtual #225 // Method Day21$Monkey.getName:()Ljava/lang/String;\n 74: ldc #227 // String root\n 76: invokestatic #231 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 79: ifeq 88\n 82: lload 6\n 84: lload 4\n 86: lsub\n 87: lreturn\n 88: aload_3\n 89: invokevirtual #196 // Method Day21$Monkey.getOp:()LMathOperator;\n 92: dup\n 93: invokestatic #180 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 96: getstatic #202 // Field Day21$WhenMappings.$EnumSwitchMapping$0:[I\n 99: swap\n 100: invokevirtual #205 // Method MathOperator.ordinal:()I\n 103: iaload\n 104: tableswitch { // 1 to 4\n 1: 136\n 2: 144\n 3: 152\n 4: 160\n default: 168\n }\n 136: lload 4\n 138: lload 6\n 140: ladd\n 141: goto 176\n 144: lload 4\n 146: lload 6\n 148: lsub\n 149: goto 176\n 152: lload 4\n 154: lload 6\n 156: lmul\n 157: goto 176\n 160: lload 4\n 162: lload 6\n 164: ldiv\n 165: goto 176\n 168: new #207 // class kotlin/NoWhenBranchMatchedException\n 171: dup\n 172: invokespecial #208 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 175: athrow\n 176: lstore 8\n 178: aload_3\n 179: lload 8\n 181: invokestatic #141 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 184: invokevirtual #212 // Method Day21$Monkey.setValue:(Ljava/lang/Long;)V\n 187: lload 8\n 189: lreturn\n\n public final java.lang.String part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #78 // String input\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokevirtual #236 // Method parse:(Ljava/util/List;)Ljava/util/List;\n 11: astore_2\n 12: aload_2\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: bipush 10\n 25: invokestatic #88 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 28: invokestatic #240 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 31: bipush 16\n 33: invokestatic #246 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 36: istore 6\n 38: aload 4\n 40: astore 7\n 42: new #248 // class java/util/LinkedHashMap\n 45: dup\n 46: iload 6\n 48: invokespecial #249 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 51: checkcast #251 // class java/util/Map\n 54: astore 8\n 56: iconst_0\n 57: istore 9\n 59: aload 7\n 61: invokeinterface #97, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 66: astore 10\n 68: aload 10\n 70: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 75: ifeq 120\n 78: aload 10\n 80: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 85: astore 11\n 87: aload 8\n 89: aload 11\n 91: checkcast #122 // class Day21$Monkey\n 94: astore 12\n 96: astore 14\n 98: iconst_0\n 99: istore 13\n 101: aload 12\n 103: invokevirtual #225 // Method Day21$Monkey.getName:()Ljava/lang/String;\n 106: aload 14\n 108: swap\n 109: aload 11\n 111: invokeinterface #255, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 116: pop\n 117: goto 68\n 120: aload 8\n 122: nop\n 123: astore_3\n 124: aload_0\n 125: ldc #227 // String root\n 127: aload_3\n 128: invokevirtual #189 // Method calc1:(Ljava/lang/String;Ljava/util/Map;)J\n 131: lstore 4\n 133: lload 4\n 135: invokestatic #258 // Method java/lang/String.valueOf:(J)Ljava/lang/String;\n 138: areturn\n\n public final java.lang.String part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #78 // String input\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc2_w #270 // long 5000000000000l\n 9: lstore_2\n 10: lconst_0\n 11: lstore 4\n 13: lload_2\n 14: lload 4\n 16: lsub\n 17: lconst_1\n 18: lcmp\n 19: ifle 220\n 22: lload_2\n 23: lload 4\n 25: ladd\n 26: iconst_2\n 27: i2l\n 28: ldiv\n 29: lstore 6\n 31: aload_0\n 32: aload_1\n 33: invokevirtual #236 // Method parse:(Ljava/util/List;)Ljava/util/List;\n 36: astore 8\n 38: aload 8\n 40: checkcast #80 // class java/lang/Iterable\n 43: astore 10\n 45: iconst_0\n 46: istore 11\n 48: aload 10\n 50: bipush 10\n 52: invokestatic #88 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 55: invokestatic #240 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 58: bipush 16\n 60: invokestatic #246 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 63: istore 12\n 65: aload 10\n 67: astore 13\n 69: new #248 // class java/util/LinkedHashMap\n 72: dup\n 73: iload 12\n 75: invokespecial #249 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 78: checkcast #251 // class java/util/Map\n 81: astore 14\n 83: iconst_0\n 84: istore 15\n 86: aload 13\n 88: invokeinterface #97, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 93: astore 16\n 95: aload 16\n 97: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 102: ifeq 147\n 105: aload 16\n 107: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 112: astore 17\n 114: aload 14\n 116: aload 17\n 118: checkcast #122 // class Day21$Monkey\n 121: astore 18\n 123: astore 20\n 125: iconst_0\n 126: istore 19\n 128: aload 18\n 130: invokevirtual #225 // Method Day21$Monkey.getName:()Ljava/lang/String;\n 133: aload 20\n 135: swap\n 136: aload 17\n 138: invokeinterface #255, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 143: pop\n 144: goto 95\n 147: aload 14\n 149: nop\n 150: astore 9\n 152: aload 9\n 154: ldc_w #273 // String humn\n 157: invokeinterface #276, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 162: dup\n 163: invokestatic #180 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 166: checkcast #122 // class Day21$Monkey\n 169: lload 6\n 171: invokestatic #141 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 174: invokevirtual #212 // Method Day21$Monkey.setValue:(Ljava/lang/Long;)V\n 177: aload_0\n 178: ldc #227 // String root\n 180: aload 9\n 182: invokevirtual #222 // Method calc2:(Ljava/lang/String;Ljava/util/Map;)J\n 185: lstore 10\n 187: lload 10\n 189: lconst_0\n 190: lcmp\n 191: ifeq 214\n 194: lload 10\n 196: lconst_0\n 197: lcmp\n 198: ifge 208\n 201: lload 6\n 203: lstore 4\n 205: goto 211\n 208: lload 6\n 210: lstore_2\n 211: goto 13\n 214: lload 6\n 216: invokestatic #258 // Method java/lang/String.valueOf:(J)Ljava/lang/String;\n 219: areturn\n 220: ldc_w #278 // String Not Found\n 223: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day21$Monkey.class",
"javap": "Compiled from \"Day21.kt\"\npublic final class Day21$Monkey {\n private final java.lang.String name;\n\n private java.lang.Long value;\n\n private final java.lang.String left;\n\n private final java.lang.String right;\n\n private final MathOperator op;\n\n public Day21$Monkey(java.lang.String, java.lang.Long, java.lang.String, java.lang.String, MathOperator);\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_0\n 7: invokespecial #19 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: aload_1\n 12: putfield #22 // Field name:Ljava/lang/String;\n 15: aload_0\n 16: aload_2\n 17: putfield #26 // Field value:Ljava/lang/Long;\n 20: aload_0\n 21: aload_3\n 22: putfield #29 // Field left:Ljava/lang/String;\n 25: aload_0\n 26: aload 4\n 28: putfield #32 // Field right:Ljava/lang/String;\n 31: aload_0\n 32: aload 5\n 34: putfield #36 // Field op:LMathOperator;\n 37: return\n\n public final java.lang.String getName();\n Code:\n 0: aload_0\n 1: getfield #22 // Field name:Ljava/lang/String;\n 4: areturn\n\n public final java.lang.Long getValue();\n Code:\n 0: aload_0\n 1: getfield #26 // Field value:Ljava/lang/Long;\n 4: areturn\n\n public final void setValue(java.lang.Long);\n Code:\n 0: aload_0\n 1: aload_1\n 2: putfield #26 // Field value:Ljava/lang/Long;\n 5: return\n\n public final java.lang.String getLeft();\n Code:\n 0: aload_0\n 1: getfield #29 // Field left:Ljava/lang/String;\n 4: areturn\n\n public final java.lang.String getRight();\n Code:\n 0: aload_0\n 1: getfield #32 // Field right:Ljava/lang/String;\n 4: areturn\n\n public final MathOperator getOp();\n Code:\n 0: aload_0\n 1: getfield #36 // Field op:LMathOperator;\n 4: areturn\n\n public final java.lang.String component1();\n Code:\n 0: aload_0\n 1: getfield #22 // Field name:Ljava/lang/String;\n 4: areturn\n\n public final java.lang.Long component2();\n Code:\n 0: aload_0\n 1: getfield #26 // Field value:Ljava/lang/Long;\n 4: areturn\n\n public final java.lang.String component3();\n Code:\n 0: aload_0\n 1: getfield #29 // Field left:Ljava/lang/String;\n 4: areturn\n\n public final java.lang.String component4();\n Code:\n 0: aload_0\n 1: getfield #32 // Field right:Ljava/lang/String;\n 4: areturn\n\n public final MathOperator component5();\n Code:\n 0: aload_0\n 1: getfield #36 // Field op:LMathOperator;\n 4: areturn\n\n public final Day21$Monkey copy(java.lang.String, java.lang.Long, java.lang.String, java.lang.String, MathOperator);\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: new #2 // class Day21$Monkey\n 9: dup\n 10: aload_1\n 11: aload_2\n 12: aload_3\n 13: aload 4\n 15: aload 5\n 17: invokespecial #58 // Method \"<init>\":(Ljava/lang/String;Ljava/lang/Long;Ljava/lang/String;Ljava/lang/String;LMathOperator;)V\n 20: areturn\n\n public static Day21$Monkey copy$default(Day21$Monkey, java.lang.String, java.lang.Long, java.lang.String, java.lang.String, MathOperator, int, java.lang.Object);\n Code:\n 0: iload 6\n 2: iconst_1\n 3: iand\n 4: ifeq 12\n 7: aload_0\n 8: getfield #22 // Field name:Ljava/lang/String;\n 11: astore_1\n 12: iload 6\n 14: iconst_2\n 15: iand\n 16: ifeq 24\n 19: aload_0\n 20: getfield #26 // Field value:Ljava/lang/Long;\n 23: astore_2\n 24: iload 6\n 26: iconst_4\n 27: iand\n 28: ifeq 36\n 31: aload_0\n 32: getfield #29 // Field left:Ljava/lang/String;\n 35: astore_3\n 36: iload 6\n 38: bipush 8\n 40: iand\n 41: ifeq 50\n 44: aload_0\n 45: getfield #32 // Field right:Ljava/lang/String;\n 48: astore 4\n 50: iload 6\n 52: bipush 16\n 54: iand\n 55: ifeq 64\n 58: aload_0\n 59: getfield #36 // Field op:LMathOperator;\n 62: astore 5\n 64: aload_0\n 65: aload_1\n 66: aload_2\n 67: aload_3\n 68: aload 4\n 70: aload 5\n 72: invokevirtual #62 // Method copy:(Ljava/lang/String;Ljava/lang/Long;Ljava/lang/String;Ljava/lang/String;LMathOperator;)LDay21$Monkey;\n 75: 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 Monkey(name=\n 9: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #22 // Field name:Ljava/lang/String;\n 16: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 19: ldc #74 // String , value=\n 21: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #26 // Field value:Ljava/lang/Long;\n 28: invokevirtual #77 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: ldc #79 // String , left=\n 33: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #29 // Field left:Ljava/lang/String;\n 40: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 43: ldc #81 // String , right=\n 45: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: aload_0\n 49: getfield #32 // Field right:Ljava/lang/String;\n 52: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 55: ldc #83 // String , op=\n 57: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 60: aload_0\n 61: getfield #36 // Field op:LMathOperator;\n 64: invokevirtual #77 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 67: bipush 41\n 69: invokevirtual #86 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 72: invokevirtual #88 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 75: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #22 // Field name:Ljava/lang/String;\n 4: invokevirtual #94 // Method java/lang/String.hashCode:()I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #26 // Field value:Ljava/lang/Long;\n 16: ifnonnull 23\n 19: iconst_0\n 20: goto 30\n 23: aload_0\n 24: getfield #26 // Field value:Ljava/lang/Long;\n 27: invokevirtual #95 // Method java/lang/Object.hashCode:()I\n 30: iadd\n 31: istore_1\n 32: iload_1\n 33: bipush 31\n 35: imul\n 36: aload_0\n 37: getfield #29 // Field left:Ljava/lang/String;\n 40: ifnonnull 47\n 43: iconst_0\n 44: goto 54\n 47: aload_0\n 48: getfield #29 // Field left:Ljava/lang/String;\n 51: invokevirtual #94 // Method java/lang/String.hashCode:()I\n 54: iadd\n 55: istore_1\n 56: iload_1\n 57: bipush 31\n 59: imul\n 60: aload_0\n 61: getfield #32 // Field right:Ljava/lang/String;\n 64: ifnonnull 71\n 67: iconst_0\n 68: goto 78\n 71: aload_0\n 72: getfield #32 // Field right:Ljava/lang/String;\n 75: invokevirtual #94 // Method java/lang/String.hashCode:()I\n 78: iadd\n 79: istore_1\n 80: iload_1\n 81: bipush 31\n 83: imul\n 84: aload_0\n 85: getfield #36 // Field op:LMathOperator;\n 88: ifnonnull 95\n 91: iconst_0\n 92: goto 102\n 95: aload_0\n 96: getfield #36 // Field op:LMathOperator;\n 99: invokevirtual #98 // Method MathOperator.hashCode:()I\n 102: iadd\n 103: istore_1\n 104: iload_1\n 105: 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$Monkey\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day21$Monkey\n 20: astore_2\n 21: aload_0\n 22: getfield #22 // Field name:Ljava/lang/String;\n 25: aload_2\n 26: getfield #22 // Field name:Ljava/lang/String;\n 29: invokestatic #106 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 32: ifne 37\n 35: iconst_0\n 36: ireturn\n 37: aload_0\n 38: getfield #26 // Field value:Ljava/lang/Long;\n 41: aload_2\n 42: getfield #26 // Field value:Ljava/lang/Long;\n 45: invokestatic #106 // 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 left:Ljava/lang/String;\n 57: aload_2\n 58: getfield #29 // Field left:Ljava/lang/String;\n 61: invokestatic #106 // 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: aload_0\n 70: getfield #32 // Field right:Ljava/lang/String;\n 73: aload_2\n 74: getfield #32 // Field right:Ljava/lang/String;\n 77: invokestatic #106 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 80: ifne 85\n 83: iconst_0\n 84: ireturn\n 85: aload_0\n 86: getfield #36 // Field op:LMathOperator;\n 89: aload_2\n 90: getfield #36 // Field op:LMathOperator;\n 93: if_acmpeq 98\n 96: iconst_0\n 97: ireturn\n 98: iconst_1\n 99: ireturn\n}\n",
"javap_err": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day17.kt
|
import kotlin.math.max
class Rock(val cells: List<Point>, var shift: Point) {
fun getCoords(): List<Point> {
return cells.map { x -> x.sum(shift) }
}
fun hasCollision(points: Set<Point>, move: Point): Boolean {
val newPosition = this.getCoords()
.map { it.sum(move) }
val hasBoundsCollision = newPosition.any { p -> p.x == -1 || p.y == -1 || p.x == 7 }
if (hasBoundsCollision) {
return true
}
val hasCollision = newPosition
.intersect(points)
.isNotEmpty()
if (hasCollision) {
return true
}
return false
}
companion object {
fun create(index: Int, init: Point): Rock {
return when (val number = index % 5) {
// ####
0 -> Rock(
listOf(
Point(0, 0),
Point(1, 0),
Point(2, 0),
Point(3, 0)
),
init
)
// +
1 -> Rock(
listOf(
Point(1, 0),
Point(0, 1),
Point(1, 1),
Point(2, 1),
Point(1, 2)
),
init
)
// _|
2 -> Rock(
listOf(
Point(0, 0),
Point(1, 0),
Point(2, 0),
Point(2, 1),
Point(2, 2)
),
init
)
// |
3 -> Rock(
listOf(
Point(0, 0),
Point(0, 1),
Point(0, 2),
Point(0, 3)
),
init
)
// square
4 -> Rock(
listOf(
Point(0, 0),
Point(1, 0),
Point(0, 1),
Point(1, 1)
),
init
)
else -> throw RuntimeException("Unexpected $number")
}
}
}
}
@Suppress("DuplicatedCode")
fun main() {
data class State(
val stoppedRocksCount: Long,
val ground: Set<Point>,
val maxY: Int
)
fun parse(input: List<String>): List<Direction> {
return input[0].toCharArray().map { c -> if (c == '<') Direction.Left else Direction.Right }
}
fun print(rocks: List<Rock>) {
val points = rocks.flatMap { r -> r.getCoords() }.toSet()
val maxY = points.maxOf { c -> c.y }
for (y in maxY downTo 0) {
for (x in 0..6) {
if (points.contains(Point(x, y))) {
print('#')
} else {
print('.')
}
}
println()
}
println()
println()
}
fun calculateState(
topLevelMap: MutableMap<Int, Int>,
stopped: Long,
maxY: Int
): State {
val minY = topLevelMap.minOf { t -> t.value }
val newGround = topLevelMap.map { t -> Point(t.key, (t.value - minY)) }.toSet()
return State(stopped, newGround, maxY)
}
fun removeUnreachable(
topLevelMap: MutableMap<Int, Int>,
ground: MutableSet<Point>
) {
val minLevel = topLevelMap.values.min()
ground.removeIf { it.y < minLevel }
}
fun actualizeTopLevels(
coords: List<Point>,
topLevelMap: MutableMap<Int, Int>
) {
for (coord in coords) {
val top = topLevelMap[coord.x]
if (top == null || top < coord.y) {
topLevelMap[coord.x] = coord.y
}
}
}
fun play(directions: List<Direction>, rocksLimit: Long, initGround: Set<Point>): List<State> {
var directionIterator = 0
var rockIterator = 0
var shift = Point(2, 3)
val ground = initGround.toMutableSet()
var stopped = 0L
val topLevelMap = mutableMapOf<Int, Int>()
var activeRock: Rock? = null
var maxY = 0
val states = mutableListOf<State>()
val dy = Point(0, -1)
while (stopped < rocksLimit) {
if (activeRock == null) {
activeRock = Rock.create(rockIterator, shift)
++rockIterator
}
val direction = directions[directionIterator]
val dx = if (direction == Direction.Left) Point(-1, 0) else Point(1, 0)
if (!activeRock.hasCollision(ground, dx)) {
activeRock.shift = activeRock.shift.sum(dx)
}
if (!activeRock.hasCollision(ground, dy)) {
activeRock.shift = activeRock.shift.sum(dy)
} else {
++stopped
val coords = activeRock.getCoords()
actualizeTopLevels(coords, topLevelMap)
ground.addAll(coords)
removeUnreachable(topLevelMap, ground)
maxY = max(maxY, topLevelMap.values.max() + 1)
shift = Point(shift.x, maxY + 3)
activeRock = null
}
directionIterator = (directionIterator + 1) % directions.size
if (directionIterator == 0) {
states.add(calculateState(topLevelMap, stopped, maxY))
if (states.size > 1) {
break
}
}
}
if (states.size <= 1) {
states.add(calculateState(topLevelMap, stopped, maxY))
}
return states
}
fun findMax(directions: List<Direction>, totalRocks: Long): Long {
val defaultGround = (0..6).map { Point(it, -1) }.toSet()
val states = play(directions, totalRocks, defaultGround).reversed()
val lastRocksCount = states[0].stoppedRocksCount
val maxY = states[0].maxY
val leftRocks = totalRocks - lastRocksCount
if (leftRocks == 0L) {
return maxY.toLong()
}
val deltaRocks = lastRocksCount - states[1].stoppedRocksCount
val deltaY = states[0].maxY - states[1].maxY
val mult = leftRocks / deltaRocks
val sliceY = deltaY * mult
val restRocks = leftRocks % deltaRocks
val (_, _, maxY1) = play(
directions,
restRocks,
states[0].ground
)[0]
return maxY + sliceY + maxY1 - 1
}
fun part1(input: List<String>): Long {
return findMax(parse(input), 2022L)
}
fun part2(input: List<String>): Long {
return findMax(parse(input), 1000000000000L)
}
// ==================================================================== //
val day = "17"
fun test() {
val testInput = readInput("Day${day}_test")
assert(part1(testInput), 3068L)
assert(part2(testInput), 1514285714288L)
}
fun run() {
val input = readInput("Day$day")
println(part1(input))
println(part2(input))
}
// test()
run()
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day17Kt.class",
"javap": "Compiled from \"Day17.kt\"\npublic final class Day17Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String 17\n 2: astore_0\n 3: aload_0\n 4: invokestatic #12 // Method main$run:(Ljava/lang/String;)V\n 7: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #17 // Method main:()V\n 3: return\n\n private static final java.util.List<Direction> main$parse(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: iconst_0\n 2: invokeinterface #28, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #30 // class java/lang/String\n 10: invokevirtual #34 // Method java/lang/String.toCharArray:()[C\n 13: dup\n 14: ldc #36 // String toCharArray(...)\n 16: invokestatic #42 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 19: astore_1\n 20: nop\n 21: iconst_0\n 22: istore_2\n 23: aload_1\n 24: astore_3\n 25: new #44 // class java/util/ArrayList\n 28: dup\n 29: aload_1\n 30: arraylength\n 31: invokespecial #48 // Method java/util/ArrayList.\"<init>\":(I)V\n 34: checkcast #50 // class java/util/Collection\n 37: astore 4\n 39: iconst_0\n 40: istore 5\n 42: iconst_0\n 43: istore 6\n 45: aload_3\n 46: arraylength\n 47: istore 7\n 49: iload 6\n 51: iload 7\n 53: if_icmpge 104\n 56: aload_3\n 57: iload 6\n 59: caload\n 60: istore 8\n 62: aload 4\n 64: iload 8\n 66: istore 9\n 68: astore 11\n 70: iconst_0\n 71: istore 10\n 73: iload 9\n 75: bipush 60\n 77: if_icmpne 86\n 80: getstatic #56 // Field Direction.Left:LDirection;\n 83: goto 89\n 86: getstatic #59 // Field Direction.Right:LDirection;\n 89: aload 11\n 91: swap\n 92: invokeinterface #63, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 97: pop\n 98: iinc 6, 1\n 101: goto 49\n 104: aload 4\n 106: checkcast #24 // class java/util/List\n 109: nop\n 110: areturn\n\n private static final void main$print(java.util.List<Rock>);\n Code:\n 0: aload_0\n 1: checkcast #83 // 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 #44 // class java/util/ArrayList\n 13: dup\n 14: invokespecial #85 // Method java/util/ArrayList.\"<init>\":()V\n 17: checkcast #50 // class java/util/Collection\n 20: astore 5\n 22: iconst_0\n 23: istore 6\n 25: aload 4\n 27: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 32: astore 7\n 34: aload 7\n 36: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 41: ifeq 84\n 44: aload 7\n 46: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 51: astore 8\n 53: aload 8\n 55: checkcast #101 // class Rock\n 58: astore 9\n 60: iconst_0\n 61: istore 10\n 63: aload 9\n 65: invokevirtual #105 // Method Rock.getCoords:()Ljava/util/List;\n 68: checkcast #83 // class java/lang/Iterable\n 71: astore 9\n 73: aload 5\n 75: aload 9\n 77: invokestatic #111 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 80: pop\n 81: goto 34\n 84: aload 5\n 86: checkcast #24 // class java/util/List\n 89: nop\n 90: checkcast #83 // class java/lang/Iterable\n 93: invokestatic #115 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 96: astore_1\n 97: aload_1\n 98: checkcast #83 // class java/lang/Iterable\n 101: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 106: astore 4\n 108: aload 4\n 110: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 115: ifne 126\n 118: new #117 // class java/util/NoSuchElementException\n 121: dup\n 122: invokespecial #118 // Method java/util/NoSuchElementException.\"<init>\":()V\n 125: athrow\n 126: aload 4\n 128: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 133: checkcast #120 // class Point\n 136: astore 5\n 138: iconst_0\n 139: istore 6\n 141: aload 5\n 143: invokevirtual #124 // Method Point.getY:()I\n 146: istore 5\n 148: aload 4\n 150: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 155: ifeq 194\n 158: aload 4\n 160: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 165: checkcast #120 // class Point\n 168: astore 6\n 170: iconst_0\n 171: istore 7\n 173: aload 6\n 175: invokevirtual #124 // Method Point.getY:()I\n 178: istore 6\n 180: iload 5\n 182: iload 6\n 184: if_icmpge 148\n 187: iload 6\n 189: istore 5\n 191: goto 148\n 194: iload 5\n 196: istore_2\n 197: iload_2\n 198: istore_3\n 199: iconst_m1\n 200: iload_3\n 201: if_icmpge 278\n 204: iconst_0\n 205: istore 4\n 207: iload 4\n 209: bipush 7\n 211: if_icmpge 266\n 214: aload_1\n 215: new #120 // class Point\n 218: dup\n 219: iload 4\n 221: iload_3\n 222: invokespecial #127 // Method Point.\"<init>\":(II)V\n 225: invokeinterface #132, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 230: ifeq 248\n 233: bipush 35\n 235: istore 5\n 237: getstatic #138 // Field java/lang/System.out:Ljava/io/PrintStream;\n 240: iload 5\n 242: invokevirtual #144 // Method java/io/PrintStream.print:(C)V\n 245: goto 260\n 248: bipush 46\n 250: istore 5\n 252: getstatic #138 // Field java/lang/System.out:Ljava/io/PrintStream;\n 255: iload 5\n 257: invokevirtual #144 // Method java/io/PrintStream.print:(C)V\n 260: iinc 4, 1\n 263: goto 207\n 266: getstatic #138 // Field java/lang/System.out:Ljava/io/PrintStream;\n 269: invokevirtual #147 // Method java/io/PrintStream.println:()V\n 272: iinc 3, -1\n 275: goto 199\n 278: getstatic #138 // Field java/lang/System.out:Ljava/io/PrintStream;\n 281: invokevirtual #147 // Method java/io/PrintStream.println:()V\n 284: getstatic #138 // Field java/lang/System.out:Ljava/io/PrintStream;\n 287: invokevirtual #147 // Method java/io/PrintStream.println:()V\n 290: return\n\n private static final Day17Kt$main$State main$calculateState(java.util.Map<java.lang.Integer, java.lang.Integer>, long, int);\n Code:\n 0: aload_0\n 1: invokeinterface #175, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 6: checkcast #83 // class java/lang/Iterable\n 9: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 14: astore 6\n 16: aload 6\n 18: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 23: ifne 34\n 26: new #117 // class java/util/NoSuchElementException\n 29: dup\n 30: invokespecial #118 // Method java/util/NoSuchElementException.\"<init>\":()V\n 33: athrow\n 34: aload 6\n 36: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 41: checkcast #177 // class java/util/Map$Entry\n 44: astore 7\n 46: iconst_0\n 47: istore 8\n 49: aload 7\n 51: invokeinterface #180, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 56: checkcast #182 // class java/lang/Number\n 59: invokevirtual #185 // Method java/lang/Number.intValue:()I\n 62: istore 7\n 64: aload 6\n 66: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 71: ifeq 118\n 74: aload 6\n 76: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 81: checkcast #177 // class java/util/Map$Entry\n 84: astore 8\n 86: iconst_0\n 87: istore 9\n 89: aload 8\n 91: invokeinterface #180, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 96: checkcast #182 // class java/lang/Number\n 99: invokevirtual #185 // Method java/lang/Number.intValue:()I\n 102: istore 8\n 104: iload 7\n 106: iload 8\n 108: if_icmple 64\n 111: iload 8\n 113: istore 7\n 115: goto 64\n 118: iload 7\n 120: istore 4\n 122: aload_0\n 123: astore 6\n 125: iconst_0\n 126: istore 7\n 128: aload 6\n 130: astore 8\n 132: new #44 // class java/util/ArrayList\n 135: dup\n 136: aload 6\n 138: invokeinterface #188, 1 // InterfaceMethod java/util/Map.size:()I\n 143: invokespecial #48 // Method java/util/ArrayList.\"<init>\":(I)V\n 146: checkcast #50 // class java/util/Collection\n 149: astore 9\n 151: iconst_0\n 152: istore 10\n 154: aload 8\n 156: invokeinterface #175, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 161: invokeinterface #189, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 166: astore 11\n 168: aload 11\n 170: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 175: ifeq 249\n 178: aload 11\n 180: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 185: checkcast #177 // class java/util/Map$Entry\n 188: astore 12\n 190: aload 9\n 192: aload 12\n 194: astore 13\n 196: astore 15\n 198: iconst_0\n 199: istore 14\n 201: new #120 // class Point\n 204: dup\n 205: aload 13\n 207: invokeinterface #192, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 212: checkcast #182 // class java/lang/Number\n 215: invokevirtual #185 // Method java/lang/Number.intValue:()I\n 218: aload 13\n 220: invokeinterface #180, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 225: checkcast #182 // class java/lang/Number\n 228: invokevirtual #185 // Method java/lang/Number.intValue:()I\n 231: iload 4\n 233: isub\n 234: invokespecial #127 // Method Point.\"<init>\":(II)V\n 237: aload 15\n 239: swap\n 240: invokeinterface #63, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 245: pop\n 246: goto 168\n 249: aload 9\n 251: checkcast #24 // class java/util/List\n 254: nop\n 255: checkcast #83 // class java/lang/Iterable\n 258: invokestatic #115 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 261: astore 5\n 263: new #194 // class Day17Kt$main$State\n 266: dup\n 267: lload_1\n 268: aload 5\n 270: iload_3\n 271: invokespecial #197 // Method Day17Kt$main$State.\"<init>\":(JLjava/util/Set;I)V\n 274: areturn\n\n private static final boolean main$removeUnreachable$lambda$5(int, Point);\n Code:\n 0: aload_1\n 1: ldc #211 // String it\n 3: invokestatic #214 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokevirtual #124 // Method Point.getY:()I\n 10: iload_0\n 11: if_icmpge 18\n 14: iconst_1\n 15: goto 19\n 18: iconst_0\n 19: ireturn\n\n private static final boolean main$removeUnreachable$lambda$6(kotlin.jvm.functions.Function1, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokeinterface #223, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: checkcast #225 // class java/lang/Boolean\n 10: invokevirtual #228 // Method java/lang/Boolean.booleanValue:()Z\n 13: ireturn\n\n private static final void main$removeUnreachable(java.util.Map<java.lang.Integer, java.lang.Integer>, java.util.Set<Point>);\n Code:\n 0: aload_0\n 1: invokeinterface #238, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 6: checkcast #83 // class java/lang/Iterable\n 9: invokestatic #242 // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 12: checkcast #182 // class java/lang/Number\n 15: invokevirtual #185 // Method java/lang/Number.intValue:()I\n 18: istore_2\n 19: aload_1\n 20: iload_2\n 21: invokedynamic #258, 0 // InvokeDynamic #0:invoke:(I)Lkotlin/jvm/functions/Function1;\n 26: invokedynamic #266, 0 // InvokeDynamic #1:test:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Predicate;\n 31: invokeinterface #270, 2 // InterfaceMethod java/util/Set.removeIf:(Ljava/util/function/Predicate;)Z\n 36: pop\n 37: return\n\n private static final void main$actualizeTopLevels(java.util.List<Point>, java.util.Map<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: invokeinterface #276, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 6: astore_2\n 7: aload_2\n 8: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 13: ifeq 85\n 16: aload_2\n 17: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 22: checkcast #120 // class Point\n 25: astore_3\n 26: aload_1\n 27: aload_3\n 28: invokevirtual #279 // Method Point.getX:()I\n 31: invokestatic #285 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 34: invokeinterface #287, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 39: checkcast #281 // class java/lang/Integer\n 42: astore 4\n 44: aload 4\n 46: ifnull 61\n 49: aload 4\n 51: invokevirtual #288 // Method java/lang/Integer.intValue:()I\n 54: aload_3\n 55: invokevirtual #124 // Method Point.getY:()I\n 58: if_icmpge 7\n 61: aload_1\n 62: aload_3\n 63: invokevirtual #279 // Method Point.getX:()I\n 66: invokestatic #285 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 69: aload_3\n 70: invokevirtual #124 // Method Point.getY:()I\n 73: invokestatic #285 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 76: invokeinterface #292, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 81: pop\n 82: goto 7\n 85: return\n\n private static final java.util.List<Day17Kt$main$State> main$play(java.util.List<? extends Direction>, long, java.util.Set<Point>);\n Code:\n 0: iconst_0\n 1: istore 4\n 3: iconst_0\n 4: istore 5\n 6: new #120 // class Point\n 9: dup\n 10: iconst_2\n 11: iconst_3\n 12: invokespecial #127 // Method Point.\"<init>\":(II)V\n 15: astore 6\n 17: aload_3\n 18: checkcast #83 // class java/lang/Iterable\n 21: invokestatic #302 // Method kotlin/collections/CollectionsKt.toMutableSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 24: astore 7\n 26: lconst_0\n 27: lstore 8\n 29: new #304 // class java/util/LinkedHashMap\n 32: dup\n 33: invokespecial #305 // Method java/util/LinkedHashMap.\"<init>\":()V\n 36: checkcast #171 // class java/util/Map\n 39: astore 10\n 41: aconst_null\n 42: astore 11\n 44: iconst_0\n 45: istore 12\n 47: new #44 // class java/util/ArrayList\n 50: dup\n 51: invokespecial #85 // Method java/util/ArrayList.\"<init>\":()V\n 54: checkcast #24 // class java/util/List\n 57: astore 13\n 59: new #120 // class Point\n 62: dup\n 63: iconst_0\n 64: iconst_m1\n 65: invokespecial #127 // Method Point.\"<init>\":(II)V\n 68: astore 14\n 70: lload 8\n 72: lload_1\n 73: lcmp\n 74: ifge 336\n 77: aload 11\n 79: ifnonnull 97\n 82: getstatic #309 // Field Rock.Companion:LRock$Companion;\n 85: iload 5\n 87: aload 6\n 89: invokevirtual #315 // Method Rock$Companion.create:(ILPoint;)LRock;\n 92: astore 11\n 94: iinc 5, 1\n 97: aload_0\n 98: iload 4\n 100: invokeinterface #28, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 105: checkcast #52 // class Direction\n 108: astore 15\n 110: aload 15\n 112: getstatic #56 // Field Direction.Left:LDirection;\n 115: if_acmpne 130\n 118: new #120 // class Point\n 121: dup\n 122: iconst_m1\n 123: iconst_0\n 124: invokespecial #127 // Method Point.\"<init>\":(II)V\n 127: goto 139\n 130: new #120 // class Point\n 133: dup\n 134: iconst_1\n 135: iconst_0\n 136: invokespecial #127 // Method Point.\"<init>\":(II)V\n 139: astore 16\n 141: aload 11\n 143: aload 7\n 145: aload 16\n 147: invokevirtual #319 // Method Rock.hasCollision:(Ljava/util/Set;LPoint;)Z\n 150: ifne 168\n 153: aload 11\n 155: aload 11\n 157: invokevirtual #323 // Method Rock.getShift:()LPoint;\n 160: aload 16\n 162: invokevirtual #327 // Method Point.sum:(LPoint;)LPoint;\n 165: invokevirtual #331 // Method Rock.setShift:(LPoint;)V\n 168: aload 11\n 170: aload 7\n 172: aload 14\n 174: invokevirtual #319 // Method Rock.hasCollision:(Ljava/util/Set;LPoint;)Z\n 177: ifne 198\n 180: aload 11\n 182: aload 11\n 184: invokevirtual #323 // Method Rock.getShift:()LPoint;\n 187: aload 14\n 189: invokevirtual #327 // Method Point.sum:(LPoint;)LPoint;\n 192: invokevirtual #331 // Method Rock.setShift:(LPoint;)V\n 195: goto 287\n 198: lload 8\n 200: lconst_1\n 201: ladd\n 202: lstore 8\n 204: aload 11\n 206: invokevirtual #105 // Method Rock.getCoords:()Ljava/util/List;\n 209: astore 17\n 211: aload 17\n 213: aload 10\n 215: invokestatic #333 // Method main$actualizeTopLevels:(Ljava/util/List;Ljava/util/Map;)V\n 218: aload 7\n 220: aload 17\n 222: checkcast #50 // class java/util/Collection\n 225: invokeinterface #336, 2 // InterfaceMethod java/util/Set.addAll:(Ljava/util/Collection;)Z\n 230: pop\n 231: aload 10\n 233: aload 7\n 235: invokestatic #338 // Method main$removeUnreachable:(Ljava/util/Map;Ljava/util/Set;)V\n 238: iload 12\n 240: aload 10\n 242: invokeinterface #238, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 247: checkcast #83 // class java/lang/Iterable\n 250: invokestatic #341 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 253: checkcast #182 // class java/lang/Number\n 256: invokevirtual #185 // Method java/lang/Number.intValue:()I\n 259: iconst_1\n 260: iadd\n 261: invokestatic #347 // Method java/lang/Math.max:(II)I\n 264: istore 12\n 266: new #120 // class Point\n 269: dup\n 270: aload 6\n 272: invokevirtual #279 // Method Point.getX:()I\n 275: iload 12\n 277: iconst_3\n 278: iadd\n 279: invokespecial #127 // Method Point.\"<init>\":(II)V\n 282: astore 6\n 284: aconst_null\n 285: astore 11\n 287: iload 4\n 289: iconst_1\n 290: iadd\n 291: aload_0\n 292: invokeinterface #348, 1 // InterfaceMethod java/util/List.size:()I\n 297: irem\n 298: istore 4\n 300: iload 4\n 302: ifne 70\n 305: aload 13\n 307: aload 10\n 309: lload 8\n 311: iload 12\n 313: invokestatic #350 // Method main$calculateState:(Ljava/util/Map;JI)LDay17Kt$main$State;\n 316: invokeinterface #351, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 321: pop\n 322: aload 13\n 324: invokeinterface #348, 1 // InterfaceMethod java/util/List.size:()I\n 329: iconst_1\n 330: if_icmple 70\n 333: goto 336\n 336: aload 13\n 338: invokeinterface #348, 1 // InterfaceMethod java/util/List.size:()I\n 343: iconst_1\n 344: if_icmpgt 364\n 347: aload 13\n 349: aload 10\n 351: lload 8\n 353: iload 12\n 355: invokestatic #350 // Method main$calculateState:(Ljava/util/Map;JI)LDay17Kt$main$State;\n 358: invokeinterface #351, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 363: pop\n 364: aload 13\n 366: areturn\n\n private static final long main$findMax(java.util.List<? extends Direction>, long);\n Code:\n 0: new #367 // class kotlin/ranges/IntRange\n 3: dup\n 4: iconst_0\n 5: bipush 6\n 7: invokespecial #368 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 10: checkcast #83 // class java/lang/Iterable\n 13: astore 4\n 15: iconst_0\n 16: istore 5\n 18: aload 4\n 20: astore 6\n 22: new #44 // class java/util/ArrayList\n 25: dup\n 26: aload 4\n 28: bipush 10\n 30: invokestatic #372 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 33: invokespecial #48 // Method java/util/ArrayList.\"<init>\":(I)V\n 36: checkcast #50 // class java/util/Collection\n 39: astore 7\n 41: iconst_0\n 42: istore 8\n 44: aload 6\n 46: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 51: astore 9\n 53: aload 9\n 55: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 60: ifeq 106\n 63: aload 9\n 65: checkcast #374 // class kotlin/collections/IntIterator\n 68: invokevirtual #377 // Method kotlin/collections/IntIterator.nextInt:()I\n 71: istore 10\n 73: aload 7\n 75: iload 10\n 77: istore 11\n 79: astore 20\n 81: iconst_0\n 82: istore 12\n 84: new #120 // class Point\n 87: dup\n 88: iload 11\n 90: iconst_m1\n 91: invokespecial #127 // Method Point.\"<init>\":(II)V\n 94: aload 20\n 96: swap\n 97: invokeinterface #63, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 102: pop\n 103: goto 53\n 106: aload 7\n 108: checkcast #24 // class java/util/List\n 111: nop\n 112: checkcast #83 // class java/lang/Iterable\n 115: invokestatic #115 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 118: astore_3\n 119: aload_0\n 120: lload_1\n 121: aload_3\n 122: invokestatic #379 // Method main$play:(Ljava/util/List;JLjava/util/Set;)Ljava/util/List;\n 125: checkcast #83 // class java/lang/Iterable\n 128: invokestatic #383 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 131: astore 4\n 133: aload 4\n 135: iconst_0\n 136: invokeinterface #28, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 141: checkcast #194 // class Day17Kt$main$State\n 144: invokevirtual #387 // Method Day17Kt$main$State.getStoppedRocksCount:()J\n 147: lstore 5\n 149: aload 4\n 151: iconst_0\n 152: invokeinterface #28, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 157: checkcast #194 // class Day17Kt$main$State\n 160: invokevirtual #390 // Method Day17Kt$main$State.getMaxY:()I\n 163: istore 7\n 165: lload_1\n 166: lload 5\n 168: lsub\n 169: lstore 8\n 171: lload 8\n 173: lconst_0\n 174: lcmp\n 175: ifne 182\n 178: iload 7\n 180: i2l\n 181: lreturn\n 182: lload 5\n 184: aload 4\n 186: iconst_1\n 187: invokeinterface #28, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 192: checkcast #194 // class Day17Kt$main$State\n 195: invokevirtual #387 // Method Day17Kt$main$State.getStoppedRocksCount:()J\n 198: lsub\n 199: lstore 10\n 201: aload 4\n 203: iconst_0\n 204: invokeinterface #28, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 209: checkcast #194 // class Day17Kt$main$State\n 212: invokevirtual #390 // Method Day17Kt$main$State.getMaxY:()I\n 215: aload 4\n 217: iconst_1\n 218: invokeinterface #28, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 223: checkcast #194 // class Day17Kt$main$State\n 226: invokevirtual #390 // Method Day17Kt$main$State.getMaxY:()I\n 229: isub\n 230: istore 12\n 232: lload 8\n 234: lload 10\n 236: ldiv\n 237: lstore 13\n 239: iload 12\n 241: i2l\n 242: lload 13\n 244: lmul\n 245: lstore 15\n 247: lload 8\n 249: lload 10\n 251: lrem\n 252: lstore 17\n 254: aload_0\n 255: lload 17\n 257: aload 4\n 259: iconst_0\n 260: invokeinterface #28, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 265: checkcast #194 // class Day17Kt$main$State\n 268: invokevirtual #393 // Method Day17Kt$main$State.getGround:()Ljava/util/Set;\n 271: invokestatic #379 // Method main$play:(Ljava/util/List;JLjava/util/Set;)Ljava/util/List;\n 274: iconst_0\n 275: invokeinterface #28, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 280: checkcast #194 // class Day17Kt$main$State\n 283: invokevirtual #396 // Method Day17Kt$main$State.component3:()I\n 286: istore 19\n 288: iload 7\n 290: i2l\n 291: lload 15\n 293: ladd\n 294: iload 19\n 296: i2l\n 297: ladd\n 298: lconst_1\n 299: lsub\n 300: lreturn\n\n private static final long main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #412 // Method main$parse:(Ljava/util/List;)Ljava/util/List;\n 4: ldc2_w #413 // long 2022l\n 7: invokestatic #416 // Method main$findMax:(Ljava/util/List;J)J\n 10: lreturn\n\n private static final long main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #412 // Method main$parse:(Ljava/util/List;)Ljava/util/List;\n 4: ldc2_w #418 // long 1000000000000l\n 7: invokestatic #416 // Method main$findMax:(Ljava/util/List;J)J\n 10: lreturn\n\n private static final void main$test(java.lang.String);\n Code:\n 0: new #422 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #423 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc_w #425 // String Day\n 10: invokevirtual #429 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 13: aload_0\n 14: invokevirtual #429 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 17: ldc_w #431 // String _test\n 20: invokevirtual #429 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 23: invokevirtual #435 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 26: invokestatic #441 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 29: astore_1\n 30: aload_1\n 31: invokestatic #443 // Method main$part1:(Ljava/util/List;)J\n 34: invokestatic #448 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 37: ldc2_w #449 // long 3068l\n 40: invokestatic #448 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 43: invokestatic #454 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 46: aload_1\n 47: invokestatic #456 // Method main$part2:(Ljava/util/List;)J\n 50: invokestatic #448 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 53: ldc2_w #457 // long 1514285714288l\n 56: invokestatic #448 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 59: invokestatic #454 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 62: return\n\n private static final void main$run(java.lang.String);\n Code:\n 0: new #422 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #423 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc_w #425 // String Day\n 10: invokevirtual #429 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 13: aload_0\n 14: invokevirtual #429 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 17: invokevirtual #435 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 20: invokestatic #441 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 23: astore_1\n 24: aload_1\n 25: invokestatic #443 // Method main$part1:(Ljava/util/List;)J\n 28: lstore_2\n 29: getstatic #138 // Field java/lang/System.out:Ljava/io/PrintStream;\n 32: lload_2\n 33: invokevirtual #462 // Method java/io/PrintStream.println:(J)V\n 36: aload_1\n 37: invokestatic #456 // Method main$part2:(Ljava/util/List;)J\n 40: lstore_2\n 41: getstatic #138 // Field java/lang/System.out:Ljava/io/PrintStream;\n 44: lload_2\n 45: invokevirtual #462 // Method java/io/PrintStream.println:(J)V\n 48: return\n}\n",
"javap_err": ""
},
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day17Kt$main$State.class",
"javap": "Compiled from \"Day17.kt\"\npublic final class Day17Kt$main$State {\n private final long stoppedRocksCount;\n\n private final java.util.Set<Point> ground;\n\n private final int maxY;\n\n public Day17Kt$main$State(long, java.util.Set<Point>, int);\n Code:\n 0: aload_3\n 1: ldc #9 // String ground\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: lload_1\n 12: putfield #22 // Field stoppedRocksCount:J\n 15: aload_0\n 16: aload_3\n 17: putfield #25 // Field ground:Ljava/util/Set;\n 20: aload_0\n 21: iload 4\n 23: putfield #29 // Field maxY:I\n 26: return\n\n public final long getStoppedRocksCount();\n Code:\n 0: aload_0\n 1: getfield #22 // Field stoppedRocksCount:J\n 4: lreturn\n\n public final java.util.Set<Point> getGround();\n Code:\n 0: aload_0\n 1: getfield #25 // Field ground:Ljava/util/Set;\n 4: areturn\n\n public final int getMaxY();\n Code:\n 0: aload_0\n 1: getfield #29 // Field maxY:I\n 4: ireturn\n\n public final long component1();\n Code:\n 0: aload_0\n 1: getfield #22 // Field stoppedRocksCount:J\n 4: lreturn\n\n public final java.util.Set<Point> component2();\n Code:\n 0: aload_0\n 1: getfield #25 // Field ground:Ljava/util/Set;\n 4: areturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #29 // Field maxY:I\n 4: ireturn\n\n public final Day17Kt$main$State copy(long, java.util.Set<Point>, int);\n Code:\n 0: aload_3\n 1: ldc #9 // String ground\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class Day17Kt$main$State\n 9: dup\n 10: lload_1\n 11: aload_3\n 12: iload 4\n 14: invokespecial #46 // Method \"<init>\":(JLjava/util/Set;I)V\n 17: areturn\n\n public static Day17Kt$main$State copy$default(Day17Kt$main$State, long, java.util.Set, 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 #22 // Field stoppedRocksCount:J\n 11: lstore_1\n 12: iload 5\n 14: iconst_2\n 15: iand\n 16: ifeq 24\n 19: aload_0\n 20: getfield #25 // Field ground:Ljava/util/Set;\n 23: astore_3\n 24: iload 5\n 26: iconst_4\n 27: iand\n 28: ifeq 37\n 31: aload_0\n 32: getfield #29 // Field maxY:I\n 35: istore 4\n 37: aload_0\n 38: lload_1\n 39: aload_3\n 40: iload 4\n 42: invokevirtual #50 // Method copy:(JLjava/util/Set;I)LDay17Kt$main$State;\n 45: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #54 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #55 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #57 // String State(stoppedRocksCount=\n 9: invokevirtual #61 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #22 // Field stoppedRocksCount:J\n 16: invokevirtual #64 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 19: ldc #66 // String , ground=\n 21: invokevirtual #61 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #25 // Field ground:Ljava/util/Set;\n 28: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: ldc #71 // String , maxY=\n 33: invokevirtual #61 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #29 // Field maxY:I\n 40: invokevirtual #74 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #77 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #79 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 51: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #22 // Field stoppedRocksCount:J\n 4: invokestatic #85 // Method java/lang/Long.hashCode:(J)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 ground:Ljava/util/Set;\n 16: invokevirtual #87 // Method java/lang/Object.hashCode:()I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: bipush 31\n 24: imul\n 25: aload_0\n 26: getfield #29 // Field maxY:I\n 29: invokestatic #92 // 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 Day17Kt$main$State\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day17Kt$main$State\n 20: astore_2\n 21: aload_0\n 22: getfield #22 // Field stoppedRocksCount:J\n 25: aload_2\n 26: getfield #22 // Field stoppedRocksCount:J\n 29: lcmp\n 30: ifeq 35\n 33: iconst_0\n 34: ireturn\n 35: aload_0\n 36: getfield #25 // Field ground:Ljava/util/Set;\n 39: aload_2\n 40: getfield #25 // Field ground:Ljava/util/Set;\n 43: invokestatic #99 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 46: ifne 51\n 49: iconst_0\n 50: ireturn\n 51: aload_0\n 52: getfield #29 // Field maxY:I\n 55: aload_2\n 56: getfield #29 // Field maxY:I\n 59: if_icmpeq 64\n 62: iconst_0\n 63: ireturn\n 64: iconst_1\n 65: ireturn\n}\n",
"javap_err": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day07.kt
|
import java.math.BigInteger
enum class NodeType { File, Dir }
class Node(val parent: Node?, val children: MutableMap<String, Node>, val alias: String, val size: BigInteger?, val type: NodeType) {
var totalSize = BigInteger.ZERO
fun getRoot(): Node {
var currentNode = this
while (currentNode.parent != null) {
currentNode = currentNode.parent!!
}
return currentNode
}
fun calculateTotalSize(): BigInteger {
if (type == NodeType.File) {
totalSize = size!!
return totalSize
}
totalSize = children.values.sumOf { it.calculateTotalSize() }
return totalSize
}
fun sumBy(threshold: BigInteger): BigInteger {
var result = BigInteger.ZERO
if (type == NodeType.Dir && totalSize <= threshold) {
result += totalSize
}
return result + children.values.sumOf { it.sumBy(threshold) }
}
fun printNode() {
printNode(0)
}
fun printNode(indentLevel: Int) {
val indent = (0..indentLevel).map { ' ' }.joinToString("")
val typeMsg = if (type == NodeType.Dir) "dir" else "file, size=$size"
println("$indent- $alias ($typeMsg)")
children.values.forEach { it.printNode(indentLevel + 2) }
}
fun getDirSizes(): List<BigInteger> {
val result = mutableListOf(totalSize)
result.addAll(children.values.flatMap { it.getDirSizes() })
return result
}
}
fun main() {
fun ensureDirExists(node: Node, alias: String) {
if (node.children[alias] == null) {
node.children[alias] = Node(node, mutableMapOf(), alias, null, NodeType.Dir)
}
}
fun ensureFileExists(node: Node, alias: String, size: BigInteger) {
if (node.children[alias] == null) {
node.children[alias] = Node(node, mutableMapOf(), alias, size, NodeType.File)
}
}
fun parse(input: List<String>): Node {
val root = Node(null, mutableMapOf(), "/", null, NodeType.Dir)
var pointer = root
var lineIdx = 0
val totalSize = input.size
while (lineIdx < totalSize) {
val line = input[lineIdx]
println("Command: $line")
if (line == "$ cd /") {
pointer = pointer.getRoot()
++lineIdx
} else if (line == "$ cd ..") {
pointer = pointer.parent!!
++lineIdx
} else if (line.startsWith("$ cd")) {
val dirAlias = line.split(' ')[2]
ensureDirExists(pointer, dirAlias)
pointer = pointer.children[dirAlias]!!
++lineIdx
} else if (line == "$ ls") {
var listIdx = lineIdx + 1
while (listIdx < totalSize && !input[listIdx].startsWith("$")) {
val node = input[listIdx]
if (node.startsWith("dir")) {
val dirAlias = node.split(' ')[1]
ensureDirExists(pointer, dirAlias)
} else {
val parts = node.split(' ')
val size = parts[0].toBigInteger()
val fileAlias = parts[1]
ensureFileExists(pointer, fileAlias, size)
}
++listIdx
}
lineIdx = listIdx
} else {
println("Unexpected line: $line")
return root
}
println("Root")
root.printNode()
println()
}
return root
}
fun part1(input: List<String>): BigInteger {
val root = parse(input)
root.calculateTotalSize()
return root.sumBy(BigInteger.valueOf(100000))
}
fun part2(input: List<String>): BigInteger {
val root = parse(input)
root.calculateTotalSize()
val threshold = root.totalSize - BigInteger.valueOf(40000000)
return root.getDirSizes().filter { it >= threshold }.min()
}
val testInput = readInput("Day07_test")
assert(part1(testInput), BigInteger.valueOf(95437L))
val input = readInput("Day07")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day07Kt.class",
"javap": "Compiled from \"Day07.kt\"\npublic final class Day07Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day07_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;)Ljava/math/BigInteger;\n 10: ldc2_w #19 // long 95437l\n 13: invokestatic #26 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 16: invokestatic #30 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 19: ldc #32 // String Day07\n 21: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 24: astore_1\n 25: aload_1\n 26: invokestatic #18 // Method main$part1:(Ljava/util/List;)Ljava/math/BigInteger;\n 29: getstatic #38 // Field java/lang/System.out:Ljava/io/PrintStream;\n 32: swap\n 33: invokevirtual #44 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 36: aload_1\n 37: invokestatic #47 // Method main$part2:(Ljava/util/List;)Ljava/math/BigInteger;\n 40: getstatic #38 // Field java/lang/System.out:Ljava/io/PrintStream;\n 43: swap\n 44: invokevirtual #44 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 47: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #53 // Method main:()V\n 3: return\n\n private static final void main$ensureDirExists(Node, java.lang.String);\n Code:\n 0: aload_0\n 1: invokevirtual #63 // Method Node.getChildren:()Ljava/util/Map;\n 4: aload_1\n 5: invokeinterface #69, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 10: ifnonnull 47\n 13: aload_0\n 14: invokevirtual #63 // Method Node.getChildren:()Ljava/util/Map;\n 17: aload_1\n 18: new #59 // class Node\n 21: dup\n 22: aload_0\n 23: new #71 // class java/util/LinkedHashMap\n 26: dup\n 27: invokespecial #74 // Method java/util/LinkedHashMap.\"<init>\":()V\n 30: checkcast #65 // class java/util/Map\n 33: aload_1\n 34: aconst_null\n 35: getstatic #80 // Field NodeType.Dir:LNodeType;\n 38: invokespecial #83 // Method Node.\"<init>\":(LNode;Ljava/util/Map;Ljava/lang/String;Ljava/math/BigInteger;LNodeType;)V\n 41: invokeinterface #87, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 46: pop\n 47: return\n\n private static final void main$ensureFileExists(Node, java.lang.String, java.math.BigInteger);\n Code:\n 0: aload_0\n 1: invokevirtual #63 // Method Node.getChildren:()Ljava/util/Map;\n 4: aload_1\n 5: invokeinterface #69, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 10: ifnonnull 47\n 13: aload_0\n 14: invokevirtual #63 // Method Node.getChildren:()Ljava/util/Map;\n 17: aload_1\n 18: new #59 // class Node\n 21: dup\n 22: aload_0\n 23: new #71 // class java/util/LinkedHashMap\n 26: dup\n 27: invokespecial #74 // Method java/util/LinkedHashMap.\"<init>\":()V\n 30: checkcast #65 // class java/util/Map\n 33: aload_1\n 34: aload_2\n 35: getstatic #96 // Field NodeType.File:LNodeType;\n 38: invokespecial #83 // Method Node.\"<init>\":(LNode;Ljava/util/Map;Ljava/lang/String;Ljava/math/BigInteger;LNodeType;)V\n 41: invokeinterface #87, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 46: pop\n 47: return\n\n private static final Node main$parse(java.util.List<java.lang.String>);\n Code:\n 0: new #59 // class Node\n 3: dup\n 4: aconst_null\n 5: new #71 // class java/util/LinkedHashMap\n 8: dup\n 9: invokespecial #74 // Method java/util/LinkedHashMap.\"<init>\":()V\n 12: checkcast #65 // class java/util/Map\n 15: ldc #103 // String /\n 17: aconst_null\n 18: getstatic #80 // Field NodeType.Dir:LNodeType;\n 21: invokespecial #83 // Method Node.\"<init>\":(LNode;Ljava/util/Map;Ljava/lang/String;Ljava/math/BigInteger;LNodeType;)V\n 24: astore_1\n 25: aload_1\n 26: astore_2\n 27: iconst_0\n 28: istore_3\n 29: aload_0\n 30: invokeinterface #108, 1 // InterfaceMethod java/util/List.size:()I\n 35: istore 4\n 37: iload_3\n 38: iload 4\n 40: if_icmpge 463\n 43: aload_0\n 44: iload_3\n 45: invokeinterface #111, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 50: checkcast #113 // class java/lang/String\n 53: astore 5\n 55: new #115 // class java/lang/StringBuilder\n 58: dup\n 59: invokespecial #116 // Method java/lang/StringBuilder.\"<init>\":()V\n 62: ldc #118 // String Command:\n 64: invokevirtual #122 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 67: aload 5\n 69: invokevirtual #122 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 72: invokevirtual #126 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 75: getstatic #38 // Field java/lang/System.out:Ljava/io/PrintStream;\n 78: swap\n 79: invokevirtual #44 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 82: aload 5\n 84: ldc #128 // String $ cd /\n 86: invokestatic #134 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 89: ifeq 105\n 92: aload_2\n 93: invokevirtual #138 // Method Node.getRoot:()LNode;\n 96: astore_2\n 97: iinc 3, 1\n 100: iload_3\n 101: pop\n 102: goto 441\n 105: aload 5\n 107: ldc #140 // String $ cd ..\n 109: invokestatic #134 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 112: ifeq 132\n 115: aload_2\n 116: invokevirtual #143 // Method Node.getParent:()LNode;\n 119: dup\n 120: invokestatic #146 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 123: astore_2\n 124: iinc 3, 1\n 127: iload_3\n 128: pop\n 129: goto 441\n 132: aload 5\n 134: ldc #148 // String $ cd\n 136: iconst_0\n 137: iconst_2\n 138: aconst_null\n 139: invokestatic #154 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 142: ifeq 215\n 145: aload 5\n 147: checkcast #156 // class java/lang/CharSequence\n 150: iconst_1\n 151: newarray char\n 153: astore 7\n 155: aload 7\n 157: iconst_0\n 158: bipush 32\n 160: castore\n 161: aload 7\n 163: iconst_0\n 164: iconst_0\n 165: bipush 6\n 167: aconst_null\n 168: invokestatic #160 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 171: iconst_2\n 172: invokeinterface #111, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 177: checkcast #113 // class java/lang/String\n 180: astore 6\n 182: aload_2\n 183: aload 6\n 185: invokestatic #162 // Method main$ensureDirExists:(LNode;Ljava/lang/String;)V\n 188: aload_2\n 189: invokevirtual #63 // Method Node.getChildren:()Ljava/util/Map;\n 192: aload 6\n 194: invokeinterface #69, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 199: dup\n 200: invokestatic #146 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 203: checkcast #59 // class Node\n 206: astore_2\n 207: iinc 3, 1\n 210: iload_3\n 211: pop\n 212: goto 441\n 215: aload 5\n 217: ldc #164 // String $ ls\n 219: invokestatic #134 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 222: ifeq 412\n 225: iload_3\n 226: iconst_1\n 227: iadd\n 228: istore 6\n 230: iload 6\n 232: iload 4\n 234: if_icmpge 406\n 237: aload_0\n 238: iload 6\n 240: invokeinterface #111, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 245: checkcast #113 // class java/lang/String\n 248: ldc #166 // String $\n 250: iconst_0\n 251: iconst_2\n 252: aconst_null\n 253: invokestatic #154 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 256: ifne 406\n 259: aload_0\n 260: iload 6\n 262: invokeinterface #111, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 267: checkcast #113 // class java/lang/String\n 270: astore 7\n 272: aload 7\n 274: ldc #168 // String dir\n 276: iconst_0\n 277: iconst_2\n 278: aconst_null\n 279: invokestatic #154 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 282: ifeq 331\n 285: aload 7\n 287: checkcast #156 // class java/lang/CharSequence\n 290: iconst_1\n 291: newarray char\n 293: astore 9\n 295: aload 9\n 297: iconst_0\n 298: bipush 32\n 300: castore\n 301: aload 9\n 303: iconst_0\n 304: iconst_0\n 305: bipush 6\n 307: aconst_null\n 308: invokestatic #160 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 311: iconst_1\n 312: invokeinterface #111, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 317: checkcast #113 // class java/lang/String\n 320: astore 8\n 322: aload_2\n 323: aload 8\n 325: invokestatic #162 // Method main$ensureDirExists:(LNode;Ljava/lang/String;)V\n 328: goto 400\n 331: aload 7\n 333: checkcast #156 // class java/lang/CharSequence\n 336: iconst_1\n 337: newarray char\n 339: astore 9\n 341: aload 9\n 343: iconst_0\n 344: bipush 32\n 346: castore\n 347: aload 9\n 349: iconst_0\n 350: iconst_0\n 351: bipush 6\n 353: aconst_null\n 354: invokestatic #160 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 357: astore 8\n 359: new #22 // class java/math/BigInteger\n 362: dup\n 363: aload 8\n 365: iconst_0\n 366: invokeinterface #111, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 371: checkcast #113 // class java/lang/String\n 374: invokespecial #171 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;)V\n 377: astore 9\n 379: aload 8\n 381: iconst_1\n 382: invokeinterface #111, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 387: checkcast #113 // class java/lang/String\n 390: astore 10\n 392: aload_2\n 393: aload 10\n 395: aload 9\n 397: invokestatic #173 // Method main$ensureFileExists:(LNode;Ljava/lang/String;Ljava/math/BigInteger;)V\n 400: iinc 6, 1\n 403: goto 230\n 406: iload 6\n 408: istore_3\n 409: goto 441\n 412: new #115 // class java/lang/StringBuilder\n 415: dup\n 416: invokespecial #116 // Method java/lang/StringBuilder.\"<init>\":()V\n 419: ldc #175 // String Unexpected line:\n 421: invokevirtual #122 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 424: aload 5\n 426: invokevirtual #122 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 429: invokevirtual #126 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 432: getstatic #38 // Field java/lang/System.out:Ljava/io/PrintStream;\n 435: swap\n 436: invokevirtual #44 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 439: aload_1\n 440: areturn\n 441: ldc #177 // String Root\n 443: getstatic #38 // Field java/lang/System.out:Ljava/io/PrintStream;\n 446: swap\n 447: invokevirtual #44 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 450: aload_1\n 451: invokevirtual #180 // Method Node.printNode:()V\n 454: getstatic #38 // Field java/lang/System.out:Ljava/io/PrintStream;\n 457: invokevirtual #182 // Method java/io/PrintStream.println:()V\n 460: goto 37\n 463: aload_1\n 464: areturn\n\n private static final java.math.BigInteger main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #195 // Method main$parse:(Ljava/util/List;)LNode;\n 4: astore_1\n 5: aload_1\n 6: invokevirtual #199 // Method Node.calculateTotalSize:()Ljava/math/BigInteger;\n 9: pop\n 10: aload_1\n 11: ldc2_w #200 // long 100000l\n 14: invokestatic #26 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 17: dup\n 18: ldc #203 // String valueOf(...)\n 20: invokestatic #207 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 23: invokevirtual #211 // Method Node.sumBy:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 26: areturn\n\n private static final java.math.BigInteger main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #195 // Method main$parse:(Ljava/util/List;)LNode;\n 4: astore_1\n 5: aload_1\n 6: invokevirtual #199 // Method Node.calculateTotalSize:()Ljava/math/BigInteger;\n 9: pop\n 10: aload_1\n 11: invokevirtual #214 // Method Node.getTotalSize:()Ljava/math/BigInteger;\n 14: dup\n 15: ldc #216 // String <get-totalSize>(...)\n 17: invokestatic #207 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 20: astore_3\n 21: ldc2_w #217 // long 40000000l\n 24: invokestatic #26 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 27: dup\n 28: ldc #203 // String valueOf(...)\n 30: invokestatic #207 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 33: aload_3\n 34: swap\n 35: invokevirtual #221 // Method java/math/BigInteger.subtract:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 38: dup\n 39: ldc #223 // String subtract(...)\n 41: invokestatic #207 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 44: astore_2\n 45: aload_1\n 46: invokevirtual #227 // Method Node.getDirSizes:()Ljava/util/List;\n 49: checkcast #229 // 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 #231 // class java/util/ArrayList\n 62: dup\n 63: invokespecial #232 // Method java/util/ArrayList.\"<init>\":()V\n 66: checkcast #234 // class java/util/Collection\n 69: astore 6\n 71: iconst_0\n 72: istore 7\n 74: aload 5\n 76: invokeinterface #238, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 81: astore 8\n 83: aload 8\n 85: invokeinterface #244, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 90: ifeq 142\n 93: aload 8\n 95: invokeinterface #248, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 100: astore 9\n 102: aload 9\n 104: checkcast #22 // class java/math/BigInteger\n 107: astore 10\n 109: iconst_0\n 110: istore 11\n 112: aload 10\n 114: aload_2\n 115: invokevirtual #252 // Method java/math/BigInteger.compareTo:(Ljava/math/BigInteger;)I\n 118: iflt 125\n 121: iconst_1\n 122: goto 126\n 125: iconst_0\n 126: ifeq 83\n 129: aload 6\n 131: aload 9\n 133: invokeinterface #256, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 138: pop\n 139: goto 83\n 142: aload 6\n 144: checkcast #105 // class java/util/List\n 147: nop\n 148: checkcast #229 // class java/lang/Iterable\n 151: invokestatic #262 // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 154: checkcast #22 // class java/math/BigInteger\n 157: areturn\n}\n",
"javap_err": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day01.kt
|
fun main() {
fun getStructure(input: List<String>): MutableList<List<Int>> {
val result = mutableListOf<List<Int>>()
var bucket = mutableListOf<Int>()
result.add(bucket)
input.forEach { line ->
run {
if (line.isBlank()) {
bucket = mutableListOf()
result.add(bucket)
} else {
bucket.add(line.toInt())
}
}
}
return result
}
fun part1(input: List<String>): Int {
val structure = getStructure(input)
return structure.maxOf { it.sum() }
}
fun part2(input: List<String>): Int {
val structure = getStructure(input)
return structure
.map { it.sum() }
.sortedByDescending { it }
.take(3)
.sumOf { it }
}
val testInput = readInput("Day01_test")
check(part1(testInput) == 24000)
val input = readInput("Day01")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day01Kt$main$part2$$inlined$sortedByDescending$1.class",
"javap": "Compiled from \"Comparisons.kt\"\npublic final class Day01Kt$main$part2$$inlined$sortedByDescending$1<T> implements java.util.Comparator {\n public Day01Kt$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 java/lang/Number\n 4: invokevirtual #27 // Method java/lang/Number.intValue:()I\n 7: istore_3\n 8: iconst_0\n 9: istore 4\n 11: iload_3\n 12: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 15: checkcast #35 // class java/lang/Comparable\n 18: aload_1\n 19: checkcast #23 // class java/lang/Number\n 22: invokevirtual #27 // Method java/lang/Number.intValue:()I\n 25: istore_3\n 26: astore 5\n 28: iconst_0\n 29: istore 4\n 31: iload_3\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": "kipwoker__aoc2022__d8aeea8/Day01Kt.class",
"javap": "Compiled from \"Day01.kt\"\npublic final class Day01Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day01_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 10: sipush 24000\n 13: if_icmpne 20\n 16: iconst_1\n 17: goto 21\n 20: iconst_0\n 21: ifne 34\n 24: new #20 // class java/lang/IllegalStateException\n 27: dup\n 28: ldc #22 // String Check failed.\n 30: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 33: athrow\n 34: ldc #28 // String Day01\n 36: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 39: astore_1\n 40: aload_1\n 41: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 44: istore_2\n 45: getstatic #34 // Field java/lang/System.out:Ljava/io/PrintStream;\n 48: iload_2\n 49: invokevirtual #40 // Method java/io/PrintStream.println:(I)V\n 52: aload_1\n 53: invokestatic #43 // Method main$part2:(Ljava/util/List;)I\n 56: istore_2\n 57: getstatic #34 // Field java/lang/System.out:Ljava/io/PrintStream;\n 60: iload_2\n 61: invokevirtual #40 // Method java/io/PrintStream.println:(I)V\n 64: 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 java.util.List<java.util.List<java.lang.Integer>> main$getStructure(java.util.List<java.lang.String>);\n Code:\n 0: new #58 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #60 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #48 // class java/util/List\n 10: astore_1\n 11: aconst_null\n 12: astore_2\n 13: new #58 // class java/util/ArrayList\n 16: dup\n 17: invokespecial #60 // Method java/util/ArrayList.\"<init>\":()V\n 20: checkcast #48 // class java/util/List\n 23: astore_2\n 24: aload_1\n 25: aload_2\n 26: invokeinterface #64, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 31: pop\n 32: aload_0\n 33: checkcast #66 // class java/lang/Iterable\n 36: astore_3\n 37: iconst_0\n 38: istore 4\n 40: aload_3\n 41: invokeinterface #70, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 46: astore 5\n 48: aload 5\n 50: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 55: ifeq 134\n 58: aload 5\n 60: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 65: astore 6\n 67: aload 6\n 69: checkcast #82 // class java/lang/String\n 72: astore 7\n 74: iconst_0\n 75: istore 8\n 77: iconst_0\n 78: istore 9\n 80: aload 7\n 82: checkcast #84 // class java/lang/CharSequence\n 85: invokestatic #90 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 88: ifeq 112\n 91: new #58 // class java/util/ArrayList\n 94: dup\n 95: invokespecial #60 // Method java/util/ArrayList.\"<init>\":()V\n 98: checkcast #48 // class java/util/List\n 101: astore_2\n 102: aload_1\n 103: aload_2\n 104: invokeinterface #64, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 109: goto 126\n 112: aload_2\n 113: aload 7\n 115: invokestatic #96 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 118: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 121: invokeinterface #64, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 126: pop\n 127: nop\n 128: nop\n 129: nop\n 130: nop\n 131: goto 48\n 134: nop\n 135: aload_1\n 136: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #115 // Method main$getStructure:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: aload_1\n 6: checkcast #66 // class java/lang/Iterable\n 9: invokeinterface #70, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 14: astore_2\n 15: aload_2\n 16: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 21: ifne 32\n 24: new #117 // class java/util/NoSuchElementException\n 27: dup\n 28: invokespecial #118 // Method java/util/NoSuchElementException.\"<init>\":()V\n 31: athrow\n 32: aload_2\n 33: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 38: checkcast #48 // class java/util/List\n 41: astore_3\n 42: iconst_0\n 43: istore 4\n 45: aload_3\n 46: checkcast #66 // class java/lang/Iterable\n 49: invokestatic #124 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 52: istore_3\n 53: aload_2\n 54: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 98\n 62: aload_2\n 63: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 68: checkcast #48 // class java/util/List\n 71: astore 4\n 73: iconst_0\n 74: istore 5\n 76: aload 4\n 78: checkcast #66 // class java/lang/Iterable\n 81: invokestatic #124 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 84: istore 4\n 86: iload_3\n 87: iload 4\n 89: if_icmpge 53\n 92: iload 4\n 94: istore_3\n 95: goto 53\n 98: iload_3\n 99: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #115 // Method main$getStructure:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: aload_1\n 6: checkcast #66 // class java/lang/Iterable\n 9: astore_2\n 10: nop\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: astore 4\n 16: new #58 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: bipush 10\n 23: invokestatic #131 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #133 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #135 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: aload 4\n 39: invokeinterface #70, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 7\n 46: aload 7\n 48: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 102\n 56: aload 7\n 58: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 8\n 65: aload 5\n 67: aload 8\n 69: checkcast #48 // class java/util/List\n 72: astore 9\n 74: astore 11\n 76: iconst_0\n 77: istore 10\n 79: aload 9\n 81: checkcast #66 // class java/lang/Iterable\n 84: invokestatic #124 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 87: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 90: aload 11\n 92: swap\n 93: invokeinterface #136, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 98: pop\n 99: goto 46\n 102: aload 5\n 104: checkcast #48 // class java/util/List\n 107: nop\n 108: checkcast #66 // class java/lang/Iterable\n 111: astore_2\n 112: nop\n 113: iconst_0\n 114: istore_3\n 115: aload_2\n 116: new #138 // class Day01Kt$main$part2$$inlined$sortedByDescending$1\n 119: dup\n 120: invokespecial #139 // Method Day01Kt$main$part2$$inlined$sortedByDescending$1.\"<init>\":()V\n 123: checkcast #141 // class java/util/Comparator\n 126: invokestatic #145 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 129: checkcast #66 // class java/lang/Iterable\n 132: iconst_3\n 133: invokestatic #149 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 136: checkcast #66 // class java/lang/Iterable\n 139: astore_2\n 140: iconst_0\n 141: istore_3\n 142: aload_2\n 143: invokeinterface #70, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 148: astore 4\n 150: aload 4\n 152: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 157: ifeq 198\n 160: aload 4\n 162: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 167: astore 5\n 169: iload_3\n 170: aload 5\n 172: checkcast #151 // class java/lang/Number\n 175: invokevirtual #155 // Method java/lang/Number.intValue:()I\n 178: istore 6\n 180: istore 11\n 182: iconst_0\n 183: istore 7\n 185: iload 6\n 187: istore 12\n 189: iload 11\n 191: iload 12\n 193: iadd\n 194: istore_3\n 195: goto 150\n 198: iload_3\n 199: ireturn\n}\n",
"javap_err": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day06.kt
|
fun main() {
fun getDiffIndex(input: List<String>, diffCount: Int): Int {
val line = input[0].toCharArray()
for (i in 0..line.size - diffCount) {
if (line.slice(i until i + diffCount).toSet().size == diffCount) {
return i + diffCount
}
}
return -1
}
fun part1(input: List<String>): Int {
return getDiffIndex(input, 4)
}
fun part2(input: List<String>): Int {
return getDiffIndex(input, 14)
}
assert(part1(readInput("Day06_test_1")), 7)
assert(part1(readInput("Day06_test_2")), 5)
assert(part1(readInput("Day06_test_3")), 11)
assert(part2(readInput("Day06_test_1")), 19)
assert(part2(readInput("Day06_test_2")), 23)
assert(part2(readInput("Day06_test_3")), 26)
val input = readInput("Day06")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/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_1\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 8: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 11: bipush 7\n 13: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 16: invokestatic #28 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 19: ldc #30 // String Day06_test_2\n 21: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 24: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 27: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 30: iconst_5\n 31: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 34: invokestatic #28 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 37: ldc #32 // String Day06_test_3\n 39: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 42: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 45: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 48: bipush 11\n 50: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 53: invokestatic #28 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 56: ldc #8 // String Day06_test_1\n 58: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 61: invokestatic #35 // Method main$part2:(Ljava/util/List;)I\n 64: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 67: bipush 19\n 69: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 72: invokestatic #28 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 75: ldc #30 // String Day06_test_2\n 77: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 80: invokestatic #35 // Method main$part2:(Ljava/util/List;)I\n 83: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 86: bipush 23\n 88: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 91: invokestatic #28 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 94: ldc #32 // String Day06_test_3\n 96: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 99: invokestatic #35 // Method main$part2:(Ljava/util/List;)I\n 102: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 105: bipush 26\n 107: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 110: invokestatic #28 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 113: ldc #37 // String Day06\n 115: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 118: astore_0\n 119: aload_0\n 120: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 123: istore_1\n 124: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 127: iload_1\n 128: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 131: aload_0\n 132: invokestatic #35 // Method main$part2:(Ljava/util/List;)I\n 135: istore_1\n 136: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 139: iload_1\n 140: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 143: 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$getDiffIndex(java.util.List<java.lang.String>, int);\n Code:\n 0: aload_0\n 1: iconst_0\n 2: invokeinterface #65, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #67 // class java/lang/String\n 10: invokevirtual #71 // Method java/lang/String.toCharArray:()[C\n 13: dup\n 14: ldc #73 // String toCharArray(...)\n 16: invokestatic #79 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 19: astore_2\n 20: iconst_0\n 21: istore_3\n 22: aload_2\n 23: arraylength\n 24: iload_1\n 25: isub\n 26: istore 4\n 28: iload_3\n 29: iload 4\n 31: if_icmpgt 76\n 34: aload_2\n 35: iload_3\n 36: iload_3\n 37: iload_1\n 38: iadd\n 39: invokestatic #85 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 42: invokestatic #91 // Method kotlin/collections/ArraysKt.slice:([CLkotlin/ranges/IntRange;)Ljava/util/List;\n 45: checkcast #93 // class java/lang/Iterable\n 48: invokestatic #99 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 51: invokeinterface #105, 1 // InterfaceMethod java/util/Set.size:()I\n 56: iload_1\n 57: if_icmpne 64\n 60: iload_3\n 61: iload_1\n 62: iadd\n 63: ireturn\n 64: iload_3\n 65: iload 4\n 67: if_icmpeq 76\n 70: iinc 3, 1\n 73: goto 34\n 76: iconst_m1\n 77: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: iconst_4\n 2: invokestatic #114 // Method main$getDiffIndex:(Ljava/util/List;I)I\n 5: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: bipush 14\n 3: invokestatic #114 // Method main$getDiffIndex:(Ljava/util/List;I)I\n 6: ireturn\n}\n",
"javap_err": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day03.kt
|
fun main() {
fun getPriority(ch: Char): Long {
if (ch in 'A'..'Z') {
return ch - 'A' + 27L
}
return ch - 'a' + 1L
}
fun part1(input: List<String>): Long {
return input.sumOf { line ->
line
.chunkedSequence(line.length / 2)
.map { it.toSet() }
.reduce { acc, chars -> acc.intersect(chars) }
.sumOf {
getPriority(it)
}
}
}
fun part2(input: List<String>): Long {
return input
.chunked(3)
.sumOf { group ->
group
.map { it.toSet() }
.reduce { acc, chars -> acc.intersect(chars) }
.sumOf {
getPriority(it)
}
}
}
check(getPriority('a') == 1L)
check(getPriority('z') == 26L)
check(getPriority('A') == 27L)
check(getPriority('Z') == 52L)
val testInput = readInput("Day03_test")
check(part1(testInput) == 157L)
check(part2(testInput) == 70L)
val input = readInput("Day03")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day03Kt.class",
"javap": "Compiled from \"Day03.kt\"\npublic final class Day03Kt {\n public static final void main();\n Code:\n 0: bipush 97\n 2: invokestatic #10 // Method main$getPriority:(C)J\n 5: lconst_1\n 6: lcmp\n 7: ifne 14\n 10: iconst_1\n 11: goto 15\n 14: iconst_0\n 15: ifne 28\n 18: new #12 // class java/lang/IllegalStateException\n 21: dup\n 22: ldc #14 // String Check failed.\n 24: invokespecial #18 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 27: athrow\n 28: bipush 122\n 30: invokestatic #10 // Method main$getPriority:(C)J\n 33: ldc2_w #19 // long 26l\n 36: lcmp\n 37: ifne 44\n 40: iconst_1\n 41: goto 45\n 44: iconst_0\n 45: ifne 58\n 48: new #12 // class java/lang/IllegalStateException\n 51: dup\n 52: ldc #14 // String Check failed.\n 54: invokespecial #18 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 57: athrow\n 58: bipush 65\n 60: invokestatic #10 // Method main$getPriority:(C)J\n 63: ldc2_w #21 // long 27l\n 66: lcmp\n 67: ifne 74\n 70: iconst_1\n 71: goto 75\n 74: iconst_0\n 75: ifne 88\n 78: new #12 // class java/lang/IllegalStateException\n 81: dup\n 82: ldc #14 // String Check failed.\n 84: invokespecial #18 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 87: athrow\n 88: bipush 90\n 90: invokestatic #10 // Method main$getPriority:(C)J\n 93: ldc2_w #23 // long 52l\n 96: lcmp\n 97: ifne 104\n 100: iconst_1\n 101: goto 105\n 104: iconst_0\n 105: ifne 118\n 108: new #12 // class java/lang/IllegalStateException\n 111: dup\n 112: ldc #14 // String Check failed.\n 114: invokespecial #18 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 117: athrow\n 118: ldc #26 // String Day03_test\n 120: invokestatic #32 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 123: astore_0\n 124: aload_0\n 125: invokestatic #36 // Method main$part1:(Ljava/util/List;)J\n 128: ldc2_w #37 // long 157l\n 131: lcmp\n 132: ifne 139\n 135: iconst_1\n 136: goto 140\n 139: iconst_0\n 140: ifne 153\n 143: new #12 // class java/lang/IllegalStateException\n 146: dup\n 147: ldc #14 // String Check failed.\n 149: invokespecial #18 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 152: athrow\n 153: aload_0\n 154: invokestatic #41 // Method main$part2:(Ljava/util/List;)J\n 157: ldc2_w #42 // long 70l\n 160: lcmp\n 161: ifne 168\n 164: iconst_1\n 165: goto 169\n 168: iconst_0\n 169: ifne 182\n 172: new #12 // class java/lang/IllegalStateException\n 175: dup\n 176: ldc #14 // String Check failed.\n 178: invokespecial #18 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 181: athrow\n 182: ldc #45 // String Day03\n 184: invokestatic #32 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 187: astore_1\n 188: aload_1\n 189: invokestatic #36 // Method main$part1:(Ljava/util/List;)J\n 192: lstore_2\n 193: getstatic #51 // Field java/lang/System.out:Ljava/io/PrintStream;\n 196: lload_2\n 197: invokevirtual #57 // Method java/io/PrintStream.println:(J)V\n 200: aload_1\n 201: invokestatic #41 // Method main$part2:(Ljava/util/List;)J\n 204: lstore_2\n 205: getstatic #51 // Field java/lang/System.out:Ljava/io/PrintStream;\n 208: lload_2\n 209: invokevirtual #57 // Method java/io/PrintStream.println:(J)V\n 212: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #65 // Method main:()V\n 3: return\n\n private static final long main$getPriority(char);\n Code:\n 0: bipush 65\n 2: iload_0\n 3: if_icmpgt 20\n 6: iload_0\n 7: bipush 91\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: ifeq 34\n 24: iload_0\n 25: bipush 65\n 27: isub\n 28: i2l\n 29: ldc2_w #21 // long 27l\n 32: ladd\n 33: lreturn\n 34: iload_0\n 35: bipush 97\n 37: isub\n 38: i2l\n 39: lconst_1\n 40: ladd\n 41: lreturn\n\n private static final java.util.Set main$part1$lambda$3$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #73 // String it\n 3: invokestatic #79 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #81 // class java/lang/CharSequence\n 10: invokestatic #87 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 13: areturn\n\n private static final long main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #91 // class java/lang/Iterable\n 4: astore_1\n 5: lconst_0\n 6: lstore_2\n 7: aload_1\n 8: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore 4\n 15: aload 4\n 17: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 22: ifeq 250\n 25: aload 4\n 27: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 32: astore 5\n 34: lload_2\n 35: aload 5\n 37: checkcast #107 // class java/lang/String\n 40: astore 6\n 42: lstore 21\n 44: iconst_0\n 45: istore 7\n 47: aload 6\n 49: checkcast #81 // class java/lang/CharSequence\n 52: aload 6\n 54: invokevirtual #111 // Method java/lang/String.length:()I\n 57: iconst_2\n 58: idiv\n 59: invokestatic #115 // Method kotlin/text/StringsKt.chunkedSequence:(Ljava/lang/CharSequence;I)Lkotlin/sequences/Sequence;\n 62: invokedynamic #132, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 67: invokestatic #138 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 70: astore 8\n 72: nop\n 73: iconst_0\n 74: istore 9\n 76: aload 8\n 78: invokeinterface #141, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 83: astore 10\n 85: aload 10\n 87: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 92: ifne 105\n 95: new #143 // class java/lang/UnsupportedOperationException\n 98: dup\n 99: ldc #145 // String Empty sequence can\\'t be reduced.\n 101: invokespecial #146 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 104: athrow\n 105: aload 10\n 107: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 112: astore 11\n 114: aload 10\n 116: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 121: ifeq 164\n 124: aload 11\n 126: aload 10\n 128: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 133: checkcast #148 // class java/util/Set\n 136: astore 12\n 138: checkcast #148 // class java/util/Set\n 141: astore 13\n 143: iconst_0\n 144: istore 14\n 146: aload 13\n 148: checkcast #91 // class java/lang/Iterable\n 151: aload 12\n 153: checkcast #91 // class java/lang/Iterable\n 156: invokestatic #154 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 159: astore 11\n 161: goto 114\n 164: aload 11\n 166: checkcast #91 // class java/lang/Iterable\n 169: astore 8\n 171: lconst_0\n 172: lstore 15\n 174: aload 8\n 176: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 181: astore 11\n 183: aload 11\n 185: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 190: ifeq 236\n 193: aload 11\n 195: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 200: astore 12\n 202: lload 15\n 204: aload 12\n 206: checkcast #156 // class java/lang/Character\n 209: invokevirtual #160 // Method java/lang/Character.charValue:()C\n 212: istore 13\n 214: lstore 17\n 216: iconst_0\n 217: istore 14\n 219: iload 13\n 221: invokestatic #10 // Method main$getPriority:(C)J\n 224: lstore 19\n 226: lload 17\n 228: lload 19\n 230: ladd\n 231: lstore 15\n 233: goto 183\n 236: lload 15\n 238: nop\n 239: lstore 23\n 241: lload 21\n 243: lload 23\n 245: ladd\n 246: lstore_2\n 247: goto 15\n 250: lload_2\n 251: lreturn\n\n private static final long main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #91 // class java/lang/Iterable\n 4: iconst_3\n 5: invokestatic #179 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;\n 8: checkcast #91 // class java/lang/Iterable\n 11: astore_1\n 12: lconst_0\n 13: lstore_2\n 14: aload_1\n 15: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 20: astore 4\n 22: aload 4\n 24: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 29: ifeq 342\n 32: aload 4\n 34: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 39: astore 5\n 41: lload_2\n 42: aload 5\n 44: checkcast #62 // class java/util/List\n 47: astore 6\n 49: lstore 24\n 51: iconst_0\n 52: istore 7\n 54: aload 6\n 56: checkcast #91 // class java/lang/Iterable\n 59: astore 8\n 61: nop\n 62: iconst_0\n 63: istore 9\n 65: aload 8\n 67: astore 10\n 69: new #181 // class java/util/ArrayList\n 72: dup\n 73: aload 8\n 75: bipush 10\n 77: invokestatic #185 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 80: invokespecial #188 // Method java/util/ArrayList.\"<init>\":(I)V\n 83: checkcast #190 // class java/util/Collection\n 86: astore 11\n 88: iconst_0\n 89: istore 12\n 91: aload 10\n 93: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 98: astore 13\n 100: aload 13\n 102: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 107: ifeq 153\n 110: aload 13\n 112: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 117: astore 14\n 119: aload 11\n 121: aload 14\n 123: checkcast #107 // class java/lang/String\n 126: astore 15\n 128: astore 16\n 130: iconst_0\n 131: istore 17\n 133: aload 15\n 135: checkcast #81 // class java/lang/CharSequence\n 138: invokestatic #87 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 141: aload 16\n 143: swap\n 144: invokeinterface #194, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 149: pop\n 150: goto 100\n 153: aload 11\n 155: checkcast #62 // class java/util/List\n 158: nop\n 159: checkcast #91 // class java/lang/Iterable\n 162: astore 8\n 164: nop\n 165: iconst_0\n 166: istore 9\n 168: aload 8\n 170: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 175: astore 10\n 177: aload 10\n 179: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 184: ifne 197\n 187: new #143 // class java/lang/UnsupportedOperationException\n 190: dup\n 191: ldc #196 // String Empty collection can\\'t be reduced.\n 193: invokespecial #146 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 196: athrow\n 197: aload 10\n 199: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 204: astore 11\n 206: aload 10\n 208: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 213: ifeq 256\n 216: aload 11\n 218: aload 10\n 220: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 225: checkcast #148 // class java/util/Set\n 228: astore 12\n 230: checkcast #148 // class java/util/Set\n 233: astore 13\n 235: iconst_0\n 236: istore 14\n 238: aload 13\n 240: checkcast #91 // class java/lang/Iterable\n 243: aload 12\n 245: checkcast #91 // class java/lang/Iterable\n 248: invokestatic #154 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 251: astore 11\n 253: goto 206\n 256: aload 11\n 258: checkcast #91 // class java/lang/Iterable\n 261: astore 8\n 263: lconst_0\n 264: lstore 18\n 266: aload 8\n 268: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 273: astore 11\n 275: aload 11\n 277: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 282: ifeq 328\n 285: aload 11\n 287: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 292: astore 12\n 294: lload 18\n 296: aload 12\n 298: checkcast #156 // class java/lang/Character\n 301: invokevirtual #160 // Method java/lang/Character.charValue:()C\n 304: istore 13\n 306: lstore 20\n 308: iconst_0\n 309: istore 14\n 311: iload 13\n 313: invokestatic #10 // Method main$getPriority:(C)J\n 316: lstore 22\n 318: lload 20\n 320: lload 22\n 322: ladd\n 323: lstore 18\n 325: goto 275\n 328: lload 18\n 330: nop\n 331: lstore 26\n 333: lload 24\n 335: lload 26\n 337: ladd\n 338: lstore_2\n 339: goto 22\n 342: lload_2\n 343: lreturn\n}\n",
"javap_err": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day09.kt
|
import kotlin.math.abs
class Command(val direction: Direction, val count: Int)
fun main() {
fun parse(input: List<String>): List<Command> {
return input.map { line ->
val parts = line.split(' ')
val direction = when (parts[0]) {
"U" -> Direction.Up
"D" -> Direction.Down
"L" -> Direction.Left
"R" -> Direction.Right
else -> throw RuntimeException()
}
Command(direction, parts[1].toInt())
}
}
fun move(point: Point, direction: Direction): Point {
return when (direction) {
Direction.Up -> Point(point.x, point.y + 1)
Direction.Down -> Point(point.x, point.y - 1)
Direction.Left -> Point(point.x - 1, point.y)
Direction.Right -> Point(point.x + 1, point.y)
}
}
fun isTouching(head: Point, tail: Point): Boolean {
return abs(head.x - tail.x) <= 1 && abs(head.y - tail.y) <= 1
}
fun getDelta(head: Int, tail: Int): Int {
if (head == tail) {
return 0
}
if (head > tail) {
return 1
}
return -1
}
fun tryMoveTail(head: Point, tail: Point): Point {
if (isTouching(head, tail)) {
return tail
}
val dx = getDelta(head.x, tail.x)
val dy = getDelta(head.y, tail.y)
return Point(tail.x + dx, tail.y + dy)
}
fun traverse(commands: List<Command>, totalSize: Int): Int {
val visited = mutableSetOf<Point>()
var head = Point(0, 0)
val size = totalSize - 2
val middle = (1..size).map { Point(0, 0) }.toMutableList()
var tail = Point(0, 0)
visited.add(tail)
for (command in commands) {
for (i in 1..command.count) {
head = move(head, command.direction)
var pointer = head
for (j in 0 until size) {
middle[j] = tryMoveTail(pointer, middle[j])
pointer = middle[j]
}
tail = tryMoveTail(pointer, tail)
visited.add(tail)
}
}
return visited.count()
}
fun part1(input: List<String>): Int {
val commands = parse(input)
return traverse(commands, 2)
}
fun part2(input: List<String>): Int {
val commands = parse(input)
return traverse(commands, 10)
}
val testInput = readInput("Day09_test")
assert(part1(testInput), 13)
assert(part2(testInput), 1)
val input = readInput("Day09")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day09Kt$WhenMappings.class",
"javap": "Compiled from \"Day09.kt\"\npublic final class Day09Kt$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method Direction.values:()[LDirection;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field Direction.Up:LDirection;\n 12: invokevirtual #22 // Method Direction.ordinal:()I\n 15: iconst_1\n 16: iastore\n 17: goto 21\n 20: astore_1\n 21: nop\n 22: aload_0\n 23: getstatic #25 // Field Direction.Down:LDirection;\n 26: invokevirtual #22 // Method Direction.ordinal:()I\n 29: iconst_2\n 30: iastore\n 31: goto 35\n 34: astore_1\n 35: nop\n 36: aload_0\n 37: getstatic #28 // Field Direction.Left:LDirection;\n 40: invokevirtual #22 // Method Direction.ordinal:()I\n 43: iconst_3\n 44: iastore\n 45: goto 49\n 48: astore_1\n 49: nop\n 50: aload_0\n 51: getstatic #31 // Field Direction.Right:LDirection;\n 54: invokevirtual #22 // Method Direction.ordinal:()I\n 57: iconst_4\n 58: iastore\n 59: goto 63\n 62: astore_1\n 63: aload_0\n 64: putstatic #35 // Field $EnumSwitchMapping$0:[I\n 67: return\n Exception table:\n from to target type\n 7 17 20 Class java/lang/NoSuchFieldError\n 21 31 34 Class java/lang/NoSuchFieldError\n 35 45 48 Class java/lang/NoSuchFieldError\n 49 59 62 Class java/lang/NoSuchFieldError\n}\n",
"javap_err": ""
},
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day09Kt.class",
"javap": "Compiled from \"Day09.kt\"\npublic final class Day09Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day09_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: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 13: bipush 13\n 15: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 18: invokestatic #28 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 21: aload_0\n 22: invokestatic #31 // Method main$part2:(Ljava/util/List;)I\n 25: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 28: iconst_1\n 29: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 32: invokestatic #28 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 35: ldc #33 // String Day09\n 37: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 40: astore_1\n 41: aload_1\n 42: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 45: istore_2\n 46: getstatic #39 // Field java/lang/System.out:Ljava/io/PrintStream;\n 49: iload_2\n 50: invokevirtual #45 // Method java/io/PrintStream.println:(I)V\n 53: aload_1\n 54: invokestatic #31 // Method main$part2:(Ljava/util/List;)I\n 57: istore_2\n 58: getstatic #39 // Field java/lang/System.out:Ljava/io/PrintStream;\n 61: iload_2\n 62: invokevirtual #45 // Method java/io/PrintStream.println:(I)V\n 65: 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 java.util.List<Command> main$parse(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #58 // 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 #60 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #66 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #69 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #71 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 281\n 48: aload 6\n 50: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #87 // class java/lang/String\n 64: astore 8\n 66: astore 13\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: checkcast #89 // class java/lang/CharSequence\n 76: iconst_1\n 77: newarray char\n 79: astore 10\n 81: aload 10\n 83: iconst_0\n 84: bipush 32\n 86: castore\n 87: aload 10\n 89: iconst_0\n 90: iconst_0\n 91: bipush 6\n 93: aconst_null\n 94: invokestatic #95 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 97: astore 11\n 99: aload 11\n 101: iconst_0\n 102: invokeinterface #101, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 107: checkcast #87 // class java/lang/String\n 110: astore 12\n 112: aload 12\n 114: invokevirtual #105 // Method java/lang/String.hashCode:()I\n 117: lookupswitch { // 4\n 68: 173\n 76: 199\n 82: 160\n 85: 186\n default: 236\n }\n 160: aload 12\n 162: ldc #107 // String R\n 164: invokevirtual #111 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 167: ifne 230\n 170: goto 236\n 173: aload 12\n 175: ldc #113 // String D\n 177: invokevirtual #111 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 180: ifne 218\n 183: goto 236\n 186: aload 12\n 188: ldc #115 // String U\n 190: invokevirtual #111 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 193: ifne 212\n 196: goto 236\n 199: aload 12\n 201: ldc #117 // String L\n 203: invokevirtual #111 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 206: ifne 224\n 209: goto 236\n 212: getstatic #123 // Field Direction.Up:LDirection;\n 215: goto 244\n 218: getstatic #126 // Field Direction.Down:LDirection;\n 221: goto 244\n 224: getstatic #129 // Field Direction.Left:LDirection;\n 227: goto 244\n 230: getstatic #132 // Field Direction.Right:LDirection;\n 233: goto 244\n 236: new #134 // class java/lang/RuntimeException\n 239: dup\n 240: invokespecial #136 // Method java/lang/RuntimeException.\"<init>\":()V\n 243: athrow\n 244: astore 10\n 246: new #138 // class Command\n 249: dup\n 250: aload 10\n 252: aload 11\n 254: iconst_1\n 255: invokeinterface #101, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 260: checkcast #87 // class java/lang/String\n 263: invokestatic #142 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 266: invokespecial #145 // Method Command.\"<init>\":(LDirection;I)V\n 269: aload 13\n 271: swap\n 272: invokeinterface #148, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 277: pop\n 278: goto 38\n 281: aload 4\n 283: checkcast #97 // class java/util/List\n 286: nop\n 287: areturn\n\n private static final Point main$move(Point, Direction);\n Code:\n 0: aload_1\n 1: getstatic #173 // Field Day09Kt$WhenMappings.$EnumSwitchMapping$0:[I\n 4: swap\n 5: invokevirtual #176 // Method Direction.ordinal:()I\n 8: iaload\n 9: tableswitch { // 1 to 4\n 1: 40\n 2: 60\n 3: 80\n 4: 100\n default: 120\n }\n 40: new #178 // class Point\n 43: dup\n 44: aload_0\n 45: invokevirtual #181 // Method Point.getX:()I\n 48: aload_0\n 49: invokevirtual #184 // Method Point.getY:()I\n 52: iconst_1\n 53: iadd\n 54: invokespecial #187 // Method Point.\"<init>\":(II)V\n 57: goto 128\n 60: new #178 // class Point\n 63: dup\n 64: aload_0\n 65: invokevirtual #181 // Method Point.getX:()I\n 68: aload_0\n 69: invokevirtual #184 // Method Point.getY:()I\n 72: iconst_1\n 73: isub\n 74: invokespecial #187 // Method Point.\"<init>\":(II)V\n 77: goto 128\n 80: new #178 // class Point\n 83: dup\n 84: aload_0\n 85: invokevirtual #181 // Method Point.getX:()I\n 88: iconst_1\n 89: isub\n 90: aload_0\n 91: invokevirtual #184 // Method Point.getY:()I\n 94: invokespecial #187 // Method Point.\"<init>\":(II)V\n 97: goto 128\n 100: new #178 // class Point\n 103: dup\n 104: aload_0\n 105: invokevirtual #181 // Method Point.getX:()I\n 108: iconst_1\n 109: iadd\n 110: aload_0\n 111: invokevirtual #184 // Method Point.getY:()I\n 114: invokespecial #187 // Method Point.\"<init>\":(II)V\n 117: goto 128\n 120: new #189 // class kotlin/NoWhenBranchMatchedException\n 123: dup\n 124: invokespecial #190 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 127: athrow\n 128: areturn\n\n private static final boolean main$isTouching(Point, Point);\n Code:\n 0: aload_0\n 1: invokevirtual #181 // Method Point.getX:()I\n 4: aload_1\n 5: invokevirtual #181 // Method Point.getX:()I\n 8: isub\n 9: invokestatic #200 // Method java/lang/Math.abs:(I)I\n 12: iconst_1\n 13: if_icmpgt 36\n 16: aload_0\n 17: invokevirtual #184 // Method Point.getY:()I\n 20: aload_1\n 21: invokevirtual #184 // Method Point.getY:()I\n 24: isub\n 25: invokestatic #200 // Method java/lang/Math.abs:(I)I\n 28: iconst_1\n 29: if_icmpgt 36\n 32: iconst_1\n 33: goto 37\n 36: iconst_0\n 37: ireturn\n\n private static final int main$getDelta(int, int);\n Code:\n 0: iload_0\n 1: iload_1\n 2: if_icmpne 7\n 5: iconst_0\n 6: ireturn\n 7: iload_0\n 8: iload_1\n 9: if_icmple 14\n 12: iconst_1\n 13: ireturn\n 14: iconst_m1\n 15: ireturn\n\n private static final Point main$tryMoveTail(Point, Point);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #208 // Method main$isTouching:(LPoint;LPoint;)Z\n 5: ifeq 10\n 8: aload_1\n 9: areturn\n 10: aload_0\n 11: invokevirtual #181 // Method Point.getX:()I\n 14: aload_1\n 15: invokevirtual #181 // Method Point.getX:()I\n 18: invokestatic #210 // Method main$getDelta:(II)I\n 21: istore_2\n 22: aload_0\n 23: invokevirtual #184 // Method Point.getY:()I\n 26: aload_1\n 27: invokevirtual #184 // Method Point.getY:()I\n 30: invokestatic #210 // Method main$getDelta:(II)I\n 33: istore_3\n 34: new #178 // class Point\n 37: dup\n 38: aload_1\n 39: invokevirtual #181 // Method Point.getX:()I\n 42: iload_2\n 43: iadd\n 44: aload_1\n 45: invokevirtual #184 // Method Point.getY:()I\n 48: iload_3\n 49: iadd\n 50: invokespecial #187 // Method Point.\"<init>\":(II)V\n 53: areturn\n\n private static final int main$traverse(java.util.List<Command>, int);\n Code:\n 0: new #217 // class java/util/LinkedHashSet\n 3: dup\n 4: invokespecial #218 // Method java/util/LinkedHashSet.\"<init>\":()V\n 7: checkcast #220 // class java/util/Set\n 10: astore_2\n 11: new #178 // class Point\n 14: dup\n 15: iconst_0\n 16: iconst_0\n 17: invokespecial #187 // Method Point.\"<init>\":(II)V\n 20: astore_3\n 21: iload_1\n 22: iconst_2\n 23: isub\n 24: istore 4\n 26: new #222 // class kotlin/ranges/IntRange\n 29: dup\n 30: iconst_1\n 31: iload 4\n 33: invokespecial #223 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 36: checkcast #58 // class java/lang/Iterable\n 39: astore 6\n 41: iconst_0\n 42: istore 7\n 44: aload 6\n 46: astore 8\n 48: new #60 // class java/util/ArrayList\n 51: dup\n 52: aload 6\n 54: bipush 10\n 56: invokestatic #66 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 59: invokespecial #69 // Method java/util/ArrayList.\"<init>\":(I)V\n 62: checkcast #71 // class java/util/Collection\n 65: astore 9\n 67: iconst_0\n 68: istore 10\n 70: aload 8\n 72: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 77: astore 11\n 79: aload 11\n 81: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 86: ifeq 131\n 89: aload 11\n 91: checkcast #225 // class kotlin/collections/IntIterator\n 94: invokevirtual #228 // Method kotlin/collections/IntIterator.nextInt:()I\n 97: istore 12\n 99: aload 9\n 101: iload 12\n 103: istore 13\n 105: astore 15\n 107: iconst_0\n 108: istore 14\n 110: new #178 // class Point\n 113: dup\n 114: iconst_0\n 115: iconst_0\n 116: invokespecial #187 // Method Point.\"<init>\":(II)V\n 119: aload 15\n 121: swap\n 122: invokeinterface #148, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 127: pop\n 128: goto 79\n 131: aload 9\n 133: checkcast #97 // class java/util/List\n 136: nop\n 137: checkcast #71 // class java/util/Collection\n 140: invokestatic #232 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 143: astore 5\n 145: new #178 // class Point\n 148: dup\n 149: iconst_0\n 150: iconst_0\n 151: invokespecial #187 // Method Point.\"<init>\":(II)V\n 154: astore 6\n 156: aload_2\n 157: aload 6\n 159: invokeinterface #233, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 164: pop\n 165: aload_0\n 166: invokeinterface #234, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 171: astore 7\n 173: aload 7\n 175: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 180: ifeq 313\n 183: aload 7\n 185: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 190: checkcast #138 // class Command\n 193: astore 8\n 195: iconst_1\n 196: istore 9\n 198: aload 8\n 200: invokevirtual #237 // Method Command.getCount:()I\n 203: istore 10\n 205: iload 9\n 207: iload 10\n 209: if_icmpgt 173\n 212: aload_3\n 213: aload 8\n 215: invokevirtual #241 // Method Command.getDirection:()LDirection;\n 218: invokestatic #243 // Method main$move:(LPoint;LDirection;)LPoint;\n 221: astore_3\n 222: aload_3\n 223: astore 11\n 225: iconst_0\n 226: istore 12\n 228: iload 12\n 230: iload 4\n 232: if_icmpge 282\n 235: aload 5\n 237: iload 12\n 239: aload 11\n 241: aload 5\n 243: iload 12\n 245: invokeinterface #101, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 250: checkcast #178 // class Point\n 253: invokestatic #245 // Method main$tryMoveTail:(LPoint;LPoint;)LPoint;\n 256: invokeinterface #249, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 261: pop\n 262: aload 5\n 264: iload 12\n 266: invokeinterface #101, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 271: checkcast #178 // class Point\n 274: astore 11\n 276: iinc 12, 1\n 279: goto 228\n 282: aload 11\n 284: aload 6\n 286: invokestatic #245 // Method main$tryMoveTail:(LPoint;LPoint;)LPoint;\n 289: astore 6\n 291: aload_2\n 292: aload 6\n 294: invokeinterface #233, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 299: pop\n 300: iload 9\n 302: iload 10\n 304: if_icmpeq 173\n 307: iinc 9, 1\n 310: goto 212\n 313: aload_2\n 314: checkcast #71 // class java/util/Collection\n 317: invokeinterface #252, 1 // InterfaceMethod java/util/Collection.size:()I\n 322: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #267 // Method main$parse:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: aload_1\n 6: iconst_2\n 7: invokestatic #269 // Method main$traverse:(Ljava/util/List;I)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: invokestatic #267 // Method main$parse:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: aload_1\n 6: bipush 10\n 8: invokestatic #269 // Method main$traverse:(Ljava/util/List;I)I\n 11: ireturn\n}\n",
"javap_err": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day02.kt
|
enum class Figure(val score: Int) {
Rock(1),
Paper(2),
Scissors(3)
}
fun main() {
fun createFigure(value: String): Figure {
return when (value) {
"A" -> Figure.Rock
"B" -> Figure.Paper
"C" -> Figure.Scissors
"X" -> Figure.Rock
"Y" -> Figure.Paper
"Z" -> Figure.Scissors
else -> throw Exception("Value unsupported $value")
}
}
fun compare(f1: Figure, f2: Figure): Int {
if (f1 == f2) {
return 3
}
if (
f1 == Figure.Paper && f2 == Figure.Scissors ||
f1 == Figure.Rock && f2 == Figure.Paper ||
f1 == Figure.Scissors && f2 == Figure.Rock
) {
return 6
}
return 0
}
fun readTurns(lines: List<String>): List<Pair<Figure, Figure>> {
return lines.map {
val parts = it.split(' ')
Pair(createFigure(parts[0]), createFigure(parts[1]))
}
}
fun createFigure2(first: Figure, value: String): Figure {
if (value == "Y") {
return first
}
if (value == "X") {
return when (first) {
Figure.Rock -> Figure.Scissors
Figure.Paper -> Figure.Rock
Figure.Scissors -> Figure.Paper
}
}
return when (first) {
Figure.Rock -> Figure.Paper
Figure.Paper -> Figure.Scissors
Figure.Scissors -> Figure.Rock
}
}
fun readTurns2(lines: List<String>): List<Pair<Figure, Figure>> {
return lines.map {
val parts = it.split(' ')
val first = createFigure(parts[0])
Pair(first, createFigure2(first, parts[1]))
}
}
fun play(turns: List<Pair<Figure, Figure>>): Long {
var result = 0L
turns.map {
compare(it.first, it.second) + it.second.score
}.forEach {
result += it
}
return result
}
fun part1(input: List<String>): Long {
return play(readTurns(input))
}
fun part2(input: List<String>): Long {
return play(readTurns2(input))
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day02_test")
check(part1(testInput) == 15L)
check(part2(testInput) == 12L)
val input = readInput("Day02")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/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: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method main$part1:(Ljava/util/List;)J\n 10: ldc2_w #19 // long 15l\n 13: lcmp\n 14: ifne 21\n 17: iconst_1\n 18: goto 22\n 21: iconst_0\n 22: ifne 35\n 25: new #22 // class java/lang/IllegalStateException\n 28: dup\n 29: ldc #24 // String Check failed.\n 31: invokespecial #28 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 34: athrow\n 35: aload_0\n 36: invokestatic #31 // Method main$part2:(Ljava/util/List;)J\n 39: ldc2_w #32 // long 12l\n 42: lcmp\n 43: ifne 50\n 46: iconst_1\n 47: goto 51\n 50: iconst_0\n 51: ifne 64\n 54: new #22 // class java/lang/IllegalStateException\n 57: dup\n 58: ldc #24 // String Check failed.\n 60: invokespecial #28 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 63: athrow\n 64: ldc #35 // String Day02\n 66: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 69: astore_1\n 70: aload_1\n 71: invokestatic #18 // Method main$part1:(Ljava/util/List;)J\n 74: lstore_2\n 75: getstatic #41 // Field java/lang/System.out:Ljava/io/PrintStream;\n 78: lload_2\n 79: invokevirtual #47 // Method java/io/PrintStream.println:(J)V\n 82: aload_1\n 83: invokestatic #31 // Method main$part2:(Ljava/util/List;)J\n 86: lstore_2\n 87: getstatic #41 // Field java/lang/System.out:Ljava/io/PrintStream;\n 90: lload_2\n 91: invokevirtual #47 // Method java/io/PrintStream.println:(J)V\n 94: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #55 // Method main:()V\n 3: return\n\n private static final Figure main$createFigure(java.lang.String);\n Code:\n 0: aload_0\n 1: astore_1\n 2: aload_1\n 3: invokevirtual #65 // 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: 172\n }\n 64: aload_1\n 65: ldc #67 // String A\n 67: invokevirtual #71 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 70: ifne 136\n 73: goto 172\n 76: aload_1\n 77: ldc #73 // String B\n 79: invokevirtual #71 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 82: ifne 142\n 85: goto 172\n 88: aload_1\n 89: ldc #75 // String C\n 91: invokevirtual #71 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 94: ifne 148\n 97: goto 172\n 100: aload_1\n 101: ldc #77 // String X\n 103: invokevirtual #71 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 106: ifne 154\n 109: goto 172\n 112: aload_1\n 113: ldc #79 // String Y\n 115: invokevirtual #71 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 118: ifne 160\n 121: goto 172\n 124: aload_1\n 125: ldc #81 // String Z\n 127: invokevirtual #71 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 130: ifne 166\n 133: goto 172\n 136: getstatic #87 // Field Figure.Rock:LFigure;\n 139: goto 199\n 142: getstatic #90 // Field Figure.Paper:LFigure;\n 145: goto 199\n 148: getstatic #93 // Field Figure.Scissors:LFigure;\n 151: goto 199\n 154: getstatic #87 // Field Figure.Rock:LFigure;\n 157: goto 199\n 160: getstatic #90 // Field Figure.Paper:LFigure;\n 163: goto 199\n 166: getstatic #93 // Field Figure.Scissors:LFigure;\n 169: goto 199\n 172: new #95 // class java/lang/Exception\n 175: dup\n 176: new #97 // class java/lang/StringBuilder\n 179: dup\n 180: invokespecial #99 // Method java/lang/StringBuilder.\"<init>\":()V\n 183: ldc #101 // String Value unsupported\n 185: invokevirtual #105 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 188: aload_0\n 189: invokevirtual #105 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 192: invokevirtual #109 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 195: invokespecial #110 // Method java/lang/Exception.\"<init>\":(Ljava/lang/String;)V\n 198: athrow\n 199: areturn\n\n private static final int main$compare(Figure, Figure);\n Code:\n 0: aload_0\n 1: aload_1\n 2: if_acmpne 7\n 5: iconst_3\n 6: ireturn\n 7: aload_0\n 8: getstatic #90 // Field Figure.Paper:LFigure;\n 11: if_acmpne 21\n 14: aload_1\n 15: getstatic #93 // Field Figure.Scissors:LFigure;\n 18: if_acmpeq 49\n 21: aload_0\n 22: getstatic #87 // Field Figure.Rock:LFigure;\n 25: if_acmpne 35\n 28: aload_1\n 29: getstatic #90 // Field Figure.Paper:LFigure;\n 32: if_acmpeq 49\n 35: aload_0\n 36: getstatic #93 // Field Figure.Scissors:LFigure;\n 39: if_acmpne 52\n 42: aload_1\n 43: getstatic #87 // Field Figure.Rock:LFigure;\n 46: if_acmpne 52\n 49: bipush 6\n 51: ireturn\n 52: iconst_0\n 53: ireturn\n\n private static final java.util.List<kotlin.Pair<Figure, Figure>> main$readTurns(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #121 // 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 #123 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #129 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #132 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #134 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #138, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #144, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 146\n 48: aload 6\n 50: invokeinterface #148, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #61 // class java/lang/String\n 64: astore 8\n 66: astore 12\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: checkcast #150 // class java/lang/CharSequence\n 76: iconst_1\n 77: newarray char\n 79: astore 10\n 81: aload 10\n 83: iconst_0\n 84: bipush 32\n 86: castore\n 87: aload 10\n 89: iconst_0\n 90: iconst_0\n 91: bipush 6\n 93: aconst_null\n 94: invokestatic #156 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 97: astore 11\n 99: new #158 // class kotlin/Pair\n 102: dup\n 103: aload 11\n 105: iconst_0\n 106: invokeinterface #162, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 111: checkcast #61 // class java/lang/String\n 114: invokestatic #164 // Method main$createFigure:(Ljava/lang/String;)LFigure;\n 117: aload 11\n 119: iconst_1\n 120: invokeinterface #162, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 125: checkcast #61 // class java/lang/String\n 128: invokestatic #164 // Method main$createFigure:(Ljava/lang/String;)LFigure;\n 131: invokespecial #167 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 134: aload 12\n 136: swap\n 137: invokeinterface #170, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 142: pop\n 143: goto 38\n 146: aload 4\n 148: checkcast #52 // class java/util/List\n 151: nop\n 152: areturn\n\n private static final Figure main$createFigure2(Figure, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #79 // String Y\n 3: invokestatic #192 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 6: ifeq 11\n 9: aload_0\n 10: areturn\n 11: aload_1\n 12: ldc #77 // String X\n 14: invokestatic #192 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 17: ifeq 83\n 20: aload_0\n 21: getstatic #198 // Field Day02Kt$WhenMappings.$EnumSwitchMapping$0:[I\n 24: swap\n 25: invokevirtual #201 // Method Figure.ordinal:()I\n 28: iaload\n 29: tableswitch { // 1 to 3\n 1: 56\n 2: 62\n 3: 68\n default: 74\n }\n 56: getstatic #93 // Field Figure.Scissors:LFigure;\n 59: goto 82\n 62: getstatic #87 // Field Figure.Rock:LFigure;\n 65: goto 82\n 68: getstatic #90 // Field Figure.Paper:LFigure;\n 71: goto 82\n 74: new #203 // class kotlin/NoWhenBranchMatchedException\n 77: dup\n 78: invokespecial #204 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 81: athrow\n 82: areturn\n 83: aload_0\n 84: getstatic #198 // Field Day02Kt$WhenMappings.$EnumSwitchMapping$0:[I\n 87: swap\n 88: invokevirtual #201 // Method Figure.ordinal:()I\n 91: iaload\n 92: tableswitch { // 1 to 3\n 1: 120\n 2: 126\n 3: 132\n default: 138\n }\n 120: getstatic #90 // Field Figure.Paper:LFigure;\n 123: goto 146\n 126: getstatic #93 // Field Figure.Scissors:LFigure;\n 129: goto 146\n 132: getstatic #87 // Field Figure.Rock:LFigure;\n 135: goto 146\n 138: new #203 // class kotlin/NoWhenBranchMatchedException\n 141: dup\n 142: invokespecial #204 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 145: athrow\n 146: areturn\n\n private static final java.util.List<kotlin.Pair<Figure, Figure>> main$readTurns2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #121 // 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 #123 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #129 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #132 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #134 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #138, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #144, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 152\n 48: aload 6\n 50: invokeinterface #148, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #61 // class java/lang/String\n 64: astore 8\n 66: astore 12\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: checkcast #150 // class java/lang/CharSequence\n 76: iconst_1\n 77: newarray char\n 79: astore 10\n 81: aload 10\n 83: iconst_0\n 84: bipush 32\n 86: castore\n 87: aload 10\n 89: iconst_0\n 90: iconst_0\n 91: bipush 6\n 93: aconst_null\n 94: invokestatic #156 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 97: astore 11\n 99: aload 11\n 101: iconst_0\n 102: invokeinterface #162, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 107: checkcast #61 // class java/lang/String\n 110: invokestatic #164 // Method main$createFigure:(Ljava/lang/String;)LFigure;\n 113: astore 10\n 115: new #158 // class kotlin/Pair\n 118: dup\n 119: aload 10\n 121: aload 10\n 123: aload 11\n 125: iconst_1\n 126: invokeinterface #162, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 131: checkcast #61 // class java/lang/String\n 134: invokestatic #208 // Method main$createFigure2:(LFigure;Ljava/lang/String;)LFigure;\n 137: invokespecial #167 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 140: aload 12\n 142: swap\n 143: invokeinterface #170, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 148: pop\n 149: goto 38\n 152: aload 4\n 154: checkcast #52 // class java/util/List\n 157: nop\n 158: areturn\n\n private static final long main$play(java.util.List<? extends kotlin.Pair<? extends Figure, ? extends Figure>>);\n Code:\n 0: lconst_0\n 1: lstore 11\n 3: aload_0\n 4: checkcast #121 // 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 #123 // class java/util/ArrayList\n 15: dup\n 16: aload_1\n 17: bipush 10\n 19: invokestatic #129 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 22: invokespecial #132 // Method java/util/ArrayList.\"<init>\":(I)V\n 25: checkcast #134 // class java/util/Collection\n 28: astore 4\n 30: iconst_0\n 31: istore 5\n 33: aload_3\n 34: invokeinterface #138, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 6\n 41: aload 6\n 43: invokeinterface #144, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 120\n 51: aload 6\n 53: invokeinterface #148, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 7\n 60: aload 4\n 62: aload 7\n 64: checkcast #158 // class kotlin/Pair\n 67: astore 8\n 69: astore 10\n 71: iconst_0\n 72: istore 9\n 74: aload 8\n 76: invokevirtual #214 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 79: checkcast #83 // class Figure\n 82: aload 8\n 84: invokevirtual #217 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 87: checkcast #83 // class Figure\n 90: invokestatic #219 // Method main$compare:(LFigure;LFigure;)I\n 93: aload 8\n 95: invokevirtual #217 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 98: checkcast #83 // class Figure\n 101: invokevirtual #222 // Method Figure.getScore:()I\n 104: iadd\n 105: invokestatic #228 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 108: aload 10\n 110: swap\n 111: invokeinterface #170, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 116: pop\n 117: goto 41\n 120: aload 4\n 122: checkcast #52 // class java/util/List\n 125: nop\n 126: checkcast #121 // class java/lang/Iterable\n 129: astore_1\n 130: nop\n 131: iconst_0\n 132: istore_2\n 133: aload_1\n 134: invokeinterface #138, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 139: astore_3\n 140: aload_3\n 141: invokeinterface #144, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 146: ifeq 183\n 149: aload_3\n 150: invokeinterface #148, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 155: astore 4\n 157: aload 4\n 159: checkcast #230 // class java/lang/Number\n 162: invokevirtual #233 // Method java/lang/Number.intValue:()I\n 165: istore 5\n 167: iconst_0\n 168: istore 6\n 170: lload 11\n 172: iload 5\n 174: i2l\n 175: ladd\n 176: lstore 11\n 178: nop\n 179: nop\n 180: goto 140\n 183: nop\n 184: lload 11\n 186: lreturn\n\n private static final long main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #245 // Method main$readTurns:(Ljava/util/List;)Ljava/util/List;\n 4: invokestatic #247 // Method main$play:(Ljava/util/List;)J\n 7: lreturn\n\n private static final long main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #249 // Method main$readTurns2:(Ljava/util/List;)Ljava/util/List;\n 4: invokestatic #247 // Method main$play:(Ljava/util/List;)J\n 7: lreturn\n}\n",
"javap_err": ""
},
{
"class_path": "kipwoker__aoc2022__d8aeea8/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 Figure.values:()[LFigure;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field Figure.Rock:LFigure;\n 12: invokevirtual #22 // Method Figure.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 Figure.Paper:LFigure;\n 26: invokevirtual #22 // Method Figure.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 Figure.Scissors:LFigure;\n 40: invokevirtual #22 // Method Figure.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": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day12.kt
|
class Day12Input(
val graph: Map<Point, Int>,
val start: Point,
val end: Point
)
data class Trace(val weight: Int, val current: Point, val prev: Point?, val distance: Int)
fun main() {
fun getNeighbors(point: Point, graph: Map<Point, Int>): List<Point> {
return listOf(
Point(point.x - 1, point.y),
Point(point.x + 1, point.y),
Point(point.x, point.y - 1),
Point(point.x, point.y + 1)
).filter { graph.contains(it) }
}
fun search(graph: Map<Point, Int>, startPoints: List<Point>, endPoint: Point): Int {
val visited = startPoints.toMutableSet()
val queue = ArrayDeque(
startPoints.map { start -> Trace(graph[start]!!, start, null, 0) }
)
while (queue.isNotEmpty()) {
val item = queue.removeFirst()
if (item.current == endPoint) {
return item.distance
}
val source = item.current
val sourceWeight = graph[source]!!
for (target in getNeighbors(source, graph)) {
val targetWeight = graph[target]!!
if (targetWeight - sourceWeight > 1 || target in visited) {
continue
}
visited.add(target)
queue.addLast(Trace(targetWeight, target, source, item.distance + 1))
}
}
return -1
}
fun parse(input: List<String>): Day12Input {
var start = Point(0, 0)
var end = Point(0, 0)
val graph = input.mapIndexed { i, line ->
line.mapIndexed { j, cell ->
val value: Int = when (cell) {
'S' -> {
start = Point(i, j)
1
}
'E' -> {
end = Point(i, j)
'z' - 'a' + 1
}
else ->
(cell - 'a' + 1)
}
Point(i, j) to value
}
}.flatten().toMap()
return Day12Input(graph, start, end)
}
fun part1(input: List<String>): Int {
val day12Input = parse(input)
return search(day12Input.graph, listOf(day12Input.start), day12Input.end)
}
fun part2(input: List<String>): Int {
val day12Input = parse(input)
val startPoints = day12Input.graph.filter { it.value == 1 }.map { it.key }
return search(day12Input.graph, startPoints, day12Input.end)
}
val testInput = readInput("Day12_test")
assert(part1(testInput), 31)
assert(part2(testInput), 29)
val input = readInput("Day12")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day12Kt.class",
"javap": "Compiled from \"Day12.kt\"\npublic final class Day12Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day12_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 10: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 13: bipush 31\n 15: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 18: invokestatic #28 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 21: aload_0\n 22: invokestatic #31 // Method main$part2:(Ljava/util/List;)I\n 25: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 28: bipush 29\n 30: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 33: invokestatic #28 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 36: ldc #33 // String Day12\n 38: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 41: astore_1\n 42: aload_1\n 43: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 46: istore_2\n 47: getstatic #39 // Field java/lang/System.out:Ljava/io/PrintStream;\n 50: iload_2\n 51: invokevirtual #45 // Method java/io/PrintStream.println:(I)V\n 54: aload_1\n 55: invokestatic #31 // Method main$part2:(Ljava/util/List;)I\n 58: istore_2\n 59: getstatic #39 // Field java/lang/System.out:Ljava/io/PrintStream;\n 62: iload_2\n 63: invokevirtual #45 // Method java/io/PrintStream.println:(I)V\n 66: 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 java.util.List<Point> main$getNeighbors(Point, java.util.Map<Point, java.lang.Integer>);\n Code:\n 0: iconst_4\n 1: anewarray #58 // class Point\n 4: astore_2\n 5: aload_2\n 6: iconst_0\n 7: new #58 // class Point\n 10: dup\n 11: aload_0\n 12: invokevirtual #62 // Method Point.getX:()I\n 15: iconst_1\n 16: isub\n 17: aload_0\n 18: invokevirtual #65 // Method Point.getY:()I\n 21: invokespecial #69 // Method Point.\"<init>\":(II)V\n 24: aastore\n 25: aload_2\n 26: iconst_1\n 27: new #58 // class Point\n 30: dup\n 31: aload_0\n 32: invokevirtual #62 // Method Point.getX:()I\n 35: iconst_1\n 36: iadd\n 37: aload_0\n 38: invokevirtual #65 // Method Point.getY:()I\n 41: invokespecial #69 // Method Point.\"<init>\":(II)V\n 44: aastore\n 45: aload_2\n 46: iconst_2\n 47: new #58 // class Point\n 50: dup\n 51: aload_0\n 52: invokevirtual #62 // Method Point.getX:()I\n 55: aload_0\n 56: invokevirtual #65 // Method Point.getY:()I\n 59: iconst_1\n 60: isub\n 61: invokespecial #69 // Method Point.\"<init>\":(II)V\n 64: aastore\n 65: aload_2\n 66: iconst_3\n 67: new #58 // class Point\n 70: dup\n 71: aload_0\n 72: invokevirtual #62 // Method Point.getX:()I\n 75: aload_0\n 76: invokevirtual #65 // Method Point.getY:()I\n 79: iconst_1\n 80: iadd\n 81: invokespecial #69 // Method Point.\"<init>\":(II)V\n 84: aastore\n 85: aload_2\n 86: invokestatic #75 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 89: checkcast #77 // class java/lang/Iterable\n 92: astore_2\n 93: nop\n 94: iconst_0\n 95: istore_3\n 96: aload_2\n 97: astore 4\n 99: new #79 // class java/util/ArrayList\n 102: dup\n 103: invokespecial #81 // Method java/util/ArrayList.\"<init>\":()V\n 106: checkcast #83 // class java/util/Collection\n 109: astore 5\n 111: iconst_0\n 112: istore 6\n 114: aload 4\n 116: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 121: astore 7\n 123: aload 7\n 125: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 130: ifeq 177\n 133: aload 7\n 135: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 140: astore 8\n 142: aload 8\n 144: checkcast #58 // class Point\n 147: astore 9\n 149: iconst_0\n 150: istore 10\n 152: aload_1\n 153: aload 9\n 155: invokeinterface #103, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 160: nop\n 161: ifeq 123\n 164: aload 5\n 166: aload 8\n 168: invokeinterface #106, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 173: pop\n 174: goto 123\n 177: aload 5\n 179: checkcast #108 // class java/util/List\n 182: nop\n 183: areturn\n\n private static final int main$search(java.util.Map<Point, java.lang.Integer>, java.util.List<Point>, Point);\n Code:\n 0: aload_1\n 1: checkcast #77 // class java/lang/Iterable\n 4: invokestatic #131 // Method kotlin/collections/CollectionsKt.toMutableSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 7: astore_3\n 8: aload_1\n 9: checkcast #77 // class java/lang/Iterable\n 12: astore 5\n 14: iconst_0\n 15: istore 6\n 17: aload 5\n 19: astore 7\n 21: new #79 // class java/util/ArrayList\n 24: dup\n 25: aload 5\n 27: bipush 10\n 29: invokestatic #135 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 32: invokespecial #137 // Method java/util/ArrayList.\"<init>\":(I)V\n 35: checkcast #83 // class java/util/Collection\n 38: astore 8\n 40: iconst_0\n 41: istore 9\n 43: aload 7\n 45: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 50: astore 10\n 52: aload 10\n 54: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 126\n 62: aload 10\n 64: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 69: astore 11\n 71: aload 8\n 73: aload 11\n 75: checkcast #58 // class Point\n 78: astore 12\n 80: astore 14\n 82: iconst_0\n 83: istore 13\n 85: new #139 // class Trace\n 88: dup\n 89: aload_0\n 90: aload 12\n 92: invokeinterface #143, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 97: dup\n 98: invokestatic #149 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 101: checkcast #151 // class java/lang/Number\n 104: invokevirtual #154 // Method java/lang/Number.intValue:()I\n 107: aload 12\n 109: aconst_null\n 110: iconst_0\n 111: invokespecial #157 // Method Trace.\"<init>\":(ILPoint;LPoint;I)V\n 114: aload 14\n 116: swap\n 117: invokeinterface #106, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 122: pop\n 123: goto 52\n 126: aload 8\n 128: checkcast #108 // class java/util/List\n 131: nop\n 132: checkcast #83 // class java/util/Collection\n 135: astore 15\n 137: new #159 // class kotlin/collections/ArrayDeque\n 140: dup\n 141: aload 15\n 143: invokespecial #162 // Method kotlin/collections/ArrayDeque.\"<init>\":(Ljava/util/Collection;)V\n 146: astore 4\n 148: aload 4\n 150: checkcast #83 // class java/util/Collection\n 153: invokeinterface #165, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 158: ifne 165\n 161: iconst_1\n 162: goto 166\n 165: iconst_0\n 166: ifeq 339\n 169: aload 4\n 171: invokevirtual #168 // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;\n 174: checkcast #139 // class Trace\n 177: astore 5\n 179: aload 5\n 181: invokevirtual #172 // Method Trace.getCurrent:()LPoint;\n 184: aload_2\n 185: invokestatic #176 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 188: ifeq 197\n 191: aload 5\n 193: invokevirtual #179 // Method Trace.getDistance:()I\n 196: ireturn\n 197: aload 5\n 199: invokevirtual #172 // Method Trace.getCurrent:()LPoint;\n 202: astore 6\n 204: aload_0\n 205: aload 6\n 207: invokeinterface #143, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 212: dup\n 213: invokestatic #149 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 216: checkcast #151 // class java/lang/Number\n 219: invokevirtual #154 // Method java/lang/Number.intValue:()I\n 222: istore 7\n 224: aload 6\n 226: aload_0\n 227: invokestatic #181 // Method main$getNeighbors:(LPoint;Ljava/util/Map;)Ljava/util/List;\n 230: invokeinterface #182, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 235: astore 8\n 237: aload 8\n 239: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 244: ifeq 148\n 247: aload 8\n 249: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 254: checkcast #58 // class Point\n 257: astore 9\n 259: aload_0\n 260: aload 9\n 262: invokeinterface #143, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 267: dup\n 268: invokestatic #149 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 271: checkcast #151 // class java/lang/Number\n 274: invokevirtual #154 // Method java/lang/Number.intValue:()I\n 277: istore 10\n 279: iload 10\n 281: iload 7\n 283: isub\n 284: iconst_1\n 285: if_icmpgt 299\n 288: aload_3\n 289: aload 9\n 291: invokeinterface #187, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 296: ifeq 302\n 299: goto 237\n 302: aload_3\n 303: aload 9\n 305: invokeinterface #188, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 310: pop\n 311: aload 4\n 313: new #139 // class Trace\n 316: dup\n 317: iload 10\n 319: aload 9\n 321: aload 6\n 323: aload 5\n 325: invokevirtual #179 // Method Trace.getDistance:()I\n 328: iconst_1\n 329: iadd\n 330: invokespecial #157 // Method Trace.\"<init>\":(ILPoint;LPoint;I)V\n 333: invokevirtual #191 // Method kotlin/collections/ArrayDeque.addLast:(Ljava/lang/Object;)V\n 336: goto 237\n 339: iconst_m1\n 340: ireturn\n\n private static final Day12Input main$parse(java.util.List<java.lang.String>);\n Code:\n 0: aconst_null\n 1: astore_1\n 2: new #58 // class Point\n 5: dup\n 6: iconst_0\n 7: iconst_0\n 8: invokespecial #69 // Method Point.\"<init>\":(II)V\n 11: astore_1\n 12: aconst_null\n 13: astore_2\n 14: new #58 // class Point\n 17: dup\n 18: iconst_0\n 19: iconst_0\n 20: invokespecial #69 // Method Point.\"<init>\":(II)V\n 23: astore_2\n 24: aload_0\n 25: checkcast #77 // class java/lang/Iterable\n 28: astore 4\n 30: iconst_0\n 31: istore 5\n 33: aload 4\n 35: astore 6\n 37: new #79 // class java/util/ArrayList\n 40: dup\n 41: aload 4\n 43: bipush 10\n 45: invokestatic #135 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 48: invokespecial #137 // Method java/util/ArrayList.\"<init>\":(I)V\n 51: checkcast #83 // class java/util/Collection\n 54: astore 7\n 56: iconst_0\n 57: istore 8\n 59: iconst_0\n 60: istore 9\n 62: aload 6\n 64: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 69: astore 10\n 71: aload 10\n 73: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 78: ifeq 331\n 81: aload 10\n 83: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 88: astore 11\n 90: aload 7\n 92: iload 9\n 94: iinc 9, 1\n 97: istore 12\n 99: iload 12\n 101: ifge 107\n 104: invokestatic #216 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 107: iload 12\n 109: aload 11\n 111: checkcast #218 // class java/lang/String\n 114: astore 13\n 116: istore 14\n 118: astore 29\n 120: iconst_0\n 121: istore 15\n 123: aload 13\n 125: checkcast #220 // class java/lang/CharSequence\n 128: astore 16\n 130: iconst_0\n 131: istore 17\n 133: aload 16\n 135: astore 18\n 137: new #79 // class java/util/ArrayList\n 140: dup\n 141: aload 16\n 143: invokeinterface #223, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 148: invokespecial #137 // Method java/util/ArrayList.\"<init>\":(I)V\n 151: checkcast #83 // class java/util/Collection\n 154: astore 19\n 156: iconst_0\n 157: istore 20\n 159: iconst_0\n 160: istore 21\n 162: iconst_0\n 163: istore 22\n 165: iload 22\n 167: aload 18\n 169: invokeinterface #223, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 174: if_icmpge 312\n 177: aload 18\n 179: iload 22\n 181: invokeinterface #227, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 186: istore 23\n 188: aload 19\n 190: iload 21\n 192: iinc 21, 1\n 195: iload 23\n 197: istore 24\n 199: istore 25\n 201: astore 26\n 203: iconst_0\n 204: istore 27\n 206: iload 24\n 208: lookupswitch { // 2\n 69: 252\n 83: 236\n default: 269\n }\n 236: new #58 // class Point\n 239: dup\n 240: iload 14\n 242: iload 25\n 244: invokespecial #69 // Method Point.\"<init>\":(II)V\n 247: astore_1\n 248: iconst_1\n 249: goto 276\n 252: new #58 // class Point\n 255: dup\n 256: iload 14\n 258: iload 25\n 260: invokespecial #69 // Method Point.\"<init>\":(II)V\n 263: astore_2\n 264: bipush 26\n 266: goto 276\n 269: iload 24\n 271: bipush 97\n 273: isub\n 274: iconst_1\n 275: iadd\n 276: istore 28\n 278: new #58 // class Point\n 281: dup\n 282: iload 14\n 284: iload 25\n 286: invokespecial #69 // Method Point.\"<init>\":(II)V\n 289: iload 28\n 291: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 294: invokestatic #233 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 297: aload 26\n 299: swap\n 300: invokeinterface #106, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 305: pop\n 306: iinc 22, 1\n 309: goto 165\n 312: aload 19\n 314: checkcast #108 // class java/util/List\n 317: nop\n 318: nop\n 319: aload 29\n 321: swap\n 322: invokeinterface #106, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 327: pop\n 328: goto 71\n 331: aload 7\n 333: checkcast #108 // class java/util/List\n 336: nop\n 337: checkcast #77 // class java/lang/Iterable\n 340: invokestatic #237 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 343: checkcast #77 // class java/lang/Iterable\n 346: invokestatic #243 // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;\n 349: astore_3\n 350: new #245 // class Day12Input\n 353: dup\n 354: aload_3\n 355: aload_1\n 356: aload_2\n 357: invokespecial #248 // Method Day12Input.\"<init>\":(Ljava/util/Map;LPoint;LPoint;)V\n 360: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #267 // Method main$parse:(Ljava/util/List;)LDay12Input;\n 4: astore_1\n 5: aload_1\n 6: invokevirtual #271 // Method Day12Input.getGraph:()Ljava/util/Map;\n 9: aload_1\n 10: invokevirtual #274 // Method Day12Input.getStart:()LPoint;\n 13: invokestatic #277 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 16: aload_1\n 17: invokevirtual #280 // Method Day12Input.getEnd:()LPoint;\n 20: invokestatic #282 // Method main$search:(Ljava/util/Map;Ljava/util/List;LPoint;)I\n 23: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #267 // Method main$parse:(Ljava/util/List;)LDay12Input;\n 4: astore_1\n 5: aload_1\n 6: invokevirtual #271 // Method Day12Input.getGraph:()Ljava/util/Map;\n 9: astore_3\n 10: iconst_0\n 11: istore 4\n 13: aload_3\n 14: astore 5\n 16: new #286 // class java/util/LinkedHashMap\n 19: dup\n 20: invokespecial #287 // Method java/util/LinkedHashMap.\"<init>\":()V\n 23: checkcast #99 // class java/util/Map\n 26: astore 6\n 28: iconst_0\n 29: istore 7\n 31: aload 5\n 33: invokeinterface #291, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 38: invokeinterface #292, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 43: astore 8\n 45: aload 8\n 47: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 52: ifeq 124\n 55: aload 8\n 57: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 62: checkcast #294 // class java/util/Map$Entry\n 65: astore 9\n 67: aload 9\n 69: astore 10\n 71: iconst_0\n 72: istore 11\n 74: aload 10\n 76: invokeinterface #297, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 81: checkcast #151 // class java/lang/Number\n 84: invokevirtual #154 // Method java/lang/Number.intValue:()I\n 87: iconst_1\n 88: if_icmpne 95\n 91: iconst_1\n 92: goto 96\n 95: iconst_0\n 96: ifeq 45\n 99: aload 6\n 101: aload 9\n 103: invokeinterface #300, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 108: aload 9\n 110: invokeinterface #297, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 115: invokeinterface #304, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 120: pop\n 121: goto 45\n 124: aload 6\n 126: nop\n 127: astore_3\n 128: nop\n 129: iconst_0\n 130: istore 4\n 132: aload_3\n 133: astore 5\n 135: new #79 // class java/util/ArrayList\n 138: dup\n 139: aload_3\n 140: invokeinterface #307, 1 // InterfaceMethod java/util/Map.size:()I\n 145: invokespecial #137 // Method java/util/ArrayList.\"<init>\":(I)V\n 148: checkcast #83 // class java/util/Collection\n 151: astore 6\n 153: iconst_0\n 154: istore 7\n 156: aload 5\n 158: invokeinterface #291, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 163: invokeinterface #292, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 168: astore 8\n 170: aload 8\n 172: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 177: ifeq 225\n 180: aload 8\n 182: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 187: checkcast #294 // class java/util/Map$Entry\n 190: astore 9\n 192: aload 6\n 194: aload 9\n 196: astore 10\n 198: astore 12\n 200: iconst_0\n 201: istore 11\n 203: aload 10\n 205: invokeinterface #300, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 210: checkcast #58 // class Point\n 213: aload 12\n 215: swap\n 216: invokeinterface #106, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 221: pop\n 222: goto 170\n 225: aload 6\n 227: checkcast #108 // class java/util/List\n 230: nop\n 231: astore_2\n 232: aload_1\n 233: invokevirtual #271 // Method Day12Input.getGraph:()Ljava/util/Map;\n 236: aload_2\n 237: aload_1\n 238: invokevirtual #280 // Method Day12Input.getEnd:()LPoint;\n 241: invokestatic #282 // Method main$search:(Ljava/util/Map;Ljava/util/List;LPoint;)I\n 244: ireturn\n}\n",
"javap_err": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day11.kt
|
import kotlin.math.pow
data class Modifier(val op: Char, val value: Int)
data class Condition(val divisibleBy: Int, val ifTrue: Int, val ifFalse: Int)
data class Monkey(
val index: Int,
val queue: MutableList<Long>,
val modifier: Modifier,
val condition: Condition,
var inspectionCount: Long
)
fun main() {
fun parse(input: List<String>): List<Monkey> {
val chunks = input.chunked(7)
return chunks.map { it ->
val index = it[0].toInt()
val items = it[1].split(',').map { x -> x.toLong() }.toMutableList()
val modifierParts = it[2].split(' ')
val modifier = Modifier(modifierParts[0][0], modifierParts[1].toInt())
val divisibleBy = it[3].toInt()
val ifTrue = it[4].toInt()
val ifFalse = it[5].toInt()
val condition = Condition(divisibleBy, ifTrue, ifFalse)
Monkey(index, items, modifier, condition, 0)
}
}
fun applyModifier(value: Long, modifier: Modifier): Long {
return when (modifier.op) {
'^' -> value.toDouble().pow(modifier.value.toDouble()).toLong()
'+' -> value + modifier.value
'*' -> value * modifier.value
else -> throw RuntimeException("Unknown modifier $modifier")
}
}
fun applyCondition(value: Long, condition: Condition): Int {
return if (value % condition.divisibleBy == 0L) condition.ifTrue else condition.ifFalse
}
fun printState(monkeys: List<Monkey>) {
for (monkey in monkeys) {
println("Monkey ${monkey.index}: ${monkey.queue}")
}
}
fun printCounts(monkeys: List<Monkey>) {
for (monkey in monkeys) {
println("Monkey ${monkey.index}: ${monkey.inspectionCount}")
}
}
fun play(monkeys: List<Monkey>, iterationsCount: Int, worryReducer: (v: Long) -> Long) {
val overflowBreaker = monkeys.map { it.condition.divisibleBy }.reduce { acc, i -> acc * i }
for (i in 1..iterationsCount) {
for (monkey in monkeys) {
for (item in monkey.queue) {
val worryLevel = applyModifier(item, monkey.modifier)
val newLevel = worryReducer(worryLevel) % overflowBreaker
val newIndex = applyCondition(newLevel, monkey.condition)
monkeys[newIndex].queue.add(newLevel)
++monkey.inspectionCount
}
monkey.queue.clear()
}
if (i % 20 == 0){
println("Iteration $i")
printCounts(monkeys)
println()
}
}
}
fun calculateResult(monkeys: List<Monkey>): Long {
val ordered = monkeys.sortedBy { -it.inspectionCount }
return ordered[0].inspectionCount * ordered[1].inspectionCount
}
fun part1(input: List<String>): Long {
val monkeys = parse(input)
play(monkeys, 20) { x -> x / 3 }
return calculateResult(monkeys)
}
fun part2(input: List<String>): Long {
val monkeys = parse(input)
play(monkeys, 10000) { x -> x }
return calculateResult(monkeys)
}
val testInput = readInput("Day11_test")
assert(part1(testInput), 10605L)
assert(part2(testInput), 2713310158L)
val input = readInput("Day11")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day11Kt$main$calculateResult$$inlined$sortedBy$1.class",
"javap": "Compiled from \"Comparisons.kt\"\npublic final class Day11Kt$main$calculateResult$$inlined$sortedBy$1<T> implements java.util.Comparator {\n public Day11Kt$main$calculateResult$$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:()J\n 12: lneg\n 13: invokestatic #33 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 16: checkcast #35 // class java/lang/Comparable\n 19: aload_2\n 20: checkcast #23 // class Monkey\n 23: astore_3\n 24: astore 5\n 26: iconst_0\n 27: istore 4\n 29: aload_3\n 30: invokevirtual #27 // Method Monkey.getInspectionCount:()J\n 33: lneg\n 34: invokestatic #33 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 37: aload 5\n 39: swap\n 40: checkcast #35 // class java/lang/Comparable\n 43: invokestatic #41 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I\n 46: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day11Kt.class",
"javap": "Compiled from \"Day11.kt\"\npublic final class Day11Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day11_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method main$part1:(Ljava/util/List;)J\n 10: invokestatic #24 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 13: ldc2_w #25 // long 10605l\n 16: invokestatic #24 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 19: invokestatic #30 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 22: aload_0\n 23: invokestatic #33 // Method main$part2:(Ljava/util/List;)J\n 26: invokestatic #24 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 29: ldc2_w #34 // long 2713310158l\n 32: invokestatic #24 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 35: invokestatic #30 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 38: ldc #37 // String Day11\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;)J\n 48: lstore_2\n 49: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 52: lload_2\n 53: invokevirtual #49 // Method java/io/PrintStream.println:(J)V\n 56: aload_1\n 57: invokestatic #33 // Method main$part2:(Ljava/util/List;)J\n 60: lstore_2\n 61: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 64: lload_2\n 65: invokevirtual #49 // Method java/io/PrintStream.println:(J)V\n 68: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #55 // Method main:()V\n 3: return\n\n private static final java.util.List<Monkey> main$parse(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #62 // class java/lang/Iterable\n 4: bipush 7\n 6: invokestatic #68 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;\n 9: astore_1\n 10: aload_1\n 11: checkcast #62 // 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 #70 // class java/util/ArrayList\n 23: dup\n 24: aload_2\n 25: bipush 10\n 27: invokestatic #74 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 30: invokespecial #78 // Method java/util/ArrayList.\"<init>\":(I)V\n 33: checkcast #80 // class java/util/Collection\n 36: astore 5\n 38: iconst_0\n 39: istore 6\n 41: aload 4\n 43: invokeinterface #84, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 48: astore 7\n 50: aload 7\n 52: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 57: ifeq 405\n 60: aload 7\n 62: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 67: astore 8\n 69: aload 5\n 71: aload 8\n 73: checkcast #96 // class java/util/List\n 76: astore 9\n 78: astore 23\n 80: iconst_0\n 81: istore 10\n 83: aload 9\n 85: iconst_0\n 86: invokeinterface #100, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 91: checkcast #102 // class java/lang/String\n 94: invokestatic #108 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 97: istore 11\n 99: aload 9\n 101: iconst_1\n 102: invokeinterface #100, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 107: checkcast #110 // class java/lang/CharSequence\n 110: iconst_1\n 111: newarray char\n 113: astore 12\n 115: aload 12\n 117: iconst_0\n 118: bipush 44\n 120: castore\n 121: aload 12\n 123: iconst_0\n 124: iconst_0\n 125: bipush 6\n 127: aconst_null\n 128: invokestatic #116 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 131: checkcast #62 // class java/lang/Iterable\n 134: astore 12\n 136: iconst_0\n 137: istore 13\n 139: aload 12\n 141: astore 14\n 143: new #70 // class java/util/ArrayList\n 146: dup\n 147: aload 12\n 149: bipush 10\n 151: invokestatic #74 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 154: invokespecial #78 // Method java/util/ArrayList.\"<init>\":(I)V\n 157: checkcast #80 // class java/util/Collection\n 160: astore 15\n 162: iconst_0\n 163: istore 16\n 165: aload 14\n 167: invokeinterface #84, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 172: astore 17\n 174: aload 17\n 176: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 181: ifeq 228\n 184: aload 17\n 186: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 191: astore 18\n 193: aload 15\n 195: aload 18\n 197: checkcast #102 // class java/lang/String\n 200: astore 19\n 202: astore 20\n 204: iconst_0\n 205: istore 21\n 207: aload 19\n 209: invokestatic #120 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 212: nop\n 213: invokestatic #24 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 216: aload 20\n 218: swap\n 219: invokeinterface #124, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 224: pop\n 225: goto 174\n 228: aload 15\n 230: checkcast #96 // class java/util/List\n 233: nop\n 234: checkcast #80 // class java/util/Collection\n 237: invokestatic #128 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 240: astore 22\n 242: aload 9\n 244: iconst_2\n 245: invokeinterface #100, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 250: checkcast #110 // class java/lang/CharSequence\n 253: iconst_1\n 254: newarray char\n 256: astore 13\n 258: aload 13\n 260: iconst_0\n 261: bipush 32\n 263: castore\n 264: aload 13\n 266: iconst_0\n 267: iconst_0\n 268: bipush 6\n 270: aconst_null\n 271: invokestatic #116 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 274: astore 12\n 276: new #130 // class Modifier\n 279: dup\n 280: aload 12\n 282: iconst_0\n 283: invokeinterface #100, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 288: checkcast #102 // class java/lang/String\n 291: iconst_0\n 292: invokevirtual #134 // Method java/lang/String.charAt:(I)C\n 295: aload 12\n 297: iconst_1\n 298: invokeinterface #100, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 303: checkcast #102 // class java/lang/String\n 306: invokestatic #108 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 309: invokespecial #137 // Method Modifier.\"<init>\":(CI)V\n 312: astore 13\n 314: aload 9\n 316: iconst_3\n 317: invokeinterface #100, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 322: checkcast #102 // class java/lang/String\n 325: invokestatic #108 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 328: istore 14\n 330: aload 9\n 332: iconst_4\n 333: invokeinterface #100, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 338: checkcast #102 // class java/lang/String\n 341: invokestatic #108 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 344: istore 15\n 346: aload 9\n 348: iconst_5\n 349: invokeinterface #100, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 354: checkcast #102 // class java/lang/String\n 357: invokestatic #108 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 360: istore 16\n 362: new #139 // class Condition\n 365: dup\n 366: iload 14\n 368: iload 15\n 370: iload 16\n 372: invokespecial #142 // Method Condition.\"<init>\":(III)V\n 375: astore 17\n 377: new #144 // class Monkey\n 380: dup\n 381: iload 11\n 383: aload 22\n 385: aload 13\n 387: aload 17\n 389: lconst_0\n 390: invokespecial #147 // Method Monkey.\"<init>\":(ILjava/util/List;LModifier;LCondition;J)V\n 393: aload 23\n 395: swap\n 396: invokeinterface #124, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 401: pop\n 402: goto 50\n 405: aload 5\n 407: checkcast #96 // class java/util/List\n 410: nop\n 411: areturn\n\n private static final long main$applyModifier(long, Modifier);\n Code:\n 0: aload_2\n 1: invokevirtual #179 // Method Modifier.getOp:()C\n 4: lookupswitch { // 3\n 42: 64\n 43: 54\n 94: 40\n default: 74\n }\n 40: lload_0\n 41: l2d\n 42: aload_2\n 43: invokevirtual #183 // Method Modifier.getValue:()I\n 46: i2d\n 47: invokestatic #189 // Method java/lang/Math.pow:(DD)D\n 50: d2l\n 51: goto 101\n 54: lload_0\n 55: aload_2\n 56: invokevirtual #183 // Method Modifier.getValue:()I\n 59: i2l\n 60: ladd\n 61: goto 101\n 64: lload_0\n 65: aload_2\n 66: invokevirtual #183 // Method Modifier.getValue:()I\n 69: i2l\n 70: lmul\n 71: goto 101\n 74: new #191 // class java/lang/RuntimeException\n 77: dup\n 78: new #193 // class java/lang/StringBuilder\n 81: dup\n 82: invokespecial #195 // Method java/lang/StringBuilder.\"<init>\":()V\n 85: ldc #197 // String Unknown modifier\n 87: invokevirtual #201 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 90: aload_2\n 91: invokevirtual #204 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 94: invokevirtual #208 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 97: invokespecial #211 // Method java/lang/RuntimeException.\"<init>\":(Ljava/lang/String;)V\n 100: athrow\n 101: lreturn\n\n private static final int main$applyCondition(long, Condition);\n Code:\n 0: lload_0\n 1: aload_2\n 2: invokevirtual #218 // Method Condition.getDivisibleBy:()I\n 5: i2l\n 6: lrem\n 7: lconst_0\n 8: lcmp\n 9: ifne 19\n 12: aload_2\n 13: invokevirtual #221 // Method Condition.getIfTrue:()I\n 16: goto 23\n 19: aload_2\n 20: invokevirtual #224 // Method Condition.getIfFalse:()I\n 23: ireturn\n\n private static final void main$printState(java.util.List<Monkey>);\n Code:\n 0: aload_0\n 1: invokeinterface #228, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 6: astore_1\n 7: aload_1\n 8: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 13: ifeq 70\n 16: aload_1\n 17: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 22: checkcast #144 // class Monkey\n 25: astore_2\n 26: new #193 // class java/lang/StringBuilder\n 29: dup\n 30: invokespecial #195 // Method java/lang/StringBuilder.\"<init>\":()V\n 33: ldc #230 // String Monkey\n 35: invokevirtual #201 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 38: aload_2\n 39: invokevirtual #233 // Method Monkey.getIndex:()I\n 42: invokevirtual #236 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 45: ldc #238 // String :\n 47: invokevirtual #201 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 50: aload_2\n 51: invokevirtual #242 // Method Monkey.getQueue:()Ljava/util/List;\n 54: invokevirtual #204 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 57: invokevirtual #208 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 60: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 63: swap\n 64: invokevirtual #245 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 67: goto 7\n 70: return\n\n private static final void main$printCounts(java.util.List<Monkey>);\n Code:\n 0: aload_0\n 1: invokeinterface #228, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 6: astore_1\n 7: aload_1\n 8: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 13: ifeq 70\n 16: aload_1\n 17: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 22: checkcast #144 // class Monkey\n 25: astore_2\n 26: new #193 // class java/lang/StringBuilder\n 29: dup\n 30: invokespecial #195 // Method java/lang/StringBuilder.\"<init>\":()V\n 33: ldc #230 // String Monkey\n 35: invokevirtual #201 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 38: aload_2\n 39: invokevirtual #233 // Method Monkey.getIndex:()I\n 42: invokevirtual #236 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 45: ldc #238 // String :\n 47: invokevirtual #201 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 50: aload_2\n 51: invokevirtual #253 // Method Monkey.getInspectionCount:()J\n 54: invokevirtual #256 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 57: invokevirtual #208 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 60: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 63: swap\n 64: invokevirtual #245 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 67: goto 7\n 70: return\n\n private static final void main$play(java.util.List<Monkey>, int, kotlin.jvm.functions.Function1<? super java.lang.Long, java.lang.Long>);\n Code:\n 0: aload_0\n 1: checkcast #62 // class java/lang/Iterable\n 4: astore 4\n 6: iconst_0\n 7: istore 5\n 9: aload 4\n 11: astore 6\n 13: new #70 // class java/util/ArrayList\n 16: dup\n 17: aload 4\n 19: bipush 10\n 21: invokestatic #74 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 24: invokespecial #78 // Method java/util/ArrayList.\"<init>\":(I)V\n 27: checkcast #80 // class java/util/Collection\n 30: astore 7\n 32: iconst_0\n 33: istore 8\n 35: aload 6\n 37: invokeinterface #84, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 9\n 44: aload 9\n 46: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 100\n 54: aload 9\n 56: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 10\n 63: aload 7\n 65: aload 10\n 67: checkcast #144 // class Monkey\n 70: astore 11\n 72: astore 15\n 74: iconst_0\n 75: istore 12\n 77: aload 11\n 79: invokevirtual #263 // Method Monkey.getCondition:()LCondition;\n 82: invokevirtual #218 // Method Condition.getDivisibleBy:()I\n 85: invokestatic #266 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 88: aload 15\n 90: swap\n 91: invokeinterface #124, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 96: pop\n 97: goto 44\n 100: aload 7\n 102: checkcast #96 // class java/util/List\n 105: nop\n 106: checkcast #62 // class java/lang/Iterable\n 109: astore 4\n 111: nop\n 112: iconst_0\n 113: istore 5\n 115: aload 4\n 117: invokeinterface #84, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 122: astore 6\n 124: aload 6\n 126: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 131: ifne 145\n 134: new #268 // class java/lang/UnsupportedOperationException\n 137: dup\n 138: ldc_w #270 // String Empty collection can\\'t be reduced.\n 141: invokespecial #271 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 144: athrow\n 145: aload 6\n 147: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 152: astore 7\n 154: aload 6\n 156: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 161: ifeq 205\n 164: aload 7\n 166: aload 6\n 168: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 173: checkcast #273 // class java/lang/Number\n 176: invokevirtual #276 // Method java/lang/Number.intValue:()I\n 179: istore 8\n 181: checkcast #273 // class java/lang/Number\n 184: invokevirtual #276 // Method java/lang/Number.intValue:()I\n 187: istore 9\n 189: iconst_0\n 190: istore 10\n 192: iload 9\n 194: iload 8\n 196: imul\n 197: invokestatic #266 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 200: astore 7\n 202: goto 154\n 205: aload 7\n 207: checkcast #273 // class java/lang/Number\n 210: invokevirtual #276 // Method java/lang/Number.intValue:()I\n 213: istore_3\n 214: iconst_1\n 215: istore 4\n 217: iload 4\n 219: iload_1\n 220: if_icmpgt 453\n 223: aload_0\n 224: invokeinterface #228, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 229: astore 5\n 231: aload 5\n 233: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 238: ifeq 395\n 241: aload 5\n 243: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 248: checkcast #144 // class Monkey\n 251: astore 6\n 253: aload 6\n 255: invokevirtual #242 // Method Monkey.getQueue:()Ljava/util/List;\n 258: invokeinterface #228, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 263: astore 7\n 265: aload 7\n 267: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 272: ifeq 382\n 275: aload 7\n 277: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 282: checkcast #273 // class java/lang/Number\n 285: invokevirtual #279 // Method java/lang/Number.longValue:()J\n 288: lstore 8\n 290: lload 8\n 292: aload 6\n 294: invokevirtual #283 // Method Monkey.getModifier:()LModifier;\n 297: invokestatic #285 // Method main$applyModifier:(JLModifier;)J\n 300: lstore 10\n 302: aload_2\n 303: lload 10\n 305: invokestatic #24 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 308: invokeinterface #291, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 313: checkcast #273 // class java/lang/Number\n 316: invokevirtual #279 // Method java/lang/Number.longValue:()J\n 319: iload_3\n 320: i2l\n 321: lrem\n 322: lstore 12\n 324: lload 12\n 326: aload 6\n 328: invokevirtual #263 // Method Monkey.getCondition:()LCondition;\n 331: invokestatic #293 // Method main$applyCondition:(JLCondition;)I\n 334: istore 14\n 336: aload_0\n 337: iload 14\n 339: invokeinterface #100, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 344: checkcast #144 // class Monkey\n 347: invokevirtual #242 // Method Monkey.getQueue:()Ljava/util/List;\n 350: lload 12\n 352: invokestatic #24 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 355: invokeinterface #294, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 360: pop\n 361: aload 6\n 363: aload 6\n 365: invokevirtual #253 // Method Monkey.getInspectionCount:()J\n 368: lconst_1\n 369: ladd\n 370: invokevirtual #297 // Method Monkey.setInspectionCount:(J)V\n 373: aload 6\n 375: invokevirtual #253 // Method Monkey.getInspectionCount:()J\n 378: pop2\n 379: goto 265\n 382: aload 6\n 384: invokevirtual #242 // Method Monkey.getQueue:()Ljava/util/List;\n 387: invokeinterface #300, 1 // InterfaceMethod java/util/List.clear:()V\n 392: goto 231\n 395: iload 4\n 397: bipush 20\n 399: irem\n 400: ifne 441\n 403: new #193 // class java/lang/StringBuilder\n 406: dup\n 407: invokespecial #195 // Method java/lang/StringBuilder.\"<init>\":()V\n 410: ldc_w #302 // String Iteration\n 413: invokevirtual #201 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 416: iload 4\n 418: invokevirtual #236 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 421: invokevirtual #208 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 424: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 427: swap\n 428: invokevirtual #245 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 431: aload_0\n 432: invokestatic #304 // Method main$printCounts:(Ljava/util/List;)V\n 435: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 438: invokevirtual #306 // Method java/io/PrintStream.println:()V\n 441: iload 4\n 443: iload_1\n 444: if_icmpeq 453\n 447: iinc 4, 1\n 450: goto 223\n 453: return\n\n private static final long main$calculateResult(java.util.List<Monkey>);\n Code:\n 0: aload_0\n 1: checkcast #62 // class java/lang/Iterable\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: aload_2\n 8: new #327 // class Day11Kt$main$calculateResult$$inlined$sortedBy$1\n 11: dup\n 12: invokespecial #328 // Method Day11Kt$main$calculateResult$$inlined$sortedBy$1.\"<init>\":()V\n 15: checkcast #330 // class java/util/Comparator\n 18: invokestatic #334 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 21: astore_1\n 22: aload_1\n 23: iconst_0\n 24: invokeinterface #100, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 29: checkcast #144 // class Monkey\n 32: invokevirtual #253 // Method Monkey.getInspectionCount:()J\n 35: aload_1\n 36: iconst_1\n 37: invokeinterface #100, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 42: checkcast #144 // class Monkey\n 45: invokevirtual #253 // Method Monkey.getInspectionCount:()J\n 48: lmul\n 49: lreturn\n\n private static final long main$part1$lambda$5(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<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #342 // Method main$parse:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: aload_1\n 6: bipush 20\n 8: invokedynamic #358, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 13: invokestatic #360 // Method main$play:(Ljava/util/List;ILkotlin/jvm/functions/Function1;)V\n 16: aload_1\n 17: invokestatic #362 // Method main$calculateResult:(Ljava/util/List;)J\n 20: lreturn\n\n private static final long main$part2$lambda$6(long);\n Code:\n 0: lload_0\n 1: lreturn\n\n private static final long main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #342 // Method main$parse:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: aload_1\n 6: sipush 10000\n 9: invokedynamic #367, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 14: invokestatic #360 // Method main$play:(Ljava/util/List;ILkotlin/jvm/functions/Function1;)V\n 17: aload_1\n 18: invokestatic #362 // Method main$calculateResult:(Ljava/util/List;)J\n 21: lreturn\n}\n",
"javap_err": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day10.kt
|
class Operation(val cycles: Int, val add: Int)
fun main() {
fun parse(input: List<String>): List<Operation> {
return input.map { line ->
if (line == "noop") {
Operation(1, 0)
} else {
val modifier = line.split(' ')[1].toInt()
Operation(2, modifier)
}
}
}
fun part1(input: List<String>): Long {
val ops = parse(input)
var x = 1
var result = 0L
val maxIndex = 220
var seekIndex = 20
val hop = 40
var cycleCounter = 0
for (op in ops) {
for (cycle in 1..op.cycles) {
++cycleCounter
if (cycleCounter == seekIndex) {
result += x * seekIndex
if (seekIndex == maxIndex) {
return result
}
seekIndex += hop
}
}
x += op.add
}
return result
}
fun isSprite(cycleCounter: Int, x: Int, lineIndex: Int, hop: Int): Boolean {
val lineValue = cycleCounter - (hop * lineIndex)
return lineValue >= x - 1 && lineValue <= x + 1
}
fun part2(input: List<String>): Long {
val ops = parse(input)
var x = 1
var lineIndex = 0
val maxIndex = 240
var seekIndex = 40
val hop = 40
var cycleCounter = 0
for (op in ops) {
for (cycle in 1..op.cycles) {
if (isSprite(cycleCounter, x, lineIndex, hop)) {
print("#")
} else {
print(".")
}
++cycleCounter
if (cycleCounter == seekIndex) {
println()
if (seekIndex == maxIndex) {
return 0
}
seekIndex += hop
++lineIndex
}
}
x += op.add
}
return 0
}
val testInput = readInput("Day10_test")
assert(part1(testInput), 13140L)
val input = readInput("Day10")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/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;)J\n 10: invokestatic #24 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 13: ldc2_w #25 // long 13140l\n 16: invokestatic #24 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 19: invokestatic #30 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 22: ldc #32 // String Day10\n 24: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 27: astore_1\n 28: aload_1\n 29: invokestatic #18 // Method main$part1:(Ljava/util/List;)J\n 32: lstore_2\n 33: getstatic #38 // Field java/lang/System.out:Ljava/io/PrintStream;\n 36: lload_2\n 37: invokevirtual #44 // Method java/io/PrintStream.println:(J)V\n 40: aload_1\n 41: invokestatic #47 // Method main$part2:(Ljava/util/List;)J\n 44: lstore_2\n 45: getstatic #38 // Field java/lang/System.out:Ljava/io/PrintStream;\n 48: lload_2\n 49: invokevirtual #44 // Method java/io/PrintStream.println:(J)V\n 52: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #53 // Method main:()V\n 3: return\n\n private static final java.util.List<Operation> main$parse(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #60 // 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 #62 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #68 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #72 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #74 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #78, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 156\n 48: aload 6\n 50: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #90 // class java/lang/String\n 64: astore 8\n 66: astore 12\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: ldc #92 // String noop\n 75: invokestatic #98 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 78: ifeq 93\n 81: new #100 // class Operation\n 84: dup\n 85: iconst_1\n 86: iconst_0\n 87: invokespecial #103 // Method Operation.\"<init>\":(II)V\n 90: goto 143\n 93: aload 8\n 95: checkcast #105 // class java/lang/CharSequence\n 98: iconst_1\n 99: newarray char\n 101: astore 10\n 103: aload 10\n 105: iconst_0\n 106: bipush 32\n 108: castore\n 109: aload 10\n 111: iconst_0\n 112: iconst_0\n 113: bipush 6\n 115: aconst_null\n 116: invokestatic #111 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 119: iconst_1\n 120: invokeinterface #117, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 125: checkcast #90 // class java/lang/String\n 128: invokestatic #123 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 131: istore 11\n 133: new #100 // class Operation\n 136: dup\n 137: iconst_2\n 138: iload 11\n 140: invokespecial #103 // Method Operation.\"<init>\":(II)V\n 143: nop\n 144: aload 12\n 146: swap\n 147: invokeinterface #127, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 152: pop\n 153: goto 38\n 156: aload 4\n 158: checkcast #113 // class java/util/List\n 161: nop\n 162: areturn\n\n private static final long main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #144 // Method main$parse:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: iconst_1\n 6: istore_2\n 7: lconst_0\n 8: lstore_3\n 9: sipush 220\n 12: istore 5\n 14: bipush 20\n 16: istore 6\n 18: bipush 40\n 20: istore 7\n 22: iconst_0\n 23: istore 8\n 25: aload_1\n 26: invokeinterface #145, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 31: astore 9\n 33: aload 9\n 35: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 40: ifeq 130\n 43: aload 9\n 45: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 50: checkcast #100 // class Operation\n 53: astore 10\n 55: iconst_1\n 56: istore 11\n 58: aload 10\n 60: invokevirtual #149 // Method Operation.getCycles:()I\n 63: istore 12\n 65: iload 11\n 67: iload 12\n 69: if_icmpgt 119\n 72: iinc 8, 1\n 75: iload 8\n 77: iload 6\n 79: if_icmpne 106\n 82: lload_3\n 83: iload_2\n 84: iload 6\n 86: imul\n 87: i2l\n 88: ladd\n 89: lstore_3\n 90: iload 6\n 92: iload 5\n 94: if_icmpne 99\n 97: lload_3\n 98: lreturn\n 99: iload 6\n 101: iload 7\n 103: iadd\n 104: istore 6\n 106: iload 11\n 108: iload 12\n 110: if_icmpeq 119\n 113: iinc 11, 1\n 116: goto 72\n 119: iload_2\n 120: aload 10\n 122: invokevirtual #152 // Method Operation.getAdd:()I\n 125: iadd\n 126: istore_2\n 127: goto 33\n 130: lload_3\n 131: lreturn\n\n private static final boolean main$isSprite(int, int, int, int);\n Code:\n 0: iload_0\n 1: iload_3\n 2: iload_2\n 3: imul\n 4: isub\n 5: istore 4\n 7: iload 4\n 9: iload_1\n 10: iconst_1\n 11: isub\n 12: if_icmplt 27\n 15: iload 4\n 17: iload_1\n 18: iconst_1\n 19: iadd\n 20: if_icmpgt 27\n 23: iconst_1\n 24: goto 28\n 27: iconst_0\n 28: ireturn\n\n private static final long main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #144 // Method main$parse:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: iconst_1\n 6: istore_2\n 7: iconst_0\n 8: istore_3\n 9: sipush 240\n 12: istore 4\n 14: bipush 40\n 16: istore 5\n 18: bipush 40\n 20: istore 6\n 22: iconst_0\n 23: istore 7\n 25: aload_1\n 26: invokeinterface #145, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 31: astore 8\n 33: aload 8\n 35: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 40: ifeq 164\n 43: aload 8\n 45: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 50: checkcast #100 // class Operation\n 53: astore 9\n 55: iconst_1\n 56: istore 10\n 58: aload 9\n 60: invokevirtual #149 // Method Operation.getCycles:()I\n 63: istore 11\n 65: iload 10\n 67: iload 11\n 69: if_icmpgt 153\n 72: iload 7\n 74: iload_2\n 75: iload_3\n 76: iload 6\n 78: invokestatic #169 // Method main$isSprite:(IIII)Z\n 81: ifeq 96\n 84: ldc #171 // String #\n 86: getstatic #38 // Field java/lang/System.out:Ljava/io/PrintStream;\n 89: swap\n 90: invokevirtual #175 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 93: goto 105\n 96: ldc #177 // String .\n 98: getstatic #38 // Field java/lang/System.out:Ljava/io/PrintStream;\n 101: swap\n 102: invokevirtual #175 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 105: iinc 7, 1\n 108: iload 7\n 110: iload 5\n 112: if_icmpne 140\n 115: getstatic #38 // Field java/lang/System.out:Ljava/io/PrintStream;\n 118: invokevirtual #179 // Method java/io/PrintStream.println:()V\n 121: iload 5\n 123: iload 4\n 125: if_icmpne 130\n 128: lconst_0\n 129: lreturn\n 130: iload 5\n 132: iload 6\n 134: iadd\n 135: istore 5\n 137: iinc 3, 1\n 140: iload 10\n 142: iload 11\n 144: if_icmpeq 153\n 147: iinc 10, 1\n 150: goto 72\n 153: iload_2\n 154: aload 9\n 156: invokevirtual #152 // Method Operation.getAdd:()I\n 159: iadd\n 160: istore_2\n 161: goto 33\n 164: lconst_0\n 165: lreturn\n}\n",
"javap_err": ""
}
] |
kipwoker__aoc2022__d8aeea8/src/Day08.kt
|
import kotlin.math.max
class Tree(val value: Int, var visible: Boolean)
fun main() {
fun parse(input: List<String>): List<List<Tree>> {
return input.map { line ->
line.toCharArray().map {
Tree(it.digitToInt(), false)
}
}
}
fun findVisible(trees: List<List<Tree>>): Int {
val size = trees.size
val lastIdx = size - 1
for (i in 0..lastIdx) {
var maxLeft = -1
var maxRight = -1
for (j in 0..lastIdx) {
val cellLeft = trees[i][j]
if (cellLeft.value > maxLeft) {
cellLeft.visible = true
maxLeft = cellLeft.value
}
val cellRight = trees[i][lastIdx - j]
if (cellRight.value > maxRight) {
cellRight.visible = true
maxRight = cellRight.value
}
}
}
for (i in 0..lastIdx) {
var maxTop = -1
var maxBottom = -1
for (j in 0..lastIdx) {
val cellTop = trees[j][i]
if (cellTop.value > maxTop) {
cellTop.visible = true
maxTop = cellTop.value
}
val cellBottom = trees[lastIdx - j][i]
if (cellBottom.value > maxBottom) {
cellBottom.visible = true
maxBottom = cellBottom.value
}
}
}
return trees.sumOf { x -> x.count { y -> y.visible } }
}
fun findMax(center: Int, range: IntProgression, getter: (x: Int) -> Tree): Int {
var count = 0
for (i in range) {
val cell = getter(i)
if (cell.value >= center) {
return count + 1
}
++count
}
return count
}
fun findScenic(trees: List<List<Tree>>): Int {
val size = trees.size
val lastIdx = size - 1
var maxScenic = -1
for (i in 0..lastIdx) {
for (j in 0..lastIdx) {
val center = trees[i][j].value
val left = findMax(center, j - 1 downTo 0) { x -> trees[i][x] }
val right = findMax(center, j + 1..lastIdx) { x -> trees[i][x] }
val top = findMax(center, i - 1 downTo 0) { x -> trees[x][j] }
val bottom = findMax(center, i + 1..lastIdx) { x -> trees[x][j] }
val scenic = top * left * bottom * right
maxScenic = max(scenic, maxScenic)
}
}
return maxScenic
}
fun part1(input: List<String>): Int {
val trees = parse(input)
return findVisible(trees)
}
fun part2(input: List<String>): Int {
val trees = parse(input)
return findScenic(trees)
}
val testInput = readInput("Day08_test")
assert(part1(testInput), 21)
assert(part2(testInput), 8)
val input = readInput("Day08")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "kipwoker__aoc2022__d8aeea8/Day08Kt.class",
"javap": "Compiled from \"Day08.kt\"\npublic final class Day08Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day08_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 10: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 13: bipush 21\n 15: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 18: invokestatic #28 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 21: aload_0\n 22: invokestatic #31 // Method main$part2:(Ljava/util/List;)I\n 25: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 28: bipush 8\n 30: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 33: invokestatic #28 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V\n 36: ldc #33 // String Day08\n 38: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 41: astore_1\n 42: aload_1\n 43: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 46: istore_2\n 47: getstatic #39 // Field java/lang/System.out:Ljava/io/PrintStream;\n 50: iload_2\n 51: invokevirtual #45 // Method java/io/PrintStream.println:(I)V\n 54: aload_1\n 55: invokestatic #31 // Method main$part2:(Ljava/util/List;)I\n 58: istore_2\n 59: getstatic #39 // Field java/lang/System.out:Ljava/io/PrintStream;\n 62: iload_2\n 63: invokevirtual #45 // Method java/io/PrintStream.println:(I)V\n 66: 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 java.util.List<java.util.List<Tree>> main$parse(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #58 // 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 #60 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #66 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #69 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #71 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 190\n 48: aload 6\n 50: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #87 // 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: invokevirtual #91 // Method java/lang/String.toCharArray:()[C\n 76: dup\n 77: ldc #93 // String toCharArray(...)\n 79: invokestatic #99 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 82: astore 10\n 84: nop\n 85: iconst_0\n 86: istore 11\n 88: aload 10\n 90: astore 12\n 92: new #60 // class java/util/ArrayList\n 95: dup\n 96: aload 10\n 98: arraylength\n 99: invokespecial #69 // Method java/util/ArrayList.\"<init>\":(I)V\n 102: checkcast #71 // class java/util/Collection\n 105: astore 13\n 107: iconst_0\n 108: istore 14\n 110: iconst_0\n 111: istore 15\n 113: aload 12\n 115: arraylength\n 116: istore 16\n 118: iload 15\n 120: iload 16\n 122: if_icmpge 171\n 125: aload 12\n 127: iload 15\n 129: caload\n 130: istore 17\n 132: aload 13\n 134: iload 17\n 136: istore 18\n 138: astore 19\n 140: iconst_0\n 141: istore 20\n 143: new #101 // class Tree\n 146: dup\n 147: iload 18\n 149: invokestatic #107 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 152: iconst_0\n 153: invokespecial #110 // Method Tree.\"<init>\":(IZ)V\n 156: aload 19\n 158: swap\n 159: invokeinterface #114, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 164: pop\n 165: iinc 15, 1\n 168: goto 118\n 171: aload 13\n 173: checkcast #116 // class java/util/List\n 176: nop\n 177: nop\n 178: aload 21\n 180: swap\n 181: invokeinterface #114, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 186: pop\n 187: goto 38\n 190: aload 4\n 192: checkcast #116 // class java/util/List\n 195: nop\n 196: areturn\n\n private static final int main$findVisible(java.util.List<? extends java.util.List<Tree>>);\n Code:\n 0: aload_0\n 1: invokeinterface #140, 1 // InterfaceMethod java/util/List.size:()I\n 6: istore_1\n 7: iload_1\n 8: iconst_1\n 9: isub\n 10: istore_2\n 11: iconst_0\n 12: istore_3\n 13: iload_3\n 14: iload_2\n 15: if_icmpgt 148\n 18: iconst_m1\n 19: istore 4\n 21: iconst_m1\n 22: istore 5\n 24: iconst_0\n 25: istore 6\n 27: iload 6\n 29: iload_2\n 30: if_icmpgt 137\n 33: aload_0\n 34: iload_3\n 35: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 40: checkcast #116 // class java/util/List\n 43: iload 6\n 45: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 50: checkcast #101 // class Tree\n 53: astore 7\n 55: aload 7\n 57: invokevirtual #147 // Method Tree.getValue:()I\n 60: iload 4\n 62: if_icmple 78\n 65: aload 7\n 67: iconst_1\n 68: invokevirtual #151 // Method Tree.setVisible:(Z)V\n 71: aload 7\n 73: invokevirtual #147 // Method Tree.getValue:()I\n 76: istore 4\n 78: aload_0\n 79: iload_3\n 80: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 85: checkcast #116 // class java/util/List\n 88: iload_2\n 89: iload 6\n 91: isub\n 92: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 97: checkcast #101 // class Tree\n 100: astore 8\n 102: aload 8\n 104: invokevirtual #147 // Method Tree.getValue:()I\n 107: iload 5\n 109: if_icmple 125\n 112: aload 8\n 114: iconst_1\n 115: invokevirtual #151 // Method Tree.setVisible:(Z)V\n 118: aload 8\n 120: invokevirtual #147 // Method Tree.getValue:()I\n 123: istore 5\n 125: iload 6\n 127: iload_2\n 128: if_icmpeq 137\n 131: iinc 6, 1\n 134: goto 33\n 137: iload_3\n 138: iload_2\n 139: if_icmpeq 148\n 142: iinc 3, 1\n 145: goto 18\n 148: iconst_0\n 149: istore_3\n 150: iload_3\n 151: iload_2\n 152: if_icmpgt 285\n 155: iconst_m1\n 156: istore 4\n 158: iconst_m1\n 159: istore 5\n 161: iconst_0\n 162: istore 6\n 164: iload 6\n 166: iload_2\n 167: if_icmpgt 274\n 170: aload_0\n 171: iload 6\n 173: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 178: checkcast #116 // class java/util/List\n 181: iload_3\n 182: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 187: checkcast #101 // class Tree\n 190: astore 7\n 192: aload 7\n 194: invokevirtual #147 // Method Tree.getValue:()I\n 197: iload 4\n 199: if_icmple 215\n 202: aload 7\n 204: iconst_1\n 205: invokevirtual #151 // Method Tree.setVisible:(Z)V\n 208: aload 7\n 210: invokevirtual #147 // Method Tree.getValue:()I\n 213: istore 4\n 215: aload_0\n 216: iload_2\n 217: iload 6\n 219: isub\n 220: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 225: checkcast #116 // class java/util/List\n 228: iload_3\n 229: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 234: checkcast #101 // class Tree\n 237: astore 8\n 239: aload 8\n 241: invokevirtual #147 // Method Tree.getValue:()I\n 244: iload 5\n 246: if_icmple 262\n 249: aload 8\n 251: iconst_1\n 252: invokevirtual #151 // Method Tree.setVisible:(Z)V\n 255: aload 8\n 257: invokevirtual #147 // Method Tree.getValue:()I\n 260: istore 5\n 262: iload 6\n 264: iload_2\n 265: if_icmpeq 274\n 268: iinc 6, 1\n 271: goto 170\n 274: iload_3\n 275: iload_2\n 276: if_icmpeq 285\n 279: iinc 3, 1\n 282: goto 155\n 285: aload_0\n 286: checkcast #58 // class java/lang/Iterable\n 289: astore_3\n 290: iconst_0\n 291: istore 4\n 293: aload_3\n 294: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 299: astore 5\n 301: aload 5\n 303: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 308: ifeq 447\n 311: aload 5\n 313: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 318: astore 6\n 320: iload 4\n 322: aload 6\n 324: checkcast #116 // class java/util/List\n 327: astore 7\n 329: istore 16\n 331: iconst_0\n 332: istore 8\n 334: aload 7\n 336: checkcast #58 // class java/lang/Iterable\n 339: astore 9\n 341: iconst_0\n 342: istore 10\n 344: aload 9\n 346: instanceof #71 // class java/util/Collection\n 349: ifeq 369\n 352: aload 9\n 354: checkcast #71 // class java/util/Collection\n 357: invokeinterface #154, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 362: ifeq 369\n 365: iconst_0\n 366: goto 434\n 369: iconst_0\n 370: istore 11\n 372: aload 9\n 374: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 379: astore 12\n 381: aload 12\n 383: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 388: ifeq 432\n 391: aload 12\n 393: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 398: astore 13\n 400: aload 13\n 402: checkcast #101 // class Tree\n 405: astore 14\n 407: iconst_0\n 408: istore 15\n 410: aload 14\n 412: invokevirtual #157 // Method Tree.getVisible:()Z\n 415: ifeq 381\n 418: iinc 11, 1\n 421: iload 11\n 423: ifge 381\n 426: invokestatic #160 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 429: goto 381\n 432: iload 11\n 434: nop\n 435: istore 17\n 437: iload 16\n 439: iload 17\n 441: iadd\n 442: istore 4\n 444: goto 301\n 447: iload 4\n 449: ireturn\n\n private static final int main$findMax(int, kotlin.ranges.IntProgression, kotlin.jvm.functions.Function1<? super java.lang.Integer, Tree>);\n Code:\n 0: iconst_0\n 1: istore_3\n 2: aload_1\n 3: invokevirtual #189 // Method kotlin/ranges/IntProgression.getFirst:()I\n 6: istore 4\n 8: aload_1\n 9: invokevirtual #192 // Method kotlin/ranges/IntProgression.getLast:()I\n 12: istore 5\n 14: aload_1\n 15: invokevirtual #195 // Method kotlin/ranges/IntProgression.getStep:()I\n 18: istore 6\n 20: iload 6\n 22: ifle 32\n 25: iload 4\n 27: iload 5\n 29: if_icmple 44\n 32: iload 6\n 34: ifge 93\n 37: iload 5\n 39: iload 4\n 41: if_icmpgt 93\n 44: aload_2\n 45: iload 4\n 47: invokestatic #24 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 50: invokeinterface #201, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 55: checkcast #101 // class Tree\n 58: astore 7\n 60: aload 7\n 62: invokevirtual #147 // Method Tree.getValue:()I\n 65: iload_0\n 66: if_icmplt 73\n 69: iload_3\n 70: iconst_1\n 71: iadd\n 72: ireturn\n 73: iinc 3, 1\n 76: iload 4\n 78: iload 5\n 80: if_icmpeq 93\n 83: iload 4\n 85: iload 6\n 87: iadd\n 88: istore 4\n 90: goto 44\n 93: iload_3\n 94: ireturn\n\n private static final Tree main$findScenic$lambda$4(java.util.List, int, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #116 // class java/util/List\n 10: iload_2\n 11: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 16: checkcast #101 // class Tree\n 19: areturn\n\n private static final Tree main$findScenic$lambda$5(java.util.List, int, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #116 // class java/util/List\n 10: iload_2\n 11: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 16: checkcast #101 // class Tree\n 19: areturn\n\n private static final Tree main$findScenic$lambda$6(java.util.List, int, int);\n Code:\n 0: aload_0\n 1: iload_2\n 2: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #116 // class java/util/List\n 10: iload_1\n 11: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 16: checkcast #101 // class Tree\n 19: areturn\n\n private static final Tree main$findScenic$lambda$7(java.util.List, int, int);\n Code:\n 0: aload_0\n 1: iload_2\n 2: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #116 // class java/util/List\n 10: iload_1\n 11: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 16: checkcast #101 // class Tree\n 19: areturn\n\n private static final int main$findScenic(java.util.List<? extends java.util.List<Tree>>);\n Code:\n 0: aload_0\n 1: invokeinterface #140, 1 // InterfaceMethod java/util/List.size:()I\n 6: istore_1\n 7: iload_1\n 8: iconst_1\n 9: isub\n 10: istore_2\n 11: iconst_m1\n 12: istore_3\n 13: iconst_0\n 14: istore 4\n 16: iload 4\n 18: iload_2\n 19: if_icmpgt 207\n 22: iconst_0\n 23: istore 5\n 25: iload 5\n 27: iload_2\n 28: if_icmpgt 195\n 31: aload_0\n 32: iload 4\n 34: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 39: checkcast #116 // class java/util/List\n 42: iload 5\n 44: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 49: checkcast #101 // class Tree\n 52: invokevirtual #147 // Method Tree.getValue:()I\n 55: istore 6\n 57: iload 6\n 59: iload 5\n 61: iconst_1\n 62: isub\n 63: iconst_0\n 64: invokestatic #223 // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;\n 67: aload_0\n 68: iload 4\n 70: invokedynamic #239, 0 // InvokeDynamic #0:invoke:(Ljava/util/List;I)Lkotlin/jvm/functions/Function1;\n 75: invokestatic #241 // Method main$findMax:(ILkotlin/ranges/IntProgression;Lkotlin/jvm/functions/Function1;)I\n 78: istore 7\n 80: iload 6\n 82: new #243 // class kotlin/ranges/IntRange\n 85: dup\n 86: iload 5\n 88: iconst_1\n 89: iadd\n 90: iload_2\n 91: invokespecial #246 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 94: checkcast #186 // class kotlin/ranges/IntProgression\n 97: aload_0\n 98: iload 4\n 100: invokedynamic #250, 0 // InvokeDynamic #1:invoke:(Ljava/util/List;I)Lkotlin/jvm/functions/Function1;\n 105: invokestatic #241 // Method main$findMax:(ILkotlin/ranges/IntProgression;Lkotlin/jvm/functions/Function1;)I\n 108: istore 8\n 110: iload 6\n 112: iload 4\n 114: iconst_1\n 115: isub\n 116: iconst_0\n 117: invokestatic #223 // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;\n 120: aload_0\n 121: iload 5\n 123: invokedynamic #254, 0 // InvokeDynamic #2:invoke:(Ljava/util/List;I)Lkotlin/jvm/functions/Function1;\n 128: invokestatic #241 // Method main$findMax:(ILkotlin/ranges/IntProgression;Lkotlin/jvm/functions/Function1;)I\n 131: istore 9\n 133: iload 6\n 135: new #243 // class kotlin/ranges/IntRange\n 138: dup\n 139: iload 4\n 141: iconst_1\n 142: iadd\n 143: iload_2\n 144: invokespecial #246 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 147: checkcast #186 // class kotlin/ranges/IntProgression\n 150: aload_0\n 151: iload 5\n 153: invokedynamic #258, 0 // InvokeDynamic #3:invoke:(Ljava/util/List;I)Lkotlin/jvm/functions/Function1;\n 158: invokestatic #241 // Method main$findMax:(ILkotlin/ranges/IntProgression;Lkotlin/jvm/functions/Function1;)I\n 161: istore 10\n 163: iload 9\n 165: iload 7\n 167: imul\n 168: iload 10\n 170: imul\n 171: iload 8\n 173: imul\n 174: istore 11\n 176: iload 11\n 178: iload_3\n 179: invokestatic #264 // Method java/lang/Math.max:(II)I\n 182: istore_3\n 183: iload 5\n 185: iload_2\n 186: if_icmpeq 195\n 189: iinc 5, 1\n 192: goto 31\n 195: iload 4\n 197: iload_2\n 198: if_icmpeq 207\n 201: iinc 4, 1\n 204: goto 22\n 207: iload_3\n 208: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #273 // Method main$parse:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: aload_1\n 6: invokestatic #275 // Method main$findVisible:(Ljava/util/List;)I\n 9: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #273 // Method main$parse:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: aload_1\n 6: invokestatic #277 // Method main$findScenic:(Ljava/util/List;)I\n 9: ireturn\n}\n",
"javap_err": ""
}
] |
knivey__adventofcode__14a8a23/Day11/Day11part2.kt
|
import java.io.File
enum class Tile(val c: String) {
FLOOR("."),
FILLED("#"),
EMPTY("L"),
UNKNOWN("?");
fun from(c: Char) : Tile {
when (c) {
'.' -> return FLOOR
'#' -> return FILLED
'L' -> return EMPTY
}
return UNKNOWN;
}
override fun toString(): String {
return c
}
}
fun main() {
val map: ArrayList<ArrayList<Tile>> = File("input.txt").readLines().asSequence()
.map { line -> line.asSequence() }
.map { it.map {t -> Tile.UNKNOWN.from(t)} }
.map { it.toCollection(ArrayList()) }
.toCollection(ArrayList())
val maxY = map.size -1
val maxX = map[0].size -1
var changes = 1
var iterations = 0
while (changes != 0) {
changes = 0
val mapc = copyMap(map)
for ((y, row) in mapc.withIndex()) {
for ((x, tile) in row.withIndex()) {
if(tile == Tile.FLOOR) {
//print(".")
continue
}
var occupied : Int = 0
for(vec in genVecs(x, y, maxX, maxY)) {
for (v in vec) {
if (mapc[v.y][v.x] == Tile.FILLED) {
occupied++
break
}
if (mapc[v.y][v.x] == Tile.EMPTY) {
break
}
}
}
if(occupied >= 5)
if(tile != Tile.EMPTY) {
map[y][x] = Tile.EMPTY
changes++
}
if(occupied == 0)
if(tile != Tile.FILLED) {
map[y][x] = Tile.FILLED
changes++
}
//print(occupied)
}
//print("\n")
}
if(changes != 0)
iterations++
if(iterations > 100000) {
println("giving up");
break;
}
//println("Changed: $changes ------")
//map.forEach{ println(it.joinToString("")) }
//println("------------------------")
}
val filled = map
.flatten()
.filter {it == Tile.FILLED}
.count()
println("$filled seats filled")
}
fun copyMap(map: ArrayList<ArrayList<Tile>>): ArrayList<ArrayList<Tile>>{
val mapc: ArrayList<ArrayList<Tile>> = arrayListOf()
for(m: ArrayList<Tile> in map) {
mapc.add(m.clone() as java.util.ArrayList<Tile>)
}
return mapc;
}
data class Coord(val x: Int, val y: Int) {
}
//Boy this seems silly
//Will update later to make something that take (stepx, stepy)
fun genVecs(x:Int, y:Int, maxX: Int, maxY:Int) : List<List<Coord>> {
val out: MutableList<MutableList<Coord>> = mutableListOf()
/**
* 123
* 0o4
* 765
*/
for (v in 0..7) {
var list: MutableList<Coord> = mutableListOf()
when (v) {
0 -> list = (x-1 downTo 0).map { Coord(it, y) }.toMutableList()
1 -> {
for (i in x-1 downTo 0) {
val j = y - (x - i)
if (j >= 0)
list.add(Coord(i, j))
}
}
2 -> list = (y-1 downTo 0).map { Coord(x, it) }.toMutableList()
3 -> {
for (i in x+1..maxX) {
val j = y - (i - x)
if (j in 0..maxY)
list.add(Coord(i, j))
}
}
4 -> list = (x+1..maxX).map { Coord(it, y) }.toMutableList()
5 -> {
for (i in x+1..maxX) {
val j = y + (i - x)
if (j in 0..maxY)
list.add(Coord(i, j))
}
}
6 -> list = (y+1..maxY).map { Coord(x, it) }.toMutableList()
7 -> {
for (i in x-1 downTo 0) {
val j = y - (i - x)
if (j in 0..maxY)
list.add(Coord(i, j))
}
}
}
out.add(list)
}
return out
}
|
[
{
"class_path": "knivey__adventofcode__14a8a23/Day11part2Kt.class",
"javap": "Compiled from \"Day11part2.kt\"\npublic final class Day11part2Kt {\n public static final void main();\n Code:\n 0: new #8 // class java/io/File\n 3: dup\n 4: ldc #10 // String input.txt\n 6: invokespecial #14 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: aconst_null\n 10: iconst_1\n 11: aconst_null\n 12: invokestatic #20 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 15: checkcast #22 // class java/lang/Iterable\n 18: invokestatic #28 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 21: invokedynamic #47, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 26: invokestatic #53 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 29: invokedynamic #60, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 34: invokestatic #53 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 37: invokedynamic #67, 0 // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;\n 42: invokestatic #53 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 45: new #69 // class java/util/ArrayList\n 48: dup\n 49: invokespecial #71 // Method java/util/ArrayList.\"<init>\":()V\n 52: checkcast #73 // class java/util/Collection\n 55: invokestatic #77 // Method kotlin/sequences/SequencesKt.toCollection:(Lkotlin/sequences/Sequence;Ljava/util/Collection;)Ljava/util/Collection;\n 58: checkcast #69 // class java/util/ArrayList\n 61: astore_0\n 62: aload_0\n 63: invokevirtual #81 // Method java/util/ArrayList.size:()I\n 66: iconst_1\n 67: isub\n 68: istore_1\n 69: aload_0\n 70: iconst_0\n 71: invokevirtual #85 // Method java/util/ArrayList.get:(I)Ljava/lang/Object;\n 74: checkcast #69 // class java/util/ArrayList\n 77: invokevirtual #81 // Method java/util/ArrayList.size:()I\n 80: iconst_1\n 81: isub\n 82: istore_2\n 83: iconst_1\n 84: istore_3\n 85: iconst_0\n 86: istore 4\n 88: iload_3\n 89: ifeq 438\n 92: iconst_0\n 93: istore_3\n 94: aload_0\n 95: invokestatic #89 // Method copyMap:(Ljava/util/ArrayList;)Ljava/util/ArrayList;\n 98: astore 5\n 100: aload 5\n 102: checkcast #22 // class java/lang/Iterable\n 105: invokeinterface #93, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 110: astore 6\n 112: iconst_0\n 113: istore 7\n 115: aload 6\n 117: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 122: ifeq 412\n 125: iload 7\n 127: istore 8\n 129: iload 7\n 131: iconst_1\n 132: iadd\n 133: istore 7\n 135: aload 6\n 137: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 142: checkcast #69 // class java/util/ArrayList\n 145: astore 9\n 147: aload 9\n 149: checkcast #22 // class java/lang/Iterable\n 152: invokeinterface #93, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 157: astore 10\n 159: iconst_0\n 160: istore 11\n 162: aload 10\n 164: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 169: ifeq 115\n 172: iload 11\n 174: istore 12\n 176: iload 11\n 178: iconst_1\n 179: iadd\n 180: istore 11\n 182: aload 10\n 184: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 189: checkcast #105 // class Tile\n 192: astore 13\n 194: aload 13\n 196: getstatic #109 // Field Tile.FLOOR:LTile;\n 199: if_acmpne 205\n 202: goto 162\n 205: iconst_0\n 206: istore 14\n 208: iload 12\n 210: iload 8\n 212: iload_2\n 213: iload_1\n 214: invokestatic #113 // Method genVecs:(IIII)Ljava/util/List;\n 217: invokeinterface #116, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 222: astore 15\n 224: aload 15\n 226: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 231: ifeq 340\n 234: aload 15\n 236: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 241: checkcast #115 // class java/util/List\n 244: astore 16\n 246: aload 16\n 248: invokeinterface #116, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 253: astore 17\n 255: aload 17\n 257: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 262: ifeq 224\n 265: aload 17\n 267: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 272: checkcast #118 // class Coord\n 275: astore 18\n 277: aload 5\n 279: aload 18\n 281: invokevirtual #121 // Method Coord.getY:()I\n 284: invokevirtual #85 // Method java/util/ArrayList.get:(I)Ljava/lang/Object;\n 287: checkcast #69 // class java/util/ArrayList\n 290: aload 18\n 292: invokevirtual #124 // Method Coord.getX:()I\n 295: invokevirtual #85 // Method java/util/ArrayList.get:(I)Ljava/lang/Object;\n 298: getstatic #127 // Field Tile.FILLED:LTile;\n 301: if_acmpne 310\n 304: iinc 14, 1\n 307: goto 224\n 310: aload 5\n 312: aload 18\n 314: invokevirtual #121 // Method Coord.getY:()I\n 317: invokevirtual #85 // Method java/util/ArrayList.get:(I)Ljava/lang/Object;\n 320: checkcast #69 // class java/util/ArrayList\n 323: aload 18\n 325: invokevirtual #124 // Method Coord.getX:()I\n 328: invokevirtual #85 // Method java/util/ArrayList.get:(I)Ljava/lang/Object;\n 331: getstatic #130 // Field Tile.EMPTY:LTile;\n 334: if_acmpne 255\n 337: goto 224\n 340: iload 14\n 342: iconst_5\n 343: if_icmplt 375\n 346: aload 13\n 348: getstatic #130 // Field Tile.EMPTY:LTile;\n 351: if_acmpeq 375\n 354: aload_0\n 355: iload 8\n 357: invokevirtual #85 // Method java/util/ArrayList.get:(I)Ljava/lang/Object;\n 360: checkcast #69 // class java/util/ArrayList\n 363: iload 12\n 365: getstatic #130 // Field Tile.EMPTY:LTile;\n 368: invokevirtual #134 // Method java/util/ArrayList.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 371: pop\n 372: iinc 3, 1\n 375: iload 14\n 377: ifne 162\n 380: aload 13\n 382: getstatic #127 // Field Tile.FILLED:LTile;\n 385: if_acmpeq 162\n 388: aload_0\n 389: iload 8\n 391: invokevirtual #85 // Method java/util/ArrayList.get:(I)Ljava/lang/Object;\n 394: checkcast #69 // class java/util/ArrayList\n 397: iload 12\n 399: getstatic #127 // Field Tile.FILLED:LTile;\n 402: invokevirtual #134 // Method java/util/ArrayList.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 405: pop\n 406: iinc 3, 1\n 409: goto 162\n 412: iload_3\n 413: ifeq 419\n 416: iinc 4, 1\n 419: iload 4\n 421: ldc #135 // int 100000\n 423: if_icmple 88\n 426: ldc #137 // String giving up\n 428: getstatic #143 // Field java/lang/System.out:Ljava/io/PrintStream;\n 431: swap\n 432: invokevirtual #149 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 435: goto 438\n 438: aload_0\n 439: checkcast #22 // class java/lang/Iterable\n 442: invokestatic #153 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 445: checkcast #22 // class java/lang/Iterable\n 448: astore 6\n 450: nop\n 451: iconst_0\n 452: istore 7\n 454: aload 6\n 456: astore 8\n 458: new #69 // class java/util/ArrayList\n 461: dup\n 462: invokespecial #71 // Method java/util/ArrayList.\"<init>\":()V\n 465: checkcast #73 // class java/util/Collection\n 468: astore 9\n 470: iconst_0\n 471: istore 10\n 473: aload 8\n 475: invokeinterface #93, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 480: astore 11\n 482: aload 11\n 484: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 489: ifeq 540\n 492: aload 11\n 494: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 499: astore 12\n 501: aload 12\n 503: checkcast #105 // class Tile\n 506: astore 13\n 508: iconst_0\n 509: istore 14\n 511: aload 13\n 513: getstatic #127 // Field Tile.FILLED:LTile;\n 516: if_acmpne 523\n 519: iconst_1\n 520: goto 524\n 523: iconst_0\n 524: ifeq 482\n 527: aload 9\n 529: aload 12\n 531: invokeinterface #157, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 536: pop\n 537: goto 482\n 540: aload 9\n 542: checkcast #115 // class java/util/List\n 545: nop\n 546: checkcast #73 // class java/util/Collection\n 549: invokeinterface #158, 1 // InterfaceMethod java/util/Collection.size:()I\n 554: istore 5\n 556: new #160 // class java/lang/StringBuilder\n 559: dup\n 560: invokespecial #161 // Method java/lang/StringBuilder.\"<init>\":()V\n 563: iload 5\n 565: invokevirtual #165 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 568: ldc #167 // String seats filled\n 570: invokevirtual #170 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 573: invokevirtual #174 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 576: getstatic #143 // Field java/lang/System.out:Ljava/io/PrintStream;\n 579: swap\n 580: invokevirtual #149 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 583: return\n\n public static final java.util.ArrayList<java.util.ArrayList<Tile>> copyMap(java.util.ArrayList<java.util.ArrayList<Tile>>);\n Code:\n 0: aload_0\n 1: ldc #205 // String map\n 3: invokestatic #211 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #69 // class java/util/ArrayList\n 9: dup\n 10: invokespecial #71 // Method java/util/ArrayList.\"<init>\":()V\n 13: astore_1\n 14: aload_0\n 15: invokevirtual #212 // Method java/util/ArrayList.iterator:()Ljava/util/Iterator;\n 18: dup\n 19: ldc #214 // String iterator(...)\n 21: invokestatic #217 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 24: astore_2\n 25: aload_2\n 26: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 31: ifeq 71\n 34: aload_2\n 35: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 40: dup\n 41: ldc #219 // String next(...)\n 43: invokestatic #217 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 46: checkcast #69 // class java/util/ArrayList\n 49: astore_3\n 50: aload_1\n 51: aload_3\n 52: invokevirtual #222 // Method java/util/ArrayList.clone:()Ljava/lang/Object;\n 55: dup\n 56: ldc #224 // String null cannot be cast to non-null type java.util.ArrayList<<root>.Tile>\n 58: invokestatic #227 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V\n 61: checkcast #69 // class java/util/ArrayList\n 64: invokevirtual #228 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 67: pop\n 68: goto 25\n 71: aload_1\n 72: areturn\n\n public static final java.util.List<java.util.List<Coord>> genVecs(int, int, int, int);\n Code:\n 0: new #69 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #71 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #115 // class java/util/List\n 10: astore 4\n 12: iconst_0\n 13: istore 5\n 15: iload 5\n 17: bipush 8\n 19: if_icmpge 853\n 22: new #69 // class java/util/ArrayList\n 25: dup\n 26: invokespecial #71 // Method java/util/ArrayList.\"<init>\":()V\n 29: checkcast #115 // class java/util/List\n 32: astore 6\n 34: iload 5\n 36: tableswitch { // 0 to 7\n 0: 84\n 1: 204\n 2: 253\n 3: 373\n 4: 447\n 5: 571\n 6: 645\n 7: 769\n default: 837\n }\n 84: iload_0\n 85: iconst_1\n 86: isub\n 87: iconst_0\n 88: invokestatic #236 // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;\n 91: checkcast #22 // class java/lang/Iterable\n 94: astore 7\n 96: iconst_0\n 97: istore 8\n 99: aload 7\n 101: astore 9\n 103: new #69 // class java/util/ArrayList\n 106: dup\n 107: aload 7\n 109: bipush 10\n 111: invokestatic #240 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 114: invokespecial #243 // Method java/util/ArrayList.\"<init>\":(I)V\n 117: checkcast #73 // class java/util/Collection\n 120: astore 10\n 122: iconst_0\n 123: istore 11\n 125: aload 9\n 127: invokeinterface #93, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 132: astore 12\n 134: aload 12\n 136: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 141: ifeq 187\n 144: aload 12\n 146: checkcast #245 // class kotlin/collections/IntIterator\n 149: invokevirtual #248 // Method kotlin/collections/IntIterator.nextInt:()I\n 152: istore 13\n 154: aload 10\n 156: iload 13\n 158: istore 14\n 160: astore 16\n 162: iconst_0\n 163: istore 15\n 165: new #118 // class Coord\n 168: dup\n 169: iload 14\n 171: iload_1\n 172: invokespecial #251 // Method Coord.\"<init>\":(II)V\n 175: aload 16\n 177: swap\n 178: invokeinterface #157, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 183: pop\n 184: goto 134\n 187: aload 10\n 189: checkcast #115 // class java/util/List\n 192: nop\n 193: checkcast #73 // class java/util/Collection\n 196: invokestatic #255 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 199: astore 6\n 201: goto 837\n 204: iload_0\n 205: iconst_1\n 206: isub\n 207: istore 7\n 209: iconst_m1\n 210: iload 7\n 212: if_icmpge 837\n 215: iload_1\n 216: iload_0\n 217: iload 7\n 219: isub\n 220: isub\n 221: istore 8\n 223: iload 8\n 225: iflt 247\n 228: aload 6\n 230: new #118 // class Coord\n 233: dup\n 234: iload 7\n 236: iload 8\n 238: invokespecial #251 // Method Coord.\"<init>\":(II)V\n 241: invokeinterface #256, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 246: pop\n 247: iinc 7, -1\n 250: goto 209\n 253: iload_1\n 254: iconst_1\n 255: isub\n 256: iconst_0\n 257: invokestatic #236 // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;\n 260: checkcast #22 // class java/lang/Iterable\n 263: astore 7\n 265: iconst_0\n 266: istore 8\n 268: aload 7\n 270: astore 9\n 272: new #69 // class java/util/ArrayList\n 275: dup\n 276: aload 7\n 278: bipush 10\n 280: invokestatic #240 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 283: invokespecial #243 // Method java/util/ArrayList.\"<init>\":(I)V\n 286: checkcast #73 // class java/util/Collection\n 289: astore 10\n 291: iconst_0\n 292: istore 11\n 294: aload 9\n 296: invokeinterface #93, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 301: astore 12\n 303: aload 12\n 305: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 310: ifeq 356\n 313: aload 12\n 315: checkcast #245 // class kotlin/collections/IntIterator\n 318: invokevirtual #248 // Method kotlin/collections/IntIterator.nextInt:()I\n 321: istore 13\n 323: aload 10\n 325: iload 13\n 327: istore 14\n 329: astore 16\n 331: iconst_0\n 332: istore 15\n 334: new #118 // class Coord\n 337: dup\n 338: iload_0\n 339: iload 14\n 341: invokespecial #251 // Method Coord.\"<init>\":(II)V\n 344: aload 16\n 346: swap\n 347: invokeinterface #157, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 352: pop\n 353: goto 303\n 356: aload 10\n 358: checkcast #115 // class java/util/List\n 361: nop\n 362: checkcast #73 // class java/util/Collection\n 365: invokestatic #255 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 368: astore 6\n 370: goto 837\n 373: iload_0\n 374: iconst_1\n 375: iadd\n 376: istore 7\n 378: iload 7\n 380: iload_2\n 381: if_icmpgt 837\n 384: iload_1\n 385: iload 7\n 387: iload_0\n 388: isub\n 389: isub\n 390: istore 8\n 392: iconst_0\n 393: iload 8\n 395: if_icmpgt 412\n 398: iload 8\n 400: iload_3\n 401: if_icmpgt 408\n 404: iconst_1\n 405: goto 413\n 408: iconst_0\n 409: goto 413\n 412: iconst_0\n 413: ifeq 435\n 416: aload 6\n 418: new #118 // class Coord\n 421: dup\n 422: iload 7\n 424: iload 8\n 426: invokespecial #251 // Method Coord.\"<init>\":(II)V\n 429: invokeinterface #256, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 434: pop\n 435: iload 7\n 437: iload_2\n 438: if_icmpeq 837\n 441: iinc 7, 1\n 444: goto 384\n 447: new #258 // class kotlin/ranges/IntRange\n 450: dup\n 451: iload_0\n 452: iconst_1\n 453: iadd\n 454: iload_2\n 455: invokespecial #259 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 458: checkcast #22 // class java/lang/Iterable\n 461: astore 7\n 463: iconst_0\n 464: istore 8\n 466: aload 7\n 468: astore 9\n 470: new #69 // class java/util/ArrayList\n 473: dup\n 474: aload 7\n 476: bipush 10\n 478: invokestatic #240 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 481: invokespecial #243 // Method java/util/ArrayList.\"<init>\":(I)V\n 484: checkcast #73 // class java/util/Collection\n 487: astore 10\n 489: iconst_0\n 490: istore 11\n 492: aload 9\n 494: invokeinterface #93, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 499: astore 12\n 501: aload 12\n 503: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 508: ifeq 554\n 511: aload 12\n 513: checkcast #245 // class kotlin/collections/IntIterator\n 516: invokevirtual #248 // Method kotlin/collections/IntIterator.nextInt:()I\n 519: istore 13\n 521: aload 10\n 523: iload 13\n 525: istore 14\n 527: astore 16\n 529: iconst_0\n 530: istore 15\n 532: new #118 // class Coord\n 535: dup\n 536: iload 14\n 538: iload_1\n 539: invokespecial #251 // Method Coord.\"<init>\":(II)V\n 542: aload 16\n 544: swap\n 545: invokeinterface #157, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 550: pop\n 551: goto 501\n 554: aload 10\n 556: checkcast #115 // class java/util/List\n 559: nop\n 560: checkcast #73 // class java/util/Collection\n 563: invokestatic #255 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 566: astore 6\n 568: goto 837\n 571: iload_0\n 572: iconst_1\n 573: iadd\n 574: istore 7\n 576: iload 7\n 578: iload_2\n 579: if_icmpgt 837\n 582: iload_1\n 583: iload 7\n 585: iload_0\n 586: isub\n 587: iadd\n 588: istore 8\n 590: iconst_0\n 591: iload 8\n 593: if_icmpgt 610\n 596: iload 8\n 598: iload_3\n 599: if_icmpgt 606\n 602: iconst_1\n 603: goto 611\n 606: iconst_0\n 607: goto 611\n 610: iconst_0\n 611: ifeq 633\n 614: aload 6\n 616: new #118 // class Coord\n 619: dup\n 620: iload 7\n 622: iload 8\n 624: invokespecial #251 // Method Coord.\"<init>\":(II)V\n 627: invokeinterface #256, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 632: pop\n 633: iload 7\n 635: iload_2\n 636: if_icmpeq 837\n 639: iinc 7, 1\n 642: goto 582\n 645: new #258 // class kotlin/ranges/IntRange\n 648: dup\n 649: iload_1\n 650: iconst_1\n 651: iadd\n 652: iload_3\n 653: invokespecial #259 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 656: checkcast #22 // class java/lang/Iterable\n 659: astore 7\n 661: iconst_0\n 662: istore 8\n 664: aload 7\n 666: astore 9\n 668: new #69 // class java/util/ArrayList\n 671: dup\n 672: aload 7\n 674: bipush 10\n 676: invokestatic #240 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 679: invokespecial #243 // Method java/util/ArrayList.\"<init>\":(I)V\n 682: checkcast #73 // class java/util/Collection\n 685: astore 10\n 687: iconst_0\n 688: istore 11\n 690: aload 9\n 692: invokeinterface #93, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 697: astore 12\n 699: aload 12\n 701: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 706: ifeq 752\n 709: aload 12\n 711: checkcast #245 // class kotlin/collections/IntIterator\n 714: invokevirtual #248 // Method kotlin/collections/IntIterator.nextInt:()I\n 717: istore 13\n 719: aload 10\n 721: iload 13\n 723: istore 14\n 725: astore 16\n 727: iconst_0\n 728: istore 15\n 730: new #118 // class Coord\n 733: dup\n 734: iload_0\n 735: iload 14\n 737: invokespecial #251 // Method Coord.\"<init>\":(II)V\n 740: aload 16\n 742: swap\n 743: invokeinterface #157, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 748: pop\n 749: goto 699\n 752: aload 10\n 754: checkcast #115 // class java/util/List\n 757: nop\n 758: checkcast #73 // class java/util/Collection\n 761: invokestatic #255 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 764: astore 6\n 766: goto 837\n 769: iload_0\n 770: iconst_1\n 771: isub\n 772: istore 7\n 774: iconst_m1\n 775: iload 7\n 777: if_icmpge 837\n 780: iload_1\n 781: iload 7\n 783: iload_0\n 784: isub\n 785: isub\n 786: istore 8\n 788: iconst_0\n 789: iload 8\n 791: if_icmpgt 808\n 794: iload 8\n 796: iload_3\n 797: if_icmpgt 804\n 800: iconst_1\n 801: goto 809\n 804: iconst_0\n 805: goto 809\n 808: iconst_0\n 809: ifeq 831\n 812: aload 6\n 814: new #118 // class Coord\n 817: dup\n 818: iload 7\n 820: iload 8\n 822: invokespecial #251 // Method Coord.\"<init>\":(II)V\n 825: invokeinterface #256, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 830: pop\n 831: iinc 7, -1\n 834: goto 774\n 837: aload 4\n 839: aload 6\n 841: invokeinterface #256, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 846: pop\n 847: iinc 5, 1\n 850: goto 15\n 853: aload 4\n 855: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #274 // Method main:()V\n 3: return\n\n private static final kotlin.sequences.Sequence main$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #278 // String line\n 4: invokestatic #211 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: checkcast #280 // class java/lang/CharSequence\n 11: invokestatic #285 // Method kotlin/text/StringsKt.asSequence:(Ljava/lang/CharSequence;)Lkotlin/sequences/Sequence;\n 14: areturn\n\n private static final Tile main$lambda$2$lambda$1(char);\n Code:\n 0: getstatic #291 // Field Tile.UNKNOWN:LTile;\n 3: iload_0\n 4: invokevirtual #294 // Method Tile.from:(C)LTile;\n 7: areturn\n\n private static final kotlin.sequences.Sequence main$lambda$2(kotlin.sequences.Sequence);\n Code:\n 0: aload_0\n 1: ldc_w #297 // String it\n 4: invokestatic #211 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokedynamic #303, 0 // InvokeDynamic #3:invoke:()Lkotlin/jvm/functions/Function1;\n 13: invokestatic #53 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 16: areturn\n\n private static final java.util.ArrayList main$lambda$3(kotlin.sequences.Sequence);\n Code:\n 0: aload_0\n 1: ldc_w #297 // String it\n 4: invokestatic #211 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: new #69 // class java/util/ArrayList\n 11: dup\n 12: invokespecial #71 // Method java/util/ArrayList.\"<init>\":()V\n 15: checkcast #73 // class java/util/Collection\n 18: invokestatic #77 // Method kotlin/sequences/SequencesKt.toCollection:(Lkotlin/sequences/Sequence;Ljava/util/Collection;)Ljava/util/Collection;\n 21: checkcast #69 // class java/util/ArrayList\n 24: areturn\n}\n",
"javap_err": ""
}
] |
Javran__exercism-solutions__15891b1/kotlin/pig-latin/src/main/kotlin/PigLatin.kt
|
object PigLatin {
// List of char sequence that should be considered a single cluster of vowel / consonant.
// Longer elements must appear first.
private val clusters: List<Pair<String, Boolean>> = listOf(
"sch" to false, "thr" to false,
"xr" to true, "yt" to true,
"ch" to false, "qu" to false, "th" to false, "rh" to false,
"a" to true, "e" to true, "i" to true, "o" to true, "u" to true,
"y" to false
)
private data class SplitResult(
val head: String,
val headIsVowel: Boolean,
val tail: String
)
// Splits a non-empty word by first vowel / consonant cluster.
// INVARIANT: head + tail == <input word>, where head and tail are from SplitResult.
private fun splitFirstCluster(word: String): SplitResult {
for ((prefix, prefixIsVowel) in clusters) {
if (word.startsWith(prefix)) {
return SplitResult(prefix, prefixIsVowel, word.substring(prefix.length))
}
}
return SplitResult(word.substring(0, 1), false, word.substring(1))
}
// Translates a single word into Pig Latin. It is assumed that the word is not empty.
private fun translateWord(word: String): String {
val (head, headIsVowel, tail) = splitFirstCluster(word)
return when {
headIsVowel ->
// Rule 1
word + "ay"
tail.startsWith("y") ->
// Rule 4
tail + head + "ay"
tail.startsWith("qu") ->
// Rule 3
tail.substring(2) + head + "quay"
else ->
// Rule 2
tail + head + "ay"
}
}
fun translate(phrase: String): String =
phrase.split(" ").map(::translateWord).joinToString(" ")
}
|
[
{
"class_path": "Javran__exercism-solutions__15891b1/PigLatin.class",
"javap": "Compiled from \"PigLatin.kt\"\npublic final class PigLatin {\n public static final PigLatin INSTANCE;\n\n private static final java.util.List<kotlin.Pair<java.lang.String, java.lang.Boolean>> clusters;\n\n private PigLatin();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final PigLatin$SplitResult splitFirstCluster(java.lang.String);\n Code:\n 0: getstatic #16 // Field clusters:Ljava/util/List;\n 3: invokeinterface #22, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 8: astore_2\n 9: aload_2\n 10: invokeinterface #28, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 15: ifeq 88\n 18: aload_2\n 19: invokeinterface #32, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 24: checkcast #34 // class kotlin/Pair\n 27: astore_3\n 28: aload_3\n 29: invokevirtual #37 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 32: checkcast #39 // class java/lang/String\n 35: astore 4\n 37: aload_3\n 38: invokevirtual #42 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 41: checkcast #44 // class java/lang/Boolean\n 44: invokevirtual #47 // Method java/lang/Boolean.booleanValue:()Z\n 47: istore 5\n 49: aload_1\n 50: aload 4\n 52: iconst_0\n 53: iconst_2\n 54: aconst_null\n 55: invokestatic #53 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 58: ifeq 9\n 61: new #55 // class PigLatin$SplitResult\n 64: dup\n 65: aload 4\n 67: iload 5\n 69: aload_1\n 70: aload 4\n 72: invokevirtual #59 // Method java/lang/String.length:()I\n 75: invokevirtual #63 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 78: dup\n 79: ldc #65 // String substring(...)\n 81: invokestatic #71 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 84: invokespecial #74 // Method PigLatin$SplitResult.\"<init>\":(Ljava/lang/String;ZLjava/lang/String;)V\n 87: areturn\n 88: new #55 // class PigLatin$SplitResult\n 91: dup\n 92: aload_1\n 93: iconst_0\n 94: iconst_1\n 95: invokevirtual #77 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 98: dup\n 99: ldc #65 // String substring(...)\n 101: invokestatic #71 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 104: iconst_0\n 105: aload_1\n 106: iconst_1\n 107: invokevirtual #63 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 110: dup\n 111: ldc #65 // String substring(...)\n 113: invokestatic #71 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 116: invokespecial #74 // Method PigLatin$SplitResult.\"<init>\":(Ljava/lang/String;ZLjava/lang/String;)V\n 119: areturn\n\n private final java.lang.String translateWord(java.lang.String);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #86 // Method splitFirstCluster:(Ljava/lang/String;)LPigLatin$SplitResult;\n 5: astore_2\n 6: aload_2\n 7: invokevirtual #89 // Method PigLatin$SplitResult.component1:()Ljava/lang/String;\n 10: astore_3\n 11: aload_2\n 12: invokevirtual #91 // Method PigLatin$SplitResult.component2:()Z\n 15: istore 4\n 17: aload_2\n 18: invokevirtual #94 // Method PigLatin$SplitResult.component3:()Ljava/lang/String;\n 21: astore 5\n 23: nop\n 24: iload 4\n 26: ifeq 51\n 29: new #96 // class java/lang/StringBuilder\n 32: dup\n 33: invokespecial #97 // Method java/lang/StringBuilder.\"<init>\":()V\n 36: aload_1\n 37: invokevirtual #101 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 40: ldc #103 // String ay\n 42: invokevirtual #101 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 45: invokevirtual #106 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 48: goto 165\n 51: aload 5\n 53: ldc #108 // String y\n 55: iconst_0\n 56: iconst_2\n 57: aconst_null\n 58: invokestatic #53 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 61: ifeq 91\n 64: new #96 // class java/lang/StringBuilder\n 67: dup\n 68: invokespecial #97 // Method java/lang/StringBuilder.\"<init>\":()V\n 71: aload 5\n 73: invokevirtual #101 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 76: aload_3\n 77: invokevirtual #101 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 80: ldc #103 // String ay\n 82: invokevirtual #101 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 85: invokevirtual #106 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 88: goto 165\n 91: aload 5\n 93: ldc #110 // String qu\n 95: iconst_0\n 96: iconst_2\n 97: aconst_null\n 98: invokestatic #53 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 101: ifeq 141\n 104: new #96 // class java/lang/StringBuilder\n 107: dup\n 108: invokespecial #97 // Method java/lang/StringBuilder.\"<init>\":()V\n 111: aload 5\n 113: iconst_2\n 114: invokevirtual #63 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 117: dup\n 118: ldc #65 // String substring(...)\n 120: invokestatic #71 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 123: invokevirtual #101 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 126: aload_3\n 127: invokevirtual #101 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 130: ldc #112 // String quay\n 132: invokevirtual #101 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 135: invokevirtual #106 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 138: goto 165\n 141: new #96 // class java/lang/StringBuilder\n 144: dup\n 145: invokespecial #97 // Method java/lang/StringBuilder.\"<init>\":()V\n 148: aload 5\n 150: invokevirtual #101 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 153: aload_3\n 154: invokevirtual #101 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 157: ldc #103 // String ay\n 159: invokevirtual #101 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 162: invokevirtual #106 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 165: areturn\n\n public final java.lang.String translate(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #119 // String phrase\n 3: invokestatic #122 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #124 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #39 // class java/lang/String\n 14: astore_2\n 15: aload_2\n 16: iconst_0\n 17: ldc #126 // 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 #130 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: checkcast #132 // class java/lang/Iterable\n 32: astore_2\n 33: iconst_0\n 34: istore_3\n 35: aload_2\n 36: astore 4\n 38: new #134 // class java/util/ArrayList\n 41: dup\n 42: aload_2\n 43: bipush 10\n 45: invokestatic #140 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 48: invokespecial #143 // Method java/util/ArrayList.\"<init>\":(I)V\n 51: checkcast #145 // class java/util/Collection\n 54: astore 5\n 56: iconst_0\n 57: istore 6\n 59: aload 4\n 61: invokeinterface #146, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 66: astore 7\n 68: aload 7\n 70: invokeinterface #28, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 75: ifeq 119\n 78: aload 7\n 80: invokeinterface #32, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 85: astore 8\n 87: aload 5\n 89: aload 8\n 91: checkcast #39 // class java/lang/String\n 94: astore 9\n 96: astore 11\n 98: iconst_0\n 99: istore 10\n 101: aload_0\n 102: aload 9\n 104: invokespecial #148 // Method translateWord:(Ljava/lang/String;)Ljava/lang/String;\n 107: aload 11\n 109: swap\n 110: invokeinterface #152, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 115: pop\n 116: goto 68\n 119: aload 5\n 121: checkcast #18 // class java/util/List\n 124: nop\n 125: checkcast #132 // class java/lang/Iterable\n 128: ldc #126 // String\n 130: checkcast #124 // class java/lang/CharSequence\n 133: aconst_null\n 134: aconst_null\n 135: iconst_0\n 136: aconst_null\n 137: aconst_null\n 138: bipush 62\n 140: aconst_null\n 141: invokestatic #156 // 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 144: areturn\n\n static {};\n Code:\n 0: new #2 // class PigLatin\n 3: dup\n 4: invokespecial #170 // Method \"<init>\":()V\n 7: putstatic #173 // Field INSTANCE:LPigLatin;\n 10: bipush 14\n 12: anewarray #34 // class kotlin/Pair\n 15: astore_0\n 16: aload_0\n 17: iconst_0\n 18: ldc #175 // String sch\n 20: iconst_0\n 21: invokestatic #179 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 24: invokestatic #185 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 27: aastore\n 28: aload_0\n 29: iconst_1\n 30: ldc #187 // String thr\n 32: iconst_0\n 33: invokestatic #179 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 36: invokestatic #185 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 39: aastore\n 40: aload_0\n 41: iconst_2\n 42: ldc #189 // String xr\n 44: iconst_1\n 45: invokestatic #179 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 48: invokestatic #185 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 51: aastore\n 52: aload_0\n 53: iconst_3\n 54: ldc #191 // String yt\n 56: iconst_1\n 57: invokestatic #179 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 60: invokestatic #185 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 63: aastore\n 64: aload_0\n 65: iconst_4\n 66: ldc #193 // String ch\n 68: iconst_0\n 69: invokestatic #179 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 72: invokestatic #185 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 75: aastore\n 76: aload_0\n 77: iconst_5\n 78: ldc #110 // String qu\n 80: iconst_0\n 81: invokestatic #179 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 84: invokestatic #185 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 87: aastore\n 88: aload_0\n 89: bipush 6\n 91: ldc #195 // String th\n 93: iconst_0\n 94: invokestatic #179 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 97: invokestatic #185 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 100: aastore\n 101: aload_0\n 102: bipush 7\n 104: ldc #197 // String rh\n 106: iconst_0\n 107: invokestatic #179 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 110: invokestatic #185 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 113: aastore\n 114: aload_0\n 115: bipush 8\n 117: ldc #199 // String a\n 119: iconst_1\n 120: invokestatic #179 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 123: invokestatic #185 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 126: aastore\n 127: aload_0\n 128: bipush 9\n 130: ldc #201 // String e\n 132: iconst_1\n 133: invokestatic #179 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 136: invokestatic #185 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 139: aastore\n 140: aload_0\n 141: bipush 10\n 143: ldc #203 // String i\n 145: iconst_1\n 146: invokestatic #179 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 149: invokestatic #185 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 152: aastore\n 153: aload_0\n 154: bipush 11\n 156: ldc #205 // String o\n 158: iconst_1\n 159: invokestatic #179 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 162: invokestatic #185 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 165: aastore\n 166: aload_0\n 167: bipush 12\n 169: ldc #207 // String u\n 171: iconst_1\n 172: invokestatic #179 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 175: invokestatic #185 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 178: aastore\n 179: aload_0\n 180: bipush 13\n 182: ldc #108 // String y\n 184: iconst_0\n 185: invokestatic #179 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 188: invokestatic #185 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 191: aastore\n 192: aload_0\n 193: invokestatic #211 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 196: putstatic #16 // Field clusters:Ljava/util/List;\n 199: return\n}\n",
"javap_err": ""
},
{
"class_path": "Javran__exercism-solutions__15891b1/PigLatin$SplitResult.class",
"javap": "Compiled from \"PigLatin.kt\"\nfinal class PigLatin$SplitResult {\n private final java.lang.String head;\n\n private final boolean headIsVowel;\n\n private final java.lang.String tail;\n\n public PigLatin$SplitResult(java.lang.String, boolean, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #9 // String head\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_3\n 7: ldc #17 // String tail\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 head:Ljava/lang/String;\n 21: aload_0\n 22: iload_2\n 23: putfield #27 // Field headIsVowel:Z\n 26: aload_0\n 27: aload_3\n 28: putfield #29 // Field tail:Ljava/lang/String;\n 31: return\n\n public final java.lang.String getHead();\n Code:\n 0: aload_0\n 1: getfield #23 // Field head:Ljava/lang/String;\n 4: areturn\n\n public final boolean getHeadIsVowel();\n Code:\n 0: aload_0\n 1: getfield #27 // Field headIsVowel:Z\n 4: ireturn\n\n public final java.lang.String getTail();\n Code:\n 0: aload_0\n 1: getfield #29 // Field tail:Ljava/lang/String;\n 4: areturn\n\n public final java.lang.String component1();\n Code:\n 0: aload_0\n 1: getfield #23 // Field head:Ljava/lang/String;\n 4: areturn\n\n public final boolean component2();\n Code:\n 0: aload_0\n 1: getfield #27 // Field headIsVowel:Z\n 4: ireturn\n\n public final java.lang.String component3();\n Code:\n 0: aload_0\n 1: getfield #29 // Field tail:Ljava/lang/String;\n 4: areturn\n\n public final PigLatin$SplitResult copy(java.lang.String, boolean, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #9 // String head\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_3\n 7: ldc #17 // String tail\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class PigLatin$SplitResult\n 15: dup\n 16: aload_1\n 17: iload_2\n 18: aload_3\n 19: invokespecial #43 // Method \"<init>\":(Ljava/lang/String;ZLjava/lang/String;)V\n 22: areturn\n\n public static PigLatin$SplitResult copy$default(PigLatin$SplitResult, java.lang.String, boolean, java.lang.String, int, java.lang.Object);\n Code:\n 0: iload 4\n 2: iconst_1\n 3: iand\n 4: ifeq 12\n 7: aload_0\n 8: getfield #23 // Field head: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 #27 // Field headIsVowel: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 #29 // Field tail:Ljava/lang/String;\n 35: astore_3\n 36: aload_0\n 37: aload_1\n 38: iload_2\n 39: aload_3\n 40: invokevirtual #47 // Method copy:(Ljava/lang/String;ZLjava/lang/String;)LPigLatin$SplitResult;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #50 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #51 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #53 // String SplitResult(head=\n 9: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #23 // Field head:Ljava/lang/String;\n 16: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 19: ldc #59 // String , headIsVowel=\n 21: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #27 // Field headIsVowel:Z\n 28: invokevirtual #62 // Method java/lang/StringBuilder.append:(Z)Ljava/lang/StringBuilder;\n 31: ldc #64 // String , tail=\n 33: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #29 // Field tail:Ljava/lang/String;\n 40: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #67 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #69 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 51: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #23 // Field head:Ljava/lang/String;\n 4: invokevirtual #75 // 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 #27 // Field headIsVowel:Z\n 16: invokestatic #80 // 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 #29 // Field tail:Ljava/lang/String;\n 29: invokevirtual #75 // Method java/lang/String.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 PigLatin$SplitResult\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class PigLatin$SplitResult\n 20: astore_2\n 21: aload_0\n 22: getfield #23 // Field head:Ljava/lang/String;\n 25: aload_2\n 26: getfield #23 // Field head:Ljava/lang/String;\n 29: invokestatic #89 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 32: ifne 37\n 35: iconst_0\n 36: ireturn\n 37: aload_0\n 38: getfield #27 // Field headIsVowel:Z\n 41: aload_2\n 42: getfield #27 // Field headIsVowel:Z\n 45: if_icmpeq 50\n 48: iconst_0\n 49: ireturn\n 50: aload_0\n 51: getfield #29 // Field tail:Ljava/lang/String;\n 54: aload_2\n 55: getfield #29 // Field tail:Ljava/lang/String;\n 58: invokestatic #89 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 61: ifne 66\n 64: iconst_0\n 65: ireturn\n 66: iconst_1\n 67: ireturn\n}\n",
"javap_err": ""
}
] |
babangsund__sorting-algorithms__0f05c41/merge-sort/mergeSort.kt
|
fun <T:Comparable<T>> merge(a: List<T>, b: List<T>): List<T> {
if (a.isEmpty() && b.isNotEmpty()) return b
if (b.isEmpty() && a.isNotEmpty()) return a
val (ah, at) = Pair(a[0], a.drop(1))
val (bh, bt) = Pair(b[0], b.drop(1))
return when {
ah >= bh -> listOf(bh) + merge(a, bt)
else -> listOf(ah) + merge(at, b)
}
}
fun <T:Comparable<T>> mergeSort(list: List<T>): List<T> {
val len = list.count()
if (len < 2) return list
val half = kotlin.math.ceil((len.toDouble() / 2)).toInt()
val (left, right) = list.chunked(half)
return merge(mergeSort(left), mergeSort(right))
}
fun main() {
val sorted = mergeSort(listOf(6, 5, 2, 3, 0, 1))
println("sorted: $sorted")
}
|
[
{
"class_path": "babangsund__sorting-algorithms__0f05c41/MergeSortKt.class",
"javap": "Compiled from \"mergeSort.kt\"\npublic final class MergeSortKt {\n public static final <T extends java.lang.Comparable<? super T>> java.util.List<T> merge(java.util.List<? extends T>, java.util.List<? extends T>);\n Code:\n 0: aload_0\n 1: ldc #10 // String a\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 b\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokeinterface #24, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 18: ifeq 43\n 21: aload_1\n 22: checkcast #26 // class java/util/Collection\n 25: invokeinterface #27, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 30: ifne 37\n 33: iconst_1\n 34: goto 38\n 37: iconst_0\n 38: ifeq 43\n 41: aload_1\n 42: areturn\n 43: aload_1\n 44: invokeinterface #24, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 49: ifeq 74\n 52: aload_0\n 53: checkcast #26 // class java/util/Collection\n 56: invokeinterface #27, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 61: ifne 68\n 64: iconst_1\n 65: goto 69\n 68: iconst_0\n 69: ifeq 74\n 72: aload_0\n 73: areturn\n 74: new #29 // class kotlin/Pair\n 77: dup\n 78: aload_0\n 79: iconst_0\n 80: invokeinterface #33, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 85: aload_0\n 86: checkcast #35 // class java/lang/Iterable\n 89: iconst_1\n 90: invokestatic #41 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 93: invokespecial #45 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 96: astore_2\n 97: aload_2\n 98: invokevirtual #49 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 101: checkcast #51 // class java/lang/Comparable\n 104: astore_3\n 105: aload_2\n 106: invokevirtual #54 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 109: checkcast #20 // class java/util/List\n 112: astore 4\n 114: new #29 // class kotlin/Pair\n 117: dup\n 118: aload_1\n 119: iconst_0\n 120: invokeinterface #33, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 125: aload_1\n 126: checkcast #35 // class java/lang/Iterable\n 129: iconst_1\n 130: invokestatic #41 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 133: invokespecial #45 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 136: astore 5\n 138: aload 5\n 140: invokevirtual #49 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 143: checkcast #51 // class java/lang/Comparable\n 146: astore 6\n 148: aload 5\n 150: invokevirtual #54 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 153: checkcast #20 // class java/util/List\n 156: astore 7\n 158: nop\n 159: aload_3\n 160: aload 6\n 162: invokeinterface #58, 2 // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I\n 167: iflt 193\n 170: aload 6\n 172: invokestatic #62 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 175: checkcast #26 // class java/util/Collection\n 178: aload_0\n 179: aload 7\n 181: invokestatic #64 // Method merge:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 184: checkcast #35 // class java/lang/Iterable\n 187: invokestatic #68 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 190: goto 212\n 193: aload_3\n 194: invokestatic #62 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 197: checkcast #26 // class java/util/Collection\n 200: aload 4\n 202: aload_1\n 203: invokestatic #64 // Method merge:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 206: checkcast #35 // class java/lang/Iterable\n 209: invokestatic #68 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 212: areturn\n\n public static final <T extends java.lang.Comparable<? super T>> java.util.List<T> mergeSort(java.util.List<? extends T>);\n Code:\n 0: aload_0\n 1: ldc #79 // String list\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #26 // class java/util/Collection\n 10: invokeinterface #83, 1 // InterfaceMethod java/util/Collection.size:()I\n 15: istore_1\n 16: iload_1\n 17: iconst_2\n 18: if_icmpge 23\n 21: aload_0\n 22: areturn\n 23: iload_1\n 24: i2d\n 25: iconst_2\n 26: i2d\n 27: ddiv\n 28: invokestatic #89 // Method java/lang/Math.ceil:(D)D\n 31: d2i\n 32: istore_2\n 33: aload_0\n 34: checkcast #35 // class java/lang/Iterable\n 37: iload_2\n 38: invokestatic #92 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;\n 41: astore_3\n 42: aload_3\n 43: iconst_0\n 44: invokeinterface #33, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 49: checkcast #20 // class java/util/List\n 52: astore 4\n 54: aload_3\n 55: iconst_1\n 56: invokeinterface #33, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 61: checkcast #20 // class java/util/List\n 64: astore 5\n 66: aload 4\n 68: invokestatic #94 // Method mergeSort:(Ljava/util/List;)Ljava/util/List;\n 71: aload 5\n 73: invokestatic #94 // Method mergeSort:(Ljava/util/List;)Ljava/util/List;\n 76: invokestatic #64 // Method merge:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 79: areturn\n\n public static final void main();\n Code:\n 0: bipush 6\n 2: anewarray #103 // class java/lang/Integer\n 5: astore_1\n 6: aload_1\n 7: iconst_0\n 8: bipush 6\n 10: invokestatic #107 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 13: aastore\n 14: aload_1\n 15: iconst_1\n 16: iconst_5\n 17: invokestatic #107 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 20: aastore\n 21: aload_1\n 22: iconst_2\n 23: iconst_2\n 24: invokestatic #107 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 27: aastore\n 28: aload_1\n 29: iconst_3\n 30: iconst_3\n 31: invokestatic #107 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 34: aastore\n 35: aload_1\n 36: iconst_4\n 37: iconst_0\n 38: invokestatic #107 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 41: aastore\n 42: aload_1\n 43: iconst_5\n 44: iconst_1\n 45: invokestatic #107 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 48: aastore\n 49: aload_1\n 50: invokestatic #110 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 53: invokestatic #94 // Method mergeSort:(Ljava/util/List;)Ljava/util/List;\n 56: astore_0\n 57: new #112 // class java/lang/StringBuilder\n 60: dup\n 61: invokespecial #114 // Method java/lang/StringBuilder.\"<init>\":()V\n 64: ldc #116 // String sorted:\n 66: invokevirtual #120 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 69: aload_0\n 70: invokevirtual #123 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 73: invokevirtual #127 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 76: getstatic #133 // Field java/lang/System.out:Ljava/io/PrintStream;\n 79: swap\n 80: invokevirtual #139 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 83: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #143 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
mikhail-dvorkin__algorithms__5ad1705/numberTheory.kt
|
private fun largestPrimeDivisors(n: Int): IntArray {
val largestPrimeDivisors = IntArray(n + 1) { it }
for (i in 2..n) {
if (largestPrimeDivisors[i] < i) continue
var j = i * i
if (j > n) break
do {
largestPrimeDivisors[j] = i
j += i
} while (j <= n)
}
return largestPrimeDivisors
}
private fun divisorsOf(n: Int, largestPrimeDivisors: IntArray): IntArray {
if (n == 1) return intArrayOf(1)
val p = largestPrimeDivisors[n]
if (p == n) return intArrayOf(1, n)
var m = n / p
var counter = 2
while (m % p == 0) {
m /= p
counter++
}
val divisorsOfM = divisorsOf(m, largestPrimeDivisors)
val result = IntArray(divisorsOfM.size * counter)
for (i in divisorsOfM.indices) {
var d = divisorsOfM[i]
for (j in 0 until counter) {
result[i * counter + j] = d
d *= p
}
}
return result
}
|
[
{
"class_path": "mikhail-dvorkin__algorithms__5ad1705/NumberTheoryKt.class",
"javap": "Compiled from \"numberTheory.kt\"\npublic final class NumberTheoryKt {\n private static final int[] largestPrimeDivisors(int);\n Code:\n 0: iconst_0\n 1: istore_2\n 2: iload_0\n 3: iconst_1\n 4: iadd\n 5: istore_3\n 6: iload_3\n 7: newarray int\n 9: astore 4\n 11: iload_2\n 12: iload_3\n 13: if_icmpge 32\n 16: iload_2\n 17: istore 5\n 19: aload 4\n 21: iload 5\n 23: iload 5\n 25: iastore\n 26: iinc 2, 1\n 29: goto 11\n 32: aload 4\n 34: astore_1\n 35: iconst_2\n 36: istore_2\n 37: iload_2\n 38: iload_0\n 39: if_icmpgt 82\n 42: aload_1\n 43: iload_2\n 44: iaload\n 45: iload_2\n 46: if_icmplt 71\n 49: iload_2\n 50: iload_2\n 51: imul\n 52: istore_3\n 53: iload_3\n 54: iload_0\n 55: if_icmpgt 82\n 58: aload_1\n 59: iload_3\n 60: iload_2\n 61: iastore\n 62: iload_3\n 63: iload_2\n 64: iadd\n 65: istore_3\n 66: iload_3\n 67: iload_0\n 68: if_icmple 58\n 71: iload_2\n 72: iload_0\n 73: if_icmpeq 82\n 76: iinc 2, 1\n 79: goto 42\n 82: aload_1\n 83: areturn\n\n private static final int[] divisorsOf(int, int[]);\n Code:\n 0: iload_0\n 1: iconst_1\n 2: if_icmpne 15\n 5: iconst_1\n 6: newarray int\n 8: astore_2\n 9: aload_2\n 10: iconst_0\n 11: iconst_1\n 12: iastore\n 13: aload_2\n 14: areturn\n 15: aload_1\n 16: iload_0\n 17: iaload\n 18: istore_2\n 19: iload_2\n 20: iload_0\n 21: if_icmpne 38\n 24: iconst_2\n 25: newarray int\n 27: astore_3\n 28: aload_3\n 29: iconst_0\n 30: iconst_1\n 31: iastore\n 32: aload_3\n 33: iconst_1\n 34: iload_0\n 35: iastore\n 36: aload_3\n 37: areturn\n 38: iload_0\n 39: iload_2\n 40: idiv\n 41: istore_3\n 42: iconst_2\n 43: istore 4\n 45: iload_3\n 46: iload_2\n 47: irem\n 48: ifne 61\n 51: iload_3\n 52: iload_2\n 53: idiv\n 54: istore_3\n 55: iinc 4, 1\n 58: goto 45\n 61: iload_3\n 62: aload_1\n 63: invokestatic #16 // Method divisorsOf:(I[I)[I\n 66: astore 5\n 68: aload 5\n 70: arraylength\n 71: iload 4\n 73: imul\n 74: newarray int\n 76: astore 6\n 78: iconst_0\n 79: istore 7\n 81: aload 5\n 83: arraylength\n 84: istore 8\n 86: iload 7\n 88: iload 8\n 90: if_icmpge 145\n 93: aload 5\n 95: iload 7\n 97: iaload\n 98: istore 9\n 100: iconst_0\n 101: istore 10\n 103: iload 4\n 105: istore 11\n 107: iload 10\n 109: iload 11\n 111: if_icmpge 139\n 114: aload 6\n 116: iload 7\n 118: iload 4\n 120: imul\n 121: iload 10\n 123: iadd\n 124: iload 9\n 126: iastore\n 127: iload 9\n 129: iload_2\n 130: imul\n 131: istore 9\n 133: iinc 10, 1\n 136: goto 107\n 139: iinc 7, 1\n 142: goto 86\n 145: aload 6\n 147: areturn\n}\n",
"javap_err": ""
}
] |
teodor-vasile__aoc-2022-kotlin__2fcfe95/src/main/kotlin/Day009.kt
|
import kotlin.math.abs
import kotlin.math.sign
class Day009 {
companion object {
private val visitedTails = mutableSetOf<Point>()
}
var initialPoint = State(Point(0, 0), Point(0, 0))
fun moveTheSnake(input: List<String>): Int {
println(input.size)
input.forEach {
makeMove(initialPoint, it[2].digitToInt(), it[0].toPoint())
}
println(visitedTails)
return visitedTails.size
}
data class State(
val head: Point,
val tail: Point
)
data class Point(
val x: Int,
val y: Int
) {
infix operator fun plus(that: Point) =
Point(this.x + that.x, this.y + that.y)
fun moveTowards(other: Point): Point =
Point(
(other.x - x).sign + x,
(other.y - y).sign + y
)
}
private fun makeMove(initialState: State, numberOfTimes: Int, direction: Point): State {
var head = initialState.head
var tail = initialState.tail
repeat(numberOfTimes) {
// println("Step " + (it + 1) + " head $head and tail $tail")
head += direction
tail = moveTailAbs(tail, head)
initialPoint = State(head, tail)
// println("after move $initialPoint")
}
return State(head, tail)
}
private fun moveTailAbs(tailInitial: Point, headAfter: Point): Point {
val result =
if (abs(headAfter.x - abs(tailInitial.x)) <= 1 && abs(headAfter.y - abs(tailInitial.y)) <= 1) {
// if ((headAfter.x - tailInitial.x).absoluteValue <= 1 && (headAfter.y - tailInitial.y).absoluteValue <= 1) {
tailInitial
} else {
/*Point(
(headAfter.x - tailInitial.x).sign + tailInitial.x,
(headAfter.y - tailInitial.y).sign + tailInitial.y
)*/
tailInitial.moveTowards(headAfter)
}
visitedTails.add(result)
return result
}
private fun Char.toPoint(): Point {
return when (this) {
'R' -> Point(1, 0)
'L' -> Point(-1, 0)
'U' -> Point(0, 1)
'D' -> Point(0, -1)
else -> {
error("Value not valid")
}
}
}
}
|
[
{
"class_path": "teodor-vasile__aoc-2022-kotlin__2fcfe95/Day009$Point.class",
"javap": "Compiled from \"Day009.kt\"\npublic final class Day009$Point {\n private final int x;\n\n private final int y;\n\n public Day009$Point(int, int);\n Code:\n 0: aload_0\n 1: invokespecial #9 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #13 // Field x:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field y:I\n 14: return\n\n public final int getX();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: ireturn\n\n public final int getY();\n Code:\n 0: aload_0\n 1: getfield #16 // Field y:I\n 4: ireturn\n\n public final Day009$Point plus(Day009$Point);\n Code:\n 0: aload_1\n 1: ldc #26 // String that\n 3: invokestatic #32 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class Day009$Point\n 9: dup\n 10: aload_0\n 11: getfield #13 // Field x:I\n 14: aload_1\n 15: getfield #13 // Field x:I\n 18: iadd\n 19: aload_0\n 20: getfield #16 // Field y:I\n 23: aload_1\n 24: getfield #16 // Field y:I\n 27: iadd\n 28: invokespecial #34 // Method \"<init>\":(II)V\n 31: areturn\n\n public final Day009$Point moveTowards(Day009$Point);\n Code:\n 0: aload_1\n 1: ldc #37 // String other\n 3: invokestatic #32 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class Day009$Point\n 9: dup\n 10: aload_1\n 11: getfield #13 // Field x:I\n 14: aload_0\n 15: getfield #13 // Field x:I\n 18: isub\n 19: invokestatic #43 // Method kotlin/math/MathKt.getSign:(I)I\n 22: aload_0\n 23: getfield #13 // Field x:I\n 26: iadd\n 27: aload_1\n 28: getfield #16 // Field y:I\n 31: aload_0\n 32: getfield #16 // Field y:I\n 35: isub\n 36: invokestatic #43 // Method kotlin/math/MathKt.getSign:(I)I\n 39: aload_0\n 40: getfield #16 // Field y:I\n 43: iadd\n 44: invokespecial #34 // Method \"<init>\":(II)V\n 47: 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 Day009$Point copy(int, int);\n Code:\n 0: new #2 // class Day009$Point\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: invokespecial #34 // Method \"<init>\":(II)V\n 9: areturn\n\n public static Day009$Point copy$default(Day009$Point, int, int, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_1\n 2: iand\n 3: ifeq 11\n 6: aload_0\n 7: getfield #13 // Field x:I\n 10: istore_1\n 11: iload_3\n 12: iconst_2\n 13: iand\n 14: ifeq 22\n 17: aload_0\n 18: getfield #16 // Field y:I\n 21: istore_2\n 22: aload_0\n 23: iload_1\n 24: iload_2\n 25: invokevirtual #51 // Method copy:(II)LDay009$Point;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #55 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #56 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #58 // String Point(x=\n 9: invokevirtual #62 // 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 #65 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #67 // String , y=\n 21: invokevirtual #62 // 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 #65 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #70 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #72 // 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 #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 y: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: 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 Day009$Point\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day009$Point\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field x:I\n 25: aload_2\n 26: getfield #13 // Field x:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field y:I\n 38: aload_2\n 39: getfield #16 // Field y:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: iconst_1\n 48: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "teodor-vasile__aoc-2022-kotlin__2fcfe95/Day009.class",
"javap": "Compiled from \"Day009.kt\"\npublic final class Day009 {\n public static final Day009$Companion Companion;\n\n private Day009$State initialPoint;\n\n private static final java.util.Set<Day009$Point> visitedTails;\n\n public Day009();\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 Day009$State\n 8: dup\n 9: new #12 // class Day009$Point\n 12: dup\n 13: iconst_0\n 14: iconst_0\n 15: invokespecial #15 // Method Day009$Point.\"<init>\":(II)V\n 18: new #12 // class Day009$Point\n 21: dup\n 22: iconst_0\n 23: iconst_0\n 24: invokespecial #15 // Method Day009$Point.\"<init>\":(II)V\n 27: invokespecial #18 // Method Day009$State.\"<init>\":(LDay009$Point;LDay009$Point;)V\n 30: putfield #22 // Field initialPoint:LDay009$State;\n 33: return\n\n public final Day009$State getInitialPoint();\n Code:\n 0: aload_0\n 1: getfield #22 // Field initialPoint:LDay009$State;\n 4: areturn\n\n public final void setInitialPoint(Day009$State);\n Code:\n 0: aload_1\n 1: ldc #31 // String <set-?>\n 3: invokestatic #37 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: putfield #22 // Field initialPoint:LDay009$State;\n 11: return\n\n public final int moveTheSnake(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #42 // String input\n 3: invokestatic #37 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokeinterface #48, 1 // InterfaceMethod java/util/List.size:()I\n 12: istore_2\n 13: getstatic #54 // Field java/lang/System.out:Ljava/io/PrintStream;\n 16: iload_2\n 17: invokevirtual #60 // Method java/io/PrintStream.println:(I)V\n 20: aload_1\n 21: checkcast #62 // class java/lang/Iterable\n 24: astore_2\n 25: iconst_0\n 26: istore_3\n 27: aload_2\n 28: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 33: astore 4\n 35: aload 4\n 37: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 42: ifeq 97\n 45: aload 4\n 47: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 52: astore 5\n 54: aload 5\n 56: checkcast #78 // class java/lang/String\n 59: astore 6\n 61: iconst_0\n 62: istore 7\n 64: aload_0\n 65: aload_0\n 66: getfield #22 // Field initialPoint:LDay009$State;\n 69: aload 6\n 71: iconst_2\n 72: invokevirtual #82 // Method java/lang/String.charAt:(I)C\n 75: invokestatic #88 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 78: aload_0\n 79: aload 6\n 81: iconst_0\n 82: invokevirtual #82 // Method java/lang/String.charAt:(I)C\n 85: invokespecial #92 // Method toPoint:(C)LDay009$Point;\n 88: invokespecial #96 // Method makeMove:(LDay009$State;ILDay009$Point;)LDay009$State;\n 91: pop\n 92: nop\n 93: nop\n 94: goto 35\n 97: nop\n 98: getstatic #100 // Field visitedTails:Ljava/util/Set;\n 101: getstatic #54 // Field java/lang/System.out:Ljava/io/PrintStream;\n 104: swap\n 105: invokevirtual #103 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 108: getstatic #100 // Field visitedTails:Ljava/util/Set;\n 111: invokeinterface #106, 1 // InterfaceMethod java/util/Set.size:()I\n 116: ireturn\n\n private final Day009$State makeMove(Day009$State, int, Day009$Point);\n Code:\n 0: aconst_null\n 1: astore 4\n 3: aload_1\n 4: invokevirtual #120 // Method Day009$State.getHead:()LDay009$Point;\n 7: astore 4\n 9: aconst_null\n 10: astore 5\n 12: aload_1\n 13: invokevirtual #123 // Method Day009$State.getTail:()LDay009$Point;\n 16: astore 5\n 18: iconst_0\n 19: istore 6\n 21: iload 6\n 23: iload_2\n 24: if_icmpge 74\n 27: iload 6\n 29: istore 7\n 31: iconst_0\n 32: istore 8\n 34: aload 4\n 36: aload_3\n 37: invokevirtual #127 // Method Day009$Point.plus:(LDay009$Point;)LDay009$Point;\n 40: astore 4\n 42: aload_0\n 43: aload 5\n 45: aload 4\n 47: invokespecial #131 // Method moveTailAbs:(LDay009$Point;LDay009$Point;)LDay009$Point;\n 50: astore 5\n 52: aload_0\n 53: new #10 // class Day009$State\n 56: dup\n 57: aload 4\n 59: aload 5\n 61: invokespecial #18 // Method Day009$State.\"<init>\":(LDay009$Point;LDay009$Point;)V\n 64: putfield #22 // Field initialPoint:LDay009$State;\n 67: nop\n 68: iinc 6, 1\n 71: goto 21\n 74: new #10 // class Day009$State\n 77: dup\n 78: aload 4\n 80: aload 5\n 82: invokespecial #18 // Method Day009$State.\"<init>\":(LDay009$Point;LDay009$Point;)V\n 85: areturn\n\n private final Day009$Point moveTailAbs(Day009$Point, Day009$Point);\n Code:\n 0: aload_2\n 1: invokevirtual #141 // Method Day009$Point.getX:()I\n 4: aload_1\n 5: invokevirtual #141 // Method Day009$Point.getX:()I\n 8: invokestatic #147 // Method java/lang/Math.abs:(I)I\n 11: isub\n 12: invokestatic #147 // Method java/lang/Math.abs:(I)I\n 15: iconst_1\n 16: if_icmpgt 42\n 19: aload_2\n 20: invokevirtual #150 // Method Day009$Point.getY:()I\n 23: aload_1\n 24: invokevirtual #150 // Method Day009$Point.getY:()I\n 27: invokestatic #147 // Method java/lang/Math.abs:(I)I\n 30: isub\n 31: invokestatic #147 // Method java/lang/Math.abs:(I)I\n 34: iconst_1\n 35: if_icmpgt 42\n 38: aload_1\n 39: goto 47\n 42: aload_1\n 43: aload_2\n 44: invokevirtual #153 // Method Day009$Point.moveTowards:(LDay009$Point;)LDay009$Point;\n 47: astore_3\n 48: getstatic #100 // Field visitedTails:Ljava/util/Set;\n 51: aload_3\n 52: invokeinterface #157, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 57: pop\n 58: aload_3\n 59: areturn\n\n private final Day009$Point toPoint(char);\n Code:\n 0: iload_1\n 1: lookupswitch { // 4\n 68: 80\n 76: 56\n 82: 44\n 85: 68\n default: 92\n }\n 44: new #12 // class Day009$Point\n 47: dup\n 48: iconst_1\n 49: iconst_0\n 50: invokespecial #15 // Method Day009$Point.\"<init>\":(II)V\n 53: goto 105\n 56: new #12 // class Day009$Point\n 59: dup\n 60: iconst_m1\n 61: iconst_0\n 62: invokespecial #15 // Method Day009$Point.\"<init>\":(II)V\n 65: goto 105\n 68: new #12 // class Day009$Point\n 71: dup\n 72: iconst_0\n 73: iconst_1\n 74: invokespecial #15 // Method Day009$Point.\"<init>\":(II)V\n 77: goto 105\n 80: new #12 // class Day009$Point\n 83: dup\n 84: iconst_0\n 85: iconst_m1\n 86: invokespecial #15 // Method Day009$Point.\"<init>\":(II)V\n 89: goto 105\n 92: new #162 // class java/lang/IllegalStateException\n 95: dup\n 96: ldc #164 // String Value not valid\n 98: invokevirtual #168 // Method java/lang/Object.toString:()Ljava/lang/String;\n 101: invokespecial #171 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 104: athrow\n 105: areturn\n\n static {};\n Code:\n 0: new #176 // class Day009$Companion\n 3: dup\n 4: aconst_null\n 5: invokespecial #179 // Method Day009$Companion.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 8: putstatic #183 // Field Companion:LDay009$Companion;\n 11: new #185 // class java/util/LinkedHashSet\n 14: dup\n 15: invokespecial #186 // Method java/util/LinkedHashSet.\"<init>\":()V\n 18: checkcast #105 // class java/util/Set\n 21: putstatic #100 // Field visitedTails:Ljava/util/Set;\n 24: return\n}\n",
"javap_err": ""
},
{
"class_path": "teodor-vasile__aoc-2022-kotlin__2fcfe95/Day009$Companion.class",
"javap": "Compiled from \"Day009.kt\"\npublic final class Day009$Companion {\n private Day009$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public Day009$Companion(kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: invokespecial #12 // Method \"<init>\":()V\n 4: return\n}\n",
"javap_err": ""
},
{
"class_path": "teodor-vasile__aoc-2022-kotlin__2fcfe95/Day009$State.class",
"javap": "Compiled from \"Day009.kt\"\npublic final class Day009$State {\n private final Day009$Point head;\n\n private final Day009$Point tail;\n\n public Day009$State(Day009$Point, Day009$Point);\n Code:\n 0: aload_1\n 1: ldc #9 // String head\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 tail\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 head:LDay009$Point;\n 21: aload_0\n 22: aload_2\n 23: putfield #25 // Field tail:LDay009$Point;\n 26: return\n\n public final Day009$Point getHead();\n Code:\n 0: aload_0\n 1: getfield #23 // Field head:LDay009$Point;\n 4: areturn\n\n public final Day009$Point getTail();\n Code:\n 0: aload_0\n 1: getfield #25 // Field tail:LDay009$Point;\n 4: areturn\n\n public final Day009$Point component1();\n Code:\n 0: aload_0\n 1: getfield #23 // Field head:LDay009$Point;\n 4: areturn\n\n public final Day009$Point component2();\n Code:\n 0: aload_0\n 1: getfield #25 // Field tail:LDay009$Point;\n 4: areturn\n\n public final Day009$State copy(Day009$Point, Day009$Point);\n Code:\n 0: aload_1\n 1: ldc #9 // String head\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 tail\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class Day009$State\n 15: dup\n 16: aload_1\n 17: aload_2\n 18: invokespecial #36 // Method \"<init>\":(LDay009$Point;LDay009$Point;)V\n 21: areturn\n\n public static Day009$State copy$default(Day009$State, Day009$Point, Day009$Point, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_1\n 2: iand\n 3: ifeq 11\n 6: aload_0\n 7: getfield #23 // Field head:LDay009$Point;\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 tail:LDay009$Point;\n 21: astore_2\n 22: aload_0\n 23: aload_1\n 24: aload_2\n 25: invokevirtual #40 // Method copy:(LDay009$Point;LDay009$Point;)LDay009$State;\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 State(head=\n 9: invokevirtual #51 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #23 // Field head:LDay009$Point;\n 16: invokevirtual #54 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #56 // String , tail=\n 21: invokevirtual #51 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #25 // Field tail:LDay009$Point;\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 head:LDay009$Point;\n 4: invokevirtual #67 // Method Day009$Point.hashCode:()I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #25 // Field tail:LDay009$Point;\n 16: invokevirtual #67 // Method Day009$Point.hashCode:()I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: ireturn\n\n public boolean equals(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: if_acmpne 7\n 5: iconst_1\n 6: ireturn\n 7: aload_1\n 8: instanceof #2 // class Day009$State\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day009$State\n 20: astore_2\n 21: aload_0\n 22: getfield #23 // Field head:LDay009$Point;\n 25: aload_2\n 26: getfield #23 // Field head:LDay009$Point;\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 tail:LDay009$Point;\n 41: aload_2\n 42: getfield #25 // Field tail:LDay009$Point;\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": ""
}
] |
teodor-vasile__aoc-2022-kotlin__2fcfe95/src/main/kotlin/Day11.kt
|
class Day11 {
fun solvePart1(input: String): Int {
// parse the input
val monkeys = input.split("\n\n")
.map { monkey ->
Monkey(
items = getListOfItems(monkey),
operator = getOperator(monkey),
worryMultiplier = getWorryMultiplier(monkey),
divisibleBy = getDivisibleBy(monkey),
actionIsTrue = getActionIsTrue(monkey),
actionIsFalse = getActionIsFalse(monkey),
operationsPerformed = 0
)
}
repeat(20) {doOperations(monkeys)}
monkeys.forEach { println(it) }
println()
return monkeys.sortedByDescending { monkey -> monkey.operationsPerformed }
.take(2)
.map { it.operationsPerformed }
.fold(1) { acc, value -> acc * value }
}
private fun doOperations(monkeys: List<Monkey>) {
monkeys.forEach {monkey ->
if (monkey.items.isNotEmpty()) {
convertWorryMultiplier(monkey)
calculateWorryLevel(monkey)
monkeyGetsBored(monkey)
throwToMonkey(monkey, monkeys)
}
}
}
data class Monkey(
var items: ArrayDeque<Int>,
val operator: String,
val worryMultiplier: String,
val divisibleBy: Int,
val actionIsTrue: Int,
val actionIsFalse: Int,
var operationsPerformed: Int
)
private fun throwToMonkey(monkey: Monkey, monkeys: List<Monkey>) {
repeat(monkey.items.count()) {
if (monkeyGetsBored(monkey) % monkey.divisibleBy == 0) {
monkeys[monkey.actionIsTrue].items.addLast(monkeyGetsBored(monkey))
monkey.items.removeFirst()
monkey.operationsPerformed++
} else {
monkeys[monkey.actionIsFalse].items.addLast(monkeyGetsBored(monkey))
monkey.items.removeFirst()
monkey.operationsPerformed++
}
}
}
private fun monkeyGetsBored(monkey: Monkey): Int {
return calculateWorryLevel(monkey) / 3
}
private fun convertWorryMultiplier(monkey: Monkey): Int {
return if (monkey.worryMultiplier == "old") monkey.items.first() else monkey.worryMultiplier.toInt()
}
private fun calculateWorryLevel(monkey: Monkey): Int {
return when (monkey.operator) {
"*" -> monkey.items.first() * convertWorryMultiplier(monkey)
"/" -> monkey.items.first() / convertWorryMultiplier(monkey)
"+" -> monkey.items.first() + convertWorryMultiplier(monkey)
"-" -> monkey.items.first() - convertWorryMultiplier(monkey)
else -> error("invalid operation")
}
}
private fun getListOfItems(monkey: String): ArrayDeque<Int> {
val worryMultiplier =
monkey.lines()
.find { it.trim().startsWith("Starting") }
.let {
it!!.substring(18, it.length)
.split(",")
.map { it.trim().toInt() }
}
return ArrayDeque(worryMultiplier)
}
private fun getWorryMultiplier(monkey: String): String {
val worryMultiplier = monkey.lines()
.find { it.trim().startsWith("Operation") }
.let {
it!!.substring(25, it.length)
}
return worryMultiplier
}
private fun getOperator(monkey: String): String {
val worryMultiplier =
monkey.lines()
.find { it.trim().startsWith("Operation") }
.let {
it!!.substring(23, 24)
}
return worryMultiplier
}
private fun getDivisibleBy(lines: String): Int {
val regex = """Test: divisible by (\d+)""".toRegex()
val divisibleBy = regex.find(lines)
val (value) = divisibleBy!!.destructured
return value.toInt()
}
private fun getActionIsTrue(lines: String): Int {
val regex = """If true: throw to monkey (\d+)""".toRegex()
val divisibleBy = regex.find(lines)
val (value) = divisibleBy!!.destructured
return value.toInt()
}
private fun getActionIsFalse(lines: String): Int {
val regex = """If false: throw to monkey (\d+)""".toRegex()
val divisibleBy = regex.find(lines)
val (value) = divisibleBy!!.destructured
return value.toInt()
}
}
|
[
{
"class_path": "teodor-vasile__aoc-2022-kotlin__2fcfe95/Day11.class",
"javap": "Compiled from \"Day11.kt\"\npublic final class Day11 {\n public Day11();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int solvePart1(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String input\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #23 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #25 // class java/lang/String\n 14: astore_3\n 15: aload_3\n 16: iconst_0\n 17: ldc #27 // String \\n\\n\n 19: aastore\n 20: aload_3\n 21: iconst_0\n 22: iconst_0\n 23: bipush 6\n 25: aconst_null\n 26: invokestatic #33 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: checkcast #35 // class java/lang/Iterable\n 32: astore_3\n 33: nop\n 34: iconst_0\n 35: istore 4\n 37: aload_3\n 38: astore 5\n 40: new #37 // class java/util/ArrayList\n 43: dup\n 44: aload_3\n 45: bipush 10\n 47: invokestatic #43 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 50: invokespecial #46 // Method java/util/ArrayList.\"<init>\":(I)V\n 53: checkcast #48 // class java/util/Collection\n 56: astore 6\n 58: iconst_0\n 59: istore 7\n 61: aload 5\n 63: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 68: astore 8\n 70: aload 8\n 72: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 77: ifeq 160\n 80: aload 8\n 82: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 87: astore 9\n 89: aload 6\n 91: aload 9\n 93: checkcast #25 // class java/lang/String\n 96: astore 10\n 98: astore 12\n 100: iconst_0\n 101: istore 11\n 103: new #64 // class Day11$Monkey\n 106: dup\n 107: aload_0\n 108: aload 10\n 110: invokespecial #68 // Method getListOfItems:(Ljava/lang/String;)Lkotlin/collections/ArrayDeque;\n 113: aload_0\n 114: aload 10\n 116: invokespecial #72 // Method getOperator:(Ljava/lang/String;)Ljava/lang/String;\n 119: aload_0\n 120: aload 10\n 122: invokespecial #75 // Method getWorryMultiplier:(Ljava/lang/String;)Ljava/lang/String;\n 125: aload_0\n 126: aload 10\n 128: invokespecial #78 // Method getDivisibleBy:(Ljava/lang/String;)I\n 131: aload_0\n 132: aload 10\n 134: invokespecial #81 // Method getActionIsTrue:(Ljava/lang/String;)I\n 137: aload_0\n 138: aload 10\n 140: invokespecial #84 // Method getActionIsFalse:(Ljava/lang/String;)I\n 143: iconst_0\n 144: invokespecial #87 // Method Day11$Monkey.\"<init>\":(Lkotlin/collections/ArrayDeque;Ljava/lang/String;Ljava/lang/String;IIII)V\n 147: nop\n 148: aload 12\n 150: swap\n 151: invokeinterface #91, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 156: pop\n 157: goto 70\n 160: aload 6\n 162: checkcast #93 // class java/util/List\n 165: nop\n 166: astore_2\n 167: bipush 20\n 169: istore_3\n 170: iconst_0\n 171: istore 4\n 173: iload 4\n 175: iload_3\n 176: if_icmpge 197\n 179: iload 4\n 181: istore 5\n 183: iconst_0\n 184: istore 6\n 186: aload_0\n 187: aload_2\n 188: invokespecial #97 // Method doOperations:(Ljava/util/List;)V\n 191: iinc 4, 1\n 194: goto 173\n 197: aload_2\n 198: checkcast #35 // class java/lang/Iterable\n 201: astore_3\n 202: iconst_0\n 203: istore 4\n 205: aload_3\n 206: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 211: astore 5\n 213: aload 5\n 215: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 220: ifeq 255\n 223: aload 5\n 225: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 230: astore 6\n 232: aload 6\n 234: checkcast #64 // class Day11$Monkey\n 237: astore 7\n 239: iconst_0\n 240: istore 8\n 242: getstatic #103 // Field java/lang/System.out:Ljava/io/PrintStream;\n 245: aload 7\n 247: invokevirtual #109 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 250: nop\n 251: nop\n 252: goto 213\n 255: nop\n 256: getstatic #103 // Field java/lang/System.out:Ljava/io/PrintStream;\n 259: invokevirtual #111 // Method java/io/PrintStream.println:()V\n 262: aload_2\n 263: checkcast #35 // class java/lang/Iterable\n 266: astore_3\n 267: iconst_0\n 268: istore 4\n 270: aload_3\n 271: new #113 // class Day11$solvePart1$$inlined$sortedByDescending$1\n 274: dup\n 275: invokespecial #114 // Method Day11$solvePart1$$inlined$sortedByDescending$1.\"<init>\":()V\n 278: checkcast #116 // class java/util/Comparator\n 281: invokestatic #120 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 284: checkcast #35 // class java/lang/Iterable\n 287: iconst_2\n 288: invokestatic #124 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 291: checkcast #35 // class java/lang/Iterable\n 294: astore_3\n 295: nop\n 296: iconst_0\n 297: istore 4\n 299: aload_3\n 300: astore 5\n 302: new #37 // class java/util/ArrayList\n 305: dup\n 306: aload_3\n 307: bipush 10\n 309: invokestatic #43 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 312: invokespecial #46 // Method java/util/ArrayList.\"<init>\":(I)V\n 315: checkcast #48 // class java/util/Collection\n 318: astore 6\n 320: iconst_0\n 321: istore 7\n 323: aload 5\n 325: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 330: astore 8\n 332: aload 8\n 334: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 339: ifeq 385\n 342: aload 8\n 344: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 349: astore 9\n 351: aload 6\n 353: aload 9\n 355: checkcast #64 // class Day11$Monkey\n 358: astore 10\n 360: astore 12\n 362: iconst_0\n 363: istore 11\n 365: aload 10\n 367: invokevirtual #128 // Method Day11$Monkey.getOperationsPerformed:()I\n 370: invokestatic #134 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 373: aload 12\n 375: swap\n 376: invokeinterface #91, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 381: pop\n 382: goto 332\n 385: aload 6\n 387: checkcast #93 // class java/util/List\n 390: nop\n 391: checkcast #35 // class java/lang/Iterable\n 394: astore_3\n 395: iconst_1\n 396: istore 4\n 398: iconst_0\n 399: istore 5\n 401: iload 4\n 403: istore 6\n 405: aload_3\n 406: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 411: astore 7\n 413: aload 7\n 415: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 420: ifeq 459\n 423: aload 7\n 425: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 430: astore 8\n 432: iload 6\n 434: aload 8\n 436: checkcast #136 // class java/lang/Number\n 439: invokevirtual #139 // Method java/lang/Number.intValue:()I\n 442: istore 9\n 444: istore 10\n 446: iconst_0\n 447: istore 11\n 449: iload 10\n 451: iload 9\n 453: imul\n 454: istore 6\n 456: goto 413\n 459: iload 6\n 461: ireturn\n\n private final void doOperations(java.util.List<Day11$Monkey>);\n Code:\n 0: aload_1\n 1: checkcast #35 // class java/lang/Iterable\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: aload_2\n 8: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore 4\n 15: aload 4\n 17: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 22: ifeq 101\n 25: aload 4\n 27: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 32: astore 5\n 34: aload 5\n 36: checkcast #64 // class Day11$Monkey\n 39: astore 6\n 41: iconst_0\n 42: istore 7\n 44: aload 6\n 46: invokevirtual #176 // Method Day11$Monkey.getItems:()Lkotlin/collections/ArrayDeque;\n 49: checkcast #48 // class java/util/Collection\n 52: invokeinterface #179, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 57: ifne 64\n 60: iconst_1\n 61: goto 65\n 64: iconst_0\n 65: ifeq 96\n 68: aload_0\n 69: aload 6\n 71: invokespecial #183 // Method convertWorryMultiplier:(LDay11$Monkey;)I\n 74: pop\n 75: aload_0\n 76: aload 6\n 78: invokespecial #186 // Method calculateWorryLevel:(LDay11$Monkey;)I\n 81: pop\n 82: aload_0\n 83: aload 6\n 85: invokespecial #189 // Method monkeyGetsBored:(LDay11$Monkey;)I\n 88: pop\n 89: aload_0\n 90: aload 6\n 92: aload_1\n 93: invokespecial #193 // Method throwToMonkey:(LDay11$Monkey;Ljava/util/List;)V\n 96: nop\n 97: nop\n 98: goto 15\n 101: nop\n 102: return\n\n private final void throwToMonkey(Day11$Monkey, java.util.List<Day11$Monkey>);\n Code:\n 0: aload_1\n 1: invokevirtual #176 // Method Day11$Monkey.getItems:()Lkotlin/collections/ArrayDeque;\n 4: checkcast #48 // class java/util/Collection\n 7: invokeinterface #198, 1 // InterfaceMethod java/util/Collection.size:()I\n 12: istore_3\n 13: iconst_0\n 14: istore 4\n 16: iload 4\n 18: iload_3\n 19: if_icmpge 150\n 22: iload 4\n 24: istore 5\n 26: iconst_0\n 27: istore 6\n 29: aload_0\n 30: aload_1\n 31: invokespecial #189 // Method monkeyGetsBored:(LDay11$Monkey;)I\n 34: aload_1\n 35: invokevirtual #200 // Method Day11$Monkey.getDivisibleBy:()I\n 38: irem\n 39: ifne 94\n 42: aload_2\n 43: aload_1\n 44: invokevirtual #202 // Method Day11$Monkey.getActionIsTrue:()I\n 47: invokeinterface #206, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 52: checkcast #64 // class Day11$Monkey\n 55: invokevirtual #176 // Method Day11$Monkey.getItems:()Lkotlin/collections/ArrayDeque;\n 58: aload_0\n 59: aload_1\n 60: invokespecial #189 // Method monkeyGetsBored:(LDay11$Monkey;)I\n 63: invokestatic #134 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 66: invokevirtual #211 // Method kotlin/collections/ArrayDeque.addLast:(Ljava/lang/Object;)V\n 69: aload_1\n 70: invokevirtual #176 // Method Day11$Monkey.getItems:()Lkotlin/collections/ArrayDeque;\n 73: invokevirtual #214 // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;\n 76: pop\n 77: aload_1\n 78: invokevirtual #128 // Method Day11$Monkey.getOperationsPerformed:()I\n 81: istore 7\n 83: aload_1\n 84: iload 7\n 86: iconst_1\n 87: iadd\n 88: invokevirtual #217 // Method Day11$Monkey.setOperationsPerformed:(I)V\n 91: goto 143\n 94: aload_2\n 95: aload_1\n 96: invokevirtual #219 // Method Day11$Monkey.getActionIsFalse:()I\n 99: invokeinterface #206, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 104: checkcast #64 // class Day11$Monkey\n 107: invokevirtual #176 // Method Day11$Monkey.getItems:()Lkotlin/collections/ArrayDeque;\n 110: aload_0\n 111: aload_1\n 112: invokespecial #189 // Method monkeyGetsBored:(LDay11$Monkey;)I\n 115: invokestatic #134 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 118: invokevirtual #211 // Method kotlin/collections/ArrayDeque.addLast:(Ljava/lang/Object;)V\n 121: aload_1\n 122: invokevirtual #176 // Method Day11$Monkey.getItems:()Lkotlin/collections/ArrayDeque;\n 125: invokevirtual #214 // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;\n 128: pop\n 129: aload_1\n 130: invokevirtual #128 // Method Day11$Monkey.getOperationsPerformed:()I\n 133: istore 7\n 135: aload_1\n 136: iload 7\n 138: iconst_1\n 139: iadd\n 140: invokevirtual #217 // Method Day11$Monkey.setOperationsPerformed:(I)V\n 143: nop\n 144: iinc 4, 1\n 147: goto 16\n 150: return\n\n private final int monkeyGetsBored(Day11$Monkey);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #186 // Method calculateWorryLevel:(LDay11$Monkey;)I\n 5: iconst_3\n 6: idiv\n 7: ireturn\n\n private final int convertWorryMultiplier(Day11$Monkey);\n Code:\n 0: aload_1\n 1: invokevirtual #223 // Method Day11$Monkey.getWorryMultiplier:()Ljava/lang/String;\n 4: ldc #225 // String old\n 6: invokestatic #229 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 9: ifeq 28\n 12: aload_1\n 13: invokevirtual #176 // Method Day11$Monkey.getItems:()Lkotlin/collections/ArrayDeque;\n 16: invokevirtual #232 // Method kotlin/collections/ArrayDeque.first:()Ljava/lang/Object;\n 19: checkcast #136 // class java/lang/Number\n 22: invokevirtual #139 // Method java/lang/Number.intValue:()I\n 25: goto 35\n 28: aload_1\n 29: invokevirtual #223 // Method Day11$Monkey.getWorryMultiplier:()Ljava/lang/String;\n 32: invokestatic #235 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 35: ireturn\n\n private final int calculateWorryLevel(Day11$Monkey);\n Code:\n 0: aload_1\n 1: invokevirtual #237 // Method Day11$Monkey.getOperator:()Ljava/lang/String;\n 4: astore_2\n 5: aload_2\n 6: invokevirtual #240 // Method java/lang/String.hashCode:()I\n 9: tableswitch { // 42 to 47\n 42: 48\n 43: 60\n 44: 184\n 45: 72\n 46: 184\n 47: 84\n default: 184\n }\n 48: aload_2\n 49: ldc #242 // String *\n 51: invokevirtual #245 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 54: ifne 96\n 57: goto 184\n 60: aload_2\n 61: ldc #247 // String +\n 63: invokevirtual #245 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 66: ifne 140\n 69: goto 184\n 72: aload_2\n 73: ldc #249 // String -\n 75: invokevirtual #245 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 78: ifne 162\n 81: goto 184\n 84: aload_2\n 85: ldc #251 // String /\n 87: invokevirtual #245 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 90: ifne 118\n 93: goto 184\n 96: aload_1\n 97: invokevirtual #176 // Method Day11$Monkey.getItems:()Lkotlin/collections/ArrayDeque;\n 100: invokevirtual #232 // Method kotlin/collections/ArrayDeque.first:()Ljava/lang/Object;\n 103: checkcast #136 // class java/lang/Number\n 106: invokevirtual #139 // Method java/lang/Number.intValue:()I\n 109: aload_0\n 110: aload_1\n 111: invokespecial #183 // Method convertWorryMultiplier:(LDay11$Monkey;)I\n 114: imul\n 115: goto 197\n 118: aload_1\n 119: invokevirtual #176 // Method Day11$Monkey.getItems:()Lkotlin/collections/ArrayDeque;\n 122: invokevirtual #232 // Method kotlin/collections/ArrayDeque.first:()Ljava/lang/Object;\n 125: checkcast #136 // class java/lang/Number\n 128: invokevirtual #139 // Method java/lang/Number.intValue:()I\n 131: aload_0\n 132: aload_1\n 133: invokespecial #183 // Method convertWorryMultiplier:(LDay11$Monkey;)I\n 136: idiv\n 137: goto 197\n 140: aload_1\n 141: invokevirtual #176 // Method Day11$Monkey.getItems:()Lkotlin/collections/ArrayDeque;\n 144: invokevirtual #232 // Method kotlin/collections/ArrayDeque.first:()Ljava/lang/Object;\n 147: checkcast #136 // class java/lang/Number\n 150: invokevirtual #139 // Method java/lang/Number.intValue:()I\n 153: aload_0\n 154: aload_1\n 155: invokespecial #183 // Method convertWorryMultiplier:(LDay11$Monkey;)I\n 158: iadd\n 159: goto 197\n 162: aload_1\n 163: invokevirtual #176 // Method Day11$Monkey.getItems:()Lkotlin/collections/ArrayDeque;\n 166: invokevirtual #232 // Method kotlin/collections/ArrayDeque.first:()Ljava/lang/Object;\n 169: checkcast #136 // class java/lang/Number\n 172: invokevirtual #139 // Method java/lang/Number.intValue:()I\n 175: aload_0\n 176: aload_1\n 177: invokespecial #183 // Method convertWorryMultiplier:(LDay11$Monkey;)I\n 180: isub\n 181: goto 197\n 184: new #253 // class java/lang/IllegalStateException\n 187: dup\n 188: ldc #255 // String invalid operation\n 190: invokevirtual #258 // Method java/lang/Object.toString:()Ljava/lang/String;\n 193: invokespecial #261 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 196: athrow\n 197: ireturn\n\n private final kotlin.collections.ArrayDeque<java.lang.Integer> getListOfItems(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #23 // class java/lang/CharSequence\n 4: invokestatic #266 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 7: checkcast #35 // class java/lang/Iterable\n 10: astore_3\n 11: aload_3\n 12: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 17: astore 4\n 19: aload 4\n 21: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 26: ifeq 76\n 29: aload 4\n 31: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 36: astore 5\n 38: aload 5\n 40: checkcast #25 // class java/lang/String\n 43: astore 6\n 45: iconst_0\n 46: istore 7\n 48: aload 6\n 50: checkcast #23 // class java/lang/CharSequence\n 53: invokestatic #270 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 56: invokevirtual #258 // Method java/lang/Object.toString:()Ljava/lang/String;\n 59: ldc_w #272 // String Starting\n 62: iconst_0\n 63: iconst_2\n 64: aconst_null\n 65: invokestatic #276 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 68: ifeq 19\n 71: aload 5\n 73: goto 77\n 76: aconst_null\n 77: checkcast #25 // class java/lang/String\n 80: astore_3\n 81: iconst_0\n 82: istore 4\n 84: aload_3\n 85: dup\n 86: invokestatic #279 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 89: bipush 18\n 91: aload_3\n 92: invokevirtual #282 // Method java/lang/String.length:()I\n 95: invokevirtual #286 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 98: dup\n 99: ldc_w #288 // String substring(...)\n 102: invokestatic #291 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 105: checkcast #23 // class java/lang/CharSequence\n 108: iconst_1\n 109: anewarray #25 // class java/lang/String\n 112: astore 5\n 114: aload 5\n 116: iconst_0\n 117: ldc_w #293 // String ,\n 120: aastore\n 121: aload 5\n 123: iconst_0\n 124: iconst_0\n 125: bipush 6\n 127: aconst_null\n 128: invokestatic #33 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 131: checkcast #35 // class java/lang/Iterable\n 134: astore 5\n 136: nop\n 137: iconst_0\n 138: istore 6\n 140: aload 5\n 142: astore 7\n 144: new #37 // class java/util/ArrayList\n 147: dup\n 148: aload 5\n 150: bipush 10\n 152: invokestatic #43 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 155: invokespecial #46 // Method java/util/ArrayList.\"<init>\":(I)V\n 158: checkcast #48 // class java/util/Collection\n 161: astore 8\n 163: iconst_0\n 164: istore 9\n 166: aload 7\n 168: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 173: astore 10\n 175: aload 10\n 177: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 182: ifeq 239\n 185: aload 10\n 187: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 192: astore 11\n 194: aload 8\n 196: aload 11\n 198: checkcast #25 // class java/lang/String\n 201: astore 12\n 203: astore 13\n 205: iconst_0\n 206: istore 14\n 208: nop\n 209: aload 12\n 211: checkcast #23 // class java/lang/CharSequence\n 214: invokestatic #270 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 217: invokevirtual #258 // Method java/lang/Object.toString:()Ljava/lang/String;\n 220: invokestatic #235 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 223: nop\n 224: invokestatic #134 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 227: aload 13\n 229: swap\n 230: invokeinterface #91, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 235: pop\n 236: goto 175\n 239: aload 8\n 241: checkcast #93 // class java/util/List\n 244: nop\n 245: nop\n 246: nop\n 247: astore_2\n 248: new #208 // class kotlin/collections/ArrayDeque\n 251: dup\n 252: aload_2\n 253: checkcast #48 // class java/util/Collection\n 256: invokespecial #296 // Method kotlin/collections/ArrayDeque.\"<init>\":(Ljava/util/Collection;)V\n 259: areturn\n\n private final java.lang.String getWorryMultiplier(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #23 // class java/lang/CharSequence\n 4: invokestatic #266 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 7: checkcast #35 // class java/lang/Iterable\n 10: astore_3\n 11: aload_3\n 12: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 17: astore 4\n 19: aload 4\n 21: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 26: ifeq 76\n 29: aload 4\n 31: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 36: astore 5\n 38: aload 5\n 40: checkcast #25 // class java/lang/String\n 43: astore 6\n 45: iconst_0\n 46: istore 7\n 48: aload 6\n 50: checkcast #23 // class java/lang/CharSequence\n 53: invokestatic #270 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 56: invokevirtual #258 // Method java/lang/Object.toString:()Ljava/lang/String;\n 59: ldc_w #302 // String Operation\n 62: iconst_0\n 63: iconst_2\n 64: aconst_null\n 65: invokestatic #276 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 68: ifeq 19\n 71: aload 5\n 73: goto 77\n 76: aconst_null\n 77: checkcast #25 // class java/lang/String\n 80: astore_3\n 81: iconst_0\n 82: istore 4\n 84: aload_3\n 85: dup\n 86: invokestatic #279 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 89: bipush 25\n 91: aload_3\n 92: invokevirtual #282 // Method java/lang/String.length:()I\n 95: invokevirtual #286 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 98: dup\n 99: ldc_w #288 // String substring(...)\n 102: invokestatic #291 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 105: nop\n 106: nop\n 107: astore_2\n 108: aload_2\n 109: areturn\n\n private final java.lang.String getOperator(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #23 // class java/lang/CharSequence\n 4: invokestatic #266 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 7: checkcast #35 // class java/lang/Iterable\n 10: astore_3\n 11: aload_3\n 12: invokeinterface #52, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 17: astore 4\n 19: aload 4\n 21: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 26: ifeq 76\n 29: aload 4\n 31: invokeinterface #62, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 36: astore 5\n 38: aload 5\n 40: checkcast #25 // class java/lang/String\n 43: astore 6\n 45: iconst_0\n 46: istore 7\n 48: aload 6\n 50: checkcast #23 // class java/lang/CharSequence\n 53: invokestatic #270 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 56: invokevirtual #258 // Method java/lang/Object.toString:()Ljava/lang/String;\n 59: ldc_w #302 // String Operation\n 62: iconst_0\n 63: iconst_2\n 64: aconst_null\n 65: invokestatic #276 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 68: ifeq 19\n 71: aload 5\n 73: goto 77\n 76: aconst_null\n 77: checkcast #25 // class java/lang/String\n 80: astore_3\n 81: iconst_0\n 82: istore 4\n 84: aload_3\n 85: dup\n 86: invokestatic #279 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 89: bipush 23\n 91: bipush 24\n 93: invokevirtual #286 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 96: dup\n 97: ldc_w #288 // String substring(...)\n 100: invokestatic #291 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 103: nop\n 104: nop\n 105: astore_2\n 106: aload_2\n 107: areturn\n\n private final int getDivisibleBy(java.lang.String);\n Code:\n 0: new #308 // class kotlin/text/Regex\n 3: dup\n 4: ldc_w #310 // String Test: divisible by (\\\\d+)\n 7: invokespecial #311 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 10: astore_2\n 11: aload_2\n 12: aload_1\n 13: checkcast #23 // class java/lang/CharSequence\n 16: iconst_0\n 17: iconst_2\n 18: aconst_null\n 19: invokestatic #315 // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;\n 22: astore_3\n 23: aload_3\n 24: dup\n 25: invokestatic #279 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 28: invokeinterface #321, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 33: invokevirtual #327 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 36: invokeinterface #331, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 41: iconst_1\n 42: invokeinterface #206, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 47: checkcast #25 // class java/lang/String\n 50: astore 4\n 52: aload 4\n 54: invokestatic #235 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 57: ireturn\n\n private final int getActionIsTrue(java.lang.String);\n Code:\n 0: new #308 // class kotlin/text/Regex\n 3: dup\n 4: ldc_w #337 // String If true: throw to monkey (\\\\d+)\n 7: invokespecial #311 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 10: astore_2\n 11: aload_2\n 12: aload_1\n 13: checkcast #23 // class java/lang/CharSequence\n 16: iconst_0\n 17: iconst_2\n 18: aconst_null\n 19: invokestatic #315 // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;\n 22: astore_3\n 23: aload_3\n 24: dup\n 25: invokestatic #279 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 28: invokeinterface #321, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 33: invokevirtual #327 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 36: invokeinterface #331, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 41: iconst_1\n 42: invokeinterface #206, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 47: checkcast #25 // class java/lang/String\n 50: astore 4\n 52: aload 4\n 54: invokestatic #235 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 57: ireturn\n\n private final int getActionIsFalse(java.lang.String);\n Code:\n 0: new #308 // class kotlin/text/Regex\n 3: dup\n 4: ldc_w #339 // String If false: throw to monkey (\\\\d+)\n 7: invokespecial #311 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 10: astore_2\n 11: aload_2\n 12: aload_1\n 13: checkcast #23 // class java/lang/CharSequence\n 16: iconst_0\n 17: iconst_2\n 18: aconst_null\n 19: invokestatic #315 // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;\n 22: astore_3\n 23: aload_3\n 24: dup\n 25: invokestatic #279 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 28: invokeinterface #321, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 33: invokevirtual #327 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 36: invokeinterface #331, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 41: iconst_1\n 42: invokeinterface #206, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 47: checkcast #25 // class java/lang/String\n 50: astore 4\n 52: aload 4\n 54: invokestatic #235 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 57: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "teodor-vasile__aoc-2022-kotlin__2fcfe95/Day11$solvePart1$$inlined$sortedByDescending$1.class",
"javap": "Compiled from \"Comparisons.kt\"\npublic final class Day11$solvePart1$$inlined$sortedByDescending$1<T> implements java.util.Comparator {\n public Day11$solvePart1$$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 Day11$Monkey\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method Day11$Monkey.getOperationsPerformed:()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 Day11$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 Day11$Monkey.getOperationsPerformed:()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": "teodor-vasile__aoc-2022-kotlin__2fcfe95/Day11$Monkey.class",
"javap": "Compiled from \"Day11.kt\"\npublic final class Day11$Monkey {\n private kotlin.collections.ArrayDeque<java.lang.Integer> items;\n\n private final java.lang.String operator;\n\n private final java.lang.String worryMultiplier;\n\n private final int divisibleBy;\n\n private final int actionIsTrue;\n\n private final int actionIsFalse;\n\n private int operationsPerformed;\n\n public Day11$Monkey(kotlin.collections.ArrayDeque<java.lang.Integer>, java.lang.String, java.lang.String, int, int, int, int);\n Code:\n 0: aload_1\n 1: ldc #10 // String items\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #18 // String operator\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_3\n 13: ldc #20 // String worryMultiplier\n 15: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: aload_0\n 19: invokespecial #23 // Method java/lang/Object.\"<init>\":()V\n 22: aload_0\n 23: aload_1\n 24: putfield #26 // Field items:Lkotlin/collections/ArrayDeque;\n 27: aload_0\n 28: aload_2\n 29: putfield #29 // Field operator:Ljava/lang/String;\n 32: aload_0\n 33: aload_3\n 34: putfield #31 // Field worryMultiplier:Ljava/lang/String;\n 37: aload_0\n 38: iload 4\n 40: putfield #35 // Field divisibleBy:I\n 43: aload_0\n 44: iload 5\n 46: putfield #38 // Field actionIsTrue:I\n 49: aload_0\n 50: iload 6\n 52: putfield #41 // Field actionIsFalse:I\n 55: aload_0\n 56: iload 7\n 58: putfield #44 // Field operationsPerformed:I\n 61: return\n\n public final kotlin.collections.ArrayDeque<java.lang.Integer> getItems();\n Code:\n 0: aload_0\n 1: getfield #26 // Field items:Lkotlin/collections/ArrayDeque;\n 4: areturn\n\n public final void setItems(kotlin.collections.ArrayDeque<java.lang.Integer>);\n Code:\n 0: aload_1\n 1: ldc #54 // 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 #26 // Field items:Lkotlin/collections/ArrayDeque;\n 11: return\n\n public final java.lang.String getOperator();\n Code:\n 0: aload_0\n 1: getfield #29 // Field operator:Ljava/lang/String;\n 4: areturn\n\n public final java.lang.String getWorryMultiplier();\n Code:\n 0: aload_0\n 1: getfield #31 // Field worryMultiplier:Ljava/lang/String;\n 4: areturn\n\n public final int getDivisibleBy();\n Code:\n 0: aload_0\n 1: getfield #35 // Field divisibleBy:I\n 4: ireturn\n\n public final int getActionIsTrue();\n Code:\n 0: aload_0\n 1: getfield #38 // Field actionIsTrue:I\n 4: ireturn\n\n public final int getActionIsFalse();\n Code:\n 0: aload_0\n 1: getfield #41 // Field actionIsFalse:I\n 4: ireturn\n\n public final int getOperationsPerformed();\n Code:\n 0: aload_0\n 1: getfield #44 // Field operationsPerformed:I\n 4: ireturn\n\n public final void setOperationsPerformed(int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: putfield #44 // Field operationsPerformed:I\n 5: return\n\n public final kotlin.collections.ArrayDeque<java.lang.Integer> component1();\n Code:\n 0: aload_0\n 1: getfield #26 // Field items:Lkotlin/collections/ArrayDeque;\n 4: areturn\n\n public final java.lang.String component2();\n Code:\n 0: aload_0\n 1: getfield #29 // Field operator:Ljava/lang/String;\n 4: areturn\n\n public final java.lang.String component3();\n Code:\n 0: aload_0\n 1: getfield #31 // Field worryMultiplier:Ljava/lang/String;\n 4: areturn\n\n public final int component4();\n Code:\n 0: aload_0\n 1: getfield #35 // Field divisibleBy:I\n 4: ireturn\n\n public final int component5();\n Code:\n 0: aload_0\n 1: getfield #38 // Field actionIsTrue:I\n 4: ireturn\n\n public final int component6();\n Code:\n 0: aload_0\n 1: getfield #41 // Field actionIsFalse:I\n 4: ireturn\n\n public final int component7();\n Code:\n 0: aload_0\n 1: getfield #44 // Field operationsPerformed:I\n 4: ireturn\n\n public final Day11$Monkey copy(kotlin.collections.ArrayDeque<java.lang.Integer>, java.lang.String, java.lang.String, int, int, int, int);\n Code:\n 0: aload_1\n 1: ldc #10 // String items\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #18 // String operator\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_3\n 13: ldc #20 // String worryMultiplier\n 15: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: new #2 // class Day11$Monkey\n 21: dup\n 22: aload_1\n 23: aload_2\n 24: aload_3\n 25: iload 4\n 27: iload 5\n 29: iload 6\n 31: iload 7\n 33: invokespecial #76 // Method \"<init>\":(Lkotlin/collections/ArrayDeque;Ljava/lang/String;Ljava/lang/String;IIII)V\n 36: areturn\n\n public static Day11$Monkey copy$default(Day11$Monkey, kotlin.collections.ArrayDeque, java.lang.String, java.lang.String, int, int, int, int, int, java.lang.Object);\n Code:\n 0: iload 8\n 2: iconst_1\n 3: iand\n 4: ifeq 12\n 7: aload_0\n 8: getfield #26 // Field items:Lkotlin/collections/ArrayDeque;\n 11: astore_1\n 12: iload 8\n 14: iconst_2\n 15: iand\n 16: ifeq 24\n 19: aload_0\n 20: getfield #29 // Field operator:Ljava/lang/String;\n 23: astore_2\n 24: iload 8\n 26: iconst_4\n 27: iand\n 28: ifeq 36\n 31: aload_0\n 32: getfield #31 // Field worryMultiplier:Ljava/lang/String;\n 35: astore_3\n 36: iload 8\n 38: bipush 8\n 40: iand\n 41: ifeq 50\n 44: aload_0\n 45: getfield #35 // Field divisibleBy:I\n 48: istore 4\n 50: iload 8\n 52: bipush 16\n 54: iand\n 55: ifeq 64\n 58: aload_0\n 59: getfield #38 // Field actionIsTrue:I\n 62: istore 5\n 64: iload 8\n 66: bipush 32\n 68: iand\n 69: ifeq 78\n 72: aload_0\n 73: getfield #41 // Field actionIsFalse:I\n 76: istore 6\n 78: iload 8\n 80: bipush 64\n 82: iand\n 83: ifeq 92\n 86: aload_0\n 87: getfield #44 // Field operationsPerformed:I\n 90: istore 7\n 92: aload_0\n 93: aload_1\n 94: aload_2\n 95: aload_3\n 96: iload 4\n 98: iload 5\n 100: iload 6\n 102: iload 7\n 104: invokevirtual #80 // Method copy:(Lkotlin/collections/ArrayDeque;Ljava/lang/String;Ljava/lang/String;IIII)LDay11$Monkey;\n 107: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #83 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #84 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #86 // String Monkey(items=\n 9: invokevirtual #90 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #26 // Field items:Lkotlin/collections/ArrayDeque;\n 16: invokevirtual #93 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #95 // String , operator=\n 21: invokevirtual #90 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #29 // Field operator:Ljava/lang/String;\n 28: invokevirtual #90 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 31: ldc #97 // String , worryMultiplier=\n 33: invokevirtual #90 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #31 // Field worryMultiplier:Ljava/lang/String;\n 40: invokevirtual #90 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 43: ldc #99 // String , divisibleBy=\n 45: invokevirtual #90 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: aload_0\n 49: getfield #35 // Field divisibleBy:I\n 52: invokevirtual #102 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 55: ldc #104 // String , actionIsTrue=\n 57: invokevirtual #90 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 60: aload_0\n 61: getfield #38 // Field actionIsTrue:I\n 64: invokevirtual #102 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 67: ldc #106 // String , actionIsFalse=\n 69: invokevirtual #90 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 72: aload_0\n 73: getfield #41 // Field actionIsFalse:I\n 76: invokevirtual #102 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 79: ldc #108 // String , operationsPerformed=\n 81: invokevirtual #90 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 84: aload_0\n 85: getfield #44 // Field operationsPerformed:I\n 88: invokevirtual #102 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 91: bipush 41\n 93: invokevirtual #111 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 96: invokevirtual #113 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 99: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #26 // Field items:Lkotlin/collections/ArrayDeque;\n 4: invokevirtual #118 // Method kotlin/collections/ArrayDeque.hashCode:()I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #29 // Field operator:Ljava/lang/String;\n 16: invokevirtual #121 // Method java/lang/String.hashCode:()I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: bipush 31\n 24: imul\n 25: aload_0\n 26: getfield #31 // Field worryMultiplier:Ljava/lang/String;\n 29: invokevirtual #121 // Method java/lang/String.hashCode:()I\n 32: iadd\n 33: istore_1\n 34: iload_1\n 35: bipush 31\n 37: imul\n 38: aload_0\n 39: getfield #35 // Field divisibleBy:I\n 42: invokestatic #126 // Method java/lang/Integer.hashCode:(I)I\n 45: iadd\n 46: istore_1\n 47: iload_1\n 48: bipush 31\n 50: imul\n 51: aload_0\n 52: getfield #38 // Field actionIsTrue:I\n 55: invokestatic #126 // Method java/lang/Integer.hashCode:(I)I\n 58: iadd\n 59: istore_1\n 60: iload_1\n 61: bipush 31\n 63: imul\n 64: aload_0\n 65: getfield #41 // Field actionIsFalse:I\n 68: invokestatic #126 // Method java/lang/Integer.hashCode:(I)I\n 71: iadd\n 72: istore_1\n 73: iload_1\n 74: bipush 31\n 76: imul\n 77: aload_0\n 78: getfield #44 // Field operationsPerformed:I\n 81: invokestatic #126 // Method java/lang/Integer.hashCode:(I)I\n 84: iadd\n 85: istore_1\n 86: iload_1\n 87: 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$Monkey\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day11$Monkey\n 20: astore_2\n 21: aload_0\n 22: getfield #26 // Field items:Lkotlin/collections/ArrayDeque;\n 25: aload_2\n 26: getfield #26 // Field items:Lkotlin/collections/ArrayDeque;\n 29: invokestatic #134 // 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 #29 // Field operator:Ljava/lang/String;\n 41: aload_2\n 42: getfield #29 // Field operator:Ljava/lang/String;\n 45: invokestatic #134 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 48: ifne 53\n 51: iconst_0\n 52: ireturn\n 53: aload_0\n 54: getfield #31 // Field worryMultiplier:Ljava/lang/String;\n 57: aload_2\n 58: getfield #31 // Field worryMultiplier:Ljava/lang/String;\n 61: invokestatic #134 // 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: aload_0\n 70: getfield #35 // Field divisibleBy:I\n 73: aload_2\n 74: getfield #35 // Field divisibleBy:I\n 77: if_icmpeq 82\n 80: iconst_0\n 81: ireturn\n 82: aload_0\n 83: getfield #38 // Field actionIsTrue:I\n 86: aload_2\n 87: getfield #38 // Field actionIsTrue:I\n 90: if_icmpeq 95\n 93: iconst_0\n 94: ireturn\n 95: aload_0\n 96: getfield #41 // Field actionIsFalse:I\n 99: aload_2\n 100: getfield #41 // Field actionIsFalse:I\n 103: if_icmpeq 108\n 106: iconst_0\n 107: ireturn\n 108: aload_0\n 109: getfield #44 // Field operationsPerformed:I\n 112: aload_2\n 113: getfield #44 // Field operationsPerformed:I\n 116: if_icmpeq 121\n 119: iconst_0\n 120: ireturn\n 121: iconst_1\n 122: ireturn\n}\n",
"javap_err": ""
}
] |
teodor-vasile__aoc-2022-kotlin__2fcfe95/src/main/kotlin/Day005.kt
|
class Day005 {
data class Instruction(val count: Int, val source: Int, val target: Int)
fun part1(lines: List<String>): String {
val numberOfContainers = lines.first { it.trim().startsWith("1") }.trim().last().digitToInt()
val containers = List(numberOfContainers) { ArrayDeque<Char>() }
createContainers(lines, containers as MutableList<ArrayDeque<Char>>)
val instructions: List<Instruction> = getInstructions(lines)
instructions.forEach { instruction ->
repeat(instruction.count) {
if (containers[instruction.source - 1].isNotEmpty()) {
containers[instruction.target - 1].addFirst(containers[instruction.source - 1].removeFirst())
}
}
}
return containers.map { it.first() }.joinToString("")
}
fun part2(lines: List<String>): String {
val numberOfContainers = lines.first { it.trim().startsWith("1") }.trim().last().digitToInt()
val containers = List(numberOfContainers) { ArrayDeque<Char>() }.toMutableList()
createContainers(lines, containers)
val instructions: List<Instruction> = getInstructions(lines)
instructions.forEach { instr ->
containers[instr.target - 1].addAll(0, containers[instr.source - 1].take(instr.count))
repeat(instr.count) { containers[instr.source - 1].removeFirst() }
}
return containers.map { it.first() }.joinToString("")
}
private fun getInstructions(lines: List<String>): List<Instruction> {
val regex = """move (\d+) from (\d+) to (\d+)""".toRegex()
val instructions: List<Instruction> = lines
.dropWhile { !it.trim().startsWith("move") }
.map {
val matchResult = regex.find(it)
val (count, source, target) = matchResult!!.destructured
Instruction(count.toInt(), source.toInt(), target.toInt())
}
return instructions
}
private fun createContainers(
lines: List<String>,
containers: MutableList<ArrayDeque<Char>>,
) {
lines
.takeWhile { !it.trim().startsWith("1") }
.map { line ->
line.slice(1..line.length step 4)
.mapIndexed { containerNumber, value ->
if (value.isLetter()) containers[containerNumber].addLast(value)
}
}
}
}
|
[
{
"class_path": "teodor-vasile__aoc-2022-kotlin__2fcfe95/Day005$Instruction.class",
"javap": "Compiled from \"Day005.kt\"\npublic final class Day005$Instruction {\n private final int count;\n\n private final int source;\n\n private final int target;\n\n public Day005$Instruction(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 count:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field source:I\n 14: aload_0\n 15: iload_3\n 16: putfield #19 // Field target:I\n 19: return\n\n public final int getCount();\n Code:\n 0: aload_0\n 1: getfield #13 // Field count:I\n 4: ireturn\n\n public final int getSource();\n Code:\n 0: aload_0\n 1: getfield #16 // Field source:I\n 4: ireturn\n\n public final int getTarget();\n Code:\n 0: aload_0\n 1: getfield #19 // Field target:I\n 4: ireturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field count:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field source:I\n 4: ireturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #19 // Field target:I\n 4: ireturn\n\n public final Day005$Instruction copy(int, int, int);\n Code:\n 0: new #2 // class Day005$Instruction\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 Day005$Instruction copy$default(Day005$Instruction, 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 count: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 source: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 target: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)LDay005$Instruction;\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 Instruction(count=\n 9: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field count:I\n 16: invokevirtual #51 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #53 // String , source=\n 21: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #16 // Field source:I\n 28: invokevirtual #51 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #55 // String , target=\n 33: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #19 // Field target: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 count: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 source: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 target: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 Day005$Instruction\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day005$Instruction\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field count:I\n 25: aload_2\n 26: getfield #13 // Field count:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field source:I\n 38: aload_2\n 39: getfield #16 // Field source:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: aload_0\n 48: getfield #19 // Field target:I\n 51: aload_2\n 52: getfield #19 // Field target: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": "teodor-vasile__aoc-2022-kotlin__2fcfe95/Day005.class",
"javap": "Compiled from \"Day005.kt\"\npublic final class Day005 {\n public Day005();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final java.lang.String part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String lines\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #24 // class java/lang/Iterable\n 10: astore_3\n 11: iconst_0\n 12: istore 4\n 14: aload_3\n 15: invokeinterface #28, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 20: astore 5\n 22: aload 5\n 24: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 29: ifeq 78\n 32: aload 5\n 34: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 39: astore 6\n 41: aload 6\n 43: checkcast #40 // class java/lang/String\n 46: astore 7\n 48: iconst_0\n 49: istore 8\n 51: aload 7\n 53: checkcast #42 // class java/lang/CharSequence\n 56: invokestatic #48 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 59: invokevirtual #52 // Method java/lang/Object.toString:()Ljava/lang/String;\n 62: ldc #54 // String 1\n 64: iconst_0\n 65: iconst_2\n 66: aconst_null\n 67: invokestatic #58 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 70: ifeq 22\n 73: aload 6\n 75: goto 88\n 78: new #60 // class java/util/NoSuchElementException\n 81: dup\n 82: ldc #62 // String Collection contains no element matching the predicate.\n 84: invokespecial #65 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 87: athrow\n 88: checkcast #40 // class java/lang/String\n 91: checkcast #42 // class java/lang/CharSequence\n 94: invokestatic #48 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 97: invokevirtual #52 // Method java/lang/Object.toString:()Ljava/lang/String;\n 100: checkcast #42 // class java/lang/CharSequence\n 103: invokestatic #69 // Method kotlin/text/StringsKt.last:(Ljava/lang/CharSequence;)C\n 106: invokestatic #75 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 109: istore_2\n 110: new #77 // class java/util/ArrayList\n 113: dup\n 114: iload_2\n 115: invokespecial #80 // Method java/util/ArrayList.\"<init>\":(I)V\n 118: astore 4\n 120: iconst_0\n 121: istore 5\n 123: iload 5\n 125: iload_2\n 126: if_icmpge 164\n 129: iload 5\n 131: istore 6\n 133: aload 4\n 135: iload 6\n 137: istore 7\n 139: astore 15\n 141: iconst_0\n 142: istore 8\n 144: new #82 // class kotlin/collections/ArrayDeque\n 147: dup\n 148: invokespecial #83 // Method kotlin/collections/ArrayDeque.\"<init>\":()V\n 151: aload 15\n 153: swap\n 154: invokevirtual #87 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 157: pop\n 158: iinc 5, 1\n 161: goto 123\n 164: aload 4\n 166: checkcast #89 // class java/util/List\n 169: astore_3\n 170: aload_0\n 171: aload_1\n 172: aload_3\n 173: invokestatic #95 // Method kotlin/jvm/internal/TypeIntrinsics.asMutableList:(Ljava/lang/Object;)Ljava/util/List;\n 176: invokespecial #99 // Method createContainers:(Ljava/util/List;Ljava/util/List;)V\n 179: aload_0\n 180: aload_1\n 181: invokespecial #103 // Method getInstructions:(Ljava/util/List;)Ljava/util/List;\n 184: astore 4\n 186: aload 4\n 188: checkcast #24 // class java/lang/Iterable\n 191: astore 5\n 193: iconst_0\n 194: istore 6\n 196: aload 5\n 198: invokeinterface #28, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 203: astore 7\n 205: aload 7\n 207: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 212: ifeq 340\n 215: aload 7\n 217: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 222: astore 8\n 224: aload 8\n 226: checkcast #105 // class Day005$Instruction\n 229: astore 9\n 231: iconst_0\n 232: istore 10\n 234: aload 9\n 236: invokevirtual #109 // Method Day005$Instruction.getCount:()I\n 239: istore 11\n 241: iconst_0\n 242: istore 12\n 244: iload 12\n 246: iload 11\n 248: if_icmpge 335\n 251: iload 12\n 253: istore 13\n 255: iconst_0\n 256: istore 14\n 258: aload_3\n 259: aload 9\n 261: invokevirtual #112 // Method Day005$Instruction.getSource:()I\n 264: iconst_1\n 265: isub\n 266: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 271: checkcast #118 // class java/util/Collection\n 274: invokeinterface #121, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 279: ifne 286\n 282: iconst_1\n 283: goto 287\n 286: iconst_0\n 287: ifeq 328\n 290: aload_3\n 291: aload 9\n 293: invokevirtual #124 // Method Day005$Instruction.getTarget:()I\n 296: iconst_1\n 297: isub\n 298: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 303: checkcast #82 // class kotlin/collections/ArrayDeque\n 306: aload_3\n 307: aload 9\n 309: invokevirtual #112 // Method Day005$Instruction.getSource:()I\n 312: iconst_1\n 313: isub\n 314: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 319: checkcast #82 // class kotlin/collections/ArrayDeque\n 322: invokevirtual #127 // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;\n 325: invokevirtual #131 // Method kotlin/collections/ArrayDeque.addFirst:(Ljava/lang/Object;)V\n 328: nop\n 329: iinc 12, 1\n 332: goto 244\n 335: nop\n 336: nop\n 337: goto 205\n 340: nop\n 341: aload_3\n 342: checkcast #24 // class java/lang/Iterable\n 345: astore 5\n 347: iconst_0\n 348: istore 6\n 350: aload 5\n 352: astore 7\n 354: new #77 // class java/util/ArrayList\n 357: dup\n 358: aload 5\n 360: bipush 10\n 362: invokestatic #137 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 365: invokespecial #80 // Method java/util/ArrayList.\"<init>\":(I)V\n 368: checkcast #118 // class java/util/Collection\n 371: astore 8\n 373: iconst_0\n 374: istore 9\n 376: aload 7\n 378: invokeinterface #28, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 383: astore 10\n 385: aload 10\n 387: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 392: ifeq 444\n 395: aload 10\n 397: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 402: astore 11\n 404: aload 8\n 406: aload 11\n 408: checkcast #82 // class kotlin/collections/ArrayDeque\n 411: astore 12\n 413: astore 15\n 415: iconst_0\n 416: istore 13\n 418: aload 12\n 420: invokevirtual #140 // Method kotlin/collections/ArrayDeque.first:()Ljava/lang/Object;\n 423: checkcast #142 // class java/lang/Character\n 426: invokevirtual #146 // Method java/lang/Character.charValue:()C\n 429: invokestatic #150 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 432: aload 15\n 434: swap\n 435: invokeinterface #151, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 440: pop\n 441: goto 385\n 444: aload 8\n 446: checkcast #89 // class java/util/List\n 449: nop\n 450: checkcast #24 // class java/lang/Iterable\n 453: ldc #153 // String\n 455: checkcast #42 // class java/lang/CharSequence\n 458: aconst_null\n 459: aconst_null\n 460: iconst_0\n 461: aconst_null\n 462: aconst_null\n 463: bipush 62\n 465: aconst_null\n 466: invokestatic #157 // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;\n 469: areturn\n\n public final java.lang.String part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String lines\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #24 // class java/lang/Iterable\n 10: astore_3\n 11: iconst_0\n 12: istore 4\n 14: aload_3\n 15: invokeinterface #28, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 20: astore 5\n 22: aload 5\n 24: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 29: ifeq 78\n 32: aload 5\n 34: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 39: astore 6\n 41: aload 6\n 43: checkcast #40 // class java/lang/String\n 46: astore 7\n 48: iconst_0\n 49: istore 8\n 51: aload 7\n 53: checkcast #42 // class java/lang/CharSequence\n 56: invokestatic #48 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 59: invokevirtual #52 // Method java/lang/Object.toString:()Ljava/lang/String;\n 62: ldc #54 // String 1\n 64: iconst_0\n 65: iconst_2\n 66: aconst_null\n 67: invokestatic #58 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 70: ifeq 22\n 73: aload 6\n 75: goto 88\n 78: new #60 // class java/util/NoSuchElementException\n 81: dup\n 82: ldc #62 // String Collection contains no element matching the predicate.\n 84: invokespecial #65 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 87: athrow\n 88: checkcast #40 // class java/lang/String\n 91: checkcast #42 // class java/lang/CharSequence\n 94: invokestatic #48 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 97: invokevirtual #52 // Method java/lang/Object.toString:()Ljava/lang/String;\n 100: checkcast #42 // class java/lang/CharSequence\n 103: invokestatic #69 // Method kotlin/text/StringsKt.last:(Ljava/lang/CharSequence;)C\n 106: invokestatic #75 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 109: istore_2\n 110: new #77 // class java/util/ArrayList\n 113: dup\n 114: iload_2\n 115: invokespecial #80 // Method java/util/ArrayList.\"<init>\":(I)V\n 118: astore 4\n 120: iconst_0\n 121: istore 5\n 123: iload 5\n 125: iload_2\n 126: if_icmpge 164\n 129: iload 5\n 131: istore 6\n 133: aload 4\n 135: iload 6\n 137: istore 7\n 139: astore 15\n 141: iconst_0\n 142: istore 8\n 144: new #82 // class kotlin/collections/ArrayDeque\n 147: dup\n 148: invokespecial #83 // Method kotlin/collections/ArrayDeque.\"<init>\":()V\n 151: aload 15\n 153: swap\n 154: invokevirtual #87 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 157: pop\n 158: iinc 5, 1\n 161: goto 123\n 164: aload 4\n 166: checkcast #89 // class java/util/List\n 169: checkcast #118 // class java/util/Collection\n 172: invokestatic #191 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 175: astore_3\n 176: aload_0\n 177: aload_1\n 178: aload_3\n 179: invokespecial #99 // Method createContainers:(Ljava/util/List;Ljava/util/List;)V\n 182: aload_0\n 183: aload_1\n 184: invokespecial #103 // Method getInstructions:(Ljava/util/List;)Ljava/util/List;\n 187: astore 4\n 189: aload 4\n 191: checkcast #24 // class java/lang/Iterable\n 194: astore 5\n 196: iconst_0\n 197: istore 6\n 199: aload 5\n 201: invokeinterface #28, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 206: astore 7\n 208: aload 7\n 210: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 215: ifeq 340\n 218: aload 7\n 220: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 225: astore 8\n 227: aload 8\n 229: checkcast #105 // class Day005$Instruction\n 232: astore 9\n 234: iconst_0\n 235: istore 10\n 237: aload_3\n 238: aload 9\n 240: invokevirtual #124 // Method Day005$Instruction.getTarget:()I\n 243: iconst_1\n 244: isub\n 245: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 250: checkcast #82 // class kotlin/collections/ArrayDeque\n 253: iconst_0\n 254: aload_3\n 255: aload 9\n 257: invokevirtual #112 // Method Day005$Instruction.getSource:()I\n 260: iconst_1\n 261: isub\n 262: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 267: checkcast #24 // class java/lang/Iterable\n 270: aload 9\n 272: invokevirtual #109 // Method Day005$Instruction.getCount:()I\n 275: invokestatic #195 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 278: checkcast #118 // class java/util/Collection\n 281: invokevirtual #199 // Method kotlin/collections/ArrayDeque.addAll:(ILjava/util/Collection;)Z\n 284: pop\n 285: aload 9\n 287: invokevirtual #109 // Method Day005$Instruction.getCount:()I\n 290: istore 11\n 292: iconst_0\n 293: istore 12\n 295: iload 12\n 297: iload 11\n 299: if_icmpge 335\n 302: iload 12\n 304: istore 13\n 306: iconst_0\n 307: istore 14\n 309: aload_3\n 310: aload 9\n 312: invokevirtual #112 // Method Day005$Instruction.getSource:()I\n 315: iconst_1\n 316: isub\n 317: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 322: checkcast #82 // class kotlin/collections/ArrayDeque\n 325: invokevirtual #127 // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;\n 328: pop\n 329: iinc 12, 1\n 332: goto 295\n 335: nop\n 336: nop\n 337: goto 208\n 340: nop\n 341: aload_3\n 342: checkcast #24 // class java/lang/Iterable\n 345: astore 5\n 347: iconst_0\n 348: istore 6\n 350: aload 5\n 352: astore 7\n 354: new #77 // class java/util/ArrayList\n 357: dup\n 358: aload 5\n 360: bipush 10\n 362: invokestatic #137 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 365: invokespecial #80 // Method java/util/ArrayList.\"<init>\":(I)V\n 368: checkcast #118 // class java/util/Collection\n 371: astore 8\n 373: iconst_0\n 374: istore 9\n 376: aload 7\n 378: invokeinterface #28, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 383: astore 10\n 385: aload 10\n 387: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 392: ifeq 444\n 395: aload 10\n 397: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 402: astore 11\n 404: aload 8\n 406: aload 11\n 408: checkcast #82 // class kotlin/collections/ArrayDeque\n 411: astore 12\n 413: astore 15\n 415: iconst_0\n 416: istore 13\n 418: aload 12\n 420: invokevirtual #140 // Method kotlin/collections/ArrayDeque.first:()Ljava/lang/Object;\n 423: checkcast #142 // class java/lang/Character\n 426: invokevirtual #146 // Method java/lang/Character.charValue:()C\n 429: invokestatic #150 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 432: aload 15\n 434: swap\n 435: invokeinterface #151, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 440: pop\n 441: goto 385\n 444: aload 8\n 446: checkcast #89 // class java/util/List\n 449: nop\n 450: checkcast #24 // class java/lang/Iterable\n 453: ldc #153 // String\n 455: checkcast #42 // class java/lang/CharSequence\n 458: aconst_null\n 459: aconst_null\n 460: iconst_0\n 461: aconst_null\n 462: aconst_null\n 463: bipush 62\n 465: aconst_null\n 466: invokestatic #157 // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;\n 469: areturn\n\n private final java.util.List<Day005$Instruction> getInstructions(java.util.List<java.lang.String>);\n Code:\n 0: new #208 // class kotlin/text/Regex\n 3: dup\n 4: ldc #210 // String move (\\\\d+) from (\\\\d+) to (\\\\d+)\n 6: invokespecial #211 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 9: astore_2\n 10: aload_1\n 11: checkcast #24 // class java/lang/Iterable\n 14: astore 4\n 16: nop\n 17: iconst_0\n 18: istore 5\n 20: iconst_0\n 21: istore 6\n 23: new #77 // class java/util/ArrayList\n 26: dup\n 27: invokespecial #212 // Method java/util/ArrayList.\"<init>\":()V\n 30: astore 7\n 32: aload 4\n 34: invokeinterface #28, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 8\n 41: aload 8\n 43: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 130\n 51: aload 8\n 53: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 9\n 60: iload 6\n 62: ifeq 76\n 65: aload 7\n 67: aload 9\n 69: invokevirtual #87 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 72: pop\n 73: goto 41\n 76: aload 9\n 78: checkcast #40 // class java/lang/String\n 81: astore 10\n 83: iconst_0\n 84: istore 11\n 86: aload 10\n 88: checkcast #42 // class java/lang/CharSequence\n 91: invokestatic #48 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 94: invokevirtual #52 // Method java/lang/Object.toString:()Ljava/lang/String;\n 97: ldc #214 // String move\n 99: iconst_0\n 100: iconst_2\n 101: aconst_null\n 102: invokestatic #58 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 105: ifne 112\n 108: iconst_1\n 109: goto 113\n 112: iconst_0\n 113: ifne 41\n 116: aload 7\n 118: aload 9\n 120: invokevirtual #87 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 123: pop\n 124: iconst_1\n 125: istore 6\n 127: goto 41\n 130: aload 7\n 132: checkcast #89 // class java/util/List\n 135: checkcast #24 // class java/lang/Iterable\n 138: astore 4\n 140: nop\n 141: iconst_0\n 142: istore 5\n 144: aload 4\n 146: astore 6\n 148: new #77 // class java/util/ArrayList\n 151: dup\n 152: aload 4\n 154: bipush 10\n 156: invokestatic #137 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 159: invokespecial #80 // Method java/util/ArrayList.\"<init>\":(I)V\n 162: checkcast #118 // class java/util/Collection\n 165: astore 7\n 167: iconst_0\n 168: istore 8\n 170: aload 6\n 172: invokeinterface #28, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 177: astore 9\n 179: aload 9\n 181: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 186: ifeq 336\n 189: aload 9\n 191: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 196: astore 10\n 198: aload 7\n 200: aload 10\n 202: checkcast #40 // class java/lang/String\n 205: astore 11\n 207: astore 18\n 209: iconst_0\n 210: istore 12\n 212: aload_2\n 213: aload 11\n 215: checkcast #42 // class java/lang/CharSequence\n 218: iconst_0\n 219: iconst_2\n 220: aconst_null\n 221: invokestatic #218 // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;\n 224: astore 13\n 226: aload 13\n 228: dup\n 229: invokestatic #221 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 232: invokeinterface #227, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 237: astore 14\n 239: aload 14\n 241: invokevirtual #233 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 244: invokeinterface #237, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 249: iconst_1\n 250: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 255: checkcast #40 // class java/lang/String\n 258: astore 15\n 260: aload 14\n 262: invokevirtual #233 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 265: invokeinterface #237, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 270: iconst_2\n 271: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 276: checkcast #40 // class java/lang/String\n 279: astore 16\n 281: aload 14\n 283: invokevirtual #233 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 286: invokeinterface #237, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 291: iconst_3\n 292: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 297: checkcast #40 // class java/lang/String\n 300: astore 17\n 302: new #105 // class Day005$Instruction\n 305: dup\n 306: aload 15\n 308: invokestatic #243 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 311: aload 16\n 313: invokestatic #243 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 316: aload 17\n 318: invokestatic #243 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 321: invokespecial #246 // Method Day005$Instruction.\"<init>\":(III)V\n 324: aload 18\n 326: swap\n 327: invokeinterface #151, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 332: pop\n 333: goto 179\n 336: aload 7\n 338: checkcast #89 // class java/util/List\n 341: nop\n 342: astore_3\n 343: aload_3\n 344: areturn\n\n private final void createContainers(java.util.List<java.lang.String>, java.util.List<kotlin.collections.ArrayDeque<java.lang.Character>>);\n Code:\n 0: aload_1\n 1: checkcast #24 // class java/lang/Iterable\n 4: astore_3\n 5: nop\n 6: iconst_0\n 7: istore 4\n 9: new #77 // class java/util/ArrayList\n 12: dup\n 13: invokespecial #212 // Method java/util/ArrayList.\"<init>\":()V\n 16: astore 5\n 18: aload_3\n 19: invokeinterface #28, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 24: astore 6\n 26: aload 6\n 28: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 33: ifeq 99\n 36: aload 6\n 38: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 43: astore 7\n 45: aload 7\n 47: checkcast #40 // class java/lang/String\n 50: astore 8\n 52: iconst_0\n 53: istore 9\n 55: aload 8\n 57: checkcast #42 // class java/lang/CharSequence\n 60: invokestatic #48 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 63: invokevirtual #52 // Method java/lang/Object.toString:()Ljava/lang/String;\n 66: ldc #54 // String 1\n 68: iconst_0\n 69: iconst_2\n 70: aconst_null\n 71: invokestatic #58 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 74: ifne 81\n 77: iconst_1\n 78: goto 82\n 81: iconst_0\n 82: ifne 88\n 85: goto 99\n 88: aload 5\n 90: aload 7\n 92: invokevirtual #87 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 95: pop\n 96: goto 26\n 99: aload 5\n 101: checkcast #89 // class java/util/List\n 104: checkcast #24 // class java/lang/Iterable\n 107: astore_3\n 108: nop\n 109: iconst_0\n 110: istore 4\n 112: aload_3\n 113: astore 5\n 115: new #77 // class java/util/ArrayList\n 118: dup\n 119: aload_3\n 120: bipush 10\n 122: invokestatic #137 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 125: invokespecial #80 // Method java/util/ArrayList.\"<init>\":(I)V\n 128: checkcast #118 // class java/util/Collection\n 131: astore 6\n 133: iconst_0\n 134: istore 7\n 136: aload 5\n 138: invokeinterface #28, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 143: astore 8\n 145: aload 8\n 147: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 152: ifeq 366\n 155: aload 8\n 157: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 162: astore 9\n 164: aload 6\n 166: aload 9\n 168: checkcast #40 // class java/lang/String\n 171: astore 10\n 173: astore 24\n 175: iconst_0\n 176: istore 11\n 178: aload 10\n 180: astore 12\n 182: new #265 // class kotlin/ranges/IntRange\n 185: dup\n 186: iconst_1\n 187: aload 10\n 189: invokevirtual #268 // Method java/lang/String.length:()I\n 192: invokespecial #271 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 195: checkcast #273 // class kotlin/ranges/IntProgression\n 198: iconst_4\n 199: invokestatic #279 // Method kotlin/ranges/RangesKt.step:(Lkotlin/ranges/IntProgression;I)Lkotlin/ranges/IntProgression;\n 202: checkcast #24 // class java/lang/Iterable\n 205: astore 13\n 207: aload 12\n 209: checkcast #42 // class java/lang/CharSequence\n 212: aload 13\n 214: invokestatic #283 // Method kotlin/text/StringsKt.slice:(Ljava/lang/CharSequence;Ljava/lang/Iterable;)Ljava/lang/CharSequence;\n 217: invokevirtual #52 // Method java/lang/Object.toString:()Ljava/lang/String;\n 220: checkcast #42 // class java/lang/CharSequence\n 223: astore 12\n 225: nop\n 226: iconst_0\n 227: istore 13\n 229: aload 12\n 231: astore 14\n 233: new #77 // class java/util/ArrayList\n 236: dup\n 237: aload 12\n 239: invokeinterface #284, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 244: invokespecial #80 // Method java/util/ArrayList.\"<init>\":(I)V\n 247: checkcast #118 // class java/util/Collection\n 250: astore 15\n 252: iconst_0\n 253: istore 16\n 255: iconst_0\n 256: istore 17\n 258: iconst_0\n 259: istore 18\n 261: iload 18\n 263: aload 14\n 265: invokeinterface #284, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 270: if_icmpge 347\n 273: aload 14\n 275: iload 18\n 277: invokeinterface #288, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 282: istore 19\n 284: aload 15\n 286: iload 17\n 288: iinc 17, 1\n 291: iload 19\n 293: istore 20\n 295: istore 21\n 297: astore 22\n 299: iconst_0\n 300: istore 23\n 302: iload 20\n 304: invokestatic #292 // Method java/lang/Character.isLetter:(C)Z\n 307: ifeq 329\n 310: aload_2\n 311: iload 21\n 313: invokeinterface #116, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 318: checkcast #82 // class kotlin/collections/ArrayDeque\n 321: iload 20\n 323: invokestatic #150 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 326: invokevirtual #295 // Method kotlin/collections/ArrayDeque.addLast:(Ljava/lang/Object;)V\n 329: nop\n 330: aload 22\n 332: getstatic #301 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 335: invokeinterface #151, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 340: pop\n 341: iinc 18, 1\n 344: goto 261\n 347: aload 15\n 349: checkcast #89 // class java/util/List\n 352: nop\n 353: nop\n 354: aload 24\n 356: swap\n 357: invokeinterface #151, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 362: pop\n 363: goto 145\n 366: aload 6\n 368: checkcast #89 // class java/util/List\n 371: nop\n 372: pop\n 373: return\n}\n",
"javap_err": ""
}
] |
teodor-vasile__aoc-2022-kotlin__2fcfe95/src/main/kotlin/Day003.kt
|
class Day003 {
fun part1(input: List<String>): Int {
var prioritiesSum = 0
for (rucksack in input) {
val firstHalf = rucksack.subSequence(0, rucksack.length / 2)
val lastHalf = rucksack.subSequence(rucksack.length / 2, rucksack.length)
for (char in lastHalf) {
if (firstHalf.contains(char)) {
val itemPriority = if (char.isLowerCase()) char.code - 96 else char.code - 38
prioritiesSum += itemPriority
break
}
}
}
return prioritiesSum
}
fun part2(input: List<String>): Int {
val chunkedInput = input.chunked(3)
var prioritiesSum = 0
for (chunk in chunkedInput) {
for (char in chunk[0]) {
if (chunk[1].contains(char) && chunk[2].contains(char)) {
val itemPriority = if (char.isLowerCase()) char.code - 96 else char.code - 38
prioritiesSum += itemPriority
break
}
}
}
return prioritiesSum
// check out zipWithNext() for this solution
// and intersect() method
// single() to return one value
}
}
|
[
{
"class_path": "teodor-vasile__aoc-2022-kotlin__2fcfe95/Day003.class",
"javap": "Compiled from \"Day003.kt\"\npublic final class Day003 {\n public Day003();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_2\n 8: aload_1\n 9: invokeinterface #28, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 14: astore_3\n 15: aload_3\n 16: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 21: ifeq 145\n 24: aload_3\n 25: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 30: checkcast #40 // class java/lang/String\n 33: astore 4\n 35: aload 4\n 37: iconst_0\n 38: aload 4\n 40: invokevirtual #44 // Method java/lang/String.length:()I\n 43: iconst_2\n 44: idiv\n 45: invokevirtual #48 // Method java/lang/String.subSequence:(II)Ljava/lang/CharSequence;\n 48: astore 5\n 50: aload 4\n 52: aload 4\n 54: invokevirtual #44 // Method java/lang/String.length:()I\n 57: iconst_2\n 58: idiv\n 59: aload 4\n 61: invokevirtual #44 // Method java/lang/String.length:()I\n 64: invokevirtual #48 // Method java/lang/String.subSequence:(II)Ljava/lang/CharSequence;\n 67: astore 6\n 69: iconst_0\n 70: istore 7\n 72: iload 7\n 74: aload 6\n 76: invokeinterface #51, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 81: if_icmpge 15\n 84: aload 6\n 86: iload 7\n 88: invokeinterface #55, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 93: istore 8\n 95: aload 5\n 97: iload 8\n 99: iconst_0\n 100: iconst_2\n 101: aconst_null\n 102: invokestatic #61 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;CZILjava/lang/Object;)Z\n 105: ifeq 139\n 108: iload 8\n 110: invokestatic #67 // Method java/lang/Character.isLowerCase:(C)Z\n 113: ifeq 124\n 116: iload 8\n 118: bipush 96\n 120: isub\n 121: goto 129\n 124: iload 8\n 126: bipush 38\n 128: isub\n 129: istore 9\n 131: iload_2\n 132: iload 9\n 134: iadd\n 135: istore_2\n 136: goto 15\n 139: iinc 7, 1\n 142: goto 72\n 145: iload_2\n 146: ireturn\n\n public final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #81 // class java/lang/Iterable\n 10: iconst_3\n 11: invokestatic #87 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;\n 14: astore_2\n 15: iconst_0\n 16: istore_3\n 17: aload_2\n 18: invokeinterface #28, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 23: astore 4\n 25: aload 4\n 27: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 32: ifeq 167\n 35: aload 4\n 37: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 42: checkcast #24 // class java/util/List\n 45: astore 5\n 47: aload 5\n 49: iconst_0\n 50: invokeinterface #91, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 55: checkcast #40 // class java/lang/String\n 58: astore 6\n 60: iconst_0\n 61: istore 7\n 63: aload 6\n 65: invokevirtual #44 // Method java/lang/String.length:()I\n 68: istore 8\n 70: iload 7\n 72: iload 8\n 74: if_icmpge 25\n 77: aload 6\n 79: iload 7\n 81: invokevirtual #92 // Method java/lang/String.charAt:(I)C\n 84: istore 9\n 86: aload 5\n 88: iconst_1\n 89: invokeinterface #91, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 94: checkcast #50 // class java/lang/CharSequence\n 97: iload 9\n 99: iconst_0\n 100: iconst_2\n 101: aconst_null\n 102: invokestatic #61 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;CZILjava/lang/Object;)Z\n 105: ifeq 161\n 108: aload 5\n 110: iconst_2\n 111: invokeinterface #91, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 116: checkcast #50 // class java/lang/CharSequence\n 119: iload 9\n 121: iconst_0\n 122: iconst_2\n 123: aconst_null\n 124: invokestatic #61 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;CZILjava/lang/Object;)Z\n 127: ifeq 161\n 130: iload 9\n 132: invokestatic #67 // Method java/lang/Character.isLowerCase:(C)Z\n 135: ifeq 146\n 138: iload 9\n 140: bipush 96\n 142: isub\n 143: goto 151\n 146: iload 9\n 148: bipush 38\n 150: isub\n 151: istore 10\n 153: iload_3\n 154: iload 10\n 156: iadd\n 157: istore_3\n 158: goto 25\n 161: iinc 7, 1\n 164: goto 70\n 167: iload_3\n 168: ireturn\n}\n",
"javap_err": ""
}
] |
teodor-vasile__aoc-2022-kotlin__2fcfe95/src/main/kotlin/Day004.kt
|
class Day004 {
var counter = 0
fun part1(elfPairs: List<List<String>>): Int {
for (elfPair in elfPairs) {
val firstElf = elfPair[0].split('-').map { it.toInt() }
val secondElf = elfPair[1].split('-').map { it.toInt() }
countContainingRanges(firstElf, secondElf)
}
return counter
}
fun part1Functional(elfPairs: List<List<String>>): Int {
elfPairs.forEach { elfPair ->
val firstElf = elfPair[0].split('-').map { it.toInt() }
val secondElf = elfPair[1].split('-').map { it.toInt() }
countContainingRanges(firstElf, secondElf)
}
return counter
}
private fun countContainingRanges(firstElf: List<Int>, secondElf: List<Int>) {
if ((firstElf[0] >= secondElf[0] && firstElf[1] <= secondElf[1]) ||
(secondElf[0] >= firstElf[0] && secondElf[1] <= firstElf[1])
) {
counter++
}
}
fun part2(elfPairs: List<List<String>>): Int {
for (elfPair in elfPairs) {
val firstElf = elfPair[0].split('-').map { it.toInt() }
val secondElf = elfPair[1].split('-').map { it.toInt() }
if ((firstElf[1] >= secondElf[0] && firstElf[1] <= secondElf[1]) ||
(secondElf[1] >= firstElf[0] && secondElf[1] <= firstElf[1])
) {
counter++
}
}
return counter
}
fun test() {
val pair = Pair("primu", "ultimu")
pair.first
}
// transform to Pair<IntRange, IntRange> -> you can use first and last in an IntRange
// substringBefore() method also useful
// .count() -> how many of the items in the set match the predicate
// https://todd.ginsberg.com/post/advent-of-code/2022/day4/
}
|
[
{
"class_path": "teodor-vasile__aoc-2022-kotlin__2fcfe95/Day004.class",
"javap": "Compiled from \"Day004.kt\"\npublic final class Day004 {\n private int counter;\n\n public Day004();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int getCounter();\n Code:\n 0: aload_0\n 1: getfield #16 // Field counter:I\n 4: ireturn\n\n public final void setCounter(int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: putfield #16 // Field counter:I\n 5: return\n\n public final int part1(java.util.List<? extends java.util.List<java.lang.String>>);\n Code:\n 0: aload_1\n 1: ldc #25 // String elfPairs\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokeinterface #37, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 12: astore_2\n 13: aload_2\n 14: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 19: ifeq 315\n 22: aload_2\n 23: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 28: checkcast #33 // class java/util/List\n 31: astore_3\n 32: aload_3\n 33: iconst_0\n 34: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 39: checkcast #53 // class java/lang/CharSequence\n 42: iconst_1\n 43: newarray char\n 45: astore 5\n 47: aload 5\n 49: iconst_0\n 50: bipush 45\n 52: castore\n 53: aload 5\n 55: iconst_0\n 56: iconst_0\n 57: bipush 6\n 59: aconst_null\n 60: invokestatic #59 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 63: checkcast #61 // class java/lang/Iterable\n 66: astore 5\n 68: iconst_0\n 69: istore 6\n 71: aload 5\n 73: astore 7\n 75: new #63 // class java/util/ArrayList\n 78: dup\n 79: aload 5\n 81: bipush 10\n 83: invokestatic #69 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 86: invokespecial #71 // Method java/util/ArrayList.\"<init>\":(I)V\n 89: checkcast #73 // class java/util/Collection\n 92: astore 8\n 94: iconst_0\n 95: istore 9\n 97: aload 7\n 99: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 104: astore 10\n 106: aload 10\n 108: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 113: ifeq 160\n 116: aload 10\n 118: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 123: astore 11\n 125: aload 8\n 127: aload 11\n 129: checkcast #76 // class java/lang/String\n 132: astore 12\n 134: astore 15\n 136: iconst_0\n 137: istore 13\n 139: aload 12\n 141: invokestatic #82 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 144: nop\n 145: invokestatic #86 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 148: aload 15\n 150: swap\n 151: invokeinterface #90, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 156: pop\n 157: goto 106\n 160: aload 8\n 162: checkcast #33 // class java/util/List\n 165: nop\n 166: astore 4\n 168: aload_3\n 169: iconst_1\n 170: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 175: checkcast #53 // class java/lang/CharSequence\n 178: iconst_1\n 179: newarray char\n 181: astore 6\n 183: aload 6\n 185: iconst_0\n 186: bipush 45\n 188: castore\n 189: aload 6\n 191: iconst_0\n 192: iconst_0\n 193: bipush 6\n 195: aconst_null\n 196: invokestatic #59 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 199: checkcast #61 // class java/lang/Iterable\n 202: astore 6\n 204: iconst_0\n 205: istore 7\n 207: aload 6\n 209: astore 8\n 211: new #63 // class java/util/ArrayList\n 214: dup\n 215: aload 6\n 217: bipush 10\n 219: invokestatic #69 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 222: invokespecial #71 // Method java/util/ArrayList.\"<init>\":(I)V\n 225: checkcast #73 // class java/util/Collection\n 228: astore 9\n 230: iconst_0\n 231: istore 10\n 233: aload 8\n 235: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 240: astore 11\n 242: aload 11\n 244: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 249: ifeq 296\n 252: aload 11\n 254: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 259: astore 12\n 261: aload 9\n 263: aload 12\n 265: checkcast #76 // class java/lang/String\n 268: astore 13\n 270: astore 15\n 272: iconst_0\n 273: istore 14\n 275: aload 13\n 277: invokestatic #82 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 280: nop\n 281: invokestatic #86 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 284: aload 15\n 286: swap\n 287: invokeinterface #90, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 292: pop\n 293: goto 242\n 296: aload 9\n 298: checkcast #33 // class java/util/List\n 301: nop\n 302: astore 5\n 304: aload_0\n 305: aload 4\n 307: aload 5\n 309: invokespecial #94 // Method countContainingRanges:(Ljava/util/List;Ljava/util/List;)V\n 312: goto 13\n 315: aload_0\n 316: getfield #16 // Field counter:I\n 319: ireturn\n\n public final int part1Functional(java.util.List<? extends java.util.List<java.lang.String>>);\n Code:\n 0: aload_1\n 1: ldc #25 // String elfPairs\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #61 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 19: astore 4\n 21: aload 4\n 23: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 28: ifeq 337\n 31: aload 4\n 33: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 38: astore 5\n 40: aload 5\n 42: checkcast #33 // class java/util/List\n 45: astore 6\n 47: iconst_0\n 48: istore 7\n 50: aload 6\n 52: iconst_0\n 53: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 58: checkcast #53 // class java/lang/CharSequence\n 61: iconst_1\n 62: newarray char\n 64: astore 8\n 66: aload 8\n 68: iconst_0\n 69: bipush 45\n 71: castore\n 72: aload 8\n 74: iconst_0\n 75: iconst_0\n 76: bipush 6\n 78: aconst_null\n 79: invokestatic #59 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 82: checkcast #61 // class java/lang/Iterable\n 85: astore 8\n 87: iconst_0\n 88: istore 9\n 90: aload 8\n 92: astore 10\n 94: new #63 // class java/util/ArrayList\n 97: dup\n 98: aload 8\n 100: bipush 10\n 102: invokestatic #69 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 105: invokespecial #71 // Method java/util/ArrayList.\"<init>\":(I)V\n 108: checkcast #73 // class java/util/Collection\n 111: astore 11\n 113: iconst_0\n 114: istore 12\n 116: aload 10\n 118: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 123: astore 13\n 125: aload 13\n 127: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 132: ifeq 179\n 135: aload 13\n 137: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 142: astore 14\n 144: aload 11\n 146: aload 14\n 148: checkcast #76 // class java/lang/String\n 151: astore 15\n 153: astore 16\n 155: iconst_0\n 156: istore 17\n 158: aload 15\n 160: invokestatic #82 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 163: nop\n 164: invokestatic #86 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 167: aload 16\n 169: swap\n 170: invokeinterface #90, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 175: pop\n 176: goto 125\n 179: aload 11\n 181: checkcast #33 // class java/util/List\n 184: nop\n 185: astore 18\n 187: aload 6\n 189: iconst_1\n 190: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 195: checkcast #53 // class java/lang/CharSequence\n 198: iconst_1\n 199: newarray char\n 201: astore 9\n 203: aload 9\n 205: iconst_0\n 206: bipush 45\n 208: castore\n 209: aload 9\n 211: iconst_0\n 212: iconst_0\n 213: bipush 6\n 215: aconst_null\n 216: invokestatic #59 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 219: checkcast #61 // class java/lang/Iterable\n 222: astore 9\n 224: iconst_0\n 225: istore 10\n 227: aload 9\n 229: astore 11\n 231: new #63 // class java/util/ArrayList\n 234: dup\n 235: aload 9\n 237: bipush 10\n 239: invokestatic #69 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 242: invokespecial #71 // Method java/util/ArrayList.\"<init>\":(I)V\n 245: checkcast #73 // class java/util/Collection\n 248: astore 12\n 250: iconst_0\n 251: istore 13\n 253: aload 11\n 255: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 260: astore 14\n 262: aload 14\n 264: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 269: ifeq 316\n 272: aload 14\n 274: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 279: astore 15\n 281: aload 12\n 283: aload 15\n 285: checkcast #76 // class java/lang/String\n 288: astore 17\n 290: astore 16\n 292: iconst_0\n 293: istore 19\n 295: aload 17\n 297: invokestatic #82 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 300: nop\n 301: invokestatic #86 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 304: aload 16\n 306: swap\n 307: invokeinterface #90, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 312: pop\n 313: goto 262\n 316: aload 12\n 318: checkcast #33 // class java/util/List\n 321: nop\n 322: astore 8\n 324: aload_0\n 325: aload 18\n 327: aload 8\n 329: invokespecial #94 // Method countContainingRanges:(Ljava/util/List;Ljava/util/List;)V\n 332: nop\n 333: nop\n 334: goto 21\n 337: nop\n 338: aload_0\n 339: getfield #16 // Field counter:I\n 342: ireturn\n\n private final void countContainingRanges(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>);\n Code:\n 0: aload_1\n 1: iconst_0\n 2: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #121 // class java/lang/Number\n 10: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 13: aload_2\n 14: iconst_0\n 15: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 20: checkcast #121 // class java/lang/Number\n 23: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 26: if_icmplt 58\n 29: aload_1\n 30: iconst_1\n 31: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 36: checkcast #121 // class java/lang/Number\n 39: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 42: aload_2\n 43: iconst_1\n 44: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 49: checkcast #121 // class java/lang/Number\n 52: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 55: if_icmple 116\n 58: aload_2\n 59: iconst_0\n 60: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 65: checkcast #121 // class java/lang/Number\n 68: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 71: aload_1\n 72: iconst_0\n 73: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 78: checkcast #121 // class java/lang/Number\n 81: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 84: if_icmplt 128\n 87: aload_2\n 88: iconst_1\n 89: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 94: checkcast #121 // class java/lang/Number\n 97: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 100: aload_1\n 101: iconst_1\n 102: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 107: checkcast #121 // class java/lang/Number\n 110: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 113: if_icmpgt 128\n 116: aload_0\n 117: getfield #16 // Field counter:I\n 120: istore_3\n 121: aload_0\n 122: iload_3\n 123: iconst_1\n 124: iadd\n 125: putfield #16 // Field counter:I\n 128: return\n\n public final int part2(java.util.List<? extends java.util.List<java.lang.String>>);\n Code:\n 0: aload_1\n 1: ldc #25 // String elfPairs\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokeinterface #37, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 12: astore_2\n 13: aload_2\n 14: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 19: ifeq 445\n 22: aload_2\n 23: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 28: checkcast #33 // class java/util/List\n 31: astore_3\n 32: aload_3\n 33: iconst_0\n 34: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 39: checkcast #53 // class java/lang/CharSequence\n 42: iconst_1\n 43: newarray char\n 45: astore 5\n 47: aload 5\n 49: iconst_0\n 50: bipush 45\n 52: castore\n 53: aload 5\n 55: iconst_0\n 56: iconst_0\n 57: bipush 6\n 59: aconst_null\n 60: invokestatic #59 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 63: checkcast #61 // class java/lang/Iterable\n 66: astore 5\n 68: iconst_0\n 69: istore 6\n 71: aload 5\n 73: astore 7\n 75: new #63 // class java/util/ArrayList\n 78: dup\n 79: aload 5\n 81: bipush 10\n 83: invokestatic #69 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 86: invokespecial #71 // Method java/util/ArrayList.\"<init>\":(I)V\n 89: checkcast #73 // class java/util/Collection\n 92: astore 8\n 94: iconst_0\n 95: istore 9\n 97: aload 7\n 99: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 104: astore 10\n 106: aload 10\n 108: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 113: ifeq 160\n 116: aload 10\n 118: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 123: astore 11\n 125: aload 8\n 127: aload 11\n 129: checkcast #76 // class java/lang/String\n 132: astore 12\n 134: astore 15\n 136: iconst_0\n 137: istore 13\n 139: aload 12\n 141: invokestatic #82 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 144: nop\n 145: invokestatic #86 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 148: aload 15\n 150: swap\n 151: invokeinterface #90, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 156: pop\n 157: goto 106\n 160: aload 8\n 162: checkcast #33 // class java/util/List\n 165: nop\n 166: astore 4\n 168: aload_3\n 169: iconst_1\n 170: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 175: checkcast #53 // class java/lang/CharSequence\n 178: iconst_1\n 179: newarray char\n 181: astore 6\n 183: aload 6\n 185: iconst_0\n 186: bipush 45\n 188: castore\n 189: aload 6\n 191: iconst_0\n 192: iconst_0\n 193: bipush 6\n 195: aconst_null\n 196: invokestatic #59 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 199: checkcast #61 // class java/lang/Iterable\n 202: astore 6\n 204: iconst_0\n 205: istore 7\n 207: aload 6\n 209: astore 8\n 211: new #63 // class java/util/ArrayList\n 214: dup\n 215: aload 6\n 217: bipush 10\n 219: invokestatic #69 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 222: invokespecial #71 // Method java/util/ArrayList.\"<init>\":(I)V\n 225: checkcast #73 // class java/util/Collection\n 228: astore 9\n 230: iconst_0\n 231: istore 10\n 233: aload 8\n 235: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 240: astore 11\n 242: aload 11\n 244: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 249: ifeq 296\n 252: aload 11\n 254: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 259: astore 12\n 261: aload 9\n 263: aload 12\n 265: checkcast #76 // class java/lang/String\n 268: astore 13\n 270: astore 15\n 272: iconst_0\n 273: istore 14\n 275: aload 13\n 277: invokestatic #82 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 280: nop\n 281: invokestatic #86 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 284: aload 15\n 286: swap\n 287: invokeinterface #90, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 292: pop\n 293: goto 242\n 296: aload 9\n 298: checkcast #33 // class java/util/List\n 301: nop\n 302: astore 5\n 304: aload 4\n 306: iconst_1\n 307: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 312: checkcast #121 // class java/lang/Number\n 315: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 318: aload 5\n 320: iconst_0\n 321: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 326: checkcast #121 // class java/lang/Number\n 329: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 332: if_icmplt 366\n 335: aload 4\n 337: iconst_1\n 338: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 343: checkcast #121 // class java/lang/Number\n 346: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 349: aload 5\n 351: iconst_1\n 352: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 357: checkcast #121 // class java/lang/Number\n 360: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 363: if_icmple 428\n 366: aload 5\n 368: iconst_1\n 369: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 374: checkcast #121 // class java/lang/Number\n 377: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 380: aload 4\n 382: iconst_0\n 383: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 388: checkcast #121 // class java/lang/Number\n 391: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 394: if_icmplt 13\n 397: aload 5\n 399: iconst_1\n 400: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 405: checkcast #121 // class java/lang/Number\n 408: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 411: aload 4\n 413: iconst_1\n 414: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 419: checkcast #121 // class java/lang/Number\n 422: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 425: if_icmpgt 13\n 428: aload_0\n 429: getfield #16 // Field counter:I\n 432: istore 6\n 434: aload_0\n 435: iload 6\n 437: iconst_1\n 438: iadd\n 439: putfield #16 // Field counter:I\n 442: goto 13\n 445: aload_0\n 446: getfield #16 // Field counter:I\n 449: ireturn\n\n public final void test();\n Code:\n 0: new #130 // class kotlin/Pair\n 3: dup\n 4: ldc #132 // String primu\n 6: ldc #134 // String ultimu\n 8: invokespecial #137 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 11: astore_1\n 12: aload_1\n 13: invokevirtual #140 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 16: pop\n 17: return\n}\n",
"javap_err": ""
}
] |
SwampThingTom__AoC2022__a7825f7/21-MonkeyMath/MonkeyMath.kt
|
// Monkey Math
// https://adventofcode.com/2022/day/21
import java.io.File
import java.util.ArrayDeque
typealias MonkeyMap = Map<String, List<String>>
typealias MutableValuesMap = MutableMap<String, Long>
fun debugPrint(msg: String, show: Boolean = false) = if (show) { println(msg) } else {}
fun readInput(): List<String> = File("input.txt").useLines { it.toList() }
fun parseMonkey(line: String): Pair<String, List<String>> {
val components = line.split(": ")
val value = components[1].split(" ")
return components[0] to value
}
fun solvePart1(monkeys: MonkeyMap): Long {
val values: MutableValuesMap = mutableMapOf()
return solveFor("root", monkeys, values)
}
fun solvePart2(monkeys: MonkeyMap): Long {
val values: MutableValuesMap = mutableMapOf()
val rootExpr = monkeys["root"]!!
val (humnMonkey, otherMonkey) = whichMonkeyLeadsToHumn(rootExpr[0], rootExpr[2], monkeys)
val expectedValue = solveFor(otherMonkey, monkeys, values)
return solveForHumn(humnMonkey, expectedValue, monkeys, values)
}
fun whichMonkeyLeadsToHumn(lhs: String, rhs: String, monkeys: MonkeyMap): Pair<String, String> =
if (leadsToHumn(lhs, monkeys)) Pair(lhs, rhs) else Pair(rhs, lhs)
fun leadsToHumn(monkey: String, monkeys: MonkeyMap): Boolean {
if (monkey == "humn") return true
val expr = monkeys[monkey]!!
if (expr.size == 1) return false
return leadsToHumn(expr[0], monkeys) || leadsToHumn(expr[2], monkeys)
}
fun solveForHumn(monkey: String, expectedValue: Long, monkeys: MonkeyMap, values: MutableValuesMap): Long {
if (monkey == "humn") {
return expectedValue
}
val expr = monkeys[monkey]!!
assert(expr.size == 3)
val (humnMonkey, otherMonkey) = whichMonkeyLeadsToHumn(expr[0], expr[2], monkeys)
val knownValue = solveFor(otherMonkey, monkeys, values)
val newExpectedValue = evaluateInverse(expr[1], expectedValue, knownValue, humnMonkey == expr[0])
return solveForHumn(humnMonkey, newExpectedValue, monkeys, values)
}
fun solveFor(monkey: String, monkeys: MonkeyMap, values: MutableValuesMap): Long {
val value = values[monkey]
if (value is Long) {
return value
}
val expr = monkeys[monkey]!!
if (expr.size == 1) {
values[monkey] = expr[0].toLong()
return values[monkey]!!
}
assert(expr.size == 3)
val lhs = values[expr[0]] ?: solveFor(expr[0], monkeys, values)
val rhs = values[expr[2]] ?: solveFor(expr[2], monkeys, values)
values[monkey] = evaluate(expr[1], lhs, rhs)
return values[monkey]!!
}
fun evaluate(op: String, lhs: Long, rhs: Long): Long {
return when (op) {
"+" -> lhs + rhs
"-" -> lhs - rhs
"*" -> lhs * rhs
"/" -> lhs / rhs
else -> throw IllegalArgumentException("Unexpected operator.")
}
}
fun evaluateInverse(op: String, lhs: Long, rhs: Long, lhsIsHumn: Boolean): Long {
return when (op) {
"+" -> lhs - rhs
"-" -> if (lhsIsHumn) lhs + rhs else rhs - lhs
"*" -> lhs / rhs
"/" -> lhs * rhs
else -> throw IllegalArgumentException("Unexpected operator.")
}
}
fun main() {
val input = readInput()
val monkeys: MonkeyMap = input.map { parseMonkey(it) }.toMap()
val part1 = solvePart1(monkeys)
println("Part 1: $part1")
val part2 = solvePart2(monkeys)
println("Part 2: $part2")
}
|
[
{
"class_path": "SwampThingTom__AoC2022__a7825f7/MonkeyMathKt.class",
"javap": "Compiled from \"MonkeyMath.kt\"\npublic final class MonkeyMathKt {\n public static final void debugPrint(java.lang.String, boolean);\n Code:\n 0: aload_0\n 1: ldc #9 // String msg\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iload_1\n 7: ifeq 17\n 10: getstatic #21 // Field java/lang/System.out:Ljava/io/PrintStream;\n 13: aload_0\n 14: invokevirtual #27 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 17: return\n\n public static void debugPrint$default(java.lang.String, boolean, int, java.lang.Object);\n Code:\n 0: iload_2\n 1: iconst_2\n 2: iand\n 3: ifeq 8\n 6: iconst_0\n 7: istore_1\n 8: aload_0\n 9: iload_1\n 10: invokestatic #34 // Method debugPrint:(Ljava/lang/String;Z)V\n 13: return\n\n public static final java.util.List<java.lang.String> readInput();\n Code:\n 0: new #41 // class java/io/File\n 3: dup\n 4: ldc #43 // String input.txt\n 6: invokespecial #47 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: astore_0\n 10: getstatic #53 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 13: astore_1\n 14: iconst_0\n 15: istore_2\n 16: aload_0\n 17: astore_3\n 18: sipush 8192\n 21: istore 4\n 23: aload_3\n 24: astore 5\n 26: new #55 // class java/io/InputStreamReader\n 29: dup\n 30: new #57 // class java/io/FileInputStream\n 33: dup\n 34: aload 5\n 36: invokespecial #60 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 39: checkcast #62 // class java/io/InputStream\n 42: aload_1\n 43: invokespecial #65 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 46: checkcast #67 // class java/io/Reader\n 49: astore 5\n 51: aload 5\n 53: instanceof #69 // class java/io/BufferedReader\n 56: ifeq 67\n 59: aload 5\n 61: checkcast #69 // class java/io/BufferedReader\n 64: goto 78\n 67: new #69 // class java/io/BufferedReader\n 70: dup\n 71: aload 5\n 73: iload 4\n 75: invokespecial #72 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 78: checkcast #74 // class java/io/Closeable\n 81: astore_3\n 82: aconst_null\n 83: astore 4\n 85: nop\n 86: aload_3\n 87: checkcast #69 // class java/io/BufferedReader\n 90: astore 5\n 92: iconst_0\n 93: istore 6\n 95: aload 5\n 97: invokestatic #80 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;\n 100: astore 7\n 102: iconst_0\n 103: istore 8\n 105: aload 7\n 107: invokestatic #86 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 110: astore 5\n 112: aload_3\n 113: aload 4\n 115: invokestatic #92 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 118: aload 5\n 120: goto 143\n 123: astore 6\n 125: aload 6\n 127: astore 4\n 129: aload 6\n 131: athrow\n 132: astore 6\n 134: aload_3\n 135: aload 4\n 137: invokestatic #92 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 140: aload 6\n 142: athrow\n 143: nop\n 144: areturn\n Exception table:\n from to target type\n 85 112 123 Class java/lang/Throwable\n 85 112 132 any\n 123 132 132 any\n 132 134 132 any\n\n public static final kotlin.Pair<java.lang.String, java.util.List<java.lang.String>> parseMonkey(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #114 // String line\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #116 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #118 // class java/lang/String\n 14: astore_2\n 15: aload_2\n 16: iconst_0\n 17: ldc #120 // 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 #126 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: astore_1\n 30: aload_1\n 31: iconst_1\n 32: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 37: checkcast #116 // class java/lang/CharSequence\n 40: iconst_1\n 41: anewarray #118 // class java/lang/String\n 44: astore_3\n 45: aload_3\n 46: iconst_0\n 47: ldc #132 // String\n 49: aastore\n 50: aload_3\n 51: iconst_0\n 52: iconst_0\n 53: bipush 6\n 55: aconst_null\n 56: invokestatic #126 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 59: astore_2\n 60: aload_1\n 61: iconst_0\n 62: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 67: aload_2\n 68: invokestatic #138 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 71: areturn\n\n public static final long solvePart1(java.util.Map<java.lang.String, ? extends java.util.List<java.lang.String>>);\n Code:\n 0: aload_0\n 1: ldc #146 // String monkeys\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #148 // class java/util/LinkedHashMap\n 9: dup\n 10: invokespecial #151 // Method java/util/LinkedHashMap.\"<init>\":()V\n 13: checkcast #153 // class java/util/Map\n 16: astore_1\n 17: ldc #155 // String root\n 19: aload_0\n 20: aload_1\n 21: invokestatic #159 // Method solveFor:(Ljava/lang/String;Ljava/util/Map;Ljava/util/Map;)J\n 24: lreturn\n\n public static final long solvePart2(java.util.Map<java.lang.String, ? extends java.util.List<java.lang.String>>);\n Code:\n 0: aload_0\n 1: ldc #146 // String monkeys\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #148 // class java/util/LinkedHashMap\n 9: dup\n 10: invokespecial #151 // Method java/util/LinkedHashMap.\"<init>\":()V\n 13: checkcast #153 // class java/util/Map\n 16: astore_1\n 17: aload_0\n 18: ldc #155 // String root\n 20: invokeinterface #165, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 25: dup\n 26: invokestatic #168 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 29: checkcast #107 // class java/util/List\n 32: astore_2\n 33: aload_2\n 34: iconst_0\n 35: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 40: checkcast #118 // class java/lang/String\n 43: aload_2\n 44: iconst_2\n 45: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 50: checkcast #118 // class java/lang/String\n 53: aload_0\n 54: invokestatic #172 // Method whichMonkeyLeadsToHumn:(Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)Lkotlin/Pair;\n 57: astore_3\n 58: aload_3\n 59: invokevirtual #178 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 62: checkcast #118 // class java/lang/String\n 65: astore 4\n 67: aload_3\n 68: invokevirtual #181 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 71: checkcast #118 // class java/lang/String\n 74: astore 5\n 76: aload 5\n 78: aload_0\n 79: aload_1\n 80: invokestatic #159 // Method solveFor:(Ljava/lang/String;Ljava/util/Map;Ljava/util/Map;)J\n 83: lstore 6\n 85: aload 4\n 87: lload 6\n 89: aload_0\n 90: aload_1\n 91: invokestatic #185 // Method solveForHumn:(Ljava/lang/String;JLjava/util/Map;Ljava/util/Map;)J\n 94: lreturn\n\n public static final kotlin.Pair<java.lang.String, java.lang.String> whichMonkeyLeadsToHumn(java.lang.String, java.lang.String, java.util.Map<java.lang.String, ? extends java.util.List<java.lang.String>>);\n Code:\n 0: aload_0\n 1: ldc #193 // String lhs\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #195 // String rhs\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_2\n 13: ldc #146 // String monkeys\n 15: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: aload_0\n 19: aload_2\n 20: invokestatic #199 // Method leadsToHumn:(Ljava/lang/String;Ljava/util/Map;)Z\n 23: ifeq 38\n 26: new #174 // class kotlin/Pair\n 29: dup\n 30: aload_0\n 31: aload_1\n 32: invokespecial #202 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 35: goto 47\n 38: new #174 // class kotlin/Pair\n 41: dup\n 42: aload_1\n 43: aload_0\n 44: invokespecial #202 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 47: areturn\n\n public static final boolean leadsToHumn(java.lang.String, java.util.Map<java.lang.String, ? extends java.util.List<java.lang.String>>);\n Code:\n 0: aload_0\n 1: ldc #205 // String monkey\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #146 // String monkeys\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: ldc #207 // String humn\n 15: invokestatic #211 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 18: ifeq 23\n 21: iconst_1\n 22: ireturn\n 23: aload_1\n 24: aload_0\n 25: invokeinterface #165, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 30: dup\n 31: invokestatic #168 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 34: checkcast #107 // class java/util/List\n 37: astore_2\n 38: aload_2\n 39: invokeinterface #215, 1 // InterfaceMethod java/util/List.size:()I\n 44: iconst_1\n 45: if_icmpne 50\n 48: iconst_0\n 49: ireturn\n 50: aload_2\n 51: iconst_0\n 52: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 57: checkcast #118 // class java/lang/String\n 60: aload_1\n 61: invokestatic #199 // Method leadsToHumn:(Ljava/lang/String;Ljava/util/Map;)Z\n 64: ifne 84\n 67: aload_2\n 68: iconst_2\n 69: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 74: checkcast #118 // class java/lang/String\n 77: aload_1\n 78: invokestatic #199 // Method leadsToHumn:(Ljava/lang/String;Ljava/util/Map;)Z\n 81: ifeq 88\n 84: iconst_1\n 85: goto 89\n 88: iconst_0\n 89: ireturn\n\n public static final long solveForHumn(java.lang.String, long, java.util.Map<java.lang.String, ? extends java.util.List<java.lang.String>>, java.util.Map<java.lang.String, java.lang.Long>);\n Code:\n 0: aload_0\n 1: ldc #205 // String monkey\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_3\n 7: ldc #146 // String monkeys\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload 4\n 14: ldc #218 // String values\n 16: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 19: aload_0\n 20: ldc #207 // String humn\n 22: invokestatic #211 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 25: ifeq 30\n 28: lload_1\n 29: lreturn\n 30: aload_3\n 31: aload_0\n 32: invokeinterface #165, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 37: dup\n 38: invokestatic #168 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 41: checkcast #107 // class java/util/List\n 44: astore 5\n 46: aload 5\n 48: invokeinterface #215, 1 // InterfaceMethod java/util/List.size:()I\n 53: iconst_3\n 54: if_icmpne 61\n 57: iconst_1\n 58: goto 62\n 61: iconst_0\n 62: istore 6\n 64: getstatic #223 // Field kotlin/_Assertions.ENABLED:Z\n 67: ifeq 89\n 70: iload 6\n 72: ifne 89\n 75: ldc #225 // String Assertion failed\n 77: astore 7\n 79: new #227 // class java/lang/AssertionError\n 82: dup\n 83: aload 7\n 85: invokespecial #229 // Method java/lang/AssertionError.\"<init>\":(Ljava/lang/Object;)V\n 88: athrow\n 89: aload 5\n 91: iconst_0\n 92: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 97: checkcast #118 // class java/lang/String\n 100: aload 5\n 102: iconst_2\n 103: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 108: checkcast #118 // class java/lang/String\n 111: aload_3\n 112: invokestatic #172 // Method whichMonkeyLeadsToHumn:(Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)Lkotlin/Pair;\n 115: astore 6\n 117: aload 6\n 119: invokevirtual #178 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 122: checkcast #118 // class java/lang/String\n 125: astore 7\n 127: aload 6\n 129: invokevirtual #181 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 132: checkcast #118 // class java/lang/String\n 135: astore 8\n 137: aload 8\n 139: aload_3\n 140: aload 4\n 142: invokestatic #159 // Method solveFor:(Ljava/lang/String;Ljava/util/Map;Ljava/util/Map;)J\n 145: lstore 9\n 147: aload 5\n 149: iconst_1\n 150: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 155: checkcast #118 // class java/lang/String\n 158: lload_1\n 159: lload 9\n 161: aload 7\n 163: aload 5\n 165: iconst_0\n 166: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 171: invokestatic #211 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 174: invokestatic #233 // Method evaluateInverse:(Ljava/lang/String;JJZ)J\n 177: lstore 11\n 179: aload 7\n 181: lload 11\n 183: aload_3\n 184: aload 4\n 186: invokestatic #185 // Method solveForHumn:(Ljava/lang/String;JLjava/util/Map;Ljava/util/Map;)J\n 189: lreturn\n\n public static final long solveFor(java.lang.String, java.util.Map<java.lang.String, ? extends java.util.List<java.lang.String>>, java.util.Map<java.lang.String, java.lang.Long>);\n Code:\n 0: aload_0\n 1: ldc #205 // String monkey\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #146 // String monkeys\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_2\n 13: ldc #218 // String values\n 15: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: aload_2\n 19: aload_0\n 20: invokeinterface #165, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 25: checkcast #238 // class java/lang/Long\n 28: astore_3\n 29: aload_3\n 30: ifnull 38\n 33: aload_3\n 34: invokevirtual #242 // Method java/lang/Long.longValue:()J\n 37: lreturn\n 38: aload_1\n 39: aload_0\n 40: invokeinterface #165, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 45: dup\n 46: invokestatic #168 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 49: checkcast #107 // class java/util/List\n 52: astore 4\n 54: aload 4\n 56: invokeinterface #215, 1 // InterfaceMethod java/util/List.size:()I\n 61: iconst_1\n 62: if_icmpne 109\n 65: nop\n 66: aload_2\n 67: aload_0\n 68: aload 4\n 70: iconst_0\n 71: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 76: checkcast #118 // class java/lang/String\n 79: invokestatic #246 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 82: invokestatic #250 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 85: invokeinterface #254, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 90: pop\n 91: aload_2\n 92: aload_0\n 93: invokeinterface #165, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 98: dup\n 99: invokestatic #168 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 102: checkcast #256 // class java/lang/Number\n 105: invokevirtual #257 // Method java/lang/Number.longValue:()J\n 108: lreturn\n 109: aload 4\n 111: invokeinterface #215, 1 // InterfaceMethod java/util/List.size:()I\n 116: iconst_3\n 117: if_icmpne 124\n 120: iconst_1\n 121: goto 125\n 124: iconst_0\n 125: istore 5\n 127: getstatic #223 // Field kotlin/_Assertions.ENABLED:Z\n 130: ifeq 152\n 133: iload 5\n 135: ifne 152\n 138: ldc #225 // String Assertion failed\n 140: astore 6\n 142: new #227 // class java/lang/AssertionError\n 145: dup\n 146: aload 6\n 148: invokespecial #229 // Method java/lang/AssertionError.\"<init>\":(Ljava/lang/Object;)V\n 151: athrow\n 152: aload_2\n 153: aload 4\n 155: iconst_0\n 156: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 161: invokeinterface #165, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 166: checkcast #238 // class java/lang/Long\n 169: dup\n 170: ifnull 179\n 173: invokevirtual #242 // Method java/lang/Long.longValue:()J\n 176: goto 196\n 179: pop\n 180: aload 4\n 182: iconst_0\n 183: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 188: checkcast #118 // class java/lang/String\n 191: aload_1\n 192: aload_2\n 193: invokestatic #159 // Method solveFor:(Ljava/lang/String;Ljava/util/Map;Ljava/util/Map;)J\n 196: lstore 5\n 198: aload_2\n 199: aload 4\n 201: iconst_2\n 202: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 207: invokeinterface #165, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 212: checkcast #238 // class java/lang/Long\n 215: dup\n 216: ifnull 225\n 219: invokevirtual #242 // Method java/lang/Long.longValue:()J\n 222: goto 242\n 225: pop\n 226: aload 4\n 228: iconst_2\n 229: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 234: checkcast #118 // class java/lang/String\n 237: aload_1\n 238: aload_2\n 239: invokestatic #159 // Method solveFor:(Ljava/lang/String;Ljava/util/Map;Ljava/util/Map;)J\n 242: lstore 7\n 244: aload_2\n 245: aload_0\n 246: aload 4\n 248: iconst_1\n 249: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 254: checkcast #118 // class java/lang/String\n 257: lload 5\n 259: lload 7\n 261: invokestatic #261 // Method evaluate:(Ljava/lang/String;JJ)J\n 264: invokestatic #250 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 267: invokeinterface #254, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 272: pop\n 273: aload_2\n 274: aload_0\n 275: invokeinterface #165, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 280: dup\n 281: invokestatic #168 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 284: checkcast #256 // class java/lang/Number\n 287: invokevirtual #257 // Method java/lang/Number.longValue:()J\n 290: lreturn\n\n public static final long evaluate(java.lang.String, long, long);\n Code:\n 0: aload_0\n 1: ldc_w #264 // String op\n 4: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: astore 5\n 10: aload 5\n 12: invokevirtual #267 // Method java/lang/String.hashCode:()I\n 15: tableswitch { // 42 to 47\n 42: 52\n 43: 66\n 44: 132\n 45: 80\n 46: 132\n 47: 94\n default: 132\n }\n 52: aload 5\n 54: ldc_w #269 // String *\n 57: invokevirtual #273 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 60: ifne 120\n 63: goto 132\n 66: aload 5\n 68: ldc_w #275 // String +\n 71: invokevirtual #273 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 74: ifne 108\n 77: goto 132\n 80: aload 5\n 82: ldc_w #277 // String -\n 85: invokevirtual #273 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 88: ifne 114\n 91: goto 132\n 94: aload 5\n 96: ldc_w #279 // String /\n 99: invokevirtual #273 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 102: ifne 126\n 105: goto 132\n 108: lload_1\n 109: lload_3\n 110: ladd\n 111: goto 143\n 114: lload_1\n 115: lload_3\n 116: lsub\n 117: goto 143\n 120: lload_1\n 121: lload_3\n 122: lmul\n 123: goto 143\n 126: lload_1\n 127: lload_3\n 128: ldiv\n 129: goto 143\n 132: new #281 // class java/lang/IllegalArgumentException\n 135: dup\n 136: ldc_w #283 // String Unexpected operator.\n 139: invokespecial #284 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 142: athrow\n 143: lreturn\n\n public static final long evaluateInverse(java.lang.String, long, long, boolean);\n Code:\n 0: aload_0\n 1: ldc_w #264 // String op\n 4: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: astore 6\n 10: aload 6\n 12: invokevirtual #267 // Method java/lang/String.hashCode:()I\n 15: tableswitch { // 42 to 47\n 42: 52\n 43: 66\n 44: 143\n 45: 80\n 46: 143\n 47: 94\n default: 143\n }\n 52: aload 6\n 54: ldc_w #269 // String *\n 57: invokevirtual #273 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 60: ifne 131\n 63: goto 143\n 66: aload 6\n 68: ldc_w #275 // String +\n 71: invokevirtual #273 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 74: ifne 108\n 77: goto 143\n 80: aload 6\n 82: ldc_w #277 // String -\n 85: invokevirtual #273 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 88: ifne 114\n 91: goto 143\n 94: aload 6\n 96: ldc_w #279 // String /\n 99: invokevirtual #273 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 102: ifne 137\n 105: goto 143\n 108: lload_1\n 109: lload_3\n 110: lsub\n 111: goto 154\n 114: iload 5\n 116: ifeq 125\n 119: lload_1\n 120: lload_3\n 121: ladd\n 122: goto 154\n 125: lload_3\n 126: lload_1\n 127: lsub\n 128: goto 154\n 131: lload_1\n 132: lload_3\n 133: ldiv\n 134: goto 154\n 137: lload_1\n 138: lload_3\n 139: lmul\n 140: goto 154\n 143: new #281 // class java/lang/IllegalArgumentException\n 146: dup\n 147: ldc_w #283 // String Unexpected operator.\n 150: invokespecial #284 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 153: athrow\n 154: lreturn\n\n public static final void main();\n Code:\n 0: invokestatic #288 // Method readInput:()Ljava/util/List;\n 3: astore_0\n 4: aload_0\n 5: checkcast #290 // class java/lang/Iterable\n 8: astore_2\n 9: iconst_0\n 10: istore_3\n 11: aload_2\n 12: astore 4\n 14: new #292 // class java/util/ArrayList\n 17: dup\n 18: aload_2\n 19: bipush 10\n 21: invokestatic #298 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 24: invokespecial #301 // Method java/util/ArrayList.\"<init>\":(I)V\n 27: checkcast #303 // class java/util/Collection\n 30: astore 5\n 32: iconst_0\n 33: istore 6\n 35: aload 4\n 37: invokeinterface #307, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 7\n 44: aload 7\n 46: invokeinterface #313, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 94\n 54: aload 7\n 56: invokeinterface #316, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 8\n 63: aload 5\n 65: aload 8\n 67: checkcast #118 // class java/lang/String\n 70: astore 9\n 72: astore 11\n 74: iconst_0\n 75: istore 10\n 77: aload 9\n 79: invokestatic #318 // Method parseMonkey:(Ljava/lang/String;)Lkotlin/Pair;\n 82: aload 11\n 84: swap\n 85: invokeinterface #321, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 90: pop\n 91: goto 44\n 94: aload 5\n 96: checkcast #107 // class java/util/List\n 99: nop\n 100: checkcast #290 // class java/lang/Iterable\n 103: invokestatic #327 // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;\n 106: astore_1\n 107: aload_1\n 108: invokestatic #329 // Method solvePart1:(Ljava/util/Map;)J\n 111: lstore_2\n 112: new #331 // class java/lang/StringBuilder\n 115: dup\n 116: invokespecial #332 // Method java/lang/StringBuilder.\"<init>\":()V\n 119: ldc_w #334 // String Part 1:\n 122: invokevirtual #338 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 125: lload_2\n 126: invokevirtual #341 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 129: invokevirtual #345 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 132: getstatic #21 // Field java/lang/System.out:Ljava/io/PrintStream;\n 135: swap\n 136: invokevirtual #27 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 139: aload_1\n 140: invokestatic #347 // Method solvePart2:(Ljava/util/Map;)J\n 143: lstore 4\n 145: new #331 // class java/lang/StringBuilder\n 148: dup\n 149: invokespecial #332 // Method java/lang/StringBuilder.\"<init>\":()V\n 152: ldc_w #349 // String Part 2:\n 155: invokevirtual #338 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 158: lload 4\n 160: invokevirtual #341 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 163: invokevirtual #345 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 166: getstatic #21 // Field java/lang/System.out:Ljava/io/PrintStream;\n 169: swap\n 170: invokevirtual #27 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 173: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #365 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
thomasnield__traveling_salesman_demo__f6d2098/src/main/kotlin/CitiesAndDistances.kt
|
import java.util.concurrent.ThreadLocalRandom
data class CityPair(val city1: Int, val city2: Int)
class City(val id: Int, val name: String, val x: Double, val y: Double) {
override fun toString() = name
fun distanceTo(other: City) =CitiesAndDistances.distances[CityPair(id, other.id)]?:0.0
}
object CitiesAndDistances {
val citiesById = CitiesAndDistances::class.java.getResource("cities.csv").readText().lines()
.asSequence()
.map { it.split(",") }
.map { City(it[0].toInt(), it[1], it[2].toDouble(), it[3].toDouble()) }
.map { it.id to it }
.toMap()
val citiesByString = citiesById.entries.asSequence()
.map { it.value.name to it.value }
.toMap()
val cities = citiesById.values.toList()
val distances = CitiesAndDistances::class.java.getResource("distances.csv").readText().lines()
.asSequence()
.map { it.split(",") }
.map { CityPair(it[0].toInt(), it[1].toInt()) to it[2].toDouble() }
.toMap()
val distancesByStartCityId = distances.entries.asSequence()
.map { it.key.city1 to (cities[it.key.city2] to it.value) }
.groupBy({it.first},{it.second})
val randomCity get() = ThreadLocalRandom.current().nextInt(0,CitiesAndDistances.cities.count()).let { CitiesAndDistances.cities[it] }
}
operator fun Map<CityPair,String>.get(city1: Int, city2: Int) = get(CityPair(city1,city2))
operator fun Map<CityPair,String>.get(city1: City, city2: City) = get(CityPair(city1.id,city2.id))
|
[
{
"class_path": "thomasnield__traveling_salesman_demo__f6d2098/CitiesAndDistancesKt.class",
"javap": "Compiled from \"CitiesAndDistances.kt\"\npublic final class CitiesAndDistancesKt {\n public static final java.lang.String get(java.util.Map<CityPair, java.lang.String>, int, int);\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: new #19 // class CityPair\n 10: dup\n 11: iload_1\n 12: iload_2\n 13: invokespecial #23 // Method CityPair.\"<init>\":(II)V\n 16: invokeinterface #28, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 21: checkcast #30 // class java/lang/String\n 24: areturn\n\n public static final java.lang.String get(java.util.Map<CityPair, java.lang.String>, City, City);\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 #38 // String city1\n 9: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_2\n 13: ldc #39 // String city2\n 15: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: aload_0\n 19: new #19 // class CityPair\n 22: dup\n 23: aload_1\n 24: invokevirtual #45 // Method City.getId:()I\n 27: aload_2\n 28: invokevirtual #45 // Method City.getId:()I\n 31: invokespecial #23 // Method CityPair.\"<init>\":(II)V\n 34: invokeinterface #28, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 39: checkcast #30 // class java/lang/String\n 42: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "thomasnield__traveling_salesman_demo__f6d2098/CitiesAndDistances.class",
"javap": "Compiled from \"CitiesAndDistances.kt\"\npublic final class CitiesAndDistances {\n public static final CitiesAndDistances INSTANCE;\n\n private static final java.util.Map<java.lang.Integer, City> citiesById;\n\n private static final java.util.Map<java.lang.String, City> citiesByString;\n\n private static final java.util.List<City> cities;\n\n private static final java.util.Map<CityPair, java.lang.Double> distances;\n\n private static final java.util.Map<java.lang.Integer, java.util.List<kotlin.Pair<City, java.lang.Double>>> distancesByStartCityId;\n\n private CitiesAndDistances();\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.Map<java.lang.Integer, City> getCitiesById();\n Code:\n 0: getstatic #18 // Field citiesById:Ljava/util/Map;\n 3: areturn\n\n public final java.util.Map<java.lang.String, City> getCitiesByString();\n Code:\n 0: getstatic #23 // Field citiesByString:Ljava/util/Map;\n 3: areturn\n\n public final java.util.List<City> getCities();\n Code:\n 0: getstatic #30 // Field cities:Ljava/util/List;\n 3: areturn\n\n public final java.util.Map<CityPair, java.lang.Double> getDistances();\n Code:\n 0: getstatic #35 // Field distances:Ljava/util/Map;\n 3: areturn\n\n public final java.util.Map<java.lang.Integer, java.util.List<kotlin.Pair<City, java.lang.Double>>> getDistancesByStartCityId();\n Code:\n 0: getstatic #40 // Field distancesByStartCityId:Ljava/util/Map;\n 3: areturn\n\n public final City getRandomCity();\n Code:\n 0: invokestatic #48 // Method java/util/concurrent/ThreadLocalRandom.current:()Ljava/util/concurrent/ThreadLocalRandom;\n 3: iconst_0\n 4: getstatic #51 // Field INSTANCE:LCitiesAndDistances;\n 7: pop\n 8: getstatic #30 // Field cities:Ljava/util/List;\n 11: checkcast #53 // class java/util/Collection\n 14: invokeinterface #57, 1 // InterfaceMethod java/util/Collection.size:()I\n 19: invokevirtual #61 // Method java/util/concurrent/ThreadLocalRandom.nextInt:(II)I\n 22: istore_1\n 23: iconst_0\n 24: istore_2\n 25: getstatic #51 // Field INSTANCE:LCitiesAndDistances;\n 28: pop\n 29: getstatic #30 // Field cities:Ljava/util/List;\n 32: iload_1\n 33: invokeinterface #67, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 38: checkcast #69 // class City\n 41: nop\n 42: areturn\n\n private static final java.util.List citiesById$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #75 // String it\n 3: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #83 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #85 // class java/lang/String\n 14: astore_1\n 15: aload_1\n 16: iconst_0\n 17: ldc #87 // 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 #93 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: areturn\n\n private static final City citiesById$lambda$1(java.util.List);\n Code:\n 0: aload_0\n 1: ldc #75 // String it\n 3: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #69 // class City\n 9: dup\n 10: aload_0\n 11: iconst_0\n 12: invokeinterface #67, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 17: checkcast #85 // class java/lang/String\n 20: invokestatic #102 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 23: aload_0\n 24: iconst_1\n 25: invokeinterface #67, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 30: checkcast #85 // class java/lang/String\n 33: aload_0\n 34: iconst_2\n 35: invokeinterface #67, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 40: checkcast #85 // class java/lang/String\n 43: invokestatic #108 // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D\n 46: aload_0\n 47: iconst_3\n 48: invokeinterface #67, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 53: checkcast #85 // class java/lang/String\n 56: invokestatic #108 // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D\n 59: invokespecial #111 // Method City.\"<init>\":(ILjava/lang/String;DD)V\n 62: areturn\n\n private static final kotlin.Pair citiesById$lambda$2(City);\n Code:\n 0: aload_0\n 1: ldc #75 // String it\n 3: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokevirtual #116 // Method City.getId:()I\n 10: invokestatic #120 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 13: aload_0\n 14: invokestatic #126 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 17: areturn\n\n private static final kotlin.Pair citiesByString$lambda$3(java.util.Map$Entry);\n Code:\n 0: aload_0\n 1: ldc #75 // String it\n 3: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #135, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 12: checkcast #69 // class City\n 15: invokevirtual #139 // Method City.getName:()Ljava/lang/String;\n 18: aload_0\n 19: invokeinterface #135, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 24: invokestatic #126 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 27: areturn\n\n private static final java.util.List distances$lambda$4(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #75 // String it\n 3: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #83 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #85 // class java/lang/String\n 14: astore_1\n 15: aload_1\n 16: iconst_0\n 17: ldc #87 // 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 #93 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: areturn\n\n private static final kotlin.Pair distances$lambda$5(java.util.List);\n Code:\n 0: aload_0\n 1: ldc #75 // String it\n 3: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #145 // class CityPair\n 9: dup\n 10: aload_0\n 11: iconst_0\n 12: invokeinterface #67, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 17: checkcast #85 // class java/lang/String\n 20: invokestatic #102 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 23: aload_0\n 24: iconst_1\n 25: invokeinterface #67, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 30: checkcast #85 // class java/lang/String\n 33: invokestatic #102 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 36: invokespecial #148 // Method CityPair.\"<init>\":(II)V\n 39: aload_0\n 40: iconst_2\n 41: invokeinterface #67, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 46: checkcast #85 // class java/lang/String\n 49: invokestatic #108 // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D\n 52: invokestatic #151 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 55: invokestatic #126 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 58: areturn\n\n private static final kotlin.Pair distancesByStartCityId$lambda$6(java.util.Map$Entry);\n Code:\n 0: aload_0\n 1: ldc #75 // String it\n 3: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #155, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 12: checkcast #145 // class CityPair\n 15: invokevirtual #158 // Method CityPair.getCity1:()I\n 18: invokestatic #120 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 21: getstatic #51 // Field INSTANCE:LCitiesAndDistances;\n 24: pop\n 25: getstatic #30 // Field cities:Ljava/util/List;\n 28: aload_0\n 29: invokeinterface #155, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 34: checkcast #145 // class CityPair\n 37: invokevirtual #161 // Method CityPair.getCity2:()I\n 40: invokeinterface #67, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 45: aload_0\n 46: invokeinterface #135, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 51: invokestatic #126 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 54: invokestatic #126 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 57: areturn\n\n static {};\n Code:\n 0: new #2 // class CitiesAndDistances\n 3: dup\n 4: invokespecial #163 // Method \"<init>\":()V\n 7: putstatic #51 // Field INSTANCE:LCitiesAndDistances;\n 10: ldc #2 // class CitiesAndDistances\n 12: ldc #165 // String cities.csv\n 14: invokevirtual #171 // Method java/lang/Class.getResource:(Ljava/lang/String;)Ljava/net/URL;\n 17: dup\n 18: ldc #173 // String getResource(...)\n 20: invokestatic #176 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 23: astore_0\n 24: getstatic #182 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 27: astore_1\n 28: aload_0\n 29: invokestatic #188 // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B\n 32: astore_2\n 33: new #85 // class java/lang/String\n 36: dup\n 37: aload_2\n 38: aload_1\n 39: invokespecial #191 // Method java/lang/String.\"<init>\":([BLjava/nio/charset/Charset;)V\n 42: checkcast #83 // class java/lang/CharSequence\n 45: invokestatic #195 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 48: checkcast #197 // class java/lang/Iterable\n 51: invokestatic #203 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 54: invokedynamic #220, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 59: invokestatic #226 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 62: invokedynamic #231, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 67: invokestatic #226 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 70: invokedynamic #236, 0 // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;\n 75: invokestatic #226 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 78: invokestatic #242 // Method kotlin/collections/MapsKt.toMap:(Lkotlin/sequences/Sequence;)Ljava/util/Map;\n 81: putstatic #18 // Field citiesById:Ljava/util/Map;\n 84: getstatic #51 // Field INSTANCE:LCitiesAndDistances;\n 87: pop\n 88: getstatic #18 // Field citiesById:Ljava/util/Map;\n 91: invokeinterface #248, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 96: checkcast #197 // class java/lang/Iterable\n 99: invokestatic #203 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 102: invokedynamic #253, 0 // InvokeDynamic #3:invoke:()Lkotlin/jvm/functions/Function1;\n 107: invokestatic #226 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 110: invokestatic #242 // Method kotlin/collections/MapsKt.toMap:(Lkotlin/sequences/Sequence;)Ljava/util/Map;\n 113: putstatic #23 // Field citiesByString:Ljava/util/Map;\n 116: getstatic #51 // Field INSTANCE:LCitiesAndDistances;\n 119: pop\n 120: getstatic #18 // Field citiesById:Ljava/util/Map;\n 123: invokeinterface #257, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 128: checkcast #197 // class java/lang/Iterable\n 131: invokestatic #261 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 134: putstatic #30 // Field cities:Ljava/util/List;\n 137: ldc #2 // class CitiesAndDistances\n 139: ldc_w #263 // String distances.csv\n 142: invokevirtual #171 // Method java/lang/Class.getResource:(Ljava/lang/String;)Ljava/net/URL;\n 145: dup\n 146: ldc #173 // String getResource(...)\n 148: invokestatic #176 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 151: astore_0\n 152: getstatic #182 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 155: astore_1\n 156: aload_0\n 157: invokestatic #188 // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B\n 160: astore_2\n 161: new #85 // class java/lang/String\n 164: dup\n 165: aload_2\n 166: aload_1\n 167: invokespecial #191 // Method java/lang/String.\"<init>\":([BLjava/nio/charset/Charset;)V\n 170: checkcast #83 // class java/lang/CharSequence\n 173: invokestatic #195 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 176: checkcast #197 // class java/lang/Iterable\n 179: invokestatic #203 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 182: invokedynamic #267, 0 // InvokeDynamic #4:invoke:()Lkotlin/jvm/functions/Function1;\n 187: invokestatic #226 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 190: invokedynamic #272, 0 // InvokeDynamic #5:invoke:()Lkotlin/jvm/functions/Function1;\n 195: invokestatic #226 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 198: invokestatic #242 // Method kotlin/collections/MapsKt.toMap:(Lkotlin/sequences/Sequence;)Ljava/util/Map;\n 201: putstatic #35 // Field distances:Ljava/util/Map;\n 204: getstatic #51 // Field INSTANCE:LCitiesAndDistances;\n 207: pop\n 208: getstatic #35 // Field distances:Ljava/util/Map;\n 211: invokeinterface #248, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 216: checkcast #197 // class java/lang/Iterable\n 219: invokestatic #203 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 222: invokedynamic #276, 0 // InvokeDynamic #6:invoke:()Lkotlin/jvm/functions/Function1;\n 227: invokestatic #226 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 230: astore_0\n 231: nop\n 232: iconst_0\n 233: istore_1\n 234: aload_0\n 235: astore_2\n 236: new #278 // class java/util/LinkedHashMap\n 239: dup\n 240: invokespecial #279 // Method java/util/LinkedHashMap.\"<init>\":()V\n 243: checkcast #244 // class java/util/Map\n 246: astore_3\n 247: iconst_0\n 248: istore 4\n 250: aload_2\n 251: invokeinterface #285, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 256: astore 5\n 258: aload 5\n 260: invokeinterface #291, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 265: ifeq 399\n 268: aload 5\n 270: invokeinterface #294, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 275: astore 6\n 277: aload 6\n 279: checkcast #296 // class kotlin/Pair\n 282: astore 7\n 284: iconst_0\n 285: istore 8\n 287: aload 7\n 289: invokevirtual #299 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 292: checkcast #301 // class java/lang/Number\n 295: invokevirtual #304 // Method java/lang/Number.intValue:()I\n 298: invokestatic #120 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 301: astore 9\n 303: aload_3\n 304: astore 10\n 306: iconst_0\n 307: istore 11\n 309: aload 10\n 311: aload 9\n 313: invokeinterface #306, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 318: astore 12\n 320: aload 12\n 322: ifnonnull 357\n 325: iconst_0\n 326: istore 13\n 328: new #308 // class java/util/ArrayList\n 331: dup\n 332: invokespecial #309 // Method java/util/ArrayList.\"<init>\":()V\n 335: checkcast #63 // class java/util/List\n 338: astore 13\n 340: aload 10\n 342: aload 9\n 344: aload 13\n 346: invokeinterface #313, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 351: pop\n 352: aload 13\n 354: goto 359\n 357: aload 12\n 359: nop\n 360: checkcast #63 // class java/util/List\n 363: astore 7\n 365: aload 7\n 367: aload 6\n 369: checkcast #296 // class kotlin/Pair\n 372: astore 8\n 374: astore 15\n 376: iconst_0\n 377: istore 14\n 379: aload 8\n 381: invokevirtual #316 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 384: checkcast #296 // class kotlin/Pair\n 387: aload 15\n 389: swap\n 390: invokeinterface #320, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 395: pop\n 396: goto 258\n 399: aload_3\n 400: nop\n 401: putstatic #40 // Field distancesByStartCityId:Ljava/util/Map;\n 404: return\n}\n",
"javap_err": ""
}
] |
jacobprudhomme__advent-of-code-2022__9c2b080/src/day04/Day04.kt
|
import java.io.File
fun main() {
fun readInput(name: String) = File("src/day04", name)
.readLines()
fun processInput(line: String): Pair<Pair<Int, Int>, Pair<Int, Int>> {
val (range1, range2, _) = line.split(",").map { range ->
range.split("-").map { it.toInt() }.let { (start, end, _) ->
Pair(start, end)
}
}
return Pair(range1, range2)
}
fun sign(n: Int): Int =
if (n > 0) { 1 }
else if (n < 0) { -1 }
else { 0 }
fun Pair<Int, Int>.contains(otherRange: Pair<Int, Int>): Boolean {
val startDiff = this.first - otherRange.first
val endDiff = this.second - otherRange.second
return (sign(startDiff) >= 0) and (sign(endDiff) <= 0)
}
fun Pair<Int, Int>.overlaps(otherRange: Pair<Int, Int>): Boolean =
(this.first <= otherRange.second) and (otherRange.first <= this.second)
fun part1(input: List<String>): Int {
var count = 0
for (line in input) {
val (range1, range2) = processInput(line)
if (range1.contains(range2) or range2.contains(range1)) {
++count
}
}
return count
}
fun part2(input: List<String>): Int {
var count = 0
for (line in input) {
val (range1, range2) = processInput(line)
if (range1.overlaps(range2)) {
++count
}
}
return count
}
val input = readInput("input")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "jacobprudhomme__advent-of-code-2022__9c2b080/Day04Kt.class",
"javap": "Compiled from \"Day04.kt\"\npublic final class Day04Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String input\n 2: invokestatic #12 // Method main$readInput:(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: istore_1\n 11: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #28 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #31 // Method main$part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #28 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #35 // Method main:()V\n 3: return\n\n private static final java.util.List<java.lang.String> main$readInput(java.lang.String);\n Code:\n 0: new #40 // class java/io/File\n 3: dup\n 4: ldc #42 // String src/day04\n 6: aload_0\n 7: invokespecial #46 // Method java/io/File.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 10: aconst_null\n 11: iconst_1\n 12: aconst_null\n 13: invokestatic #52 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 16: areturn\n\n private static final kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>> main$processInput(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #59 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #61 // class java/lang/String\n 8: astore_2\n 9: aload_2\n 10: iconst_0\n 11: ldc #63 // 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 #69 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 23: checkcast #71 // class java/lang/Iterable\n 26: astore_2\n 27: iconst_0\n 28: istore_3\n 29: aload_2\n 30: astore 4\n 32: new #73 // class java/util/ArrayList\n 35: dup\n 36: aload_2\n 37: bipush 10\n 39: invokestatic #79 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 42: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 45: checkcast #83 // class java/util/Collection\n 48: astore 5\n 50: iconst_0\n 51: istore 6\n 53: aload 4\n 55: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 60: astore 7\n 62: aload 7\n 64: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 69: ifeq 293\n 72: aload 7\n 74: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 79: astore 8\n 81: aload 5\n 83: aload 8\n 85: checkcast #61 // class java/lang/String\n 88: astore 9\n 90: astore 21\n 92: iconst_0\n 93: istore 10\n 95: aload 9\n 97: checkcast #59 // class java/lang/CharSequence\n 100: iconst_1\n 101: anewarray #61 // class java/lang/String\n 104: astore 11\n 106: aload 11\n 108: iconst_0\n 109: ldc #99 // String -\n 111: aastore\n 112: aload 11\n 114: iconst_0\n 115: iconst_0\n 116: bipush 6\n 118: aconst_null\n 119: invokestatic #69 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 122: checkcast #71 // class java/lang/Iterable\n 125: astore 11\n 127: iconst_0\n 128: istore 12\n 130: aload 11\n 132: astore 13\n 134: new #73 // class java/util/ArrayList\n 137: dup\n 138: aload 11\n 140: bipush 10\n 142: invokestatic #79 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 145: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 148: checkcast #83 // class java/util/Collection\n 151: astore 14\n 153: iconst_0\n 154: istore 15\n 156: aload 13\n 158: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 163: astore 16\n 165: aload 16\n 167: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 172: ifeq 219\n 175: aload 16\n 177: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 182: astore 17\n 184: aload 14\n 186: aload 17\n 188: checkcast #61 // class java/lang/String\n 191: astore 18\n 193: astore 19\n 195: iconst_0\n 196: istore 20\n 198: aload 18\n 200: invokestatic #105 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 203: nop\n 204: invokestatic #109 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 207: aload 19\n 209: swap\n 210: invokeinterface #113, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 215: pop\n 216: goto 165\n 219: aload 14\n 221: checkcast #115 // class java/util/List\n 224: nop\n 225: astore 12\n 227: iconst_0\n 228: istore 13\n 230: aload 12\n 232: iconst_0\n 233: invokeinterface #119, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 238: checkcast #121 // class java/lang/Number\n 241: invokevirtual #125 // Method java/lang/Number.intValue:()I\n 244: istore 14\n 246: aload 12\n 248: iconst_1\n 249: invokeinterface #119, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 254: checkcast #121 // class java/lang/Number\n 257: invokevirtual #125 // Method java/lang/Number.intValue:()I\n 260: istore 15\n 262: new #127 // class kotlin/Pair\n 265: dup\n 266: iload 14\n 268: invokestatic #109 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 271: iload 15\n 273: invokestatic #109 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 276: invokespecial #130 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 279: nop\n 280: nop\n 281: aload 21\n 283: swap\n 284: invokeinterface #113, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 289: pop\n 290: goto 62\n 293: aload 5\n 295: checkcast #115 // class java/util/List\n 298: nop\n 299: astore_1\n 300: aload_1\n 301: iconst_0\n 302: invokeinterface #119, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 307: checkcast #127 // class kotlin/Pair\n 310: astore_2\n 311: aload_1\n 312: iconst_1\n 313: invokeinterface #119, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 318: checkcast #127 // class kotlin/Pair\n 321: astore_3\n 322: new #127 // class kotlin/Pair\n 325: dup\n 326: aload_2\n 327: aload_3\n 328: invokespecial #130 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 331: areturn\n\n private static final int main$sign(int);\n Code:\n 0: iload_0\n 1: ifle 8\n 4: iconst_1\n 5: goto 17\n 8: iload_0\n 9: ifge 16\n 12: iconst_m1\n 13: goto 17\n 16: iconst_0\n 17: ireturn\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 #160 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 4: checkcast #121 // class java/lang/Number\n 7: invokevirtual #125 // Method java/lang/Number.intValue:()I\n 10: aload_1\n 11: invokevirtual #160 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 14: checkcast #121 // class java/lang/Number\n 17: invokevirtual #125 // Method java/lang/Number.intValue:()I\n 20: isub\n 21: istore_2\n 22: aload_0\n 23: invokevirtual #163 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 26: checkcast #121 // class java/lang/Number\n 29: invokevirtual #125 // Method java/lang/Number.intValue:()I\n 32: aload_1\n 33: invokevirtual #163 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 36: checkcast #121 // class java/lang/Number\n 39: invokevirtual #125 // Method java/lang/Number.intValue:()I\n 42: isub\n 43: istore_3\n 44: iload_2\n 45: invokestatic #165 // Method main$sign:(I)I\n 48: iflt 55\n 51: iconst_1\n 52: goto 56\n 55: iconst_0\n 56: iload_3\n 57: invokestatic #165 // Method main$sign:(I)I\n 60: ifgt 67\n 63: iconst_1\n 64: goto 68\n 67: iconst_0\n 68: iand\n 69: ireturn\n\n private static final boolean main$overlaps(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 #160 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 4: checkcast #121 // class java/lang/Number\n 7: invokevirtual #125 // Method java/lang/Number.intValue:()I\n 10: aload_1\n 11: invokevirtual #163 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 14: checkcast #121 // class java/lang/Number\n 17: invokevirtual #125 // Method java/lang/Number.intValue:()I\n 20: if_icmpgt 27\n 23: iconst_1\n 24: goto 28\n 27: iconst_0\n 28: aload_1\n 29: invokevirtual #160 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 32: checkcast #121 // class java/lang/Number\n 35: invokevirtual #125 // Method java/lang/Number.intValue:()I\n 38: aload_0\n 39: invokevirtual #163 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 42: checkcast #121 // class java/lang/Number\n 45: invokevirtual #125 // Method java/lang/Number.intValue:()I\n 48: if_icmpgt 55\n 51: iconst_1\n 52: goto 56\n 55: iconst_0\n 56: iand\n 57: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: aload_0\n 3: invokeinterface #173, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 8: astore_2\n 9: aload_2\n 10: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 15: ifeq 78\n 18: aload_2\n 19: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 24: checkcast #61 // class java/lang/String\n 27: astore_3\n 28: aload_3\n 29: invokestatic #175 // Method main$processInput:(Ljava/lang/String;)Lkotlin/Pair;\n 32: astore 4\n 34: aload 4\n 36: invokevirtual #178 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 39: checkcast #127 // class kotlin/Pair\n 42: astore 5\n 44: aload 4\n 46: invokevirtual #181 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 49: checkcast #127 // class kotlin/Pair\n 52: astore 6\n 54: aload 5\n 56: aload 6\n 58: invokestatic #183 // Method main$contains:(Lkotlin/Pair;Lkotlin/Pair;)Z\n 61: aload 6\n 63: aload 5\n 65: invokestatic #183 // Method main$contains:(Lkotlin/Pair;Lkotlin/Pair;)Z\n 68: ior\n 69: ifeq 9\n 72: iinc 1, 1\n 75: goto 9\n 78: iload_1\n 79: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: aload_0\n 3: invokeinterface #173, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 8: astore_2\n 9: aload_2\n 10: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 15: ifeq 70\n 18: aload_2\n 19: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 24: checkcast #61 // class java/lang/String\n 27: astore_3\n 28: aload_3\n 29: invokestatic #175 // Method main$processInput:(Ljava/lang/String;)Lkotlin/Pair;\n 32: astore 4\n 34: aload 4\n 36: invokevirtual #178 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 39: checkcast #127 // class kotlin/Pair\n 42: astore 5\n 44: aload 4\n 46: invokevirtual #181 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 49: checkcast #127 // class kotlin/Pair\n 52: astore 6\n 54: aload 5\n 56: aload 6\n 58: invokestatic #186 // Method main$overlaps:(Lkotlin/Pair;Lkotlin/Pair;)Z\n 61: ifeq 9\n 64: iinc 1, 1\n 67: goto 9\n 70: iload_1\n 71: ireturn\n}\n",
"javap_err": ""
}
] |
jacobprudhomme__advent-of-code-2022__9c2b080/src/day05/Day05.kt
|
import java.io.File
typealias CrateStacks = Array<ArrayDeque<Char>>
typealias CraneProcedure = List<Triple<Int, Int, Int>>
fun main() {
fun readInput(name: String) = File("src/day05", name)
.readLines()
fun processInput(input: List<String>): Pair<CrateStacks, CraneProcedure> {
val craneProcedureStrs = input.takeLastWhile { it.isNotEmpty() }
val craneProcedure: CraneProcedure = craneProcedureStrs.map { procedure ->
Regex("\\d+")
.findAll(procedure)
.map(MatchResult::value)
.map(String::toInt)
.toList()
.let { (num, from, to, _) -> Triple(num, from-1, to-1) }
}
val (crateStacksStrs, stackNumbersStr) = input
.takeWhile { it.isNotEmpty() }
.let { Pair(it.dropLast(1).reversed(), it.last()) }
val numStacks = Regex("\\d+")
.findAll(stackNumbersStr)
.count()
val crateStacks = Array(numStacks) { ArrayDeque<Char>() }
for (line in crateStacksStrs) {
val cratesAtLevel = line.chunked(4) { it.filter(Char::isLetter) }
cratesAtLevel.forEachIndexed { i, crate ->
if (crate.isNotEmpty()) {
crateStacks[i].addLast(crate.first())
}
}
}
return Pair(crateStacks, craneProcedure)
}
fun part1(input: List<String>): String {
val (crateStacks, craneProcedure) = processInput(input)
for ((num, from, to) in craneProcedure) {
repeat(num) {
val crate = crateStacks[from].removeLast()
crateStacks[to].addLast(crate)
}
}
return crateStacks.map { it.last() }.joinToString("")
}
fun part2(input: List<String>): String {
val (crateStacks, craneProcedure) = processInput(input)
for ((num, from, to) in craneProcedure) {
val crates = crateStacks[from].takeLast(num)
repeat(num) {
crateStacks[from].removeLast()
}
crateStacks[to].addAll(crates)
}
return crateStacks.map { it.last() }.joinToString("")
}
val input = readInput("input")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "jacobprudhomme__advent-of-code-2022__9c2b080/Day05Kt$main$processInput$craneProcedure$1$2.class",
"javap": "Compiled from \"Day05.kt\"\nfinal class Day05Kt$main$processInput$craneProcedure$1$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, java.lang.Integer> {\n public static final Day05Kt$main$processInput$craneProcedure$1$2 INSTANCE;\n\n Day05Kt$main$processInput$craneProcedure$1$2();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class kotlin/text/StringsKt\n 4: ldc #13 // String toInt\n 6: ldc #15 // String toInt(Ljava/lang/String;)I\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.Integer invoke(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #24 // String p0\n 3: invokestatic #30 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokestatic #36 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 10: invokestatic #40 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 13: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #44 // class java/lang/String\n 5: invokevirtual #46 // Method invoke:(Ljava/lang/String;)Ljava/lang/Integer;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class Day05Kt$main$processInput$craneProcedure$1$2\n 3: dup\n 4: invokespecial #51 // Method \"<init>\":()V\n 7: putstatic #54 // Field INSTANCE:LDay05Kt$main$processInput$craneProcedure$1$2;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "jacobprudhomme__advent-of-code-2022__9c2b080/Day05Kt.class",
"javap": "Compiled from \"Day05.kt\"\npublic final class Day05Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String input\n 2: invokestatic #12 // Method main$readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #16 // Method main$part1:(Ljava/util/List;)Ljava/lang/String;\n 10: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 13: swap\n 14: invokevirtual #28 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 17: aload_0\n 18: invokestatic #31 // Method main$part2:(Ljava/util/List;)Ljava/lang/String;\n 21: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 24: swap\n 25: invokevirtual #28 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 28: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #35 // Method main:()V\n 3: return\n\n private static final java.util.List<java.lang.String> main$readInput(java.lang.String);\n Code:\n 0: new #40 // class java/io/File\n 3: dup\n 4: ldc #42 // String src/day05\n 6: aload_0\n 7: invokespecial #46 // Method java/io/File.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 10: aconst_null\n 11: iconst_1\n 12: aconst_null\n 13: invokestatic #52 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 16: areturn\n\n private static final java.lang.CharSequence main$processInput$lambda$5(java.lang.CharSequence);\n Code:\n 0: aload_0\n 1: ldc #58 // String it\n 3: invokestatic #64 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: astore_3\n 12: new #66 // class java/lang/StringBuilder\n 15: dup\n 16: invokespecial #68 // Method java/lang/StringBuilder.\"<init>\":()V\n 19: checkcast #70 // class java/lang/Appendable\n 22: astore 4\n 24: iconst_0\n 25: istore 5\n 27: iconst_0\n 28: istore 6\n 30: aload_3\n 31: invokeinterface #76, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 36: istore 7\n 38: iload 6\n 40: iload 7\n 42: if_icmpge 87\n 45: aload_3\n 46: iload 6\n 48: invokeinterface #80, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 53: istore 8\n 55: iload 8\n 57: istore 9\n 59: iconst_0\n 60: istore 10\n 62: iload 9\n 64: invokestatic #86 // Method java/lang/Character.isLetter:(C)Z\n 67: nop\n 68: ifeq 81\n 71: aload 4\n 73: iload 8\n 75: invokeinterface #90, 2 // InterfaceMethod java/lang/Appendable.append:(C)Ljava/lang/Appendable;\n 80: pop\n 81: iinc 6, 1\n 84: goto 38\n 87: aload 4\n 89: checkcast #72 // class java/lang/CharSequence\n 92: nop\n 93: areturn\n\n private static final kotlin.Pair<kotlin.collections.ArrayDeque<java.lang.Character>[], java.util.List<kotlin.Triple<java.lang.Integer, java.lang.Integer, java.lang.Integer>>> main$processInput(java.util.List<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: invokeinterface #112, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 10: ifeq 19\n 13: invokestatic #118 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 16: goto 175\n 19: aload_2\n 20: aload_2\n 21: invokeinterface #121, 1 // InterfaceMethod java/util/List.size:()I\n 26: invokeinterface #125, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 31: astore 4\n 33: aload 4\n 35: invokeinterface #130, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 40: ifeq 168\n 43: aload 4\n 45: invokeinterface #134, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 50: checkcast #136 // class java/lang/String\n 53: astore 5\n 55: iconst_0\n 56: istore 6\n 58: aload 5\n 60: checkcast #72 // class java/lang/CharSequence\n 63: invokeinterface #76, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 68: ifle 75\n 71: iconst_1\n 72: goto 76\n 75: iconst_0\n 76: nop\n 77: ifne 33\n 80: aload 4\n 82: invokeinterface #139, 1 // InterfaceMethod java/util/ListIterator.next:()Ljava/lang/Object;\n 87: pop\n 88: aload_2\n 89: invokeinterface #121, 1 // InterfaceMethod java/util/List.size:()I\n 94: aload 4\n 96: invokeinterface #142, 1 // InterfaceMethod java/util/ListIterator.nextIndex:()I\n 101: isub\n 102: istore 7\n 104: iload 7\n 106: ifne 115\n 109: invokestatic #118 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 112: goto 175\n 115: new #144 // class java/util/ArrayList\n 118: dup\n 119: iload 7\n 121: invokespecial #147 // Method java/util/ArrayList.\"<init>\":(I)V\n 124: astore 8\n 126: aload 8\n 128: astore 9\n 130: iconst_0\n 131: istore 10\n 133: aload 4\n 135: invokeinterface #150, 1 // InterfaceMethod java/util/ListIterator.hasNext:()Z\n 140: ifeq 159\n 143: aload 9\n 145: aload 4\n 147: invokeinterface #139, 1 // InterfaceMethod java/util/ListIterator.next:()Ljava/lang/Object;\n 152: invokevirtual #154 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 155: pop\n 156: goto 133\n 159: nop\n 160: aload 8\n 162: checkcast #108 // class java/util/List\n 165: goto 175\n 168: aload_2\n 169: checkcast #156 // class java/lang/Iterable\n 172: invokestatic #160 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 175: astore_1\n 176: aload_1\n 177: checkcast #156 // class java/lang/Iterable\n 180: astore_3\n 181: iconst_0\n 182: istore 4\n 184: aload_3\n 185: astore 5\n 187: new #144 // class java/util/ArrayList\n 190: dup\n 191: aload_3\n 192: bipush 10\n 194: invokestatic #164 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 197: invokespecial #147 // Method java/util/ArrayList.\"<init>\":(I)V\n 200: checkcast #166 // class java/util/Collection\n 203: astore 6\n 205: iconst_0\n 206: istore 7\n 208: aload 5\n 210: invokeinterface #170, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 215: astore 8\n 217: aload 8\n 219: invokeinterface #173, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 224: ifeq 384\n 227: aload 8\n 229: invokeinterface #174, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 234: astore 9\n 236: aload 6\n 238: aload 9\n 240: checkcast #136 // class java/lang/String\n 243: astore 10\n 245: astore 20\n 247: iconst_0\n 248: istore 11\n 250: new #176 // class kotlin/text/Regex\n 253: dup\n 254: ldc #178 // String \\\\d+\n 256: invokespecial #181 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 259: aload 10\n 261: checkcast #72 // class java/lang/CharSequence\n 264: iconst_0\n 265: iconst_2\n 266: aconst_null\n 267: invokestatic #185 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 270: getstatic #191 // Field Day05Kt$main$processInput$craneProcedure$1$1.INSTANCE:LDay05Kt$main$processInput$craneProcedure$1$1;\n 273: checkcast #193 // class kotlin/jvm/functions/Function1\n 276: invokestatic #199 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 279: getstatic #204 // Field Day05Kt$main$processInput$craneProcedure$1$2.INSTANCE:LDay05Kt$main$processInput$craneProcedure$1$2;\n 282: checkcast #193 // class kotlin/jvm/functions/Function1\n 285: invokestatic #199 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 288: invokestatic #207 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 291: astore 12\n 293: iconst_0\n 294: istore 13\n 296: aload 12\n 298: iconst_0\n 299: invokeinterface #211, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 304: checkcast #213 // class java/lang/Number\n 307: invokevirtual #216 // Method java/lang/Number.intValue:()I\n 310: istore 14\n 312: aload 12\n 314: iconst_1\n 315: invokeinterface #211, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 320: checkcast #213 // class java/lang/Number\n 323: invokevirtual #216 // Method java/lang/Number.intValue:()I\n 326: istore 15\n 328: aload 12\n 330: iconst_2\n 331: invokeinterface #211, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 336: checkcast #213 // class java/lang/Number\n 339: invokevirtual #216 // Method java/lang/Number.intValue:()I\n 342: istore 16\n 344: new #218 // class kotlin/Triple\n 347: dup\n 348: iload 14\n 350: invokestatic #224 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 353: iload 15\n 355: iconst_1\n 356: isub\n 357: invokestatic #224 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 360: iload 16\n 362: iconst_1\n 363: isub\n 364: invokestatic #224 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 367: invokespecial #227 // Method kotlin/Triple.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V\n 370: nop\n 371: nop\n 372: aload 20\n 374: swap\n 375: invokeinterface #228, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 380: pop\n 381: goto 217\n 384: aload 6\n 386: checkcast #108 // class java/util/List\n 389: nop\n 390: astore_2\n 391: aload_0\n 392: checkcast #156 // class java/lang/Iterable\n 395: astore 4\n 397: nop\n 398: iconst_0\n 399: istore 5\n 401: new #144 // class java/util/ArrayList\n 404: dup\n 405: invokespecial #229 // Method java/util/ArrayList.\"<init>\":()V\n 408: astore 6\n 410: aload 4\n 412: invokeinterface #170, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 417: astore 7\n 419: aload 7\n 421: invokeinterface #173, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 426: ifeq 484\n 429: aload 7\n 431: invokeinterface #174, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 436: astore 8\n 438: aload 8\n 440: checkcast #136 // class java/lang/String\n 443: astore 9\n 445: iconst_0\n 446: istore 10\n 448: aload 9\n 450: checkcast #72 // class java/lang/CharSequence\n 453: invokeinterface #76, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 458: ifle 465\n 461: iconst_1\n 462: goto 466\n 465: iconst_0\n 466: nop\n 467: ifne 473\n 470: goto 484\n 473: aload 6\n 475: aload 8\n 477: invokevirtual #154 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 480: pop\n 481: goto 419\n 484: aload 6\n 486: checkcast #108 // class java/util/List\n 489: astore 5\n 491: iconst_0\n 492: istore 6\n 494: new #231 // class kotlin/Pair\n 497: dup\n 498: aload 5\n 500: iconst_1\n 501: invokestatic #235 // Method kotlin/collections/CollectionsKt.dropLast:(Ljava/util/List;I)Ljava/util/List;\n 504: checkcast #156 // class java/lang/Iterable\n 507: invokestatic #238 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 510: aload 5\n 512: invokestatic #242 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 515: invokespecial #245 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 518: nop\n 519: astore_3\n 520: aload_3\n 521: invokevirtual #248 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 524: checkcast #108 // class java/util/List\n 527: astore 4\n 529: aload_3\n 530: invokevirtual #251 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 533: checkcast #136 // class java/lang/String\n 536: astore 5\n 538: new #176 // class kotlin/text/Regex\n 541: dup\n 542: ldc #178 // String \\\\d+\n 544: invokespecial #181 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 547: aload 5\n 549: checkcast #72 // class java/lang/CharSequence\n 552: iconst_0\n 553: iconst_2\n 554: aconst_null\n 555: invokestatic #185 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 558: invokestatic #255 // Method kotlin/sequences/SequencesKt.count:(Lkotlin/sequences/Sequence;)I\n 561: istore 6\n 563: iconst_0\n 564: istore 8\n 566: iload 6\n 568: anewarray #257 // class kotlin/collections/ArrayDeque\n 571: astore 9\n 573: iload 8\n 575: iload 6\n 577: if_icmpge 602\n 580: iload 8\n 582: istore 10\n 584: aload 9\n 586: iload 10\n 588: new #257 // class kotlin/collections/ArrayDeque\n 591: dup\n 592: invokespecial #258 // Method kotlin/collections/ArrayDeque.\"<init>\":()V\n 595: aastore\n 596: iinc 8, 1\n 599: goto 573\n 602: aload 9\n 604: astore 7\n 606: aload 4\n 608: invokeinterface #259, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 613: astore 8\n 615: aload 8\n 617: invokeinterface #173, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 622: ifeq 766\n 625: aload 8\n 627: invokeinterface #174, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 632: checkcast #136 // class java/lang/String\n 635: astore 9\n 637: aload 9\n 639: checkcast #72 // class java/lang/CharSequence\n 642: iconst_4\n 643: invokedynamic #276, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 648: invokestatic #282 // Method kotlin/text/StringsKt.chunked:(Ljava/lang/CharSequence;ILkotlin/jvm/functions/Function1;)Ljava/util/List;\n 651: astore 10\n 653: aload 10\n 655: checkcast #156 // class java/lang/Iterable\n 658: astore 11\n 660: iconst_0\n 661: istore 12\n 663: iconst_0\n 664: istore 13\n 666: aload 11\n 668: invokeinterface #170, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 673: astore 14\n 675: aload 14\n 677: invokeinterface #173, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 682: ifeq 762\n 685: aload 14\n 687: invokeinterface #174, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 692: astore 15\n 694: iload 13\n 696: iinc 13, 1\n 699: istore 16\n 701: iload 16\n 703: ifge 709\n 706: invokestatic #285 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 709: iload 16\n 711: aload 15\n 713: checkcast #72 // class java/lang/CharSequence\n 716: astore 17\n 718: istore 18\n 720: iconst_0\n 721: istore 19\n 723: aload 17\n 725: invokeinterface #76, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 730: ifle 737\n 733: iconst_1\n 734: goto 738\n 737: iconst_0\n 738: ifeq 757\n 741: aload 7\n 743: iload 18\n 745: aaload\n 746: aload 17\n 748: invokestatic #289 // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C\n 751: invokestatic #292 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 754: invokevirtual #295 // Method kotlin/collections/ArrayDeque.addLast:(Ljava/lang/Object;)V\n 757: nop\n 758: nop\n 759: goto 675\n 762: nop\n 763: goto 615\n 766: new #231 // class kotlin/Pair\n 769: dup\n 770: aload 7\n 772: aload_2\n 773: invokespecial #245 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 776: areturn\n\n private static final java.lang.String main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #343 // Method main$processInput:(Ljava/util/List;)Lkotlin/Pair;\n 4: astore_1\n 5: aload_1\n 6: invokevirtual #248 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 9: checkcast #340 // class \"[Lkotlin/collections/ArrayDeque;\"\n 12: astore_2\n 13: aload_1\n 14: invokevirtual #251 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 17: checkcast #108 // class java/util/List\n 20: astore_3\n 21: aload_3\n 22: invokeinterface #259, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 27: astore 4\n 29: aload 4\n 31: invokeinterface #173, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 36: ifeq 141\n 39: aload 4\n 41: invokeinterface #174, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 46: checkcast #218 // class kotlin/Triple\n 49: astore 5\n 51: aload 5\n 53: invokevirtual #344 // Method kotlin/Triple.component1:()Ljava/lang/Object;\n 56: checkcast #213 // class java/lang/Number\n 59: invokevirtual #216 // Method java/lang/Number.intValue:()I\n 62: istore 6\n 64: aload 5\n 66: invokevirtual #345 // Method kotlin/Triple.component2:()Ljava/lang/Object;\n 69: checkcast #213 // class java/lang/Number\n 72: invokevirtual #216 // Method java/lang/Number.intValue:()I\n 75: istore 7\n 77: aload 5\n 79: invokevirtual #348 // Method kotlin/Triple.component3:()Ljava/lang/Object;\n 82: checkcast #213 // class java/lang/Number\n 85: invokevirtual #216 // Method java/lang/Number.intValue:()I\n 88: istore 8\n 90: iconst_0\n 91: istore 9\n 93: iload 9\n 95: iload 6\n 97: if_icmpge 29\n 100: iload 9\n 102: istore 10\n 104: iconst_0\n 105: istore 11\n 107: aload_2\n 108: iload 7\n 110: aaload\n 111: invokevirtual #351 // Method kotlin/collections/ArrayDeque.removeLast:()Ljava/lang/Object;\n 114: checkcast #82 // class java/lang/Character\n 117: invokevirtual #355 // Method java/lang/Character.charValue:()C\n 120: istore 12\n 122: aload_2\n 123: iload 8\n 125: aaload\n 126: iload 12\n 128: invokestatic #292 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 131: invokevirtual #295 // Method kotlin/collections/ArrayDeque.addLast:(Ljava/lang/Object;)V\n 134: nop\n 135: iinc 9, 1\n 138: goto 93\n 141: aload_2\n 142: astore 4\n 144: iconst_0\n 145: istore 5\n 147: aload 4\n 149: astore 6\n 151: new #144 // class java/util/ArrayList\n 154: dup\n 155: aload 4\n 157: arraylength\n 158: invokespecial #147 // Method java/util/ArrayList.\"<init>\":(I)V\n 161: checkcast #166 // class java/util/Collection\n 164: astore 7\n 166: iconst_0\n 167: istore 8\n 169: iconst_0\n 170: istore 9\n 172: aload 6\n 174: arraylength\n 175: istore 10\n 177: iload 9\n 179: iload 10\n 181: if_icmpge 231\n 184: aload 6\n 186: iload 9\n 188: aaload\n 189: astore 11\n 191: aload 7\n 193: aload 11\n 195: astore 12\n 197: astore 14\n 199: iconst_0\n 200: istore 13\n 202: aload 12\n 204: invokevirtual #357 // Method kotlin/collections/ArrayDeque.last:()Ljava/lang/Object;\n 207: checkcast #82 // class java/lang/Character\n 210: invokevirtual #355 // Method java/lang/Character.charValue:()C\n 213: invokestatic #292 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 216: aload 14\n 218: swap\n 219: invokeinterface #228, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 224: pop\n 225: iinc 9, 1\n 228: goto 177\n 231: aload 7\n 233: checkcast #108 // class java/util/List\n 236: nop\n 237: checkcast #156 // class java/lang/Iterable\n 240: ldc_w #359 // String\n 243: checkcast #72 // class java/lang/CharSequence\n 246: aconst_null\n 247: aconst_null\n 248: iconst_0\n 249: aconst_null\n 250: aconst_null\n 251: bipush 62\n 253: aconst_null\n 254: invokestatic #363 // 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 257: areturn\n\n private static final java.lang.String main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #343 // Method main$processInput:(Ljava/util/List;)Lkotlin/Pair;\n 4: astore_1\n 5: aload_1\n 6: invokevirtual #248 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 9: checkcast #340 // class \"[Lkotlin/collections/ArrayDeque;\"\n 12: astore_2\n 13: aload_1\n 14: invokevirtual #251 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 17: checkcast #108 // class java/util/List\n 20: astore_3\n 21: aload_3\n 22: invokeinterface #259, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 27: astore 4\n 29: aload 4\n 31: invokeinterface #173, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 36: ifeq 152\n 39: aload 4\n 41: invokeinterface #174, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 46: checkcast #218 // class kotlin/Triple\n 49: astore 5\n 51: aload 5\n 53: invokevirtual #344 // Method kotlin/Triple.component1:()Ljava/lang/Object;\n 56: checkcast #213 // class java/lang/Number\n 59: invokevirtual #216 // Method java/lang/Number.intValue:()I\n 62: istore 6\n 64: aload 5\n 66: invokevirtual #345 // Method kotlin/Triple.component2:()Ljava/lang/Object;\n 69: checkcast #213 // class java/lang/Number\n 72: invokevirtual #216 // Method java/lang/Number.intValue:()I\n 75: istore 7\n 77: aload 5\n 79: invokevirtual #348 // Method kotlin/Triple.component3:()Ljava/lang/Object;\n 82: checkcast #213 // class java/lang/Number\n 85: invokevirtual #216 // Method java/lang/Number.intValue:()I\n 88: istore 8\n 90: aload_2\n 91: iload 7\n 93: aaload\n 94: checkcast #108 // class java/util/List\n 97: iload 6\n 99: invokestatic #370 // Method kotlin/collections/CollectionsKt.takeLast:(Ljava/util/List;I)Ljava/util/List;\n 102: astore 9\n 104: iconst_0\n 105: istore 10\n 107: iload 10\n 109: iload 6\n 111: if_icmpge 136\n 114: iload 10\n 116: istore 11\n 118: iconst_0\n 119: istore 12\n 121: aload_2\n 122: iload 7\n 124: aaload\n 125: invokevirtual #351 // Method kotlin/collections/ArrayDeque.removeLast:()Ljava/lang/Object;\n 128: pop\n 129: nop\n 130: iinc 10, 1\n 133: goto 107\n 136: aload_2\n 137: iload 8\n 139: aaload\n 140: aload 9\n 142: checkcast #166 // class java/util/Collection\n 145: invokevirtual #374 // Method kotlin/collections/ArrayDeque.addAll:(Ljava/util/Collection;)Z\n 148: pop\n 149: goto 29\n 152: aload_2\n 153: astore 4\n 155: iconst_0\n 156: istore 5\n 158: aload 4\n 160: astore 6\n 162: new #144 // class java/util/ArrayList\n 165: dup\n 166: aload 4\n 168: arraylength\n 169: invokespecial #147 // Method java/util/ArrayList.\"<init>\":(I)V\n 172: checkcast #166 // class java/util/Collection\n 175: astore 7\n 177: iconst_0\n 178: istore 8\n 180: iconst_0\n 181: istore 9\n 183: aload 6\n 185: arraylength\n 186: istore 10\n 188: iload 9\n 190: iload 10\n 192: if_icmpge 242\n 195: aload 6\n 197: iload 9\n 199: aaload\n 200: astore 11\n 202: aload 7\n 204: aload 11\n 206: astore 12\n 208: astore 14\n 210: iconst_0\n 211: istore 13\n 213: aload 12\n 215: invokevirtual #357 // Method kotlin/collections/ArrayDeque.last:()Ljava/lang/Object;\n 218: checkcast #82 // class java/lang/Character\n 221: invokevirtual #355 // Method java/lang/Character.charValue:()C\n 224: invokestatic #292 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 227: aload 14\n 229: swap\n 230: invokeinterface #228, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 235: pop\n 236: iinc 9, 1\n 239: goto 188\n 242: aload 7\n 244: checkcast #108 // class java/util/List\n 247: nop\n 248: checkcast #156 // class java/lang/Iterable\n 251: ldc_w #359 // String\n 254: checkcast #72 // class java/lang/CharSequence\n 257: aconst_null\n 258: aconst_null\n 259: iconst_0\n 260: aconst_null\n 261: aconst_null\n 262: bipush 62\n 264: aconst_null\n 265: invokestatic #363 // 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 268: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "jacobprudhomme__advent-of-code-2022__9c2b080/Day05Kt$main$processInput$craneProcedure$1$1.class",
"javap": "Compiled from \"Day05.kt\"\nfinal class Day05Kt$main$processInput$craneProcedure$1$1 extends kotlin.jvm.internal.PropertyReference1Impl {\n public static final Day05Kt$main$processInput$craneProcedure$1$1 INSTANCE;\n\n Day05Kt$main$processInput$craneProcedure$1$1();\n Code:\n 0: aload_0\n 1: ldc #8 // class kotlin/text/MatchResult\n 3: ldc #10 // String value\n 5: ldc #12 // String getValue()Ljava/lang/String;\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/text/MatchResult\n 4: invokeinterface #23, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 9: areturn\n\n static {};\n Code:\n 0: new #2 // class Day05Kt$main$processInput$craneProcedure$1$1\n 3: dup\n 4: invokespecial #28 // Method \"<init>\":()V\n 7: putstatic #31 // Field INSTANCE:LDay05Kt$main$processInput$craneProcedure$1$1;\n 10: return\n}\n",
"javap_err": ""
}
] |
jacobprudhomme__advent-of-code-2022__9c2b080/src/day11/Day11.kt
|
import java.io.File
import java.lang.IllegalArgumentException
import java.math.BigInteger
import java.util.PriorityQueue
class Monkey(
val heldItems: MutableList<Int>,
val applyOperation: (Int) -> BigInteger,
val decide: (Int) -> Int
) {
var inspectedItems: BigInteger = BigInteger.ZERO
fun inspect() { ++inspectedItems }
}
fun main() {
fun readInput(name: String) = File("src/day11", name)
.readLines()
fun iterateInput(input: List<String>) = sequence {
var currMonkey = input.takeWhile { it.isNotBlank() }.drop(1)
var rest = input.dropWhile { it.isNotBlank() }.drop(1)
while (currMonkey.isNotEmpty()) {
yield(currMonkey)
currMonkey = rest.takeWhile { it.isNotBlank() }
.let { if (it.isNotEmpty()) { it.drop(1) } else { it } }
rest = rest.dropWhile { it.isNotBlank() }
.let { if (it.isNotEmpty()) { it.drop(1) } else { it } }
}
}
fun processOperation(
opStr: String,
leftArg: String,
rightArg: String
): (Int) -> BigInteger {
val operation: (BigInteger, BigInteger) -> BigInteger = when (opStr) {
"+" -> { m, n -> m + n }
"*" -> { m, n -> m * n }
else -> throw IllegalArgumentException("We should never get here")
}
return if ((leftArg == "old") and (rightArg == "old")) {
{ n -> operation(n.toBigInteger(), n.toBigInteger()) }
} else if (leftArg == "old") {
{ n -> operation(n.toBigInteger(), rightArg.toBigInteger()) }
} else if (rightArg == "old") {
{ n -> operation(leftArg.toBigInteger(), n.toBigInteger()) }
} else {
{ _ -> operation(leftArg.toBigInteger(), rightArg.toBigInteger()) }
}
}
fun gcd(m: Int, n: Int): Int {
var a = m
var b = n
while (b > 0) {
val temp = b
b = a % b
a = temp
}
return a
}
fun lcm(m: Int, n: Int): Int = (m * n) / gcd(m, n)
fun processInput(input: List<String>): Pair<Array<Monkey>, Int> {
val monkeys = mutableListOf<Monkey>()
val testValues = mutableListOf<Int>()
for (monkeyStr in iterateInput(input)) {
val initItems = monkeyStr[0].substring(18).split(", ").map(String::toInt)
val (leftArg, op, rightArg, _) = monkeyStr[1].substring(19).split(" ")
val testValue = monkeyStr[2].substring(21).toInt()
val trueResult = monkeyStr[3].substring(29).toInt()
val falseResult = monkeyStr[4].substring(30).toInt()
val monkey = Monkey(
initItems.toMutableList(),
processOperation(op, leftArg, rightArg)
) { n -> if (n % testValue == 0) { trueResult } else { falseResult } }
monkeys.add(monkey)
testValues.add(testValue)
}
return Pair(monkeys.toTypedArray(), testValues.reduce { acc, value -> lcm(acc, value) })
}
fun doRound(monkeys: Array<Monkey>, spiraling: Boolean = false, lcm: Int = 1) {
for (monkey in monkeys) {
while (monkey.heldItems.isNotEmpty()) {
val currItem = monkey.heldItems.removeFirst()
monkey.inspect()
val worryLevel = monkey.applyOperation(currItem)
.let { if (spiraling) { it % lcm.toBigInteger() } else { it.div(3.toBigInteger()) } }
.toInt()
val monkeyToCatch = monkey.decide(worryLevel)
monkeys[monkeyToCatch].heldItems.add(worryLevel)
}
}
}
fun multiplyTwoLargest(monkeys: Array<Monkey>): BigInteger {
val monkeysByInspectedElements = PriorityQueue(monkeys.map { -it.inspectedItems }) // Induce max-queue
return monkeysByInspectedElements.poll() * monkeysByInspectedElements.poll()
}
fun part1(input: List<String>): BigInteger {
val (monkeys, _) = processInput(input)
repeat(20) {
doRound(monkeys)
}
return multiplyTwoLargest(monkeys)
}
fun part2(input: List<String>): BigInteger {
val (monkeys, lcm) = processInput(input)
repeat(10000) {
doRound(monkeys, spiraling=true, lcm=lcm)
}
return multiplyTwoLargest(monkeys)
}
val input = readInput("input")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "jacobprudhomme__advent-of-code-2022__9c2b080/Day11Kt$main$iterateInput$1.class",
"javap": "Compiled from \"Day11.kt\"\nfinal class Day11Kt$main$iterateInput$1 extends kotlin.coroutines.jvm.internal.RestrictedSuspendLambda implements kotlin.jvm.functions.Function2<kotlin.sequences.SequenceScope<? super java.util.List<? extends java.lang.String>>, 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 java.util.List<java.lang.String> $input;\n\n Day11Kt$main$iterateInput$1(java.util.List<java.lang.String>, kotlin.coroutines.Continuation<? super Day11Kt$main$iterateInput$1>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: putfield #14 // Field $input:Ljava/util/List;\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 13\n 5: aload_0\n 6: getfield #49 // Field label:I\n 9: tableswitch { // 0 to 1\n 0: 32\n 1: 330\n default: 656\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 $input:Ljava/util/List;\n 48: checkcast #61 // class java/lang/Iterable\n 51: astore 4\n 53: iconst_0\n 54: istore 5\n 56: new #63 // class java/util/ArrayList\n 59: dup\n 60: invokespecial #66 // Method java/util/ArrayList.\"<init>\":()V\n 63: astore 6\n 65: aload 4\n 67: invokeinterface #70, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 72: astore 7\n 74: aload 7\n 76: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 81: ifeq 137\n 84: aload 7\n 86: invokeinterface #79, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 91: astore 8\n 93: aload 8\n 95: checkcast #81 // class java/lang/String\n 98: astore 9\n 100: iconst_0\n 101: istore 10\n 103: aload 9\n 105: checkcast #83 // class java/lang/CharSequence\n 108: invokestatic #89 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 111: ifne 118\n 114: iconst_1\n 115: goto 119\n 118: iconst_0\n 119: nop\n 120: ifne 126\n 123: goto 137\n 126: aload 6\n 128: aload 8\n 130: invokevirtual #93 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 133: pop\n 134: goto 74\n 137: aload 6\n 139: checkcast #95 // class java/util/List\n 142: checkcast #61 // class java/lang/Iterable\n 145: iconst_1\n 146: invokestatic #101 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 149: astore_3\n 150: aload_0\n 151: getfield #14 // Field $input:Ljava/util/List;\n 154: checkcast #61 // class java/lang/Iterable\n 157: astore 5\n 159: iconst_0\n 160: istore 6\n 162: iconst_0\n 163: istore 7\n 165: new #63 // class java/util/ArrayList\n 168: dup\n 169: invokespecial #66 // Method java/util/ArrayList.\"<init>\":()V\n 172: astore 8\n 174: aload 5\n 176: invokeinterface #70, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 181: astore 9\n 183: aload 9\n 185: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 190: ifeq 262\n 193: aload 9\n 195: invokeinterface #79, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 200: astore 10\n 202: iload 7\n 204: ifeq 218\n 207: aload 8\n 209: aload 10\n 211: invokevirtual #93 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 214: pop\n 215: goto 183\n 218: aload 10\n 220: checkcast #81 // class java/lang/String\n 223: astore 11\n 225: iconst_0\n 226: istore 12\n 228: aload 11\n 230: checkcast #83 // class java/lang/CharSequence\n 233: invokestatic #89 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 236: ifne 243\n 239: iconst_1\n 240: goto 244\n 243: iconst_0\n 244: nop\n 245: ifne 183\n 248: aload 8\n 250: aload 10\n 252: invokevirtual #93 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 255: pop\n 256: iconst_1\n 257: istore 7\n 259: goto 183\n 262: aload 8\n 264: checkcast #95 // class java/util/List\n 267: checkcast #61 // class java/lang/Iterable\n 270: iconst_1\n 271: invokestatic #101 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 274: astore 4\n 276: aload_3\n 277: checkcast #103 // class java/util/Collection\n 280: invokeinterface #106, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 285: ifne 292\n 288: iconst_1\n 289: goto 293\n 292: iconst_0\n 293: ifeq 652\n 296: aload_2\n 297: aload_3\n 298: aload_0\n 299: checkcast #108 // class kotlin/coroutines/Continuation\n 302: aload_0\n 303: aload_2\n 304: putfield #57 // Field L$0:Ljava/lang/Object;\n 307: aload_0\n 308: aload 4\n 310: putfield #110 // Field L$1:Ljava/lang/Object;\n 313: aload_0\n 314: iconst_1\n 315: putfield #49 // Field label:I\n 318: invokevirtual #114 // Method kotlin/sequences/SequenceScope.yield:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;\n 321: dup\n 322: aload 13\n 324: if_acmpne 352\n 327: aload 13\n 329: areturn\n 330: aload_0\n 331: getfield #110 // Field L$1:Ljava/lang/Object;\n 334: checkcast #95 // class java/util/List\n 337: astore 4\n 339: aload_0\n 340: getfield #57 // Field L$0:Ljava/lang/Object;\n 343: checkcast #59 // class kotlin/sequences/SequenceScope\n 346: astore_2\n 347: aload_1\n 348: invokestatic #55 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V\n 351: aload_1\n 352: pop\n 353: aload 4\n 355: checkcast #61 // class java/lang/Iterable\n 358: astore 5\n 360: iconst_0\n 361: istore 6\n 363: new #63 // class java/util/ArrayList\n 366: dup\n 367: invokespecial #66 // Method java/util/ArrayList.\"<init>\":()V\n 370: astore 7\n 372: aload 5\n 374: invokeinterface #70, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 379: astore 8\n 381: aload 8\n 383: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 388: ifeq 444\n 391: aload 8\n 393: invokeinterface #79, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 398: astore 9\n 400: aload 9\n 402: checkcast #81 // class java/lang/String\n 405: astore 10\n 407: iconst_0\n 408: istore 11\n 410: aload 10\n 412: checkcast #83 // class java/lang/CharSequence\n 415: invokestatic #89 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 418: ifne 425\n 421: iconst_1\n 422: goto 426\n 425: iconst_0\n 426: nop\n 427: ifne 433\n 430: goto 444\n 433: aload 7\n 435: aload 9\n 437: invokevirtual #93 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 440: pop\n 441: goto 381\n 444: aload 7\n 446: checkcast #95 // class java/util/List\n 449: astore 6\n 451: iconst_0\n 452: istore 7\n 454: aload 6\n 456: checkcast #103 // class java/util/Collection\n 459: invokeinterface #106, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 464: ifne 471\n 467: iconst_1\n 468: goto 472\n 471: iconst_0\n 472: ifeq 487\n 475: aload 6\n 477: checkcast #61 // class java/lang/Iterable\n 480: iconst_1\n 481: invokestatic #101 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 484: goto 489\n 487: aload 6\n 489: nop\n 490: astore_3\n 491: aload 4\n 493: checkcast #61 // class java/lang/Iterable\n 496: astore 5\n 498: iconst_0\n 499: istore 6\n 501: iconst_0\n 502: istore 7\n 504: new #63 // class java/util/ArrayList\n 507: dup\n 508: invokespecial #66 // Method java/util/ArrayList.\"<init>\":()V\n 511: astore 8\n 513: aload 5\n 515: invokeinterface #70, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 520: astore 9\n 522: aload 9\n 524: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 529: ifeq 601\n 532: aload 9\n 534: invokeinterface #79, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 539: astore 10\n 541: iload 7\n 543: ifeq 557\n 546: aload 8\n 548: aload 10\n 550: invokevirtual #93 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 553: pop\n 554: goto 522\n 557: aload 10\n 559: checkcast #81 // class java/lang/String\n 562: astore 11\n 564: iconst_0\n 565: istore 12\n 567: aload 11\n 569: checkcast #83 // class java/lang/CharSequence\n 572: invokestatic #89 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 575: ifne 582\n 578: iconst_1\n 579: goto 583\n 582: iconst_0\n 583: nop\n 584: ifne 522\n 587: aload 8\n 589: aload 10\n 591: invokevirtual #93 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 594: pop\n 595: iconst_1\n 596: istore 7\n 598: goto 522\n 601: aload 8\n 603: checkcast #95 // class java/util/List\n 606: astore 6\n 608: iconst_0\n 609: istore 7\n 611: aload 6\n 613: checkcast #103 // class java/util/Collection\n 616: invokeinterface #106, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 621: ifne 628\n 624: iconst_1\n 625: goto 629\n 628: iconst_0\n 629: ifeq 644\n 632: aload 6\n 634: checkcast #61 // class java/lang/Iterable\n 637: iconst_1\n 638: invokestatic #101 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 641: goto 646\n 644: aload 6\n 646: nop\n 647: astore 4\n 649: goto 276\n 652: getstatic #120 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 655: areturn\n 656: new #122 // class java/lang/IllegalStateException\n 659: dup\n 660: ldc #124 // String call to \\'resume\\' before \\'invoke\\' with coroutine\n 662: invokespecial #127 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 665: athrow\n\n public final kotlin.coroutines.Continuation<kotlin.Unit> create(java.lang.Object, kotlin.coroutines.Continuation<?>);\n Code:\n 0: new #2 // class Day11Kt$main$iterateInput$1\n 3: dup\n 4: aload_0\n 5: getfield #14 // Field $input:Ljava/util/List;\n 8: aload_2\n 9: invokespecial #155 // Method \"<init>\":(Ljava/util/List;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 #108 // class kotlin/coroutines/Continuation\n 22: areturn\n\n public final java.lang.Object invoke(kotlin.sequences.SequenceScope<? super java.util.List<java.lang.String>>, kotlin.coroutines.Continuation<? super kotlin.Unit>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: aload_2\n 3: invokevirtual #161 // Method create:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Lkotlin/coroutines/Continuation;\n 6: checkcast #2 // class Day11Kt$main$iterateInput$1\n 9: getstatic #120 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 12: invokevirtual #163 // 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 #108 // class kotlin/coroutines/Continuation\n 9: invokevirtual #168 // Method invoke:(Lkotlin/sequences/SequenceScope;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;\n 12: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "jacobprudhomme__advent-of-code-2022__9c2b080/Day11Kt.class",
"javap": "Compiled from \"Day11.kt\"\npublic final class Day11Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String input\n 2: invokestatic #12 // Method main$readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #16 // Method main$part1:(Ljava/util/List;)Ljava/math/BigInteger;\n 10: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 13: swap\n 14: invokevirtual #28 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 17: aload_0\n 18: invokestatic #31 // Method main$part2:(Ljava/util/List;)Ljava/math/BigInteger;\n 21: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 24: swap\n 25: invokevirtual #28 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 28: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #35 // Method main:()V\n 3: return\n\n private static final java.util.List<java.lang.String> main$readInput(java.lang.String);\n Code:\n 0: new #40 // class java/io/File\n 3: dup\n 4: ldc #42 // String src/day11\n 6: aload_0\n 7: invokespecial #46 // Method java/io/File.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 10: aconst_null\n 11: iconst_1\n 12: aconst_null\n 13: invokestatic #52 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 16: areturn\n\n private static final kotlin.sequences.Sequence<java.util.List<java.lang.String>> main$iterateInput(java.util.List<java.lang.String>);\n Code:\n 0: new #59 // class Day11Kt$main$iterateInput$1\n 3: dup\n 4: aload_0\n 5: aconst_null\n 6: invokespecial #62 // Method Day11Kt$main$iterateInput$1.\"<init>\":(Ljava/util/List;Lkotlin/coroutines/Continuation;)V\n 9: checkcast #64 // class kotlin/jvm/functions/Function2\n 12: invokestatic #70 // Method kotlin/sequences/SequencesKt.sequence:(Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;\n 15: areturn\n\n private static final java.math.BigInteger main$processOperation$lambda$0(java.math.BigInteger, java.math.BigInteger);\n Code:\n 0: aload_0\n 1: ldc #74 // String m\n 3: invokestatic #80 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #82 // String n\n 9: invokestatic #80 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: aload_1\n 14: invokevirtual #88 // Method java/math/BigInteger.add:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 17: dup\n 18: ldc #90 // String add(...)\n 20: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 23: areturn\n\n private static final java.math.BigInteger main$processOperation$lambda$1(java.math.BigInteger, java.math.BigInteger);\n Code:\n 0: aload_0\n 1: ldc #74 // String m\n 3: invokestatic #80 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #82 // String n\n 9: invokestatic #80 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: aload_1\n 14: invokevirtual #98 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 17: dup\n 18: ldc #100 // String multiply(...)\n 20: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 23: areturn\n\n private static final java.math.BigInteger main$processOperation$lambda$2(kotlin.jvm.functions.Function2, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: i2l\n 3: invokestatic #106 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 6: dup\n 7: ldc #108 // String valueOf(...)\n 9: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: iload_1\n 13: i2l\n 14: invokestatic #106 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 17: dup\n 18: ldc #108 // String valueOf(...)\n 20: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 23: invokeinterface #112, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 28: checkcast #84 // class java/math/BigInteger\n 31: areturn\n\n private static final java.math.BigInteger main$processOperation$lambda$3(kotlin.jvm.functions.Function2, java.lang.String, int);\n Code:\n 0: aload_0\n 1: iload_2\n 2: i2l\n 3: invokestatic #106 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 6: dup\n 7: ldc #108 // String valueOf(...)\n 9: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #84 // class java/math/BigInteger\n 15: dup\n 16: aload_1\n 17: invokespecial #120 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;)V\n 20: invokeinterface #112, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 25: checkcast #84 // class java/math/BigInteger\n 28: areturn\n\n private static final java.math.BigInteger main$processOperation$lambda$4(kotlin.jvm.functions.Function2, java.lang.String, int);\n Code:\n 0: aload_0\n 1: new #84 // class java/math/BigInteger\n 4: dup\n 5: aload_1\n 6: invokespecial #120 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;)V\n 9: iload_2\n 10: i2l\n 11: invokestatic #106 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 14: dup\n 15: ldc #108 // String valueOf(...)\n 17: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 20: invokeinterface #112, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 25: checkcast #84 // class java/math/BigInteger\n 28: areturn\n\n private static final java.math.BigInteger main$processOperation$lambda$5(kotlin.jvm.functions.Function2, java.lang.String, java.lang.String, int);\n Code:\n 0: aload_0\n 1: new #84 // class java/math/BigInteger\n 4: dup\n 5: aload_1\n 6: invokespecial #120 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;)V\n 9: new #84 // class java/math/BigInteger\n 12: dup\n 13: aload_2\n 14: invokespecial #120 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;)V\n 17: invokeinterface #112, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 22: checkcast #84 // class java/math/BigInteger\n 25: areturn\n\n private static final kotlin.jvm.functions.Function1<java.lang.Integer, java.math.BigInteger> main$processOperation(java.lang.String, java.lang.String, java.lang.String);\n Code:\n 0: aload_0\n 1: astore 4\n 3: aload 4\n 5: ldc #130 // String +\n 7: invokestatic #134 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 10: ifeq 21\n 13: invokedynamic #149, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;\n 18: goto 49\n 21: aload 4\n 23: ldc #151 // String *\n 25: invokestatic #134 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 28: ifeq 39\n 31: invokedynamic #155, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function2;\n 36: goto 49\n 39: new #157 // class java/lang/IllegalArgumentException\n 42: dup\n 43: ldc #159 // String We should never get here\n 45: invokespecial #160 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 48: athrow\n 49: astore_3\n 50: aload_1\n 51: ldc #162 // String old\n 53: invokestatic #134 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 56: aload_2\n 57: ldc #162 // String old\n 59: invokestatic #134 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 62: iand\n 63: ifeq 75\n 66: aload_3\n 67: invokedynamic #172, 0 // InvokeDynamic #2:invoke:(Lkotlin/jvm/functions/Function2;)Lkotlin/jvm/functions/Function1;\n 72: goto 121\n 75: aload_1\n 76: ldc #162 // String old\n 78: invokestatic #134 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 81: ifeq 94\n 84: aload_3\n 85: aload_2\n 86: invokedynamic #178, 0 // InvokeDynamic #3:invoke:(Lkotlin/jvm/functions/Function2;Ljava/lang/String;)Lkotlin/jvm/functions/Function1;\n 91: goto 121\n 94: aload_2\n 95: ldc #162 // String old\n 97: invokestatic #134 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 100: ifeq 113\n 103: aload_3\n 104: aload_1\n 105: invokedynamic #182, 0 // InvokeDynamic #4:invoke:(Lkotlin/jvm/functions/Function2;Ljava/lang/String;)Lkotlin/jvm/functions/Function1;\n 110: goto 121\n 113: aload_3\n 114: aload_1\n 115: aload_2\n 116: invokedynamic #188, 0 // InvokeDynamic #5:invoke:(Lkotlin/jvm/functions/Function2;Ljava/lang/String;Ljava/lang/String;)Lkotlin/jvm/functions/Function1;\n 121: areturn\n\n private static final int main$gcd(int, int);\n Code:\n 0: iload_0\n 1: istore_2\n 2: iload_1\n 3: istore_3\n 4: iload_3\n 5: ifle 21\n 8: iload_3\n 9: istore 4\n 11: iload_2\n 12: iload_3\n 13: irem\n 14: istore_3\n 15: iload 4\n 17: istore_2\n 18: goto 4\n 21: iload_2\n 22: ireturn\n\n private static final int main$lcm(int, int);\n Code:\n 0: iload_0\n 1: iload_1\n 2: imul\n 3: iload_0\n 4: iload_1\n 5: invokestatic #204 // Method main$gcd:(II)I\n 8: idiv\n 9: ireturn\n\n private static final int main$processInput$lambda$6(int, int, int, int);\n Code:\n 0: iload_3\n 1: iload_0\n 2: irem\n 3: ifne 10\n 6: iload_1\n 7: goto 11\n 10: iload_2\n 11: ireturn\n\n private static final kotlin.Pair<Monkey[], java.lang.Integer> main$processInput(java.util.List<java.lang.String>);\n Code:\n 0: new #214 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #216 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #218 // class java/util/List\n 10: astore_1\n 11: new #214 // class java/util/ArrayList\n 14: dup\n 15: invokespecial #216 // Method java/util/ArrayList.\"<init>\":()V\n 18: checkcast #218 // class java/util/List\n 21: astore_2\n 22: aload_0\n 23: invokestatic #220 // Method main$iterateInput:(Ljava/util/List;)Lkotlin/sequences/Sequence;\n 26: invokeinterface #226, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 31: astore_3\n 32: aload_3\n 33: invokeinterface #232, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 38: ifeq 438\n 41: aload_3\n 42: invokeinterface #236, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 47: checkcast #218 // class java/util/List\n 50: astore 4\n 52: aload 4\n 54: iconst_0\n 55: invokeinterface #240, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 60: checkcast #194 // class java/lang/String\n 63: bipush 18\n 65: invokevirtual #244 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 68: dup\n 69: ldc #246 // String substring(...)\n 71: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 74: checkcast #248 // class java/lang/CharSequence\n 77: iconst_1\n 78: anewarray #194 // class java/lang/String\n 81: astore 6\n 83: aload 6\n 85: iconst_0\n 86: ldc #250 // String ,\n 88: aastore\n 89: aload 6\n 91: iconst_0\n 92: iconst_0\n 93: bipush 6\n 95: aconst_null\n 96: invokestatic #256 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 99: checkcast #258 // class java/lang/Iterable\n 102: astore 6\n 104: iconst_0\n 105: istore 7\n 107: aload 6\n 109: astore 8\n 111: new #214 // class java/util/ArrayList\n 114: dup\n 115: aload 6\n 117: bipush 10\n 119: invokestatic #264 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 122: invokespecial #267 // Method java/util/ArrayList.\"<init>\":(I)V\n 125: checkcast #269 // class java/util/Collection\n 128: astore 9\n 130: iconst_0\n 131: istore 10\n 133: aload 8\n 135: invokeinterface #270, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 140: astore 11\n 142: aload 11\n 144: invokeinterface #232, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 149: ifeq 196\n 152: aload 11\n 154: invokeinterface #236, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 159: astore 12\n 161: aload 9\n 163: aload 12\n 165: checkcast #194 // class java/lang/String\n 168: astore 13\n 170: astore 15\n 172: iconst_0\n 173: istore 14\n 175: aload 13\n 177: invokestatic #276 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 180: nop\n 181: invokestatic #279 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 184: aload 15\n 186: swap\n 187: invokeinterface #282, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 192: pop\n 193: goto 142\n 196: aload 9\n 198: checkcast #218 // class java/util/List\n 201: nop\n 202: astore 5\n 204: aload 4\n 206: iconst_1\n 207: invokeinterface #240, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 212: checkcast #194 // class java/lang/String\n 215: bipush 19\n 217: invokevirtual #244 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 220: dup\n 221: ldc #246 // String substring(...)\n 223: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 226: checkcast #248 // class java/lang/CharSequence\n 229: iconst_1\n 230: anewarray #194 // class java/lang/String\n 233: astore 7\n 235: aload 7\n 237: iconst_0\n 238: ldc_w #284 // String\n 241: aastore\n 242: aload 7\n 244: iconst_0\n 245: iconst_0\n 246: bipush 6\n 248: aconst_null\n 249: invokestatic #256 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 252: astore 6\n 254: aload 6\n 256: iconst_0\n 257: invokeinterface #240, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 262: checkcast #194 // class java/lang/String\n 265: astore 7\n 267: aload 6\n 269: iconst_1\n 270: invokeinterface #240, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 275: checkcast #194 // class java/lang/String\n 278: astore 8\n 280: aload 6\n 282: iconst_2\n 283: invokeinterface #240, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 288: checkcast #194 // class java/lang/String\n 291: astore 9\n 293: nop\n 294: aload 4\n 296: iconst_2\n 297: invokeinterface #240, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 302: checkcast #194 // class java/lang/String\n 305: bipush 21\n 307: invokevirtual #244 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 310: dup\n 311: ldc #246 // String substring(...)\n 313: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 316: invokestatic #276 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 319: istore 10\n 321: nop\n 322: aload 4\n 324: iconst_3\n 325: invokeinterface #240, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 330: checkcast #194 // class java/lang/String\n 333: bipush 29\n 335: invokevirtual #244 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 338: dup\n 339: ldc #246 // String substring(...)\n 341: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 344: invokestatic #276 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 347: istore 11\n 349: nop\n 350: aload 4\n 352: iconst_4\n 353: invokeinterface #240, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 358: checkcast #194 // class java/lang/String\n 361: bipush 30\n 363: invokevirtual #244 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 366: dup\n 367: ldc #246 // String substring(...)\n 369: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 372: invokestatic #276 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 375: istore 12\n 377: new #286 // class Monkey\n 380: dup\n 381: aload 5\n 383: checkcast #269 // class java/util/Collection\n 386: invokestatic #290 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 389: aload 8\n 391: aload 7\n 393: aload 9\n 395: invokestatic #292 // Method main$processOperation:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lkotlin/jvm/functions/Function1;\n 398: iload 10\n 400: iload 11\n 402: iload 12\n 404: invokedynamic #300, 0 // InvokeDynamic #6:invoke:(III)Lkotlin/jvm/functions/Function1;\n 409: invokespecial #303 // Method Monkey.\"<init>\":(Ljava/util/List;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V\n 412: astore 13\n 414: aload_1\n 415: aload 13\n 417: invokeinterface #304, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 422: pop\n 423: aload_2\n 424: iload 10\n 426: invokestatic #279 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 429: invokeinterface #304, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 434: pop\n 435: goto 32\n 438: aload_1\n 439: checkcast #269 // class java/util/Collection\n 442: astore_3\n 443: iconst_0\n 444: istore 4\n 446: aload_3\n 447: astore 5\n 449: aload 5\n 451: iconst_0\n 452: anewarray #286 // class Monkey\n 455: invokeinterface #308, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 460: aload_2\n 461: checkcast #258 // class java/lang/Iterable\n 464: astore_3\n 465: astore 16\n 467: iconst_0\n 468: istore 4\n 470: aload_3\n 471: invokeinterface #270, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 476: astore 5\n 478: aload 5\n 480: invokeinterface #232, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 485: ifne 499\n 488: new #310 // class java/lang/UnsupportedOperationException\n 491: dup\n 492: ldc_w #312 // String Empty collection can\\'t be reduced.\n 495: invokespecial #313 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 498: athrow\n 499: aload 5\n 501: invokeinterface #236, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 506: astore 6\n 508: aload 5\n 510: invokeinterface #232, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 515: ifeq 561\n 518: aload 6\n 520: aload 5\n 522: invokeinterface #236, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 527: checkcast #315 // class java/lang/Number\n 530: invokevirtual #319 // Method java/lang/Number.intValue:()I\n 533: istore 7\n 535: checkcast #315 // class java/lang/Number\n 538: invokevirtual #319 // Method java/lang/Number.intValue:()I\n 541: istore 8\n 543: iconst_0\n 544: istore 9\n 546: iload 8\n 548: iload 7\n 550: invokestatic #321 // Method main$lcm:(II)I\n 553: invokestatic #279 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 556: astore 6\n 558: goto 508\n 561: aload 6\n 563: aload 16\n 565: swap\n 566: astore 17\n 568: astore 18\n 570: new #323 // class kotlin/Pair\n 573: dup\n 574: aload 18\n 576: aload 17\n 578: invokespecial #326 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 581: areturn\n\n private static final void main$doRound(Monkey[], boolean, int);\n Code:\n 0: iconst_0\n 1: istore_3\n 2: aload_0\n 3: arraylength\n 4: istore 4\n 6: iload_3\n 7: iload 4\n 9: if_icmpge 205\n 12: aload_0\n 13: iload_3\n 14: aaload\n 15: astore 5\n 17: aload 5\n 19: invokevirtual #366 // Method Monkey.getHeldItems:()Ljava/util/List;\n 22: checkcast #269 // class java/util/Collection\n 25: invokeinterface #369, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 30: ifne 37\n 33: iconst_1\n 34: goto 38\n 37: iconst_0\n 38: ifeq 199\n 41: aload 5\n 43: invokevirtual #366 // Method Monkey.getHeldItems:()Ljava/util/List;\n 46: invokeinterface #372, 1 // InterfaceMethod java/util/List.removeFirst:()Ljava/lang/Object;\n 51: dup\n 52: ldc_w #374 // String removeFirst(...)\n 55: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 58: checkcast #315 // class java/lang/Number\n 61: invokevirtual #319 // Method java/lang/Number.intValue:()I\n 64: istore 6\n 66: aload 5\n 68: invokevirtual #377 // Method Monkey.inspect:()V\n 71: aload 5\n 73: invokevirtual #381 // Method Monkey.getApplyOperation:()Lkotlin/jvm/functions/Function1;\n 76: iload 6\n 78: invokestatic #279 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 81: invokeinterface #383, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 86: checkcast #84 // class java/math/BigInteger\n 89: astore 9\n 91: iconst_0\n 92: istore 10\n 94: iload_1\n 95: ifeq 124\n 98: aload 9\n 100: iload_2\n 101: i2l\n 102: invokestatic #106 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 105: dup\n 106: ldc #108 // String valueOf(...)\n 108: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 111: invokevirtual #386 // Method java/math/BigInteger.remainder:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 114: dup\n 115: ldc_w #388 // String remainder(...)\n 118: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 121: goto 148\n 124: nop\n 125: aload 9\n 127: iconst_3\n 128: i2l\n 129: invokestatic #106 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 132: dup\n 133: ldc #108 // String valueOf(...)\n 135: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 138: invokevirtual #391 // Method java/math/BigInteger.divide:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 141: dup\n 142: ldc_w #393 // String divide(...)\n 145: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 148: nop\n 149: nop\n 150: invokevirtual #394 // Method java/math/BigInteger.intValue:()I\n 153: istore 7\n 155: aload 5\n 157: invokevirtual #397 // Method Monkey.getDecide:()Lkotlin/jvm/functions/Function1;\n 160: iload 7\n 162: invokestatic #279 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 165: invokeinterface #383, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 170: checkcast #315 // class java/lang/Number\n 173: invokevirtual #319 // Method java/lang/Number.intValue:()I\n 176: istore 8\n 178: aload_0\n 179: iload 8\n 181: aaload\n 182: invokevirtual #366 // Method Monkey.getHeldItems:()Ljava/util/List;\n 185: iload 7\n 187: invokestatic #279 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 190: invokeinterface #304, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 195: pop\n 196: goto 17\n 199: iinc 3, 1\n 202: goto 6\n 205: return\n\n static void main$doRound$default(Monkey[], boolean, int, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_2\n 2: iand\n 3: ifeq 8\n 6: iconst_0\n 7: istore_1\n 8: iload_3\n 9: iconst_4\n 10: iand\n 11: ifeq 16\n 14: iconst_1\n 15: istore_2\n 16: aload_0\n 17: iload_1\n 18: iload_2\n 19: invokestatic #411 // Method main$doRound:([LMonkey;ZI)V\n 22: return\n\n private static final java.math.BigInteger main$multiplyTwoLargest(Monkey[]);\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: new #214 // class java/util/ArrayList\n 10: dup\n 11: aload_2\n 12: arraylength\n 13: invokespecial #267 // Method java/util/ArrayList.\"<init>\":(I)V\n 16: checkcast #269 // class java/util/Collection\n 19: astore 5\n 21: iconst_0\n 22: istore 6\n 24: iconst_0\n 25: istore 7\n 27: aload 4\n 29: arraylength\n 30: istore 8\n 32: iload 7\n 34: iload 8\n 36: if_icmpge 88\n 39: aload 4\n 41: iload 7\n 43: aaload\n 44: astore 9\n 46: aload 5\n 48: aload 9\n 50: astore 10\n 52: astore 12\n 54: iconst_0\n 55: istore 11\n 57: aload 10\n 59: invokevirtual #417 // Method Monkey.getInspectedItems:()Ljava/math/BigInteger;\n 62: invokevirtual #420 // Method java/math/BigInteger.negate:()Ljava/math/BigInteger;\n 65: dup\n 66: ldc_w #422 // String negate(...)\n 69: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 72: nop\n 73: aload 12\n 75: swap\n 76: invokeinterface #282, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 81: pop\n 82: iinc 7, 1\n 85: goto 32\n 88: aload 5\n 90: checkcast #218 // class java/util/List\n 93: nop\n 94: checkcast #269 // class java/util/Collection\n 97: astore 13\n 99: new #424 // class java/util/PriorityQueue\n 102: dup\n 103: aload 13\n 105: invokespecial #427 // Method java/util/PriorityQueue.\"<init>\":(Ljava/util/Collection;)V\n 108: astore_1\n 109: aload_1\n 110: invokevirtual #430 // Method java/util/PriorityQueue.poll:()Ljava/lang/Object;\n 113: dup\n 114: ldc_w #432 // String poll(...)\n 117: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 120: checkcast #84 // class java/math/BigInteger\n 123: astore_2\n 124: aload_1\n 125: invokevirtual #430 // Method java/util/PriorityQueue.poll:()Ljava/lang/Object;\n 128: dup\n 129: ldc_w #432 // String poll(...)\n 132: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 135: checkcast #84 // class java/math/BigInteger\n 138: aload_2\n 139: swap\n 140: invokevirtual #98 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 143: dup\n 144: ldc #100 // String multiply(...)\n 146: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 149: areturn\n\n private static final java.math.BigInteger main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #438 // Method main$processInput:(Ljava/util/List;)Lkotlin/Pair;\n 4: invokevirtual #441 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 7: checkcast #407 // class \"[LMonkey;\"\n 10: astore_1\n 11: bipush 20\n 13: istore_2\n 14: iconst_0\n 15: istore_3\n 16: iload_3\n 17: iload_2\n 18: if_icmpge 43\n 21: iload_3\n 22: istore 4\n 24: iconst_0\n 25: istore 5\n 27: aload_1\n 28: iconst_0\n 29: iconst_0\n 30: bipush 6\n 32: aconst_null\n 33: invokestatic #443 // Method main$doRound$default:([LMonkey;ZIILjava/lang/Object;)V\n 36: nop\n 37: iinc 3, 1\n 40: goto 16\n 43: aload_1\n 44: invokestatic #445 // Method main$multiplyTwoLargest:([LMonkey;)Ljava/math/BigInteger;\n 47: areturn\n\n private static final java.math.BigInteger main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #438 // Method main$processInput:(Ljava/util/List;)Lkotlin/Pair;\n 4: astore_1\n 5: aload_1\n 6: invokevirtual #441 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 9: checkcast #407 // class \"[LMonkey;\"\n 12: astore_2\n 13: aload_1\n 14: invokevirtual #449 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 17: checkcast #315 // class java/lang/Number\n 20: invokevirtual #319 // Method java/lang/Number.intValue:()I\n 23: istore_3\n 24: sipush 10000\n 27: istore 4\n 29: iconst_0\n 30: istore 5\n 32: iload 5\n 34: iload 4\n 36: if_icmpge 59\n 39: iload 5\n 41: istore 6\n 43: iconst_0\n 44: istore 7\n 46: aload_2\n 47: iconst_1\n 48: iload_3\n 49: invokestatic #411 // Method main$doRound:([LMonkey;ZI)V\n 52: nop\n 53: iinc 5, 1\n 56: goto 32\n 59: aload_2\n 60: invokestatic #445 // Method main$multiplyTwoLargest:([LMonkey;)Ljava/math/BigInteger;\n 63: areturn\n}\n",
"javap_err": ""
}
] |
jacobprudhomme__advent-of-code-2022__9c2b080/src/day03/Day03.kt
|
import java.io.File
fun main() {
fun readInput(name: String) = File("src/day03", name)
.readLines()
fun getItemPriority(item: Char): Int =
if (item.isLowerCase()) {
item.code - 96
} else {
item.code - 38
}
fun part1(input: List<String>): Int {
var sumOfPriorities = 0
for (line in input) {
val numItemsInFirstRucksack = line.length / 2
val itemsInFirstRucksack = line.take(numItemsInFirstRucksack).toSet()
val seenInSecondRucksack = mutableSetOf<Char>()
for (item in line.takeLast(numItemsInFirstRucksack)) {
if (itemsInFirstRucksack.contains(item) and !seenInSecondRucksack.contains(item)) {
sumOfPriorities += getItemPriority(item)
seenInSecondRucksack.add(item)
}
}
}
return sumOfPriorities
}
fun part2(input: List<String>): Int {
var sumOfPriorities = 0
var group = arrayListOf<Set<Char>>()
for (line in input) {
group.add(line.toSet())
if (group.size == 3) {
val itemsCommonToAllRucksacks = group.reduce { acc, currRucksack -> acc.intersect(currRucksack) }
val item = itemsCommonToAllRucksacks.first()
sumOfPriorities += getItemPriority(item)
group = arrayListOf()
}
}
return sumOfPriorities
}
val input = readInput("input")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "jacobprudhomme__advent-of-code-2022__9c2b080/Day03Kt.class",
"javap": "Compiled from \"Day03.kt\"\npublic final class Day03Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String input\n 2: invokestatic #12 // Method main$readInput:(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: istore_1\n 11: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #28 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #31 // Method main$part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #28 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #35 // Method main:()V\n 3: return\n\n private static final java.util.List<java.lang.String> main$readInput(java.lang.String);\n Code:\n 0: new #40 // class java/io/File\n 3: dup\n 4: ldc #42 // String src/day03\n 6: aload_0\n 7: invokespecial #46 // Method java/io/File.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 10: aconst_null\n 11: iconst_1\n 12: aconst_null\n 13: invokestatic #52 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 16: areturn\n\n private static final int main$getItemPriority(char);\n Code:\n 0: iload_0\n 1: invokestatic #62 // Method java/lang/Character.isLowerCase:(C)Z\n 4: ifeq 14\n 7: iload_0\n 8: bipush 96\n 10: isub\n 11: goto 18\n 14: iload_0\n 15: bipush 38\n 17: isub\n 18: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: aload_0\n 3: invokeinterface #71, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 8: astore_2\n 9: aload_2\n 10: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 15: ifeq 159\n 18: aload_2\n 19: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 24: checkcast #83 // class java/lang/String\n 27: astore_3\n 28: aload_3\n 29: invokevirtual #87 // Method java/lang/String.length:()I\n 32: iconst_2\n 33: idiv\n 34: istore 4\n 36: aload_3\n 37: iload 4\n 39: invokestatic #93 // Method kotlin/text/StringsKt.take:(Ljava/lang/String;I)Ljava/lang/String;\n 42: checkcast #95 // class java/lang/CharSequence\n 45: invokestatic #99 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 48: astore 5\n 50: new #101 // class java/util/LinkedHashSet\n 53: dup\n 54: invokespecial #103 // Method java/util/LinkedHashSet.\"<init>\":()V\n 57: checkcast #105 // class java/util/Set\n 60: astore 6\n 62: aload_3\n 63: iload 4\n 65: invokestatic #108 // Method kotlin/text/StringsKt.takeLast:(Ljava/lang/String;I)Ljava/lang/String;\n 68: astore 7\n 70: iconst_0\n 71: istore 8\n 73: aload 7\n 75: invokevirtual #87 // Method java/lang/String.length:()I\n 78: istore 9\n 80: iload 8\n 82: iload 9\n 84: if_icmpge 9\n 87: aload 7\n 89: iload 8\n 91: invokevirtual #112 // Method java/lang/String.charAt:(I)C\n 94: istore 10\n 96: aload 5\n 98: iload 10\n 100: invokestatic #116 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 103: invokeinterface #120, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 108: aload 6\n 110: iload 10\n 112: invokestatic #116 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 115: invokeinterface #120, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 120: ifne 127\n 123: iconst_1\n 124: goto 128\n 127: iconst_0\n 128: iand\n 129: ifeq 153\n 132: iload_1\n 133: iload 10\n 135: invokestatic #122 // Method main$getItemPriority:(C)I\n 138: iadd\n 139: istore_1\n 140: aload 6\n 142: iload 10\n 144: invokestatic #116 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 147: invokeinterface #125, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 152: pop\n 153: iinc 8, 1\n 156: goto 80\n 159: iload_1\n 160: 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: new #134 // class java/util/ArrayList\n 5: dup\n 6: invokespecial #135 // Method java/util/ArrayList.\"<init>\":()V\n 9: astore_2\n 10: aload_0\n 11: invokeinterface #71, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 16: astore_3\n 17: aload_3\n 18: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 23: ifeq 197\n 26: aload_3\n 27: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 32: checkcast #83 // class java/lang/String\n 35: astore 4\n 37: aload_2\n 38: aload 4\n 40: checkcast #95 // class java/lang/CharSequence\n 43: invokestatic #99 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 46: invokevirtual #136 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 49: pop\n 50: aload_2\n 51: invokevirtual #139 // Method java/util/ArrayList.size:()I\n 54: iconst_3\n 55: if_icmpne 17\n 58: aload_2\n 59: checkcast #141 // class java/lang/Iterable\n 62: astore 6\n 64: iconst_0\n 65: istore 7\n 67: aload 6\n 69: invokeinterface #142, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 74: astore 8\n 76: aload 8\n 78: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 83: ifne 96\n 86: new #144 // class java/lang/UnsupportedOperationException\n 89: dup\n 90: ldc #146 // String Empty collection can\\'t be reduced.\n 92: invokespecial #149 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 95: athrow\n 96: aload 8\n 98: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 103: astore 9\n 105: aload 8\n 107: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 112: ifeq 155\n 115: aload 9\n 117: aload 8\n 119: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 124: checkcast #105 // class java/util/Set\n 127: astore 10\n 129: checkcast #105 // class java/util/Set\n 132: astore 11\n 134: iconst_0\n 135: istore 12\n 137: aload 11\n 139: checkcast #141 // class java/lang/Iterable\n 142: aload 10\n 144: checkcast #141 // class java/lang/Iterable\n 147: invokestatic #155 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 150: astore 9\n 152: goto 105\n 155: aload 9\n 157: checkcast #105 // class java/util/Set\n 160: astore 5\n 162: aload 5\n 164: checkcast #141 // class java/lang/Iterable\n 167: invokestatic #159 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 170: checkcast #58 // class java/lang/Character\n 173: invokevirtual #163 // Method java/lang/Character.charValue:()C\n 176: istore 6\n 178: iload_1\n 179: iload 6\n 181: invokestatic #122 // Method main$getItemPriority:(C)I\n 184: iadd\n 185: istore_1\n 186: new #134 // class java/util/ArrayList\n 189: dup\n 190: invokespecial #135 // Method java/util/ArrayList.\"<init>\":()V\n 193: astore_2\n 194: goto 17\n 197: iload_1\n 198: ireturn\n}\n",
"javap_err": ""
}
] |
jacobprudhomme__advent-of-code-2022__9c2b080/src/day09/Day09.kt
|
import java.io.File
import java.lang.IllegalArgumentException
import kotlin.math.abs
typealias Pos = Pair<Int, Int>
enum class Direction {
UP,
RIGHT,
DOWN,
LEFT,
}
fun main() {
fun readInput(name: String) = File("src/day09", name)
.readLines()
fun convertToDirection(dirStr: String): Direction =
when (dirStr) {
"U" -> Direction.UP
"R" -> Direction.RIGHT
"D" -> Direction.DOWN
"L" -> Direction.LEFT
else -> throw IllegalArgumentException("We should never get here")
}
fun moveHead(headPos: Pos, dir: Direction): Pos =
when (dir) {
Direction.UP -> headPos.let { (x, y) -> Pair(x, y+1) }
Direction.RIGHT -> headPos.let { (x, y) -> Pair(x+1, y) }
Direction.DOWN -> headPos.let { (x, y) -> Pair(x, y-1) }
Direction.LEFT -> headPos.let { (x, y) -> Pair(x-1, y) }
}
fun moveTail(headPos: Pos, tailPos: Pos): Pos {
val horizontalDist = abs(headPos.first - tailPos.first)
val verticalDist = abs(headPos.second - tailPos.second)
return if ((horizontalDist == 2) or (verticalDist == 2)) {
if (horizontalDist == 0) {
tailPos.let { (x, y) -> Pair(x, (y + headPos.second).div(2)) }
} else if (verticalDist == 0) {
tailPos.let { (x, y) -> Pair((x + headPos.first).div(2), y) }
} else if (horizontalDist == 1) {
tailPos.let { (_, y) -> Pair(headPos.first, (y + headPos.second).div(2)) }
} else if (verticalDist == 1) {
tailPos.let { (x, _) -> Pair((x + headPos.first).div(2), headPos.second) }
} else {
tailPos.let { (x, y) -> Pair((x + headPos.first).div(2), (y + headPos.second).div(2)) }
}
} else {
tailPos
}
}
fun move(headPos: Pos, tailPos: Pos, dir: Direction): Pair<Pos, Pos> {
val nextHeadPos = moveHead(headPos, dir)
val nextTailPos = moveTail(nextHeadPos, tailPos)
return Pair(nextHeadPos, nextTailPos)
}
fun part1(input: List<String>): Int {
var currHeadPosition = Pair(0, 0)
var currTailPosition = Pair(0, 0)
val seenPositions = mutableSetOf(currTailPosition)
for (line in input) {
val (dir, steps) = line.split(" ").let { (dirStr, stepsStr, _) ->
Pair(convertToDirection(dirStr), stepsStr.toInt())
}
repeat(steps) {
val (nextHeadPosition, nextTailPosition) = move(currHeadPosition, currTailPosition, dir)
currHeadPosition = nextHeadPosition
currTailPosition = nextTailPosition
seenPositions.add(currTailPosition)
}
}
return seenPositions.count()
}
fun part2(input: List<String>): Int {
val currPositions = MutableList(10) { Pair(0, 0) }
val seenPositions = mutableSetOf(currPositions.last())
for (line in input) {
val (dir, steps) = line.split(" ").let { (dirStr, stepsStr, _) ->
Pair(convertToDirection(dirStr), stepsStr.toInt())
}
repeat(steps) {
currPositions[0] = moveHead(currPositions[0], dir)
for (knotIndex in currPositions.indices.drop(1)) {
currPositions[knotIndex] = moveTail(currPositions[knotIndex-1], currPositions[knotIndex])
}
seenPositions.add(currPositions.last())
}
}
return seenPositions.count()
}
val input = readInput("input")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "jacobprudhomme__advent-of-code-2022__9c2b080/Day09Kt$WhenMappings.class",
"javap": "Compiled from \"Day09.kt\"\npublic final class Day09Kt$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method Direction.values:()[LDirection;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field Direction.UP:LDirection;\n 12: invokevirtual #22 // Method Direction.ordinal:()I\n 15: iconst_1\n 16: iastore\n 17: goto 21\n 20: astore_1\n 21: nop\n 22: aload_0\n 23: getstatic #25 // Field Direction.RIGHT:LDirection;\n 26: invokevirtual #22 // Method Direction.ordinal:()I\n 29: iconst_2\n 30: iastore\n 31: goto 35\n 34: astore_1\n 35: nop\n 36: aload_0\n 37: getstatic #28 // Field Direction.DOWN:LDirection;\n 40: invokevirtual #22 // Method Direction.ordinal:()I\n 43: iconst_3\n 44: iastore\n 45: goto 49\n 48: astore_1\n 49: nop\n 50: aload_0\n 51: getstatic #31 // Field Direction.LEFT:LDirection;\n 54: invokevirtual #22 // Method Direction.ordinal:()I\n 57: iconst_4\n 58: iastore\n 59: goto 63\n 62: astore_1\n 63: aload_0\n 64: putstatic #35 // Field $EnumSwitchMapping$0:[I\n 67: return\n Exception table:\n from to target type\n 7 17 20 Class java/lang/NoSuchFieldError\n 21 31 34 Class java/lang/NoSuchFieldError\n 35 45 48 Class java/lang/NoSuchFieldError\n 49 59 62 Class java/lang/NoSuchFieldError\n}\n",
"javap_err": ""
},
{
"class_path": "jacobprudhomme__advent-of-code-2022__9c2b080/Day09Kt.class",
"javap": "Compiled from \"Day09.kt\"\npublic final class Day09Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String input\n 2: invokestatic #12 // Method main$readInput:(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: istore_1\n 11: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #28 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #31 // Method main$part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #28 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #35 // Method main:()V\n 3: return\n\n private static final java.util.List<java.lang.String> main$readInput(java.lang.String);\n Code:\n 0: new #40 // class java/io/File\n 3: dup\n 4: ldc #42 // String src/day09\n 6: aload_0\n 7: invokespecial #46 // Method java/io/File.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 10: aconst_null\n 11: iconst_1\n 12: aconst_null\n 13: invokestatic #52 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 16: areturn\n\n private static final Direction main$convertToDirection(java.lang.String);\n Code:\n 0: aload_0\n 1: astore_1\n 2: aload_1\n 3: invokevirtual #62 // Method java/lang/String.hashCode:()I\n 6: lookupswitch { // 4\n 68: 60\n 76: 84\n 82: 48\n 85: 72\n default: 120\n }\n 48: aload_1\n 49: ldc #64 // String R\n 51: invokevirtual #68 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 54: ifne 102\n 57: goto 120\n 60: aload_1\n 61: ldc #70 // String D\n 63: invokevirtual #68 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 66: ifne 108\n 69: goto 120\n 72: aload_1\n 73: ldc #72 // String U\n 75: invokevirtual #68 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 78: ifne 96\n 81: goto 120\n 84: aload_1\n 85: ldc #74 // String L\n 87: invokevirtual #68 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 90: ifne 114\n 93: goto 120\n 96: getstatic #80 // Field Direction.UP:LDirection;\n 99: goto 130\n 102: getstatic #83 // Field Direction.RIGHT:LDirection;\n 105: goto 130\n 108: getstatic #86 // Field Direction.DOWN:LDirection;\n 111: goto 130\n 114: getstatic #89 // Field Direction.LEFT:LDirection;\n 117: goto 130\n 120: new #91 // class java/lang/IllegalArgumentException\n 123: dup\n 124: ldc #93 // String We should never get here\n 126: invokespecial #96 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 129: athrow\n 130: areturn\n\n private static final kotlin.Pair<java.lang.Integer, java.lang.Integer> main$moveHead(kotlin.Pair<java.lang.Integer, java.lang.Integer>, Direction);\n Code:\n 0: aload_1\n 1: getstatic #106 // Field Day09Kt$WhenMappings.$EnumSwitchMapping$0:[I\n 4: swap\n 5: invokevirtual #109 // Method Direction.ordinal:()I\n 8: iaload\n 9: tableswitch { // 1 to 4\n 1: 40\n 2: 90\n 3: 140\n 4: 190\n default: 240\n }\n 40: aload_0\n 41: astore_2\n 42: iconst_0\n 43: istore_3\n 44: aload_2\n 45: invokevirtual #115 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 48: checkcast #117 // class java/lang/Number\n 51: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 54: istore 4\n 56: aload_2\n 57: invokevirtual #123 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 60: checkcast #117 // class java/lang/Number\n 63: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 66: istore 5\n 68: new #111 // class kotlin/Pair\n 71: dup\n 72: iload 4\n 74: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 77: iload 5\n 79: iconst_1\n 80: iadd\n 81: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 84: invokespecial #132 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 87: goto 248\n 90: aload_0\n 91: astore_2\n 92: iconst_0\n 93: istore_3\n 94: aload_2\n 95: invokevirtual #115 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 98: checkcast #117 // class java/lang/Number\n 101: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 104: istore 4\n 106: aload_2\n 107: invokevirtual #123 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 110: checkcast #117 // class java/lang/Number\n 113: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 116: istore 5\n 118: new #111 // class kotlin/Pair\n 121: dup\n 122: iload 4\n 124: iconst_1\n 125: iadd\n 126: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 129: iload 5\n 131: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 134: invokespecial #132 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 137: goto 248\n 140: aload_0\n 141: astore_2\n 142: iconst_0\n 143: istore_3\n 144: aload_2\n 145: invokevirtual #115 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 148: checkcast #117 // class java/lang/Number\n 151: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 154: istore 4\n 156: aload_2\n 157: invokevirtual #123 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 160: checkcast #117 // class java/lang/Number\n 163: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 166: istore 5\n 168: new #111 // class kotlin/Pair\n 171: dup\n 172: iload 4\n 174: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 177: iload 5\n 179: iconst_1\n 180: isub\n 181: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 184: invokespecial #132 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 187: goto 248\n 190: aload_0\n 191: astore_2\n 192: iconst_0\n 193: istore_3\n 194: aload_2\n 195: invokevirtual #115 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 198: checkcast #117 // class java/lang/Number\n 201: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 204: istore 4\n 206: aload_2\n 207: invokevirtual #123 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 210: checkcast #117 // class java/lang/Number\n 213: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 216: istore 5\n 218: new #111 // class kotlin/Pair\n 221: dup\n 222: iload 4\n 224: iconst_1\n 225: isub\n 226: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 229: iload 5\n 231: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 234: invokespecial #132 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 237: goto 248\n 240: new #134 // class kotlin/NoWhenBranchMatchedException\n 243: dup\n 244: invokespecial #136 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 247: athrow\n 248: areturn\n\n private static final kotlin.Pair<java.lang.Integer, java.lang.Integer> main$moveTail(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 #152 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 4: checkcast #117 // class java/lang/Number\n 7: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 10: aload_1\n 11: invokevirtual #152 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 14: checkcast #117 // class java/lang/Number\n 17: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 20: isub\n 21: invokestatic #158 // Method java/lang/Math.abs:(I)I\n 24: istore_2\n 25: aload_0\n 26: invokevirtual #161 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 29: checkcast #117 // class java/lang/Number\n 32: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 35: aload_1\n 36: invokevirtual #161 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 39: checkcast #117 // class java/lang/Number\n 42: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 45: isub\n 46: invokestatic #158 // Method java/lang/Math.abs:(I)I\n 49: istore_3\n 50: iload_2\n 51: iconst_2\n 52: if_icmpne 59\n 55: iconst_1\n 56: goto 60\n 59: iconst_0\n 60: iload_3\n 61: iconst_2\n 62: if_icmpne 69\n 65: iconst_1\n 66: goto 70\n 69: iconst_0\n 70: ior\n 71: ifeq 402\n 74: iload_2\n 75: ifne 143\n 78: aload_1\n 79: astore 4\n 81: iconst_0\n 82: istore 5\n 84: aload 4\n 86: invokevirtual #115 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 89: checkcast #117 // class java/lang/Number\n 92: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 95: istore 6\n 97: aload 4\n 99: invokevirtual #123 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 102: checkcast #117 // class java/lang/Number\n 105: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 108: istore 7\n 110: new #111 // class kotlin/Pair\n 113: dup\n 114: iload 6\n 116: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 119: iload 7\n 121: aload_0\n 122: invokevirtual #161 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 125: checkcast #117 // class java/lang/Number\n 128: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 131: iadd\n 132: iconst_2\n 133: idiv\n 134: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 137: invokespecial #132 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 140: goto 403\n 143: iload_3\n 144: ifne 212\n 147: aload_1\n 148: astore 4\n 150: iconst_0\n 151: istore 5\n 153: aload 4\n 155: invokevirtual #115 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 158: checkcast #117 // class java/lang/Number\n 161: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 164: istore 6\n 166: aload 4\n 168: invokevirtual #123 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 171: checkcast #117 // class java/lang/Number\n 174: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 177: istore 7\n 179: new #111 // class kotlin/Pair\n 182: dup\n 183: iload 6\n 185: aload_0\n 186: invokevirtual #152 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 189: checkcast #117 // class java/lang/Number\n 192: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 195: iadd\n 196: iconst_2\n 197: idiv\n 198: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 201: iload 7\n 203: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 206: invokespecial #132 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 209: goto 403\n 212: iload_2\n 213: iconst_1\n 214: if_icmpne 268\n 217: aload_1\n 218: astore 4\n 220: iconst_0\n 221: istore 5\n 223: aload 4\n 225: invokevirtual #123 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 228: checkcast #117 // class java/lang/Number\n 231: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 234: istore 6\n 236: new #111 // class kotlin/Pair\n 239: dup\n 240: aload_0\n 241: invokevirtual #152 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 244: iload 6\n 246: aload_0\n 247: invokevirtual #161 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 250: checkcast #117 // class java/lang/Number\n 253: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 256: iadd\n 257: iconst_2\n 258: idiv\n 259: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 262: invokespecial #132 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 265: goto 403\n 268: iload_3\n 269: iconst_1\n 270: if_icmpne 324\n 273: aload_1\n 274: astore 4\n 276: iconst_0\n 277: istore 5\n 279: aload 4\n 281: invokevirtual #115 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 284: checkcast #117 // class java/lang/Number\n 287: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 290: istore 6\n 292: new #111 // class kotlin/Pair\n 295: dup\n 296: iload 6\n 298: aload_0\n 299: invokevirtual #152 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 302: checkcast #117 // class java/lang/Number\n 305: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 308: iadd\n 309: iconst_2\n 310: idiv\n 311: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 314: aload_0\n 315: invokevirtual #161 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 318: invokespecial #132 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 321: goto 403\n 324: aload_1\n 325: astore 4\n 327: iconst_0\n 328: istore 5\n 330: aload 4\n 332: invokevirtual #115 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 335: checkcast #117 // class java/lang/Number\n 338: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 341: istore 6\n 343: aload 4\n 345: invokevirtual #123 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 348: checkcast #117 // class java/lang/Number\n 351: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 354: istore 7\n 356: new #111 // class kotlin/Pair\n 359: dup\n 360: iload 6\n 362: aload_0\n 363: invokevirtual #152 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 366: checkcast #117 // class java/lang/Number\n 369: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 372: iadd\n 373: iconst_2\n 374: idiv\n 375: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 378: iload 7\n 380: aload_0\n 381: invokevirtual #161 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 384: checkcast #117 // class java/lang/Number\n 387: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 390: iadd\n 391: iconst_2\n 392: idiv\n 393: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 396: invokespecial #132 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 399: goto 403\n 402: aload_1\n 403: areturn\n\n private static final kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>> main$move(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>, Direction);\n Code:\n 0: aload_0\n 1: aload_2\n 2: invokestatic #174 // Method main$moveHead:(Lkotlin/Pair;LDirection;)Lkotlin/Pair;\n 5: astore_3\n 6: aload_3\n 7: aload_1\n 8: invokestatic #176 // Method main$moveTail:(Lkotlin/Pair;Lkotlin/Pair;)Lkotlin/Pair;\n 11: astore 4\n 13: new #111 // class kotlin/Pair\n 16: dup\n 17: aload_3\n 18: aload 4\n 20: invokespecial #132 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 23: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aconst_null\n 1: astore_1\n 2: new #111 // class kotlin/Pair\n 5: dup\n 6: iconst_0\n 7: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 10: iconst_0\n 11: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 14: invokespecial #132 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 17: astore_1\n 18: aconst_null\n 19: astore_2\n 20: new #111 // class kotlin/Pair\n 23: dup\n 24: iconst_0\n 25: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 28: iconst_0\n 29: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 32: invokespecial #132 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 35: astore_2\n 36: iconst_1\n 37: anewarray #111 // class kotlin/Pair\n 40: astore 4\n 42: aload 4\n 44: iconst_0\n 45: aload_2\n 46: aastore\n 47: aload 4\n 49: invokestatic #185 // Method kotlin/collections/SetsKt.mutableSetOf:([Ljava/lang/Object;)Ljava/util/Set;\n 52: astore_3\n 53: aload_0\n 54: invokeinterface #191, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 59: astore 4\n 61: aload 4\n 63: invokeinterface #197, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 68: ifeq 254\n 71: aload 4\n 73: invokeinterface #200, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 78: checkcast #58 // class java/lang/String\n 81: astore 5\n 83: aload 5\n 85: checkcast #202 // class java/lang/CharSequence\n 88: iconst_1\n 89: anewarray #58 // class java/lang/String\n 92: astore 7\n 94: aload 7\n 96: iconst_0\n 97: ldc #204 // String\n 99: aastore\n 100: aload 7\n 102: iconst_0\n 103: iconst_0\n 104: bipush 6\n 106: aconst_null\n 107: invokestatic #210 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 110: astore 8\n 112: iconst_0\n 113: istore 9\n 115: aload 8\n 117: iconst_0\n 118: invokeinterface #214, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 123: checkcast #58 // class java/lang/String\n 126: astore 10\n 128: aload 8\n 130: iconst_1\n 131: invokeinterface #214, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 136: checkcast #58 // class java/lang/String\n 139: astore 11\n 141: new #111 // class kotlin/Pair\n 144: dup\n 145: aload 10\n 147: invokestatic #216 // Method main$convertToDirection:(Ljava/lang/String;)LDirection;\n 150: aload 11\n 152: invokestatic #220 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 155: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 158: invokespecial #132 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 161: nop\n 162: astore 6\n 164: aload 6\n 166: invokevirtual #115 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 169: checkcast #76 // class Direction\n 172: astore 7\n 174: aload 6\n 176: invokevirtual #123 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 179: checkcast #117 // class java/lang/Number\n 182: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 185: istore 8\n 187: iconst_0\n 188: istore 9\n 190: iload 9\n 192: iload 8\n 194: if_icmpge 61\n 197: iload 9\n 199: istore 10\n 201: iconst_0\n 202: istore 11\n 204: aload_1\n 205: aload_2\n 206: aload 7\n 208: invokestatic #222 // Method main$move:(Lkotlin/Pair;Lkotlin/Pair;LDirection;)Lkotlin/Pair;\n 211: astore 12\n 213: aload 12\n 215: invokevirtual #115 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 218: checkcast #111 // class kotlin/Pair\n 221: astore 13\n 223: aload 12\n 225: invokevirtual #123 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 228: checkcast #111 // class kotlin/Pair\n 231: astore 14\n 233: aload 13\n 235: astore_1\n 236: aload 14\n 238: astore_2\n 239: aload_3\n 240: aload_2\n 241: invokeinterface #227, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 246: pop\n 247: nop\n 248: iinc 9, 1\n 251: goto 190\n 254: aload_3\n 255: checkcast #229 // class java/util/Collection\n 258: invokeinterface #232, 1 // InterfaceMethod java/util/Collection.size:()I\n 263: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: bipush 10\n 2: istore_2\n 3: new #247 // class java/util/ArrayList\n 6: dup\n 7: iload_2\n 8: invokespecial #249 // Method java/util/ArrayList.\"<init>\":(I)V\n 11: astore_3\n 12: iconst_0\n 13: istore 4\n 15: iload 4\n 17: iload_2\n 18: if_icmpge 63\n 21: iload 4\n 23: istore 5\n 25: aload_3\n 26: iload 5\n 28: istore 6\n 30: astore 13\n 32: iconst_0\n 33: istore 7\n 35: new #111 // class kotlin/Pair\n 38: dup\n 39: iconst_0\n 40: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 43: iconst_0\n 44: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 47: invokespecial #132 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 50: aload 13\n 52: swap\n 53: invokevirtual #250 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 56: pop\n 57: iinc 4, 1\n 60: goto 15\n 63: aload_3\n 64: checkcast #187 // class java/util/List\n 67: astore_1\n 68: iconst_1\n 69: anewarray #111 // class kotlin/Pair\n 72: astore_3\n 73: aload_3\n 74: iconst_0\n 75: aload_1\n 76: invokestatic #256 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 79: aastore\n 80: aload_3\n 81: invokestatic #185 // Method kotlin/collections/SetsKt.mutableSetOf:([Ljava/lang/Object;)Ljava/util/Set;\n 84: astore_2\n 85: aload_0\n 86: invokeinterface #191, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 91: astore_3\n 92: aload_3\n 93: invokeinterface #197, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 98: ifeq 359\n 101: aload_3\n 102: invokeinterface #200, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 107: checkcast #58 // class java/lang/String\n 110: astore 4\n 112: aload 4\n 114: checkcast #202 // class java/lang/CharSequence\n 117: iconst_1\n 118: anewarray #58 // class java/lang/String\n 121: astore 6\n 123: aload 6\n 125: iconst_0\n 126: ldc #204 // String\n 128: aastore\n 129: aload 6\n 131: iconst_0\n 132: iconst_0\n 133: bipush 6\n 135: aconst_null\n 136: invokestatic #210 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 139: astore 7\n 141: iconst_0\n 142: istore 8\n 144: aload 7\n 146: iconst_0\n 147: invokeinterface #214, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 152: checkcast #58 // class java/lang/String\n 155: astore 9\n 157: aload 7\n 159: iconst_1\n 160: invokeinterface #214, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 165: checkcast #58 // class java/lang/String\n 168: astore 10\n 170: new #111 // class kotlin/Pair\n 173: dup\n 174: aload 9\n 176: invokestatic #216 // Method main$convertToDirection:(Ljava/lang/String;)LDirection;\n 179: aload 10\n 181: invokestatic #220 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 184: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 187: invokespecial #132 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 190: nop\n 191: astore 5\n 193: aload 5\n 195: invokevirtual #115 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 198: checkcast #76 // class Direction\n 201: astore 6\n 203: aload 5\n 205: invokevirtual #123 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 208: checkcast #117 // class java/lang/Number\n 211: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 214: istore 7\n 216: iconst_0\n 217: istore 8\n 219: iload 8\n 221: iload 7\n 223: if_icmpge 92\n 226: iload 8\n 228: istore 9\n 230: iconst_0\n 231: istore 10\n 233: aload_1\n 234: iconst_0\n 235: aload_1\n 236: iconst_0\n 237: invokeinterface #214, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 242: checkcast #111 // class kotlin/Pair\n 245: aload 6\n 247: invokestatic #174 // Method main$moveHead:(Lkotlin/Pair;LDirection;)Lkotlin/Pair;\n 250: invokeinterface #260, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 255: pop\n 256: aload_1\n 257: checkcast #229 // class java/util/Collection\n 260: invokestatic #264 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 263: checkcast #266 // class java/lang/Iterable\n 266: iconst_1\n 267: invokestatic #270 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 270: invokeinterface #191, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 275: astore 11\n 277: aload 11\n 279: invokeinterface #197, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 284: ifeq 341\n 287: aload 11\n 289: invokeinterface #200, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 294: checkcast #117 // class java/lang/Number\n 297: invokevirtual #120 // Method java/lang/Number.intValue:()I\n 300: istore 12\n 302: aload_1\n 303: iload 12\n 305: aload_1\n 306: iload 12\n 308: iconst_1\n 309: isub\n 310: invokeinterface #214, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 315: checkcast #111 // class kotlin/Pair\n 318: aload_1\n 319: iload 12\n 321: invokeinterface #214, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 326: checkcast #111 // class kotlin/Pair\n 329: invokestatic #176 // Method main$moveTail:(Lkotlin/Pair;Lkotlin/Pair;)Lkotlin/Pair;\n 332: invokeinterface #260, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 337: pop\n 338: goto 277\n 341: aload_2\n 342: aload_1\n 343: invokestatic #256 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 346: invokeinterface #227, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 351: pop\n 352: nop\n 353: iinc 8, 1\n 356: goto 219\n 359: aload_2\n 360: checkcast #229 // class java/util/Collection\n 363: invokeinterface #232, 1 // InterfaceMethod java/util/Collection.size:()I\n 368: ireturn\n}\n",
"javap_err": ""
}
] |
jacobprudhomme__advent-of-code-2022__9c2b080/src/day02/Day02.kt
|
import java.io.File
import java.lang.IllegalArgumentException
enum class Result(val score: Int) {
LOSE(0),
DRAW(3),
WIN(6),
}
enum class Move(val value: Int) {
ROCK(1),
PAPER(2),
SCISSORS(3);
fun against(other: Move): Result = when (other.value) {
((value + 1) % 3) + 1 -> Result.WIN
value -> Result.DRAW
else -> Result.LOSE
}
fun obtainsAgainst(result: Result): Move = when (result) {
Result.WIN -> fromValue((value % 3) + 1)
Result.LOSE -> fromValue(((value + 1) % 3) + 1)
else -> this
}
companion object {
fun fromValue(value: Int): Move = when (value) {
1 -> ROCK
2 -> PAPER
3 -> SCISSORS
else -> throw IllegalArgumentException("We should never get here")
}
}
}
fun main() {
fun readInput(name: String) = File("src/day02", name)
.readLines()
fun decryptMove(encryptedMove: String): Move = when (encryptedMove) {
"A", "X" -> Move.ROCK
"B", "Y" -> Move.PAPER
"C", "Z" -> Move.SCISSORS
else -> throw IllegalArgumentException("We should never get here")
}
fun decryptResult(encryptedResult: String): Result = when (encryptedResult) {
"X" -> Result.LOSE
"Y" -> Result.DRAW
"Z" -> Result.WIN
else -> throw IllegalArgumentException("We should never get here")
}
fun part1(input: List<String>): Int {
var score = 0
for (line in input) {
val (theirMove, myMove, _) = line.split(" ").map { decryptMove(it) }
score += myMove.value + myMove.against(theirMove).score
}
return score
}
fun part2(input: List<String>): Int {
var score = 0
for (line in input) {
val (theirMove, myResult) = line.split(" ").let { (theirMoveStr, myResultStr, _) ->
Pair(decryptMove(theirMoveStr), decryptResult(myResultStr))
}
score += theirMove.obtainsAgainst(myResult).value + myResult.score
}
return score
}
val input = readInput("input")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "jacobprudhomme__advent-of-code-2022__9c2b080/Day02Kt.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class Day02Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String input\n 2: invokestatic #12 // Method main$readInput:(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: istore_1\n 11: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #28 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #31 // Method main$part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #28 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #35 // Method main:()V\n 3: return\n\n private static final java.util.List<java.lang.String> main$readInput(java.lang.String);\n Code:\n 0: new #40 // class java/io/File\n 3: dup\n 4: ldc #42 // String src/day02\n 6: aload_0\n 7: invokespecial #46 // Method java/io/File.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 10: aconst_null\n 11: iconst_1\n 12: aconst_null\n 13: invokestatic #52 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 16: areturn\n\n private static final Move main$decryptMove(java.lang.String);\n Code:\n 0: aload_0\n 1: astore_1\n 2: aload_1\n 3: invokevirtual #62 // 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 #64 // String A\n 67: invokevirtual #68 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 70: ifne 136\n 73: goto 154\n 76: aload_1\n 77: ldc #70 // String B\n 79: invokevirtual #68 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 82: ifne 142\n 85: goto 154\n 88: aload_1\n 89: ldc #72 // String C\n 91: invokevirtual #68 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 94: ifne 148\n 97: goto 154\n 100: aload_1\n 101: ldc #74 // String X\n 103: invokevirtual #68 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 106: ifne 136\n 109: goto 154\n 112: aload_1\n 113: ldc #76 // String Y\n 115: invokevirtual #68 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 118: ifne 142\n 121: goto 154\n 124: aload_1\n 125: ldc #78 // String Z\n 127: invokevirtual #68 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 130: ifne 148\n 133: goto 154\n 136: getstatic #84 // Field Move.ROCK:LMove;\n 139: goto 164\n 142: getstatic #87 // Field Move.PAPER:LMove;\n 145: goto 164\n 148: getstatic #90 // Field Move.SCISSORS:LMove;\n 151: goto 164\n 154: new #92 // class java/lang/IllegalArgumentException\n 157: dup\n 158: ldc #94 // String We should never get here\n 160: invokespecial #97 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 163: athrow\n 164: areturn\n\n private static final Result main$decryptResult(java.lang.String);\n Code:\n 0: aload_0\n 1: astore_1\n 2: aload_1\n 3: invokevirtual #62 // 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 #74 // String X\n 35: invokevirtual #68 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 38: ifne 68\n 41: goto 86\n 44: aload_1\n 45: ldc #76 // String Y\n 47: invokevirtual #68 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 50: ifne 74\n 53: goto 86\n 56: aload_1\n 57: ldc #78 // String Z\n 59: invokevirtual #68 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 62: ifne 80\n 65: goto 86\n 68: getstatic #106 // Field Result.LOSE:LResult;\n 71: goto 96\n 74: getstatic #109 // Field Result.DRAW:LResult;\n 77: goto 96\n 80: getstatic #112 // Field Result.WIN:LResult;\n 83: goto 96\n 86: new #92 // class java/lang/IllegalArgumentException\n 89: dup\n 90: ldc #94 // String We should never get here\n 92: invokespecial #97 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 95: athrow\n 96: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: aload_0\n 3: invokeinterface #120, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 8: astore_2\n 9: aload_2\n 10: invokeinterface #126, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 15: ifeq 203\n 18: aload_2\n 19: invokeinterface #130, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 24: checkcast #58 // class java/lang/String\n 27: astore_3\n 28: aload_3\n 29: checkcast #132 // class java/lang/CharSequence\n 32: iconst_1\n 33: anewarray #58 // class java/lang/String\n 36: astore 5\n 38: aload 5\n 40: iconst_0\n 41: ldc #134 // String\n 43: aastore\n 44: aload 5\n 46: iconst_0\n 47: iconst_0\n 48: bipush 6\n 50: aconst_null\n 51: invokestatic #140 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 54: checkcast #142 // class java/lang/Iterable\n 57: astore 5\n 59: iconst_0\n 60: istore 6\n 62: aload 5\n 64: astore 7\n 66: new #144 // class java/util/ArrayList\n 69: dup\n 70: aload 5\n 72: bipush 10\n 74: invokestatic #150 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 77: invokespecial #152 // Method java/util/ArrayList.\"<init>\":(I)V\n 80: checkcast #154 // class java/util/Collection\n 83: astore 8\n 85: iconst_0\n 86: istore 9\n 88: aload 7\n 90: invokeinterface #155, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 95: astore 10\n 97: aload 10\n 99: invokeinterface #126, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 104: ifeq 147\n 107: aload 10\n 109: invokeinterface #130, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 114: astore 11\n 116: aload 8\n 118: aload 11\n 120: checkcast #58 // class java/lang/String\n 123: astore 12\n 125: astore 14\n 127: iconst_0\n 128: istore 13\n 130: aload 12\n 132: invokestatic #157 // Method main$decryptMove:(Ljava/lang/String;)LMove;\n 135: aload 14\n 137: swap\n 138: invokeinterface #160, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 143: pop\n 144: goto 97\n 147: aload 8\n 149: checkcast #116 // class java/util/List\n 152: nop\n 153: astore 4\n 155: aload 4\n 157: iconst_0\n 158: invokeinterface #164, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 163: checkcast #80 // class Move\n 166: astore 5\n 168: aload 4\n 170: iconst_1\n 171: invokeinterface #164, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 176: checkcast #80 // class Move\n 179: astore 6\n 181: iload_1\n 182: aload 6\n 184: invokevirtual #167 // Method Move.getValue:()I\n 187: aload 6\n 189: aload 5\n 191: invokevirtual #171 // Method Move.against:(LMove;)LResult;\n 194: invokevirtual #174 // Method Result.getScore:()I\n 197: iadd\n 198: iadd\n 199: istore_1\n 200: goto 9\n 203: iload_1\n 204: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: aload_0\n 3: invokeinterface #120, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 8: astore_2\n 9: aload_2\n 10: invokeinterface #126, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 15: ifeq 147\n 18: aload_2\n 19: invokeinterface #130, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 24: checkcast #58 // class java/lang/String\n 27: astore_3\n 28: aload_3\n 29: checkcast #132 // class java/lang/CharSequence\n 32: iconst_1\n 33: anewarray #58 // class java/lang/String\n 36: astore 5\n 38: aload 5\n 40: iconst_0\n 41: ldc #134 // String\n 43: aastore\n 44: aload 5\n 46: iconst_0\n 47: iconst_0\n 48: bipush 6\n 50: aconst_null\n 51: invokestatic #140 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 54: astore 6\n 56: iconst_0\n 57: istore 7\n 59: aload 6\n 61: iconst_0\n 62: invokeinterface #164, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 67: checkcast #58 // class java/lang/String\n 70: astore 8\n 72: aload 6\n 74: iconst_1\n 75: invokeinterface #164, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 80: checkcast #58 // class java/lang/String\n 83: astore 9\n 85: new #192 // class kotlin/Pair\n 88: dup\n 89: aload 8\n 91: invokestatic #157 // Method main$decryptMove:(Ljava/lang/String;)LMove;\n 94: aload 9\n 96: invokestatic #194 // Method main$decryptResult:(Ljava/lang/String;)LResult;\n 99: invokespecial #197 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 102: nop\n 103: astore 4\n 105: aload 4\n 107: invokevirtual #200 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 110: checkcast #80 // class Move\n 113: astore 5\n 115: aload 4\n 117: invokevirtual #203 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 120: checkcast #102 // class Result\n 123: astore 6\n 125: iload_1\n 126: aload 5\n 128: aload 6\n 130: invokevirtual #207 // Method Move.obtainsAgainst:(LResult;)LMove;\n 133: invokevirtual #167 // Method Move.getValue:()I\n 136: aload 6\n 138: invokevirtual #174 // Method Result.getScore:()I\n 141: iadd\n 142: iadd\n 143: istore_1\n 144: goto 9\n 147: iload_1\n 148: ireturn\n}\n",
"javap_err": ""
}
] |
jacobprudhomme__advent-of-code-2022__9c2b080/src/day08/Day08.kt
|
import java.io.File
class Matrix<T>(private val mtx: List<List<T>>) {
fun dimensions(): Pair<Int, Int> = Pair(mtx.size, mtx[0].size)
fun getRow(rowIdx: Int): List<T> = mtx[rowIdx]
fun getColumn(colIdx: Int): List<T> = mtx.map { row -> row[colIdx] }
fun forEachIndexed(f: (rowIndex: Int, columnIndex: Int, T) -> Unit) {
this.mtx.forEachIndexed { rowIndex, row ->
row.forEachIndexed { columnIndex, item ->
f(rowIndex, columnIndex, item)
}
}
}
}
fun main() {
fun readInput(name: String) = File("src/day08", name)
.readLines()
fun smallerToLeft(mtx: Matrix<Int>, thisTree: Int, pos: Pair<Int, Int>): Int {
val row = mtx.getRow(pos.first).subList(0, pos.second)
return row.takeLastWhile { tree -> tree < thisTree }.count()
}
fun smallerToRight(mtx: Matrix<Int>, thisTree: Int, pos: Pair<Int, Int>): Int {
val row = mtx.getRow(pos.first).subList(pos.second + 1, mtx.dimensions().second)
return row.takeWhile { tree -> tree < thisTree }.count()
}
fun smallerAbove(mtx: Matrix<Int>, thisTree: Int, pos: Pair<Int, Int>): Int {
val col = mtx.getColumn(pos.second).subList(0, pos.first)
return col.takeLastWhile { tree -> tree < thisTree }.count()
}
fun smallerBelow(mtx: Matrix<Int>, thisTree: Int, pos: Pair<Int, Int>): Int {
val col = mtx.getColumn(pos.second).subList(pos.first + 1, mtx.dimensions().first)
return col.takeWhile { tree -> tree < thisTree }.count()
}
fun isVisibleFromADirection(mtx: Matrix<Int>, tree: Int, pos: Pair<Int, Int>): Boolean {
val (height, width) = mtx.dimensions()
return ((smallerToLeft(mtx, tree, pos) == pos.second)
or (smallerToRight(mtx, tree, pos) == width - pos.second - 1)
or (smallerAbove(mtx, tree, pos) == pos.first)
or (smallerBelow(mtx, tree, pos) == height - pos.first - 1))
}
fun calculateVisibilityScore(mtx: Matrix<Int>, tree: Int, pos: Pair<Int, Int>): Int {
val (row, col) = pos
val (height, width) = mtx.dimensions()
var stl = smallerToLeft(mtx, tree, pos)
if (stl < col) { ++stl }
var str = smallerToRight(mtx, tree, pos)
if (str < width - col - 1) { ++str }
var sa = smallerAbove(mtx, tree, pos)
if (sa < row) { ++sa }
var sb = smallerBelow(mtx, tree, pos)
if (sb < height - row - 1) { ++sb }
return (stl * str * sa * sb)
}
fun part1(input: List<String>): Int {
val grid = Matrix(input.map { row -> row.map(Char::digitToInt) })
val treesSeen = mutableSetOf<Pair<Int, Int>>()
var count = 0
grid.forEachIndexed { rowIdx, colIdx, tree ->
if ((Pair(rowIdx, colIdx) !in treesSeen) and isVisibleFromADirection(grid, tree, Pair(rowIdx, colIdx))) {
count += 1
treesSeen.add(Pair(rowIdx, colIdx))
}
}
return count
}
fun part2(input: List<String>): Int {
val grid = Matrix(input.map { row -> row.map(Char::digitToInt) })
val treesSeen = mutableSetOf<Pair<Int, Int>>()
var maxScoreSeenSoFar = 0
grid.forEachIndexed { rowIdx, colIdx, tree ->
if (Pair(rowIdx, colIdx) !in treesSeen) {
val visibilityScore = calculateVisibilityScore(grid, tree, Pair(rowIdx, colIdx))
if (visibilityScore > maxScoreSeenSoFar) {
maxScoreSeenSoFar = visibilityScore
}
treesSeen.add(Pair(rowIdx, colIdx))
}
}
return maxScoreSeenSoFar
}
val input = readInput("input")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "jacobprudhomme__advent-of-code-2022__9c2b080/Day08Kt.class",
"javap": "Compiled from \"Day08.kt\"\npublic final class Day08Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String input\n 2: invokestatic #12 // Method main$readInput:(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: istore_1\n 11: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #28 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #31 // Method main$part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #28 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #35 // Method main:()V\n 3: return\n\n private static final java.util.List<java.lang.String> main$readInput(java.lang.String);\n Code:\n 0: new #40 // class java/io/File\n 3: dup\n 4: ldc #42 // String src/day08\n 6: aload_0\n 7: invokespecial #46 // Method java/io/File.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 10: aconst_null\n 11: iconst_1\n 12: aconst_null\n 13: invokestatic #52 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 16: areturn\n\n private static final int main$smallerToLeft(Matrix<java.lang.Integer>, int, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: aload_2\n 2: invokevirtual #63 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 5: checkcast #65 // class java/lang/Number\n 8: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 11: invokevirtual #75 // Method Matrix.getRow:(I)Ljava/util/List;\n 14: iconst_0\n 15: aload_2\n 16: invokevirtual #78 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 19: checkcast #65 // class java/lang/Number\n 22: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 25: invokeinterface #84, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 30: astore_3\n 31: aload_3\n 32: astore 4\n 34: iconst_0\n 35: istore 5\n 37: aload 4\n 39: invokeinterface #88, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 44: ifeq 53\n 47: invokestatic #94 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 50: goto 208\n 53: aload 4\n 55: aload 4\n 57: invokeinterface #97, 1 // InterfaceMethod java/util/List.size:()I\n 62: invokeinterface #101, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 67: astore 6\n 69: aload 6\n 71: invokeinterface #106, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 76: ifeq 200\n 79: aload 6\n 81: invokeinterface #109, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 86: checkcast #65 // class java/lang/Number\n 89: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 92: istore 7\n 94: iconst_0\n 95: istore 8\n 97: iload 7\n 99: iload_1\n 100: if_icmpge 107\n 103: iconst_1\n 104: goto 108\n 107: iconst_0\n 108: ifne 69\n 111: aload 6\n 113: invokeinterface #112, 1 // InterfaceMethod java/util/ListIterator.next:()Ljava/lang/Object;\n 118: pop\n 119: aload 4\n 121: invokeinterface #97, 1 // InterfaceMethod java/util/List.size:()I\n 126: aload 6\n 128: invokeinterface #115, 1 // InterfaceMethod java/util/ListIterator.nextIndex:()I\n 133: isub\n 134: istore 9\n 136: iload 9\n 138: ifne 147\n 141: invokestatic #94 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 144: goto 208\n 147: new #117 // class java/util/ArrayList\n 150: dup\n 151: iload 9\n 153: invokespecial #119 // Method java/util/ArrayList.\"<init>\":(I)V\n 156: astore 10\n 158: aload 10\n 160: astore 11\n 162: iconst_0\n 163: istore 12\n 165: aload 6\n 167: invokeinterface #122, 1 // InterfaceMethod java/util/ListIterator.hasNext:()Z\n 172: ifeq 191\n 175: aload 11\n 177: aload 6\n 179: invokeinterface #112, 1 // InterfaceMethod java/util/ListIterator.next:()Ljava/lang/Object;\n 184: invokevirtual #126 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 187: pop\n 188: goto 165\n 191: nop\n 192: aload 10\n 194: checkcast #80 // class java/util/List\n 197: goto 208\n 200: aload 4\n 202: checkcast #128 // class java/lang/Iterable\n 205: invokestatic #132 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 208: checkcast #134 // class java/util/Collection\n 211: invokeinterface #135, 1 // InterfaceMethod java/util/Collection.size:()I\n 216: ireturn\n\n private static final int main$smallerToRight(Matrix<java.lang.Integer>, int, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: aload_2\n 2: invokevirtual #63 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 5: checkcast #65 // class java/lang/Number\n 8: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 11: invokevirtual #75 // Method Matrix.getRow:(I)Ljava/util/List;\n 14: aload_2\n 15: invokevirtual #78 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 18: checkcast #65 // class java/lang/Number\n 21: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 24: iconst_1\n 25: iadd\n 26: aload_0\n 27: invokevirtual #157 // Method Matrix.dimensions:()Lkotlin/Pair;\n 30: invokevirtual #78 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 33: checkcast #65 // class java/lang/Number\n 36: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 39: invokeinterface #84, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 44: astore_3\n 45: aload_3\n 46: checkcast #128 // class java/lang/Iterable\n 49: astore 4\n 51: iconst_0\n 52: istore 5\n 54: new #117 // class java/util/ArrayList\n 57: dup\n 58: invokespecial #159 // Method java/util/ArrayList.\"<init>\":()V\n 61: astore 6\n 63: aload 4\n 65: invokeinterface #163, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 70: astore 7\n 72: aload 7\n 74: invokeinterface #166, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 79: ifeq 132\n 82: aload 7\n 84: invokeinterface #167, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 89: astore 8\n 91: aload 8\n 93: checkcast #65 // class java/lang/Number\n 96: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 99: istore 9\n 101: iconst_0\n 102: istore 10\n 104: iload 9\n 106: iload_1\n 107: if_icmpge 114\n 110: iconst_1\n 111: goto 115\n 114: iconst_0\n 115: ifne 121\n 118: goto 132\n 121: aload 6\n 123: aload 8\n 125: invokevirtual #126 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 128: pop\n 129: goto 72\n 132: aload 6\n 134: checkcast #80 // class java/util/List\n 137: checkcast #134 // class java/util/Collection\n 140: invokeinterface #135, 1 // InterfaceMethod java/util/Collection.size:()I\n 145: ireturn\n\n private static final int main$smallerAbove(Matrix<java.lang.Integer>, int, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: aload_2\n 2: invokevirtual #78 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 5: checkcast #65 // class java/lang/Number\n 8: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 11: invokevirtual #178 // Method Matrix.getColumn:(I)Ljava/util/List;\n 14: iconst_0\n 15: aload_2\n 16: invokevirtual #63 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 19: checkcast #65 // class java/lang/Number\n 22: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 25: invokeinterface #84, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 30: astore_3\n 31: aload_3\n 32: astore 4\n 34: iconst_0\n 35: istore 5\n 37: aload 4\n 39: invokeinterface #88, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 44: ifeq 53\n 47: invokestatic #94 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 50: goto 208\n 53: aload 4\n 55: aload 4\n 57: invokeinterface #97, 1 // InterfaceMethod java/util/List.size:()I\n 62: invokeinterface #101, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 67: astore 6\n 69: aload 6\n 71: invokeinterface #106, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 76: ifeq 200\n 79: aload 6\n 81: invokeinterface #109, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 86: checkcast #65 // class java/lang/Number\n 89: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 92: istore 7\n 94: iconst_0\n 95: istore 8\n 97: iload 7\n 99: iload_1\n 100: if_icmpge 107\n 103: iconst_1\n 104: goto 108\n 107: iconst_0\n 108: ifne 69\n 111: aload 6\n 113: invokeinterface #112, 1 // InterfaceMethod java/util/ListIterator.next:()Ljava/lang/Object;\n 118: pop\n 119: aload 4\n 121: invokeinterface #97, 1 // InterfaceMethod java/util/List.size:()I\n 126: aload 6\n 128: invokeinterface #115, 1 // InterfaceMethod java/util/ListIterator.nextIndex:()I\n 133: isub\n 134: istore 9\n 136: iload 9\n 138: ifne 147\n 141: invokestatic #94 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 144: goto 208\n 147: new #117 // class java/util/ArrayList\n 150: dup\n 151: iload 9\n 153: invokespecial #119 // Method java/util/ArrayList.\"<init>\":(I)V\n 156: astore 10\n 158: aload 10\n 160: astore 11\n 162: iconst_0\n 163: istore 12\n 165: aload 6\n 167: invokeinterface #122, 1 // InterfaceMethod java/util/ListIterator.hasNext:()Z\n 172: ifeq 191\n 175: aload 11\n 177: aload 6\n 179: invokeinterface #112, 1 // InterfaceMethod java/util/ListIterator.next:()Ljava/lang/Object;\n 184: invokevirtual #126 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 187: pop\n 188: goto 165\n 191: nop\n 192: aload 10\n 194: checkcast #80 // class java/util/List\n 197: goto 208\n 200: aload 4\n 202: checkcast #128 // class java/lang/Iterable\n 205: invokestatic #132 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 208: checkcast #134 // class java/util/Collection\n 211: invokeinterface #135, 1 // InterfaceMethod java/util/Collection.size:()I\n 216: ireturn\n\n private static final int main$smallerBelow(Matrix<java.lang.Integer>, int, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: aload_2\n 2: invokevirtual #78 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 5: checkcast #65 // class java/lang/Number\n 8: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 11: invokevirtual #178 // Method Matrix.getColumn:(I)Ljava/util/List;\n 14: aload_2\n 15: invokevirtual #63 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 18: checkcast #65 // class java/lang/Number\n 21: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 24: iconst_1\n 25: iadd\n 26: aload_0\n 27: invokevirtual #157 // Method Matrix.dimensions:()Lkotlin/Pair;\n 30: invokevirtual #63 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 33: checkcast #65 // class java/lang/Number\n 36: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 39: invokeinterface #84, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 44: astore_3\n 45: aload_3\n 46: checkcast #128 // class java/lang/Iterable\n 49: astore 4\n 51: iconst_0\n 52: istore 5\n 54: new #117 // class java/util/ArrayList\n 57: dup\n 58: invokespecial #159 // Method java/util/ArrayList.\"<init>\":()V\n 61: astore 6\n 63: aload 4\n 65: invokeinterface #163, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 70: astore 7\n 72: aload 7\n 74: invokeinterface #166, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 79: ifeq 132\n 82: aload 7\n 84: invokeinterface #167, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 89: astore 8\n 91: aload 8\n 93: checkcast #65 // class java/lang/Number\n 96: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 99: istore 9\n 101: iconst_0\n 102: istore 10\n 104: iload 9\n 106: iload_1\n 107: if_icmpge 114\n 110: iconst_1\n 111: goto 115\n 114: iconst_0\n 115: ifne 121\n 118: goto 132\n 121: aload 6\n 123: aload 8\n 125: invokevirtual #126 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 128: pop\n 129: goto 72\n 132: aload 6\n 134: checkcast #80 // class java/util/List\n 137: checkcast #134 // class java/util/Collection\n 140: invokeinterface #135, 1 // InterfaceMethod java/util/Collection.size:()I\n 145: ireturn\n\n private static final boolean main$isVisibleFromADirection(Matrix<java.lang.Integer>, int, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: invokevirtual #157 // Method Matrix.dimensions:()Lkotlin/Pair;\n 4: astore_3\n 5: aload_3\n 6: invokevirtual #188 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 9: checkcast #65 // class java/lang/Number\n 12: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 15: istore 4\n 17: aload_3\n 18: invokevirtual #191 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 21: checkcast #65 // class java/lang/Number\n 24: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 27: istore 5\n 29: aload_0\n 30: iload_1\n 31: aload_2\n 32: invokestatic #193 // Method main$smallerToLeft:(LMatrix;ILkotlin/Pair;)I\n 35: aload_2\n 36: invokevirtual #78 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 39: checkcast #65 // class java/lang/Number\n 42: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 45: if_icmpne 52\n 48: iconst_1\n 49: goto 53\n 52: iconst_0\n 53: aload_0\n 54: iload_1\n 55: aload_2\n 56: invokestatic #195 // Method main$smallerToRight:(LMatrix;ILkotlin/Pair;)I\n 59: iload 5\n 61: aload_2\n 62: invokevirtual #78 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 65: checkcast #65 // class java/lang/Number\n 68: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 71: isub\n 72: iconst_1\n 73: isub\n 74: if_icmpne 81\n 77: iconst_1\n 78: goto 82\n 81: iconst_0\n 82: ior\n 83: aload_0\n 84: iload_1\n 85: aload_2\n 86: invokestatic #197 // Method main$smallerAbove:(LMatrix;ILkotlin/Pair;)I\n 89: aload_2\n 90: invokevirtual #63 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 93: checkcast #65 // class java/lang/Number\n 96: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 99: if_icmpne 106\n 102: iconst_1\n 103: goto 107\n 106: iconst_0\n 107: ior\n 108: aload_0\n 109: iload_1\n 110: aload_2\n 111: invokestatic #199 // Method main$smallerBelow:(LMatrix;ILkotlin/Pair;)I\n 114: iload 4\n 116: aload_2\n 117: invokevirtual #63 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 120: checkcast #65 // class java/lang/Number\n 123: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 126: isub\n 127: iconst_1\n 128: isub\n 129: if_icmpne 136\n 132: iconst_1\n 133: goto 137\n 136: iconst_0\n 137: ior\n 138: ireturn\n\n private static final int main$calculateVisibilityScore(Matrix<java.lang.Integer>, int, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_2\n 1: invokevirtual #188 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 4: checkcast #65 // class java/lang/Number\n 7: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 10: istore_3\n 11: aload_2\n 12: invokevirtual #191 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 15: checkcast #65 // class java/lang/Number\n 18: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 21: istore 4\n 23: aload_0\n 24: invokevirtual #157 // Method Matrix.dimensions:()Lkotlin/Pair;\n 27: astore 5\n 29: aload 5\n 31: invokevirtual #188 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 34: checkcast #65 // class java/lang/Number\n 37: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 40: istore 6\n 42: aload 5\n 44: invokevirtual #191 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 47: checkcast #65 // class java/lang/Number\n 50: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 53: istore 7\n 55: aload_0\n 56: iload_1\n 57: aload_2\n 58: invokestatic #193 // Method main$smallerToLeft:(LMatrix;ILkotlin/Pair;)I\n 61: istore 8\n 63: iload 8\n 65: iload 4\n 67: if_icmpge 73\n 70: iinc 8, 1\n 73: aload_0\n 74: iload_1\n 75: aload_2\n 76: invokestatic #195 // Method main$smallerToRight:(LMatrix;ILkotlin/Pair;)I\n 79: istore 9\n 81: iload 9\n 83: iload 7\n 85: iload 4\n 87: isub\n 88: iconst_1\n 89: isub\n 90: if_icmpge 96\n 93: iinc 9, 1\n 96: aload_0\n 97: iload_1\n 98: aload_2\n 99: invokestatic #197 // Method main$smallerAbove:(LMatrix;ILkotlin/Pair;)I\n 102: istore 10\n 104: iload 10\n 106: iload_3\n 107: if_icmpge 113\n 110: iinc 10, 1\n 113: aload_0\n 114: iload_1\n 115: aload_2\n 116: invokestatic #199 // Method main$smallerBelow:(LMatrix;ILkotlin/Pair;)I\n 119: istore 11\n 121: iload 11\n 123: iload 6\n 125: iload_3\n 126: isub\n 127: iconst_1\n 128: isub\n 129: if_icmpge 135\n 132: iinc 11, 1\n 135: iload 8\n 137: iload 9\n 139: imul\n 140: iload 10\n 142: imul\n 143: iload 11\n 145: imul\n 146: ireturn\n\n private static final kotlin.Unit main$part1$lambda$5(java.util.Set, Matrix, kotlin.jvm.internal.Ref$IntRef, int, int, int);\n Code:\n 0: aload_0\n 1: new #59 // class kotlin/Pair\n 4: dup\n 5: iload_3\n 6: invokestatic #214 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 9: iload 4\n 11: invokestatic #214 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 14: invokespecial #217 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 17: invokeinterface #222, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 22: ifne 29\n 25: iconst_1\n 26: goto 30\n 29: iconst_0\n 30: aload_1\n 31: iload 5\n 33: new #59 // class kotlin/Pair\n 36: dup\n 37: iload_3\n 38: invokestatic #214 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 41: iload 4\n 43: invokestatic #214 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 46: invokespecial #217 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 49: invokestatic #224 // Method main$isVisibleFromADirection:(LMatrix;ILkotlin/Pair;)Z\n 52: iand\n 53: ifeq 89\n 56: aload_2\n 57: aload_2\n 58: getfield #229 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 61: iconst_1\n 62: iadd\n 63: putfield #229 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 66: aload_0\n 67: new #59 // class kotlin/Pair\n 70: dup\n 71: iload_3\n 72: invokestatic #214 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 75: iload 4\n 77: invokestatic #214 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 80: invokespecial #217 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 83: invokeinterface #230, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 88: pop\n 89: getstatic #236 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 92: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #128 // 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 #117 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: bipush 10\n 17: invokestatic #248 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #119 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #134 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 4\n 33: invokeinterface #163, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 7\n 40: aload 7\n 42: invokeinterface #166, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 188\n 50: aload 7\n 52: invokeinterface #167, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 8\n 59: aload 5\n 61: aload 8\n 63: checkcast #250 // 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 #252 // 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 #117 // class java/util/ArrayList\n 90: dup\n 91: aload 11\n 93: invokeinterface #255, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 98: invokespecial #119 // Method java/util/ArrayList.\"<init>\":(I)V\n 101: checkcast #134 // 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 #255, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 121: if_icmpge 169\n 124: aload 13\n 126: iload 16\n 128: invokeinterface #259, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 133: istore 17\n 135: aload 14\n 137: iload 17\n 139: istore 18\n 141: astore 19\n 143: iconst_0\n 144: istore 20\n 146: iload 18\n 148: invokestatic #265 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 151: invokestatic #214 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 154: aload 19\n 156: swap\n 157: invokeinterface #266, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 162: pop\n 163: iinc 16, 1\n 166: goto 112\n 169: aload 14\n 171: checkcast #80 // class java/util/List\n 174: nop\n 175: nop\n 176: aload 21\n 178: swap\n 179: invokeinterface #266, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 184: pop\n 185: goto 40\n 188: aload 5\n 190: checkcast #80 // class java/util/List\n 193: nop\n 194: astore 22\n 196: new #71 // class Matrix\n 199: dup\n 200: aload 22\n 202: invokespecial #269 // Method Matrix.\"<init>\":(Ljava/util/List;)V\n 205: astore_1\n 206: new #271 // class java/util/LinkedHashSet\n 209: dup\n 210: invokespecial #272 // Method java/util/LinkedHashSet.\"<init>\":()V\n 213: checkcast #219 // class java/util/Set\n 216: astore_2\n 217: new #226 // class kotlin/jvm/internal/Ref$IntRef\n 220: dup\n 221: invokespecial #273 // Method kotlin/jvm/internal/Ref$IntRef.\"<init>\":()V\n 224: astore_3\n 225: aload_1\n 226: aload_2\n 227: aload_1\n 228: aload_3\n 229: invokedynamic #291, 0 // InvokeDynamic #0:invoke:(Ljava/util/Set;LMatrix;Lkotlin/jvm/internal/Ref$IntRef;)Lkotlin/jvm/functions/Function3;\n 234: invokevirtual #295 // Method Matrix.forEachIndexed:(Lkotlin/jvm/functions/Function3;)V\n 237: aload_3\n 238: getfield #229 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 241: ireturn\n\n private static final kotlin.Unit main$part2$lambda$8(java.util.Set, Matrix, kotlin.jvm.internal.Ref$IntRef, int, int, int);\n Code:\n 0: aload_0\n 1: new #59 // class kotlin/Pair\n 4: dup\n 5: iload_3\n 6: invokestatic #214 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 9: iload 4\n 11: invokestatic #214 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 14: invokespecial #217 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 17: invokeinterface #222, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 22: ifne 87\n 25: aload_1\n 26: iload 5\n 28: new #59 // class kotlin/Pair\n 31: dup\n 32: iload_3\n 33: invokestatic #214 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 36: iload 4\n 38: invokestatic #214 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 41: invokespecial #217 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 44: invokestatic #313 // Method main$calculateVisibilityScore:(LMatrix;ILkotlin/Pair;)I\n 47: istore 6\n 49: iload 6\n 51: aload_2\n 52: getfield #229 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 55: if_icmple 64\n 58: aload_2\n 59: iload 6\n 61: putfield #229 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 64: aload_0\n 65: new #59 // class kotlin/Pair\n 68: dup\n 69: iload_3\n 70: invokestatic #214 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 73: iload 4\n 75: invokestatic #214 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 78: invokespecial #217 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 81: invokeinterface #230, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 86: pop\n 87: getstatic #236 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 90: areturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #128 // 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 #117 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: bipush 10\n 17: invokestatic #248 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #119 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #134 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 4\n 33: invokeinterface #163, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 7\n 40: aload 7\n 42: invokeinterface #166, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 188\n 50: aload 7\n 52: invokeinterface #167, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 8\n 59: aload 5\n 61: aload 8\n 63: checkcast #250 // 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 #252 // 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 #117 // class java/util/ArrayList\n 90: dup\n 91: aload 11\n 93: invokeinterface #255, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 98: invokespecial #119 // Method java/util/ArrayList.\"<init>\":(I)V\n 101: checkcast #134 // 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 #255, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 121: if_icmpge 169\n 124: aload 13\n 126: iload 16\n 128: invokeinterface #259, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 133: istore 17\n 135: aload 14\n 137: iload 17\n 139: istore 18\n 141: astore 19\n 143: iconst_0\n 144: istore 20\n 146: iload 18\n 148: invokestatic #265 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 151: invokestatic #214 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 154: aload 19\n 156: swap\n 157: invokeinterface #266, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 162: pop\n 163: iinc 16, 1\n 166: goto 112\n 169: aload 14\n 171: checkcast #80 // class java/util/List\n 174: nop\n 175: nop\n 176: aload 21\n 178: swap\n 179: invokeinterface #266, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 184: pop\n 185: goto 40\n 188: aload 5\n 190: checkcast #80 // class java/util/List\n 193: nop\n 194: astore 22\n 196: new #71 // class Matrix\n 199: dup\n 200: aload 22\n 202: invokespecial #269 // Method Matrix.\"<init>\":(Ljava/util/List;)V\n 205: astore_1\n 206: new #271 // class java/util/LinkedHashSet\n 209: dup\n 210: invokespecial #272 // Method java/util/LinkedHashSet.\"<init>\":()V\n 213: checkcast #219 // class java/util/Set\n 216: astore_2\n 217: new #226 // class kotlin/jvm/internal/Ref$IntRef\n 220: dup\n 221: invokespecial #273 // Method kotlin/jvm/internal/Ref$IntRef.\"<init>\":()V\n 224: astore_3\n 225: aload_1\n 226: aload_2\n 227: aload_1\n 228: aload_3\n 229: invokedynamic #319, 0 // InvokeDynamic #1:invoke:(Ljava/util/Set;LMatrix;Lkotlin/jvm/internal/Ref$IntRef;)Lkotlin/jvm/functions/Function3;\n 234: invokevirtual #295 // Method Matrix.forEachIndexed:(Lkotlin/jvm/functions/Function3;)V\n 237: aload_3\n 238: getfield #229 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 241: ireturn\n}\n",
"javap_err": ""
}
] |
jacobprudhomme__advent-of-code-2022__9c2b080/src/day01/Day01.kt
|
import java.io.File
fun main() {
fun readInput(name: String) = File("src/day01", name)
.readLines()
fun part1(input: List<String>): Int {
var maxSoFar = 0
var currentSum = 0
for (line in input) {
if (line.isEmpty()) {
if (currentSum > maxSoFar) {
maxSoFar = currentSum
}
currentSum = 0
} else {
currentSum += line.toInt()
}
}
return if (currentSum > maxSoFar) currentSum else maxSoFar
}
fun part2(input: List<String>): Int {
val maxesSoFar = intArrayOf(0, 0, 0)
var currentSum = 0
for (line in input) {
if (line.isEmpty()) {
val (idx, smallestMaxSoFar) = maxesSoFar.withIndex().minBy { (_, maxVal) -> maxVal }
if (currentSum > smallestMaxSoFar) {
maxesSoFar[idx] = currentSum
}
currentSum = 0
} else {
currentSum += line.toInt()
}
}
val (idx, smallestMaxSoFar) = maxesSoFar.withIndex().minBy { (_, maxVal) -> maxVal }
if (currentSum > smallestMaxSoFar) {
maxesSoFar[idx] = currentSum
}
return maxesSoFar.sum()
}
val input = readInput("input")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "jacobprudhomme__advent-of-code-2022__9c2b080/Day01Kt.class",
"javap": "Compiled from \"Day01.kt\"\npublic final class Day01Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String input\n 2: invokestatic #12 // Method main$readInput:(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: istore_1\n 11: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #28 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #31 // Method main$part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #28 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #35 // Method main:()V\n 3: return\n\n private static final java.util.List<java.lang.String> main$readInput(java.lang.String);\n Code:\n 0: new #40 // class java/io/File\n 3: dup\n 4: ldc #42 // String src/day01\n 6: aload_0\n 7: invokespecial #46 // Method java/io/File.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 10: aconst_null\n 11: iconst_1\n 12: aconst_null\n 13: invokestatic #52 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 16: areturn\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_0\n 3: istore_2\n 4: aload_0\n 5: invokeinterface #61, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 10: astore_3\n 11: aload_3\n 12: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 17: ifeq 75\n 20: aload_3\n 21: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 26: checkcast #73 // class java/lang/String\n 29: astore 4\n 31: aload 4\n 33: checkcast #75 // class java/lang/CharSequence\n 36: invokeinterface #79, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 41: ifne 48\n 44: iconst_1\n 45: goto 49\n 48: iconst_0\n 49: ifeq 64\n 52: iload_2\n 53: iload_1\n 54: if_icmple 59\n 57: iload_2\n 58: istore_1\n 59: iconst_0\n 60: istore_2\n 61: goto 11\n 64: iload_2\n 65: aload 4\n 67: invokestatic #85 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 70: iadd\n 71: istore_2\n 72: goto 11\n 75: iload_2\n 76: iload_1\n 77: if_icmple 84\n 80: iload_2\n 81: goto 85\n 84: iload_1\n 85: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: iconst_3\n 1: newarray int\n 3: astore_2\n 4: aload_2\n 5: iconst_0\n 6: iconst_0\n 7: iastore\n 8: aload_2\n 9: iconst_1\n 10: iconst_0\n 11: iastore\n 12: aload_2\n 13: iconst_2\n 14: iconst_0\n 15: iastore\n 16: aload_2\n 17: astore_1\n 18: iconst_0\n 19: istore_2\n 20: aload_0\n 21: invokeinterface #61, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 26: astore_3\n 27: aload_3\n 28: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 33: ifeq 270\n 36: aload_3\n 37: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 42: checkcast #73 // class java/lang/String\n 45: astore 4\n 47: aload 4\n 49: checkcast #75 // class java/lang/CharSequence\n 52: invokeinterface #79, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 57: ifne 64\n 60: iconst_1\n 61: goto 65\n 64: iconst_0\n 65: ifeq 259\n 68: aload_1\n 69: invokestatic #95 // Method kotlin/collections/ArraysKt.withIndex:([I)Ljava/lang/Iterable;\n 72: astore 6\n 74: iconst_0\n 75: istore 7\n 77: aload 6\n 79: invokeinterface #98, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 84: astore 8\n 86: aload 8\n 88: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 93: ifne 104\n 96: new #100 // class java/util/NoSuchElementException\n 99: dup\n 100: invokespecial #102 // Method java/util/NoSuchElementException.\"<init>\":()V\n 103: athrow\n 104: aload 8\n 106: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 111: astore 9\n 113: aload 8\n 115: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 120: ifne 128\n 123: aload 9\n 125: goto 218\n 128: aload 9\n 130: checkcast #104 // class kotlin/collections/IndexedValue\n 133: astore 10\n 135: iconst_0\n 136: istore 11\n 138: aload 10\n 140: invokevirtual #107 // Method kotlin/collections/IndexedValue.component2:()Ljava/lang/Object;\n 143: checkcast #109 // class java/lang/Number\n 146: invokevirtual #112 // Method java/lang/Number.intValue:()I\n 149: istore 12\n 151: iload 12\n 153: istore 10\n 155: aload 8\n 157: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 162: astore 11\n 164: aload 11\n 166: checkcast #104 // class kotlin/collections/IndexedValue\n 169: astore 12\n 171: iconst_0\n 172: istore 13\n 174: aload 12\n 176: invokevirtual #107 // Method kotlin/collections/IndexedValue.component2:()Ljava/lang/Object;\n 179: checkcast #109 // class java/lang/Number\n 182: invokevirtual #112 // Method java/lang/Number.intValue:()I\n 185: istore 14\n 187: iload 14\n 189: istore 12\n 191: iload 10\n 193: iload 12\n 195: if_icmple 206\n 198: aload 11\n 200: astore 9\n 202: iload 12\n 204: istore 10\n 206: aload 8\n 208: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 213: ifne 155\n 216: aload 9\n 218: checkcast #104 // class kotlin/collections/IndexedValue\n 221: astore 5\n 223: aload 5\n 225: invokevirtual #115 // Method kotlin/collections/IndexedValue.component1:()I\n 228: istore 6\n 230: aload 5\n 232: invokevirtual #107 // Method kotlin/collections/IndexedValue.component2:()Ljava/lang/Object;\n 235: checkcast #109 // class java/lang/Number\n 238: invokevirtual #112 // Method java/lang/Number.intValue:()I\n 241: istore 7\n 243: iload_2\n 244: iload 7\n 246: if_icmple 254\n 249: aload_1\n 250: iload 6\n 252: iload_2\n 253: iastore\n 254: iconst_0\n 255: istore_2\n 256: goto 27\n 259: iload_2\n 260: aload 4\n 262: invokestatic #85 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 265: iadd\n 266: istore_2\n 267: goto 27\n 270: aload_1\n 271: invokestatic #95 // Method kotlin/collections/ArraysKt.withIndex:([I)Ljava/lang/Iterable;\n 274: astore 4\n 276: iconst_0\n 277: istore 5\n 279: aload 4\n 281: invokeinterface #98, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 286: astore 6\n 288: aload 6\n 290: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 295: ifne 306\n 298: new #100 // class java/util/NoSuchElementException\n 301: dup\n 302: invokespecial #102 // Method java/util/NoSuchElementException.\"<init>\":()V\n 305: athrow\n 306: aload 6\n 308: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 313: astore 7\n 315: aload 6\n 317: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 322: ifne 330\n 325: aload 7\n 327: goto 420\n 330: aload 7\n 332: checkcast #104 // class kotlin/collections/IndexedValue\n 335: astore 8\n 337: iconst_0\n 338: istore 9\n 340: aload 8\n 342: invokevirtual #107 // Method kotlin/collections/IndexedValue.component2:()Ljava/lang/Object;\n 345: checkcast #109 // class java/lang/Number\n 348: invokevirtual #112 // Method java/lang/Number.intValue:()I\n 351: istore 10\n 353: iload 10\n 355: istore 8\n 357: aload 6\n 359: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 364: astore 9\n 366: aload 9\n 368: checkcast #104 // class kotlin/collections/IndexedValue\n 371: astore 10\n 373: iconst_0\n 374: istore 11\n 376: aload 10\n 378: invokevirtual #107 // Method kotlin/collections/IndexedValue.component2:()Ljava/lang/Object;\n 381: checkcast #109 // class java/lang/Number\n 384: invokevirtual #112 // Method java/lang/Number.intValue:()I\n 387: istore 12\n 389: iload 12\n 391: istore 10\n 393: iload 8\n 395: iload 10\n 397: if_icmple 408\n 400: aload 9\n 402: astore 7\n 404: iload 10\n 406: istore 8\n 408: aload 6\n 410: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 415: ifne 357\n 418: aload 7\n 420: checkcast #104 // class kotlin/collections/IndexedValue\n 423: astore_3\n 424: aload_3\n 425: invokevirtual #115 // Method kotlin/collections/IndexedValue.component1:()I\n 428: istore 4\n 430: aload_3\n 431: invokevirtual #107 // Method kotlin/collections/IndexedValue.component2:()Ljava/lang/Object;\n 434: checkcast #109 // class java/lang/Number\n 437: invokevirtual #112 // Method java/lang/Number.intValue:()I\n 440: istore 5\n 442: iload_2\n 443: iload 5\n 445: if_icmple 453\n 448: aload_1\n 449: iload 4\n 451: iload_2\n 452: iastore\n 453: aload_1\n 454: invokestatic #119 // Method kotlin/collections/ArraysKt.sum:([I)I\n 457: ireturn\n}\n",
"javap_err": ""
}
] |
nothingelsematters__university__d442a3d/advanced-algorithms/kotlin/src/bO2CMax.kt
|
import java.io.File
import java.util.Scanner
fun scheduleO2CMax(p1: List<Long>, p2: List<Long>): Pair<Long, List<List<Long>>> {
fun fill(schedule: MutableList<Long>, times: List<Long>, indices: Sequence<Int>, init: Long = 0) =
indices.fold(init) { sum, index ->
schedule[index] = sum
sum + times[index]
}
fun i() = p1.asSequence().withIndex().filter { (index, i) -> i <= p2[index] }.map { it.index }
fun j() = p1.asSequence().withIndex().filter { (index, i) -> i > p2[index] }.map { it.index }
val x = i().maxByOrNull { p1[it] }
val y = j().maxByOrNull { p2[it] }
return if (x == null || y != null && p1[x] < p2[y]) {
val (cMax, schedule) = scheduleO2CMax(p2, p1)
cMax to listOf(schedule[1], schedule[0])
} else {
val cMax = maxOf(p1.sum(), p2.sum(), p1.asSequence().zip(p2.asSequence()).maxOf { (a, b) -> a + b })
val first = MutableList(p1.size) { 0L }
fill(first, p1, i() - x)
fill(first, p1, sequenceOf(x), cMax - p1[x])
fill(first, p1, j(), cMax - p1[x] - j().sumOf { p1[it] })
val second = MutableList(p2.size) { 0L }
fill(second, p2, sequenceOf(x))
fill(second, p2, i() - x, p2[x])
fill(second, p2, j(), cMax - j().sumOf { p2[it] })
cMax to listOf(first, second)
}
}
fun main() {
val input = Scanner(File("o2cmax.in").bufferedReader())
val n = input.nextInt()
val p1 = List(n) { input.nextLong() }
val p2 = List(n) { input.nextLong() }
val (c, schedule) = scheduleO2CMax(p1, p2)
File("o2cmax.out").printWriter().use { output ->
output.println(c)
schedule.forEach { line ->
line.forEach { output.print("$it ") }
output.println()
}
}
}
|
[
{
"class_path": "nothingelsematters__university__d442a3d/BO2CMaxKt.class",
"javap": "Compiled from \"bO2CMax.kt\"\npublic final class BO2CMaxKt {\n public static final kotlin.Pair<java.lang.Long, java.util.List<java.util.List<java.lang.Long>>> scheduleO2CMax(java.util.List<java.lang.Long>, java.util.List<java.lang.Long>);\n Code:\n 0: aload_0\n 1: ldc #10 // String p1\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #18 // String p2\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: aload_1\n 14: invokestatic #22 // Method scheduleO2CMax$i:(Ljava/util/List;Ljava/util/List;)Lkotlin/sequences/Sequence;\n 17: astore_3\n 18: iconst_0\n 19: istore 4\n 21: aload_3\n 22: invokeinterface #28, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 27: astore 5\n 29: aload 5\n 31: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 36: ifne 43\n 39: aconst_null\n 40: goto 162\n 43: aload 5\n 45: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 50: astore 6\n 52: aload 5\n 54: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifne 67\n 62: aload 6\n 64: goto 162\n 67: aload 6\n 69: checkcast #40 // class java/lang/Number\n 72: invokevirtual #44 // Method java/lang/Number.intValue:()I\n 75: istore 7\n 77: iconst_0\n 78: istore 9\n 80: aload_0\n 81: iload 7\n 83: invokeinterface #50, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 88: checkcast #40 // class java/lang/Number\n 91: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 94: lstore 7\n 96: aload 5\n 98: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 103: astore 9\n 105: aload 9\n 107: checkcast #40 // class java/lang/Number\n 110: invokevirtual #44 // Method java/lang/Number.intValue:()I\n 113: istore 11\n 115: iconst_0\n 116: istore 13\n 118: aload_0\n 119: iload 11\n 121: invokeinterface #50, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 126: checkcast #40 // class java/lang/Number\n 129: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 132: lstore 11\n 134: lload 7\n 136: lload 11\n 138: lcmp\n 139: ifge 150\n 142: aload 9\n 144: astore 6\n 146: lload 11\n 148: lstore 7\n 150: aload 5\n 152: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 157: ifne 96\n 160: aload 6\n 162: checkcast #56 // class java/lang/Integer\n 165: astore_2\n 166: aload_0\n 167: aload_1\n 168: invokestatic #59 // Method scheduleO2CMax$j:(Ljava/util/List;Ljava/util/List;)Lkotlin/sequences/Sequence;\n 171: astore 4\n 173: iconst_0\n 174: istore 5\n 176: aload 4\n 178: invokeinterface #28, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 183: astore 6\n 185: aload 6\n 187: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 192: ifne 199\n 195: aconst_null\n 196: goto 318\n 199: aload 6\n 201: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 206: astore 7\n 208: aload 6\n 210: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 215: ifne 223\n 218: aload 7\n 220: goto 318\n 223: aload 7\n 225: checkcast #40 // class java/lang/Number\n 228: invokevirtual #44 // Method java/lang/Number.intValue:()I\n 231: istore 9\n 233: iconst_0\n 234: istore 11\n 236: aload_1\n 237: iload 9\n 239: invokeinterface #50, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 244: checkcast #40 // class java/lang/Number\n 247: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 250: lstore 9\n 252: aload 6\n 254: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 259: astore 11\n 261: aload 11\n 263: checkcast #40 // class java/lang/Number\n 266: invokevirtual #44 // Method java/lang/Number.intValue:()I\n 269: istore 13\n 271: iconst_0\n 272: istore 15\n 274: aload_1\n 275: iload 13\n 277: invokeinterface #50, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 282: checkcast #40 // class java/lang/Number\n 285: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 288: lstore 13\n 290: lload 9\n 292: lload 13\n 294: lcmp\n 295: ifge 306\n 298: aload 11\n 300: astore 7\n 302: lload 13\n 304: lstore 9\n 306: aload 6\n 308: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 313: ifne 252\n 316: aload 7\n 318: checkcast #56 // class java/lang/Integer\n 321: astore_3\n 322: aload_2\n 323: ifnull 366\n 326: aload_3\n 327: ifnull 442\n 330: aload_0\n 331: aload_2\n 332: invokevirtual #60 // Method java/lang/Integer.intValue:()I\n 335: invokeinterface #50, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 340: checkcast #40 // class java/lang/Number\n 343: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 346: aload_1\n 347: aload_3\n 348: invokevirtual #60 // Method java/lang/Integer.intValue:()I\n 351: invokeinterface #50, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 356: checkcast #40 // class java/lang/Number\n 359: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 362: lcmp\n 363: ifge 442\n 366: aload_1\n 367: aload_0\n 368: invokestatic #62 // Method scheduleO2CMax:(Ljava/util/List;Ljava/util/List;)Lkotlin/Pair;\n 371: astore 4\n 373: aload 4\n 375: invokevirtual #67 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 378: checkcast #40 // class java/lang/Number\n 381: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 384: lstore 5\n 386: aload 4\n 388: invokevirtual #70 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 391: checkcast #46 // class java/util/List\n 394: astore 7\n 396: lload 5\n 398: invokestatic #76 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 401: iconst_2\n 402: anewarray #46 // class java/util/List\n 405: astore 9\n 407: aload 9\n 409: iconst_0\n 410: aload 7\n 412: iconst_1\n 413: invokeinterface #50, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 418: aastore\n 419: aload 9\n 421: iconst_1\n 422: aload 7\n 424: iconst_0\n 425: invokeinterface #50, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 430: aastore\n 431: aload 9\n 433: invokestatic #82 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 436: invokestatic #88 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 439: goto 1182\n 442: aload_0\n 443: checkcast #90 // class java/lang/Iterable\n 446: invokestatic #94 // Method kotlin/collections/CollectionsKt.sumOfLong:(Ljava/lang/Iterable;)J\n 449: lstore 6\n 451: aload_1\n 452: checkcast #90 // class java/lang/Iterable\n 455: invokestatic #94 // Method kotlin/collections/CollectionsKt.sumOfLong:(Ljava/lang/Iterable;)J\n 458: lstore 9\n 460: aload_0\n 461: checkcast #90 // class java/lang/Iterable\n 464: invokestatic #98 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 467: aload_1\n 468: checkcast #90 // class java/lang/Iterable\n 471: invokestatic #98 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 474: invokestatic #104 // Method kotlin/sequences/SequencesKt.zip:(Lkotlin/sequences/Sequence;Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;\n 477: invokeinterface #28, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 482: astore 15\n 484: aload 15\n 486: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 491: ifne 502\n 494: new #106 // class java/util/NoSuchElementException\n 497: dup\n 498: invokespecial #110 // Method java/util/NoSuchElementException.\"<init>\":()V\n 501: athrow\n 502: aload 15\n 504: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 509: checkcast #64 // class kotlin/Pair\n 512: astore 16\n 514: iconst_0\n 515: istore 18\n 517: aload 16\n 519: invokevirtual #67 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 522: checkcast #40 // class java/lang/Number\n 525: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 528: lstore 20\n 530: aload 16\n 532: invokevirtual #70 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 535: checkcast #40 // class java/lang/Number\n 538: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 541: lstore 22\n 543: lload 20\n 545: lload 22\n 547: ladd\n 548: lstore 16\n 550: aload 15\n 552: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 557: ifeq 623\n 560: aload 15\n 562: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 567: checkcast #64 // class kotlin/Pair\n 570: astore 18\n 572: iconst_0\n 573: istore 24\n 575: aload 18\n 577: invokevirtual #67 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 580: checkcast #40 // class java/lang/Number\n 583: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 586: lstore 25\n 588: aload 18\n 590: invokevirtual #70 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 593: checkcast #40 // class java/lang/Number\n 596: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 599: lstore 27\n 601: lload 25\n 603: lload 27\n 605: ladd\n 606: lstore 18\n 608: lload 16\n 610: lload 18\n 612: lcmp\n 613: ifge 550\n 616: lload 18\n 618: lstore 16\n 620: goto 550\n 623: lload 16\n 625: lstore 13\n 627: lload 6\n 629: lload 9\n 631: lload 13\n 633: invokestatic #116 // Method java/lang/Math.max:(JJ)J\n 636: invokestatic #116 // Method java/lang/Math.max:(JJ)J\n 639: lstore 4\n 641: aload_0\n 642: invokeinterface #119, 1 // InterfaceMethod java/util/List.size:()I\n 647: istore 7\n 649: new #121 // class java/util/ArrayList\n 652: dup\n 653: iload 7\n 655: invokespecial #124 // Method java/util/ArrayList.\"<init>\":(I)V\n 658: astore 9\n 660: iconst_0\n 661: istore 11\n 663: iload 11\n 665: iload 7\n 667: if_icmpge 702\n 670: iload 11\n 672: istore 13\n 674: aload 9\n 676: iload 13\n 678: istore 15\n 680: astore 29\n 682: iconst_0\n 683: istore 16\n 685: lconst_0\n 686: invokestatic #76 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 689: aload 29\n 691: swap\n 692: invokevirtual #128 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 695: pop\n 696: iinc 11, 1\n 699: goto 663\n 702: aload 9\n 704: checkcast #46 // class java/util/List\n 707: astore 6\n 709: aload 6\n 711: aload_0\n 712: aload_0\n 713: aload_1\n 714: invokestatic #22 // Method scheduleO2CMax$i:(Ljava/util/List;Ljava/util/List;)Lkotlin/sequences/Sequence;\n 717: aload_2\n 718: invokestatic #132 // Method kotlin/sequences/SequencesKt.minus:(Lkotlin/sequences/Sequence;Ljava/lang/Object;)Lkotlin/sequences/Sequence;\n 721: lconst_0\n 722: bipush 8\n 724: aconst_null\n 725: invokestatic #136 // Method scheduleO2CMax$fill$default:(Ljava/util/List;Ljava/util/List;Lkotlin/sequences/Sequence;JILjava/lang/Object;)J\n 728: pop2\n 729: aload 6\n 731: aload_0\n 732: iconst_1\n 733: anewarray #56 // class java/lang/Integer\n 736: astore 7\n 738: aload 7\n 740: iconst_0\n 741: aload_2\n 742: aastore\n 743: aload 7\n 745: invokestatic #140 // Method kotlin/sequences/SequencesKt.sequenceOf:([Ljava/lang/Object;)Lkotlin/sequences/Sequence;\n 748: lload 4\n 750: aload_0\n 751: aload_2\n 752: invokevirtual #60 // Method java/lang/Integer.intValue:()I\n 755: invokeinterface #50, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 760: checkcast #40 // class java/lang/Number\n 763: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 766: lsub\n 767: invokestatic #144 // Method scheduleO2CMax$fill:(Ljava/util/List;Ljava/util/List;Lkotlin/sequences/Sequence;J)J\n 770: pop2\n 771: aload 6\n 773: aload_0\n 774: aload_0\n 775: aload_1\n 776: invokestatic #59 // Method scheduleO2CMax$j:(Ljava/util/List;Ljava/util/List;)Lkotlin/sequences/Sequence;\n 779: lload 4\n 781: aload_0\n 782: aload_2\n 783: invokevirtual #60 // Method java/lang/Integer.intValue:()I\n 786: invokeinterface #50, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 791: checkcast #40 // class java/lang/Number\n 794: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 797: lsub\n 798: aload_0\n 799: aload_1\n 800: invokestatic #59 // Method scheduleO2CMax$j:(Ljava/util/List;Ljava/util/List;)Lkotlin/sequences/Sequence;\n 803: astore 7\n 805: lstore 32\n 807: astore 31\n 809: astore 30\n 811: astore 29\n 813: lconst_0\n 814: lstore 9\n 816: aload 7\n 818: invokeinterface #28, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 823: astore 13\n 825: aload 13\n 827: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 832: ifeq 887\n 835: aload 13\n 837: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 842: astore 15\n 844: lload 9\n 846: aload 15\n 848: checkcast #40 // class java/lang/Number\n 851: invokevirtual #44 // Method java/lang/Number.intValue:()I\n 854: istore 16\n 856: lstore 34\n 858: iconst_0\n 859: istore 18\n 861: aload_0\n 862: iload 16\n 864: invokeinterface #50, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 869: checkcast #40 // class java/lang/Number\n 872: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 875: lstore 36\n 877: lload 34\n 879: lload 36\n 881: ladd\n 882: lstore 9\n 884: goto 825\n 887: lload 9\n 889: lstore 34\n 891: aload 29\n 893: aload 30\n 895: aload 31\n 897: lload 32\n 899: lload 34\n 901: lsub\n 902: invokestatic #144 // Method scheduleO2CMax$fill:(Ljava/util/List;Ljava/util/List;Lkotlin/sequences/Sequence;J)J\n 905: pop2\n 906: aload_1\n 907: invokeinterface #119, 1 // InterfaceMethod java/util/List.size:()I\n 912: istore 9\n 914: new #121 // class java/util/ArrayList\n 917: dup\n 918: iload 9\n 920: invokespecial #124 // Method java/util/ArrayList.\"<init>\":(I)V\n 923: astore 11\n 925: iconst_0\n 926: istore 13\n 928: iload 13\n 930: iload 9\n 932: if_icmpge 967\n 935: iload 13\n 937: istore 15\n 939: aload 11\n 941: iload 15\n 943: istore 16\n 945: astore 29\n 947: iconst_0\n 948: istore 18\n 950: lconst_0\n 951: invokestatic #76 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 954: aload 29\n 956: swap\n 957: invokevirtual #128 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 960: pop\n 961: iinc 13, 1\n 964: goto 928\n 967: aload 11\n 969: checkcast #46 // class java/util/List\n 972: astore 7\n 974: aload 7\n 976: aload_1\n 977: iconst_1\n 978: anewarray #56 // class java/lang/Integer\n 981: astore 9\n 983: aload 9\n 985: iconst_0\n 986: aload_2\n 987: aastore\n 988: aload 9\n 990: invokestatic #140 // Method kotlin/sequences/SequencesKt.sequenceOf:([Ljava/lang/Object;)Lkotlin/sequences/Sequence;\n 993: lconst_0\n 994: bipush 8\n 996: aconst_null\n 997: invokestatic #136 // Method scheduleO2CMax$fill$default:(Ljava/util/List;Ljava/util/List;Lkotlin/sequences/Sequence;JILjava/lang/Object;)J\n 1000: pop2\n 1001: aload 7\n 1003: aload_1\n 1004: aload_0\n 1005: aload_1\n 1006: invokestatic #22 // Method scheduleO2CMax$i:(Ljava/util/List;Ljava/util/List;)Lkotlin/sequences/Sequence;\n 1009: aload_2\n 1010: invokestatic #132 // Method kotlin/sequences/SequencesKt.minus:(Lkotlin/sequences/Sequence;Ljava/lang/Object;)Lkotlin/sequences/Sequence;\n 1013: aload_1\n 1014: aload_2\n 1015: invokevirtual #60 // Method java/lang/Integer.intValue:()I\n 1018: invokeinterface #50, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 1023: checkcast #40 // class java/lang/Number\n 1026: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 1029: invokestatic #144 // Method scheduleO2CMax$fill:(Ljava/util/List;Ljava/util/List;Lkotlin/sequences/Sequence;J)J\n 1032: pop2\n 1033: aload 7\n 1035: aload_1\n 1036: aload_0\n 1037: aload_1\n 1038: invokestatic #59 // Method scheduleO2CMax$j:(Ljava/util/List;Ljava/util/List;)Lkotlin/sequences/Sequence;\n 1041: lload 4\n 1043: aload_0\n 1044: aload_1\n 1045: invokestatic #59 // Method scheduleO2CMax$j:(Ljava/util/List;Ljava/util/List;)Lkotlin/sequences/Sequence;\n 1048: astore 9\n 1050: lstore 32\n 1052: astore 31\n 1054: astore 30\n 1056: astore 29\n 1058: lconst_0\n 1059: lstore 11\n 1061: aload 9\n 1063: invokeinterface #28, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 1068: astore 15\n 1070: aload 15\n 1072: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1077: ifeq 1132\n 1080: aload 15\n 1082: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1087: astore 16\n 1089: lload 11\n 1091: aload 16\n 1093: checkcast #40 // class java/lang/Number\n 1096: invokevirtual #44 // Method java/lang/Number.intValue:()I\n 1099: istore 18\n 1101: lstore 34\n 1103: iconst_0\n 1104: istore 20\n 1106: aload_1\n 1107: iload 18\n 1109: invokeinterface #50, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 1114: checkcast #40 // class java/lang/Number\n 1117: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 1120: lstore 36\n 1122: lload 34\n 1124: lload 36\n 1126: ladd\n 1127: lstore 11\n 1129: goto 1070\n 1132: lload 11\n 1134: lstore 34\n 1136: aload 29\n 1138: aload 30\n 1140: aload 31\n 1142: lload 32\n 1144: lload 34\n 1146: lsub\n 1147: invokestatic #144 // Method scheduleO2CMax$fill:(Ljava/util/List;Ljava/util/List;Lkotlin/sequences/Sequence;J)J\n 1150: pop2\n 1151: lload 4\n 1153: invokestatic #76 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 1156: iconst_2\n 1157: anewarray #46 // class java/util/List\n 1160: astore 9\n 1162: aload 9\n 1164: iconst_0\n 1165: aload 6\n 1167: aastore\n 1168: aload 9\n 1170: iconst_1\n 1171: aload 7\n 1173: aastore\n 1174: aload 9\n 1176: invokestatic #82 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 1179: invokestatic #88 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 1182: areturn\n\n public static final void main();\n Code:\n 0: new #181 // class java/util/Scanner\n 3: dup\n 4: new #183 // class java/io/File\n 7: dup\n 8: ldc #185 // String o2cmax.in\n 10: invokespecial #188 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 13: astore_1\n 14: getstatic #194 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 17: astore_2\n 18: sipush 8192\n 21: istore_3\n 22: aload_1\n 23: astore 4\n 25: new #196 // class java/io/InputStreamReader\n 28: dup\n 29: new #198 // class java/io/FileInputStream\n 32: dup\n 33: aload 4\n 35: invokespecial #201 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 38: checkcast #203 // class java/io/InputStream\n 41: aload_2\n 42: invokespecial #206 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 45: checkcast #208 // class java/io/Reader\n 48: astore 4\n 50: aload 4\n 52: instanceof #210 // class java/io/BufferedReader\n 55: ifeq 66\n 58: aload 4\n 60: checkcast #210 // class java/io/BufferedReader\n 63: goto 76\n 66: new #210 // class java/io/BufferedReader\n 69: dup\n 70: aload 4\n 72: iload_3\n 73: invokespecial #213 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 76: checkcast #215 // class java/lang/Readable\n 79: invokespecial #218 // Method java/util/Scanner.\"<init>\":(Ljava/lang/Readable;)V\n 82: astore_0\n 83: aload_0\n 84: invokevirtual #221 // Method java/util/Scanner.nextInt:()I\n 87: istore_1\n 88: new #121 // class java/util/ArrayList\n 91: dup\n 92: iload_1\n 93: invokespecial #124 // Method java/util/ArrayList.\"<init>\":(I)V\n 96: astore_3\n 97: iconst_0\n 98: istore 4\n 100: iload 4\n 102: iload_1\n 103: if_icmpge 140\n 106: iload 4\n 108: istore 5\n 110: aload_3\n 111: iload 5\n 113: istore 6\n 115: astore 25\n 117: iconst_0\n 118: istore 7\n 120: aload_0\n 121: invokevirtual #224 // Method java/util/Scanner.nextLong:()J\n 124: invokestatic #76 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 127: aload 25\n 129: swap\n 130: invokevirtual #128 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 133: pop\n 134: iinc 4, 1\n 137: goto 100\n 140: aload_3\n 141: checkcast #46 // class java/util/List\n 144: astore_2\n 145: new #121 // class java/util/ArrayList\n 148: dup\n 149: iload_1\n 150: invokespecial #124 // Method java/util/ArrayList.\"<init>\":(I)V\n 153: astore 4\n 155: iconst_0\n 156: istore 5\n 158: iload 5\n 160: iload_1\n 161: if_icmpge 199\n 164: iload 5\n 166: istore 6\n 168: aload 4\n 170: iload 6\n 172: istore 7\n 174: astore 25\n 176: iconst_0\n 177: istore 8\n 179: aload_0\n 180: invokevirtual #224 // Method java/util/Scanner.nextLong:()J\n 183: invokestatic #76 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 186: aload 25\n 188: swap\n 189: invokevirtual #128 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 192: pop\n 193: iinc 5, 1\n 196: goto 158\n 199: aload 4\n 201: checkcast #46 // class java/util/List\n 204: astore_3\n 205: aload_2\n 206: aload_3\n 207: invokestatic #62 // Method scheduleO2CMax:(Ljava/util/List;Ljava/util/List;)Lkotlin/Pair;\n 210: astore 4\n 212: aload 4\n 214: invokevirtual #67 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 217: checkcast #40 // class java/lang/Number\n 220: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 223: lstore 5\n 225: aload 4\n 227: invokevirtual #70 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 230: checkcast #46 // class java/util/List\n 233: astore 7\n 235: new #183 // class java/io/File\n 238: dup\n 239: ldc #226 // String o2cmax.out\n 241: invokespecial #188 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 244: astore 8\n 246: getstatic #194 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 249: astore 9\n 251: new #228 // class java/io/PrintWriter\n 254: dup\n 255: aload 8\n 257: astore 10\n 259: sipush 8192\n 262: istore 11\n 264: aload 10\n 266: astore 12\n 268: new #230 // class java/io/OutputStreamWriter\n 271: dup\n 272: new #232 // class java/io/FileOutputStream\n 275: dup\n 276: aload 12\n 278: invokespecial #233 // Method java/io/FileOutputStream.\"<init>\":(Ljava/io/File;)V\n 281: checkcast #235 // class java/io/OutputStream\n 284: aload 9\n 286: invokespecial #238 // Method java/io/OutputStreamWriter.\"<init>\":(Ljava/io/OutputStream;Ljava/nio/charset/Charset;)V\n 289: checkcast #240 // class java/io/Writer\n 292: astore 12\n 294: aload 12\n 296: instanceof #242 // class java/io/BufferedWriter\n 299: ifeq 310\n 302: aload 12\n 304: checkcast #242 // class java/io/BufferedWriter\n 307: goto 321\n 310: new #242 // class java/io/BufferedWriter\n 313: dup\n 314: aload 12\n 316: iload 11\n 318: invokespecial #245 // Method java/io/BufferedWriter.\"<init>\":(Ljava/io/Writer;I)V\n 321: checkcast #240 // class java/io/Writer\n 324: invokespecial #248 // Method java/io/PrintWriter.\"<init>\":(Ljava/io/Writer;)V\n 327: checkcast #250 // class java/io/Closeable\n 330: astore 8\n 332: aconst_null\n 333: astore 9\n 335: nop\n 336: aload 8\n 338: checkcast #228 // class java/io/PrintWriter\n 341: astore 10\n 343: iconst_0\n 344: istore 11\n 346: aload 10\n 348: lload 5\n 350: invokevirtual #254 // Method java/io/PrintWriter.println:(J)V\n 353: aload 7\n 355: checkcast #90 // class java/lang/Iterable\n 358: astore 12\n 360: iconst_0\n 361: istore 13\n 363: aload 12\n 365: invokeinterface #255, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 370: astore 14\n 372: aload 14\n 374: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 379: ifeq 492\n 382: aload 14\n 384: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 389: astore 15\n 391: aload 15\n 393: checkcast #46 // class java/util/List\n 396: astore 16\n 398: iconst_0\n 399: istore 17\n 401: aload 16\n 403: checkcast #90 // class java/lang/Iterable\n 406: astore 18\n 408: iconst_0\n 409: istore 19\n 411: aload 18\n 413: invokeinterface #255, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 418: astore 20\n 420: aload 20\n 422: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 427: ifeq 481\n 430: aload 20\n 432: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 437: astore 21\n 439: aload 21\n 441: checkcast #40 // class java/lang/Number\n 444: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 447: lstore 22\n 449: iconst_0\n 450: istore 24\n 452: aload 10\n 454: new #257 // class java/lang/StringBuilder\n 457: dup\n 458: invokespecial #258 // Method java/lang/StringBuilder.\"<init>\":()V\n 461: lload 22\n 463: invokevirtual #262 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 466: bipush 32\n 468: invokevirtual #265 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 471: invokevirtual #269 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 474: invokevirtual #272 // Method java/io/PrintWriter.print:(Ljava/lang/String;)V\n 477: nop\n 478: goto 420\n 481: nop\n 482: aload 10\n 484: invokevirtual #274 // Method java/io/PrintWriter.println:()V\n 487: nop\n 488: nop\n 489: goto 372\n 492: nop\n 493: nop\n 494: getstatic #280 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 497: astore 10\n 499: aload 8\n 501: aload 9\n 503: invokestatic #286 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 506: goto 530\n 509: astore 11\n 511: aload 11\n 513: astore 9\n 515: aload 11\n 517: athrow\n 518: astore 11\n 520: aload 8\n 522: aload 9\n 524: invokestatic #286 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 527: aload 11\n 529: athrow\n 530: return\n Exception table:\n from to target type\n 335 499 509 Class java/lang/Throwable\n 335 499 518 any\n 509 518 518 any\n 518 520 518 any\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #307 // Method main:()V\n 3: return\n\n private static final long scheduleO2CMax$fill(java.util.List<java.lang.Long>, java.util.List<java.lang.Long>, kotlin.sequences.Sequence<java.lang.Integer>, long);\n Code:\n 0: aload_2\n 1: astore 5\n 3: lload_3\n 4: lstore 6\n 6: iconst_0\n 7: istore 8\n 9: lload 6\n 11: lstore 9\n 13: aload 5\n 15: invokeinterface #28, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 20: astore 11\n 22: aload 11\n 24: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 29: ifeq 94\n 32: aload 11\n 34: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 39: astore 12\n 41: lload 9\n 43: aload 12\n 45: checkcast #40 // class java/lang/Number\n 48: invokevirtual #44 // Method java/lang/Number.intValue:()I\n 51: istore 13\n 53: lstore 14\n 55: iconst_0\n 56: istore 16\n 58: aload_0\n 59: iload 13\n 61: lload 14\n 63: invokestatic #76 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 66: invokeinterface #314, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 71: pop\n 72: lload 14\n 74: aload_1\n 75: iload 13\n 77: invokeinterface #50, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 82: checkcast #40 // class java/lang/Number\n 85: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 88: ladd\n 89: lstore 9\n 91: goto 22\n 94: lload 9\n 96: lreturn\n\n static long scheduleO2CMax$fill$default(java.util.List, java.util.List, kotlin.sequences.Sequence, long, int, java.lang.Object);\n Code:\n 0: iload 5\n 2: bipush 8\n 4: iand\n 5: ifeq 10\n 8: lconst_0\n 9: lstore_3\n 10: aload_0\n 11: aload_1\n 12: aload_2\n 13: lload_3\n 14: invokestatic #144 // Method scheduleO2CMax$fill:(Ljava/util/List;Ljava/util/List;Lkotlin/sequences/Sequence;J)J\n 17: lreturn\n\n private static final boolean scheduleO2CMax$i$lambda$1(java.util.List, kotlin.collections.IndexedValue);\n Code:\n 0: aload_1\n 1: ldc_w #328 // String <destruct>\n 4: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: invokevirtual #332 // Method kotlin/collections/IndexedValue.component1:()I\n 11: istore_2\n 12: aload_1\n 13: invokevirtual #333 // Method kotlin/collections/IndexedValue.component2:()Ljava/lang/Object;\n 16: checkcast #40 // class java/lang/Number\n 19: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 22: lstore_3\n 23: lload_3\n 24: aload_0\n 25: iload_2\n 26: invokeinterface #50, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 31: checkcast #40 // class java/lang/Number\n 34: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 37: lcmp\n 38: ifgt 45\n 41: iconst_1\n 42: goto 46\n 45: iconst_0\n 46: ireturn\n\n private static final int scheduleO2CMax$i$lambda$2(kotlin.collections.IndexedValue);\n Code:\n 0: aload_0\n 1: ldc_w #338 // 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: invokevirtual #341 // Method kotlin/collections/IndexedValue.getIndex:()I\n 11: ireturn\n\n private static final kotlin.sequences.Sequence<java.lang.Integer> scheduleO2CMax$i(java.util.List<java.lang.Long>, java.util.List<java.lang.Long>);\n Code:\n 0: aload_0\n 1: checkcast #90 // class java/lang/Iterable\n 4: invokestatic #98 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 7: invokestatic #347 // Method kotlin/sequences/SequencesKt.withIndex:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;\n 10: aload_1\n 11: invokedynamic #365, 0 // InvokeDynamic #0:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function1;\n 16: invokestatic #369 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 19: invokedynamic #377, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 24: invokestatic #380 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 27: areturn\n\n private static final boolean scheduleO2CMax$j$lambda$3(java.util.List, kotlin.collections.IndexedValue);\n Code:\n 0: aload_1\n 1: ldc_w #328 // String <destruct>\n 4: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: invokevirtual #332 // Method kotlin/collections/IndexedValue.component1:()I\n 11: istore_2\n 12: aload_1\n 13: invokevirtual #333 // Method kotlin/collections/IndexedValue.component2:()Ljava/lang/Object;\n 16: checkcast #40 // class java/lang/Number\n 19: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 22: lstore_3\n 23: lload_3\n 24: aload_0\n 25: iload_2\n 26: invokeinterface #50, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 31: checkcast #40 // class java/lang/Number\n 34: invokevirtual #54 // Method java/lang/Number.longValue:()J\n 37: lcmp\n 38: ifle 45\n 41: iconst_1\n 42: goto 46\n 45: iconst_0\n 46: ireturn\n\n private static final int scheduleO2CMax$j$lambda$4(kotlin.collections.IndexedValue);\n Code:\n 0: aload_0\n 1: ldc_w #338 // 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: invokevirtual #341 // Method kotlin/collections/IndexedValue.getIndex:()I\n 11: ireturn\n\n private static final kotlin.sequences.Sequence<java.lang.Integer> scheduleO2CMax$j(java.util.List<java.lang.Long>, java.util.List<java.lang.Long>);\n Code:\n 0: aload_0\n 1: checkcast #90 // class java/lang/Iterable\n 4: invokestatic #98 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 7: invokestatic #347 // Method kotlin/sequences/SequencesKt.withIndex:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;\n 10: aload_1\n 11: invokedynamic #387, 0 // InvokeDynamic #2:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function1;\n 16: invokestatic #369 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 19: invokedynamic #391, 0 // InvokeDynamic #3:invoke:()Lkotlin/jvm/functions/Function1;\n 24: invokestatic #380 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 27: areturn\n}\n",
"javap_err": ""
}
] |
nothingelsematters__university__d442a3d/advanced-algorithms/kotlin/src/lPIntreeP1LMax.kt
|
import java.io.File
import java.util.Scanner
fun schedulePIntreeP1LMax(
deadlines: MutableList<Int>,
m: Int,
fromTo: Map<Int, Int>,
toFrom: Map<Int, List<Int>>,
): Pair<Int, List<Int>> {
val i = deadlines.indices.find { it !in fromTo }!!
val deque = ArrayDeque<Int>()
deque += i
while (deque.isNotEmpty()) {
val j = deque.removeFirst()
toFrom[j].orEmpty().forEach { k ->
deadlines[k] = minOf(deadlines[k], deadlines[j] - 1)
deque.addLast(k)
}
}
var f = 0
val r = MutableList(deadlines.size) { 0 }
val q = MutableList(deadlines.size) { 0 }
val x = MutableList(deadlines.size) { 0 }
deadlines.asSequence().withIndex().sortedBy { it.value }.map { it.index }.forEach { i ->
val t = maxOf(r[i], f)
x[i] = t
q[t] += 1
if (q[t] == m) {
f = t + 1
}
fromTo[i]?.let { j -> r[j] = maxOf(r[j], t + 1) }
}
val l = deadlines.asSequence().zip(x.asSequence()).maxOf { (d, c) -> c + 1 - d }
return l to x
}
fun main() {
val input = Scanner(File("pintreep1l.in").bufferedReader())
val n = input.nextInt()
val m = input.nextInt()
val deadlines = MutableList(n) { input.nextInt() }
val fromTo = mutableMapOf<Int, Int>()
val toFrom = mutableMapOf<Int, MutableList<Int>>()
repeat(n - 1) {
val from = input.nextInt() - 1
val to = input.nextInt() - 1
fromTo[from] = to
toFrom.getOrPut(to) { mutableListOf() }.add(from)
}
val (lMax, schedule) = schedulePIntreeP1LMax(deadlines, m, fromTo, toFrom)
File("pintreep1l.out").printWriter().use { output ->
output.println(lMax)
schedule.forEach { output.print("$it ") }
}
}
|
[
{
"class_path": "nothingelsematters__university__d442a3d/LPIntreeP1LMaxKt$schedulePIntreeP1LMax$$inlined$sortedBy$1.class",
"javap": "Compiled from \"Comparisons.kt\"\npublic final class LPIntreeP1LMaxKt$schedulePIntreeP1LMax$$inlined$sortedBy$1<T> implements java.util.Comparator {\n public LPIntreeP1LMaxKt$schedulePIntreeP1LMax$$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/collections/IndexedValue\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method kotlin/collections/IndexedValue.getValue:()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/collections/IndexedValue\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/collections/IndexedValue.getValue:()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": ""
},
{
"class_path": "nothingelsematters__university__d442a3d/LPIntreeP1LMaxKt.class",
"javap": "Compiled from \"lPIntreeP1LMax.kt\"\npublic final class LPIntreeP1LMaxKt {\n public static final kotlin.Pair<java.lang.Integer, java.util.List<java.lang.Integer>> schedulePIntreeP1LMax(java.util.List<java.lang.Integer>, int, java.util.Map<java.lang.Integer, java.lang.Integer>, java.util.Map<java.lang.Integer, ? extends java.util.List<java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: ldc #10 // String deadlines\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #18 // String fromTo\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_3\n 13: ldc #20 // String toFrom\n 15: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: aload_0\n 19: checkcast #22 // class java/util/Collection\n 22: invokestatic #28 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 25: checkcast #30 // class java/lang/Iterable\n 28: astore 6\n 30: aload 6\n 32: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 37: astore 7\n 39: aload 7\n 41: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 46: ifeq 99\n 49: aload 7\n 51: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 56: astore 8\n 58: aload 8\n 60: checkcast #46 // class java/lang/Number\n 63: invokevirtual #50 // Method java/lang/Number.intValue:()I\n 66: istore 9\n 68: iconst_0\n 69: istore 10\n 71: iload 9\n 73: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 76: aload_2\n 77: swap\n 78: invokeinterface #62, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 83: ifne 90\n 86: iconst_1\n 87: goto 91\n 90: iconst_0\n 91: ifeq 39\n 94: aload 8\n 96: goto 100\n 99: aconst_null\n 100: dup\n 101: invokestatic #66 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 104: checkcast #46 // class java/lang/Number\n 107: invokevirtual #50 // Method java/lang/Number.intValue:()I\n 110: istore 4\n 112: new #68 // class kotlin/collections/ArrayDeque\n 115: dup\n 116: invokespecial #72 // Method kotlin/collections/ArrayDeque.\"<init>\":()V\n 119: astore 5\n 121: iload 4\n 123: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 126: astore 7\n 128: aload 5\n 130: checkcast #22 // class java/util/Collection\n 133: aload 7\n 135: invokeinterface #75, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 140: pop\n 141: aload 5\n 143: checkcast #22 // class java/util/Collection\n 146: invokeinterface #78, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 151: ifne 158\n 154: iconst_1\n 155: goto 159\n 158: iconst_0\n 159: ifeq 311\n 162: aload 5\n 164: invokevirtual #81 // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;\n 167: checkcast #46 // class java/lang/Number\n 170: invokevirtual #50 // Method java/lang/Number.intValue:()I\n 173: istore 6\n 175: aload_3\n 176: iload 6\n 178: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 181: invokeinterface #85, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 186: checkcast #87 // class java/util/List\n 189: dup\n 190: ifnonnull 197\n 193: pop\n 194: invokestatic #91 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 197: checkcast #30 // class java/lang/Iterable\n 200: astore 7\n 202: nop\n 203: iconst_0\n 204: istore 8\n 206: aload 7\n 208: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 213: astore 9\n 215: aload 9\n 217: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 222: ifeq 307\n 225: aload 9\n 227: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 232: astore 10\n 234: aload 10\n 236: checkcast #46 // class java/lang/Number\n 239: invokevirtual #50 // Method java/lang/Number.intValue:()I\n 242: istore 11\n 244: iconst_0\n 245: istore 12\n 247: aload_0\n 248: iload 11\n 250: aload_0\n 251: iload 11\n 253: invokeinterface #94, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 258: checkcast #46 // class java/lang/Number\n 261: invokevirtual #50 // Method java/lang/Number.intValue:()I\n 264: aload_0\n 265: iload 6\n 267: invokeinterface #94, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 272: checkcast #46 // class java/lang/Number\n 275: invokevirtual #50 // Method java/lang/Number.intValue:()I\n 278: iconst_1\n 279: isub\n 280: invokestatic #100 // Method java/lang/Math.min:(II)I\n 283: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 286: invokeinterface #104, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 291: pop\n 292: aload 5\n 294: iload 11\n 296: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 299: invokevirtual #107 // Method kotlin/collections/ArrayDeque.addLast:(Ljava/lang/Object;)V\n 302: nop\n 303: nop\n 304: goto 215\n 307: nop\n 308: goto 141\n 311: iconst_0\n 312: istore 6\n 314: aload_0\n 315: invokeinterface #110, 1 // InterfaceMethod java/util/List.size:()I\n 320: istore 8\n 322: new #112 // class java/util/ArrayList\n 325: dup\n 326: iload 8\n 328: invokespecial #115 // Method java/util/ArrayList.\"<init>\":(I)V\n 331: astore 9\n 333: iconst_0\n 334: istore 10\n 336: iload 10\n 338: iload 8\n 340: if_icmpge 375\n 343: iload 10\n 345: istore 11\n 347: aload 9\n 349: iload 11\n 351: istore 12\n 353: astore 19\n 355: iconst_0\n 356: istore 13\n 358: iconst_0\n 359: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 362: aload 19\n 364: swap\n 365: invokevirtual #116 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 368: pop\n 369: iinc 10, 1\n 372: goto 336\n 375: aload 9\n 377: checkcast #87 // class java/util/List\n 380: astore 7\n 382: aload_0\n 383: invokeinterface #110, 1 // InterfaceMethod java/util/List.size:()I\n 388: istore 9\n 390: new #112 // class java/util/ArrayList\n 393: dup\n 394: iload 9\n 396: invokespecial #115 // Method java/util/ArrayList.\"<init>\":(I)V\n 399: astore 10\n 401: iconst_0\n 402: istore 11\n 404: iload 11\n 406: iload 9\n 408: if_icmpge 443\n 411: iload 11\n 413: istore 12\n 415: aload 10\n 417: iload 12\n 419: istore 13\n 421: astore 19\n 423: iconst_0\n 424: istore 14\n 426: iconst_0\n 427: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 430: aload 19\n 432: swap\n 433: invokevirtual #116 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 436: pop\n 437: iinc 11, 1\n 440: goto 404\n 443: aload 10\n 445: checkcast #87 // class java/util/List\n 448: astore 8\n 450: aload_0\n 451: invokeinterface #110, 1 // InterfaceMethod java/util/List.size:()I\n 456: istore 10\n 458: new #112 // class java/util/ArrayList\n 461: dup\n 462: iload 10\n 464: invokespecial #115 // Method java/util/ArrayList.\"<init>\":(I)V\n 467: astore 11\n 469: iconst_0\n 470: istore 12\n 472: iload 12\n 474: iload 10\n 476: if_icmpge 511\n 479: iload 12\n 481: istore 13\n 483: aload 11\n 485: iload 13\n 487: istore 14\n 489: astore 19\n 491: iconst_0\n 492: istore 15\n 494: iconst_0\n 495: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 498: aload 19\n 500: swap\n 501: invokevirtual #116 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 504: pop\n 505: iinc 12, 1\n 508: goto 472\n 511: aload 11\n 513: checkcast #87 // class java/util/List\n 516: astore 9\n 518: aload_0\n 519: checkcast #30 // class java/lang/Iterable\n 522: invokestatic #120 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 525: invokestatic #126 // Method kotlin/sequences/SequencesKt.withIndex:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;\n 528: astore 10\n 530: iconst_0\n 531: istore 11\n 533: aload 10\n 535: new #128 // class LPIntreeP1LMaxKt$schedulePIntreeP1LMax$$inlined$sortedBy$1\n 538: dup\n 539: invokespecial #129 // Method LPIntreeP1LMaxKt$schedulePIntreeP1LMax$$inlined$sortedBy$1.\"<init>\":()V\n 542: checkcast #131 // class java/util/Comparator\n 545: invokestatic #135 // Method kotlin/sequences/SequencesKt.sortedWith:(Lkotlin/sequences/Sequence;Ljava/util/Comparator;)Lkotlin/sequences/Sequence;\n 548: invokedynamic #154, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 553: invokestatic #158 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 556: astore 10\n 558: iconst_0\n 559: istore 11\n 561: aload 10\n 563: invokeinterface #161, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 568: astore 12\n 570: aload 12\n 572: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 577: ifeq 768\n 580: aload 12\n 582: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 587: astore 13\n 589: aload 13\n 591: checkcast #46 // class java/lang/Number\n 594: invokevirtual #50 // Method java/lang/Number.intValue:()I\n 597: istore 14\n 599: iconst_0\n 600: istore 15\n 602: aload 7\n 604: iload 14\n 606: invokeinterface #94, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 611: checkcast #46 // class java/lang/Number\n 614: invokevirtual #50 // Method java/lang/Number.intValue:()I\n 617: iload 6\n 619: invokestatic #164 // Method java/lang/Math.max:(II)I\n 622: istore 16\n 624: aload 9\n 626: iload 14\n 628: iload 16\n 630: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 633: invokeinterface #104, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 638: pop\n 639: aload 8\n 641: iload 16\n 643: aload 8\n 645: iload 16\n 647: invokeinterface #94, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 652: checkcast #46 // class java/lang/Number\n 655: invokevirtual #50 // Method java/lang/Number.intValue:()I\n 658: iconst_1\n 659: iadd\n 660: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 663: invokeinterface #104, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 668: pop\n 669: aload 8\n 671: iload 16\n 673: invokeinterface #94, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 678: checkcast #46 // class java/lang/Number\n 681: invokevirtual #50 // Method java/lang/Number.intValue:()I\n 684: iload_1\n 685: if_icmpne 694\n 688: iload 16\n 690: iconst_1\n 691: iadd\n 692: istore 6\n 694: aload_2\n 695: iload 14\n 697: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 700: invokeinterface #85, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 705: checkcast #52 // class java/lang/Integer\n 708: dup\n 709: ifnull 761\n 712: checkcast #46 // class java/lang/Number\n 715: invokevirtual #50 // Method java/lang/Number.intValue:()I\n 718: istore 17\n 720: iconst_0\n 721: istore 18\n 723: aload 7\n 725: iload 17\n 727: aload 7\n 729: iload 17\n 731: invokeinterface #94, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 736: checkcast #46 // class java/lang/Number\n 739: invokevirtual #50 // Method java/lang/Number.intValue:()I\n 742: iload 16\n 744: iconst_1\n 745: iadd\n 746: invokestatic #164 // Method java/lang/Math.max:(II)I\n 749: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 752: invokeinterface #104, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 757: pop\n 758: goto 763\n 761: pop\n 762: nop\n 763: nop\n 764: nop\n 765: goto 570\n 768: nop\n 769: aload_0\n 770: checkcast #30 // class java/lang/Iterable\n 773: invokestatic #120 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 776: aload 9\n 778: checkcast #30 // class java/lang/Iterable\n 781: invokestatic #120 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 784: invokestatic #168 // Method kotlin/sequences/SequencesKt.zip:(Lkotlin/sequences/Sequence;Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;\n 787: invokeinterface #161, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 792: astore 12\n 794: aload 12\n 796: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 801: ifne 812\n 804: new #170 // class java/util/NoSuchElementException\n 807: dup\n 808: invokespecial #171 // Method java/util/NoSuchElementException.\"<init>\":()V\n 811: athrow\n 812: aload 12\n 814: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 819: checkcast #173 // class kotlin/Pair\n 822: astore 13\n 824: iconst_0\n 825: istore 14\n 827: aload 13\n 829: invokevirtual #176 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 832: checkcast #46 // class java/lang/Number\n 835: invokevirtual #50 // Method java/lang/Number.intValue:()I\n 838: istore 15\n 840: aload 13\n 842: invokevirtual #179 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 845: checkcast #46 // class java/lang/Number\n 848: invokevirtual #50 // Method java/lang/Number.intValue:()I\n 851: istore 16\n 853: iload 16\n 855: iconst_1\n 856: iadd\n 857: iload 15\n 859: isub\n 860: istore 13\n 862: aload 12\n 864: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 869: ifeq 936\n 872: aload 12\n 874: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 879: checkcast #173 // class kotlin/Pair\n 882: astore 14\n 884: iconst_0\n 885: istore 15\n 887: aload 14\n 889: invokevirtual #176 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 892: checkcast #46 // class java/lang/Number\n 895: invokevirtual #50 // Method java/lang/Number.intValue:()I\n 898: istore 16\n 900: aload 14\n 902: invokevirtual #179 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 905: checkcast #46 // class java/lang/Number\n 908: invokevirtual #50 // Method java/lang/Number.intValue:()I\n 911: istore 17\n 913: iload 17\n 915: iconst_1\n 916: iadd\n 917: iload 16\n 919: isub\n 920: istore 14\n 922: iload 13\n 924: iload 14\n 926: if_icmpge 862\n 929: iload 14\n 931: istore 13\n 933: goto 862\n 936: iload 13\n 938: istore 10\n 940: iload 10\n 942: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 945: aload 9\n 947: invokestatic #185 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 950: areturn\n\n public static final void main();\n Code:\n 0: new #224 // class java/util/Scanner\n 3: dup\n 4: new #226 // class java/io/File\n 7: dup\n 8: ldc #228 // String pintreep1l.in\n 10: invokespecial #231 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 13: astore_1\n 14: getstatic #237 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 17: astore_2\n 18: sipush 8192\n 21: istore_3\n 22: aload_1\n 23: astore 4\n 25: new #239 // class java/io/InputStreamReader\n 28: dup\n 29: new #241 // class java/io/FileInputStream\n 32: dup\n 33: aload 4\n 35: invokespecial #244 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 38: checkcast #246 // class java/io/InputStream\n 41: aload_2\n 42: invokespecial #249 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 45: checkcast #251 // class java/io/Reader\n 48: astore 4\n 50: aload 4\n 52: instanceof #253 // class java/io/BufferedReader\n 55: ifeq 66\n 58: aload 4\n 60: checkcast #253 // class java/io/BufferedReader\n 63: goto 76\n 66: new #253 // class java/io/BufferedReader\n 69: dup\n 70: aload 4\n 72: iload_3\n 73: invokespecial #256 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 76: checkcast #258 // class java/lang/Readable\n 79: invokespecial #261 // Method java/util/Scanner.\"<init>\":(Ljava/lang/Readable;)V\n 82: astore_0\n 83: aload_0\n 84: invokevirtual #264 // Method java/util/Scanner.nextInt:()I\n 87: istore_1\n 88: aload_0\n 89: invokevirtual #264 // Method java/util/Scanner.nextInt:()I\n 92: istore_2\n 93: new #112 // class java/util/ArrayList\n 96: dup\n 97: iload_1\n 98: invokespecial #115 // Method java/util/ArrayList.\"<init>\":(I)V\n 101: astore 4\n 103: iconst_0\n 104: istore 5\n 106: iload 5\n 108: iload_1\n 109: if_icmpge 147\n 112: iload 5\n 114: istore 6\n 116: aload 4\n 118: iload 6\n 120: istore 7\n 122: astore 19\n 124: iconst_0\n 125: istore 8\n 127: aload_0\n 128: invokevirtual #264 // Method java/util/Scanner.nextInt:()I\n 131: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 134: aload 19\n 136: swap\n 137: invokevirtual #116 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 140: pop\n 141: iinc 5, 1\n 144: goto 106\n 147: aload 4\n 149: checkcast #87 // class java/util/List\n 152: astore_3\n 153: new #266 // class java/util/LinkedHashMap\n 156: dup\n 157: invokespecial #267 // Method java/util/LinkedHashMap.\"<init>\":()V\n 160: checkcast #58 // class java/util/Map\n 163: astore 4\n 165: new #266 // class java/util/LinkedHashMap\n 168: dup\n 169: invokespecial #267 // Method java/util/LinkedHashMap.\"<init>\":()V\n 172: checkcast #58 // class java/util/Map\n 175: astore 5\n 177: iload_1\n 178: iconst_1\n 179: isub\n 180: istore 6\n 182: iconst_0\n 183: istore 7\n 185: iload 7\n 187: iload 6\n 189: if_icmpge 328\n 192: iload 7\n 194: istore 8\n 196: iconst_0\n 197: istore 9\n 199: aload_0\n 200: invokevirtual #264 // Method java/util/Scanner.nextInt:()I\n 203: iconst_1\n 204: isub\n 205: istore 10\n 207: aload_0\n 208: invokevirtual #264 // Method java/util/Scanner.nextInt:()I\n 211: iconst_1\n 212: isub\n 213: istore 11\n 215: iload 10\n 217: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 220: astore 12\n 222: iload 11\n 224: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 227: astore 13\n 229: aload 4\n 231: aload 12\n 233: aload 13\n 235: invokeinterface #271, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 240: pop\n 241: aload 5\n 243: astore 14\n 245: iload 11\n 247: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 250: astore 12\n 252: iconst_0\n 253: istore 13\n 255: aload 14\n 257: aload 12\n 259: invokeinterface #85, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 264: astore 15\n 266: aload 15\n 268: ifnonnull 304\n 271: iconst_0\n 272: istore 16\n 274: new #112 // class java/util/ArrayList\n 277: dup\n 278: invokespecial #272 // Method java/util/ArrayList.\"<init>\":()V\n 281: checkcast #87 // class java/util/List\n 284: nop\n 285: astore 16\n 287: aload 14\n 289: aload 12\n 291: aload 16\n 293: invokeinterface #271, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 298: pop\n 299: aload 16\n 301: goto 306\n 304: aload 15\n 306: nop\n 307: checkcast #87 // class java/util/List\n 310: iload 10\n 312: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 315: invokeinterface #273, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 320: pop\n 321: nop\n 322: iinc 7, 1\n 325: goto 185\n 328: aload_3\n 329: iload_2\n 330: aload 4\n 332: aload 5\n 334: invokestatic #275 // Method schedulePIntreeP1LMax:(Ljava/util/List;ILjava/util/Map;Ljava/util/Map;)Lkotlin/Pair;\n 337: astore 6\n 339: aload 6\n 341: invokevirtual #176 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 344: checkcast #46 // class java/lang/Number\n 347: invokevirtual #50 // Method java/lang/Number.intValue:()I\n 350: istore 7\n 352: aload 6\n 354: invokevirtual #179 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 357: checkcast #87 // class java/util/List\n 360: astore 8\n 362: new #226 // class java/io/File\n 365: dup\n 366: ldc_w #277 // String pintreep1l.out\n 369: invokespecial #231 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 372: astore 9\n 374: getstatic #237 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 377: astore 10\n 379: new #279 // class java/io/PrintWriter\n 382: dup\n 383: aload 9\n 385: astore 11\n 387: sipush 8192\n 390: istore 12\n 392: aload 11\n 394: astore 13\n 396: new #281 // class java/io/OutputStreamWriter\n 399: dup\n 400: new #283 // class java/io/FileOutputStream\n 403: dup\n 404: aload 13\n 406: invokespecial #284 // Method java/io/FileOutputStream.\"<init>\":(Ljava/io/File;)V\n 409: checkcast #286 // class java/io/OutputStream\n 412: aload 10\n 414: invokespecial #289 // Method java/io/OutputStreamWriter.\"<init>\":(Ljava/io/OutputStream;Ljava/nio/charset/Charset;)V\n 417: checkcast #291 // class java/io/Writer\n 420: astore 13\n 422: aload 13\n 424: instanceof #293 // class java/io/BufferedWriter\n 427: ifeq 438\n 430: aload 13\n 432: checkcast #293 // class java/io/BufferedWriter\n 435: goto 449\n 438: new #293 // class java/io/BufferedWriter\n 441: dup\n 442: aload 13\n 444: iload 12\n 446: invokespecial #296 // Method java/io/BufferedWriter.\"<init>\":(Ljava/io/Writer;I)V\n 449: checkcast #291 // class java/io/Writer\n 452: invokespecial #299 // Method java/io/PrintWriter.\"<init>\":(Ljava/io/Writer;)V\n 455: checkcast #301 // class java/io/Closeable\n 458: astore 9\n 460: aconst_null\n 461: astore 10\n 463: nop\n 464: aload 9\n 466: checkcast #279 // class java/io/PrintWriter\n 469: astore 11\n 471: iconst_0\n 472: istore 12\n 474: aload 11\n 476: iload 7\n 478: invokevirtual #304 // Method java/io/PrintWriter.println:(I)V\n 481: aload 8\n 483: checkcast #30 // class java/lang/Iterable\n 486: astore 13\n 488: iconst_0\n 489: istore 14\n 491: aload 13\n 493: invokeinterface #34, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 498: astore 15\n 500: aload 15\n 502: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 507: ifeq 561\n 510: aload 15\n 512: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 517: astore 16\n 519: aload 16\n 521: checkcast #46 // class java/lang/Number\n 524: invokevirtual #50 // Method java/lang/Number.intValue:()I\n 527: istore 17\n 529: iconst_0\n 530: istore 18\n 532: aload 11\n 534: new #306 // class java/lang/StringBuilder\n 537: dup\n 538: invokespecial #307 // Method java/lang/StringBuilder.\"<init>\":()V\n 541: iload 17\n 543: invokevirtual #311 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 546: bipush 32\n 548: invokevirtual #314 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 551: invokevirtual #318 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 554: invokevirtual #321 // Method java/io/PrintWriter.print:(Ljava/lang/String;)V\n 557: nop\n 558: goto 500\n 561: nop\n 562: nop\n 563: getstatic #327 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 566: astore 11\n 568: aload 9\n 570: aload 10\n 572: invokestatic #333 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 575: goto 599\n 578: astore 12\n 580: aload 12\n 582: astore 10\n 584: aload 12\n 586: athrow\n 587: astore 12\n 589: aload 9\n 591: aload 10\n 593: invokestatic #333 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 596: aload 12\n 598: athrow\n 599: return\n Exception table:\n from to target type\n 463 568 578 Class java/lang/Throwable\n 463 568 587 any\n 578 587 587 any\n 587 589 587 any\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #356 // Method main:()V\n 3: return\n\n private static final int schedulePIntreeP1LMax$lambda$6(kotlin.collections.IndexedValue);\n Code:\n 0: aload_0\n 1: ldc_w #359 // 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: invokevirtual #364 // Method kotlin/collections/IndexedValue.getIndex:()I\n 11: ireturn\n}\n",
"javap_err": ""
}
] |
nothingelsematters__university__d442a3d/advanced-algorithms/kotlin/src/fP1PrecFMax.kt
|
import java.io.File
import java.math.BigInteger
import java.util.Scanner
private fun scheduleP1PrecFMax(
times: List<Int>,
functions: List<(Int) -> BigInteger>,
prec: Map<Int, List<Int>>,
): Pair<BigInteger, List<Int>> {
val n = times.size
val children = MutableList(n) { 0 }
prec.forEach { (_, row) -> row.forEach { i -> children[i] += 1 } }
val excluded = (0 until n).toMutableSet()
var p = times.sum()
val reverseSchedule = MutableList(n) { 0 }
for (k in n - 1 downTo 0) {
val j = excluded.asSequence().filter { children[it] == 0 }.minBy { functions[it](p) }
excluded.remove(j)
reverseSchedule[k] = j
p -= times[j]
prec[j]?.forEach { children[it] -= 1 }
}
val schedule = MutableList(n) { 0 }
reverseSchedule.fold(0) { sum, it ->
schedule[it] = sum
sum + times[it]
}
val fMaxMin = (0 until n)
.maxOfOrNull { functions[it](schedule[it] + times[it]) } ?: 0.toBigInteger()
return fMaxMin to schedule
}
fun main() {
val inputFile = Scanner(File("p1precfmax.in").bufferedReader())
val n = inputFile.nextInt()
val times = List(n) { inputFile.nextInt() }
val functions = List(n) {
val m = inputFile.nextInt()
val coefficients = List(m + 1) { inputFile.nextInt() };
{ x: Int ->
coefficients.asSequence()
.withIndex()
.sumOf { (i, it) -> x.toBigInteger().pow(coefficients.size - 1 - i) * it.toBigInteger() }
}
}
val d = inputFile.nextInt()
val prec = buildMap {
for (i in 0 until d) {
val from = inputFile.nextInt() - 1
val to = inputFile.nextInt() - 1
val list: MutableList<Int> = getOrPut(to) { mutableListOf() }
list += from
}
}
val (fMaxMin, schedule) = scheduleP1PrecFMax(times, functions, prec)
File("p1precfmax.out").printWriter().use { output ->
output.println(fMaxMin.toString())
for (i in schedule) {
output.print("$i ")
}
}
}
|
[
{
"class_path": "nothingelsematters__university__d442a3d/FP1PrecFMaxKt.class",
"javap": "Compiled from \"fP1PrecFMax.kt\"\npublic final class FP1PrecFMaxKt {\n private static final kotlin.Pair<java.math.BigInteger, java.util.List<java.lang.Integer>> scheduleP1PrecFMax(java.util.List<java.lang.Integer>, java.util.List<? extends kotlin.jvm.functions.Function1<? super java.lang.Integer, ? extends java.math.BigInteger>>, java.util.Map<java.lang.Integer, ? extends java.util.List<java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: invokeinterface #13, 1 // InterfaceMethod java/util/List.size:()I\n 6: istore_3\n 7: new #15 // class java/util/ArrayList\n 10: dup\n 11: iload_3\n 12: invokespecial #19 // Method java/util/ArrayList.\"<init>\":(I)V\n 15: astore 5\n 17: iconst_0\n 18: istore 6\n 20: iload 6\n 22: iload_3\n 23: if_icmpge 58\n 26: iload 6\n 28: istore 7\n 30: aload 5\n 32: iload 7\n 34: istore 8\n 36: astore 18\n 38: iconst_0\n 39: istore 9\n 41: iconst_0\n 42: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 45: aload 18\n 47: swap\n 48: invokevirtual #29 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 51: pop\n 52: iinc 6, 1\n 55: goto 20\n 58: aload 5\n 60: checkcast #9 // class java/util/List\n 63: astore 4\n 65: aload_2\n 66: astore 5\n 68: iconst_0\n 69: istore 6\n 71: aload 5\n 73: invokeinterface #35, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 78: invokeinterface #41, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 83: astore 7\n 85: aload 7\n 87: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 92: ifeq 217\n 95: aload 7\n 97: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 102: checkcast #53 // class java/util/Map$Entry\n 105: astore 8\n 107: aload 8\n 109: astore 9\n 111: iconst_0\n 112: istore 10\n 114: aload 9\n 116: invokeinterface #56, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 121: checkcast #9 // class java/util/List\n 124: astore 11\n 126: aload 11\n 128: checkcast #58 // class java/lang/Iterable\n 131: astore 12\n 133: iconst_0\n 134: istore 13\n 136: aload 12\n 138: invokeinterface #59, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 143: astore 14\n 145: aload 14\n 147: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 152: ifeq 211\n 155: aload 14\n 157: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 162: astore 15\n 164: aload 15\n 166: checkcast #61 // class java/lang/Number\n 169: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 172: istore 16\n 174: iconst_0\n 175: istore 17\n 177: aload 4\n 179: iload 16\n 181: aload 4\n 183: iload 16\n 185: invokeinterface #68, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 190: checkcast #61 // class java/lang/Number\n 193: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 196: iconst_1\n 197: iadd\n 198: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 201: invokeinterface #72, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 206: pop\n 207: nop\n 208: goto 145\n 211: nop\n 212: nop\n 213: nop\n 214: goto 85\n 217: nop\n 218: iconst_0\n 219: iload_3\n 220: invokestatic #78 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 223: checkcast #58 // class java/lang/Iterable\n 226: invokestatic #84 // Method kotlin/collections/CollectionsKt.toMutableSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 229: astore 5\n 231: iconst_0\n 232: istore 6\n 234: aload_0\n 235: checkcast #58 // class java/lang/Iterable\n 238: invokestatic #88 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 241: istore 6\n 243: new #15 // class java/util/ArrayList\n 246: dup\n 247: iload_3\n 248: invokespecial #19 // Method java/util/ArrayList.\"<init>\":(I)V\n 251: astore 8\n 253: iconst_0\n 254: istore 9\n 256: iload 9\n 258: iload_3\n 259: if_icmpge 294\n 262: iload 9\n 264: istore 10\n 266: aload 8\n 268: iload 10\n 270: istore 11\n 272: astore 18\n 274: iconst_0\n 275: istore 12\n 277: iconst_0\n 278: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 281: aload 18\n 283: swap\n 284: invokevirtual #29 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 287: pop\n 288: iinc 9, 1\n 291: goto 256\n 294: aload 8\n 296: checkcast #9 // class java/util/List\n 299: astore 7\n 301: iload_3\n 302: iconst_1\n 303: isub\n 304: istore 8\n 306: iconst_m1\n 307: iload 8\n 309: if_icmpge 679\n 312: aload 5\n 314: checkcast #58 // class java/lang/Iterable\n 317: invokestatic #92 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 320: aload 4\n 322: invokedynamic #112, 0 // InvokeDynamic #0:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function1;\n 327: invokestatic #118 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 330: astore 10\n 332: iconst_0\n 333: istore 11\n 335: aload 10\n 337: invokeinterface #121, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 342: astore 12\n 344: aload 12\n 346: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 351: ifne 362\n 354: new #123 // class java/util/NoSuchElementException\n 357: dup\n 358: invokespecial #126 // Method java/util/NoSuchElementException.\"<init>\":()V\n 361: athrow\n 362: aload 12\n 364: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 369: astore 13\n 371: aload 12\n 373: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 378: ifne 386\n 381: aload 13\n 383: goto 511\n 386: aload 13\n 388: checkcast #61 // class java/lang/Number\n 391: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 394: istore 14\n 396: iconst_0\n 397: istore 15\n 399: aload_1\n 400: iload 14\n 402: invokeinterface #68, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 407: checkcast #128 // class kotlin/jvm/functions/Function1\n 410: iload 6\n 412: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 415: invokeinterface #130, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 420: checkcast #132 // class java/math/BigInteger\n 423: checkcast #134 // class java/lang/Comparable\n 426: astore 14\n 428: aload 12\n 430: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 435: astore 15\n 437: aload 15\n 439: checkcast #61 // class java/lang/Number\n 442: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 445: istore 16\n 447: iconst_0\n 448: istore 17\n 450: aload_1\n 451: iload 16\n 453: invokeinterface #68, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 458: checkcast #128 // class kotlin/jvm/functions/Function1\n 461: iload 6\n 463: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 466: invokeinterface #130, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 471: checkcast #132 // class java/math/BigInteger\n 474: checkcast #134 // class java/lang/Comparable\n 477: astore 16\n 479: aload 14\n 481: aload 16\n 483: invokeinterface #138, 2 // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I\n 488: ifle 499\n 491: aload 15\n 493: astore 13\n 495: aload 16\n 497: astore 14\n 499: aload 12\n 501: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 506: ifne 428\n 509: aload 13\n 511: checkcast #61 // class java/lang/Number\n 514: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 517: istore 9\n 519: aload 5\n 521: iload 9\n 523: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 526: invokeinterface #141, 2 // InterfaceMethod java/util/Set.remove:(Ljava/lang/Object;)Z\n 531: pop\n 532: aload 7\n 534: iload 8\n 536: iload 9\n 538: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 541: invokeinterface #72, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 546: pop\n 547: iload 6\n 549: aload_0\n 550: iload 9\n 552: invokeinterface #68, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 557: checkcast #61 // class java/lang/Number\n 560: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 563: isub\n 564: istore 6\n 566: aload_2\n 567: iload 9\n 569: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 572: invokeinterface #143, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 577: checkcast #9 // class java/util/List\n 580: dup\n 581: ifnull 671\n 584: checkcast #58 // class java/lang/Iterable\n 587: astore 11\n 589: iconst_0\n 590: istore 12\n 592: aload 11\n 594: invokeinterface #59, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 599: astore 13\n 601: aload 13\n 603: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 608: ifeq 667\n 611: aload 13\n 613: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 618: astore 14\n 620: aload 14\n 622: checkcast #61 // class java/lang/Number\n 625: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 628: istore 15\n 630: iconst_0\n 631: istore 16\n 633: aload 4\n 635: iload 15\n 637: aload 4\n 639: iload 15\n 641: invokeinterface #68, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 646: checkcast #61 // class java/lang/Number\n 649: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 652: iconst_1\n 653: isub\n 654: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 657: invokeinterface #72, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 662: pop\n 663: nop\n 664: goto 601\n 667: nop\n 668: goto 673\n 671: pop\n 672: nop\n 673: iinc 8, -1\n 676: goto 306\n 679: new #15 // class java/util/ArrayList\n 682: dup\n 683: iload_3\n 684: invokespecial #19 // Method java/util/ArrayList.\"<init>\":(I)V\n 687: astore 9\n 689: iconst_0\n 690: istore 10\n 692: iload 10\n 694: iload_3\n 695: if_icmpge 730\n 698: iload 10\n 700: istore 11\n 702: aload 9\n 704: iload 11\n 706: istore 12\n 708: astore 18\n 710: iconst_0\n 711: istore 13\n 713: iconst_0\n 714: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 717: aload 18\n 719: swap\n 720: invokevirtual #29 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 723: pop\n 724: iinc 10, 1\n 727: goto 692\n 730: aload 9\n 732: checkcast #9 // class java/util/List\n 735: astore 8\n 737: aload 7\n 739: checkcast #58 // class java/lang/Iterable\n 742: astore 9\n 744: iconst_0\n 745: istore 10\n 747: iconst_0\n 748: istore 11\n 750: iload 10\n 752: istore 12\n 754: aload 9\n 756: invokeinterface #59, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 761: astore 13\n 763: aload 13\n 765: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 770: ifeq 836\n 773: aload 13\n 775: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 780: astore 14\n 782: iload 12\n 784: aload 14\n 786: checkcast #61 // class java/lang/Number\n 789: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 792: istore 15\n 794: istore 16\n 796: iconst_0\n 797: istore 17\n 799: aload 8\n 801: iload 15\n 803: iload 16\n 805: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 808: invokeinterface #72, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 813: pop\n 814: iload 16\n 816: aload_0\n 817: iload 15\n 819: invokeinterface #68, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 824: checkcast #61 // class java/lang/Number\n 827: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 830: iadd\n 831: istore 12\n 833: goto 763\n 836: nop\n 837: iconst_0\n 838: iload_3\n 839: invokestatic #78 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 842: checkcast #58 // class java/lang/Iterable\n 845: invokeinterface #59, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 850: astore 12\n 852: aload 12\n 854: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 859: ifne 866\n 862: aconst_null\n 863: goto 1037\n 866: aload 12\n 868: checkcast #145 // class kotlin/collections/IntIterator\n 871: invokevirtual #148 // Method kotlin/collections/IntIterator.nextInt:()I\n 874: istore 13\n 876: iconst_0\n 877: istore 14\n 879: aload_1\n 880: iload 13\n 882: invokeinterface #68, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 887: checkcast #128 // class kotlin/jvm/functions/Function1\n 890: aload 8\n 892: iload 13\n 894: invokeinterface #68, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 899: checkcast #61 // class java/lang/Number\n 902: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 905: aload_0\n 906: iload 13\n 908: invokeinterface #68, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 913: checkcast #61 // class java/lang/Number\n 916: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 919: iadd\n 920: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 923: invokeinterface #130, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 928: checkcast #132 // class java/math/BigInteger\n 931: checkcast #134 // class java/lang/Comparable\n 934: astore 13\n 936: aload 12\n 938: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 943: ifeq 1035\n 946: aload 12\n 948: checkcast #145 // class kotlin/collections/IntIterator\n 951: invokevirtual #148 // Method kotlin/collections/IntIterator.nextInt:()I\n 954: istore 14\n 956: iconst_0\n 957: istore 15\n 959: aload_1\n 960: iload 14\n 962: invokeinterface #68, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 967: checkcast #128 // class kotlin/jvm/functions/Function1\n 970: aload 8\n 972: iload 14\n 974: invokeinterface #68, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 979: checkcast #61 // class java/lang/Number\n 982: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 985: aload_0\n 986: iload 14\n 988: invokeinterface #68, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 993: checkcast #61 // class java/lang/Number\n 996: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 999: iadd\n 1000: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1003: invokeinterface #130, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 1008: checkcast #132 // class java/math/BigInteger\n 1011: checkcast #134 // class java/lang/Comparable\n 1014: astore 14\n 1016: aload 13\n 1018: aload 14\n 1020: invokeinterface #138, 2 // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I\n 1025: ifge 936\n 1028: aload 14\n 1030: astore 13\n 1032: goto 936\n 1035: aload 13\n 1037: checkcast #132 // class java/math/BigInteger\n 1040: dup\n 1041: ifnonnull 1055\n 1044: pop\n 1045: lconst_0\n 1046: invokestatic #151 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 1049: dup\n 1050: ldc #153 // String valueOf(...)\n 1052: invokestatic #159 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 1055: astore 9\n 1057: aload 9\n 1059: aload 8\n 1061: invokestatic #165 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 1064: areturn\n\n public static final void main();\n Code:\n 0: new #220 // class java/util/Scanner\n 3: dup\n 4: new #222 // class java/io/File\n 7: dup\n 8: ldc #224 // String p1precfmax.in\n 10: invokespecial #227 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 13: astore_1\n 14: getstatic #233 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 17: astore_2\n 18: sipush 8192\n 21: istore_3\n 22: aload_1\n 23: astore 4\n 25: new #235 // class java/io/InputStreamReader\n 28: dup\n 29: new #237 // class java/io/FileInputStream\n 32: dup\n 33: aload 4\n 35: invokespecial #240 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 38: checkcast #242 // class java/io/InputStream\n 41: aload_2\n 42: invokespecial #245 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 45: checkcast #247 // class java/io/Reader\n 48: astore 4\n 50: aload 4\n 52: instanceof #249 // class java/io/BufferedReader\n 55: ifeq 66\n 58: aload 4\n 60: checkcast #249 // class java/io/BufferedReader\n 63: goto 76\n 66: new #249 // class java/io/BufferedReader\n 69: dup\n 70: aload 4\n 72: iload_3\n 73: invokespecial #252 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 76: checkcast #254 // class java/lang/Readable\n 79: invokespecial #257 // Method java/util/Scanner.\"<init>\":(Ljava/lang/Readable;)V\n 82: astore_0\n 83: aload_0\n 84: invokevirtual #258 // Method java/util/Scanner.nextInt:()I\n 87: istore_1\n 88: new #15 // class java/util/ArrayList\n 91: dup\n 92: iload_1\n 93: invokespecial #19 // Method java/util/ArrayList.\"<init>\":(I)V\n 96: astore_3\n 97: iconst_0\n 98: istore 4\n 100: iload 4\n 102: iload_1\n 103: if_icmpge 140\n 106: iload 4\n 108: istore 5\n 110: aload_3\n 111: iload 5\n 113: istore 6\n 115: astore 18\n 117: iconst_0\n 118: istore 7\n 120: aload_0\n 121: invokevirtual #258 // Method java/util/Scanner.nextInt:()I\n 124: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 127: aload 18\n 129: swap\n 130: invokevirtual #29 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 133: pop\n 134: iinc 4, 1\n 137: goto 100\n 140: aload_3\n 141: checkcast #9 // class java/util/List\n 144: astore_2\n 145: new #15 // class java/util/ArrayList\n 148: dup\n 149: iload_1\n 150: invokespecial #19 // Method java/util/ArrayList.\"<init>\":(I)V\n 153: astore 4\n 155: iconst_0\n 156: istore 5\n 158: iload 5\n 160: iload_1\n 161: if_icmpge 275\n 164: iload 5\n 166: istore 6\n 168: aload 4\n 170: iload 6\n 172: istore 7\n 174: astore 18\n 176: iconst_0\n 177: istore 8\n 179: aload_0\n 180: invokevirtual #258 // Method java/util/Scanner.nextInt:()I\n 183: istore 9\n 185: iload 9\n 187: iconst_1\n 188: iadd\n 189: istore 10\n 191: new #15 // class java/util/ArrayList\n 194: dup\n 195: iload 10\n 197: invokespecial #19 // Method java/util/ArrayList.\"<init>\":(I)V\n 200: astore 11\n 202: iconst_0\n 203: istore 12\n 205: iload 12\n 207: iload 10\n 209: if_icmpge 247\n 212: iload 12\n 214: istore 13\n 216: aload 11\n 218: iload 13\n 220: istore 14\n 222: astore 15\n 224: iconst_0\n 225: istore 16\n 227: aload_0\n 228: invokevirtual #258 // Method java/util/Scanner.nextInt:()I\n 231: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 234: aload 15\n 236: swap\n 237: invokevirtual #29 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 240: pop\n 241: iinc 12, 1\n 244: goto 205\n 247: aload 11\n 249: checkcast #9 // class java/util/List\n 252: astore 17\n 254: aload 17\n 256: invokedynamic #266, 0 // InvokeDynamic #1:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function1;\n 261: nop\n 262: aload 18\n 264: swap\n 265: invokevirtual #29 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 268: pop\n 269: iinc 5, 1\n 272: goto 158\n 275: aload 4\n 277: checkcast #9 // class java/util/List\n 280: astore_3\n 281: aload_0\n 282: invokevirtual #258 // Method java/util/Scanner.nextInt:()I\n 285: istore 4\n 287: invokestatic #272 // Method kotlin/collections/MapsKt.createMapBuilder:()Ljava/util/Map;\n 290: astore 6\n 292: aload 6\n 294: astore 7\n 296: iconst_0\n 297: istore 8\n 299: iconst_0\n 300: istore 9\n 302: iload 9\n 304: iload 4\n 306: if_icmpge 422\n 309: aload_0\n 310: invokevirtual #258 // Method java/util/Scanner.nextInt:()I\n 313: iconst_1\n 314: isub\n 315: istore 10\n 317: aload_0\n 318: invokevirtual #258 // Method java/util/Scanner.nextInt:()I\n 321: iconst_1\n 322: isub\n 323: istore 11\n 325: aload 7\n 327: astore 12\n 329: iload 11\n 331: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 334: astore 13\n 336: iconst_0\n 337: istore 14\n 339: aload 12\n 341: aload 13\n 343: invokeinterface #143, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 348: astore 15\n 350: aload 15\n 352: ifnonnull 388\n 355: iconst_0\n 356: istore 16\n 358: new #15 // class java/util/ArrayList\n 361: dup\n 362: invokespecial #273 // Method java/util/ArrayList.\"<init>\":()V\n 365: checkcast #9 // class java/util/List\n 368: nop\n 369: astore 16\n 371: aload 12\n 373: aload 13\n 375: aload 16\n 377: invokeinterface #277, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 382: pop\n 383: aload 16\n 385: goto 390\n 388: aload 15\n 390: nop\n 391: checkcast #9 // class java/util/List\n 394: astore 17\n 396: iload 10\n 398: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 401: astore 13\n 403: aload 17\n 405: checkcast #279 // class java/util/Collection\n 408: aload 13\n 410: invokeinterface #280, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 415: pop\n 416: iinc 9, 1\n 419: goto 302\n 422: nop\n 423: aload 6\n 425: invokestatic #284 // Method kotlin/collections/MapsKt.build:(Ljava/util/Map;)Ljava/util/Map;\n 428: astore 5\n 430: aload_2\n 431: aload_3\n 432: aload 5\n 434: invokestatic #286 // Method scheduleP1PrecFMax:(Ljava/util/List;Ljava/util/List;Ljava/util/Map;)Lkotlin/Pair;\n 437: astore 6\n 439: aload 6\n 441: invokevirtual #291 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 444: checkcast #132 // class java/math/BigInteger\n 447: astore 7\n 449: aload 6\n 451: invokevirtual #294 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 454: checkcast #9 // class java/util/List\n 457: astore 8\n 459: new #222 // class java/io/File\n 462: dup\n 463: ldc_w #296 // String p1precfmax.out\n 466: invokespecial #227 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 469: astore 9\n 471: getstatic #233 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 474: astore 10\n 476: new #298 // class java/io/PrintWriter\n 479: dup\n 480: aload 9\n 482: astore 11\n 484: sipush 8192\n 487: istore 12\n 489: aload 11\n 491: astore 13\n 493: new #300 // class java/io/OutputStreamWriter\n 496: dup\n 497: new #302 // class java/io/FileOutputStream\n 500: dup\n 501: aload 13\n 503: invokespecial #303 // Method java/io/FileOutputStream.\"<init>\":(Ljava/io/File;)V\n 506: checkcast #305 // class java/io/OutputStream\n 509: aload 10\n 511: invokespecial #308 // Method java/io/OutputStreamWriter.\"<init>\":(Ljava/io/OutputStream;Ljava/nio/charset/Charset;)V\n 514: checkcast #310 // class java/io/Writer\n 517: astore 13\n 519: aload 13\n 521: instanceof #312 // class java/io/BufferedWriter\n 524: ifeq 535\n 527: aload 13\n 529: checkcast #312 // class java/io/BufferedWriter\n 532: goto 546\n 535: new #312 // class java/io/BufferedWriter\n 538: dup\n 539: aload 13\n 541: iload 12\n 543: invokespecial #315 // Method java/io/BufferedWriter.\"<init>\":(Ljava/io/Writer;I)V\n 546: checkcast #310 // class java/io/Writer\n 549: invokespecial #318 // Method java/io/PrintWriter.\"<init>\":(Ljava/io/Writer;)V\n 552: checkcast #320 // class java/io/Closeable\n 555: astore 9\n 557: aconst_null\n 558: astore 10\n 560: nop\n 561: aload 9\n 563: checkcast #298 // class java/io/PrintWriter\n 566: astore 11\n 568: iconst_0\n 569: istore 12\n 571: aload 11\n 573: aload 7\n 575: invokevirtual #324 // Method java/math/BigInteger.toString:()Ljava/lang/String;\n 578: invokevirtual #327 // Method java/io/PrintWriter.println:(Ljava/lang/String;)V\n 581: aload 8\n 583: invokeinterface #328, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 588: astore 13\n 590: aload 13\n 592: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 597: ifeq 643\n 600: aload 13\n 602: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 607: checkcast #61 // class java/lang/Number\n 610: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 613: istore 14\n 615: aload 11\n 617: new #330 // class java/lang/StringBuilder\n 620: dup\n 621: invokespecial #331 // Method java/lang/StringBuilder.\"<init>\":()V\n 624: iload 14\n 626: invokevirtual #335 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 629: bipush 32\n 631: invokevirtual #338 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 634: invokevirtual #339 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 637: invokevirtual #342 // Method java/io/PrintWriter.print:(Ljava/lang/String;)V\n 640: goto 590\n 643: nop\n 644: getstatic #348 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 647: astore 11\n 649: aload 9\n 651: aload 10\n 653: invokestatic #354 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 656: goto 680\n 659: astore 12\n 661: aload 12\n 663: astore 10\n 665: aload 12\n 667: athrow\n 668: astore 12\n 670: aload 9\n 672: aload 10\n 674: invokestatic #354 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 677: aload 12\n 679: athrow\n 680: return\n Exception table:\n from to target type\n 560 649 659 Class java/lang/Throwable\n 560 649 668 any\n 659 668 668 any\n 668 670 668 any\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #380 // Method main:()V\n 3: return\n\n private static final boolean scheduleP1PrecFMax$lambda$4(java.util.List, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: invokeinterface #68, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #61 // class java/lang/Number\n 10: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 13: ifne 20\n 16: iconst_1\n 17: goto 21\n 20: iconst_0\n 21: ireturn\n\n private static final java.math.BigInteger main$lambda$14$lambda$13(java.util.List, int);\n Code:\n 0: aload_0\n 1: checkcast #58 // class java/lang/Iterable\n 4: invokestatic #92 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 7: invokestatic #387 // Method kotlin/sequences/SequencesKt.withIndex:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;\n 10: astore_2\n 11: lconst_0\n 12: invokestatic #151 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 15: dup\n 16: ldc #153 // String valueOf(...)\n 18: invokestatic #159 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 21: astore_3\n 22: aload_2\n 23: invokeinterface #121, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 28: astore 4\n 30: aload 4\n 32: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 37: ifeq 159\n 40: aload 4\n 42: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 47: aload_3\n 48: swap\n 49: checkcast #389 // class kotlin/collections/IndexedValue\n 52: astore 5\n 54: astore 11\n 56: iconst_0\n 57: istore 6\n 59: aload 5\n 61: invokevirtual #391 // Method kotlin/collections/IndexedValue.component1:()I\n 64: istore 7\n 66: aload 5\n 68: invokevirtual #392 // Method kotlin/collections/IndexedValue.component2:()Ljava/lang/Object;\n 71: checkcast #61 // class java/lang/Number\n 74: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 77: istore 8\n 79: iload_1\n 80: i2l\n 81: invokestatic #151 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 84: dup\n 85: ldc #153 // String valueOf(...)\n 87: invokestatic #159 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 90: aload_0\n 91: invokeinterface #13, 1 // InterfaceMethod java/util/List.size:()I\n 96: iconst_1\n 97: isub\n 98: iload 7\n 100: isub\n 101: invokevirtual #396 // Method java/math/BigInteger.pow:(I)Ljava/math/BigInteger;\n 104: dup\n 105: ldc_w #398 // String pow(...)\n 108: invokestatic #159 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 111: astore 9\n 113: iload 8\n 115: i2l\n 116: invokestatic #151 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 119: dup\n 120: ldc #153 // String valueOf(...)\n 122: invokestatic #159 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 125: astore 10\n 127: aload 9\n 129: aload 10\n 131: invokevirtual #402 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 134: dup\n 135: ldc_w #404 // String multiply(...)\n 138: invokestatic #159 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 141: nop\n 142: aload 11\n 144: swap\n 145: invokevirtual #406 // Method java/math/BigInteger.add:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 148: dup\n 149: ldc_w #408 // String add(...)\n 152: invokestatic #159 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 155: astore_3\n 156: goto 30\n 159: aload_3\n 160: areturn\n}\n",
"javap_err": ""
}
] |
nothingelsematters__university__d442a3d/advanced-algorithms/kotlin/src/h1PrecPmtnRFMax.kt
|
import java.io.File
import java.util.Scanner
private fun <T> MutableList<T>.addAll(vararg ts: T) = addAll(ts)
data class Job(
val time: Long,
var release: Long,
val index: Int,
val f: (Long) -> Long,
val times: MutableList<Long> = mutableListOf(),
)
private data class Block(val start: Long, var time: Long = 0, val jobs: MutableList<Job> = mutableListOf()) {
val end: Long
get() = start + time
fun add(job: Job) {
jobs += job
time += job.time
}
}
private fun topologicalSort(jobs: List<Job>, edges: List<List<Int>>, reverseEdges: List<List<Int>>): List<Job> {
fun depthFirstSearch(
edges: List<List<Int>>,
jobs: List<Job>,
currentVertex: Int,
result: MutableList<Job>,
used: MutableSet<Int>,
) {
if (currentVertex in used) return
used += currentVertex
edges[currentVertex]
.asSequence()
.filter { it !in used }
.forEach { depthFirstSearch(edges, jobs, it, result, used) }
result += jobs[currentVertex]
}
val result = mutableListOf<Job>()
val used = mutableSetOf<Int>()
jobs.indices
.asSequence()
.filter { it !in used && reverseEdges[it].isEmpty() }
.forEach { depthFirstSearch(edges, jobs, it, result, used) }
return result
}
private fun createBlocks(jobs: List<Job>): List<Block> = buildList {
jobs.forEach { job ->
val block = if (lastOrNull()?.let { it.end >= job.release } == true) {
last()
} else {
Block(job.release).also { add(it) }
}
block.add(job)
}
}
private fun decompose(edges: List<List<Int>>, block: Block): Long {
val end = block.end
val used = mutableSetOf<Int>()
val minimumJobIndex = block.jobs
.indices
.reversed()
.asSequence()
.map { it to block.jobs[it] }
.filter { (_, job) -> edges[job.index].none { it in used }.also { used += job.index } }
.minBy { (_, job) -> job.f(end) }
.first
val deleted = block.jobs[minimumJobIndex]
block.jobs.removeAt(minimumJobIndex)
val newBlocks = createBlocks(block.jobs)
return if (newBlocks.isEmpty()) {
deleted.times.addAll(block.start, block.end)
deleted.f(end)
} else {
if (block.start < newBlocks.first().start) {
deleted.times.addAll(block.start, newBlocks.first().start)
}
newBlocks.asSequence()
.windowed(2)
.map { (left, right) -> left.end to right.start }
.filter { (start, end) -> start < end }
.forEach { deleted.times.addAll(it.toList()) }
if (block.end > newBlocks.last().end) {
deleted.times.addAll(newBlocks.last().end, block.end)
}
maxOf(deleted.f(end), newBlocks.maxOf { decompose(edges, it) })
}
}
fun schedule1PrecPmtnRFMax(jobs: List<Job>, edges: List<List<Int>>, reverseEdges: List<List<Int>>): Long {
val topologicalSorted = topologicalSort(jobs, edges, reverseEdges)
topologicalSorted.asReversed().forEach { job ->
edges[job.index]
.asSequence()
.map { jobs[it] }
.forEach { it.release = maxOf(it.release, job.release + job.time) }
}
return createBlocks(topologicalSorted.sortedBy { it.release }).maxOf { decompose(edges, it) }
}
fun main() {
val scanner = Scanner(File("p1precpmtnrifmax.in").bufferedReader())
val n = scanner.nextInt()
val times = List(n) { scanner.nextLong() }
val releases = List(n) { scanner.nextLong() }
val m = scanner.nextInt()
val edges = List(n) { mutableListOf<Int>() }
val reverseEdges = List(n) { mutableListOf<Int>() }
repeat(m) {
val (from, to) = List(2) { scanner.nextInt() - 1 }
edges[from] += to
reverseEdges[to] += from
}
val jobs = List(n) {
val (a, b, c) = List(3) { scanner.nextLong() }
Job(times[it], releases[it], it, { time -> a * time * time + b * time + c })
}
val fMax = schedule1PrecPmtnRFMax(jobs, edges, reverseEdges)
File("p1precpmtnrifmax.out").printWriter().use { output ->
output.println(fMax)
jobs.forEach { job ->
output.write("${job.times.size / 2} ")
job.times.forEach { output.print("$it ") }
output.println()
}
}
}
|
[
{
"class_path": "nothingelsematters__university__d442a3d/H1PrecPmtnRFMaxKt$schedule1PrecPmtnRFMax$$inlined$sortedBy$1.class",
"javap": "Compiled from \"Comparisons.kt\"\npublic final class H1PrecPmtnRFMaxKt$schedule1PrecPmtnRFMax$$inlined$sortedBy$1<T> implements java.util.Comparator {\n public H1PrecPmtnRFMaxKt$schedule1PrecPmtnRFMax$$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 Job\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method Job.getRelease:()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 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.getRelease:()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": "nothingelsematters__university__d442a3d/H1PrecPmtnRFMaxKt.class",
"javap": "Compiled from \"h1PrecPmtnRFMax.kt\"\npublic final class H1PrecPmtnRFMaxKt {\n private static final <T> boolean addAll(java.util.List<T>, T...);\n Code:\n 0: aload_0\n 1: checkcast #9 // class java/util/Collection\n 4: aload_1\n 5: invokestatic #14 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;[Ljava/lang/Object;)Z\n 8: ireturn\n\n private static final java.util.List<Job> topologicalSort(java.util.List<Job>, java.util.List<? extends java.util.List<java.lang.Integer>>, java.util.List<? extends java.util.List<java.lang.Integer>>);\n Code:\n 0: new #23 // 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_3\n 11: new #31 // class java/util/LinkedHashSet\n 14: dup\n 15: invokespecial #32 // Method java/util/LinkedHashSet.\"<init>\":()V\n 18: checkcast #34 // class java/util/Set\n 21: astore 4\n 23: aload_0\n 24: checkcast #9 // class java/util/Collection\n 27: invokestatic #38 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 30: checkcast #40 // class java/lang/Iterable\n 33: invokestatic #44 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 36: aload 4\n 38: aload_2\n 39: invokedynamic #64, 0 // InvokeDynamic #0:invoke:(Ljava/util/Set;Ljava/util/List;)Lkotlin/jvm/functions/Function1;\n 44: invokestatic #70 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 47: astore 5\n 49: nop\n 50: iconst_0\n 51: istore 6\n 53: aload 5\n 55: invokeinterface #76, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 60: astore 7\n 62: aload 7\n 64: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 69: ifeq 108\n 72: aload 7\n 74: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 79: astore 8\n 81: aload 8\n 83: checkcast #88 // class java/lang/Number\n 86: invokevirtual #92 // Method java/lang/Number.intValue:()I\n 89: istore 9\n 91: iconst_0\n 92: istore 10\n 94: aload_1\n 95: aload_0\n 96: iload 9\n 98: aload_3\n 99: aload 4\n 101: invokestatic #96 // Method topologicalSort$depthFirstSearch:(Ljava/util/List;Ljava/util/List;ILjava/util/List;Ljava/util/Set;)V\n 104: nop\n 105: goto 62\n 108: nop\n 109: aload_3\n 110: areturn\n\n private static final java.util.List<Block> createBlocks(java.util.List<Job>);\n Code:\n 0: invokestatic #117 // 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 #40 // class java/lang/Iterable\n 12: astore 4\n 14: iconst_0\n 15: istore 5\n 17: aload 4\n 19: invokeinterface #118, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 24: astore 6\n 26: aload 6\n 28: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 33: ifeq 169\n 36: aload 6\n 38: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 43: astore 7\n 45: aload 7\n 47: checkcast #120 // class Job\n 50: astore 8\n 52: iconst_0\n 53: istore 9\n 55: aload_2\n 56: invokestatic #124 // Method kotlin/collections/CollectionsKt.lastOrNull:(Ljava/util/List;)Ljava/lang/Object;\n 59: checkcast #126 // class Block\n 62: dup\n 63: ifnull 103\n 66: astore 10\n 68: iconst_0\n 69: istore 11\n 71: aload 10\n 73: invokevirtual #130 // Method Block.getEnd:()J\n 76: aload 8\n 78: invokevirtual #133 // Method Job.getRelease:()J\n 81: lcmp\n 82: iflt 89\n 85: iconst_1\n 86: goto 90\n 89: iconst_0\n 90: nop\n 91: iconst_1\n 92: if_icmpne 99\n 95: iconst_1\n 96: goto 105\n 99: iconst_0\n 100: goto 105\n 103: pop\n 104: iconst_0\n 105: ifeq 118\n 108: aload_2\n 109: invokestatic #136 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 112: checkcast #126 // class Block\n 115: goto 155\n 118: new #126 // class Block\n 121: dup\n 122: aload 8\n 124: invokevirtual #133 // Method Job.getRelease:()J\n 127: lconst_0\n 128: aconst_null\n 129: bipush 6\n 131: aconst_null\n 132: invokespecial #139 // Method Block.\"<init>\":(JJLjava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 135: astore 12\n 137: aload 12\n 139: astore 13\n 141: iconst_0\n 142: istore 10\n 144: aload_2\n 145: aload 13\n 147: invokeinterface #143, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 152: pop\n 153: aload 12\n 155: astore 14\n 157: aload 14\n 159: aload 8\n 161: invokevirtual #146 // Method Block.add:(LJob;)V\n 164: nop\n 165: nop\n 166: goto 26\n 169: nop\n 170: nop\n 171: aload_1\n 172: invokestatic #149 // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;\n 175: areturn\n\n private static final long decompose(java.util.List<? extends java.util.List<java.lang.Integer>>, Block);\n Code:\n 0: aload_1\n 1: invokevirtual #130 // Method Block.getEnd:()J\n 4: lstore_2\n 5: new #31 // class java/util/LinkedHashSet\n 8: dup\n 9: invokespecial #32 // Method java/util/LinkedHashSet.\"<init>\":()V\n 12: checkcast #34 // class java/util/Set\n 15: astore 4\n 17: aload_1\n 18: invokevirtual #165 // Method Block.getJobs:()Ljava/util/List;\n 21: checkcast #9 // class java/util/Collection\n 24: invokestatic #38 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 27: checkcast #167 // class kotlin/ranges/IntProgression\n 30: invokestatic #173 // Method kotlin/ranges/RangesKt.reversed:(Lkotlin/ranges/IntProgression;)Lkotlin/ranges/IntProgression;\n 33: checkcast #40 // class java/lang/Iterable\n 36: invokestatic #44 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 39: aload_1\n 40: invokedynamic #183, 0 // InvokeDynamic #1:invoke:(LBlock;)Lkotlin/jvm/functions/Function1;\n 45: invokestatic #186 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 48: aload_0\n 49: aload 4\n 51: invokedynamic #196, 0 // InvokeDynamic #2:invoke:(Ljava/util/List;Ljava/util/Set;)Lkotlin/jvm/functions/Function1;\n 56: invokestatic #70 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 59: astore 6\n 61: nop\n 62: iconst_0\n 63: istore 7\n 65: aload 6\n 67: invokeinterface #76, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 72: astore 8\n 74: aload 8\n 76: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 81: ifne 92\n 84: new #198 // class java/util/NoSuchElementException\n 87: dup\n 88: invokespecial #199 // Method java/util/NoSuchElementException.\"<init>\":()V\n 91: athrow\n 92: aload 8\n 94: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 99: astore 9\n 101: aload 8\n 103: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 108: ifne 116\n 111: aload 9\n 113: goto 237\n 116: aload 9\n 118: checkcast #201 // class kotlin/Pair\n 121: astore 10\n 123: iconst_0\n 124: istore 12\n 126: aload 10\n 128: invokevirtual #204 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 131: checkcast #120 // class Job\n 134: astore 13\n 136: aload 13\n 138: invokevirtual #208 // Method Job.getF:()Lkotlin/jvm/functions/Function1;\n 141: lload_2\n 142: invokestatic #214 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 145: invokeinterface #218, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 150: checkcast #88 // class java/lang/Number\n 153: invokevirtual #221 // Method java/lang/Number.longValue:()J\n 156: lstore 10\n 158: aload 8\n 160: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 165: astore 12\n 167: aload 12\n 169: checkcast #201 // class kotlin/Pair\n 172: astore 13\n 174: iconst_0\n 175: istore 15\n 177: aload 13\n 179: invokevirtual #204 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 182: checkcast #120 // class Job\n 185: astore 17\n 187: aload 17\n 189: invokevirtual #208 // Method Job.getF:()Lkotlin/jvm/functions/Function1;\n 192: lload_2\n 193: invokestatic #214 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 196: invokeinterface #218, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 201: checkcast #88 // class java/lang/Number\n 204: invokevirtual #221 // Method java/lang/Number.longValue:()J\n 207: lstore 13\n 209: lload 10\n 211: lload 13\n 213: lcmp\n 214: ifle 225\n 217: aload 12\n 219: astore 9\n 221: lload 13\n 223: lstore 10\n 225: aload 8\n 227: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 232: ifne 158\n 235: aload 9\n 237: checkcast #201 // class kotlin/Pair\n 240: invokevirtual #224 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 243: checkcast #88 // class java/lang/Number\n 246: invokevirtual #92 // Method java/lang/Number.intValue:()I\n 249: istore 5\n 251: aload_1\n 252: invokevirtual #165 // Method Block.getJobs:()Ljava/util/List;\n 255: iload 5\n 257: invokeinterface #228, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 262: checkcast #120 // class Job\n 265: astore 6\n 267: aload_1\n 268: invokevirtual #165 // Method Block.getJobs:()Ljava/util/List;\n 271: iload 5\n 273: invokeinterface #231, 2 // InterfaceMethod java/util/List.remove:(I)Ljava/lang/Object;\n 278: pop\n 279: aload_1\n 280: invokevirtual #165 // Method Block.getJobs:()Ljava/util/List;\n 283: invokestatic #233 // Method createBlocks:(Ljava/util/List;)Ljava/util/List;\n 286: astore 7\n 288: aload 7\n 290: invokeinterface #236, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 295: ifeq 360\n 298: aload 6\n 300: invokevirtual #239 // Method Job.getTimes:()Ljava/util/List;\n 303: iconst_2\n 304: anewarray #210 // class java/lang/Long\n 307: astore 8\n 309: aload 8\n 311: iconst_0\n 312: aload_1\n 313: invokevirtual #242 // Method Block.getStart:()J\n 316: invokestatic #214 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 319: aastore\n 320: aload 8\n 322: iconst_1\n 323: aload_1\n 324: invokevirtual #130 // Method Block.getEnd:()J\n 327: invokestatic #214 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 330: aastore\n 331: aload 8\n 333: invokestatic #244 // Method addAll:(Ljava/util/List;[Ljava/lang/Object;)Z\n 336: pop\n 337: aload 6\n 339: invokevirtual #208 // Method Job.getF:()Lkotlin/jvm/functions/Function1;\n 342: lload_2\n 343: invokestatic #214 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 346: invokeinterface #218, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 351: checkcast #88 // class java/lang/Number\n 354: invokevirtual #221 // Method java/lang/Number.longValue:()J\n 357: goto 725\n 360: aload_1\n 361: invokevirtual #242 // Method Block.getStart:()J\n 364: aload 7\n 366: invokestatic #247 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 369: checkcast #126 // class Block\n 372: invokevirtual #242 // Method Block.getStart:()J\n 375: lcmp\n 376: ifge 425\n 379: aload 6\n 381: invokevirtual #239 // Method Job.getTimes:()Ljava/util/List;\n 384: iconst_2\n 385: anewarray #210 // class java/lang/Long\n 388: astore 8\n 390: aload 8\n 392: iconst_0\n 393: aload_1\n 394: invokevirtual #242 // Method Block.getStart:()J\n 397: invokestatic #214 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 400: aastore\n 401: aload 8\n 403: iconst_1\n 404: aload 7\n 406: invokestatic #247 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 409: checkcast #126 // class Block\n 412: invokevirtual #242 // Method Block.getStart:()J\n 415: invokestatic #214 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 418: aastore\n 419: aload 8\n 421: invokestatic #244 // Method addAll:(Ljava/util/List;[Ljava/lang/Object;)Z\n 424: pop\n 425: aload 7\n 427: checkcast #40 // class java/lang/Iterable\n 430: invokestatic #44 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 433: iconst_2\n 434: iconst_0\n 435: iconst_0\n 436: bipush 6\n 438: aconst_null\n 439: invokestatic #251 // Method kotlin/sequences/SequencesKt.windowed$default:(Lkotlin/sequences/Sequence;IIZILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 442: invokedynamic #259, 0 // InvokeDynamic #3:invoke:()Lkotlin/jvm/functions/Function1;\n 447: invokestatic #186 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 450: invokedynamic #265, 0 // InvokeDynamic #4:invoke:()Lkotlin/jvm/functions/Function1;\n 455: invokestatic #70 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 458: astore 8\n 460: nop\n 461: iconst_0\n 462: istore 9\n 464: aload 8\n 466: invokeinterface #76, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 471: astore 10\n 473: aload 10\n 475: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 480: ifeq 525\n 483: aload 10\n 485: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 490: astore 12\n 492: aload 12\n 494: checkcast #201 // class kotlin/Pair\n 497: astore 13\n 499: iconst_0\n 500: istore 15\n 502: aload 6\n 504: invokevirtual #239 // Method Job.getTimes:()Ljava/util/List;\n 507: aload 13\n 509: invokestatic #271 // Method kotlin/TuplesKt.toList:(Lkotlin/Pair;)Ljava/util/List;\n 512: checkcast #9 // class java/util/Collection\n 515: invokeinterface #274, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 520: pop\n 521: nop\n 522: goto 473\n 525: nop\n 526: aload_1\n 527: invokevirtual #130 // Method Block.getEnd:()J\n 530: aload 7\n 532: invokestatic #136 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 535: checkcast #126 // class Block\n 538: invokevirtual #130 // Method Block.getEnd:()J\n 541: lcmp\n 542: ifle 591\n 545: aload 6\n 547: invokevirtual #239 // Method Job.getTimes:()Ljava/util/List;\n 550: iconst_2\n 551: anewarray #210 // class java/lang/Long\n 554: astore 8\n 556: aload 8\n 558: iconst_0\n 559: aload 7\n 561: invokestatic #136 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 564: checkcast #126 // class Block\n 567: invokevirtual #130 // Method Block.getEnd:()J\n 570: invokestatic #214 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 573: aastore\n 574: aload 8\n 576: iconst_1\n 577: aload_1\n 578: invokevirtual #130 // Method Block.getEnd:()J\n 581: invokestatic #214 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 584: aastore\n 585: aload 8\n 587: invokestatic #244 // Method addAll:(Ljava/util/List;[Ljava/lang/Object;)Z\n 590: pop\n 591: aload 6\n 593: invokevirtual #208 // Method Job.getF:()Lkotlin/jvm/functions/Function1;\n 596: lload_2\n 597: invokestatic #214 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 600: invokeinterface #218, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 605: checkcast #88 // class java/lang/Number\n 608: invokevirtual #221 // Method java/lang/Number.longValue:()J\n 611: lstore 8\n 613: aload 7\n 615: checkcast #40 // class java/lang/Iterable\n 618: invokeinterface #118, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 623: astore 12\n 625: aload 12\n 627: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 632: ifne 643\n 635: new #198 // class java/util/NoSuchElementException\n 638: dup\n 639: invokespecial #199 // Method java/util/NoSuchElementException.\"<init>\":()V\n 642: athrow\n 643: aload 12\n 645: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 650: checkcast #126 // class Block\n 653: astore 13\n 655: iconst_0\n 656: istore 15\n 658: aload_0\n 659: aload 13\n 661: invokestatic #276 // Method decompose:(Ljava/util/List;LBlock;)J\n 664: lstore 13\n 666: aload 12\n 668: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 673: ifeq 714\n 676: aload 12\n 678: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 683: checkcast #126 // class Block\n 686: astore 15\n 688: iconst_0\n 689: istore 17\n 691: aload_0\n 692: aload 15\n 694: invokestatic #276 // Method decompose:(Ljava/util/List;LBlock;)J\n 697: lstore 15\n 699: lload 13\n 701: lload 15\n 703: lcmp\n 704: ifge 666\n 707: lload 15\n 709: lstore 13\n 711: goto 666\n 714: lload 13\n 716: lstore 10\n 718: lload 8\n 720: lload 10\n 722: invokestatic #282 // Method java/lang/Math.max:(JJ)J\n 725: lreturn\n\n public static final long schedule1PrecPmtnRFMax(java.util.List<Job>, java.util.List<? extends java.util.List<java.lang.Integer>>, java.util.List<? extends java.util.List<java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: ldc_w #304 // String jobs\n 4: invokestatic #310 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: ldc_w #311 // String edges\n 11: invokestatic #310 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: aload_2\n 15: ldc_w #312 // String reverseEdges\n 18: invokestatic #310 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 21: aload_0\n 22: aload_1\n 23: aload_2\n 24: invokestatic #314 // Method topologicalSort:(Ljava/util/List;Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 27: astore_3\n 28: aload_3\n 29: invokestatic #317 // Method kotlin/collections/CollectionsKt.asReversed:(Ljava/util/List;)Ljava/util/List;\n 32: checkcast #40 // class java/lang/Iterable\n 35: astore 4\n 37: iconst_0\n 38: istore 5\n 40: aload 4\n 42: invokeinterface #118, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 47: astore 6\n 49: aload 6\n 51: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 56: ifeq 182\n 59: aload 6\n 61: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 66: astore 8\n 68: aload 8\n 70: checkcast #120 // class Job\n 73: astore 10\n 75: iconst_0\n 76: istore 11\n 78: aload_1\n 79: aload 10\n 81: invokevirtual #320 // Method Job.getIndex:()I\n 84: invokeinterface #228, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 89: checkcast #40 // class java/lang/Iterable\n 92: invokestatic #44 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 95: aload_0\n 96: invokedynamic #330, 0 // InvokeDynamic #5:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function1;\n 101: invokestatic #186 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 104: astore 12\n 106: nop\n 107: iconst_0\n 108: istore 13\n 110: aload 12\n 112: invokeinterface #76, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 117: astore 14\n 119: aload 14\n 121: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 126: ifeq 176\n 129: aload 14\n 131: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 136: astore 15\n 138: aload 15\n 140: checkcast #120 // class Job\n 143: astore 16\n 145: iconst_0\n 146: istore 17\n 148: aload 16\n 150: aload 16\n 152: invokevirtual #133 // Method Job.getRelease:()J\n 155: aload 10\n 157: invokevirtual #133 // Method Job.getRelease:()J\n 160: aload 10\n 162: invokevirtual #333 // Method Job.getTime:()J\n 165: ladd\n 166: invokestatic #282 // Method java/lang/Math.max:(JJ)J\n 169: invokevirtual #337 // Method Job.setRelease:(J)V\n 172: nop\n 173: goto 119\n 176: nop\n 177: nop\n 178: nop\n 179: goto 49\n 182: nop\n 183: aload_3\n 184: checkcast #40 // class java/lang/Iterable\n 187: astore 4\n 189: iconst_0\n 190: istore 5\n 192: aload 4\n 194: new #339 // class H1PrecPmtnRFMaxKt$schedule1PrecPmtnRFMax$$inlined$sortedBy$1\n 197: dup\n 198: invokespecial #340 // Method H1PrecPmtnRFMaxKt$schedule1PrecPmtnRFMax$$inlined$sortedBy$1.\"<init>\":()V\n 201: checkcast #342 // class java/util/Comparator\n 204: invokestatic #346 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 207: invokestatic #233 // Method createBlocks:(Ljava/util/List;)Ljava/util/List;\n 210: checkcast #40 // class java/lang/Iterable\n 213: invokeinterface #118, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 218: astore 5\n 220: aload 5\n 222: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 227: ifne 238\n 230: new #198 // class java/util/NoSuchElementException\n 233: dup\n 234: invokespecial #199 // Method java/util/NoSuchElementException.\"<init>\":()V\n 237: athrow\n 238: aload 5\n 240: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 245: checkcast #126 // class Block\n 248: astore 6\n 250: iconst_0\n 251: istore 8\n 253: aload_1\n 254: aload 6\n 256: invokestatic #276 // Method decompose:(Ljava/util/List;LBlock;)J\n 259: lstore 6\n 261: aload 5\n 263: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 268: ifeq 309\n 271: aload 5\n 273: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 278: checkcast #126 // class Block\n 281: astore 8\n 283: iconst_0\n 284: istore 10\n 286: aload_1\n 287: aload 8\n 289: invokestatic #276 // Method decompose:(Ljava/util/List;LBlock;)J\n 292: lstore 8\n 294: lload 6\n 296: lload 8\n 298: lcmp\n 299: ifge 261\n 302: lload 8\n 304: lstore 6\n 306: goto 261\n 309: lload 6\n 311: lreturn\n\n public static final void main();\n Code:\n 0: new #357 // class java/util/Scanner\n 3: dup\n 4: new #359 // class java/io/File\n 7: dup\n 8: ldc_w #361 // String p1precpmtnrifmax.in\n 11: invokespecial #364 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 14: astore_1\n 15: getstatic #370 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 18: astore_2\n 19: sipush 8192\n 22: istore_3\n 23: aload_1\n 24: astore 4\n 26: new #372 // class java/io/InputStreamReader\n 29: dup\n 30: new #374 // class java/io/FileInputStream\n 33: dup\n 34: aload 4\n 36: invokespecial #377 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 39: checkcast #379 // class java/io/InputStream\n 42: aload_2\n 43: invokespecial #382 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 46: checkcast #384 // class java/io/Reader\n 49: astore 4\n 51: aload 4\n 53: instanceof #386 // class java/io/BufferedReader\n 56: ifeq 67\n 59: aload 4\n 61: checkcast #386 // class java/io/BufferedReader\n 64: goto 77\n 67: new #386 // class java/io/BufferedReader\n 70: dup\n 71: aload 4\n 73: iload_3\n 74: invokespecial #389 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 77: checkcast #391 // class java/lang/Readable\n 80: invokespecial #394 // Method java/util/Scanner.\"<init>\":(Ljava/lang/Readable;)V\n 83: astore_0\n 84: aload_0\n 85: invokevirtual #397 // Method java/util/Scanner.nextInt:()I\n 88: istore_1\n 89: new #23 // class java/util/ArrayList\n 92: dup\n 93: iload_1\n 94: invokespecial #400 // Method java/util/ArrayList.\"<init>\":(I)V\n 97: astore_3\n 98: iconst_0\n 99: istore 4\n 101: iload 4\n 103: iload_1\n 104: if_icmpge 141\n 107: iload 4\n 109: istore 5\n 111: aload_3\n 112: iload 5\n 114: istore 6\n 116: astore 27\n 118: iconst_0\n 119: istore 7\n 121: aload_0\n 122: invokevirtual #403 // Method java/util/Scanner.nextLong:()J\n 125: invokestatic #214 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 128: aload 27\n 130: swap\n 131: invokevirtual #404 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 134: pop\n 135: iinc 4, 1\n 138: goto 101\n 141: aload_3\n 142: checkcast #29 // class java/util/List\n 145: astore_2\n 146: new #23 // class java/util/ArrayList\n 149: dup\n 150: iload_1\n 151: invokespecial #400 // Method java/util/ArrayList.\"<init>\":(I)V\n 154: astore 4\n 156: iconst_0\n 157: istore 5\n 159: iload 5\n 161: iload_1\n 162: if_icmpge 200\n 165: iload 5\n 167: istore 6\n 169: aload 4\n 171: iload 6\n 173: istore 7\n 175: astore 27\n 177: iconst_0\n 178: istore 8\n 180: aload_0\n 181: invokevirtual #403 // Method java/util/Scanner.nextLong:()J\n 184: invokestatic #214 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 187: aload 27\n 189: swap\n 190: invokevirtual #404 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 193: pop\n 194: iinc 5, 1\n 197: goto 159\n 200: aload 4\n 202: checkcast #29 // class java/util/List\n 205: astore_3\n 206: aload_0\n 207: invokevirtual #397 // Method java/util/Scanner.nextInt:()I\n 210: istore 4\n 212: new #23 // class java/util/ArrayList\n 215: dup\n 216: iload_1\n 217: invokespecial #400 // Method java/util/ArrayList.\"<init>\":(I)V\n 220: astore 6\n 222: iconst_0\n 223: istore 7\n 225: iload 7\n 227: iload_1\n 228: if_icmpge 270\n 231: iload 7\n 233: istore 8\n 235: aload 6\n 237: iload 8\n 239: istore 9\n 241: astore 27\n 243: iconst_0\n 244: istore 10\n 246: new #23 // class java/util/ArrayList\n 249: dup\n 250: invokespecial #27 // Method java/util/ArrayList.\"<init>\":()V\n 253: checkcast #29 // class java/util/List\n 256: nop\n 257: aload 27\n 259: swap\n 260: invokevirtual #404 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 263: pop\n 264: iinc 7, 1\n 267: goto 225\n 270: aload 6\n 272: checkcast #29 // class java/util/List\n 275: astore 5\n 277: new #23 // class java/util/ArrayList\n 280: dup\n 281: iload_1\n 282: invokespecial #400 // Method java/util/ArrayList.\"<init>\":(I)V\n 285: astore 7\n 287: iconst_0\n 288: istore 8\n 290: iload 8\n 292: iload_1\n 293: if_icmpge 335\n 296: iload 8\n 298: istore 9\n 300: aload 7\n 302: iload 9\n 304: istore 10\n 306: astore 27\n 308: iconst_0\n 309: istore 11\n 311: new #23 // class java/util/ArrayList\n 314: dup\n 315: invokespecial #27 // Method java/util/ArrayList.\"<init>\":()V\n 318: checkcast #29 // class java/util/List\n 321: nop\n 322: aload 27\n 324: swap\n 325: invokevirtual #404 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 328: pop\n 329: iinc 8, 1\n 332: goto 290\n 335: aload 7\n 337: checkcast #29 // class java/util/List\n 340: astore 6\n 342: iconst_0\n 343: istore 7\n 345: iload 7\n 347: iload 4\n 349: if_icmpge 520\n 352: iload 7\n 354: istore 8\n 356: iconst_0\n 357: istore 9\n 359: iconst_2\n 360: istore 10\n 362: new #23 // class java/util/ArrayList\n 365: dup\n 366: iload 10\n 368: invokespecial #400 // Method java/util/ArrayList.\"<init>\":(I)V\n 371: astore 11\n 373: iconst_0\n 374: istore 12\n 376: iload 12\n 378: iload 10\n 380: if_icmpge 420\n 383: iload 12\n 385: istore 13\n 387: aload 11\n 389: iload 13\n 391: istore 14\n 393: astore 15\n 395: iconst_0\n 396: istore 16\n 398: aload_0\n 399: invokevirtual #397 // Method java/util/Scanner.nextInt:()I\n 402: iconst_1\n 403: isub\n 404: invokestatic #409 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 407: aload 15\n 409: swap\n 410: invokevirtual #404 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 413: pop\n 414: iinc 12, 1\n 417: goto 376\n 420: aload 11\n 422: checkcast #29 // class java/util/List\n 425: astore 17\n 427: aload 17\n 429: iconst_0\n 430: invokeinterface #228, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 435: checkcast #88 // class java/lang/Number\n 438: invokevirtual #92 // Method java/lang/Number.intValue:()I\n 441: istore 10\n 443: aload 17\n 445: iconst_1\n 446: invokeinterface #228, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 451: checkcast #88 // class java/lang/Number\n 454: invokevirtual #92 // Method java/lang/Number.intValue:()I\n 457: istore 11\n 459: iload 11\n 461: invokestatic #409 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 464: astore 13\n 466: aload 5\n 468: iload 10\n 470: invokeinterface #228, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 475: checkcast #9 // class java/util/Collection\n 478: aload 13\n 480: invokeinterface #410, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 485: pop\n 486: iload 10\n 488: invokestatic #409 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 491: astore 13\n 493: aload 6\n 495: iload 11\n 497: invokeinterface #228, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 502: checkcast #9 // class java/util/Collection\n 505: aload 13\n 507: invokeinterface #410, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 512: pop\n 513: nop\n 514: iinc 7, 1\n 517: goto 345\n 520: new #23 // class java/util/ArrayList\n 523: dup\n 524: iload_1\n 525: invokespecial #400 // Method java/util/ArrayList.\"<init>\":(I)V\n 528: astore 8\n 530: iconst_0\n 531: istore 9\n 533: iload 9\n 535: iload_1\n 536: if_icmpge 733\n 539: iload 9\n 541: istore 10\n 543: aload 8\n 545: iload 10\n 547: istore 11\n 549: astore 27\n 551: iconst_0\n 552: istore 12\n 554: iconst_3\n 555: istore 13\n 557: new #23 // class java/util/ArrayList\n 560: dup\n 561: iload 13\n 563: invokespecial #400 // Method java/util/ArrayList.\"<init>\":(I)V\n 566: astore 14\n 568: iconst_0\n 569: istore 15\n 571: iload 15\n 573: iload 13\n 575: if_icmpge 613\n 578: iload 15\n 580: istore 16\n 582: aload 14\n 584: iload 16\n 586: istore 17\n 588: astore 18\n 590: iconst_0\n 591: istore 19\n 593: aload_0\n 594: invokevirtual #403 // Method java/util/Scanner.nextLong:()J\n 597: invokestatic #214 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 600: aload 18\n 602: swap\n 603: invokevirtual #404 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 606: pop\n 607: iinc 15, 1\n 610: goto 571\n 613: aload 14\n 615: checkcast #29 // class java/util/List\n 618: astore 20\n 620: aload 20\n 622: iconst_0\n 623: invokeinterface #228, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 628: checkcast #88 // class java/lang/Number\n 631: invokevirtual #221 // Method java/lang/Number.longValue:()J\n 634: lstore 21\n 636: aload 20\n 638: iconst_1\n 639: invokeinterface #228, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 644: checkcast #88 // class java/lang/Number\n 647: invokevirtual #221 // Method java/lang/Number.longValue:()J\n 650: lstore 23\n 652: aload 20\n 654: iconst_2\n 655: invokeinterface #228, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 660: checkcast #88 // class java/lang/Number\n 663: invokevirtual #221 // Method java/lang/Number.longValue:()J\n 666: lstore 25\n 668: new #120 // class Job\n 671: dup\n 672: aload_2\n 673: iload 11\n 675: invokeinterface #228, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 680: checkcast #88 // class java/lang/Number\n 683: invokevirtual #221 // Method java/lang/Number.longValue:()J\n 686: aload_3\n 687: iload 11\n 689: invokeinterface #228, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 694: checkcast #88 // class java/lang/Number\n 697: invokevirtual #221 // Method java/lang/Number.longValue:()J\n 700: iload 11\n 702: lload 21\n 704: lload 23\n 706: lload 25\n 708: invokedynamic #420, 0 // InvokeDynamic #6:invoke:(JJJ)Lkotlin/jvm/functions/Function1;\n 713: aconst_null\n 714: bipush 16\n 716: aconst_null\n 717: invokespecial #423 // Method Job.\"<init>\":(JJILkotlin/jvm/functions/Function1;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 720: aload 27\n 722: swap\n 723: invokevirtual #404 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 726: pop\n 727: iinc 9, 1\n 730: goto 533\n 733: aload 8\n 735: checkcast #29 // class java/util/List\n 738: astore 7\n 740: aload 7\n 742: aload 5\n 744: aload 6\n 746: invokestatic #425 // Method schedule1PrecPmtnRFMax:(Ljava/util/List;Ljava/util/List;Ljava/util/List;)J\n 749: lstore 8\n 751: new #359 // class java/io/File\n 754: dup\n 755: ldc_w #427 // String p1precpmtnrifmax.out\n 758: invokespecial #364 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 761: astore 10\n 763: getstatic #370 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 766: astore 11\n 768: new #429 // class java/io/PrintWriter\n 771: dup\n 772: aload 10\n 774: astore 12\n 776: sipush 8192\n 779: istore 13\n 781: aload 12\n 783: astore 14\n 785: new #431 // class java/io/OutputStreamWriter\n 788: dup\n 789: new #433 // class java/io/FileOutputStream\n 792: dup\n 793: aload 14\n 795: invokespecial #434 // Method java/io/FileOutputStream.\"<init>\":(Ljava/io/File;)V\n 798: checkcast #436 // class java/io/OutputStream\n 801: aload 11\n 803: invokespecial #439 // Method java/io/OutputStreamWriter.\"<init>\":(Ljava/io/OutputStream;Ljava/nio/charset/Charset;)V\n 806: checkcast #441 // class java/io/Writer\n 809: astore 14\n 811: aload 14\n 813: instanceof #443 // class java/io/BufferedWriter\n 816: ifeq 827\n 819: aload 14\n 821: checkcast #443 // class java/io/BufferedWriter\n 824: goto 838\n 827: new #443 // class java/io/BufferedWriter\n 830: dup\n 831: aload 14\n 833: iload 13\n 835: invokespecial #446 // Method java/io/BufferedWriter.\"<init>\":(Ljava/io/Writer;I)V\n 838: checkcast #441 // class java/io/Writer\n 841: invokespecial #449 // Method java/io/PrintWriter.\"<init>\":(Ljava/io/Writer;)V\n 844: checkcast #451 // class java/io/Closeable\n 847: astore 10\n 849: aconst_null\n 850: astore 11\n 852: nop\n 853: aload 10\n 855: checkcast #429 // class java/io/PrintWriter\n 858: astore 12\n 860: iconst_0\n 861: istore 13\n 863: aload 12\n 865: lload 8\n 867: invokevirtual #454 // Method java/io/PrintWriter.println:(J)V\n 870: aload 7\n 872: checkcast #40 // class java/lang/Iterable\n 875: astore 14\n 877: iconst_0\n 878: istore 15\n 880: aload 14\n 882: invokeinterface #118, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 887: astore 16\n 889: aload 16\n 891: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 896: ifeq 1047\n 899: aload 16\n 901: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 906: astore 17\n 908: aload 17\n 910: checkcast #120 // class Job\n 913: astore 18\n 915: iconst_0\n 916: istore 19\n 918: aload 12\n 920: new #456 // class java/lang/StringBuilder\n 923: dup\n 924: invokespecial #457 // Method java/lang/StringBuilder.\"<init>\":()V\n 927: aload 18\n 929: invokevirtual #239 // Method Job.getTimes:()Ljava/util/List;\n 932: invokeinterface #460, 1 // InterfaceMethod java/util/List.size:()I\n 937: iconst_2\n 938: idiv\n 939: invokevirtual #464 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 942: bipush 32\n 944: invokevirtual #467 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 947: invokevirtual #471 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 950: invokevirtual #474 // Method java/io/PrintWriter.write:(Ljava/lang/String;)V\n 953: aload 18\n 955: invokevirtual #239 // Method Job.getTimes:()Ljava/util/List;\n 958: checkcast #40 // class java/lang/Iterable\n 961: astore 20\n 963: iconst_0\n 964: istore 21\n 966: aload 20\n 968: invokeinterface #118, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 973: astore 22\n 975: aload 22\n 977: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 982: ifeq 1036\n 985: aload 22\n 987: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 992: astore 23\n 994: aload 23\n 996: checkcast #88 // class java/lang/Number\n 999: invokevirtual #221 // Method java/lang/Number.longValue:()J\n 1002: lstore 24\n 1004: iconst_0\n 1005: istore 26\n 1007: aload 12\n 1009: new #456 // class java/lang/StringBuilder\n 1012: dup\n 1013: invokespecial #457 // Method java/lang/StringBuilder.\"<init>\":()V\n 1016: lload 24\n 1018: invokevirtual #477 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 1021: bipush 32\n 1023: invokevirtual #467 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 1026: invokevirtual #471 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 1029: invokevirtual #480 // Method java/io/PrintWriter.print:(Ljava/lang/String;)V\n 1032: nop\n 1033: goto 975\n 1036: nop\n 1037: aload 12\n 1039: invokevirtual #482 // Method java/io/PrintWriter.println:()V\n 1042: nop\n 1043: nop\n 1044: goto 889\n 1047: nop\n 1048: nop\n 1049: getstatic #488 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 1052: astore 12\n 1054: aload 10\n 1056: aload 11\n 1058: invokestatic #494 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 1061: goto 1085\n 1064: astore 13\n 1066: aload 13\n 1068: astore 11\n 1070: aload 13\n 1072: athrow\n 1073: astore 13\n 1075: aload 10\n 1077: aload 11\n 1079: invokestatic #494 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 1082: aload 13\n 1084: athrow\n 1085: return\n Exception table:\n from to target type\n 852 1054 1064 Class java/lang/Throwable\n 852 1054 1073 any\n 1064 1073 1073 any\n 1073 1075 1073 any\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #524 // Method main:()V\n 3: return\n\n private static final boolean topologicalSort$depthFirstSearch$lambda$0(java.util.Set, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: invokestatic #409 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 5: invokeinterface #531, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 10: ifne 17\n 13: iconst_1\n 14: goto 18\n 17: iconst_0\n 18: ireturn\n\n private static final void topologicalSort$depthFirstSearch(java.util.List<? extends java.util.List<java.lang.Integer>>, java.util.List<Job>, int, java.util.List<Job>, java.util.Set<java.lang.Integer>);\n Code:\n 0: aload 4\n 2: iload_2\n 3: invokestatic #409 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 6: invokeinterface #531, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 11: ifeq 15\n 14: return\n 15: iload_2\n 16: invokestatic #409 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 19: astore 6\n 21: aload 4\n 23: checkcast #9 // class java/util/Collection\n 26: aload 6\n 28: invokeinterface #410, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 33: pop\n 34: aload_0\n 35: iload_2\n 36: invokeinterface #228, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 41: checkcast #40 // class java/lang/Iterable\n 44: invokestatic #44 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 47: aload 4\n 49: invokedynamic #539, 0 // InvokeDynamic #7:invoke:(Ljava/util/Set;)Lkotlin/jvm/functions/Function1;\n 54: invokestatic #70 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 57: astore 5\n 59: nop\n 60: iconst_0\n 61: istore 6\n 63: aload 5\n 65: invokeinterface #76, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 70: astore 7\n 72: aload 7\n 74: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 79: ifeq 118\n 82: aload 7\n 84: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 89: astore 8\n 91: aload 8\n 93: checkcast #88 // class java/lang/Number\n 96: invokevirtual #92 // Method java/lang/Number.intValue:()I\n 99: istore 9\n 101: iconst_0\n 102: istore 10\n 104: aload_0\n 105: aload_1\n 106: iload 9\n 108: aload_3\n 109: aload 4\n 111: invokestatic #96 // Method topologicalSort$depthFirstSearch:(Ljava/util/List;Ljava/util/List;ILjava/util/List;Ljava/util/Set;)V\n 114: nop\n 115: goto 72\n 118: nop\n 119: aload_3\n 120: checkcast #9 // class java/util/Collection\n 123: aload_1\n 124: iload_2\n 125: invokeinterface #228, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 130: invokeinterface #410, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 135: pop\n 136: return\n\n private static final boolean topologicalSort$lambda$2(java.util.Set, java.util.List, int);\n Code:\n 0: aload_0\n 1: iload_2\n 2: invokestatic #409 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 5: invokeinterface #531, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 10: ifne 35\n 13: aload_1\n 14: iload_2\n 15: invokeinterface #228, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 20: checkcast #29 // class java/util/List\n 23: invokeinterface #236, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 28: ifeq 35\n 31: iconst_1\n 32: goto 36\n 35: iconst_0\n 36: ireturn\n\n private static final kotlin.Pair decompose$lambda$8(Block, int);\n Code:\n 0: iload_1\n 1: invokestatic #409 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 4: aload_0\n 5: invokevirtual #165 // Method Block.getJobs:()Ljava/util/List;\n 8: iload_1\n 9: invokeinterface #228, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 14: invokestatic #545 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 17: areturn\n\n private static final boolean decompose$lambda$11(java.util.List, java.util.Set, kotlin.Pair);\n Code:\n 0: aload_2\n 1: ldc_w #548 // String <destruct>\n 4: invokestatic #310 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_2\n 8: invokevirtual #204 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 11: checkcast #120 // class Job\n 14: astore_3\n 15: aload_0\n 16: aload_3\n 17: invokevirtual #320 // Method Job.getIndex:()I\n 20: invokeinterface #228, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 25: checkcast #40 // class java/lang/Iterable\n 28: astore 4\n 30: iconst_0\n 31: istore 5\n 33: aload 4\n 35: instanceof #9 // class java/util/Collection\n 38: ifeq 58\n 41: aload 4\n 43: checkcast #9 // class java/util/Collection\n 46: invokeinterface #549, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 51: ifeq 58\n 54: iconst_1\n 55: goto 118\n 58: aload 4\n 60: invokeinterface #118, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 65: astore 6\n 67: aload 6\n 69: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 74: ifeq 117\n 77: aload 6\n 79: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 84: astore 7\n 86: aload 7\n 88: checkcast #88 // class java/lang/Number\n 91: invokevirtual #92 // Method java/lang/Number.intValue:()I\n 94: istore 8\n 96: iconst_0\n 97: istore 9\n 99: aload_1\n 100: iload 8\n 102: invokestatic #409 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 105: invokeinterface #531, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 110: ifeq 67\n 113: iconst_0\n 114: goto 118\n 117: iconst_1\n 118: istore 4\n 120: iload 4\n 122: istore 5\n 124: iconst_0\n 125: istore 6\n 127: aload_1\n 128: checkcast #9 // class java/util/Collection\n 131: aload_3\n 132: invokevirtual #320 // Method Job.getIndex:()I\n 135: invokestatic #409 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 138: invokeinterface #410, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 143: pop\n 144: nop\n 145: iload 4\n 147: ireturn\n\n private static final kotlin.Pair decompose$lambda$13(java.util.List);\n Code:\n 0: aload_0\n 1: ldc_w #548 // String <destruct>\n 4: invokestatic #310 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: iconst_0\n 9: invokeinterface #228, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 14: checkcast #126 // class Block\n 17: astore_1\n 18: aload_0\n 19: iconst_1\n 20: invokeinterface #228, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 25: checkcast #126 // class Block\n 28: astore_2\n 29: aload_1\n 30: invokevirtual #130 // Method Block.getEnd:()J\n 33: invokestatic #214 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 36: aload_2\n 37: invokevirtual #242 // Method Block.getStart:()J\n 40: invokestatic #214 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 43: invokestatic #545 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 46: areturn\n\n private static final boolean decompose$lambda$14(kotlin.Pair);\n Code:\n 0: aload_0\n 1: ldc_w #548 // String <destruct>\n 4: invokestatic #310 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokevirtual #560 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 11: checkcast #88 // class java/lang/Number\n 14: invokevirtual #221 // Method java/lang/Number.longValue:()J\n 17: lstore_1\n 18: aload_0\n 19: invokevirtual #204 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 22: checkcast #88 // class java/lang/Number\n 25: invokevirtual #221 // Method java/lang/Number.longValue:()J\n 28: lstore_3\n 29: lload_1\n 30: lload_3\n 31: lcmp\n 32: ifge 39\n 35: iconst_1\n 36: goto 40\n 39: iconst_0\n 40: ireturn\n\n private static final Job schedule1PrecPmtnRFMax$lambda$19$lambda$17(java.util.List, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: invokeinterface #228, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #120 // class Job\n 10: areturn\n\n private static final long main$lambda$30$lambda$29(long, long, long, long);\n Code:\n 0: lload_0\n 1: lload 6\n 3: lmul\n 4: lload 6\n 6: lmul\n 7: lload_2\n 8: lload 6\n 10: lmul\n 11: ladd\n 12: lload 4\n 14: ladd\n 15: lreturn\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day15.kt
|
import kotlin.math.abs
object Day15 {
const val EXPECTED_PART1_CHECK_ANSWER = 26
const val EXPECTED_PART2_CHECK_ANSWER = 56000011L
const val PART1_CHECK_ROW = 10
const val PART1_ROW = 2_000_000
const val PART2_CHECK_MAX = 20
const val PART2_MAX = 4_000_000
const val PART2_MULTIPLY_VALUE = 4_000_000
}
fun main() {
fun String.parseSensorAndBeaconCoordinatess(): Pair<Coordinates, Coordinates> {
val (sensorX, sensorY, beaconX, beaconY) = Regex("Sensor at x=([-\\d]+), y=([-\\d]+): closest beacon is at x=([-\\d]+), y=([-\\d]+)")
.matchEntire(this)
?.destructured ?: error("Should match regex")
return Coordinates(sensorX.toInt(), sensorY.toInt()) to Coordinates(beaconX.toInt(), beaconY.toInt())
}
data class RowInfo(val positionsCovered: Int, val notCovered: Coordinates?)
fun rowInfo(
row: Int,
gridMin: Int,
gridMax: Int,
sensorAndBeaconCoordinates: List<Pair<Coordinates, Coordinates>>
): RowInfo {
val coveredRangesOnRow = mutableListOf<IntRange>()
for (sensorAndBeaconCoordinate in sensorAndBeaconCoordinates) {
val sensorLocation = sensorAndBeaconCoordinate.first
val beaconLocation = sensorAndBeaconCoordinate.second
val distance = abs(sensorLocation.x - beaconLocation.x) + abs(sensorLocation.y - beaconLocation.y)
val positionsCoveredAtSensorRow = distance * 2 + 1
val yDistanceToCheckRow = abs(sensorLocation.y - row)
val positionsCoveredAtCheckRow = positionsCoveredAtSensorRow - yDistanceToCheckRow * 2
if (positionsCoveredAtCheckRow > 0) {
val xFrom = maxOf(gridMin, sensorLocation.x - (positionsCoveredAtCheckRow / 2))
val xTo = minOf(gridMax, sensorLocation.x + (positionsCoveredAtCheckRow / 2))
val range = xFrom..xTo
coveredRangesOnRow.add(range)
val overlappingRanges =
coveredRangesOnRow
.filter { range.first in it || range.last in it || it.first in range || it.last in range }
if (overlappingRanges.isNotEmpty()) {
val mergedRange = overlappingRanges.reduce { acc, intRange ->
minOf(acc.first, intRange.first)..maxOf(
acc.last,
intRange.last
)
}
coveredRangesOnRow.add(mergedRange)
overlappingRanges.forEach { coveredRangesOnRow.remove(it) }
}
}
}
val coveredCount = coveredRangesOnRow.sumOf { it.count() }
val notCovered = if (gridMax - gridMin - coveredCount >= 0) {
// find in ranges the open position..
if (coveredRangesOnRow.size == 1) {
if (coveredRangesOnRow[0].first > gridMin) {
gridMin
} else {
gridMax
}
} else {
coveredRangesOnRow
.sortedBy { it.first }
.windowed(2)
.first { it.first().last + 1 < it[1].first }
.let { it.first().last + 1 }
}
} else null
return RowInfo(coveredCount, if (notCovered != null) Coordinates(notCovered, row) else null)
}
fun part1(input: List<String>, checkRow: Int): Int {
val sensorAndBeaconCoordinates = input.map(String::parseSensorAndBeaconCoordinatess)
val (min, max) = sensorAndBeaconCoordinates.flatMap { listOf(it.first, it.second) }.findMinAndMax()
val beaconCoordinates = sensorAndBeaconCoordinates.map { it.second }
val beaconsOnCheckRow = beaconCoordinates.toSet().filter { it.y == checkRow }.size
return rowInfo(checkRow, min.x, max.x, sensorAndBeaconCoordinates).positionsCovered - beaconsOnCheckRow
}
fun part2(input: List<String>, max: Int): Long {
val sensorAndBeaconCoordinates = input.map(String::parseSensorAndBeaconCoordinatess)
var notCoveredRow: RowInfo? = null
for (row in max downTo 0) {
val rowInfo = rowInfo(row, 0, max, sensorAndBeaconCoordinates)
println("Row $row")
if (rowInfo.notCovered != null) {
notCoveredRow = rowInfo
break
}
}
if (notCoveredRow != null) {
return notCoveredRow.notCovered!!.x.toLong() * Day15.PART2_MULTIPLY_VALUE + notCoveredRow.notCovered!!.y
}
return -1
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day15_test")
println("Checking")
check(part1(testInput, Day15.PART1_CHECK_ROW) == Day15.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
check(part2(testInput, Day15.PART2_CHECK_MAX) == Day15.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }
println("On real data")
val input = readInput("Day15")
println(part1(input, Day15.PART1_ROW))
println(part2(input, Day15.PART2_MAX))
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day15.class",
"javap": "Compiled from \"Day15.kt\"\npublic final class Day15 {\n public static final Day15 INSTANCE;\n\n public static final int EXPECTED_PART1_CHECK_ANSWER;\n\n public static final long EXPECTED_PART2_CHECK_ANSWER;\n\n public static final int PART1_CHECK_ROW;\n\n public static final int PART1_ROW;\n\n public static final int PART2_CHECK_MAX;\n\n public static final int PART2_MAX;\n\n public static final int PART2_MULTIPLY_VALUE;\n\n private Day15();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n static {};\n Code:\n 0: new #2 // class Day15\n 3: dup\n 4: invokespecial #12 // Method \"<init>\":()V\n 7: putstatic #15 // Field INSTANCE:LDay15;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day15Kt.class",
"javap": "Compiled from \"Day15.kt\"\npublic final class Day15Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day15_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: ldc #16 // String Checking\n 8: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 11: swap\n 12: invokevirtual #28 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 15: aload_0\n 16: bipush 10\n 18: invokestatic #32 // Method main$part1:(Ljava/util/List;I)I\n 21: bipush 26\n 23: if_icmpne 30\n 26: iconst_1\n 27: goto 31\n 30: iconst_0\n 31: ifne 51\n 34: iconst_0\n 35: istore_2\n 36: ldc #34 // String Part 1 failed\n 38: astore_2\n 39: new #36 // class java/lang/IllegalStateException\n 42: dup\n 43: aload_2\n 44: invokevirtual #40 // Method java/lang/Object.toString:()Ljava/lang/String;\n 47: invokespecial #44 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 50: athrow\n 51: aload_0\n 52: bipush 20\n 54: invokestatic #48 // Method main$part2:(Ljava/util/List;I)J\n 57: ldc2_w #49 // long 56000011l\n 60: lcmp\n 61: ifne 68\n 64: iconst_1\n 65: goto 69\n 68: iconst_0\n 69: ifne 89\n 72: iconst_0\n 73: istore_2\n 74: ldc #52 // String Part 2 failed\n 76: astore_2\n 77: new #36 // class java/lang/IllegalStateException\n 80: dup\n 81: aload_2\n 82: invokevirtual #40 // Method java/lang/Object.toString:()Ljava/lang/String;\n 85: invokespecial #44 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 88: athrow\n 89: ldc #54 // String On real data\n 91: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 94: swap\n 95: invokevirtual #28 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 98: ldc #56 // String Day15\n 100: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 103: astore_1\n 104: aload_1\n 105: ldc #57 // int 2000000\n 107: invokestatic #32 // Method main$part1:(Ljava/util/List;I)I\n 110: istore_2\n 111: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 114: iload_2\n 115: invokevirtual #60 // Method java/io/PrintStream.println:(I)V\n 118: aload_1\n 119: ldc #61 // int 4000000\n 121: invokestatic #48 // Method main$part2:(Ljava/util/List;I)J\n 124: lstore_2\n 125: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 128: lload_2\n 129: invokevirtual #64 // Method java/io/PrintStream.println:(J)V\n 132: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #75 // Method main:()V\n 3: return\n\n private static final kotlin.Pair<Coordinates, Coordinates> main$parseSensorAndBeaconCoordinatess(java.lang.String);\n Code:\n 0: new #82 // class kotlin/text/Regex\n 3: dup\n 4: ldc #84 // String Sensor at x=([-\\\\d]+), y=([-\\\\d]+): closest beacon is at x=([-\\\\d]+), y=([-\\\\d]+)\n 6: invokespecial #85 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 9: aload_0\n 10: checkcast #87 // class java/lang/CharSequence\n 13: invokevirtual #91 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;\n 16: astore_2\n 17: aload_2\n 18: ifnull 36\n 21: aload_2\n 22: invokeinterface #97, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 27: astore_3\n 28: aload_3\n 29: ifnull 36\n 32: aload_3\n 33: goto 49\n 36: new #36 // class java/lang/IllegalStateException\n 39: dup\n 40: ldc #99 // String Should match regex\n 42: invokevirtual #40 // Method java/lang/Object.toString:()Ljava/lang/String;\n 45: invokespecial #44 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 48: athrow\n 49: astore_1\n 50: aload_1\n 51: invokevirtual #105 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 54: invokeinterface #109, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 59: iconst_1\n 60: invokeinterface #113, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 65: checkcast #115 // class java/lang/String\n 68: astore_2\n 69: aload_1\n 70: invokevirtual #105 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 73: invokeinterface #109, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 78: iconst_2\n 79: invokeinterface #113, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 84: checkcast #115 // class java/lang/String\n 87: astore_3\n 88: aload_1\n 89: invokevirtual #105 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 92: invokeinterface #109, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 97: iconst_3\n 98: invokeinterface #113, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 103: checkcast #115 // class java/lang/String\n 106: astore 4\n 108: aload_1\n 109: invokevirtual #105 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 112: invokeinterface #109, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 117: iconst_4\n 118: invokeinterface #113, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 123: checkcast #115 // class java/lang/String\n 126: astore 5\n 128: new #117 // class Coordinates\n 131: dup\n 132: aload_2\n 133: invokestatic #123 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 136: aload_3\n 137: invokestatic #123 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 140: invokespecial #126 // Method Coordinates.\"<init>\":(II)V\n 143: new #117 // class Coordinates\n 146: dup\n 147: aload 4\n 149: invokestatic #123 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 152: aload 5\n 154: invokestatic #123 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 157: invokespecial #126 // Method Coordinates.\"<init>\":(II)V\n 160: invokestatic #132 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 163: areturn\n\n private static final Day15Kt$main$RowInfo main$rowInfo(int, int, int, java.util.List<kotlin.Pair<Coordinates, Coordinates>>);\n Code:\n 0: new #143 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #145 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #72 // class java/util/List\n 10: astore 4\n 12: aload_3\n 13: invokeinterface #149, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 18: astore 5\n 20: aload 5\n 22: invokeinterface #155, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 27: ifeq 691\n 30: aload 5\n 32: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 37: checkcast #161 // class kotlin/Pair\n 40: astore 6\n 42: aload 6\n 44: invokevirtual #164 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 47: checkcast #117 // class Coordinates\n 50: astore 7\n 52: aload 6\n 54: invokevirtual #167 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 57: checkcast #117 // class Coordinates\n 60: astore 8\n 62: aload 7\n 64: invokevirtual #171 // Method Coordinates.getX:()I\n 67: aload 8\n 69: invokevirtual #171 // Method Coordinates.getX:()I\n 72: isub\n 73: invokestatic #177 // Method java/lang/Math.abs:(I)I\n 76: aload 7\n 78: invokevirtual #180 // Method Coordinates.getY:()I\n 81: aload 8\n 83: invokevirtual #180 // Method Coordinates.getY:()I\n 86: isub\n 87: invokestatic #177 // Method java/lang/Math.abs:(I)I\n 90: iadd\n 91: istore 9\n 93: iload 9\n 95: iconst_2\n 96: imul\n 97: iconst_1\n 98: iadd\n 99: istore 10\n 101: aload 7\n 103: invokevirtual #180 // Method Coordinates.getY:()I\n 106: iload_0\n 107: isub\n 108: invokestatic #177 // Method java/lang/Math.abs:(I)I\n 111: istore 11\n 113: iload 10\n 115: iload 11\n 117: iconst_2\n 118: imul\n 119: isub\n 120: istore 12\n 122: iload 12\n 124: ifle 20\n 127: iload_1\n 128: aload 7\n 130: invokevirtual #171 // Method Coordinates.getX:()I\n 133: iload 12\n 135: iconst_2\n 136: idiv\n 137: isub\n 138: invokestatic #184 // Method java/lang/Math.max:(II)I\n 141: istore 13\n 143: iload_2\n 144: aload 7\n 146: invokevirtual #171 // Method Coordinates.getX:()I\n 149: iload 12\n 151: iconst_2\n 152: idiv\n 153: iadd\n 154: invokestatic #187 // Method java/lang/Math.min:(II)I\n 157: istore 14\n 159: new #189 // class kotlin/ranges/IntRange\n 162: dup\n 163: iload 13\n 165: iload 14\n 167: invokespecial #190 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 170: astore 15\n 172: aload 4\n 174: aload 15\n 176: invokeinterface #194, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 181: pop\n 182: aload 4\n 184: checkcast #196 // class java/lang/Iterable\n 187: astore 17\n 189: nop\n 190: iconst_0\n 191: istore 18\n 193: aload 17\n 195: astore 19\n 197: new #143 // class java/util/ArrayList\n 200: dup\n 201: invokespecial #145 // Method java/util/ArrayList.\"<init>\":()V\n 204: checkcast #198 // class java/util/Collection\n 207: astore 20\n 209: iconst_0\n 210: istore 21\n 212: aload 19\n 214: invokeinterface #199, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 219: astore 22\n 221: aload 22\n 223: invokeinterface #155, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 228: ifeq 459\n 231: aload 22\n 233: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 238: astore 23\n 240: aload 23\n 242: checkcast #189 // class kotlin/ranges/IntRange\n 245: astore 24\n 247: iconst_0\n 248: istore 25\n 250: aload 24\n 252: invokevirtual #201 // Method kotlin/ranges/IntRange.getFirst:()I\n 255: istore 26\n 257: aload 24\n 259: invokevirtual #204 // Method kotlin/ranges/IntRange.getLast:()I\n 262: istore 27\n 264: aload 15\n 266: invokevirtual #201 // Method kotlin/ranges/IntRange.getFirst:()I\n 269: istore 28\n 271: iload 26\n 273: iload 28\n 275: if_icmpgt 293\n 278: iload 28\n 280: iload 27\n 282: if_icmpgt 289\n 285: iconst_1\n 286: goto 294\n 289: iconst_0\n 290: goto 294\n 293: iconst_0\n 294: ifne 438\n 297: aload 24\n 299: invokevirtual #201 // Method kotlin/ranges/IntRange.getFirst:()I\n 302: istore 26\n 304: aload 24\n 306: invokevirtual #204 // Method kotlin/ranges/IntRange.getLast:()I\n 309: istore 27\n 311: aload 15\n 313: invokevirtual #204 // Method kotlin/ranges/IntRange.getLast:()I\n 316: istore 28\n 318: iload 26\n 320: iload 28\n 322: if_icmpgt 340\n 325: iload 28\n 327: iload 27\n 329: if_icmpgt 336\n 332: iconst_1\n 333: goto 341\n 336: iconst_0\n 337: goto 341\n 340: iconst_0\n 341: ifne 438\n 344: aload 15\n 346: invokevirtual #201 // Method kotlin/ranges/IntRange.getFirst:()I\n 349: istore 26\n 351: aload 15\n 353: invokevirtual #204 // Method kotlin/ranges/IntRange.getLast:()I\n 356: istore 27\n 358: aload 24\n 360: invokevirtual #201 // Method kotlin/ranges/IntRange.getFirst:()I\n 363: istore 28\n 365: iload 26\n 367: iload 28\n 369: if_icmpgt 387\n 372: iload 28\n 374: iload 27\n 376: if_icmpgt 383\n 379: iconst_1\n 380: goto 388\n 383: iconst_0\n 384: goto 388\n 387: iconst_0\n 388: ifne 438\n 391: aload 15\n 393: invokevirtual #201 // Method kotlin/ranges/IntRange.getFirst:()I\n 396: istore 26\n 398: aload 15\n 400: invokevirtual #204 // Method kotlin/ranges/IntRange.getLast:()I\n 403: istore 27\n 405: aload 24\n 407: invokevirtual #204 // Method kotlin/ranges/IntRange.getLast:()I\n 410: istore 28\n 412: iload 26\n 414: iload 28\n 416: if_icmpgt 434\n 419: iload 28\n 421: iload 27\n 423: if_icmpgt 430\n 426: iconst_1\n 427: goto 435\n 430: iconst_0\n 431: goto 435\n 434: iconst_0\n 435: ifeq 442\n 438: iconst_1\n 439: goto 443\n 442: iconst_0\n 443: ifeq 221\n 446: aload 20\n 448: aload 23\n 450: invokeinterface #205, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 455: pop\n 456: goto 221\n 459: aload 20\n 461: checkcast #72 // class java/util/List\n 464: nop\n 465: astore 16\n 467: aload 16\n 469: checkcast #198 // class java/util/Collection\n 472: invokeinterface #208, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 477: ifne 484\n 480: iconst_1\n 481: goto 485\n 484: iconst_0\n 485: ifeq 20\n 488: aload 16\n 490: checkcast #196 // class java/lang/Iterable\n 493: astore 18\n 495: iconst_0\n 496: istore 19\n 498: aload 18\n 500: invokeinterface #199, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 505: astore 20\n 507: aload 20\n 509: invokeinterface #155, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 514: ifne 527\n 517: new #210 // class java/lang/UnsupportedOperationException\n 520: dup\n 521: ldc #212 // String Empty collection can\\'t be reduced.\n 523: invokespecial #213 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 526: athrow\n 527: aload 20\n 529: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 534: astore 21\n 536: aload 20\n 538: invokeinterface #155, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 543: ifeq 608\n 546: aload 21\n 548: aload 20\n 550: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 555: checkcast #189 // class kotlin/ranges/IntRange\n 558: astore 22\n 560: checkcast #189 // class kotlin/ranges/IntRange\n 563: astore 23\n 565: iconst_0\n 566: istore 24\n 568: new #189 // class kotlin/ranges/IntRange\n 571: dup\n 572: aload 23\n 574: invokevirtual #201 // Method kotlin/ranges/IntRange.getFirst:()I\n 577: aload 22\n 579: invokevirtual #201 // Method kotlin/ranges/IntRange.getFirst:()I\n 582: invokestatic #187 // Method java/lang/Math.min:(II)I\n 585: nop\n 586: aload 23\n 588: invokevirtual #204 // Method kotlin/ranges/IntRange.getLast:()I\n 591: aload 22\n 593: invokevirtual #204 // Method kotlin/ranges/IntRange.getLast:()I\n 596: invokestatic #184 // Method java/lang/Math.max:(II)I\n 599: invokespecial #190 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 602: nop\n 603: astore 21\n 605: goto 536\n 608: aload 21\n 610: checkcast #189 // class kotlin/ranges/IntRange\n 613: astore 17\n 615: aload 4\n 617: aload 17\n 619: invokeinterface #194, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 624: pop\n 625: aload 16\n 627: checkcast #196 // class java/lang/Iterable\n 630: astore 18\n 632: iconst_0\n 633: istore 19\n 635: aload 18\n 637: invokeinterface #199, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 642: astore 20\n 644: aload 20\n 646: invokeinterface #155, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 651: ifeq 687\n 654: aload 20\n 656: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 661: astore 21\n 663: aload 21\n 665: checkcast #189 // class kotlin/ranges/IntRange\n 668: astore 22\n 670: iconst_0\n 671: istore 23\n 673: aload 4\n 675: aload 22\n 677: invokeinterface #216, 2 // InterfaceMethod java/util/List.remove:(Ljava/lang/Object;)Z\n 682: pop\n 683: nop\n 684: goto 644\n 687: nop\n 688: goto 20\n 691: aload 4\n 693: checkcast #196 // class java/lang/Iterable\n 696: astore 6\n 698: iconst_0\n 699: istore 7\n 701: aload 6\n 703: invokeinterface #199, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 708: astore 8\n 710: aload 8\n 712: invokeinterface #155, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 717: ifeq 763\n 720: aload 8\n 722: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 727: astore 9\n 729: iload 7\n 731: aload 9\n 733: checkcast #189 // class kotlin/ranges/IntRange\n 736: astore 10\n 738: istore 29\n 740: iconst_0\n 741: istore 11\n 743: aload 10\n 745: checkcast #196 // class java/lang/Iterable\n 748: invokestatic #222 // Method kotlin/collections/CollectionsKt.count:(Ljava/lang/Iterable;)I\n 751: istore 30\n 753: iload 29\n 755: iload 30\n 757: iadd\n 758: istore 7\n 760: goto 710\n 763: iload 7\n 765: istore 5\n 767: iload_2\n 768: iload_1\n 769: isub\n 770: iload 5\n 772: isub\n 773: iflt 978\n 776: aload 4\n 778: invokeinterface #225, 1 // InterfaceMethod java/util/List.size:()I\n 783: iconst_1\n 784: if_icmpne 813\n 787: aload 4\n 789: iconst_0\n 790: invokeinterface #113, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 795: checkcast #189 // class kotlin/ranges/IntRange\n 798: invokevirtual #201 // Method kotlin/ranges/IntRange.getFirst:()I\n 801: iload_1\n 802: if_icmple 809\n 805: iload_1\n 806: goto 972\n 809: iload_2\n 810: goto 972\n 813: aload 4\n 815: checkcast #196 // class java/lang/Iterable\n 818: astore 7\n 820: nop\n 821: iconst_0\n 822: istore 8\n 824: aload 7\n 826: new #227 // class Day15Kt$main$rowInfo$$inlined$sortedBy$1\n 829: dup\n 830: invokespecial #228 // Method Day15Kt$main$rowInfo$$inlined$sortedBy$1.\"<init>\":()V\n 833: checkcast #230 // class java/util/Comparator\n 836: invokestatic #234 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 839: checkcast #196 // class java/lang/Iterable\n 842: iconst_2\n 843: iconst_0\n 844: iconst_0\n 845: bipush 6\n 847: aconst_null\n 848: invokestatic #238 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;\n 851: checkcast #196 // class java/lang/Iterable\n 854: astore 7\n 856: nop\n 857: iconst_0\n 858: istore 8\n 860: aload 7\n 862: invokeinterface #199, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 867: astore 9\n 869: aload 9\n 871: invokeinterface #155, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 876: ifeq 941\n 879: aload 9\n 881: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 886: astore 10\n 888: aload 10\n 890: checkcast #72 // class java/util/List\n 893: astore 11\n 895: iconst_0\n 896: istore 12\n 898: aload 11\n 900: invokestatic #242 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 903: checkcast #189 // class kotlin/ranges/IntRange\n 906: invokevirtual #204 // Method kotlin/ranges/IntRange.getLast:()I\n 909: iconst_1\n 910: iadd\n 911: aload 11\n 913: iconst_1\n 914: invokeinterface #113, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 919: checkcast #189 // class kotlin/ranges/IntRange\n 922: invokevirtual #201 // Method kotlin/ranges/IntRange.getFirst:()I\n 925: if_icmpge 932\n 928: iconst_1\n 929: goto 933\n 932: iconst_0\n 933: ifeq 869\n 936: aload 10\n 938: goto 951\n 941: new #244 // class java/util/NoSuchElementException\n 944: dup\n 945: ldc #246 // String Collection contains no element matching the predicate.\n 947: invokespecial #247 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 950: athrow\n 951: checkcast #72 // class java/util/List\n 954: astore 8\n 956: iconst_0\n 957: istore 9\n 959: aload 8\n 961: invokestatic #242 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 964: checkcast #189 // class kotlin/ranges/IntRange\n 967: invokevirtual #204 // Method kotlin/ranges/IntRange.getLast:()I\n 970: iconst_1\n 971: iadd\n 972: invokestatic #251 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 975: goto 979\n 978: aconst_null\n 979: astore 6\n 981: new #253 // class Day15Kt$main$RowInfo\n 984: dup\n 985: iload 5\n 987: aload 6\n 989: ifnull 1008\n 992: new #117 // class Coordinates\n 995: dup\n 996: aload 6\n 998: invokevirtual #256 // Method java/lang/Integer.intValue:()I\n 1001: iload_0\n 1002: invokespecial #126 // Method Coordinates.\"<init>\":(II)V\n 1005: goto 1009\n 1008: aconst_null\n 1009: invokespecial #259 // Method Day15Kt$main$RowInfo.\"<init>\":(ILCoordinates;)V\n 1012: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>, int);\n Code:\n 0: aload_0\n 1: checkcast #196 // class java/lang/Iterable\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: astore 5\n 11: new #143 // class java/util/ArrayList\n 14: dup\n 15: aload_3\n 16: bipush 10\n 18: invokestatic #317 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 21: invokespecial #319 // Method java/util/ArrayList.\"<init>\":(I)V\n 24: checkcast #198 // class java/util/Collection\n 27: astore 6\n 29: iconst_0\n 30: istore 7\n 32: aload 5\n 34: invokeinterface #199, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 8\n 41: aload 8\n 43: invokeinterface #155, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 91\n 51: aload 8\n 53: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 9\n 60: aload 6\n 62: aload 9\n 64: checkcast #115 // class java/lang/String\n 67: astore 10\n 69: astore 17\n 71: iconst_0\n 72: istore 11\n 74: aload 10\n 76: invokestatic #321 // Method main$parseSensorAndBeaconCoordinatess:(Ljava/lang/String;)Lkotlin/Pair;\n 79: aload 17\n 81: swap\n 82: invokeinterface #205, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 87: pop\n 88: goto 41\n 91: aload 6\n 93: checkcast #72 // class java/util/List\n 96: nop\n 97: astore_2\n 98: aload_2\n 99: checkcast #196 // class java/lang/Iterable\n 102: astore 4\n 104: iconst_0\n 105: istore 5\n 107: aload 4\n 109: astore 6\n 111: new #143 // class java/util/ArrayList\n 114: dup\n 115: invokespecial #145 // Method java/util/ArrayList.\"<init>\":()V\n 118: checkcast #198 // class java/util/Collection\n 121: astore 7\n 123: iconst_0\n 124: istore 8\n 126: aload 6\n 128: invokeinterface #199, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 133: astore 9\n 135: aload 9\n 137: invokeinterface #155, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 142: ifeq 209\n 145: aload 9\n 147: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 152: astore 10\n 154: aload 10\n 156: checkcast #161 // class kotlin/Pair\n 159: astore 11\n 161: iconst_0\n 162: istore 12\n 164: iconst_2\n 165: anewarray #117 // class Coordinates\n 168: astore 13\n 170: aload 13\n 172: iconst_0\n 173: aload 11\n 175: invokevirtual #164 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 178: aastore\n 179: aload 13\n 181: iconst_1\n 182: aload 11\n 184: invokevirtual #167 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 187: aastore\n 188: aload 13\n 190: invokestatic #325 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 193: checkcast #196 // class java/lang/Iterable\n 196: astore 11\n 198: aload 7\n 200: aload 11\n 202: invokestatic #329 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 205: pop\n 206: goto 135\n 209: aload 7\n 211: checkcast #72 // class java/util/List\n 214: nop\n 215: invokestatic #333 // Method UtilsKt.findMinAndMax:(Ljava/util/List;)Lkotlin/Pair;\n 218: astore_3\n 219: aload_3\n 220: invokevirtual #336 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 223: checkcast #117 // class Coordinates\n 226: astore 4\n 228: aload_3\n 229: invokevirtual #339 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 232: checkcast #117 // class Coordinates\n 235: astore 5\n 237: aload_2\n 238: checkcast #196 // class java/lang/Iterable\n 241: astore 7\n 243: iconst_0\n 244: istore 8\n 246: aload 7\n 248: astore 9\n 250: new #143 // class java/util/ArrayList\n 253: dup\n 254: aload 7\n 256: bipush 10\n 258: invokestatic #317 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 261: invokespecial #319 // Method java/util/ArrayList.\"<init>\":(I)V\n 264: checkcast #198 // class java/util/Collection\n 267: astore 10\n 269: iconst_0\n 270: istore 11\n 272: aload 9\n 274: invokeinterface #199, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 279: astore 12\n 281: aload 12\n 283: invokeinterface #155, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 288: ifeq 334\n 291: aload 12\n 293: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 298: astore 13\n 300: aload 10\n 302: aload 13\n 304: checkcast #161 // class kotlin/Pair\n 307: astore 14\n 309: astore 17\n 311: iconst_0\n 312: istore 15\n 314: aload 14\n 316: invokevirtual #167 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 319: checkcast #117 // class Coordinates\n 322: aload 17\n 324: swap\n 325: invokeinterface #205, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 330: pop\n 331: goto 281\n 334: aload 10\n 336: checkcast #72 // class java/util/List\n 339: nop\n 340: astore 6\n 342: aload 6\n 344: checkcast #196 // class java/lang/Iterable\n 347: invokestatic #343 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 350: checkcast #196 // class java/lang/Iterable\n 353: astore 8\n 355: iconst_0\n 356: istore 9\n 358: aload 8\n 360: astore 10\n 362: new #143 // class java/util/ArrayList\n 365: dup\n 366: invokespecial #145 // Method java/util/ArrayList.\"<init>\":()V\n 369: checkcast #198 // class java/util/Collection\n 372: astore 11\n 374: iconst_0\n 375: istore 12\n 377: aload 10\n 379: invokeinterface #199, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 384: astore 13\n 386: aload 13\n 388: invokeinterface #155, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 393: ifeq 445\n 396: aload 13\n 398: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 403: astore 14\n 405: aload 14\n 407: checkcast #117 // class Coordinates\n 410: astore 15\n 412: iconst_0\n 413: istore 16\n 415: aload 15\n 417: invokevirtual #180 // Method Coordinates.getY:()I\n 420: iload_1\n 421: if_icmpne 428\n 424: iconst_1\n 425: goto 429\n 428: iconst_0\n 429: ifeq 386\n 432: aload 11\n 434: aload 14\n 436: invokeinterface #205, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 441: pop\n 442: goto 386\n 445: aload 11\n 447: checkcast #72 // class java/util/List\n 450: nop\n 451: invokeinterface #225, 1 // InterfaceMethod java/util/List.size:()I\n 456: istore 7\n 458: iload_1\n 459: aload 4\n 461: invokevirtual #171 // Method Coordinates.getX:()I\n 464: aload 5\n 466: invokevirtual #171 // Method Coordinates.getX:()I\n 469: aload_2\n 470: invokestatic #345 // Method main$rowInfo:(IIILjava/util/List;)LDay15Kt$main$RowInfo;\n 473: invokevirtual #348 // Method Day15Kt$main$RowInfo.getPositionsCovered:()I\n 476: iload 7\n 478: isub\n 479: ireturn\n\n private static final long main$part2(java.util.List<java.lang.String>, int);\n Code:\n 0: aload_0\n 1: checkcast #196 // class java/lang/Iterable\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: astore 5\n 11: new #143 // class java/util/ArrayList\n 14: dup\n 15: aload_3\n 16: bipush 10\n 18: invokestatic #317 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 21: invokespecial #319 // Method java/util/ArrayList.\"<init>\":(I)V\n 24: checkcast #198 // class java/util/Collection\n 27: astore 6\n 29: iconst_0\n 30: istore 7\n 32: aload 5\n 34: invokeinterface #199, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 8\n 41: aload 8\n 43: invokeinterface #155, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 91\n 51: aload 8\n 53: invokeinterface #159, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 9\n 60: aload 6\n 62: aload 9\n 64: checkcast #115 // class java/lang/String\n 67: astore 10\n 69: astore 12\n 71: iconst_0\n 72: istore 11\n 74: aload 10\n 76: invokestatic #321 // Method main$parseSensorAndBeaconCoordinatess:(Ljava/lang/String;)Lkotlin/Pair;\n 79: aload 12\n 81: swap\n 82: invokeinterface #205, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 87: pop\n 88: goto 41\n 91: aload 6\n 93: checkcast #72 // class java/util/List\n 96: nop\n 97: astore_2\n 98: aconst_null\n 99: astore_3\n 100: iload_1\n 101: istore 4\n 103: iconst_m1\n 104: iload 4\n 106: if_icmpge 167\n 109: iload 4\n 111: iconst_0\n 112: iload_1\n 113: aload_2\n 114: invokestatic #345 // Method main$rowInfo:(IIILjava/util/List;)LDay15Kt$main$RowInfo;\n 117: astore 5\n 119: new #369 // class java/lang/StringBuilder\n 122: dup\n 123: invokespecial #370 // Method java/lang/StringBuilder.\"<init>\":()V\n 126: ldc_w #372 // String Row\n 129: invokevirtual #376 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 132: iload 4\n 134: invokevirtual #379 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 137: invokevirtual #380 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 140: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 143: swap\n 144: invokevirtual #28 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 147: aload 5\n 149: invokevirtual #384 // Method Day15Kt$main$RowInfo.getNotCovered:()LCoordinates;\n 152: ifnull 161\n 155: aload 5\n 157: astore_3\n 158: goto 167\n 161: iinc 4, -1\n 164: goto 103\n 167: aload_3\n 168: ifnull 201\n 171: aload_3\n 172: invokevirtual #384 // Method Day15Kt$main$RowInfo.getNotCovered:()LCoordinates;\n 175: dup\n 176: invokestatic #389 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 179: invokevirtual #171 // Method Coordinates.getX:()I\n 182: i2l\n 183: ldc #61 // int 4000000\n 185: i2l\n 186: lmul\n 187: aload_3\n 188: invokevirtual #384 // Method Day15Kt$main$RowInfo.getNotCovered:()LCoordinates;\n 191: dup\n 192: invokestatic #389 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 195: invokevirtual #180 // Method Coordinates.getY:()I\n 198: i2l\n 199: ladd\n 200: lreturn\n 201: ldc2_w #390 // long -1l\n 204: lreturn\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day15Kt$main$rowInfo$$inlined$sortedBy$1.class",
"javap": "Compiled from \"Comparisons.kt\"\npublic final class Day15Kt$main$rowInfo$$inlined$sortedBy$1<T> implements java.util.Comparator {\n public Day15Kt$main$rowInfo$$inlined$sortedBy$1();\n Code:\n 0: aload_0\n 1: invokespecial #16 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int compare(T, T);\n Code:\n 0: aload_1\n 1: checkcast #23 // class kotlin/ranges/IntRange\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method kotlin/ranges/IntRange.getFirst:()I\n 12: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 15: checkcast #35 // class java/lang/Comparable\n 18: aload_2\n 19: checkcast #23 // class kotlin/ranges/IntRange\n 22: astore_3\n 23: astore 5\n 25: iconst_0\n 26: istore 4\n 28: aload_3\n 29: invokevirtual #27 // Method kotlin/ranges/IntRange.getFirst:()I\n 32: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 35: aload 5\n 37: swap\n 38: checkcast #35 // class java/lang/Comparable\n 41: invokestatic #41 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I\n 44: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day15Kt$main$RowInfo.class",
"javap": "Compiled from \"Day15.kt\"\npublic final class Day15Kt$main$RowInfo {\n private final int positionsCovered;\n\n private final Coordinates notCovered;\n\n public Day15Kt$main$RowInfo(int, Coordinates);\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 positionsCovered:I\n 9: aload_0\n 10: aload_2\n 11: putfield #17 // Field notCovered:LCoordinates;\n 14: return\n\n public final int getPositionsCovered();\n Code:\n 0: aload_0\n 1: getfield #13 // Field positionsCovered:I\n 4: ireturn\n\n public final Coordinates getNotCovered();\n Code:\n 0: aload_0\n 1: getfield #17 // Field notCovered:LCoordinates;\n 4: areturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field positionsCovered:I\n 4: ireturn\n\n public final Coordinates component2();\n Code:\n 0: aload_0\n 1: getfield #17 // Field notCovered:LCoordinates;\n 4: areturn\n\n public final Day15Kt$main$RowInfo copy(int, Coordinates);\n Code:\n 0: new #2 // class Day15Kt$main$RowInfo\n 3: dup\n 4: iload_1\n 5: aload_2\n 6: invokespecial #29 // Method \"<init>\":(ILCoordinates;)V\n 9: areturn\n\n public static Day15Kt$main$RowInfo copy$default(Day15Kt$main$RowInfo, int, Coordinates, 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 positionsCovered: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 #17 // Field notCovered:LCoordinates;\n 21: astore_2\n 22: aload_0\n 23: iload_1\n 24: aload_2\n 25: invokevirtual #33 // Method copy:(ILCoordinates;)LDay15Kt$main$RowInfo;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #37 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #38 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #40 // String RowInfo(positionsCovered=\n 9: invokevirtual #44 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field positionsCovered:I\n 16: invokevirtual #47 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #49 // String , notCovered=\n 21: invokevirtual #44 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #17 // Field notCovered:LCoordinates;\n 28: invokevirtual #52 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)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 positionsCovered: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 #17 // Field notCovered:LCoordinates;\n 16: ifnonnull 23\n 19: iconst_0\n 20: goto 30\n 23: aload_0\n 24: getfield #17 // Field notCovered:LCoordinates;\n 27: invokevirtual #67 // Method Coordinates.hashCode:()I\n 30: iadd\n 31: istore_1\n 32: iload_1\n 33: 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 Day15Kt$main$RowInfo\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day15Kt$main$RowInfo\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field positionsCovered:I\n 25: aload_2\n 26: getfield #13 // Field positionsCovered:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #17 // Field notCovered:LCoordinates;\n 38: aload_2\n 39: getfield #17 // Field notCovered:LCoordinates;\n 42: invokestatic #76 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 45: ifne 50\n 48: iconst_0\n 49: ireturn\n 50: iconst_1\n 51: ireturn\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day19.kt
|
object Day19 {
const val EXPECTED_PART1_CHECK_ANSWER = 33
const val EXPECTED_PART2_CHECK_ANSWER = 3472
val BLUEPRINT_REGEX =
Regex("Blueprint (\\d+): Each ore robot costs (\\d+) ore. Each clay robot costs (\\d+) ore. Each obsidian robot costs (\\d+) ore and (\\d+) clay. Each geode robot costs (\\d+) ore and (\\d+) obsidian.")
const val PART1_MINUTES = 24
}
enum class RobotCurrency {
ORE, CLAY, OBSIDIAN
}
enum class RobotType {
ORE_COLLECTOR, CLAY_COLLECTOR, OBSIDIAN_COLLECTOR, GEODE_CRACKING
}
data class RobotBuildCost(val amount: Int, val currency: RobotCurrency)
data class Blueprint(
val id: Int,
val buildCosts: Map<RobotType, Set<RobotBuildCost>>,
)
data class CollectingState(
val minutesDone: Int = 0,
val orePerMinute: Int = 1,
val clayPerMinute: Int = 0,
val obsidianPerMinute: Int = 0,
val geoCrackedPerMinute: Int = 0,
val ore: Int = 0,
val clay: Int = 0,
val obs: Int = 0,
val geoCracked: Int = 0,
)
fun main() {
fun List<String>.parseBlueprints() =
map {
val (id, oreRobotOre, clayRobotOre, obsRobotOre, obsRobotClay, geoRobotOre, geoRobotObs) = Day19.BLUEPRINT_REGEX.matchEntire(
it
)?.destructured ?: error("Oops")
Blueprint(
id.toInt(),
mapOf(
RobotType.ORE_COLLECTOR to setOf(RobotBuildCost(oreRobotOre.toInt(), RobotCurrency.ORE)),
RobotType.CLAY_COLLECTOR to setOf(RobotBuildCost(clayRobotOre.toInt(), RobotCurrency.ORE)),
RobotType.OBSIDIAN_COLLECTOR to setOf(RobotBuildCost(obsRobotOre.toInt(), RobotCurrency.ORE), RobotBuildCost(obsRobotClay.toInt(), RobotCurrency.CLAY)),
RobotType.GEODE_CRACKING to setOf(RobotBuildCost(geoRobotOre.toInt(), RobotCurrency.ORE), RobotBuildCost(geoRobotObs.toInt(), RobotCurrency.OBSIDIAN)),
)
)
}
fun findBest(
blueprint: Blueprint,
minutesToRun: Int,
state: CollectingState,
): Int {
val minutesLeft = minutesToRun - state.minutesDone
return blueprint.buildCosts
.maxOf { (robotType, buildCosts) ->
if (
(robotType == RobotType.ORE_COLLECTOR && state.orePerMinute > 5) ||
(robotType == RobotType.CLAY_COLLECTOR && state.clayPerMinute > 5) ||
(robotType == RobotType.OBSIDIAN_COLLECTOR && state.obsidianPerMinute > 5)
){
-1
} else {
val minutesPerCurrency = buildCosts.map {
when (it.currency) {
RobotCurrency.ORE -> if (state.ore >= it.amount) 0 else if (state.orePerMinute > 0) it.amount - state.ore / state.orePerMinute else -1
RobotCurrency.CLAY -> if (state.clay >= it.amount) 0 else if (state.clayPerMinute > 0) it.amount - state.clay / state.clayPerMinute else -1
RobotCurrency.OBSIDIAN -> if (state.obs >= it.amount) 0 else if (state.obsidianPerMinute > 0) it.amount - state.obs / state.obsidianPerMinute else -1
}
}
val canNotMake = minutesPerCurrency.any { it == -1 }
val minutesUntilWeCanMakeRobot = minutesPerCurrency.max() + 1
if (canNotMake || minutesUntilWeCanMakeRobot >= minutesLeft) {
state.copy(
minutesDone = minutesToRun,
ore = state.ore + state.orePerMinute * minutesLeft,
clay = state.clay + state.clayPerMinute * minutesLeft,
obs = state.obs + state.obsidianPerMinute * minutesLeft,
geoCracked = state.geoCracked + state.geoCrackedPerMinute * minutesLeft,
).geoCracked
} else {
findBest(
blueprint,
minutesToRun,
state.copy(
minutesDone = state.minutesDone + minutesUntilWeCanMakeRobot,
ore = state.ore + (minutesUntilWeCanMakeRobot * state.orePerMinute) - (buildCosts.firstOrNull { it.currency == RobotCurrency.ORE }?.amount
?: 0),
clay = state.clay + (minutesUntilWeCanMakeRobot * state.clayPerMinute) - (buildCosts.firstOrNull { it.currency == RobotCurrency.CLAY }?.amount
?: 0),
obs = state.obs + (minutesUntilWeCanMakeRobot * state.obsidianPerMinute) - (buildCosts.firstOrNull { it.currency == RobotCurrency.OBSIDIAN }?.amount
?: 0),
geoCracked = state.geoCracked + (minutesUntilWeCanMakeRobot * state.geoCrackedPerMinute),
orePerMinute = state.orePerMinute + if (robotType == RobotType.ORE_COLLECTOR) 1 else 0,
clayPerMinute = state.clayPerMinute + if (robotType == RobotType.CLAY_COLLECTOR) 1 else 0,
obsidianPerMinute = state.obsidianPerMinute + if (robotType == RobotType.OBSIDIAN_COLLECTOR) 1 else 0,
geoCrackedPerMinute = state.geoCrackedPerMinute + if (robotType == RobotType.GEODE_CRACKING) 1 else 0,
)
)
}
}
}
}
fun part1(input: List<String>): Int {
val bluePrints = input.parseBlueprints()
println(bluePrints)
bluePrints.forEach { bluePrint -> println("${bluePrint.id}: ${findBest(bluePrint, 24 /*Day19.PART1_MINUTES*/, CollectingState())}") }
return 1
}
fun part2(input: List<String>): Int {
return 1
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day19_test")
check(part1(testInput) == Day19.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
check(part2(testInput) == Day19.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }
val input = readInput("Day19")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day19Kt$WhenMappings.class",
"javap": "Compiled from \"Day19.kt\"\npublic final class Day19Kt$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method RobotCurrency.values:()[LRobotCurrency;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field RobotCurrency.ORE:LRobotCurrency;\n 12: invokevirtual #22 // Method RobotCurrency.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 RobotCurrency.CLAY:LRobotCurrency;\n 26: invokevirtual #22 // Method RobotCurrency.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 RobotCurrency.OBSIDIAN:LRobotCurrency;\n 40: invokevirtual #22 // Method RobotCurrency.ordinal:()I\n 43: iconst_3\n 44: iastore\n 45: goto 49\n 48: astore_1\n 49: aload_0\n 50: putstatic #32 // Field $EnumSwitchMapping$0:[I\n 53: return\n Exception table:\n from to target type\n 7 17 20 Class java/lang/NoSuchFieldError\n 21 31 34 Class java/lang/NoSuchFieldError\n 35 45 48 Class java/lang/NoSuchFieldError\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day19Kt.class",
"javap": "Compiled from \"Day19.kt\"\npublic final class Day19Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day19_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 10: bipush 33\n 12: if_icmpne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 40\n 23: iconst_0\n 24: istore_2\n 25: ldc #20 // String Part 1 failed\n 27: astore_2\n 28: new #22 // class java/lang/IllegalStateException\n 31: dup\n 32: aload_2\n 33: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 36: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 39: athrow\n 40: aload_0\n 41: invokestatic #33 // Method main$part2:(Ljava/util/List;)I\n 44: sipush 3472\n 47: if_icmpne 54\n 50: iconst_1\n 51: goto 55\n 54: iconst_0\n 55: ifne 75\n 58: iconst_0\n 59: istore_2\n 60: ldc #35 // String Part 2 failed\n 62: astore_2\n 63: new #22 // class java/lang/IllegalStateException\n 66: dup\n 67: aload_2\n 68: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 71: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 74: athrow\n 75: ldc #37 // String Day19\n 77: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 80: astore_1\n 81: aload_1\n 82: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 85: istore_2\n 86: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 89: iload_2\n 90: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 93: aload_1\n 94: invokestatic #33 // Method main$part2:(Ljava/util/List;)I\n 97: istore_2\n 98: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 101: iload_2\n 102: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 105: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #60 // Method main:()V\n 3: return\n\n private static final java.util.List<Blueprint> main$parseBlueprints(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #67 // 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 #69 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #75 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #79 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 485\n 48: aload 6\n 50: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #95 // class java/lang/String\n 64: astore 8\n 66: astore 20\n 68: iconst_0\n 69: istore 9\n 71: getstatic #100 // Field Day19.INSTANCE:LDay19;\n 74: invokevirtual #104 // Method Day19.getBLUEPRINT_REGEX:()Lkotlin/text/Regex;\n 77: aload 8\n 79: checkcast #106 // class java/lang/CharSequence\n 82: invokevirtual #112 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;\n 85: astore 10\n 87: aload 10\n 89: ifnull 111\n 92: aload 10\n 94: invokeinterface #118, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 99: astore 11\n 101: aload 11\n 103: ifnull 111\n 106: aload 11\n 108: goto 124\n 111: new #22 // class java/lang/IllegalStateException\n 114: dup\n 115: ldc #120 // String Oops\n 117: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 120: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 123: athrow\n 124: astore 12\n 126: aload 12\n 128: invokevirtual #126 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 131: invokeinterface #130, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 136: iconst_1\n 137: invokeinterface #134, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 142: checkcast #95 // class java/lang/String\n 145: astore 10\n 147: aload 12\n 149: invokevirtual #126 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 152: invokeinterface #130, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 157: iconst_2\n 158: invokeinterface #134, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 163: checkcast #95 // class java/lang/String\n 166: astore 11\n 168: aload 12\n 170: invokevirtual #126 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 173: invokeinterface #130, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 178: iconst_3\n 179: invokeinterface #134, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 184: checkcast #95 // class java/lang/String\n 187: astore 13\n 189: aload 12\n 191: invokevirtual #126 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 194: invokeinterface #130, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 199: iconst_4\n 200: invokeinterface #134, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 205: checkcast #95 // class java/lang/String\n 208: astore 14\n 210: aload 12\n 212: invokevirtual #126 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 215: invokeinterface #130, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 220: iconst_5\n 221: invokeinterface #134, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 226: checkcast #95 // class java/lang/String\n 229: astore 15\n 231: aload 12\n 233: invokevirtual #126 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 236: invokeinterface #130, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 241: bipush 6\n 243: invokeinterface #134, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 248: checkcast #95 // class java/lang/String\n 251: astore 16\n 253: aload 12\n 255: invokevirtual #126 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 258: invokeinterface #130, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 263: bipush 7\n 265: invokeinterface #134, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 270: checkcast #95 // class java/lang/String\n 273: astore 17\n 275: new #136 // class Blueprint\n 278: dup\n 279: aload 10\n 281: invokestatic #142 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 284: iconst_4\n 285: anewarray #144 // class kotlin/Pair\n 288: astore 18\n 290: aload 18\n 292: iconst_0\n 293: getstatic #150 // Field RobotType.ORE_COLLECTOR:LRobotType;\n 296: new #152 // class RobotBuildCost\n 299: dup\n 300: aload 11\n 302: invokestatic #142 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 305: getstatic #158 // Field RobotCurrency.ORE:LRobotCurrency;\n 308: invokespecial #161 // Method RobotBuildCost.\"<init>\":(ILRobotCurrency;)V\n 311: invokestatic #167 // Method kotlin/collections/SetsKt.setOf:(Ljava/lang/Object;)Ljava/util/Set;\n 314: invokestatic #173 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 317: aastore\n 318: aload 18\n 320: iconst_1\n 321: getstatic #176 // Field RobotType.CLAY_COLLECTOR:LRobotType;\n 324: new #152 // class RobotBuildCost\n 327: dup\n 328: aload 13\n 330: invokestatic #142 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 333: getstatic #158 // Field RobotCurrency.ORE:LRobotCurrency;\n 336: invokespecial #161 // Method RobotBuildCost.\"<init>\":(ILRobotCurrency;)V\n 339: invokestatic #167 // Method kotlin/collections/SetsKt.setOf:(Ljava/lang/Object;)Ljava/util/Set;\n 342: invokestatic #173 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 345: aastore\n 346: aload 18\n 348: iconst_2\n 349: getstatic #179 // Field RobotType.OBSIDIAN_COLLECTOR:LRobotType;\n 352: iconst_2\n 353: anewarray #152 // class RobotBuildCost\n 356: astore 19\n 358: aload 19\n 360: iconst_0\n 361: new #152 // class RobotBuildCost\n 364: dup\n 365: aload 14\n 367: invokestatic #142 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 370: getstatic #158 // Field RobotCurrency.ORE:LRobotCurrency;\n 373: invokespecial #161 // Method RobotBuildCost.\"<init>\":(ILRobotCurrency;)V\n 376: aastore\n 377: aload 19\n 379: iconst_1\n 380: new #152 // class RobotBuildCost\n 383: dup\n 384: aload 15\n 386: invokestatic #142 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 389: getstatic #182 // Field RobotCurrency.CLAY:LRobotCurrency;\n 392: invokespecial #161 // Method RobotBuildCost.\"<init>\":(ILRobotCurrency;)V\n 395: aastore\n 396: aload 19\n 398: invokestatic #185 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 401: invokestatic #173 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 404: aastore\n 405: aload 18\n 407: iconst_3\n 408: getstatic #188 // Field RobotType.GEODE_CRACKING:LRobotType;\n 411: iconst_2\n 412: anewarray #152 // class RobotBuildCost\n 415: astore 19\n 417: aload 19\n 419: iconst_0\n 420: new #152 // class RobotBuildCost\n 423: dup\n 424: aload 16\n 426: invokestatic #142 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 429: getstatic #158 // Field RobotCurrency.ORE:LRobotCurrency;\n 432: invokespecial #161 // Method RobotBuildCost.\"<init>\":(ILRobotCurrency;)V\n 435: aastore\n 436: aload 19\n 438: iconst_1\n 439: new #152 // class RobotBuildCost\n 442: dup\n 443: aload 17\n 445: invokestatic #142 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 448: getstatic #191 // Field RobotCurrency.OBSIDIAN:LRobotCurrency;\n 451: invokespecial #161 // Method RobotBuildCost.\"<init>\":(ILRobotCurrency;)V\n 454: aastore\n 455: aload 19\n 457: invokestatic #185 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 460: invokestatic #173 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 463: aastore\n 464: aload 18\n 466: invokestatic #197 // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 469: invokespecial #200 // Method Blueprint.\"<init>\":(ILjava/util/Map;)V\n 472: nop\n 473: aload 20\n 475: swap\n 476: invokeinterface #204, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 481: pop\n 482: goto 38\n 485: aload 4\n 487: checkcast #57 // class java/util/List\n 490: nop\n 491: areturn\n\n private static final int main$findBest(Blueprint, int, CollectingState);\n Code:\n 0: iload_1\n 1: aload_2\n 2: invokevirtual #232 // Method CollectingState.getMinutesDone:()I\n 5: isub\n 6: istore_3\n 7: aload_0\n 8: invokevirtual #236 // Method Blueprint.getBuildCosts:()Ljava/util/Map;\n 11: invokeinterface #242, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 16: checkcast #67 // class java/lang/Iterable\n 19: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 24: astore 4\n 26: aload 4\n 28: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 33: ifne 44\n 36: new #244 // class java/util/NoSuchElementException\n 39: dup\n 40: invokespecial #246 // Method java/util/NoSuchElementException.\"<init>\":()V\n 43: athrow\n 44: aload 4\n 46: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 51: checkcast #248 // class java/util/Map$Entry\n 54: astore 5\n 56: iconst_0\n 57: istore 6\n 59: aload 5\n 61: invokeinterface #251, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 66: checkcast #146 // class RobotType\n 69: astore 7\n 71: aload 5\n 73: invokeinterface #254, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 78: checkcast #256 // class java/util/Set\n 81: astore 8\n 83: aload 7\n 85: getstatic #150 // Field RobotType.ORE_COLLECTOR:LRobotType;\n 88: if_acmpne 99\n 91: aload_2\n 92: invokevirtual #259 // Method CollectingState.getOrePerMinute:()I\n 95: iconst_5\n 96: if_icmpgt 131\n 99: aload 7\n 101: getstatic #176 // Field RobotType.CLAY_COLLECTOR:LRobotType;\n 104: if_acmpne 115\n 107: aload_2\n 108: invokevirtual #262 // Method CollectingState.getClayPerMinute:()I\n 111: iconst_5\n 112: if_icmpgt 131\n 115: aload 7\n 117: getstatic #179 // Field RobotType.OBSIDIAN_COLLECTOR:LRobotType;\n 120: if_acmpne 135\n 123: aload_2\n 124: invokevirtual #265 // Method CollectingState.getObsidianPerMinute:()I\n 127: iconst_5\n 128: if_icmple 135\n 131: iconst_m1\n 132: goto 1094\n 135: aload 8\n 137: checkcast #67 // class java/lang/Iterable\n 140: astore 9\n 142: iconst_0\n 143: istore 10\n 145: aload 9\n 147: astore 11\n 149: new #69 // class java/util/ArrayList\n 152: dup\n 153: aload 9\n 155: bipush 10\n 157: invokestatic #75 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 160: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 163: checkcast #79 // class java/util/Collection\n 166: astore 12\n 168: iconst_0\n 169: istore 13\n 171: aload 11\n 173: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 178: astore 14\n 180: aload 14\n 182: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 187: ifeq 411\n 190: aload 14\n 192: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 197: astore 15\n 199: aload 12\n 201: aload 15\n 203: checkcast #152 // class RobotBuildCost\n 206: astore 16\n 208: astore 17\n 210: iconst_0\n 211: istore 18\n 213: aload 16\n 215: invokevirtual #269 // Method RobotBuildCost.getCurrency:()LRobotCurrency;\n 218: getstatic #275 // Field Day19Kt$WhenMappings.$EnumSwitchMapping$0:[I\n 221: swap\n 222: invokevirtual #278 // Method RobotCurrency.ordinal:()I\n 225: iaload\n 226: tableswitch { // 1 to 3\n 1: 252\n 2: 297\n 3: 342\n default: 387\n }\n 252: aload_2\n 253: invokevirtual #281 // Method CollectingState.getOre:()I\n 256: aload 16\n 258: invokevirtual #284 // Method RobotBuildCost.getAmount:()I\n 261: if_icmplt 268\n 264: iconst_0\n 265: goto 395\n 268: aload_2\n 269: invokevirtual #259 // Method CollectingState.getOrePerMinute:()I\n 272: ifle 293\n 275: aload 16\n 277: invokevirtual #284 // Method RobotBuildCost.getAmount:()I\n 280: aload_2\n 281: invokevirtual #281 // Method CollectingState.getOre:()I\n 284: aload_2\n 285: invokevirtual #259 // Method CollectingState.getOrePerMinute:()I\n 288: idiv\n 289: isub\n 290: goto 395\n 293: iconst_m1\n 294: goto 395\n 297: aload_2\n 298: invokevirtual #287 // Method CollectingState.getClay:()I\n 301: aload 16\n 303: invokevirtual #284 // Method RobotBuildCost.getAmount:()I\n 306: if_icmplt 313\n 309: iconst_0\n 310: goto 395\n 313: aload_2\n 314: invokevirtual #262 // Method CollectingState.getClayPerMinute:()I\n 317: ifle 338\n 320: aload 16\n 322: invokevirtual #284 // Method RobotBuildCost.getAmount:()I\n 325: aload_2\n 326: invokevirtual #287 // Method CollectingState.getClay:()I\n 329: aload_2\n 330: invokevirtual #262 // Method CollectingState.getClayPerMinute:()I\n 333: idiv\n 334: isub\n 335: goto 395\n 338: iconst_m1\n 339: goto 395\n 342: aload_2\n 343: invokevirtual #290 // Method CollectingState.getObs:()I\n 346: aload 16\n 348: invokevirtual #284 // Method RobotBuildCost.getAmount:()I\n 351: if_icmplt 358\n 354: iconst_0\n 355: goto 395\n 358: aload_2\n 359: invokevirtual #265 // Method CollectingState.getObsidianPerMinute:()I\n 362: ifle 383\n 365: aload 16\n 367: invokevirtual #284 // Method RobotBuildCost.getAmount:()I\n 370: aload_2\n 371: invokevirtual #290 // Method CollectingState.getObs:()I\n 374: aload_2\n 375: invokevirtual #265 // Method CollectingState.getObsidianPerMinute:()I\n 378: idiv\n 379: isub\n 380: goto 395\n 383: iconst_m1\n 384: goto 395\n 387: new #292 // class kotlin/NoWhenBranchMatchedException\n 390: dup\n 391: invokespecial #293 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 394: athrow\n 395: nop\n 396: invokestatic #297 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 399: aload 17\n 401: swap\n 402: invokeinterface #204, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 407: pop\n 408: goto 180\n 411: aload 12\n 413: checkcast #57 // class java/util/List\n 416: nop\n 417: astore 19\n 419: aload 19\n 421: checkcast #67 // class java/lang/Iterable\n 424: astore 10\n 426: iconst_0\n 427: istore 11\n 429: aload 10\n 431: instanceof #79 // class java/util/Collection\n 434: ifeq 454\n 437: aload 10\n 439: checkcast #79 // class java/util/Collection\n 442: invokeinterface #300, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 447: ifeq 454\n 450: iconst_0\n 451: goto 514\n 454: aload 10\n 456: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 461: astore 12\n 463: aload 12\n 465: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 470: ifeq 513\n 473: aload 12\n 475: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 480: astore 13\n 482: aload 13\n 484: checkcast #302 // class java/lang/Number\n 487: invokevirtual #305 // Method java/lang/Number.intValue:()I\n 490: istore 14\n 492: iconst_0\n 493: istore 15\n 495: iload 14\n 497: iconst_m1\n 498: if_icmpne 505\n 501: iconst_1\n 502: goto 506\n 505: iconst_0\n 506: ifeq 463\n 509: iconst_1\n 510: goto 514\n 513: iconst_0\n 514: istore 9\n 516: aload 19\n 518: checkcast #67 // class java/lang/Iterable\n 521: invokestatic #309 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 524: checkcast #302 // class java/lang/Number\n 527: invokevirtual #305 // Method java/lang/Number.intValue:()I\n 530: iconst_1\n 531: iadd\n 532: istore 10\n 534: iload 9\n 536: ifne 545\n 539: iload 10\n 541: iload_3\n 542: if_icmplt 607\n 545: aload_2\n 546: iload_1\n 547: iconst_0\n 548: iconst_0\n 549: iconst_0\n 550: iconst_0\n 551: aload_2\n 552: invokevirtual #281 // Method CollectingState.getOre:()I\n 555: aload_2\n 556: invokevirtual #259 // Method CollectingState.getOrePerMinute:()I\n 559: iload_3\n 560: imul\n 561: iadd\n 562: aload_2\n 563: invokevirtual #287 // Method CollectingState.getClay:()I\n 566: aload_2\n 567: invokevirtual #262 // Method CollectingState.getClayPerMinute:()I\n 570: iload_3\n 571: imul\n 572: iadd\n 573: aload_2\n 574: invokevirtual #290 // Method CollectingState.getObs:()I\n 577: aload_2\n 578: invokevirtual #265 // Method CollectingState.getObsidianPerMinute:()I\n 581: iload_3\n 582: imul\n 583: iadd\n 584: aload_2\n 585: invokevirtual #312 // Method CollectingState.getGeoCracked:()I\n 588: aload_2\n 589: invokevirtual #315 // Method CollectingState.getGeoCrackedPerMinute:()I\n 592: iload_3\n 593: imul\n 594: iadd\n 595: bipush 30\n 597: aconst_null\n 598: invokestatic #319 // Method CollectingState.copy$default:(LCollectingState;IIIIIIIIIILjava/lang/Object;)LCollectingState;\n 601: invokevirtual #312 // Method CollectingState.getGeoCracked:()I\n 604: goto 1094\n 607: aload_0\n 608: iload_1\n 609: aload_2\n 610: invokevirtual #232 // Method CollectingState.getMinutesDone:()I\n 613: iload 10\n 615: iadd\n 616: istore 11\n 618: aload_2\n 619: invokevirtual #281 // Method CollectingState.getOre:()I\n 622: iload 10\n 624: aload_2\n 625: invokevirtual #259 // Method CollectingState.getOrePerMinute:()I\n 628: imul\n 629: iadd\n 630: aload 8\n 632: checkcast #67 // class java/lang/Iterable\n 635: astore 14\n 637: istore 20\n 639: istore 21\n 641: astore 17\n 643: iconst_0\n 644: istore 15\n 646: aload 14\n 648: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 653: astore 16\n 655: aload 16\n 657: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 662: ifeq 708\n 665: aload 16\n 667: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 672: astore 18\n 674: aload 18\n 676: checkcast #152 // class RobotBuildCost\n 679: astore 22\n 681: iconst_0\n 682: istore 23\n 684: aload 22\n 686: invokevirtual #269 // Method RobotBuildCost.getCurrency:()LRobotCurrency;\n 689: getstatic #158 // Field RobotCurrency.ORE:LRobotCurrency;\n 692: if_acmpne 699\n 695: iconst_1\n 696: goto 700\n 699: iconst_0\n 700: ifeq 655\n 703: aload 18\n 705: goto 709\n 708: aconst_null\n 709: astore 24\n 711: aload 17\n 713: iload 21\n 715: iload 20\n 717: aload 24\n 719: checkcast #152 // class RobotBuildCost\n 722: dup\n 723: ifnull 732\n 726: invokevirtual #284 // Method RobotBuildCost.getAmount:()I\n 729: goto 734\n 732: pop\n 733: iconst_0\n 734: isub\n 735: istore 12\n 737: aload_2\n 738: invokevirtual #287 // Method CollectingState.getClay:()I\n 741: iload 10\n 743: aload_2\n 744: invokevirtual #262 // Method CollectingState.getClayPerMinute:()I\n 747: imul\n 748: iadd\n 749: aload 8\n 751: checkcast #67 // class java/lang/Iterable\n 754: astore 15\n 756: istore 20\n 758: istore 21\n 760: astore 17\n 762: iconst_0\n 763: istore 16\n 765: aload 15\n 767: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 772: astore 18\n 774: aload 18\n 776: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 781: ifeq 827\n 784: aload 18\n 786: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 791: astore 22\n 793: aload 22\n 795: checkcast #152 // class RobotBuildCost\n 798: astore 23\n 800: iconst_0\n 801: istore 25\n 803: aload 23\n 805: invokevirtual #269 // Method RobotBuildCost.getCurrency:()LRobotCurrency;\n 808: getstatic #182 // Field RobotCurrency.CLAY:LRobotCurrency;\n 811: if_acmpne 818\n 814: iconst_1\n 815: goto 819\n 818: iconst_0\n 819: ifeq 774\n 822: aload 22\n 824: goto 828\n 827: aconst_null\n 828: astore 24\n 830: aload 17\n 832: iload 21\n 834: iload 20\n 836: aload 24\n 838: checkcast #152 // class RobotBuildCost\n 841: dup\n 842: ifnull 851\n 845: invokevirtual #284 // Method RobotBuildCost.getAmount:()I\n 848: goto 853\n 851: pop\n 852: iconst_0\n 853: isub\n 854: istore 13\n 856: aload_2\n 857: invokevirtual #290 // Method CollectingState.getObs:()I\n 860: iload 10\n 862: aload_2\n 863: invokevirtual #265 // Method CollectingState.getObsidianPerMinute:()I\n 866: imul\n 867: iadd\n 868: aload 8\n 870: checkcast #67 // class java/lang/Iterable\n 873: astore 16\n 875: istore 20\n 877: istore 21\n 879: astore 17\n 881: iconst_0\n 882: istore 18\n 884: aload 16\n 886: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 891: astore 22\n 893: aload 22\n 895: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 900: ifeq 946\n 903: aload 22\n 905: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 910: astore 23\n 912: aload 23\n 914: checkcast #152 // class RobotBuildCost\n 917: astore 25\n 919: iconst_0\n 920: istore 26\n 922: aload 25\n 924: invokevirtual #269 // Method RobotBuildCost.getCurrency:()LRobotCurrency;\n 927: getstatic #191 // Field RobotCurrency.OBSIDIAN:LRobotCurrency;\n 930: if_acmpne 937\n 933: iconst_1\n 934: goto 938\n 937: iconst_0\n 938: ifeq 893\n 941: aload 23\n 943: goto 947\n 946: aconst_null\n 947: astore 24\n 949: aload 17\n 951: iload 21\n 953: iload 20\n 955: aload 24\n 957: checkcast #152 // class RobotBuildCost\n 960: dup\n 961: ifnull 970\n 964: invokevirtual #284 // Method RobotBuildCost.getAmount:()I\n 967: goto 972\n 970: pop\n 971: iconst_0\n 972: isub\n 973: istore 14\n 975: aload_2\n 976: invokevirtual #312 // Method CollectingState.getGeoCracked:()I\n 979: iload 10\n 981: aload_2\n 982: invokevirtual #315 // Method CollectingState.getGeoCrackedPerMinute:()I\n 985: imul\n 986: iadd\n 987: istore 15\n 989: aload_2\n 990: invokevirtual #259 // Method CollectingState.getOrePerMinute:()I\n 993: aload 7\n 995: getstatic #150 // Field RobotType.ORE_COLLECTOR:LRobotType;\n 998: if_acmpne 1005\n 1001: iconst_1\n 1002: goto 1006\n 1005: iconst_0\n 1006: iadd\n 1007: istore 16\n 1009: aload_2\n 1010: invokevirtual #262 // Method CollectingState.getClayPerMinute:()I\n 1013: aload 7\n 1015: getstatic #176 // Field RobotType.CLAY_COLLECTOR:LRobotType;\n 1018: if_acmpne 1025\n 1021: iconst_1\n 1022: goto 1026\n 1025: iconst_0\n 1026: iadd\n 1027: istore 18\n 1029: aload_2\n 1030: invokevirtual #265 // Method CollectingState.getObsidianPerMinute:()I\n 1033: aload 7\n 1035: getstatic #179 // Field RobotType.OBSIDIAN_COLLECTOR:LRobotType;\n 1038: if_acmpne 1045\n 1041: iconst_1\n 1042: goto 1046\n 1045: iconst_0\n 1046: iadd\n 1047: istore 22\n 1049: aload_2\n 1050: invokevirtual #315 // Method CollectingState.getGeoCrackedPerMinute:()I\n 1053: aload 7\n 1055: getstatic #188 // Field RobotType.GEODE_CRACKING:LRobotType;\n 1058: if_acmpne 1065\n 1061: iconst_1\n 1062: goto 1066\n 1065: iconst_0\n 1066: iadd\n 1067: istore 23\n 1069: aload_2\n 1070: iload 11\n 1072: iload 16\n 1074: iload 18\n 1076: iload 22\n 1078: iload 23\n 1080: iload 12\n 1082: iload 13\n 1084: iload 14\n 1086: iload 15\n 1088: invokevirtual #323 // Method CollectingState.copy:(IIIIIIIII)LCollectingState;\n 1091: invokestatic #325 // Method main$findBest:(LBlueprint;ILCollectingState;)I\n 1094: nop\n 1095: istore 5\n 1097: aload 4\n 1099: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1104: ifeq 2175\n 1107: aload 4\n 1109: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1114: checkcast #248 // class java/util/Map$Entry\n 1117: astore 6\n 1119: iconst_0\n 1120: istore 7\n 1122: aload 6\n 1124: invokeinterface #251, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 1129: checkcast #146 // class RobotType\n 1132: astore 8\n 1134: aload 6\n 1136: invokeinterface #254, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 1141: checkcast #256 // class java/util/Set\n 1144: astore 9\n 1146: aload 8\n 1148: getstatic #150 // Field RobotType.ORE_COLLECTOR:LRobotType;\n 1151: if_acmpne 1162\n 1154: aload_2\n 1155: invokevirtual #259 // Method CollectingState.getOrePerMinute:()I\n 1158: iconst_5\n 1159: if_icmpgt 1194\n 1162: aload 8\n 1164: getstatic #176 // Field RobotType.CLAY_COLLECTOR:LRobotType;\n 1167: if_acmpne 1178\n 1170: aload_2\n 1171: invokevirtual #262 // Method CollectingState.getClayPerMinute:()I\n 1174: iconst_5\n 1175: if_icmpgt 1194\n 1178: aload 8\n 1180: getstatic #179 // Field RobotType.OBSIDIAN_COLLECTOR:LRobotType;\n 1183: if_acmpne 1198\n 1186: aload_2\n 1187: invokevirtual #265 // Method CollectingState.getObsidianPerMinute:()I\n 1190: iconst_5\n 1191: if_icmple 1198\n 1194: iconst_m1\n 1195: goto 2158\n 1198: aload 9\n 1200: checkcast #67 // class java/lang/Iterable\n 1203: astore 10\n 1205: iconst_0\n 1206: istore 11\n 1208: aload 10\n 1210: astore 12\n 1212: new #69 // class java/util/ArrayList\n 1215: dup\n 1216: aload 10\n 1218: bipush 10\n 1220: invokestatic #75 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 1223: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 1226: checkcast #79 // class java/util/Collection\n 1229: astore 13\n 1231: iconst_0\n 1232: istore 14\n 1234: aload 12\n 1236: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1241: astore 15\n 1243: aload 15\n 1245: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1250: ifeq 1475\n 1253: aload 15\n 1255: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1260: astore 16\n 1262: aload 13\n 1264: aload 16\n 1266: checkcast #152 // class RobotBuildCost\n 1269: astore 17\n 1271: astore 18\n 1273: iconst_0\n 1274: istore 19\n 1276: aload 17\n 1278: invokevirtual #269 // Method RobotBuildCost.getCurrency:()LRobotCurrency;\n 1281: getstatic #275 // Field Day19Kt$WhenMappings.$EnumSwitchMapping$0:[I\n 1284: swap\n 1285: invokevirtual #278 // Method RobotCurrency.ordinal:()I\n 1288: iaload\n 1289: tableswitch { // 1 to 3\n 1: 1316\n 2: 1361\n 3: 1406\n default: 1451\n }\n 1316: aload_2\n 1317: invokevirtual #281 // Method CollectingState.getOre:()I\n 1320: aload 17\n 1322: invokevirtual #284 // Method RobotBuildCost.getAmount:()I\n 1325: if_icmplt 1332\n 1328: iconst_0\n 1329: goto 1459\n 1332: aload_2\n 1333: invokevirtual #259 // Method CollectingState.getOrePerMinute:()I\n 1336: ifle 1357\n 1339: aload 17\n 1341: invokevirtual #284 // Method RobotBuildCost.getAmount:()I\n 1344: aload_2\n 1345: invokevirtual #281 // Method CollectingState.getOre:()I\n 1348: aload_2\n 1349: invokevirtual #259 // Method CollectingState.getOrePerMinute:()I\n 1352: idiv\n 1353: isub\n 1354: goto 1459\n 1357: iconst_m1\n 1358: goto 1459\n 1361: aload_2\n 1362: invokevirtual #287 // Method CollectingState.getClay:()I\n 1365: aload 17\n 1367: invokevirtual #284 // Method RobotBuildCost.getAmount:()I\n 1370: if_icmplt 1377\n 1373: iconst_0\n 1374: goto 1459\n 1377: aload_2\n 1378: invokevirtual #262 // Method CollectingState.getClayPerMinute:()I\n 1381: ifle 1402\n 1384: aload 17\n 1386: invokevirtual #284 // Method RobotBuildCost.getAmount:()I\n 1389: aload_2\n 1390: invokevirtual #287 // Method CollectingState.getClay:()I\n 1393: aload_2\n 1394: invokevirtual #262 // Method CollectingState.getClayPerMinute:()I\n 1397: idiv\n 1398: isub\n 1399: goto 1459\n 1402: iconst_m1\n 1403: goto 1459\n 1406: aload_2\n 1407: invokevirtual #290 // Method CollectingState.getObs:()I\n 1410: aload 17\n 1412: invokevirtual #284 // Method RobotBuildCost.getAmount:()I\n 1415: if_icmplt 1422\n 1418: iconst_0\n 1419: goto 1459\n 1422: aload_2\n 1423: invokevirtual #265 // Method CollectingState.getObsidianPerMinute:()I\n 1426: ifle 1447\n 1429: aload 17\n 1431: invokevirtual #284 // Method RobotBuildCost.getAmount:()I\n 1434: aload_2\n 1435: invokevirtual #290 // Method CollectingState.getObs:()I\n 1438: aload_2\n 1439: invokevirtual #265 // Method CollectingState.getObsidianPerMinute:()I\n 1442: idiv\n 1443: isub\n 1444: goto 1459\n 1447: iconst_m1\n 1448: goto 1459\n 1451: new #292 // class kotlin/NoWhenBranchMatchedException\n 1454: dup\n 1455: invokespecial #293 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 1458: athrow\n 1459: nop\n 1460: invokestatic #297 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1463: aload 18\n 1465: swap\n 1466: invokeinterface #204, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 1471: pop\n 1472: goto 1243\n 1475: aload 13\n 1477: checkcast #57 // class java/util/List\n 1480: nop\n 1481: astore 20\n 1483: aload 20\n 1485: checkcast #67 // class java/lang/Iterable\n 1488: astore 11\n 1490: iconst_0\n 1491: istore 12\n 1493: aload 11\n 1495: instanceof #79 // class java/util/Collection\n 1498: ifeq 1518\n 1501: aload 11\n 1503: checkcast #79 // class java/util/Collection\n 1506: invokeinterface #300, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 1511: ifeq 1518\n 1514: iconst_0\n 1515: goto 1578\n 1518: aload 11\n 1520: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1525: astore 13\n 1527: aload 13\n 1529: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1534: ifeq 1577\n 1537: aload 13\n 1539: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1544: astore 14\n 1546: aload 14\n 1548: checkcast #302 // class java/lang/Number\n 1551: invokevirtual #305 // Method java/lang/Number.intValue:()I\n 1554: istore 15\n 1556: iconst_0\n 1557: istore 16\n 1559: iload 15\n 1561: iconst_m1\n 1562: if_icmpne 1569\n 1565: iconst_1\n 1566: goto 1570\n 1569: iconst_0\n 1570: ifeq 1527\n 1573: iconst_1\n 1574: goto 1578\n 1577: iconst_0\n 1578: istore 10\n 1580: aload 20\n 1582: checkcast #67 // class java/lang/Iterable\n 1585: invokestatic #309 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 1588: checkcast #302 // class java/lang/Number\n 1591: invokevirtual #305 // Method java/lang/Number.intValue:()I\n 1594: iconst_1\n 1595: iadd\n 1596: istore 11\n 1598: iload 10\n 1600: ifne 1609\n 1603: iload 11\n 1605: iload_3\n 1606: if_icmplt 1671\n 1609: aload_2\n 1610: iload_1\n 1611: iconst_0\n 1612: iconst_0\n 1613: iconst_0\n 1614: iconst_0\n 1615: aload_2\n 1616: invokevirtual #281 // Method CollectingState.getOre:()I\n 1619: aload_2\n 1620: invokevirtual #259 // Method CollectingState.getOrePerMinute:()I\n 1623: iload_3\n 1624: imul\n 1625: iadd\n 1626: aload_2\n 1627: invokevirtual #287 // Method CollectingState.getClay:()I\n 1630: aload_2\n 1631: invokevirtual #262 // Method CollectingState.getClayPerMinute:()I\n 1634: iload_3\n 1635: imul\n 1636: iadd\n 1637: aload_2\n 1638: invokevirtual #290 // Method CollectingState.getObs:()I\n 1641: aload_2\n 1642: invokevirtual #265 // Method CollectingState.getObsidianPerMinute:()I\n 1645: iload_3\n 1646: imul\n 1647: iadd\n 1648: aload_2\n 1649: invokevirtual #312 // Method CollectingState.getGeoCracked:()I\n 1652: aload_2\n 1653: invokevirtual #315 // Method CollectingState.getGeoCrackedPerMinute:()I\n 1656: iload_3\n 1657: imul\n 1658: iadd\n 1659: bipush 30\n 1661: aconst_null\n 1662: invokestatic #319 // Method CollectingState.copy$default:(LCollectingState;IIIIIIIIIILjava/lang/Object;)LCollectingState;\n 1665: invokevirtual #312 // Method CollectingState.getGeoCracked:()I\n 1668: goto 2158\n 1671: aload_0\n 1672: iload_1\n 1673: aload_2\n 1674: invokevirtual #232 // Method CollectingState.getMinutesDone:()I\n 1677: iload 11\n 1679: iadd\n 1680: istore 12\n 1682: aload_2\n 1683: invokevirtual #281 // Method CollectingState.getOre:()I\n 1686: iload 11\n 1688: aload_2\n 1689: invokevirtual #259 // Method CollectingState.getOrePerMinute:()I\n 1692: imul\n 1693: iadd\n 1694: aload 9\n 1696: checkcast #67 // class java/lang/Iterable\n 1699: astore 15\n 1701: istore 21\n 1703: istore 22\n 1705: astore 18\n 1707: iconst_0\n 1708: istore 16\n 1710: aload 15\n 1712: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1717: astore 17\n 1719: aload 17\n 1721: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1726: ifeq 1772\n 1729: aload 17\n 1731: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1736: astore 19\n 1738: aload 19\n 1740: checkcast #152 // class RobotBuildCost\n 1743: astore 23\n 1745: iconst_0\n 1746: istore 24\n 1748: aload 23\n 1750: invokevirtual #269 // Method RobotBuildCost.getCurrency:()LRobotCurrency;\n 1753: getstatic #158 // Field RobotCurrency.ORE:LRobotCurrency;\n 1756: if_acmpne 1763\n 1759: iconst_1\n 1760: goto 1764\n 1763: iconst_0\n 1764: ifeq 1719\n 1767: aload 19\n 1769: goto 1773\n 1772: aconst_null\n 1773: astore 25\n 1775: aload 18\n 1777: iload 22\n 1779: iload 21\n 1781: aload 25\n 1783: checkcast #152 // class RobotBuildCost\n 1786: dup\n 1787: ifnull 1796\n 1790: invokevirtual #284 // Method RobotBuildCost.getAmount:()I\n 1793: goto 1798\n 1796: pop\n 1797: iconst_0\n 1798: isub\n 1799: istore 13\n 1801: aload_2\n 1802: invokevirtual #287 // Method CollectingState.getClay:()I\n 1805: iload 11\n 1807: aload_2\n 1808: invokevirtual #262 // Method CollectingState.getClayPerMinute:()I\n 1811: imul\n 1812: iadd\n 1813: aload 9\n 1815: checkcast #67 // class java/lang/Iterable\n 1818: astore 16\n 1820: istore 21\n 1822: istore 22\n 1824: astore 18\n 1826: iconst_0\n 1827: istore 17\n 1829: aload 16\n 1831: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1836: astore 19\n 1838: aload 19\n 1840: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1845: ifeq 1891\n 1848: aload 19\n 1850: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1855: astore 23\n 1857: aload 23\n 1859: checkcast #152 // class RobotBuildCost\n 1862: astore 24\n 1864: iconst_0\n 1865: istore 26\n 1867: aload 24\n 1869: invokevirtual #269 // Method RobotBuildCost.getCurrency:()LRobotCurrency;\n 1872: getstatic #182 // Field RobotCurrency.CLAY:LRobotCurrency;\n 1875: if_acmpne 1882\n 1878: iconst_1\n 1879: goto 1883\n 1882: iconst_0\n 1883: ifeq 1838\n 1886: aload 23\n 1888: goto 1892\n 1891: aconst_null\n 1892: astore 25\n 1894: aload 18\n 1896: iload 22\n 1898: iload 21\n 1900: aload 25\n 1902: checkcast #152 // class RobotBuildCost\n 1905: dup\n 1906: ifnull 1915\n 1909: invokevirtual #284 // Method RobotBuildCost.getAmount:()I\n 1912: goto 1917\n 1915: pop\n 1916: iconst_0\n 1917: isub\n 1918: istore 14\n 1920: aload_2\n 1921: invokevirtual #290 // Method CollectingState.getObs:()I\n 1924: iload 11\n 1926: aload_2\n 1927: invokevirtual #265 // Method CollectingState.getObsidianPerMinute:()I\n 1930: imul\n 1931: iadd\n 1932: aload 9\n 1934: checkcast #67 // class java/lang/Iterable\n 1937: astore 17\n 1939: istore 21\n 1941: istore 22\n 1943: astore 18\n 1945: iconst_0\n 1946: istore 19\n 1948: aload 17\n 1950: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1955: astore 23\n 1957: aload 23\n 1959: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1964: ifeq 2010\n 1967: aload 23\n 1969: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1974: astore 24\n 1976: aload 24\n 1978: checkcast #152 // class RobotBuildCost\n 1981: astore 26\n 1983: iconst_0\n 1984: istore 27\n 1986: aload 26\n 1988: invokevirtual #269 // Method RobotBuildCost.getCurrency:()LRobotCurrency;\n 1991: getstatic #191 // Field RobotCurrency.OBSIDIAN:LRobotCurrency;\n 1994: if_acmpne 2001\n 1997: iconst_1\n 1998: goto 2002\n 2001: iconst_0\n 2002: ifeq 1957\n 2005: aload 24\n 2007: goto 2011\n 2010: aconst_null\n 2011: astore 25\n 2013: aload 18\n 2015: iload 22\n 2017: iload 21\n 2019: aload 25\n 2021: checkcast #152 // class RobotBuildCost\n 2024: dup\n 2025: ifnull 2034\n 2028: invokevirtual #284 // Method RobotBuildCost.getAmount:()I\n 2031: goto 2036\n 2034: pop\n 2035: iconst_0\n 2036: isub\n 2037: istore 15\n 2039: aload_2\n 2040: invokevirtual #312 // Method CollectingState.getGeoCracked:()I\n 2043: iload 11\n 2045: aload_2\n 2046: invokevirtual #315 // Method CollectingState.getGeoCrackedPerMinute:()I\n 2049: imul\n 2050: iadd\n 2051: istore 16\n 2053: aload_2\n 2054: invokevirtual #259 // Method CollectingState.getOrePerMinute:()I\n 2057: aload 8\n 2059: getstatic #150 // Field RobotType.ORE_COLLECTOR:LRobotType;\n 2062: if_acmpne 2069\n 2065: iconst_1\n 2066: goto 2070\n 2069: iconst_0\n 2070: iadd\n 2071: istore 17\n 2073: aload_2\n 2074: invokevirtual #262 // Method CollectingState.getClayPerMinute:()I\n 2077: aload 8\n 2079: getstatic #176 // Field RobotType.CLAY_COLLECTOR:LRobotType;\n 2082: if_acmpne 2089\n 2085: iconst_1\n 2086: goto 2090\n 2089: iconst_0\n 2090: iadd\n 2091: istore 19\n 2093: aload_2\n 2094: invokevirtual #265 // Method CollectingState.getObsidianPerMinute:()I\n 2097: aload 8\n 2099: getstatic #179 // Field RobotType.OBSIDIAN_COLLECTOR:LRobotType;\n 2102: if_acmpne 2109\n 2105: iconst_1\n 2106: goto 2110\n 2109: iconst_0\n 2110: iadd\n 2111: istore 23\n 2113: aload_2\n 2114: invokevirtual #315 // Method CollectingState.getGeoCrackedPerMinute:()I\n 2117: aload 8\n 2119: getstatic #188 // Field RobotType.GEODE_CRACKING:LRobotType;\n 2122: if_acmpne 2129\n 2125: iconst_1\n 2126: goto 2130\n 2129: iconst_0\n 2130: iadd\n 2131: istore 24\n 2133: aload_2\n 2134: iload 12\n 2136: iload 17\n 2138: iload 19\n 2140: iload 23\n 2142: iload 24\n 2144: iload 13\n 2146: iload 14\n 2148: iload 15\n 2150: iload 16\n 2152: invokevirtual #323 // Method CollectingState.copy:(IIIIIIIII)LCollectingState;\n 2155: invokestatic #325 // Method main$findBest:(LBlueprint;ILCollectingState;)I\n 2158: nop\n 2159: istore 6\n 2161: iload 5\n 2163: iload 6\n 2165: if_icmpge 1097\n 2168: iload 6\n 2170: istore 5\n 2172: goto 1097\n 2175: iload 5\n 2177: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #353 // Method main$parseBlueprints:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 8: aload_1\n 9: invokevirtual #356 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 12: aload_1\n 13: checkcast #67 // class java/lang/Iterable\n 16: astore_2\n 17: iconst_0\n 18: istore_3\n 19: aload_2\n 20: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 25: astore 4\n 27: aload 4\n 29: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 34: ifeq 122\n 37: aload 4\n 39: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 44: astore 5\n 46: aload 5\n 48: checkcast #136 // class Blueprint\n 51: astore 6\n 53: iconst_0\n 54: istore 7\n 56: new #358 // class java/lang/StringBuilder\n 59: dup\n 60: invokespecial #359 // Method java/lang/StringBuilder.\"<init>\":()V\n 63: aload 6\n 65: invokevirtual #362 // Method Blueprint.getId:()I\n 68: invokevirtual #366 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 71: ldc_w #368 // String :\n 74: invokevirtual #371 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 77: aload 6\n 79: bipush 24\n 81: new #228 // class CollectingState\n 84: dup\n 85: iconst_0\n 86: iconst_0\n 87: iconst_0\n 88: iconst_0\n 89: iconst_0\n 90: iconst_0\n 91: iconst_0\n 92: iconst_0\n 93: iconst_0\n 94: sipush 511\n 97: aconst_null\n 98: invokespecial #374 // Method CollectingState.\"<init>\":(IIIIIIIIIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 101: invokestatic #325 // Method main$findBest:(LBlueprint;ILCollectingState;)I\n 104: invokevirtual #366 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 107: invokevirtual #375 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 110: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 113: swap\n 114: invokevirtual #356 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 117: nop\n 118: nop\n 119: goto 27\n 122: nop\n 123: iconst_1\n 124: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: iconst_1\n 1: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day19.class",
"javap": "Compiled from \"Day19.kt\"\npublic final class Day19 {\n public static final Day19 INSTANCE;\n\n public static final int EXPECTED_PART1_CHECK_ANSWER;\n\n public static final int EXPECTED_PART2_CHECK_ANSWER;\n\n private static final kotlin.text.Regex BLUEPRINT_REGEX;\n\n public static final int PART1_MINUTES;\n\n private Day19();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final kotlin.text.Regex getBLUEPRINT_REGEX();\n Code:\n 0: getstatic #17 // Field BLUEPRINT_REGEX:Lkotlin/text/Regex;\n 3: areturn\n\n static {};\n Code:\n 0: new #2 // class Day19\n 3: dup\n 4: invokespecial #19 // Method \"<init>\":()V\n 7: putstatic #22 // Field INSTANCE:LDay19;\n 10: new #24 // class kotlin/text/Regex\n 13: dup\n 14: ldc #26 // String Blueprint (\\\\d+): Each ore robot costs (\\\\d+) ore. Each clay robot costs (\\\\d+) ore. Each obsidian robot costs (\\\\d+) ore and (\\\\d+) clay. Each geode robot costs (\\\\d+) ore and (\\\\d+) obsidian.\n 16: invokespecial #29 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 19: putstatic #17 // Field BLUEPRINT_REGEX:Lkotlin/text/Regex;\n 22: return\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Utils.kt
|
import java.io.File
import java.math.BigInteger
import java.security.MessageDigest
/**
* Reads lines from the given input txt file.
*/
fun readInput(name: String) = File("src", "$name.txt")
.readLines()
/**
* Converts string to md5 hash.
*/
fun String.md5() = BigInteger(1, MessageDigest.getInstance("MD5").digest(toByteArray()))
.toString(16)
.padStart(32, '0')
data class Location(val x: Int, val y: Int)
enum class Direction(val move: Coordinates) {
WEST(Coordinates(-1, 0)),
NORTH(Coordinates(0, -1)),
EAST(Coordinates(1, 0)),
SOUTH(Coordinates(0, 1));
fun next() = when (this) {
WEST -> EAST
NORTH -> SOUTH
EAST -> NORTH
SOUTH -> WEST
}
}
data class Coordinates(val x: Int, val y: Int) {
operator fun plus(distance: Coordinates): Coordinates = Coordinates(this.x + distance.x, this.y + distance.y)
fun move(direction: Direction) = when (direction) {
Direction.NORTH -> Coordinates(x, y - 1)
Direction.SOUTH -> Coordinates(x, y + 1)
Direction.EAST -> Coordinates(x + 1, y)
Direction.WEST -> Coordinates(x - 1, y)
}
fun adjacentPositions(includeDiagonal: Boolean = true): Set<Coordinates> =
adjacentPositions(Direction.NORTH, includeDiagonal) +
adjacentPositions(Direction.EAST, includeDiagonal) +
adjacentPositions(Direction.SOUTH, includeDiagonal) +
adjacentPositions(Direction.WEST, includeDiagonal)
fun adjacentPositions(direction: Direction, includeDiagonal: Boolean = true): Set<Coordinates> =
when (direction) {
Direction.NORTH -> setOf(
this + Coordinates(0, -1),
) + if (includeDiagonal) setOf(
this + Coordinates(-1, -1),
this + Coordinates(1, -1),
) else emptySet()
Direction.EAST -> setOf(
this + Coordinates(1, 0),
) + if (includeDiagonal) setOf(
this + Coordinates(1, -1),
this + Coordinates(1, 1),
) else emptySet()
Direction.SOUTH -> setOf(
this + Coordinates(0, 1),
) + if (includeDiagonal) setOf(
this + Coordinates(1, 1),
this + Coordinates(-1, 1),
) else emptySet()
Direction.WEST -> setOf(
this + Coordinates(-1, 0),
) + if (includeDiagonal) setOf(
this + Coordinates(-1, -1),
this + Coordinates(-1, 1),
) else emptySet()
}
}
data class BigCoordinates(val x: Long, val y: Long)
data class Point3D(val x: Int, val y: Int, val z: Int)
fun List<Coordinates>.findMinAndMax(): Pair<Coordinates, Coordinates> =
fold(Coordinates(Int.MAX_VALUE, Int.MAX_VALUE) to Coordinates(0, 0)) { (min, max), (x, y) ->
Coordinates(
minOf(min.x, x),
minOf(min.y, y)
) to Coordinates(
maxOf(max.x, x),
maxOf(max.y, y)
)
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/UtilsKt.class",
"javap": "Compiled from \"Utils.kt\"\npublic final class UtilsKt {\n public static final java.util.List<java.lang.String> readInput(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #10 // String name\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #18 // class java/io/File\n 9: dup\n 10: ldc #20 // String src\n 12: new #22 // class java/lang/StringBuilder\n 15: dup\n 16: invokespecial #26 // Method java/lang/StringBuilder.\"<init>\":()V\n 19: aload_0\n 20: invokevirtual #30 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 23: ldc #32 // String .txt\n 25: invokevirtual #30 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 28: invokevirtual #36 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 31: invokespecial #39 // Method java/io/File.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 34: aconst_null\n 35: iconst_1\n 36: aconst_null\n 37: invokestatic #45 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 40: areturn\n\n public static final java.lang.String md5(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #50 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #52 // class java/math/BigInteger\n 9: dup\n 10: iconst_1\n 11: ldc #54 // String MD5\n 13: invokestatic #60 // Method java/security/MessageDigest.getInstance:(Ljava/lang/String;)Ljava/security/MessageDigest;\n 16: aload_0\n 17: astore_1\n 18: getstatic #66 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 21: aload_1\n 22: swap\n 23: invokevirtual #72 // Method java/lang/String.getBytes:(Ljava/nio/charset/Charset;)[B\n 26: dup\n 27: ldc #74 // String getBytes(...)\n 29: invokestatic #77 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 32: invokevirtual #81 // Method java/security/MessageDigest.digest:([B)[B\n 35: invokespecial #84 // Method java/math/BigInteger.\"<init>\":(I[B)V\n 38: bipush 16\n 40: invokevirtual #87 // Method java/math/BigInteger.toString:(I)Ljava/lang/String;\n 43: dup\n 44: ldc #89 // String toString(...)\n 46: invokestatic #77 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 49: bipush 32\n 51: bipush 48\n 53: invokestatic #95 // Method kotlin/text/StringsKt.padStart:(Ljava/lang/String;IC)Ljava/lang/String;\n 56: areturn\n\n public static final kotlin.Pair<Coordinates, Coordinates> findMinAndMax(java.util.List<Coordinates>);\n Code:\n 0: aload_0\n 1: ldc #50 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #101 // class java/lang/Iterable\n 10: astore_1\n 11: new #103 // class Coordinates\n 14: dup\n 15: ldc #104 // int 2147483647\n 17: ldc #104 // int 2147483647\n 19: invokespecial #107 // Method Coordinates.\"<init>\":(II)V\n 22: new #103 // class Coordinates\n 25: dup\n 26: iconst_0\n 27: iconst_0\n 28: invokespecial #107 // Method Coordinates.\"<init>\":(II)V\n 31: invokestatic #113 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 34: astore_2\n 35: iconst_0\n 36: istore_3\n 37: aload_2\n 38: astore 4\n 40: aload_1\n 41: invokeinterface #117, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 46: astore 5\n 48: aload 5\n 50: invokeinterface #123, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 55: ifeq 178\n 58: aload 5\n 60: invokeinterface #127, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 65: astore 6\n 67: aload 4\n 69: aload 6\n 71: checkcast #103 // class Coordinates\n 74: astore 7\n 76: astore 8\n 78: iconst_0\n 79: istore 9\n 81: aload 8\n 83: invokevirtual #132 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 86: checkcast #103 // class Coordinates\n 89: astore 10\n 91: aload 8\n 93: invokevirtual #135 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 96: checkcast #103 // class Coordinates\n 99: astore 11\n 101: aload 7\n 103: invokevirtual #138 // Method Coordinates.component1:()I\n 106: istore 12\n 108: aload 7\n 110: invokevirtual #140 // Method Coordinates.component2:()I\n 113: istore 13\n 115: new #103 // class Coordinates\n 118: dup\n 119: aload 10\n 121: invokevirtual #143 // Method Coordinates.getX:()I\n 124: iload 12\n 126: invokestatic #149 // Method java/lang/Math.min:(II)I\n 129: aload 10\n 131: invokevirtual #152 // Method Coordinates.getY:()I\n 134: iload 13\n 136: invokestatic #149 // Method java/lang/Math.min:(II)I\n 139: invokespecial #107 // Method Coordinates.\"<init>\":(II)V\n 142: new #103 // class Coordinates\n 145: dup\n 146: aload 11\n 148: invokevirtual #143 // Method Coordinates.getX:()I\n 151: iload 12\n 153: invokestatic #155 // Method java/lang/Math.max:(II)I\n 156: aload 11\n 158: invokevirtual #152 // Method Coordinates.getY:()I\n 161: iload 13\n 163: invokestatic #155 // Method java/lang/Math.max:(II)I\n 166: invokespecial #107 // Method Coordinates.\"<init>\":(II)V\n 169: invokestatic #113 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 172: nop\n 173: astore 4\n 175: goto 48\n 178: aload 4\n 180: areturn\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day04.kt
|
object Day04 {
const val EXPECTED_PART1_CHECK_ANSWER = 2
const val EXPECTED_PART2_CHECK_ANSWER = 4
}
fun main() {
fun String.parseToIntRangePerElf(): Pair<IntRange, IntRange> =
this
.split(",")
.map { it.split("-") }
.map { (it[0].toInt())..(it[1].toInt()) }
.let { it[0] to it[1] }
fun part1(input: List<String>): Int =
input
.map { it.parseToIntRangePerElf() }
.count { it.first.minus(it.second).isEmpty() || it.second.minus(it.first).isEmpty() }
fun part2(input: List<String>): Int =
input
.map { it.parseToIntRangePerElf() }
.count { (firstElfSections, secondElfSections) ->
firstElfSections.any { secondElfSections.contains(it) } || firstElfSections.any {
secondElfSections.contains(
it
)
}
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day04_test")
check(part1(testInput) == Day04.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
check(part2(testInput) == Day04.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }
val input = readInput("Day04")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/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 #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: iconst_2\n 11: if_icmpne 18\n 14: iconst_1\n 15: goto 19\n 18: iconst_0\n 19: ifne 39\n 22: iconst_0\n 23: istore_2\n 24: ldc #20 // String Part 1 failed\n 26: astore_2\n 27: new #22 // class java/lang/IllegalStateException\n 30: dup\n 31: aload_2\n 32: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 35: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 38: athrow\n 39: aload_0\n 40: invokestatic #33 // Method main$part2:(Ljava/util/List;)I\n 43: iconst_4\n 44: if_icmpne 51\n 47: iconst_1\n 48: goto 52\n 51: iconst_0\n 52: ifne 72\n 55: iconst_0\n 56: istore_2\n 57: ldc #35 // String Part 2 failed\n 59: astore_2\n 60: new #22 // class java/lang/IllegalStateException\n 63: dup\n 64: aload_2\n 65: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 68: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 71: athrow\n 72: ldc #37 // String Day04\n 74: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 77: astore_1\n 78: aload_1\n 79: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 82: istore_2\n 83: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 86: iload_2\n 87: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 90: aload_1\n 91: invokestatic #33 // Method main$part2:(Ljava/util/List;)I\n 94: istore_2\n 95: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 98: iload_2\n 99: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 102: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #60 // Method main:()V\n 3: return\n\n private static final kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange> main$parseToIntRangePerElf(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #67 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #69 // class java/lang/String\n 8: astore_1\n 9: aload_1\n 10: iconst_0\n 11: ldc #71 // 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 #77 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 23: checkcast #79 // class java/lang/Iterable\n 26: astore_1\n 27: nop\n 28: iconst_0\n 29: istore_2\n 30: aload_1\n 31: astore_3\n 32: new #81 // class java/util/ArrayList\n 35: dup\n 36: aload_1\n 37: bipush 10\n 39: invokestatic #87 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 42: invokespecial #89 // Method java/util/ArrayList.\"<init>\":(I)V\n 45: checkcast #91 // class java/util/Collection\n 48: astore 4\n 50: iconst_0\n 51: istore 5\n 53: aload_3\n 54: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 59: astore 6\n 61: aload 6\n 63: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 68: ifeq 133\n 71: aload 6\n 73: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 78: astore 7\n 80: aload 4\n 82: aload 7\n 84: checkcast #69 // class java/lang/String\n 87: astore 8\n 89: astore 11\n 91: iconst_0\n 92: istore 9\n 94: aload 8\n 96: checkcast #67 // class java/lang/CharSequence\n 99: iconst_1\n 100: anewarray #69 // class java/lang/String\n 103: astore 10\n 105: aload 10\n 107: iconst_0\n 108: ldc #107 // String -\n 110: aastore\n 111: aload 10\n 113: iconst_0\n 114: iconst_0\n 115: bipush 6\n 117: aconst_null\n 118: invokestatic #77 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 121: aload 11\n 123: swap\n 124: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 129: pop\n 130: goto 61\n 133: aload 4\n 135: checkcast #57 // class java/util/List\n 138: nop\n 139: checkcast #79 // class java/lang/Iterable\n 142: astore_1\n 143: nop\n 144: iconst_0\n 145: istore_2\n 146: aload_1\n 147: astore_3\n 148: new #81 // class java/util/ArrayList\n 151: dup\n 152: aload_1\n 153: bipush 10\n 155: invokestatic #87 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 158: invokespecial #89 // Method java/util/ArrayList.\"<init>\":(I)V\n 161: checkcast #91 // class java/util/Collection\n 164: astore 4\n 166: iconst_0\n 167: istore 5\n 169: aload_3\n 170: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 175: astore 6\n 177: aload 6\n 179: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 184: ifeq 257\n 187: aload 6\n 189: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 194: astore 7\n 196: aload 4\n 198: aload 7\n 200: checkcast #57 // class java/util/List\n 203: astore 8\n 205: astore 11\n 207: iconst_0\n 208: istore 9\n 210: new #113 // class kotlin/ranges/IntRange\n 213: dup\n 214: aload 8\n 216: iconst_0\n 217: invokeinterface #117, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 222: checkcast #69 // class java/lang/String\n 225: invokestatic #123 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 228: aload 8\n 230: iconst_1\n 231: invokeinterface #117, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 236: checkcast #69 // class java/lang/String\n 239: invokestatic #123 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 242: invokespecial #126 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 245: aload 11\n 247: swap\n 248: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 253: pop\n 254: goto 177\n 257: aload 4\n 259: checkcast #57 // class java/util/List\n 262: nop\n 263: astore_2\n 264: iconst_0\n 265: istore_3\n 266: aload_2\n 267: iconst_0\n 268: invokeinterface #117, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 273: aload_2\n 274: iconst_1\n 275: invokeinterface #117, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 280: invokestatic #132 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 283: nop\n 284: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #79 // class java/lang/Iterable\n 4: astore_1\n 5: nop\n 6: iconst_0\n 7: istore_2\n 8: aload_1\n 9: astore_3\n 10: new #81 // class java/util/ArrayList\n 13: dup\n 14: aload_1\n 15: bipush 10\n 17: invokestatic #87 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #89 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #91 // class java/util/Collection\n 26: astore 4\n 28: iconst_0\n 29: istore 5\n 31: aload_3\n 32: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 37: astore 6\n 39: aload 6\n 41: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 46: ifeq 89\n 49: aload 6\n 51: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 56: astore 7\n 58: aload 4\n 60: aload 7\n 62: checkcast #69 // class java/lang/String\n 65: astore 8\n 67: astore 10\n 69: iconst_0\n 70: istore 9\n 72: aload 8\n 74: invokestatic #150 // Method main$parseToIntRangePerElf:(Ljava/lang/String;)Lkotlin/Pair;\n 77: aload 10\n 79: swap\n 80: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 85: pop\n 86: goto 39\n 89: aload 4\n 91: checkcast #57 // class java/util/List\n 94: nop\n 95: checkcast #79 // class java/lang/Iterable\n 98: astore_1\n 99: nop\n 100: iconst_0\n 101: istore_2\n 102: aload_1\n 103: instanceof #91 // class java/util/Collection\n 106: ifeq 125\n 109: aload_1\n 110: checkcast #91 // class java/util/Collection\n 113: invokeinterface #153, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 118: ifeq 125\n 121: iconst_0\n 122: goto 240\n 125: iconst_0\n 126: istore_3\n 127: aload_1\n 128: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 133: astore 4\n 135: aload 4\n 137: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 142: ifeq 239\n 145: aload 4\n 147: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 152: astore 5\n 154: aload 5\n 156: checkcast #155 // class kotlin/Pair\n 159: astore 6\n 161: iconst_0\n 162: istore 7\n 164: aload 6\n 166: invokevirtual #158 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 169: checkcast #79 // class java/lang/Iterable\n 172: aload 6\n 174: invokevirtual #161 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 177: checkcast #79 // class java/lang/Iterable\n 180: invokestatic #165 // Method kotlin/collections/CollectionsKt.minus:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;\n 183: invokeinterface #166, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 188: ifne 218\n 191: aload 6\n 193: invokevirtual #161 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 196: checkcast #79 // class java/lang/Iterable\n 199: aload 6\n 201: invokevirtual #158 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 204: checkcast #79 // class java/lang/Iterable\n 207: invokestatic #165 // Method kotlin/collections/CollectionsKt.minus:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;\n 210: invokeinterface #166, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 215: ifeq 222\n 218: iconst_1\n 219: goto 223\n 222: iconst_0\n 223: ifeq 135\n 226: iinc 3, 1\n 229: iload_3\n 230: ifge 135\n 233: invokestatic #169 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 236: goto 135\n 239: iload_3\n 240: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #79 // class java/lang/Iterable\n 4: astore_1\n 5: nop\n 6: iconst_0\n 7: istore_2\n 8: aload_1\n 9: astore_3\n 10: new #81 // class java/util/ArrayList\n 13: dup\n 14: aload_1\n 15: bipush 10\n 17: invokestatic #87 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #89 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #91 // class java/util/Collection\n 26: astore 4\n 28: iconst_0\n 29: istore 5\n 31: aload_3\n 32: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 37: astore 6\n 39: aload 6\n 41: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 46: ifeq 89\n 49: aload 6\n 51: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 56: astore 7\n 58: aload 4\n 60: aload 7\n 62: checkcast #69 // class java/lang/String\n 65: astore 8\n 67: astore 16\n 69: iconst_0\n 70: istore 9\n 72: aload 8\n 74: invokestatic #150 // Method main$parseToIntRangePerElf:(Ljava/lang/String;)Lkotlin/Pair;\n 77: aload 16\n 79: swap\n 80: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 85: pop\n 86: goto 39\n 89: aload 4\n 91: checkcast #57 // class java/util/List\n 94: nop\n 95: checkcast #79 // class java/lang/Iterable\n 98: astore_1\n 99: nop\n 100: iconst_0\n 101: istore_2\n 102: aload_1\n 103: instanceof #91 // class java/util/Collection\n 106: ifeq 125\n 109: aload_1\n 110: checkcast #91 // class java/util/Collection\n 113: invokeinterface #153, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 118: ifeq 125\n 121: iconst_0\n 122: goto 386\n 125: iconst_0\n 126: istore_3\n 127: aload_1\n 128: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 133: astore 4\n 135: aload 4\n 137: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 142: ifeq 385\n 145: aload 4\n 147: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 152: astore 5\n 154: aload 5\n 156: checkcast #155 // class kotlin/Pair\n 159: astore 6\n 161: iconst_0\n 162: istore 7\n 164: aload 6\n 166: invokevirtual #179 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 169: checkcast #113 // class kotlin/ranges/IntRange\n 172: astore 8\n 174: aload 6\n 176: invokevirtual #182 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 179: checkcast #113 // class kotlin/ranges/IntRange\n 182: astore 9\n 184: aload 8\n 186: checkcast #79 // class java/lang/Iterable\n 189: astore 10\n 191: iconst_0\n 192: istore 11\n 194: aload 10\n 196: instanceof #91 // class java/util/Collection\n 199: ifeq 219\n 202: aload 10\n 204: checkcast #91 // class java/util/Collection\n 207: invokeinterface #153, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 212: ifeq 219\n 215: iconst_0\n 216: goto 270\n 219: aload 10\n 221: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 226: astore 12\n 228: aload 12\n 230: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 235: ifeq 269\n 238: aload 12\n 240: checkcast #184 // class kotlin/collections/IntIterator\n 243: invokevirtual #188 // Method kotlin/collections/IntIterator.nextInt:()I\n 246: istore 13\n 248: iload 13\n 250: istore 14\n 252: iconst_0\n 253: istore 15\n 255: aload 9\n 257: iload 14\n 259: invokevirtual #192 // Method kotlin/ranges/IntRange.contains:(I)Z\n 262: ifeq 228\n 265: iconst_1\n 266: goto 270\n 269: iconst_0\n 270: ifne 363\n 273: aload 8\n 275: checkcast #79 // class java/lang/Iterable\n 278: astore 10\n 280: iconst_0\n 281: istore 11\n 283: aload 10\n 285: instanceof #91 // class java/util/Collection\n 288: ifeq 308\n 291: aload 10\n 293: checkcast #91 // class java/util/Collection\n 296: invokeinterface #153, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 301: ifeq 308\n 304: iconst_0\n 305: goto 360\n 308: aload 10\n 310: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 315: astore 12\n 317: aload 12\n 319: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 324: ifeq 359\n 327: aload 12\n 329: checkcast #184 // class kotlin/collections/IntIterator\n 332: invokevirtual #188 // Method kotlin/collections/IntIterator.nextInt:()I\n 335: istore 13\n 337: iload 13\n 339: istore 14\n 341: iconst_0\n 342: istore 15\n 344: aload 9\n 346: iload 14\n 348: invokevirtual #192 // Method kotlin/ranges/IntRange.contains:(I)Z\n 351: nop\n 352: ifeq 317\n 355: iconst_1\n 356: goto 360\n 359: iconst_0\n 360: ifeq 367\n 363: iconst_1\n 364: goto 368\n 367: iconst_0\n 368: nop\n 369: ifeq 135\n 372: iinc 3, 1\n 375: iload_3\n 376: ifge 135\n 379: invokestatic #169 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 382: goto 135\n 385: iload_3\n 386: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day04.class",
"javap": "Compiled from \"Day04.kt\"\npublic final class Day04 {\n public static final Day04 INSTANCE;\n\n public static final int EXPECTED_PART1_CHECK_ANSWER;\n\n public static final int EXPECTED_PART2_CHECK_ANSWER;\n\n private Day04();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n static {};\n Code:\n 0: new #2 // class Day04\n 3: dup\n 4: invokespecial #12 // Method \"<init>\":()V\n 7: putstatic #15 // Field INSTANCE:LDay04;\n 10: return\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day16.kt
|
import java.util.*
object Day16 {
const val EXPECTED_PART1_CHECK_ANSWER = 1651
const val EXPECTED_PART2_CHECK_ANSWER = 1707
const val START_VALVE_NAME = "AA"
const val RUNTIME_MINS_PART1 = 30
const val RUNTIME_MINS_PART2 = 26
}
data class Valve(val name: String, val flowRate: Int) {
private var _accessibleValves: Set<Valve> = emptySet()
val accessibleValves
get() = _accessibleValves
fun addAccessibleValve(valve: Valve) {
_accessibleValves += valve
}
}
fun main() {
fun List<String>.parseValves(): MutableMap<String, Valve> {
val paths = mutableMapOf<String, List<String>>()
val valves = mutableMapOf<String, Valve>()
forEach { valveString ->
val (name, flowRate, accessibleValves) = Regex(
"Valve (.+) has flow rate=(\\d+); tunnels? leads? to valves? (.*)"
)
.matchEntire(valveString)?.destructured ?: error("Valve line not matched")
if (valves.contains(name)) error("Duplicate valve name detected")
paths[name] = accessibleValves.split(',').map(String::trim)
valves[name] = Valve(name, flowRate.toInt())
}
paths.forEach { (name, accessibleValves) ->
accessibleValves.forEach { accessibleValveName ->
valves[name]?.addAccessibleValve(
valves[accessibleValveName] ?: error("Could not find accessible valve")
)
}
}
return valves
}
fun shortestPathDistance(start: Valve, dest: Valve): Int {
val queue = LinkedList<Pair<Valve, Int>>()
val visited = mutableSetOf<Valve>()
queue.add(start to 0)
visited.add(start)
while (queue.isNotEmpty()) {
val (valve, distance) = queue.remove()
if (valve == dest) {
return distance
}
for (accessibleValve in valve.accessibleValves) {
if (!visited.contains(accessibleValve)) {
queue.add(accessibleValve to distance + 1)
visited.add(accessibleValve)
}
}
}
error("No shortest path found for $start to $dest")
}
data class Opener(val currentLocation: Valve, val minutesRemaining: Int)
fun releasedPressure(
distances: Map<Valve, Map<Valve, Int>>,
openenersData: List<Opener>,
opened: List<Valve> = emptyList(),
releasedPressure: Int = 0,
): Int {
val openerData = openenersData.maxBy { it.minutesRemaining }
return distances[openerData.currentLocation]!!.filter { it.key !in opened }
.maxOfOrNull { (nextValve, distance) ->
val newMinutesRemaining = openerData.minutesRemaining - distance - 1
if (newMinutesRemaining > 0) {
releasedPressure(
distances,
openenersData = openenersData.minus(openerData) + Opener(nextValve, newMinutesRemaining),
opened = opened + nextValve,
releasedPressure = releasedPressure + nextValve.flowRate * newMinutesRemaining,
)
} else {
releasedPressure
}
} ?: releasedPressure
}
fun part1(input: List<String>, startValveName: String): Int {
val valvesMap = input.parseValves()
val distances = valvesMap.values.associateWith { startValve ->
valvesMap.values.filter { it.flowRate > 0 }.associateWith { destValve ->
shortestPathDistance(startValve, destValve)
}
}
return releasedPressure(
distances,
openenersData = listOf(Opener(valvesMap[startValveName]!!, Day16.RUNTIME_MINS_PART1)),
)
}
fun part2(input: List<String>): Int {
val valvesMap = input.parseValves()
val distances = valvesMap.values.associateWith { startValve ->
valvesMap.values.filter { it.flowRate > 0 }.associateWith { destValve ->
shortestPathDistance(startValve, destValve)
}
}
val result = releasedPressure(
distances,
openenersData = listOf(
Opener(valvesMap[Day16.START_VALVE_NAME]!!, Day16.RUNTIME_MINS_PART2),
Opener(valvesMap[Day16.START_VALVE_NAME]!!, Day16.RUNTIME_MINS_PART2)
),
)
println("Part 2 result $result")
return result
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day16_test")
println("Part 1 check")
check(part1(testInput, Day16.START_VALVE_NAME) == Day16.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
println("Part 2 check")
check(part2(testInput) == Day16.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }
val input = readInput("Day16")
println("Part 1")
println(part1(input, Day16.START_VALVE_NAME))
println("Part 2")
println(part2(input))
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day16Kt$main$Opener.class",
"javap": "Compiled from \"Day16.kt\"\npublic final class Day16Kt$main$Opener {\n private final Valve currentLocation;\n\n private final int minutesRemaining;\n\n public Day16Kt$main$Opener(Valve, int);\n Code:\n 0: aload_1\n 1: ldc #8 // String currentLocation\n 3: invokestatic #14 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokespecial #17 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: aload_1\n 12: putfield #20 // Field currentLocation:LValve;\n 15: aload_0\n 16: iload_2\n 17: putfield #24 // Field minutesRemaining:I\n 20: return\n\n public final Valve getCurrentLocation();\n Code:\n 0: aload_0\n 1: getfield #20 // Field currentLocation:LValve;\n 4: areturn\n\n public final int getMinutesRemaining();\n Code:\n 0: aload_0\n 1: getfield #24 // Field minutesRemaining:I\n 4: ireturn\n\n public final Valve component1();\n Code:\n 0: aload_0\n 1: getfield #20 // Field currentLocation:LValve;\n 4: areturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #24 // Field minutesRemaining:I\n 4: ireturn\n\n public final Day16Kt$main$Opener copy(Valve, int);\n Code:\n 0: aload_1\n 1: ldc #8 // String currentLocation\n 3: invokestatic #14 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class Day16Kt$main$Opener\n 9: dup\n 10: aload_1\n 11: iload_2\n 12: invokespecial #36 // Method \"<init>\":(LValve;I)V\n 15: areturn\n\n public static Day16Kt$main$Opener copy$default(Day16Kt$main$Opener, Valve, 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 #20 // Field currentLocation:LValve;\n 10: astore_1\n 11: iload_3\n 12: iconst_2\n 13: iand\n 14: ifeq 22\n 17: aload_0\n 18: getfield #24 // Field minutesRemaining:I\n 21: istore_2\n 22: aload_0\n 23: aload_1\n 24: iload_2\n 25: invokevirtual #40 // Method copy:(LValve;I)LDay16Kt$main$Opener;\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 Opener(currentLocation=\n 9: invokevirtual #51 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #20 // Field currentLocation:LValve;\n 16: invokevirtual #54 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #56 // String , minutesRemaining=\n 21: invokevirtual #51 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #24 // Field minutesRemaining:I\n 28: invokevirtual #59 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #62 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #64 // 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 #20 // Field currentLocation:LValve;\n 4: invokevirtual #69 // Method Valve.hashCode:()I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #24 // Field minutesRemaining:I\n 16: invokestatic #74 // 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 Day16Kt$main$Opener\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day16Kt$main$Opener\n 20: astore_2\n 21: aload_0\n 22: getfield #20 // Field currentLocation:LValve;\n 25: aload_2\n 26: getfield #20 // Field currentLocation:LValve;\n 29: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 32: ifne 37\n 35: iconst_0\n 36: ireturn\n 37: aload_0\n 38: getfield #24 // Field minutesRemaining:I\n 41: aload_2\n 42: getfield #24 // Field minutesRemaining:I\n 45: if_icmpeq 50\n 48: iconst_0\n 49: ireturn\n 50: iconst_1\n 51: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day16.class",
"javap": "Compiled from \"Day16.kt\"\npublic final class Day16 {\n public static final Day16 INSTANCE;\n\n public static final int EXPECTED_PART1_CHECK_ANSWER;\n\n public static final int EXPECTED_PART2_CHECK_ANSWER;\n\n public static final java.lang.String START_VALVE_NAME;\n\n public static final int RUNTIME_MINS_PART1;\n\n public static final int RUNTIME_MINS_PART2;\n\n private Day16();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n static {};\n Code:\n 0: new #2 // class Day16\n 3: dup\n 4: invokespecial #12 // Method \"<init>\":()V\n 7: putstatic #15 // Field INSTANCE:LDay16;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day16Kt.class",
"javap": "Compiled from \"Day16.kt\"\npublic final class Day16Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day16_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: ldc #16 // String Part 1 check\n 8: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 11: swap\n 12: invokevirtual #28 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 15: aload_0\n 16: ldc #30 // String AA\n 18: invokestatic #34 // Method main$part1:(Ljava/util/List;Ljava/lang/String;)I\n 21: sipush 1651\n 24: if_icmpne 31\n 27: iconst_1\n 28: goto 32\n 31: iconst_0\n 32: ifne 52\n 35: iconst_0\n 36: istore_2\n 37: ldc #36 // String Part 1 failed\n 39: astore_2\n 40: new #38 // class java/lang/IllegalStateException\n 43: dup\n 44: aload_2\n 45: invokevirtual #42 // Method java/lang/Object.toString:()Ljava/lang/String;\n 48: invokespecial #46 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 51: athrow\n 52: ldc #48 // String Part 2 check\n 54: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 57: swap\n 58: invokevirtual #28 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 61: aload_0\n 62: invokestatic #52 // Method main$part2:(Ljava/util/List;)I\n 65: sipush 1707\n 68: if_icmpne 75\n 71: iconst_1\n 72: goto 76\n 75: iconst_0\n 76: ifne 96\n 79: iconst_0\n 80: istore_2\n 81: ldc #54 // String Part 2 failed\n 83: astore_2\n 84: new #38 // class java/lang/IllegalStateException\n 87: dup\n 88: aload_2\n 89: invokevirtual #42 // Method java/lang/Object.toString:()Ljava/lang/String;\n 92: invokespecial #46 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 95: athrow\n 96: ldc #56 // String Day16\n 98: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 101: astore_1\n 102: ldc #58 // String Part 1\n 104: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 107: swap\n 108: invokevirtual #28 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 111: aload_1\n 112: ldc #30 // String AA\n 114: invokestatic #34 // Method main$part1:(Ljava/util/List;Ljava/lang/String;)I\n 117: istore_2\n 118: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 121: iload_2\n 122: invokevirtual #61 // Method java/io/PrintStream.println:(I)V\n 125: ldc #63 // String Part 2\n 127: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 130: swap\n 131: invokevirtual #28 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 134: aload_1\n 135: invokestatic #52 // Method main$part2:(Ljava/util/List;)I\n 138: istore_2\n 139: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 142: iload_2\n 143: invokevirtual #61 // Method java/io/PrintStream.println:(I)V\n 146: 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.Map<java.lang.String, Valve> main$parseValves(java.util.List<java.lang.String>);\n Code:\n 0: new #81 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #83 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #85 // class java/util/Map\n 10: astore_1\n 11: new #81 // class java/util/LinkedHashMap\n 14: dup\n 15: invokespecial #83 // Method java/util/LinkedHashMap.\"<init>\":()V\n 18: checkcast #85 // class java/util/Map\n 21: astore_2\n 22: aload_0\n 23: checkcast #87 // class java/lang/Iterable\n 26: astore_3\n 27: iconst_0\n 28: istore 4\n 30: aload_3\n 31: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 5\n 38: aload 5\n 40: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 389\n 48: aload 5\n 50: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 6\n 57: aload 6\n 59: checkcast #103 // class java/lang/String\n 62: astore 7\n 64: iconst_0\n 65: istore 8\n 67: new #105 // class kotlin/text/Regex\n 70: dup\n 71: ldc #107 // String Valve (.+) has flow rate=(\\\\d+); tunnels? leads? to valves? (.*)\n 73: invokespecial #108 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 76: aload 7\n 78: checkcast #110 // class java/lang/CharSequence\n 81: invokevirtual #114 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;\n 84: astore 9\n 86: aload 9\n 88: ifnull 110\n 91: aload 9\n 93: invokeinterface #120, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 98: astore 10\n 100: aload 10\n 102: ifnull 110\n 105: aload 10\n 107: goto 123\n 110: new #38 // class java/lang/IllegalStateException\n 113: dup\n 114: ldc #122 // String Valve line not matched\n 116: invokevirtual #42 // Method java/lang/Object.toString:()Ljava/lang/String;\n 119: invokespecial #46 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 122: athrow\n 123: astore 11\n 125: aload 11\n 127: invokevirtual #128 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 130: invokeinterface #132, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 135: iconst_1\n 136: invokeinterface #136, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 141: checkcast #103 // class java/lang/String\n 144: astore 9\n 146: aload 11\n 148: invokevirtual #128 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 151: invokeinterface #132, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 156: iconst_2\n 157: invokeinterface #136, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 162: checkcast #103 // class java/lang/String\n 165: astore 10\n 167: aload 11\n 169: invokevirtual #128 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 172: invokeinterface #132, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 177: iconst_3\n 178: invokeinterface #136, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 183: checkcast #103 // class java/lang/String\n 186: astore 12\n 188: aload_2\n 189: aload 9\n 191: invokeinterface #140, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 196: ifeq 212\n 199: new #38 // class java/lang/IllegalStateException\n 202: dup\n 203: ldc #142 // String Duplicate valve name detected\n 205: invokevirtual #42 // Method java/lang/Object.toString:()Ljava/lang/String;\n 208: invokespecial #46 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 211: athrow\n 212: aload_1\n 213: astore 13\n 215: aload 12\n 217: checkcast #110 // class java/lang/CharSequence\n 220: iconst_1\n 221: newarray char\n 223: astore 14\n 225: aload 14\n 227: iconst_0\n 228: bipush 44\n 230: castore\n 231: aload 14\n 233: iconst_0\n 234: iconst_0\n 235: bipush 6\n 237: aconst_null\n 238: invokestatic #148 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 241: checkcast #87 // class java/lang/Iterable\n 244: astore 14\n 246: iconst_0\n 247: istore 15\n 249: aload 14\n 251: astore 16\n 253: new #150 // class java/util/ArrayList\n 256: dup\n 257: aload 14\n 259: bipush 10\n 261: invokestatic #156 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 264: invokespecial #158 // Method java/util/ArrayList.\"<init>\":(I)V\n 267: checkcast #160 // class java/util/Collection\n 270: astore 17\n 272: iconst_0\n 273: istore 18\n 275: aload 16\n 277: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 282: astore 19\n 284: aload 19\n 286: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 291: ifeq 341\n 294: aload 19\n 296: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 301: astore 20\n 303: aload 17\n 305: aload 20\n 307: checkcast #103 // class java/lang/String\n 310: astore 21\n 312: astore 22\n 314: iconst_0\n 315: istore 23\n 317: aload 21\n 319: checkcast #110 // class java/lang/CharSequence\n 322: invokestatic #164 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 325: invokevirtual #42 // Method java/lang/Object.toString:()Ljava/lang/String;\n 328: nop\n 329: aload 22\n 331: swap\n 332: invokeinterface #167, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 337: pop\n 338: goto 284\n 341: aload 17\n 343: checkcast #71 // class java/util/List\n 346: nop\n 347: astore 14\n 349: aload 13\n 351: aload 9\n 353: aload 14\n 355: invokeinterface #171, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 360: pop\n 361: aload_2\n 362: aload 9\n 364: new #173 // class Valve\n 367: dup\n 368: aload 9\n 370: aload 10\n 372: invokestatic #179 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 375: invokespecial #182 // Method Valve.\"<init>\":(Ljava/lang/String;I)V\n 378: invokeinterface #171, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 383: pop\n 384: nop\n 385: nop\n 386: goto 38\n 389: nop\n 390: aload_1\n 391: astore_3\n 392: iconst_0\n 393: istore 4\n 395: aload_3\n 396: invokeinterface #186, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 401: invokeinterface #189, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 406: astore 5\n 408: aload 5\n 410: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 415: ifeq 571\n 418: aload 5\n 420: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 425: checkcast #191 // class java/util/Map$Entry\n 428: astore 6\n 430: aload 6\n 432: astore 7\n 434: iconst_0\n 435: istore 8\n 437: aload 7\n 439: invokeinterface #194, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 444: checkcast #103 // class java/lang/String\n 447: astore 9\n 449: aload 7\n 451: invokeinterface #197, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 456: checkcast #71 // class java/util/List\n 459: astore 10\n 461: aload 10\n 463: checkcast #87 // class java/lang/Iterable\n 466: astore 11\n 468: iconst_0\n 469: istore 12\n 471: aload 11\n 473: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 478: astore 13\n 480: aload 13\n 482: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 487: ifeq 565\n 490: aload 13\n 492: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 497: astore 14\n 499: aload 14\n 501: checkcast #103 // class java/lang/String\n 504: astore 15\n 506: iconst_0\n 507: istore 16\n 509: aload_2\n 510: aload 9\n 512: invokeinterface #200, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 517: checkcast #173 // class Valve\n 520: dup\n 521: ifnull 559\n 524: aload_2\n 525: aload 15\n 527: invokeinterface #200, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 532: checkcast #173 // class Valve\n 535: dup\n 536: ifnonnull 553\n 539: pop\n 540: new #38 // class java/lang/IllegalStateException\n 543: dup\n 544: ldc #202 // String Could not find accessible valve\n 546: invokevirtual #42 // Method java/lang/Object.toString:()Ljava/lang/String;\n 549: invokespecial #46 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 552: athrow\n 553: invokevirtual #206 // Method Valve.addAccessibleValve:(LValve;)V\n 556: goto 560\n 559: pop\n 560: nop\n 561: nop\n 562: goto 480\n 565: nop\n 566: nop\n 567: nop\n 568: goto 408\n 571: nop\n 572: aload_2\n 573: areturn\n\n private static final int main$shortestPathDistance(Valve, Valve);\n Code:\n 0: new #238 // class java/util/LinkedList\n 3: dup\n 4: invokespecial #239 // Method java/util/LinkedList.\"<init>\":()V\n 7: astore_2\n 8: new #241 // class java/util/LinkedHashSet\n 11: dup\n 12: invokespecial #242 // Method java/util/LinkedHashSet.\"<init>\":()V\n 15: checkcast #188 // class java/util/Set\n 18: astore_3\n 19: aload_2\n 20: aload_0\n 21: iconst_0\n 22: invokestatic #246 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 25: invokestatic #252 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 28: invokevirtual #253 // Method java/util/LinkedList.add:(Ljava/lang/Object;)Z\n 31: pop\n 32: aload_3\n 33: aload_0\n 34: invokeinterface #254, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 39: pop\n 40: aload_2\n 41: checkcast #160 // class java/util/Collection\n 44: invokeinterface #257, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 49: ifne 56\n 52: iconst_1\n 53: goto 57\n 56: iconst_0\n 57: ifeq 178\n 60: aload_2\n 61: invokevirtual #260 // Method java/util/LinkedList.remove:()Ljava/lang/Object;\n 64: checkcast #262 // class kotlin/Pair\n 67: astore 4\n 69: aload 4\n 71: invokevirtual #265 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 74: checkcast #173 // class Valve\n 77: astore 5\n 79: aload 4\n 81: invokevirtual #268 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 84: checkcast #270 // class java/lang/Number\n 87: invokevirtual #274 // Method java/lang/Number.intValue:()I\n 90: istore 6\n 92: aload 5\n 94: aload_1\n 95: invokestatic #280 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 98: ifeq 104\n 101: iload 6\n 103: ireturn\n 104: aload 5\n 106: invokevirtual #283 // Method Valve.getAccessibleValves:()Ljava/util/Set;\n 109: invokeinterface #189, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 114: astore 7\n 116: aload 7\n 118: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 123: ifeq 40\n 126: aload 7\n 128: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 133: checkcast #173 // class Valve\n 136: astore 8\n 138: aload_3\n 139: aload 8\n 141: invokeinterface #286, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 146: ifne 116\n 149: aload_2\n 150: aload 8\n 152: iload 6\n 154: iconst_1\n 155: iadd\n 156: invokestatic #246 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 159: invokestatic #252 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 162: invokevirtual #253 // Method java/util/LinkedList.add:(Ljava/lang/Object;)Z\n 165: pop\n 166: aload_3\n 167: aload 8\n 169: invokeinterface #254, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 174: pop\n 175: goto 116\n 178: new #38 // class java/lang/IllegalStateException\n 181: dup\n 182: new #288 // class java/lang/StringBuilder\n 185: dup\n 186: invokespecial #289 // Method java/lang/StringBuilder.\"<init>\":()V\n 189: ldc_w #291 // String No shortest path found for\n 192: invokevirtual #295 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 195: aload_0\n 196: invokevirtual #298 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 199: ldc_w #300 // String to\n 202: invokevirtual #295 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 205: aload_1\n 206: invokevirtual #298 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 209: invokevirtual #301 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 212: invokevirtual #42 // Method java/lang/Object.toString:()Ljava/lang/String;\n 215: invokespecial #46 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 218: athrow\n\n private static final int main$releasedPressure(java.util.Map<Valve, ? extends java.util.Map<Valve, java.lang.Integer>>, java.util.List<Day16Kt$main$Opener>, java.util.List<Valve>, int);\n Code:\n 0: aload_1\n 1: checkcast #87 // class java/lang/Iterable\n 4: astore 5\n 6: iconst_0\n 7: istore 6\n 9: aload 5\n 11: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 16: astore 7\n 18: aload 7\n 20: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 25: ifne 36\n 28: new #316 // class java/util/NoSuchElementException\n 31: dup\n 32: invokespecial #317 // Method java/util/NoSuchElementException.\"<init>\":()V\n 35: athrow\n 36: aload 7\n 38: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 43: astore 8\n 45: aload 7\n 47: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 52: ifne 60\n 55: aload 8\n 57: goto 130\n 60: aload 8\n 62: checkcast #319 // class Day16Kt$main$Opener\n 65: astore 9\n 67: iconst_0\n 68: istore 10\n 70: aload 9\n 72: invokevirtual #322 // Method Day16Kt$main$Opener.getMinutesRemaining:()I\n 75: istore 9\n 77: aload 7\n 79: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 84: astore 10\n 86: aload 10\n 88: checkcast #319 // class Day16Kt$main$Opener\n 91: astore 11\n 93: iconst_0\n 94: istore 12\n 96: aload 11\n 98: invokevirtual #322 // Method Day16Kt$main$Opener.getMinutesRemaining:()I\n 101: istore 11\n 103: iload 9\n 105: iload 11\n 107: if_icmpge 118\n 110: aload 10\n 112: astore 8\n 114: iload 11\n 116: istore 9\n 118: aload 7\n 120: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 125: ifne 77\n 128: aload 8\n 130: checkcast #319 // class Day16Kt$main$Opener\n 133: astore 4\n 135: aload_0\n 136: aload 4\n 138: invokevirtual #326 // Method Day16Kt$main$Opener.getCurrentLocation:()LValve;\n 141: invokeinterface #200, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 146: dup\n 147: invokestatic #329 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 150: checkcast #85 // class java/util/Map\n 153: astore 6\n 155: iconst_0\n 156: istore 7\n 158: aload 6\n 160: astore 8\n 162: new #81 // class java/util/LinkedHashMap\n 165: dup\n 166: invokespecial #83 // Method java/util/LinkedHashMap.\"<init>\":()V\n 169: checkcast #85 // class java/util/Map\n 172: astore 9\n 174: iconst_0\n 175: istore 10\n 177: aload 8\n 179: invokeinterface #186, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 184: invokeinterface #189, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 189: astore 11\n 191: aload 11\n 193: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 198: ifeq 269\n 201: aload 11\n 203: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 208: checkcast #191 // class java/util/Map$Entry\n 211: astore 12\n 213: aload 12\n 215: astore 13\n 217: iconst_0\n 218: istore 14\n 220: aload_2\n 221: aload 13\n 223: invokeinterface #194, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 228: invokeinterface #330, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 233: ifne 240\n 236: iconst_1\n 237: goto 241\n 240: iconst_0\n 241: ifeq 191\n 244: aload 9\n 246: aload 12\n 248: invokeinterface #194, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 253: aload 12\n 255: invokeinterface #197, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 260: invokeinterface #171, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 265: pop\n 266: goto 191\n 269: aload 9\n 271: nop\n 272: invokeinterface #186, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 277: checkcast #87 // class java/lang/Iterable\n 280: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 285: astore 7\n 287: aload 7\n 289: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 294: ifne 301\n 297: aconst_null\n 298: goto 574\n 301: aload 7\n 303: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 308: checkcast #191 // class java/util/Map$Entry\n 311: astore 8\n 313: iconst_0\n 314: istore 9\n 316: aload 8\n 318: invokeinterface #194, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 323: checkcast #173 // class Valve\n 326: astore 10\n 328: aload 8\n 330: invokeinterface #197, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 335: checkcast #270 // class java/lang/Number\n 338: invokevirtual #274 // Method java/lang/Number.intValue:()I\n 341: istore 11\n 343: aload 4\n 345: invokevirtual #322 // Method Day16Kt$main$Opener.getMinutesRemaining:()I\n 348: iload 11\n 350: isub\n 351: iconst_1\n 352: isub\n 353: istore 12\n 355: iload 12\n 357: ifle 412\n 360: aload_0\n 361: aload_1\n 362: checkcast #87 // class java/lang/Iterable\n 365: aload 4\n 367: invokestatic #334 // Method kotlin/collections/CollectionsKt.minus:(Ljava/lang/Iterable;Ljava/lang/Object;)Ljava/util/List;\n 370: checkcast #160 // class java/util/Collection\n 373: new #319 // class Day16Kt$main$Opener\n 376: dup\n 377: aload 10\n 379: iload 12\n 381: invokespecial #337 // Method Day16Kt$main$Opener.\"<init>\":(LValve;I)V\n 384: invokestatic #341 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 387: aload_2\n 388: checkcast #160 // class java/util/Collection\n 391: aload 10\n 393: invokestatic #341 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 396: iload_3\n 397: aload 10\n 399: invokevirtual #344 // Method Valve.getFlowRate:()I\n 402: iload 12\n 404: imul\n 405: iadd\n 406: invokestatic #346 // Method main$releasedPressure:(Ljava/util/Map;Ljava/util/List;Ljava/util/List;I)I\n 409: goto 413\n 412: iload_3\n 413: nop\n 414: invokestatic #246 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 417: checkcast #348 // class java/lang/Comparable\n 420: astore 8\n 422: aload 7\n 424: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 429: ifeq 572\n 432: aload 7\n 434: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 439: checkcast #191 // class java/util/Map$Entry\n 442: astore 9\n 444: iconst_0\n 445: istore 10\n 447: aload 9\n 449: invokeinterface #194, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 454: checkcast #173 // class Valve\n 457: astore 11\n 459: aload 9\n 461: invokeinterface #197, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 466: checkcast #270 // class java/lang/Number\n 469: invokevirtual #274 // Method java/lang/Number.intValue:()I\n 472: istore 12\n 474: aload 4\n 476: invokevirtual #322 // Method Day16Kt$main$Opener.getMinutesRemaining:()I\n 479: iload 12\n 481: isub\n 482: iconst_1\n 483: isub\n 484: istore 13\n 486: iload 13\n 488: ifle 543\n 491: aload_0\n 492: aload_1\n 493: checkcast #87 // class java/lang/Iterable\n 496: aload 4\n 498: invokestatic #334 // Method kotlin/collections/CollectionsKt.minus:(Ljava/lang/Iterable;Ljava/lang/Object;)Ljava/util/List;\n 501: checkcast #160 // class java/util/Collection\n 504: new #319 // class Day16Kt$main$Opener\n 507: dup\n 508: aload 11\n 510: iload 13\n 512: invokespecial #337 // Method Day16Kt$main$Opener.\"<init>\":(LValve;I)V\n 515: invokestatic #341 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 518: aload_2\n 519: checkcast #160 // class java/util/Collection\n 522: aload 11\n 524: invokestatic #341 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 527: iload_3\n 528: aload 11\n 530: invokevirtual #344 // Method Valve.getFlowRate:()I\n 533: iload 13\n 535: imul\n 536: iadd\n 537: invokestatic #346 // Method main$releasedPressure:(Ljava/util/Map;Ljava/util/List;Ljava/util/List;I)I\n 540: goto 544\n 543: iload_3\n 544: nop\n 545: invokestatic #246 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 548: checkcast #348 // class java/lang/Comparable\n 551: astore 9\n 553: aload 8\n 555: aload 9\n 557: invokeinterface #352, 2 // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I\n 562: ifge 422\n 565: aload 9\n 567: astore 8\n 569: goto 422\n 572: aload 8\n 574: checkcast #175 // class java/lang/Integer\n 577: dup\n 578: ifnull 587\n 581: invokevirtual #353 // Method java/lang/Integer.intValue:()I\n 584: goto 589\n 587: pop\n 588: iload_3\n 589: ireturn\n\n static int main$releasedPressure$default(java.util.Map, java.util.List, java.util.List, int, int, java.lang.Object);\n Code:\n 0: iload 4\n 2: iconst_4\n 3: iand\n 4: ifeq 11\n 7: invokestatic #383 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 10: astore_2\n 11: iload 4\n 13: bipush 8\n 15: iand\n 16: ifeq 21\n 19: iconst_0\n 20: istore_3\n 21: aload_0\n 22: aload_1\n 23: aload_2\n 24: iload_3\n 25: invokestatic #346 // Method main$releasedPressure:(Ljava/util/Map;Ljava/util/List;Ljava/util/List;I)I\n 28: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>, java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #386 // Method main$parseValves:(Ljava/util/List;)Ljava/util/Map;\n 4: astore_2\n 5: aload_2\n 6: invokeinterface #390, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 11: checkcast #87 // class java/lang/Iterable\n 14: astore 4\n 16: iconst_0\n 17: istore 5\n 19: new #81 // class java/util/LinkedHashMap\n 22: dup\n 23: aload 4\n 25: bipush 10\n 27: invokestatic #156 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 30: invokestatic #396 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 33: bipush 16\n 35: invokestatic #402 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 38: invokespecial #403 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 41: astore 6\n 43: aload 4\n 45: astore 7\n 47: iconst_0\n 48: istore 8\n 50: aload 7\n 52: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 57: astore 9\n 59: aload 9\n 61: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 66: ifeq 345\n 69: aload 9\n 71: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 76: astore 10\n 78: aload 6\n 80: checkcast #85 // class java/util/Map\n 83: aload 10\n 85: aload 10\n 87: checkcast #173 // class Valve\n 90: astore 11\n 92: astore 26\n 94: astore 25\n 96: iconst_0\n 97: istore 12\n 99: aload_2\n 100: invokeinterface #390, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 105: checkcast #87 // class java/lang/Iterable\n 108: astore 13\n 110: iconst_0\n 111: istore 14\n 113: aload 13\n 115: astore 15\n 117: new #150 // class java/util/ArrayList\n 120: dup\n 121: invokespecial #404 // Method java/util/ArrayList.\"<init>\":()V\n 124: checkcast #160 // class java/util/Collection\n 127: astore 16\n 129: iconst_0\n 130: istore 17\n 132: aload 15\n 134: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 139: astore 18\n 141: aload 18\n 143: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 148: ifeq 199\n 151: aload 18\n 153: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 158: astore 19\n 160: aload 19\n 162: checkcast #173 // class Valve\n 165: astore 20\n 167: iconst_0\n 168: istore 21\n 170: aload 20\n 172: invokevirtual #344 // Method Valve.getFlowRate:()I\n 175: ifle 182\n 178: iconst_1\n 179: goto 183\n 182: iconst_0\n 183: ifeq 141\n 186: aload 16\n 188: aload 19\n 190: invokeinterface #167, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 195: pop\n 196: goto 141\n 199: aload 16\n 201: checkcast #71 // class java/util/List\n 204: nop\n 205: checkcast #87 // class java/lang/Iterable\n 208: astore 13\n 210: nop\n 211: iconst_0\n 212: istore 14\n 214: new #81 // class java/util/LinkedHashMap\n 217: dup\n 218: aload 13\n 220: bipush 10\n 222: invokestatic #156 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 225: invokestatic #396 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 228: bipush 16\n 230: invokestatic #402 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 233: invokespecial #403 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 236: astore 15\n 238: aload 13\n 240: astore 16\n 242: iconst_0\n 243: istore 17\n 245: aload 16\n 247: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 252: astore 18\n 254: aload 18\n 256: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 261: ifeq 321\n 264: aload 18\n 266: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 271: astore 19\n 273: aload 15\n 275: checkcast #85 // class java/util/Map\n 278: aload 19\n 280: aload 19\n 282: checkcast #173 // class Valve\n 285: astore 20\n 287: astore 22\n 289: astore 23\n 291: iconst_0\n 292: istore 21\n 294: aload 11\n 296: aload 20\n 298: invokestatic #406 // Method main$shortestPathDistance:(LValve;LValve;)I\n 301: invokestatic #246 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 304: astore 24\n 306: aload 23\n 308: aload 22\n 310: aload 24\n 312: invokeinterface #171, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 317: pop\n 318: goto 254\n 321: aload 15\n 323: checkcast #85 // class java/util/Map\n 326: nop\n 327: nop\n 328: astore 27\n 330: aload 25\n 332: aload 26\n 334: aload 27\n 336: invokeinterface #171, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 341: pop\n 342: goto 59\n 345: aload 6\n 347: checkcast #85 // class java/util/Map\n 350: nop\n 351: astore_3\n 352: aload_3\n 353: new #319 // class Day16Kt$main$Opener\n 356: dup\n 357: aload_2\n 358: aload_1\n 359: invokeinterface #200, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 364: dup\n 365: invokestatic #329 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 368: checkcast #173 // class Valve\n 371: bipush 30\n 373: invokespecial #337 // Method Day16Kt$main$Opener.\"<init>\":(LValve;I)V\n 376: invokestatic #410 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 379: aconst_null\n 380: iconst_0\n 381: bipush 12\n 383: aconst_null\n 384: invokestatic #412 // Method main$releasedPressure$default:(Ljava/util/Map;Ljava/util/List;Ljava/util/List;IILjava/lang/Object;)I\n 387: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #386 // Method main$parseValves:(Ljava/util/List;)Ljava/util/Map;\n 4: astore_1\n 5: aload_1\n 6: invokeinterface #390, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 11: checkcast #87 // class java/lang/Iterable\n 14: astore_3\n 15: iconst_0\n 16: istore 4\n 18: new #81 // class java/util/LinkedHashMap\n 21: dup\n 22: aload_3\n 23: bipush 10\n 25: invokestatic #156 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 28: invokestatic #396 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 31: bipush 16\n 33: invokestatic #402 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 36: invokespecial #403 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 39: astore 5\n 41: aload_3\n 42: astore 6\n 44: iconst_0\n 45: istore 7\n 47: aload 6\n 49: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 54: astore 8\n 56: aload 8\n 58: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 63: ifeq 342\n 66: aload 8\n 68: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 73: astore 9\n 75: aload 5\n 77: checkcast #85 // class java/util/Map\n 80: aload 9\n 82: aload 9\n 84: checkcast #173 // class Valve\n 87: astore 10\n 89: astore 25\n 91: astore 24\n 93: iconst_0\n 94: istore 11\n 96: aload_1\n 97: invokeinterface #390, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 102: checkcast #87 // class java/lang/Iterable\n 105: astore 12\n 107: iconst_0\n 108: istore 13\n 110: aload 12\n 112: astore 14\n 114: new #150 // class java/util/ArrayList\n 117: dup\n 118: invokespecial #404 // Method java/util/ArrayList.\"<init>\":()V\n 121: checkcast #160 // class java/util/Collection\n 124: astore 15\n 126: iconst_0\n 127: istore 16\n 129: aload 14\n 131: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 136: astore 17\n 138: aload 17\n 140: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 145: ifeq 196\n 148: aload 17\n 150: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 155: astore 18\n 157: aload 18\n 159: checkcast #173 // class Valve\n 162: astore 19\n 164: iconst_0\n 165: istore 20\n 167: aload 19\n 169: invokevirtual #344 // Method Valve.getFlowRate:()I\n 172: ifle 179\n 175: iconst_1\n 176: goto 180\n 179: iconst_0\n 180: ifeq 138\n 183: aload 15\n 185: aload 18\n 187: invokeinterface #167, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 192: pop\n 193: goto 138\n 196: aload 15\n 198: checkcast #71 // class java/util/List\n 201: nop\n 202: checkcast #87 // class java/lang/Iterable\n 205: astore 12\n 207: nop\n 208: iconst_0\n 209: istore 13\n 211: new #81 // class java/util/LinkedHashMap\n 214: dup\n 215: aload 12\n 217: bipush 10\n 219: invokestatic #156 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 222: invokestatic #396 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 225: bipush 16\n 227: invokestatic #402 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 230: invokespecial #403 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 233: astore 14\n 235: aload 12\n 237: astore 15\n 239: iconst_0\n 240: istore 16\n 242: aload 15\n 244: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 249: astore 17\n 251: aload 17\n 253: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 258: ifeq 318\n 261: aload 17\n 263: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 268: astore 18\n 270: aload 14\n 272: checkcast #85 // class java/util/Map\n 275: aload 18\n 277: aload 18\n 279: checkcast #173 // class Valve\n 282: astore 19\n 284: astore 21\n 286: astore 22\n 288: iconst_0\n 289: istore 20\n 291: aload 10\n 293: aload 19\n 295: invokestatic #406 // Method main$shortestPathDistance:(LValve;LValve;)I\n 298: invokestatic #246 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 301: astore 23\n 303: aload 22\n 305: aload 21\n 307: aload 23\n 309: invokeinterface #171, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 314: pop\n 315: goto 251\n 318: aload 14\n 320: checkcast #85 // class java/util/Map\n 323: nop\n 324: nop\n 325: astore 26\n 327: aload 24\n 329: aload 25\n 331: aload 26\n 333: invokeinterface #171, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 338: pop\n 339: goto 56\n 342: aload 5\n 344: checkcast #85 // class java/util/Map\n 347: nop\n 348: astore_2\n 349: aload_2\n 350: iconst_2\n 351: anewarray #319 // class Day16Kt$main$Opener\n 354: astore 4\n 356: aload 4\n 358: iconst_0\n 359: new #319 // class Day16Kt$main$Opener\n 362: dup\n 363: aload_1\n 364: ldc #30 // String AA\n 366: invokeinterface #200, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 371: dup\n 372: invokestatic #329 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 375: checkcast #173 // class Valve\n 378: bipush 26\n 380: invokespecial #337 // Method Day16Kt$main$Opener.\"<init>\":(LValve;I)V\n 383: aastore\n 384: aload 4\n 386: iconst_1\n 387: new #319 // class Day16Kt$main$Opener\n 390: dup\n 391: aload_1\n 392: ldc #30 // String AA\n 394: invokeinterface #200, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 399: dup\n 400: invokestatic #329 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 403: checkcast #173 // class Valve\n 406: bipush 26\n 408: invokespecial #337 // Method Day16Kt$main$Opener.\"<init>\":(LValve;I)V\n 411: aastore\n 412: aload 4\n 414: invokestatic #429 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 417: aconst_null\n 418: iconst_0\n 419: bipush 12\n 421: aconst_null\n 422: invokestatic #412 // Method main$releasedPressure$default:(Ljava/util/Map;Ljava/util/List;Ljava/util/List;IILjava/lang/Object;)I\n 425: istore_3\n 426: new #288 // class java/lang/StringBuilder\n 429: dup\n 430: invokespecial #289 // Method java/lang/StringBuilder.\"<init>\":()V\n 433: ldc_w #431 // String Part 2 result\n 436: invokevirtual #295 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 439: iload_3\n 440: invokevirtual #434 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 443: invokevirtual #301 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 446: getstatic #22 // Field java/lang/System.out:Ljava/io/PrintStream;\n 449: swap\n 450: invokevirtual #28 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 453: iload_3\n 454: ireturn\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day23.kt
|
import Day23.draw
import Day23.proposeMoves
object Day23 {
const val EXPECTED_PART1_CHECK_ANSWER = 110
const val EXPECTED_PART2_CHECK_ANSWER = 20
sealed interface GridCell
object Empty : GridCell
object Elf : GridCell
class Grid {
private val rows = mutableListOf<List<GridCell>>()
var width: Int = 0
private set
var height: Int = 0
private set
fun addRow(cells: List<Day23.GridCell>) {
rows += cells
width = rows.maxOf { it.size }
height = rows.size
}
fun doStep() {
}
}
fun Array<Coordinates>.draw() {
val fromX = minOf { it.x }
val toX = maxOf { it.x }
val fromY = minOf { it.y }
val toY = maxOf { it.y }
for (y in fromY..toY) {
for (x in fromX..toX) {
if (Coordinates(x, y) in this) {
print('#')
} else {
print('.')
}
}
println()
}
}
fun Array<Coordinates>.proposeMoves(
directions: Array<Direction>,
directionStartIdx: Int
): List<Pair<Coordinates, Coordinates>> = mapNotNull { elf ->
if (intersect(elf.adjacentPositions().toSet()).isNotEmpty()) {
var proposedMove: Pair<Coordinates, Coordinates>? = null
var directionIdx = directionStartIdx
var directionsDoneCount = 0
while (proposedMove == null && directionIdx < directions.size && directionsDoneCount++ <= directions.size) {
if (intersect(elf.adjacentPositions(directions[directionIdx])).isEmpty()) {
proposedMove = Pair(elf, elf + directions[directionIdx].move)
}
directionIdx = (directionIdx + 1) % directions.size
}
proposedMove
} else {
null
}
}
}
fun main() {
fun List<String>.parseElfsMap(): Array<Coordinates> = flatMapIndexed { row, line ->
line.mapIndexedNotNull { col, cell ->
when (cell) {
'.' -> null
'#' -> Coordinates(col, row)
else -> error("Unknown cell content $cell")
}
}
}.toTypedArray()
fun part1(input: List<String>, doDraw: Boolean): Int {
val elfs = input.parseElfsMap()
if (doDraw) {
elfs.draw()
println()
}
val directions = arrayOf(Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST)
var directionStartIdx = 0
repeat(10) {
val proposedMoves = elfs.proposeMoves(directions, directionStartIdx)
val allNewPositions = proposedMoves.map { it.second }
proposedMoves.forEach { (currentPosition, proposedPosition) ->
if (allNewPositions.count { it == proposedPosition } == 1) {
elfs[elfs.indexOf(currentPosition)] = proposedPosition
}
}
directionStartIdx = (directionStartIdx + 1) % directions.size
if (doDraw) {
elfs.draw()
println()
}
}
val fromX = elfs.minOf { it.x }
val toX = elfs.maxOf { it.x }
val fromY = elfs.minOf { it.y }
val toY = elfs.maxOf { it.y }
return (fromY..toY).sumOf { y -> (fromX..toX).count { x -> !elfs.contains(Coordinates(x, y)) } }
}
fun part2(input: List<String>): Int {
val elfs = input.parseElfsMap()
val directions = arrayOf(Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST)
var directionStartIdx = 0
var round = 0
var atLeastOneElfMoved: Boolean
do {
atLeastOneElfMoved = false
val proposedMoves = elfs.proposeMoves(directions, directionStartIdx)
val allNewPositions = proposedMoves.map { it.second }
proposedMoves.forEach { (currentPosition, proposedPosition) ->
if (allNewPositions.count { it == proposedPosition } == 1) {
elfs[elfs.indexOf(currentPosition)] = proposedPosition
atLeastOneElfMoved = true
}
}
directionStartIdx = (directionStartIdx + 1) % directions.size
round++
} while (atLeastOneElfMoved)
return round
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day23_test")
check(part1(testInput, true) == Day23.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
check(part2(testInput) == Day23.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }
val input = readInput("Day23")
println(part1(input, false))
println(part2(input))
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day23Kt.class",
"javap": "Compiled from \"Day23.kt\"\npublic final class Day23Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day23_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: iconst_1\n 8: invokestatic #18 // Method main$part1:(Ljava/util/List;Z)I\n 11: bipush 110\n 13: if_icmpne 20\n 16: iconst_1\n 17: goto 21\n 20: iconst_0\n 21: ifne 41\n 24: iconst_0\n 25: istore_2\n 26: ldc #20 // String Part 1 failed\n 28: astore_2\n 29: new #22 // class java/lang/IllegalStateException\n 32: dup\n 33: aload_2\n 34: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 37: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 40: athrow\n 41: aload_0\n 42: invokestatic #34 // Method main$part2:(Ljava/util/List;)I\n 45: bipush 20\n 47: if_icmpne 54\n 50: iconst_1\n 51: goto 55\n 54: iconst_0\n 55: ifne 75\n 58: iconst_0\n 59: istore_2\n 60: ldc #36 // String Part 2 failed\n 62: astore_2\n 63: new #22 // class java/lang/IllegalStateException\n 66: dup\n 67: aload_2\n 68: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 71: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 74: athrow\n 75: ldc #38 // String Day23\n 77: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 80: astore_1\n 81: aload_1\n 82: iconst_0\n 83: invokestatic #18 // Method main$part1:(Ljava/util/List;Z)I\n 86: istore_2\n 87: getstatic #44 // Field java/lang/System.out:Ljava/io/PrintStream;\n 90: iload_2\n 91: invokevirtual #50 // Method java/io/PrintStream.println:(I)V\n 94: aload_1\n 95: invokestatic #34 // Method main$part2:(Ljava/util/List;)I\n 98: istore_2\n 99: getstatic #44 // Field java/lang/System.out:Ljava/io/PrintStream;\n 102: iload_2\n 103: invokevirtual #50 // Method java/io/PrintStream.println:(I)V\n 106: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #61 // Method main:()V\n 3: return\n\n private static final Coordinates[] main$parseElfsMap(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #68 // class java/lang/Iterable\n 4: astore_2\n 5: new #70 // class java/util/ArrayList\n 8: dup\n 9: invokespecial #72 // Method java/util/ArrayList.\"<init>\":()V\n 12: checkcast #74 // class java/util/Collection\n 15: astore_3\n 16: iconst_0\n 17: istore 4\n 19: aload_2\n 20: invokeinterface #78, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 25: astore 5\n 27: aload 5\n 29: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 34: ifeq 292\n 37: aload 5\n 39: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 44: astore 6\n 46: iload 4\n 48: iinc 4, 1\n 51: istore 7\n 53: iload 7\n 55: ifge 61\n 58: invokestatic #93 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 61: iload 7\n 63: aload 6\n 65: checkcast #95 // class java/lang/String\n 68: astore 8\n 70: istore 9\n 72: iconst_0\n 73: istore 10\n 75: aload 8\n 77: checkcast #97 // class java/lang/CharSequence\n 80: astore 11\n 82: iconst_0\n 83: istore 12\n 85: aload 11\n 87: astore 13\n 89: new #70 // class java/util/ArrayList\n 92: dup\n 93: invokespecial #72 // Method java/util/ArrayList.\"<init>\":()V\n 96: checkcast #74 // class java/util/Collection\n 99: astore 14\n 101: iconst_0\n 102: istore 15\n 104: aload 13\n 106: astore 16\n 108: iconst_0\n 109: istore 17\n 111: iconst_0\n 112: istore 18\n 114: iconst_0\n 115: istore 19\n 117: iload 19\n 119: aload 16\n 121: invokeinterface #101, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 126: if_icmpge 272\n 129: aload 16\n 131: iload 19\n 133: invokeinterface #105, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 138: istore 20\n 140: iload 18\n 142: iinc 18, 1\n 145: iload 20\n 147: istore 21\n 149: istore 22\n 151: iconst_0\n 152: istore 23\n 154: iload 22\n 156: iload 21\n 158: istore 24\n 160: istore 25\n 162: iconst_0\n 163: istore 26\n 165: iload 24\n 167: lookupswitch { // 2\n 35: 196\n 46: 192\n default: 210\n }\n 192: aconst_null\n 193: goto 241\n 196: new #107 // class Coordinates\n 199: dup\n 200: iload 25\n 202: iload 9\n 204: invokespecial #110 // Method Coordinates.\"<init>\":(II)V\n 207: goto 241\n 210: new #22 // class java/lang/IllegalStateException\n 213: dup\n 214: new #112 // class java/lang/StringBuilder\n 217: dup\n 218: invokespecial #113 // Method java/lang/StringBuilder.\"<init>\":()V\n 221: ldc #115 // String Unknown cell content\n 223: invokevirtual #119 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 226: iload 24\n 228: invokevirtual #122 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 231: invokevirtual #123 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 234: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 237: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 240: athrow\n 241: nop\n 242: dup\n 243: ifnull 264\n 246: astore 27\n 248: iconst_0\n 249: istore 28\n 251: aload 14\n 253: aload 27\n 255: invokeinterface #127, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 260: pop\n 261: goto 265\n 264: pop\n 265: nop\n 266: iinc 19, 1\n 269: goto 117\n 272: nop\n 273: aload 14\n 275: checkcast #58 // class java/util/List\n 278: nop\n 279: checkcast #68 // class java/lang/Iterable\n 282: nop\n 283: aload_3\n 284: swap\n 285: invokestatic #131 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 288: pop\n 289: goto 27\n 292: aload_3\n 293: checkcast #58 // class java/util/List\n 296: checkcast #74 // class java/util/Collection\n 299: astore_1\n 300: nop\n 301: iconst_0\n 302: istore_2\n 303: aload_1\n 304: astore_3\n 305: aload_3\n 306: iconst_0\n 307: anewarray #107 // class Coordinates\n 310: invokeinterface #135, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 315: checkcast #137 // class \"[LCoordinates;\"\n 318: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>, boolean);\n Code:\n 0: aload_0\n 1: invokestatic #169 // Method main$parseElfsMap:(Ljava/util/List;)[LCoordinates;\n 4: astore_2\n 5: iload_1\n 6: ifeq 22\n 9: getstatic #174 // Field Day23.INSTANCE:LDay23;\n 12: aload_2\n 13: invokevirtual #178 // Method Day23.draw:([LCoordinates;)V\n 16: getstatic #44 // Field java/lang/System.out:Ljava/io/PrintStream;\n 19: invokevirtual #180 // Method java/io/PrintStream.println:()V\n 22: iconst_4\n 23: anewarray #182 // class Direction\n 26: astore 4\n 28: aload 4\n 30: iconst_0\n 31: getstatic #186 // Field Direction.NORTH:LDirection;\n 34: aastore\n 35: aload 4\n 37: iconst_1\n 38: getstatic #189 // Field Direction.SOUTH:LDirection;\n 41: aastore\n 42: aload 4\n 44: iconst_2\n 45: getstatic #192 // Field Direction.WEST:LDirection;\n 48: aastore\n 49: aload 4\n 51: iconst_3\n 52: getstatic #195 // Field Direction.EAST:LDirection;\n 55: aastore\n 56: aload 4\n 58: astore_3\n 59: iconst_0\n 60: istore 4\n 62: bipush 10\n 64: istore 5\n 66: iconst_0\n 67: istore 6\n 69: iload 6\n 71: iload 5\n 73: if_icmpge 424\n 76: iload 6\n 78: istore 7\n 80: iconst_0\n 81: istore 8\n 83: getstatic #174 // Field Day23.INSTANCE:LDay23;\n 86: aload_2\n 87: aload_3\n 88: iload 4\n 90: invokevirtual #199 // Method Day23.proposeMoves:([LCoordinates;[LDirection;I)Ljava/util/List;\n 93: astore 9\n 95: aload 9\n 97: checkcast #68 // class java/lang/Iterable\n 100: astore 10\n 102: iconst_0\n 103: istore 11\n 105: aload 10\n 107: astore 12\n 109: new #70 // class java/util/ArrayList\n 112: dup\n 113: aload 10\n 115: bipush 10\n 117: invokestatic #203 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 120: invokespecial #205 // Method java/util/ArrayList.\"<init>\":(I)V\n 123: checkcast #74 // class java/util/Collection\n 126: astore 13\n 128: iconst_0\n 129: istore 14\n 131: aload 12\n 133: invokeinterface #78, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 138: astore 15\n 140: aload 15\n 142: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 147: ifeq 193\n 150: aload 15\n 152: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 157: astore 16\n 159: aload 13\n 161: aload 16\n 163: checkcast #207 // class kotlin/Pair\n 166: astore 17\n 168: astore 18\n 170: iconst_0\n 171: istore 19\n 173: aload 17\n 175: invokevirtual #210 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 178: checkcast #107 // class Coordinates\n 181: aload 18\n 183: swap\n 184: invokeinterface #127, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 189: pop\n 190: goto 140\n 193: aload 13\n 195: checkcast #58 // class java/util/List\n 198: nop\n 199: astore 20\n 201: aload 9\n 203: checkcast #68 // class java/lang/Iterable\n 206: astore 10\n 208: iconst_0\n 209: istore 11\n 211: aload 10\n 213: invokeinterface #78, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 218: astore 12\n 220: aload 12\n 222: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 227: ifeq 390\n 230: aload 12\n 232: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 237: astore 13\n 239: aload 13\n 241: checkcast #207 // class kotlin/Pair\n 244: astore 14\n 246: iconst_0\n 247: istore 15\n 249: aload 14\n 251: invokevirtual #213 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 254: checkcast #107 // class Coordinates\n 257: astore 16\n 259: aload 14\n 261: invokevirtual #216 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 264: checkcast #107 // class Coordinates\n 267: astore 17\n 269: aload 20\n 271: checkcast #68 // class java/lang/Iterable\n 274: astore 19\n 276: iconst_0\n 277: istore 21\n 279: aload 19\n 281: instanceof #74 // class java/util/Collection\n 284: ifeq 304\n 287: aload 19\n 289: checkcast #74 // class java/util/Collection\n 292: invokeinterface #219, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 297: ifeq 304\n 300: iconst_0\n 301: goto 371\n 304: iconst_0\n 305: istore 22\n 307: aload 19\n 309: invokeinterface #78, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 314: astore 23\n 316: aload 23\n 318: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 323: ifeq 369\n 326: aload 23\n 328: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 333: astore 24\n 335: aload 24\n 337: checkcast #107 // class Coordinates\n 340: astore 25\n 342: iconst_0\n 343: istore 26\n 345: aload 25\n 347: aload 17\n 349: invokestatic #225 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 352: ifeq 316\n 355: iinc 22, 1\n 358: iload 22\n 360: ifge 316\n 363: invokestatic #228 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 366: goto 316\n 369: iload 22\n 371: iconst_1\n 372: if_icmpne 385\n 375: aload_2\n 376: aload_2\n 377: aload 16\n 379: invokestatic #234 // Method kotlin/collections/ArraysKt.indexOf:([Ljava/lang/Object;Ljava/lang/Object;)I\n 382: aload 17\n 384: aastore\n 385: nop\n 386: nop\n 387: goto 220\n 390: nop\n 391: iload 4\n 393: iconst_1\n 394: iadd\n 395: aload_3\n 396: arraylength\n 397: irem\n 398: istore 4\n 400: iload_1\n 401: ifeq 417\n 404: getstatic #174 // Field Day23.INSTANCE:LDay23;\n 407: aload_2\n 408: invokevirtual #178 // Method Day23.draw:([LCoordinates;)V\n 411: getstatic #44 // Field java/lang/System.out:Ljava/io/PrintStream;\n 414: invokevirtual #180 // Method java/io/PrintStream.println:()V\n 417: nop\n 418: iinc 6, 1\n 421: goto 69\n 424: aload_2\n 425: astore 6\n 427: aload 6\n 429: arraylength\n 430: ifne 437\n 433: iconst_1\n 434: goto 438\n 437: iconst_0\n 438: ifeq 449\n 441: new #236 // class java/util/NoSuchElementException\n 444: dup\n 445: invokespecial #237 // Method java/util/NoSuchElementException.\"<init>\":()V\n 448: athrow\n 449: aload 6\n 451: iconst_0\n 452: aaload\n 453: astore 7\n 455: iconst_0\n 456: istore 8\n 458: aload 7\n 460: invokevirtual #240 // Method Coordinates.getX:()I\n 463: istore 7\n 465: iconst_1\n 466: istore 8\n 468: aload 6\n 470: invokestatic #244 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I\n 473: istore 9\n 475: iload 8\n 477: iload 9\n 479: if_icmpgt 523\n 482: aload 6\n 484: iload 8\n 486: aaload\n 487: astore 10\n 489: iconst_0\n 490: istore 11\n 492: aload 10\n 494: invokevirtual #240 // Method Coordinates.getX:()I\n 497: istore 10\n 499: iload 7\n 501: iload 10\n 503: if_icmple 510\n 506: iload 10\n 508: istore 7\n 510: iload 8\n 512: iload 9\n 514: if_icmpeq 523\n 517: iinc 8, 1\n 520: goto 482\n 523: iload 7\n 525: istore 5\n 527: aload_2\n 528: astore 7\n 530: aload 7\n 532: arraylength\n 533: ifne 540\n 536: iconst_1\n 537: goto 541\n 540: iconst_0\n 541: ifeq 552\n 544: new #236 // class java/util/NoSuchElementException\n 547: dup\n 548: invokespecial #237 // Method java/util/NoSuchElementException.\"<init>\":()V\n 551: athrow\n 552: aload 7\n 554: iconst_0\n 555: aaload\n 556: astore 8\n 558: iconst_0\n 559: istore 9\n 561: aload 8\n 563: invokevirtual #240 // Method Coordinates.getX:()I\n 566: istore 8\n 568: iconst_1\n 569: istore 9\n 571: aload 7\n 573: invokestatic #244 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I\n 576: istore 10\n 578: iload 9\n 580: iload 10\n 582: if_icmpgt 626\n 585: aload 7\n 587: iload 9\n 589: aaload\n 590: astore 11\n 592: iconst_0\n 593: istore 12\n 595: aload 11\n 597: invokevirtual #240 // Method Coordinates.getX:()I\n 600: istore 11\n 602: iload 8\n 604: iload 11\n 606: if_icmpge 613\n 609: iload 11\n 611: istore 8\n 613: iload 9\n 615: iload 10\n 617: if_icmpeq 626\n 620: iinc 9, 1\n 623: goto 585\n 626: iload 8\n 628: istore 6\n 630: aload_2\n 631: astore 8\n 633: aload 8\n 635: arraylength\n 636: ifne 643\n 639: iconst_1\n 640: goto 644\n 643: iconst_0\n 644: ifeq 655\n 647: new #236 // class java/util/NoSuchElementException\n 650: dup\n 651: invokespecial #237 // Method java/util/NoSuchElementException.\"<init>\":()V\n 654: athrow\n 655: aload 8\n 657: iconst_0\n 658: aaload\n 659: astore 9\n 661: iconst_0\n 662: istore 10\n 664: aload 9\n 666: invokevirtual #247 // Method Coordinates.getY:()I\n 669: istore 9\n 671: iconst_1\n 672: istore 10\n 674: aload 8\n 676: invokestatic #244 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I\n 679: istore 11\n 681: iload 10\n 683: iload 11\n 685: if_icmpgt 729\n 688: aload 8\n 690: iload 10\n 692: aaload\n 693: astore 12\n 695: iconst_0\n 696: istore 13\n 698: aload 12\n 700: invokevirtual #247 // Method Coordinates.getY:()I\n 703: istore 12\n 705: iload 9\n 707: iload 12\n 709: if_icmple 716\n 712: iload 12\n 714: istore 9\n 716: iload 10\n 718: iload 11\n 720: if_icmpeq 729\n 723: iinc 10, 1\n 726: goto 688\n 729: iload 9\n 731: istore 7\n 733: aload_2\n 734: astore 9\n 736: aload 9\n 738: arraylength\n 739: ifne 746\n 742: iconst_1\n 743: goto 747\n 746: iconst_0\n 747: ifeq 758\n 750: new #236 // class java/util/NoSuchElementException\n 753: dup\n 754: invokespecial #237 // Method java/util/NoSuchElementException.\"<init>\":()V\n 757: athrow\n 758: aload 9\n 760: iconst_0\n 761: aaload\n 762: astore 10\n 764: iconst_0\n 765: istore 11\n 767: aload 10\n 769: invokevirtual #247 // Method Coordinates.getY:()I\n 772: istore 10\n 774: iconst_1\n 775: istore 11\n 777: aload 9\n 779: invokestatic #244 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I\n 782: istore 12\n 784: iload 11\n 786: iload 12\n 788: if_icmpgt 832\n 791: aload 9\n 793: iload 11\n 795: aaload\n 796: astore 13\n 798: iconst_0\n 799: istore 14\n 801: aload 13\n 803: invokevirtual #247 // Method Coordinates.getY:()I\n 806: istore 13\n 808: iload 10\n 810: iload 13\n 812: if_icmpge 819\n 815: iload 13\n 817: istore 10\n 819: iload 11\n 821: iload 12\n 823: if_icmpeq 832\n 826: iinc 11, 1\n 829: goto 791\n 832: iload 10\n 834: istore 8\n 836: new #249 // class kotlin/ranges/IntRange\n 839: dup\n 840: iload 7\n 842: iload 8\n 844: invokespecial #250 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 847: checkcast #68 // class java/lang/Iterable\n 850: astore 9\n 852: iconst_0\n 853: istore 10\n 855: aload 9\n 857: invokeinterface #78, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 862: astore 11\n 864: aload 11\n 866: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 871: ifeq 1033\n 874: aload 11\n 876: checkcast #252 // class kotlin/collections/IntIterator\n 879: invokevirtual #255 // Method kotlin/collections/IntIterator.nextInt:()I\n 882: istore 12\n 884: iload 10\n 886: iload 12\n 888: istore 13\n 890: istore 27\n 892: iconst_0\n 893: istore 14\n 895: new #249 // class kotlin/ranges/IntRange\n 898: dup\n 899: iload 5\n 901: iload 6\n 903: invokespecial #250 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 906: checkcast #68 // class java/lang/Iterable\n 909: astore 15\n 911: iconst_0\n 912: istore 16\n 914: aload 15\n 916: instanceof #74 // class java/util/Collection\n 919: ifeq 939\n 922: aload 15\n 924: checkcast #74 // class java/util/Collection\n 927: invokeinterface #219, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 932: ifeq 939\n 935: iconst_0\n 936: goto 1020\n 939: iconst_0\n 940: istore 17\n 942: aload 15\n 944: invokeinterface #78, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 949: astore 18\n 951: aload 18\n 953: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 958: ifeq 1018\n 961: aload 18\n 963: checkcast #252 // class kotlin/collections/IntIterator\n 966: invokevirtual #255 // Method kotlin/collections/IntIterator.nextInt:()I\n 969: istore 19\n 971: iload 19\n 973: istore 20\n 975: iconst_0\n 976: istore 21\n 978: aload_2\n 979: new #107 // class Coordinates\n 982: dup\n 983: iload 20\n 985: iload 13\n 987: invokespecial #110 // Method Coordinates.\"<init>\":(II)V\n 990: invokestatic #259 // Method kotlin/collections/ArraysKt.contains:([Ljava/lang/Object;Ljava/lang/Object;)Z\n 993: ifne 1000\n 996: iconst_1\n 997: goto 1001\n 1000: iconst_0\n 1001: ifeq 951\n 1004: iinc 17, 1\n 1007: iload 17\n 1009: ifge 951\n 1012: invokestatic #228 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 1015: goto 951\n 1018: iload 17\n 1020: nop\n 1021: istore 28\n 1023: iload 27\n 1025: iload 28\n 1027: iadd\n 1028: istore 10\n 1030: goto 864\n 1033: iload 10\n 1035: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #169 // Method main$parseElfsMap:(Ljava/util/List;)[LCoordinates;\n 4: astore_1\n 5: iconst_4\n 6: anewarray #182 // class Direction\n 9: astore_3\n 10: aload_3\n 11: iconst_0\n 12: getstatic #186 // Field Direction.NORTH:LDirection;\n 15: aastore\n 16: aload_3\n 17: iconst_1\n 18: getstatic #189 // Field Direction.SOUTH:LDirection;\n 21: aastore\n 22: aload_3\n 23: iconst_2\n 24: getstatic #192 // Field Direction.WEST:LDirection;\n 27: aastore\n 28: aload_3\n 29: iconst_3\n 30: getstatic #195 // Field Direction.EAST:LDirection;\n 33: aastore\n 34: aload_3\n 35: astore_2\n 36: iconst_0\n 37: istore_3\n 38: iconst_0\n 39: istore 4\n 41: iconst_0\n 42: istore 5\n 44: iconst_0\n 45: istore 5\n 47: getstatic #174 // Field Day23.INSTANCE:LDay23;\n 50: aload_1\n 51: aload_2\n 52: iload_3\n 53: invokevirtual #199 // Method Day23.proposeMoves:([LCoordinates;[LDirection;I)Ljava/util/List;\n 56: astore 6\n 58: aload 6\n 60: checkcast #68 // class java/lang/Iterable\n 63: astore 8\n 65: iconst_0\n 66: istore 9\n 68: aload 8\n 70: astore 10\n 72: new #70 // class java/util/ArrayList\n 75: dup\n 76: aload 8\n 78: bipush 10\n 80: invokestatic #203 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 83: invokespecial #205 // Method java/util/ArrayList.\"<init>\":(I)V\n 86: checkcast #74 // class java/util/Collection\n 89: astore 11\n 91: iconst_0\n 92: istore 12\n 94: aload 10\n 96: invokeinterface #78, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 101: astore 13\n 103: aload 13\n 105: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 110: ifeq 156\n 113: aload 13\n 115: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 120: astore 14\n 122: aload 11\n 124: aload 14\n 126: checkcast #207 // class kotlin/Pair\n 129: astore 15\n 131: astore 23\n 133: iconst_0\n 134: istore 16\n 136: aload 15\n 138: invokevirtual #210 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 141: checkcast #107 // class Coordinates\n 144: aload 23\n 146: swap\n 147: invokeinterface #127, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 152: pop\n 153: goto 103\n 156: aload 11\n 158: checkcast #58 // class java/util/List\n 161: nop\n 162: astore 7\n 164: aload 6\n 166: checkcast #68 // class java/lang/Iterable\n 169: astore 8\n 171: iconst_0\n 172: istore 9\n 174: aload 8\n 176: invokeinterface #78, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 181: astore 10\n 183: aload 10\n 185: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 190: ifeq 356\n 193: aload 10\n 195: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 200: astore 11\n 202: aload 11\n 204: checkcast #207 // class kotlin/Pair\n 207: astore 12\n 209: iconst_0\n 210: istore 13\n 212: aload 12\n 214: invokevirtual #213 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 217: checkcast #107 // class Coordinates\n 220: astore 14\n 222: aload 12\n 224: invokevirtual #216 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 227: checkcast #107 // class Coordinates\n 230: astore 15\n 232: aload 7\n 234: checkcast #68 // class java/lang/Iterable\n 237: astore 16\n 239: iconst_0\n 240: istore 17\n 242: aload 16\n 244: instanceof #74 // class java/util/Collection\n 247: ifeq 267\n 250: aload 16\n 252: checkcast #74 // class java/util/Collection\n 255: invokeinterface #219, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 260: ifeq 267\n 263: iconst_0\n 264: goto 334\n 267: iconst_0\n 268: istore 18\n 270: aload 16\n 272: invokeinterface #78, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 277: astore 19\n 279: aload 19\n 281: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 286: ifeq 332\n 289: aload 19\n 291: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 296: astore 20\n 298: aload 20\n 300: checkcast #107 // class Coordinates\n 303: astore 21\n 305: iconst_0\n 306: istore 22\n 308: aload 21\n 310: aload 15\n 312: invokestatic #225 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 315: ifeq 279\n 318: iinc 18, 1\n 321: iload 18\n 323: ifge 279\n 326: invokestatic #228 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 329: goto 279\n 332: iload 18\n 334: iconst_1\n 335: if_icmpne 351\n 338: aload_1\n 339: aload_1\n 340: aload 14\n 342: invokestatic #234 // Method kotlin/collections/ArraysKt.indexOf:([Ljava/lang/Object;Ljava/lang/Object;)I\n 345: aload 15\n 347: aastore\n 348: iconst_1\n 349: istore 5\n 351: nop\n 352: nop\n 353: goto 183\n 356: nop\n 357: iload_3\n 358: iconst_1\n 359: iadd\n 360: aload_2\n 361: arraylength\n 362: irem\n 363: istore_3\n 364: iinc 4, 1\n 367: iload 5\n 369: ifne 44\n 372: iload 4\n 374: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day23$Elf.class",
"javap": "Compiled from \"Day23.kt\"\npublic final class Day23$Elf implements Day23$GridCell {\n public static final Day23$Elf INSTANCE;\n\n private Day23$Elf();\n Code:\n 0: aload_0\n 1: invokespecial #10 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n static {};\n Code:\n 0: new #2 // class Day23$Elf\n 3: dup\n 4: invokespecial #14 // Method \"<init>\":()V\n 7: putstatic #17 // Field INSTANCE:LDay23$Elf;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day23$GridCell.class",
"javap": "Compiled from \"Day23.kt\"\npublic interface Day23$GridCell {\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day23.class",
"javap": "Compiled from \"Day23.kt\"\npublic final class Day23 {\n public static final Day23 INSTANCE;\n\n public static final int EXPECTED_PART1_CHECK_ANSWER;\n\n public static final int EXPECTED_PART2_CHECK_ANSWER;\n\n private Day23();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final void draw(Coordinates[]);\n Code:\n 0: aload_1\n 1: ldc #15 // String <this>\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: astore_3\n 8: aload_3\n 9: arraylength\n 10: ifne 17\n 13: iconst_1\n 14: goto 18\n 17: iconst_0\n 18: ifeq 29\n 21: new #23 // class java/util/NoSuchElementException\n 24: dup\n 25: invokespecial #24 // Method java/util/NoSuchElementException.\"<init>\":()V\n 28: athrow\n 29: aload_3\n 30: iconst_0\n 31: aaload\n 32: astore 4\n 34: iconst_0\n 35: istore 5\n 37: aload 4\n 39: invokevirtual #30 // Method Coordinates.getX:()I\n 42: istore 4\n 44: iconst_1\n 45: istore 5\n 47: aload_3\n 48: invokestatic #36 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I\n 51: istore 6\n 53: iload 5\n 55: iload 6\n 57: if_icmpgt 100\n 60: aload_3\n 61: iload 5\n 63: aaload\n 64: astore 7\n 66: iconst_0\n 67: istore 8\n 69: aload 7\n 71: invokevirtual #30 // Method Coordinates.getX:()I\n 74: istore 7\n 76: iload 4\n 78: iload 7\n 80: if_icmple 87\n 83: iload 7\n 85: istore 4\n 87: iload 5\n 89: iload 6\n 91: if_icmpeq 100\n 94: iinc 5, 1\n 97: goto 60\n 100: iload 4\n 102: istore_2\n 103: aload_1\n 104: astore 4\n 106: aload 4\n 108: arraylength\n 109: ifne 116\n 112: iconst_1\n 113: goto 117\n 116: iconst_0\n 117: ifeq 128\n 120: new #23 // class java/util/NoSuchElementException\n 123: dup\n 124: invokespecial #24 // Method java/util/NoSuchElementException.\"<init>\":()V\n 127: athrow\n 128: aload 4\n 130: iconst_0\n 131: aaload\n 132: astore 5\n 134: iconst_0\n 135: istore 6\n 137: aload 5\n 139: invokevirtual #30 // Method Coordinates.getX:()I\n 142: istore 5\n 144: iconst_1\n 145: istore 6\n 147: aload 4\n 149: invokestatic #36 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I\n 152: istore 7\n 154: iload 6\n 156: iload 7\n 158: if_icmpgt 202\n 161: aload 4\n 163: iload 6\n 165: aaload\n 166: astore 8\n 168: iconst_0\n 169: istore 9\n 171: aload 8\n 173: invokevirtual #30 // Method Coordinates.getX:()I\n 176: istore 8\n 178: iload 5\n 180: iload 8\n 182: if_icmpge 189\n 185: iload 8\n 187: istore 5\n 189: iload 6\n 191: iload 7\n 193: if_icmpeq 202\n 196: iinc 6, 1\n 199: goto 161\n 202: iload 5\n 204: istore_3\n 205: aload_1\n 206: astore 5\n 208: aload 5\n 210: arraylength\n 211: ifne 218\n 214: iconst_1\n 215: goto 219\n 218: iconst_0\n 219: ifeq 230\n 222: new #23 // class java/util/NoSuchElementException\n 225: dup\n 226: invokespecial #24 // Method java/util/NoSuchElementException.\"<init>\":()V\n 229: athrow\n 230: aload 5\n 232: iconst_0\n 233: aaload\n 234: astore 6\n 236: iconst_0\n 237: istore 7\n 239: aload 6\n 241: invokevirtual #39 // Method Coordinates.getY:()I\n 244: istore 6\n 246: iconst_1\n 247: istore 7\n 249: aload 5\n 251: invokestatic #36 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I\n 254: istore 8\n 256: iload 7\n 258: iload 8\n 260: if_icmpgt 304\n 263: aload 5\n 265: iload 7\n 267: aaload\n 268: astore 9\n 270: iconst_0\n 271: istore 10\n 273: aload 9\n 275: invokevirtual #39 // Method Coordinates.getY:()I\n 278: istore 9\n 280: iload 6\n 282: iload 9\n 284: if_icmple 291\n 287: iload 9\n 289: istore 6\n 291: iload 7\n 293: iload 8\n 295: if_icmpeq 304\n 298: iinc 7, 1\n 301: goto 263\n 304: iload 6\n 306: istore 4\n 308: aload_1\n 309: astore 6\n 311: aload 6\n 313: arraylength\n 314: ifne 321\n 317: iconst_1\n 318: goto 322\n 321: iconst_0\n 322: ifeq 333\n 325: new #23 // class java/util/NoSuchElementException\n 328: dup\n 329: invokespecial #24 // Method java/util/NoSuchElementException.\"<init>\":()V\n 332: athrow\n 333: aload 6\n 335: iconst_0\n 336: aaload\n 337: astore 7\n 339: iconst_0\n 340: istore 8\n 342: aload 7\n 344: invokevirtual #39 // Method Coordinates.getY:()I\n 347: istore 7\n 349: iconst_1\n 350: istore 8\n 352: aload 6\n 354: invokestatic #36 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I\n 357: istore 9\n 359: iload 8\n 361: iload 9\n 363: if_icmpgt 407\n 366: aload 6\n 368: iload 8\n 370: aaload\n 371: astore 10\n 373: iconst_0\n 374: istore 11\n 376: aload 10\n 378: invokevirtual #39 // Method Coordinates.getY:()I\n 381: istore 10\n 383: iload 7\n 385: iload 10\n 387: if_icmpge 394\n 390: iload 10\n 392: istore 7\n 394: iload 8\n 396: iload 9\n 398: if_icmpeq 407\n 401: iinc 8, 1\n 404: goto 366\n 407: iload 7\n 409: istore 5\n 411: iload 4\n 413: istore 6\n 415: iload 6\n 417: iload 5\n 419: if_icmpgt 507\n 422: iload_2\n 423: istore 7\n 425: iload 7\n 427: iload_3\n 428: if_icmpgt 488\n 431: aload_1\n 432: new #26 // class Coordinates\n 435: dup\n 436: iload 7\n 438: iload 6\n 440: invokespecial #42 // Method Coordinates.\"<init>\":(II)V\n 443: invokestatic #46 // Method kotlin/collections/ArraysKt.contains:([Ljava/lang/Object;Ljava/lang/Object;)Z\n 446: ifeq 464\n 449: bipush 35\n 451: istore 8\n 453: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 456: iload 8\n 458: invokevirtual #58 // Method java/io/PrintStream.print:(C)V\n 461: goto 476\n 464: bipush 46\n 466: istore 8\n 468: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 471: iload 8\n 473: invokevirtual #58 // Method java/io/PrintStream.print:(C)V\n 476: iload 7\n 478: iload_3\n 479: if_icmpeq 488\n 482: iinc 7, 1\n 485: goto 431\n 488: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 491: invokevirtual #61 // Method java/io/PrintStream.println:()V\n 494: iload 6\n 496: iload 5\n 498: if_icmpeq 507\n 501: iinc 6, 1\n 504: goto 422\n 507: return\n\n public final java.util.List<kotlin.Pair<Coordinates, Coordinates>> proposeMoves(Coordinates[], Direction[], int);\n Code:\n 0: aload_1\n 1: ldc #15 // String <this>\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #82 // String directions\n 9: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: astore 4\n 15: iconst_0\n 16: istore 5\n 18: aload 4\n 20: astore 6\n 22: new #84 // class java/util/ArrayList\n 25: dup\n 26: invokespecial #85 // Method java/util/ArrayList.\"<init>\":()V\n 29: checkcast #87 // class java/util/Collection\n 32: astore 7\n 34: iconst_0\n 35: istore 8\n 37: aload 6\n 39: astore 9\n 41: iconst_0\n 42: istore 10\n 44: iconst_0\n 45: istore 11\n 47: aload 9\n 49: arraylength\n 50: istore 12\n 52: iload 11\n 54: iload 12\n 56: if_icmpge 250\n 59: aload 9\n 61: iload 11\n 63: aaload\n 64: astore 13\n 66: aload 13\n 68: astore 14\n 70: iconst_0\n 71: istore 15\n 73: aload 14\n 75: astore 16\n 77: iconst_0\n 78: istore 17\n 80: aload_1\n 81: aload 16\n 83: iconst_0\n 84: iconst_1\n 85: aconst_null\n 86: invokestatic #91 // Method Coordinates.adjacentPositions$default:(LCoordinates;ZILjava/lang/Object;)Ljava/util/Set;\n 89: checkcast #93 // class java/lang/Iterable\n 92: invokestatic #99 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 95: checkcast #93 // class java/lang/Iterable\n 98: invokestatic #103 // Method kotlin/collections/ArraysKt.intersect:([Ljava/lang/Object;Ljava/lang/Iterable;)Ljava/util/Set;\n 101: checkcast #87 // class java/util/Collection\n 104: invokeinterface #107, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 109: ifne 116\n 112: iconst_1\n 113: goto 117\n 116: iconst_0\n 117: ifeq 218\n 120: aconst_null\n 121: astore 18\n 123: iload_3\n 124: istore 19\n 126: iconst_0\n 127: istore 20\n 129: aload 18\n 131: ifnonnull 213\n 134: iload 19\n 136: aload_2\n 137: arraylength\n 138: if_icmpge 213\n 141: iload 20\n 143: iinc 20, 1\n 146: aload_2\n 147: arraylength\n 148: if_icmpgt 213\n 151: aload_1\n 152: aload 16\n 154: aload_2\n 155: iload 19\n 157: aaload\n 158: iconst_0\n 159: iconst_2\n 160: aconst_null\n 161: invokestatic #110 // Method Coordinates.adjacentPositions$default:(LCoordinates;LDirection;ZILjava/lang/Object;)Ljava/util/Set;\n 164: checkcast #93 // class java/lang/Iterable\n 167: invokestatic #103 // Method kotlin/collections/ArraysKt.intersect:([Ljava/lang/Object;Ljava/lang/Iterable;)Ljava/util/Set;\n 170: invokeinterface #113, 1 // InterfaceMethod java/util/Set.isEmpty:()Z\n 175: ifeq 201\n 178: new #115 // class kotlin/Pair\n 181: dup\n 182: aload 16\n 184: aload 16\n 186: aload_2\n 187: iload 19\n 189: aaload\n 190: invokevirtual #121 // Method Direction.getMove:()LCoordinates;\n 193: invokevirtual #125 // Method Coordinates.plus:(LCoordinates;)LCoordinates;\n 196: invokespecial #128 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 199: astore 18\n 201: iload 19\n 203: iconst_1\n 204: iadd\n 205: aload_2\n 206: arraylength\n 207: irem\n 208: istore 19\n 210: goto 129\n 213: aload 18\n 215: goto 219\n 218: aconst_null\n 219: nop\n 220: dup\n 221: ifnull 242\n 224: astore 21\n 226: iconst_0\n 227: istore 22\n 229: aload 7\n 231: aload 21\n 233: invokeinterface #132, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 238: pop\n 239: goto 243\n 242: pop\n 243: nop\n 244: iinc 11, 1\n 247: goto 52\n 250: nop\n 251: aload 7\n 253: checkcast #134 // class java/util/List\n 256: nop\n 257: areturn\n\n static {};\n Code:\n 0: new #2 // class Day23\n 3: dup\n 4: invokespecial #161 // Method \"<init>\":()V\n 7: putstatic #164 // Field INSTANCE:LDay23;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day23$Empty.class",
"javap": "Compiled from \"Day23.kt\"\npublic final class Day23$Empty implements Day23$GridCell {\n public static final Day23$Empty INSTANCE;\n\n private Day23$Empty();\n Code:\n 0: aload_0\n 1: invokespecial #10 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n static {};\n Code:\n 0: new #2 // class Day23$Empty\n 3: dup\n 4: invokespecial #14 // Method \"<init>\":()V\n 7: putstatic #17 // Field INSTANCE:LDay23$Empty;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day23$Grid.class",
"javap": "Compiled from \"Day23.kt\"\npublic final class Day23$Grid {\n private final java.util.List<java.util.List<Day23$GridCell>> rows;\n\n private int width;\n\n private int height;\n\n public Day23$Grid();\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/util/ArrayList\n 8: dup\n 9: invokespecial #11 // Method java/util/ArrayList.\"<init>\":()V\n 12: checkcast #13 // class java/util/List\n 15: putfield #17 // Field rows:Ljava/util/List;\n 18: return\n\n public final int getWidth();\n Code:\n 0: aload_0\n 1: getfield #25 // Field width:I\n 4: ireturn\n\n public final int getHeight();\n Code:\n 0: aload_0\n 1: getfield #29 // Field height:I\n 4: ireturn\n\n public final void addRow(java.util.List<? extends Day23$GridCell>);\n Code:\n 0: aload_1\n 1: ldc #35 // String cells\n 3: invokestatic #41 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getfield #17 // Field rows:Ljava/util/List;\n 10: checkcast #43 // class java/util/Collection\n 13: aload_1\n 14: invokeinterface #47, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 19: pop\n 20: aload_0\n 21: aload_0\n 22: getfield #17 // Field rows:Ljava/util/List;\n 25: checkcast #49 // class java/lang/Iterable\n 28: astore_2\n 29: astore 7\n 31: aload_2\n 32: invokeinterface #53, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 37: astore_3\n 38: aload_3\n 39: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 44: ifne 55\n 47: new #61 // class java/util/NoSuchElementException\n 50: dup\n 51: invokespecial #62 // Method java/util/NoSuchElementException.\"<init>\":()V\n 54: athrow\n 55: aload_3\n 56: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: checkcast #13 // class java/util/List\n 64: astore 4\n 66: iconst_0\n 67: istore 5\n 69: aload 4\n 71: invokeinterface #69, 1 // InterfaceMethod java/util/List.size:()I\n 76: istore 4\n 78: aload_3\n 79: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 84: ifeq 124\n 87: aload_3\n 88: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 93: checkcast #13 // class java/util/List\n 96: astore 5\n 98: iconst_0\n 99: istore 6\n 101: aload 5\n 103: invokeinterface #69, 1 // InterfaceMethod java/util/List.size:()I\n 108: istore 5\n 110: iload 4\n 112: iload 5\n 114: if_icmpge 78\n 117: iload 5\n 119: istore 4\n 121: goto 78\n 124: iload 4\n 126: istore 8\n 128: aload 7\n 130: iload 8\n 132: putfield #25 // Field width:I\n 135: aload_0\n 136: aload_0\n 137: getfield #17 // Field rows:Ljava/util/List;\n 140: invokeinterface #69, 1 // InterfaceMethod java/util/List.size:()I\n 145: putfield #29 // Field height:I\n 148: return\n\n public final void doStep();\n Code:\n 0: return\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day13.kt
|
object Day13 {
const val EXPECTED_PART1_CHECK_ANSWER = 13
const val EXPECTED_PART2_CHECK_ANSWER = 140
const val PACKET_COMBOS_NR_OF_LINES = 3
val NONE_NUMBER_CHARS = listOf('[', ']', ',')
const val DIVIDER_PACKET_ONE = 2
const val DIVIDER_PACKET_TWO = 6
val DIVIDER_PACKETS: List<List<Any>> = listOf(
listOf(listOf(DIVIDER_PACKET_ONE)),
listOf(listOf(DIVIDER_PACKET_TWO))
)
}
fun main() {
fun String.parse(): List<Any> {
val stack = ArrayDeque<MutableList<Any>>()
var idx = 0
do {
when (this[idx]) {
'[' -> {
stack.addFirst(mutableListOf())
idx++
}
']' -> {
if (stack.size > 1) {
val innerList = stack.removeFirst()
stack.first().add(innerList)
}
idx++
}
in '0'..'9' -> {
var nrStr: String = this[idx].toString()
while (this[++idx] !in Day13.NONE_NUMBER_CHARS) {
nrStr += this[idx]
}
stack.first().add(nrStr.toInt())
}
else -> idx++
}
} while (idx < this.length)
check(stack.size == 1) { "Stack should only have root left" }
return stack.first()
}
operator fun List<Any>.compareTo(other: List<Any>): Int {
for (leftIdx in this.indices) {
val firstValue = this[leftIdx]
if (leftIdx < other.size) {
val secondValue = other[leftIdx]
when {
firstValue is Int && secondValue is Int -> {
if (firstValue != secondValue) return firstValue.compareTo(secondValue)
}
else -> {
val firstValueList = if (firstValue is Int) listOf(firstValue) else firstValue as List<Any>
val secondValueList = if (secondValue is Int) listOf(secondValue) else secondValue as List<Any>
if (firstValueList != secondValueList) {
return firstValueList.compareTo(secondValueList)
}
}
}
} else {
return 1
}
}
return -1
}
fun part1(input: List<String>): Int {
val pairs = input.chunked(Day13.PACKET_COMBOS_NR_OF_LINES).map { it[0].parse() to it[1].parse() }
val compareResults = pairs.map { it.first.compareTo(it.second) }
return compareResults.foldIndexed(0) { index, acc, compareResult ->
if (compareResult < 0) acc + index + 1 else acc
}
}
fun part2(input: List<String>): Int {
val pairs = input.filter { it.isNotBlank() }.map { it.parse() } + Day13.DIVIDER_PACKETS
val sorted = pairs.sortedWith { o1, o2 -> o1!!.compareTo(o2!!) }
val result = Day13.DIVIDER_PACKETS.map {
sorted.indexOf(it) + 1
}.reduce(Int::times)
return result
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day13_test")
check(part1(testInput) == Day13.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
check(part2(testInput) == Day13.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }
val input = readInput("Day13")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day13.class",
"javap": "Compiled from \"Day13.kt\"\npublic final class Day13 {\n public static final Day13 INSTANCE;\n\n public static final int EXPECTED_PART1_CHECK_ANSWER;\n\n public static final int EXPECTED_PART2_CHECK_ANSWER;\n\n public static final int PACKET_COMBOS_NR_OF_LINES;\n\n private static final java.util.List<java.lang.Character> NONE_NUMBER_CHARS;\n\n public static final int DIVIDER_PACKET_ONE;\n\n public static final int DIVIDER_PACKET_TWO;\n\n private static final java.util.List<java.util.List<java.lang.Object>> DIVIDER_PACKETS;\n\n private Day13();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final java.util.List<java.lang.Character> getNONE_NUMBER_CHARS();\n Code:\n 0: getstatic #18 // Field NONE_NUMBER_CHARS:Ljava/util/List;\n 3: areturn\n\n public final java.util.List<java.util.List<java.lang.Object>> getDIVIDER_PACKETS();\n Code:\n 0: getstatic #23 // Field DIVIDER_PACKETS:Ljava/util/List;\n 3: areturn\n\n static {};\n Code:\n 0: new #2 // class Day13\n 3: dup\n 4: invokespecial #25 // Method \"<init>\":()V\n 7: putstatic #28 // Field INSTANCE:LDay13;\n 10: iconst_3\n 11: anewarray #30 // class java/lang/Character\n 14: astore_0\n 15: aload_0\n 16: iconst_0\n 17: bipush 91\n 19: invokestatic #34 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 22: aastore\n 23: aload_0\n 24: iconst_1\n 25: bipush 93\n 27: invokestatic #34 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 30: aastore\n 31: aload_0\n 32: iconst_2\n 33: bipush 44\n 35: invokestatic #34 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 38: aastore\n 39: aload_0\n 40: invokestatic #40 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 43: putstatic #18 // Field NONE_NUMBER_CHARS:Ljava/util/List;\n 46: iconst_2\n 47: anewarray #42 // class java/util/List\n 50: astore_0\n 51: aload_0\n 52: iconst_0\n 53: iconst_2\n 54: invokestatic #47 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 57: invokestatic #50 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 60: invokestatic #50 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 63: aastore\n 64: aload_0\n 65: iconst_1\n 66: bipush 6\n 68: invokestatic #47 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 71: invokestatic #50 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 74: invokestatic #50 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 77: aastore\n 78: aload_0\n 79: invokestatic #40 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 82: putstatic #23 // Field DIVIDER_PACKETS:Ljava/util/List;\n 85: return\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day13Kt.class",
"javap": "Compiled from \"Day13.kt\"\npublic final class Day13Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day13_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 10: bipush 13\n 12: if_icmpne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 40\n 23: iconst_0\n 24: istore_2\n 25: ldc #20 // String Part 1 failed\n 27: astore_2\n 28: new #22 // class java/lang/IllegalStateException\n 31: dup\n 32: aload_2\n 33: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 36: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 39: athrow\n 40: aload_0\n 41: invokestatic #33 // Method main$part2:(Ljava/util/List;)I\n 44: sipush 140\n 47: if_icmpne 54\n 50: iconst_1\n 51: goto 55\n 54: iconst_0\n 55: ifne 75\n 58: iconst_0\n 59: istore_2\n 60: ldc #35 // String Part 2 failed\n 62: astore_2\n 63: new #22 // class java/lang/IllegalStateException\n 66: dup\n 67: aload_2\n 68: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 71: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 74: athrow\n 75: ldc #37 // String Day13\n 77: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 80: astore_1\n 81: aload_1\n 82: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 85: istore_2\n 86: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 89: iload_2\n 90: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 93: aload_1\n 94: invokestatic #33 // Method main$part2:(Ljava/util/List;)I\n 97: istore_2\n 98: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 101: iload_2\n 102: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 105: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #60 // Method main:()V\n 3: return\n\n private static final java.util.List<java.lang.Object> main$parse(java.lang.String);\n Code:\n 0: new #66 // class kotlin/collections/ArrayDeque\n 3: dup\n 4: invokespecial #68 // Method kotlin/collections/ArrayDeque.\"<init>\":()V\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_0\n 11: iload_2\n 12: invokevirtual #74 // Method java/lang/String.charAt:(I)C\n 15: istore_3\n 16: iload_3\n 17: bipush 91\n 19: if_icmpne 44\n 22: aload_1\n 23: new #76 // class java/util/ArrayList\n 26: dup\n 27: invokespecial #77 // Method java/util/ArrayList.\"<init>\":()V\n 30: checkcast #57 // class java/util/List\n 33: invokevirtual #81 // Method kotlin/collections/ArrayDeque.addFirst:(Ljava/lang/Object;)V\n 36: iload_2\n 37: iinc 2, 1\n 40: pop\n 41: goto 206\n 44: iload_3\n 45: bipush 93\n 47: if_icmpne 90\n 50: aload_1\n 51: invokevirtual #85 // Method kotlin/collections/ArrayDeque.size:()I\n 54: iconst_1\n 55: if_icmple 82\n 58: aload_1\n 59: invokevirtual #89 // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;\n 62: checkcast #57 // class java/util/List\n 65: astore 4\n 67: aload_1\n 68: invokevirtual #92 // Method kotlin/collections/ArrayDeque.first:()Ljava/lang/Object;\n 71: checkcast #57 // class java/util/List\n 74: aload 4\n 76: invokeinterface #96, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 81: pop\n 82: iload_2\n 83: iinc 2, 1\n 86: pop\n 87: goto 206\n 90: bipush 48\n 92: iload_3\n 93: if_icmpgt 110\n 96: iload_3\n 97: bipush 58\n 99: if_icmpge 106\n 102: iconst_1\n 103: goto 111\n 106: iconst_0\n 107: goto 111\n 110: iconst_0\n 111: ifeq 201\n 114: aload_0\n 115: iload_2\n 116: invokevirtual #74 // Method java/lang/String.charAt:(I)C\n 119: invokestatic #100 // Method java/lang/String.valueOf:(C)Ljava/lang/String;\n 122: astore 4\n 124: getstatic #105 // Field Day13.INSTANCE:LDay13;\n 127: invokevirtual #109 // Method Day13.getNONE_NUMBER_CHARS:()Ljava/util/List;\n 130: aload_0\n 131: iinc 2, 1\n 134: iload_2\n 135: invokevirtual #74 // Method java/lang/String.charAt:(I)C\n 138: invokestatic #114 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 141: invokeinterface #117, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 146: ifne 177\n 149: new #119 // class java/lang/StringBuilder\n 152: dup\n 153: invokespecial #120 // Method java/lang/StringBuilder.\"<init>\":()V\n 156: aload 4\n 158: invokevirtual #124 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 161: aload_0\n 162: iload_2\n 163: invokevirtual #74 // Method java/lang/String.charAt:(I)C\n 166: invokevirtual #127 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 169: invokevirtual #128 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 172: astore 4\n 174: goto 124\n 177: aload_1\n 178: invokevirtual #92 // Method kotlin/collections/ArrayDeque.first:()Ljava/lang/Object;\n 181: checkcast #57 // class java/util/List\n 184: aload 4\n 186: invokestatic #134 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 189: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 192: invokeinterface #96, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 197: pop\n 198: goto 206\n 201: iload_2\n 202: iinc 2, 1\n 205: pop\n 206: iload_2\n 207: aload_0\n 208: invokevirtual #140 // Method java/lang/String.length:()I\n 211: if_icmplt 10\n 214: aload_1\n 215: invokevirtual #85 // Method kotlin/collections/ArrayDeque.size:()I\n 218: iconst_1\n 219: if_icmpne 226\n 222: iconst_1\n 223: goto 227\n 226: iconst_0\n 227: ifne 250\n 230: iconst_0\n 231: istore 4\n 233: ldc #142 // String Stack should only have root left\n 235: astore 4\n 237: new #22 // class java/lang/IllegalStateException\n 240: dup\n 241: aload 4\n 243: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 246: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 249: athrow\n 250: aload_1\n 251: invokevirtual #92 // Method kotlin/collections/ArrayDeque.first:()Ljava/lang/Object;\n 254: checkcast #57 // class java/util/List\n 257: areturn\n\n private static final int main$compareTo(java.util.List<? extends java.lang.Object>, java.util.List<? extends java.lang.Object>);\n Code:\n 0: aload_0\n 1: ldc #155 // String <this>\n 3: invokestatic #161 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_2\n 8: aload_0\n 9: checkcast #163 // class java/util/Collection\n 12: invokeinterface #164, 1 // InterfaceMethod java/util/Collection.size:()I\n 17: istore_3\n 18: iload_2\n 19: iload_3\n 20: if_icmpge 184\n 23: aload_0\n 24: iload_2\n 25: invokeinterface #168, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 30: astore 4\n 32: iload_2\n 33: aload_1\n 34: invokeinterface #169, 1 // InterfaceMethod java/util/List.size:()I\n 39: if_icmpge 176\n 42: aload_1\n 43: iload_2\n 44: invokeinterface #168, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 49: astore 5\n 51: nop\n 52: aload 4\n 54: instanceof #130 // class java/lang/Integer\n 57: ifeq 98\n 60: aload 5\n 62: instanceof #130 // class java/lang/Integer\n 65: ifeq 98\n 68: aload 4\n 70: aload 5\n 72: invokestatic #173 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 75: ifne 178\n 78: aload 4\n 80: checkcast #175 // class java/lang/Number\n 83: invokevirtual #178 // Method java/lang/Number.intValue:()I\n 86: aload 5\n 88: checkcast #175 // class java/lang/Number\n 91: invokevirtual #178 // Method java/lang/Number.intValue:()I\n 94: invokestatic #182 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 97: ireturn\n 98: aload 4\n 100: instanceof #130 // class java/lang/Integer\n 103: ifeq 114\n 106: aload 4\n 108: invokestatic #188 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 111: goto 126\n 114: aload 4\n 116: ldc #190 // String null cannot be cast to non-null type kotlin.collections.List<kotlin.Any>\n 118: invokestatic #193 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V\n 121: aload 4\n 123: checkcast #57 // class java/util/List\n 126: astore 6\n 128: aload 5\n 130: instanceof #130 // class java/lang/Integer\n 133: ifeq 144\n 136: aload 5\n 138: invokestatic #188 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 141: goto 156\n 144: aload 5\n 146: ldc #190 // String null cannot be cast to non-null type kotlin.collections.List<kotlin.Any>\n 148: invokestatic #193 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V\n 151: aload 5\n 153: checkcast #57 // class java/util/List\n 156: astore 7\n 158: aload 6\n 160: aload 7\n 162: invokestatic #173 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 165: ifne 178\n 168: aload 6\n 170: aload 7\n 172: invokestatic #195 // Method main$compareTo:(Ljava/util/List;Ljava/util/List;)I\n 175: ireturn\n 176: iconst_1\n 177: ireturn\n 178: iinc 2, 1\n 181: goto 18\n 184: iconst_m1\n 185: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #206 // class java/lang/Iterable\n 4: iconst_3\n 5: invokestatic #210 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;\n 8: checkcast #206 // class java/lang/Iterable\n 11: astore_2\n 12: iconst_0\n 13: istore_3\n 14: aload_2\n 15: astore 4\n 17: new #76 // class java/util/ArrayList\n 20: dup\n 21: aload_2\n 22: bipush 10\n 24: invokestatic #214 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 27: invokespecial #216 // Method java/util/ArrayList.\"<init>\":(I)V\n 30: checkcast #163 // class java/util/Collection\n 33: astore 5\n 35: iconst_0\n 36: istore 6\n 38: aload 4\n 40: invokeinterface #220, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 7\n 47: aload 7\n 49: invokeinterface #226, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 123\n 57: aload 7\n 59: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 8\n 66: aload 5\n 68: aload 8\n 70: checkcast #57 // class java/util/List\n 73: astore 9\n 75: astore 15\n 77: iconst_0\n 78: istore 10\n 80: aload 9\n 82: iconst_0\n 83: invokeinterface #168, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 88: checkcast #70 // class java/lang/String\n 91: invokestatic #231 // Method main$parse:(Ljava/lang/String;)Ljava/util/List;\n 94: aload 9\n 96: iconst_1\n 97: invokeinterface #168, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 102: checkcast #70 // class java/lang/String\n 105: invokestatic #231 // Method main$parse:(Ljava/lang/String;)Ljava/util/List;\n 108: invokestatic #237 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 111: aload 15\n 113: swap\n 114: invokeinterface #238, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 119: pop\n 120: goto 47\n 123: aload 5\n 125: checkcast #57 // class java/util/List\n 128: nop\n 129: astore_1\n 130: aload_1\n 131: checkcast #206 // class java/lang/Iterable\n 134: astore_3\n 135: iconst_0\n 136: istore 4\n 138: aload_3\n 139: astore 5\n 141: new #76 // class java/util/ArrayList\n 144: dup\n 145: aload_3\n 146: bipush 10\n 148: invokestatic #214 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 151: invokespecial #216 // Method java/util/ArrayList.\"<init>\":(I)V\n 154: checkcast #163 // class java/util/Collection\n 157: astore 6\n 159: iconst_0\n 160: istore 7\n 162: aload 5\n 164: invokeinterface #220, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 169: astore 8\n 171: aload 8\n 173: invokeinterface #226, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 178: ifeq 238\n 181: aload 8\n 183: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 188: astore 9\n 190: aload 6\n 192: aload 9\n 194: checkcast #240 // class kotlin/Pair\n 197: astore 10\n 199: astore 15\n 201: iconst_0\n 202: istore 11\n 204: aload 10\n 206: invokevirtual #243 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 209: checkcast #57 // class java/util/List\n 212: aload 10\n 214: invokevirtual #246 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 217: checkcast #57 // class java/util/List\n 220: invokestatic #195 // Method main$compareTo:(Ljava/util/List;Ljava/util/List;)I\n 223: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 226: aload 15\n 228: swap\n 229: invokeinterface #238, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 234: pop\n 235: goto 171\n 238: aload 6\n 240: checkcast #57 // class java/util/List\n 243: nop\n 244: astore_2\n 245: aload_2\n 246: checkcast #206 // class java/lang/Iterable\n 249: astore_3\n 250: iconst_0\n 251: istore 4\n 253: iconst_0\n 254: istore 5\n 256: iconst_0\n 257: istore 6\n 259: iload 4\n 261: istore 7\n 263: aload_3\n 264: invokeinterface #220, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 269: astore 8\n 271: aload 8\n 273: invokeinterface #226, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 278: ifeq 348\n 281: aload 8\n 283: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 288: astore 9\n 290: iload 6\n 292: iinc 6, 1\n 295: istore 10\n 297: iload 10\n 299: ifge 305\n 302: invokestatic #249 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 305: iload 10\n 307: iload 7\n 309: aload 9\n 311: checkcast #175 // class java/lang/Number\n 314: invokevirtual #178 // Method java/lang/Number.intValue:()I\n 317: istore 11\n 319: istore 12\n 321: istore 13\n 323: iconst_0\n 324: istore 14\n 326: iload 11\n 328: ifge 341\n 331: iload 12\n 333: iload 13\n 335: iadd\n 336: iconst_1\n 337: iadd\n 338: goto 343\n 341: iload 12\n 343: istore 7\n 345: goto 271\n 348: iload 7\n 350: ireturn\n\n private static final int main$part2$lambda$6(java.util.List, java.util.List);\n Code:\n 0: aload_0\n 1: dup\n 2: invokestatic #276 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 5: aload_1\n 6: dup\n 7: invokestatic #276 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 10: invokestatic #195 // Method main$compareTo:(Ljava/util/List;Ljava/util/List;)I\n 13: ireturn\n\n private static final int main$part2$lambda$7(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 #286, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 8: checkcast #175 // class java/lang/Number\n 11: invokevirtual #178 // Method java/lang/Number.intValue:()I\n 14: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #206 // 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 #76 // class java/util/ArrayList\n 13: dup\n 14: invokespecial #77 // Method java/util/ArrayList.\"<init>\":()V\n 17: checkcast #163 // class java/util/Collection\n 20: astore 5\n 22: iconst_0\n 23: istore 6\n 25: aload 4\n 27: invokeinterface #220, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 32: astore 7\n 34: aload 7\n 36: invokeinterface #226, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 41: ifeq 96\n 44: aload 7\n 46: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 51: astore 8\n 53: aload 8\n 55: checkcast #70 // class java/lang/String\n 58: astore 9\n 60: iconst_0\n 61: istore 10\n 63: aload 9\n 65: checkcast #292 // class java/lang/CharSequence\n 68: invokestatic #298 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 71: ifne 78\n 74: iconst_1\n 75: goto 79\n 78: iconst_0\n 79: nop\n 80: ifeq 34\n 83: aload 5\n 85: aload 8\n 87: invokeinterface #238, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 92: pop\n 93: goto 34\n 96: aload 5\n 98: checkcast #57 // class java/util/List\n 101: nop\n 102: checkcast #206 // class java/lang/Iterable\n 105: astore_2\n 106: nop\n 107: iconst_0\n 108: istore_3\n 109: aload_2\n 110: astore 4\n 112: new #76 // class java/util/ArrayList\n 115: dup\n 116: aload_2\n 117: bipush 10\n 119: invokestatic #214 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 122: invokespecial #216 // Method java/util/ArrayList.\"<init>\":(I)V\n 125: checkcast #163 // class java/util/Collection\n 128: astore 5\n 130: iconst_0\n 131: istore 6\n 133: aload 4\n 135: invokeinterface #220, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 140: astore 7\n 142: aload 7\n 144: invokeinterface #226, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 149: ifeq 192\n 152: aload 7\n 154: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 159: astore 8\n 161: aload 5\n 163: aload 8\n 165: checkcast #70 // class java/lang/String\n 168: astore 9\n 170: astore 13\n 172: iconst_0\n 173: istore 10\n 175: aload 9\n 177: invokestatic #231 // Method main$parse:(Ljava/lang/String;)Ljava/util/List;\n 180: aload 13\n 182: swap\n 183: invokeinterface #238, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 188: pop\n 189: goto 142\n 192: aload 5\n 194: checkcast #57 // class java/util/List\n 197: nop\n 198: checkcast #163 // class java/util/Collection\n 201: getstatic #105 // Field Day13.INSTANCE:LDay13;\n 204: invokevirtual #301 // Method Day13.getDIVIDER_PACKETS:()Ljava/util/List;\n 207: checkcast #206 // class java/lang/Iterable\n 210: invokestatic #305 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 213: astore_1\n 214: aload_1\n 215: checkcast #206 // class java/lang/Iterable\n 218: invokedynamic #321, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;\n 223: invokedynamic #329, 0 // InvokeDynamic #1:compare:(Lkotlin/jvm/functions/Function2;)Ljava/util/Comparator;\n 228: invokestatic #333 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 231: astore_2\n 232: getstatic #105 // Field Day13.INSTANCE:LDay13;\n 235: invokevirtual #301 // Method Day13.getDIVIDER_PACKETS:()Ljava/util/List;\n 238: checkcast #206 // class java/lang/Iterable\n 241: astore 4\n 243: iconst_0\n 244: istore 5\n 246: aload 4\n 248: astore 6\n 250: new #76 // class java/util/ArrayList\n 253: dup\n 254: aload 4\n 256: bipush 10\n 258: invokestatic #214 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 261: invokespecial #216 // Method java/util/ArrayList.\"<init>\":(I)V\n 264: checkcast #163 // class java/util/Collection\n 267: astore 7\n 269: iconst_0\n 270: istore 8\n 272: aload 6\n 274: invokeinterface #220, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 279: astore 9\n 281: aload 9\n 283: invokeinterface #226, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 288: ifeq 339\n 291: aload 9\n 293: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 298: astore 10\n 300: aload 7\n 302: aload 10\n 304: checkcast #57 // class java/util/List\n 307: astore 11\n 309: astore 13\n 311: iconst_0\n 312: istore 12\n 314: aload_2\n 315: aload 11\n 317: invokeinterface #337, 2 // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I\n 322: iconst_1\n 323: iadd\n 324: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 327: aload 13\n 329: swap\n 330: invokeinterface #238, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 335: pop\n 336: goto 281\n 339: aload 7\n 341: checkcast #57 // class java/util/List\n 344: nop\n 345: checkcast #206 // class java/lang/Iterable\n 348: astore 4\n 350: nop\n 351: iconst_0\n 352: istore 5\n 354: aload 4\n 356: invokeinterface #220, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 361: astore 6\n 363: aload 6\n 365: invokeinterface #226, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 370: ifne 384\n 373: new #339 // class java/lang/UnsupportedOperationException\n 376: dup\n 377: ldc_w #341 // String Empty collection can\\'t be reduced.\n 380: invokespecial #342 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 383: athrow\n 384: aload 6\n 386: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 391: astore 7\n 393: aload 6\n 395: invokeinterface #226, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 400: ifeq 444\n 403: aload 7\n 405: aload 6\n 407: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 412: checkcast #175 // class java/lang/Number\n 415: invokevirtual #178 // Method java/lang/Number.intValue:()I\n 418: istore 8\n 420: checkcast #175 // class java/lang/Number\n 423: invokevirtual #178 // Method java/lang/Number.intValue:()I\n 426: istore 9\n 428: iconst_0\n 429: istore 10\n 431: iload 9\n 433: iload 8\n 435: imul\n 436: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 439: astore 7\n 441: goto 393\n 444: aload 7\n 446: checkcast #175 // class java/lang/Number\n 449: invokevirtual #178 // Method java/lang/Number.intValue:()I\n 452: istore_3\n 453: iload_3\n 454: ireturn\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day08.kt
|
object Day08 {
const val EXPECTED_PART1_CHECK_ANSWER = 21
const val EXPECTED_PART2_CHECK_ANSWER = 8
}
fun main() {
fun List<String>.parseTreeGrid(): List<List<Int>> =
this.map { it.toList() }.map { it.map { chr -> chr.digitToInt() } }
fun List<List<Int>>.isVisible(x: Int, y: Int): Boolean {
if (x == 0 || y == 0 || x == this[0].size - 1 || y == this.size - 1) return true
val heightOfTree = this[y][x]
if (this[y].subList(0, x).all { it < heightOfTree }) return true
if (this[y].subList(x + 1, this[y].size).all { it < heightOfTree }) return true
val treesInSameVerticalRow = this.fold(emptyList<Int>()) { acc, row -> acc + row[x] }
if (treesInSameVerticalRow.subList(0, y).all { it < heightOfTree }) return true
if (treesInSameVerticalRow.subList(y + 1, treesInSameVerticalRow.size).all { it < heightOfTree }) return true
return false
}
fun List<List<Int>>.scenicScore(x: Int, y: Int): Int {
val heightOfTree = this[y][x]
val treesToTheLeft = this[y].subList(0, x)
val leftTreesVisible = treesToTheLeft
.takeLastWhile { it < heightOfTree }.size
.let { if (it == treesToTheLeft.size) it else it + 1 } // accommodate for edges
val treesToTheRight = this[y].subList(x + 1, this[y].size)
val rightTreesVisible = treesToTheRight
.takeWhile { it < heightOfTree }.size
.let { if (it == treesToTheRight.size) it else it + 1 } // accommodate for edges
val treesInSameVerticalRow = this.fold(emptyList<Int>()) { acc, row -> acc + row[x] }
val treesToTheTop = treesInSameVerticalRow.subList(0, y)
val upTreesVisible = treesToTheTop
.takeLastWhile { it < heightOfTree }.size
.let { if (it == treesToTheTop.size) it else it + 1 } // accommodate for edge
val treesToTheBottom = treesInSameVerticalRow.subList(y + 1, treesInSameVerticalRow.size)
val downTreesVisible = treesToTheBottom
.takeWhile { it < heightOfTree }.size
.let { if (it == treesToTheBottom.size) it else it + 1 } // accommodate for edge
return leftTreesVisible * rightTreesVisible * upTreesVisible * downTreesVisible
}
fun part1(input: List<String>): Int {
val treeGrid = input.parseTreeGrid()
var treesVisible = 0
for (xIndex in treeGrid[0].indices) {
for (yIndex in treeGrid.indices) {
if (treeGrid.isVisible(xIndex, yIndex)) {
treesVisible++
}
}
}
return treesVisible
}
fun part2(input: List<String>): Int {
val treeGrid = input.parseTreeGrid()
var highestScenicScore = 0
for (xIndex in treeGrid[0].indices) {
for (yIndex in treeGrid.indices) {
val scenicScore = treeGrid.scenicScore(xIndex, yIndex)
highestScenicScore = maxOf(scenicScore, highestScenicScore)
}
}
return highestScenicScore
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day08_test")
check(part1(testInput) == Day08.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
check(part2(testInput) == Day08.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }
val input = readInput("Day08")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day08.class",
"javap": "Compiled from \"Day08.kt\"\npublic final class Day08 {\n public static final Day08 INSTANCE;\n\n public static final int EXPECTED_PART1_CHECK_ANSWER;\n\n public static final int EXPECTED_PART2_CHECK_ANSWER;\n\n private Day08();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n static {};\n Code:\n 0: new #2 // class Day08\n 3: dup\n 4: invokespecial #12 // Method \"<init>\":()V\n 7: putstatic #15 // Field INSTANCE:LDay08;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day08Kt.class",
"javap": "Compiled from \"Day08.kt\"\npublic final class Day08Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day08_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 10: bipush 21\n 12: if_icmpne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 40\n 23: iconst_0\n 24: istore_2\n 25: ldc #20 // String Part 1 failed\n 27: astore_2\n 28: new #22 // class java/lang/IllegalStateException\n 31: dup\n 32: aload_2\n 33: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 36: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 39: athrow\n 40: aload_0\n 41: invokestatic #33 // Method main$part2:(Ljava/util/List;)I\n 44: bipush 8\n 46: if_icmpne 53\n 49: iconst_1\n 50: goto 54\n 53: iconst_0\n 54: ifne 74\n 57: iconst_0\n 58: istore_2\n 59: ldc #35 // String Part 2 failed\n 61: astore_2\n 62: new #22 // class java/lang/IllegalStateException\n 65: dup\n 66: aload_2\n 67: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 70: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 73: athrow\n 74: ldc #37 // String Day08\n 76: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 79: astore_1\n 80: aload_1\n 81: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 84: istore_2\n 85: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 88: iload_2\n 89: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 92: aload_1\n 93: invokestatic #33 // Method main$part2:(Ljava/util/List;)I\n 96: istore_2\n 97: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 100: iload_2\n 101: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 104: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #60 // Method main:()V\n 3: return\n\n private static final java.util.List<java.util.List<java.lang.Integer>> main$parseTreeGrid(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #67 // 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 #69 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #75 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #79 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 91\n 48: aload 6\n 50: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #95 // 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 #97 // class java/lang/CharSequence\n 76: invokestatic #103 // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;\n 79: aload 20\n 81: swap\n 82: invokeinterface #107, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 87: pop\n 88: goto 38\n 91: aload 4\n 93: checkcast #57 // class java/util/List\n 96: nop\n 97: checkcast #67 // 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 #69 // class java/util/ArrayList\n 109: dup\n 110: aload_1\n 111: bipush 10\n 113: invokestatic #75 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 116: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 119: checkcast #79 // class java/util/Collection\n 122: astore 4\n 124: iconst_0\n 125: istore 5\n 127: aload_3\n 128: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 133: astore 6\n 135: aload 6\n 137: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 142: ifeq 288\n 145: aload 6\n 147: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 152: astore 7\n 154: aload 4\n 156: aload 7\n 158: checkcast #57 // class java/util/List\n 161: astore 8\n 163: astore 20\n 165: iconst_0\n 166: istore 9\n 168: aload 8\n 170: checkcast #67 // class java/lang/Iterable\n 173: astore 10\n 175: iconst_0\n 176: istore 11\n 178: aload 10\n 180: astore 12\n 182: new #69 // class java/util/ArrayList\n 185: dup\n 186: aload 10\n 188: bipush 10\n 190: invokestatic #75 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 193: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 196: checkcast #79 // class java/util/Collection\n 199: astore 13\n 201: iconst_0\n 202: istore 14\n 204: aload 12\n 206: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 211: astore 15\n 213: aload 15\n 215: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 220: ifeq 269\n 223: aload 15\n 225: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 230: astore 16\n 232: aload 13\n 234: aload 16\n 236: checkcast #109 // class java/lang/Character\n 239: invokevirtual #113 // Method java/lang/Character.charValue:()C\n 242: istore 17\n 244: astore 18\n 246: iconst_0\n 247: istore 19\n 249: iload 17\n 251: invokestatic #119 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 254: invokestatic #125 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 257: aload 18\n 259: swap\n 260: invokeinterface #107, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 265: pop\n 266: goto 213\n 269: aload 13\n 271: checkcast #57 // class java/util/List\n 274: nop\n 275: nop\n 276: aload 20\n 278: swap\n 279: invokeinterface #107, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 284: pop\n 285: goto 135\n 288: aload 4\n 290: checkcast #57 // class java/util/List\n 293: nop\n 294: areturn\n\n private static final boolean main$isVisible(java.util.List<? extends java.util.List<java.lang.Integer>>, int, int);\n Code:\n 0: iload_1\n 1: ifeq 41\n 4: iload_2\n 5: ifeq 41\n 8: iload_1\n 9: aload_0\n 10: iconst_0\n 11: invokeinterface #149, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 16: checkcast #57 // class java/util/List\n 19: invokeinterface #153, 1 // InterfaceMethod java/util/List.size:()I\n 24: iconst_1\n 25: isub\n 26: if_icmpeq 41\n 29: iload_2\n 30: aload_0\n 31: invokeinterface #153, 1 // InterfaceMethod java/util/List.size:()I\n 36: iconst_1\n 37: isub\n 38: if_icmpne 43\n 41: iconst_1\n 42: ireturn\n 43: aload_0\n 44: iload_2\n 45: invokeinterface #149, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 50: checkcast #57 // class java/util/List\n 53: iload_1\n 54: invokeinterface #149, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 59: checkcast #155 // class java/lang/Number\n 62: invokevirtual #158 // Method java/lang/Number.intValue:()I\n 65: istore_3\n 66: aload_0\n 67: iload_2\n 68: invokeinterface #149, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 73: checkcast #57 // class java/util/List\n 76: iconst_0\n 77: iload_1\n 78: invokeinterface #162, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 83: checkcast #67 // class java/lang/Iterable\n 86: astore 4\n 88: iconst_0\n 89: istore 5\n 91: aload 4\n 93: instanceof #79 // class java/util/Collection\n 96: ifeq 116\n 99: aload 4\n 101: checkcast #79 // class java/util/Collection\n 104: invokeinterface #165, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 109: ifeq 116\n 112: iconst_1\n 113: goto 176\n 116: aload 4\n 118: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 123: astore 6\n 125: aload 6\n 127: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 132: ifeq 175\n 135: aload 6\n 137: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 142: astore 7\n 144: aload 7\n 146: checkcast #155 // class java/lang/Number\n 149: invokevirtual #158 // Method java/lang/Number.intValue:()I\n 152: istore 8\n 154: iconst_0\n 155: istore 9\n 157: iload 8\n 159: iload_3\n 160: if_icmpge 167\n 163: iconst_1\n 164: goto 168\n 167: iconst_0\n 168: ifne 125\n 171: iconst_0\n 172: goto 176\n 175: iconst_1\n 176: ifeq 181\n 179: iconst_1\n 180: ireturn\n 181: aload_0\n 182: iload_2\n 183: invokeinterface #149, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 188: checkcast #57 // class java/util/List\n 191: iload_1\n 192: iconst_1\n 193: iadd\n 194: aload_0\n 195: iload_2\n 196: invokeinterface #149, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 201: checkcast #57 // class java/util/List\n 204: invokeinterface #153, 1 // InterfaceMethod java/util/List.size:()I\n 209: invokeinterface #162, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 214: checkcast #67 // class java/lang/Iterable\n 217: astore 4\n 219: iconst_0\n 220: istore 5\n 222: aload 4\n 224: instanceof #79 // class java/util/Collection\n 227: ifeq 247\n 230: aload 4\n 232: checkcast #79 // class java/util/Collection\n 235: invokeinterface #165, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 240: ifeq 247\n 243: iconst_1\n 244: goto 307\n 247: aload 4\n 249: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 254: astore 6\n 256: aload 6\n 258: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 263: ifeq 306\n 266: aload 6\n 268: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 273: astore 7\n 275: aload 7\n 277: checkcast #155 // class java/lang/Number\n 280: invokevirtual #158 // Method java/lang/Number.intValue:()I\n 283: istore 8\n 285: iconst_0\n 286: istore 9\n 288: iload 8\n 290: iload_3\n 291: if_icmpge 298\n 294: iconst_1\n 295: goto 299\n 298: iconst_0\n 299: ifne 256\n 302: iconst_0\n 303: goto 307\n 306: iconst_1\n 307: ifeq 312\n 310: iconst_1\n 311: ireturn\n 312: aload_0\n 313: checkcast #67 // class java/lang/Iterable\n 316: astore 5\n 318: invokestatic #169 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 321: astore 6\n 323: iconst_0\n 324: istore 7\n 326: aload 6\n 328: astore 8\n 330: aload 5\n 332: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 337: astore 9\n 339: aload 9\n 341: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 346: ifeq 393\n 349: aload 9\n 351: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 356: astore 10\n 358: aload 8\n 360: aload 10\n 362: checkcast #57 // class java/util/List\n 365: astore 11\n 367: astore 12\n 369: iconst_0\n 370: istore 13\n 372: aload 12\n 374: checkcast #79 // class java/util/Collection\n 377: aload 11\n 379: iload_1\n 380: invokeinterface #149, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 385: invokestatic #173 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 388: astore 8\n 390: goto 339\n 393: aload 8\n 395: astore 4\n 397: aload 4\n 399: iconst_0\n 400: iload_2\n 401: invokeinterface #162, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 406: checkcast #67 // class java/lang/Iterable\n 409: astore 5\n 411: iconst_0\n 412: istore 6\n 414: aload 5\n 416: instanceof #79 // class java/util/Collection\n 419: ifeq 439\n 422: aload 5\n 424: checkcast #79 // class java/util/Collection\n 427: invokeinterface #165, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 432: ifeq 439\n 435: iconst_1\n 436: goto 499\n 439: aload 5\n 441: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 446: astore 7\n 448: aload 7\n 450: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 455: ifeq 498\n 458: aload 7\n 460: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 465: astore 8\n 467: aload 8\n 469: checkcast #155 // class java/lang/Number\n 472: invokevirtual #158 // Method java/lang/Number.intValue:()I\n 475: istore 9\n 477: iconst_0\n 478: istore 10\n 480: iload 9\n 482: iload_3\n 483: if_icmpge 490\n 486: iconst_1\n 487: goto 491\n 490: iconst_0\n 491: ifne 448\n 494: iconst_0\n 495: goto 499\n 498: iconst_1\n 499: ifeq 504\n 502: iconst_1\n 503: ireturn\n 504: aload 4\n 506: iload_2\n 507: iconst_1\n 508: iadd\n 509: aload 4\n 511: invokeinterface #153, 1 // InterfaceMethod java/util/List.size:()I\n 516: invokeinterface #162, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 521: checkcast #67 // class java/lang/Iterable\n 524: astore 5\n 526: iconst_0\n 527: istore 6\n 529: aload 5\n 531: instanceof #79 // class java/util/Collection\n 534: ifeq 554\n 537: aload 5\n 539: checkcast #79 // class java/util/Collection\n 542: invokeinterface #165, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 547: ifeq 554\n 550: iconst_1\n 551: goto 614\n 554: aload 5\n 556: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 561: astore 7\n 563: aload 7\n 565: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 570: ifeq 613\n 573: aload 7\n 575: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 580: astore 8\n 582: aload 8\n 584: checkcast #155 // class java/lang/Number\n 587: invokevirtual #158 // Method java/lang/Number.intValue:()I\n 590: istore 9\n 592: iconst_0\n 593: istore 10\n 595: iload 9\n 597: iload_3\n 598: if_icmpge 605\n 601: iconst_1\n 602: goto 606\n 605: iconst_0\n 606: ifne 563\n 609: iconst_0\n 610: goto 614\n 613: iconst_1\n 614: ifeq 619\n 617: iconst_1\n 618: ireturn\n 619: iconst_0\n 620: ireturn\n\n private static final int main$scenicScore(java.util.List<? extends java.util.List<java.lang.Integer>>, int, int);\n Code:\n 0: aload_0\n 1: iload_2\n 2: invokeinterface #149, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #57 // class java/util/List\n 10: iload_1\n 11: invokeinterface #149, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 16: checkcast #155 // class java/lang/Number\n 19: invokevirtual #158 // Method java/lang/Number.intValue:()I\n 22: istore_3\n 23: aload_0\n 24: iload_2\n 25: invokeinterface #149, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 30: checkcast #57 // class java/util/List\n 33: iconst_0\n 34: iload_1\n 35: invokeinterface #162, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 40: astore 4\n 42: aload 4\n 44: astore 6\n 46: nop\n 47: iconst_0\n 48: istore 7\n 50: aload 6\n 52: invokeinterface #196, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 57: ifeq 66\n 60: invokestatic #169 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 63: goto 221\n 66: aload 6\n 68: aload 6\n 70: invokeinterface #153, 1 // InterfaceMethod java/util/List.size:()I\n 75: invokeinterface #200, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 80: astore 8\n 82: aload 8\n 84: invokeinterface #205, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 89: ifeq 213\n 92: aload 8\n 94: invokeinterface #208, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 99: checkcast #155 // class java/lang/Number\n 102: invokevirtual #158 // Method java/lang/Number.intValue:()I\n 105: istore 9\n 107: iconst_0\n 108: istore 10\n 110: iload 9\n 112: iload_3\n 113: if_icmpge 120\n 116: iconst_1\n 117: goto 121\n 120: iconst_0\n 121: ifne 82\n 124: aload 8\n 126: invokeinterface #209, 1 // InterfaceMethod java/util/ListIterator.next:()Ljava/lang/Object;\n 131: pop\n 132: aload 6\n 134: invokeinterface #153, 1 // InterfaceMethod java/util/List.size:()I\n 139: aload 8\n 141: invokeinterface #212, 1 // InterfaceMethod java/util/ListIterator.nextIndex:()I\n 146: isub\n 147: istore 11\n 149: iload 11\n 151: ifne 160\n 154: invokestatic #169 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 157: goto 221\n 160: new #69 // class java/util/ArrayList\n 163: dup\n 164: iload 11\n 166: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 169: astore 12\n 171: aload 12\n 173: astore 13\n 175: iconst_0\n 176: istore 14\n 178: aload 8\n 180: invokeinterface #213, 1 // InterfaceMethod java/util/ListIterator.hasNext:()Z\n 185: ifeq 204\n 188: aload 13\n 190: aload 8\n 192: invokeinterface #209, 1 // InterfaceMethod java/util/ListIterator.next:()Ljava/lang/Object;\n 197: invokevirtual #214 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 200: pop\n 201: goto 178\n 204: nop\n 205: aload 12\n 207: checkcast #57 // class java/util/List\n 210: goto 221\n 213: aload 6\n 215: checkcast #67 // class java/lang/Iterable\n 218: invokestatic #217 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 221: invokeinterface #153, 1 // InterfaceMethod java/util/List.size:()I\n 226: istore 7\n 228: iconst_0\n 229: istore 8\n 231: iload 7\n 233: aload 4\n 235: invokeinterface #153, 1 // InterfaceMethod java/util/List.size:()I\n 240: if_icmpne 248\n 243: iload 7\n 245: goto 252\n 248: iload 7\n 250: iconst_1\n 251: iadd\n 252: nop\n 253: istore 5\n 255: aload_0\n 256: iload_2\n 257: invokeinterface #149, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 262: checkcast #57 // class java/util/List\n 265: iload_1\n 266: iconst_1\n 267: iadd\n 268: aload_0\n 269: iload_2\n 270: invokeinterface #149, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 275: checkcast #57 // class java/util/List\n 278: invokeinterface #153, 1 // InterfaceMethod java/util/List.size:()I\n 283: invokeinterface #162, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 288: astore 6\n 290: aload 6\n 292: checkcast #67 // class java/lang/Iterable\n 295: astore 8\n 297: nop\n 298: iconst_0\n 299: istore 9\n 301: new #69 // class java/util/ArrayList\n 304: dup\n 305: invokespecial #219 // Method java/util/ArrayList.\"<init>\":()V\n 308: astore 10\n 310: aload 8\n 312: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 317: astore 11\n 319: aload 11\n 321: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 326: ifeq 379\n 329: aload 11\n 331: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 336: astore 12\n 338: aload 12\n 340: checkcast #155 // class java/lang/Number\n 343: invokevirtual #158 // Method java/lang/Number.intValue:()I\n 346: istore 13\n 348: iconst_0\n 349: istore 14\n 351: iload 13\n 353: iload_3\n 354: if_icmpge 361\n 357: iconst_1\n 358: goto 362\n 361: iconst_0\n 362: ifne 368\n 365: goto 379\n 368: aload 10\n 370: aload 12\n 372: invokevirtual #214 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 375: pop\n 376: goto 319\n 379: aload 10\n 381: checkcast #57 // class java/util/List\n 384: invokeinterface #153, 1 // InterfaceMethod java/util/List.size:()I\n 389: istore 9\n 391: iconst_0\n 392: istore 10\n 394: iload 9\n 396: aload 6\n 398: invokeinterface #153, 1 // InterfaceMethod java/util/List.size:()I\n 403: if_icmpne 411\n 406: iload 9\n 408: goto 415\n 411: iload 9\n 413: iconst_1\n 414: iadd\n 415: nop\n 416: istore 7\n 418: aload_0\n 419: checkcast #67 // class java/lang/Iterable\n 422: astore 9\n 424: invokestatic #169 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 427: astore 10\n 429: iconst_0\n 430: istore 11\n 432: aload 10\n 434: astore 12\n 436: aload 9\n 438: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 443: astore 13\n 445: aload 13\n 447: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 452: ifeq 499\n 455: aload 13\n 457: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 462: astore 14\n 464: aload 12\n 466: aload 14\n 468: checkcast #57 // class java/util/List\n 471: astore 15\n 473: astore 16\n 475: iconst_0\n 476: istore 17\n 478: aload 16\n 480: checkcast #79 // class java/util/Collection\n 483: aload 15\n 485: iload_1\n 486: invokeinterface #149, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 491: invokestatic #173 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 494: astore 12\n 496: goto 445\n 499: aload 12\n 501: astore 8\n 503: aload 8\n 505: iconst_0\n 506: iload_2\n 507: invokeinterface #162, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 512: astore 9\n 514: aload 9\n 516: astore 11\n 518: nop\n 519: iconst_0\n 520: istore 12\n 522: aload 11\n 524: invokeinterface #196, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 529: ifeq 538\n 532: invokestatic #169 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 535: goto 693\n 538: aload 11\n 540: aload 11\n 542: invokeinterface #153, 1 // InterfaceMethod java/util/List.size:()I\n 547: invokeinterface #200, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 552: astore 13\n 554: aload 13\n 556: invokeinterface #205, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 561: ifeq 685\n 564: aload 13\n 566: invokeinterface #208, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 571: checkcast #155 // class java/lang/Number\n 574: invokevirtual #158 // Method java/lang/Number.intValue:()I\n 577: istore 14\n 579: iconst_0\n 580: istore 15\n 582: iload 14\n 584: iload_3\n 585: if_icmpge 592\n 588: iconst_1\n 589: goto 593\n 592: iconst_0\n 593: ifne 554\n 596: aload 13\n 598: invokeinterface #209, 1 // InterfaceMethod java/util/ListIterator.next:()Ljava/lang/Object;\n 603: pop\n 604: aload 11\n 606: invokeinterface #153, 1 // InterfaceMethod java/util/List.size:()I\n 611: aload 13\n 613: invokeinterface #212, 1 // InterfaceMethod java/util/ListIterator.nextIndex:()I\n 618: isub\n 619: istore 16\n 621: iload 16\n 623: ifne 632\n 626: invokestatic #169 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 629: goto 693\n 632: new #69 // class java/util/ArrayList\n 635: dup\n 636: iload 16\n 638: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 641: astore 17\n 643: aload 17\n 645: astore 18\n 647: iconst_0\n 648: istore 19\n 650: aload 13\n 652: invokeinterface #213, 1 // InterfaceMethod java/util/ListIterator.hasNext:()Z\n 657: ifeq 676\n 660: aload 18\n 662: aload 13\n 664: invokeinterface #209, 1 // InterfaceMethod java/util/ListIterator.next:()Ljava/lang/Object;\n 669: invokevirtual #214 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 672: pop\n 673: goto 650\n 676: nop\n 677: aload 17\n 679: checkcast #57 // class java/util/List\n 682: goto 693\n 685: aload 11\n 687: checkcast #67 // class java/lang/Iterable\n 690: invokestatic #217 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 693: invokeinterface #153, 1 // InterfaceMethod java/util/List.size:()I\n 698: istore 12\n 700: iconst_0\n 701: istore 13\n 703: iload 12\n 705: aload 9\n 707: invokeinterface #153, 1 // InterfaceMethod java/util/List.size:()I\n 712: if_icmpne 720\n 715: iload 12\n 717: goto 724\n 720: iload 12\n 722: iconst_1\n 723: iadd\n 724: nop\n 725: istore 10\n 727: aload 8\n 729: iload_2\n 730: iconst_1\n 731: iadd\n 732: aload 8\n 734: invokeinterface #153, 1 // InterfaceMethod java/util/List.size:()I\n 739: invokeinterface #162, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 744: astore 11\n 746: aload 11\n 748: checkcast #67 // class java/lang/Iterable\n 751: astore 13\n 753: nop\n 754: iconst_0\n 755: istore 14\n 757: new #69 // class java/util/ArrayList\n 760: dup\n 761: invokespecial #219 // Method java/util/ArrayList.\"<init>\":()V\n 764: astore 15\n 766: aload 13\n 768: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 773: astore 16\n 775: aload 16\n 777: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 782: ifeq 835\n 785: aload 16\n 787: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 792: astore 17\n 794: aload 17\n 796: checkcast #155 // class java/lang/Number\n 799: invokevirtual #158 // Method java/lang/Number.intValue:()I\n 802: istore 18\n 804: iconst_0\n 805: istore 19\n 807: iload 18\n 809: iload_3\n 810: if_icmpge 817\n 813: iconst_1\n 814: goto 818\n 817: iconst_0\n 818: ifne 824\n 821: goto 835\n 824: aload 15\n 826: aload 17\n 828: invokevirtual #214 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 831: pop\n 832: goto 775\n 835: aload 15\n 837: checkcast #57 // class java/util/List\n 840: invokeinterface #153, 1 // InterfaceMethod java/util/List.size:()I\n 845: istore 14\n 847: iconst_0\n 848: istore 15\n 850: iload 14\n 852: aload 11\n 854: invokeinterface #153, 1 // InterfaceMethod java/util/List.size:()I\n 859: if_icmpne 867\n 862: iload 14\n 864: goto 871\n 867: iload 14\n 869: iconst_1\n 870: iadd\n 871: nop\n 872: istore 12\n 874: iload 5\n 876: iload 7\n 878: imul\n 879: iload 10\n 881: imul\n 882: iload 12\n 884: imul\n 885: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #252 // Method main$parseTreeGrid:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: iconst_0\n 8: istore_3\n 9: aload_1\n 10: iconst_0\n 11: invokeinterface #149, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 16: checkcast #79 // class java/util/Collection\n 19: invokeinterface #253, 1 // InterfaceMethod java/util/Collection.size:()I\n 24: istore 4\n 26: iload_3\n 27: iload 4\n 29: if_icmpge 78\n 32: iconst_0\n 33: istore 5\n 35: aload_1\n 36: checkcast #79 // class java/util/Collection\n 39: invokeinterface #253, 1 // InterfaceMethod java/util/Collection.size:()I\n 44: istore 6\n 46: iload 5\n 48: iload 6\n 50: if_icmpge 72\n 53: aload_1\n 54: iload_3\n 55: iload 5\n 57: invokestatic #255 // Method main$isVisible:(Ljava/util/List;II)Z\n 60: ifeq 66\n 63: iinc 2, 1\n 66: iinc 5, 1\n 69: goto 46\n 72: iinc 3, 1\n 75: goto 26\n 78: iload_2\n 79: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #252 // Method main$parseTreeGrid:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: iconst_0\n 8: istore_3\n 9: aload_1\n 10: iconst_0\n 11: invokeinterface #149, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 16: checkcast #79 // class java/util/Collection\n 19: invokeinterface #253, 1 // InterfaceMethod java/util/Collection.size:()I\n 24: istore 4\n 26: iload_3\n 27: iload 4\n 29: if_icmpge 81\n 32: iconst_0\n 33: istore 5\n 35: aload_1\n 36: checkcast #79 // class java/util/Collection\n 39: invokeinterface #253, 1 // InterfaceMethod java/util/Collection.size:()I\n 44: istore 6\n 46: iload 5\n 48: iload 6\n 50: if_icmpge 75\n 53: aload_1\n 54: iload_3\n 55: iload 5\n 57: invokestatic #261 // Method main$scenicScore:(Ljava/util/List;II)I\n 60: istore 7\n 62: iload 7\n 64: iload_2\n 65: invokestatic #267 // Method java/lang/Math.max:(II)I\n 68: istore_2\n 69: iinc 5, 1\n 72: goto 46\n 75: iinc 3, 1\n 78: goto 26\n 81: iload_2\n 82: ireturn\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day05.kt
|
object Day05 {
const val dayNumber = "05"
const val EXPECTED_PART1_CHECK_ANSWER = "CMZ"
const val EXPECTED_PART2_CHECK_ANSWER = "MCD"
const val STACK_SETUP_ENTRY_WITH_SPACE_SIZE = 4
const val STACK_SETUP_ENTRY_SIZE = 3
}
fun main() {
fun List<String>.parseStackSetup(): List<MutableList<Char>> {
val stacks = mutableListOf<MutableList<Char>>()
for (lineIdx in this.size - 2 downTo 0) {
val line = this[lineIdx]
var stackIndex = 0
var stackEntryStartPosition = 0
while (stackEntryStartPosition < line.length) {
if (stacks.size < stackIndex + 1) {
stacks += mutableListOf<Char>()
}
val stackEntry = line.substring(
stackEntryStartPosition until (stackEntryStartPosition + Day05.STACK_SETUP_ENTRY_SIZE)
)
if (stackEntry.isNotBlank()) {
stacks[stackIndex].add(stackEntry[1])
}
stackIndex++
stackEntryStartPosition = stackIndex * Day05.STACK_SETUP_ENTRY_WITH_SPACE_SIZE
}
}
return stacks
}
fun parseAndApplyMoves(
input: List<String>,
applyMove: (stacks: List<MutableList<Char>>, move: Triple<Int, Int, Int>) -> Unit
): String {
val indexOfEmptyLine = input.indexOf("")
val stackSetup = input.subList(0, indexOfEmptyLine).parseStackSetup()
val moves = input.subList(indexOfEmptyLine + 1, input.size)
val moveTemplate = Regex("move (\\d+) from (\\d+) to (\\d+)")
moves.forEach { move ->
moveTemplate.matchEntire(move)?.apply {
val (amount, from, to) = this.destructured
applyMove(stackSetup, Triple(amount.toInt(), from.toInt(), to.toInt()))
}
}
return stackSetup.map { stack -> stack.last() }.joinToString(separator = "")
}
fun part1(input: List<String>): String {
return parseAndApplyMoves(input) { stacks, (amount, from, to) ->
repeat(amount) { _ ->
val toMove = stacks[from - 1].removeLast()
stacks[to - 1].add(toMove)
}
}
}
fun part2(input: List<String>): String {
return parseAndApplyMoves(input) { stacks, (amount, from, to) ->
val removedChars = (1..amount).map { _ -> stacks[from - 1].removeLast() }
stacks[to - 1].addAll(removedChars.reversed())
}
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day${Day05.dayNumber}_test")
check(part1(testInput) == Day05.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
check(part2(testInput) == Day05.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }
val input = readInput("Day${Day05.dayNumber}")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/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 #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method main$part1:(Ljava/util/List;)Ljava/lang/String;\n 10: ldc #20 // String CMZ\n 12: invokestatic #26 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 15: ifne 35\n 18: iconst_0\n 19: istore_2\n 20: ldc #28 // String Part 1 failed\n 22: astore_2\n 23: new #30 // class java/lang/IllegalStateException\n 26: dup\n 27: aload_2\n 28: invokevirtual #34 // Method java/lang/Object.toString:()Ljava/lang/String;\n 31: invokespecial #38 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 34: athrow\n 35: aload_0\n 36: invokestatic #41 // Method main$part2:(Ljava/util/List;)Ljava/lang/String;\n 39: ldc #43 // String MCD\n 41: invokestatic #26 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 44: ifne 64\n 47: iconst_0\n 48: istore_2\n 49: ldc #45 // String Part 2 failed\n 51: astore_2\n 52: new #30 // class java/lang/IllegalStateException\n 55: dup\n 56: aload_2\n 57: invokevirtual #34 // Method java/lang/Object.toString:()Ljava/lang/String;\n 60: invokespecial #38 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 63: athrow\n 64: ldc #47 // String Day05\n 66: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 69: astore_1\n 70: aload_1\n 71: invokestatic #18 // Method main$part1:(Ljava/util/List;)Ljava/lang/String;\n 74: getstatic #53 // Field java/lang/System.out:Ljava/io/PrintStream;\n 77: swap\n 78: invokevirtual #59 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 81: aload_1\n 82: invokestatic #41 // Method main$part2:(Ljava/util/List;)Ljava/lang/String;\n 85: getstatic #53 // Field java/lang/System.out:Ljava/io/PrintStream;\n 88: swap\n 89: invokevirtual #59 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 92: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #70 // Method main:()V\n 3: return\n\n private static final java.util.List<java.util.List<java.lang.Character>> main$parseStackSetup(java.util.List<java.lang.String>);\n Code:\n 0: new #77 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #79 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #67 // class java/util/List\n 10: astore_1\n 11: aload_0\n 12: invokeinterface #83, 1 // InterfaceMethod java/util/List.size:()I\n 17: iconst_2\n 18: isub\n 19: istore_2\n 20: iconst_m1\n 21: iload_2\n 22: if_icmpge 163\n 25: aload_0\n 26: iload_2\n 27: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 32: checkcast #89 // class java/lang/String\n 35: astore_3\n 36: iconst_0\n 37: istore 4\n 39: iconst_0\n 40: istore 5\n 42: iload 5\n 44: aload_3\n 45: invokevirtual #92 // Method java/lang/String.length:()I\n 48: if_icmpge 157\n 51: aload_1\n 52: invokeinterface #83, 1 // InterfaceMethod java/util/List.size:()I\n 57: iload 4\n 59: iconst_1\n 60: iadd\n 61: if_icmpge 85\n 64: nop\n 65: aload_1\n 66: checkcast #94 // class java/util/Collection\n 69: new #77 // class java/util/ArrayList\n 72: dup\n 73: invokespecial #79 // Method java/util/ArrayList.\"<init>\":()V\n 76: checkcast #67 // class java/util/List\n 79: invokeinterface #98, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 84: pop\n 85: aload_3\n 86: iload 5\n 88: iload 5\n 90: iconst_3\n 91: iadd\n 92: invokestatic #104 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 95: invokestatic #110 // Method kotlin/text/StringsKt.substring:(Ljava/lang/String;Lkotlin/ranges/IntRange;)Ljava/lang/String;\n 98: astore 6\n 100: aload 6\n 102: checkcast #112 // class java/lang/CharSequence\n 105: invokestatic #116 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 108: ifne 115\n 111: iconst_1\n 112: goto 116\n 115: iconst_0\n 116: ifeq 145\n 119: aload_1\n 120: iload 4\n 122: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 127: checkcast #67 // class java/util/List\n 130: aload 6\n 132: iconst_1\n 133: invokevirtual #120 // Method java/lang/String.charAt:(I)C\n 136: invokestatic #126 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 139: invokeinterface #127, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 144: pop\n 145: iinc 4, 1\n 148: iload 4\n 150: iconst_4\n 151: imul\n 152: istore 5\n 154: goto 42\n 157: iinc 2, -1\n 160: goto 20\n 163: aload_1\n 164: areturn\n\n private static final java.lang.String main$parseAndApplyMoves(java.util.List<java.lang.String>, kotlin.jvm.functions.Function2<? super java.util.List<? extends java.util.List<java.lang.Character>>, ? super kotlin.Triple<java.lang.Integer, java.lang.Integer, java.lang.Integer>, kotlin.Unit>);\n Code:\n 0: aload_0\n 1: ldc #140 // String\n 3: invokeinterface #144, 2 // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I\n 8: istore_2\n 9: aload_0\n 10: iconst_0\n 11: iload_2\n 12: invokeinterface #148, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 17: invokestatic #150 // Method main$parseStackSetup:(Ljava/util/List;)Ljava/util/List;\n 20: astore_3\n 21: aload_0\n 22: iload_2\n 23: iconst_1\n 24: iadd\n 25: aload_0\n 26: invokeinterface #83, 1 // InterfaceMethod java/util/List.size:()I\n 31: invokeinterface #148, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 36: astore 4\n 38: new #152 // class kotlin/text/Regex\n 41: dup\n 42: ldc #154 // String move (\\\\d+) from (\\\\d+) to (\\\\d+)\n 44: invokespecial #155 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 47: astore 5\n 49: aload 4\n 51: checkcast #157 // class java/lang/Iterable\n 54: astore 6\n 56: iconst_0\n 57: istore 7\n 59: aload 6\n 61: invokeinterface #161, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 66: astore 8\n 68: aload 8\n 70: invokeinterface #167, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 75: ifeq 242\n 78: aload 8\n 80: invokeinterface #171, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 85: astore 9\n 87: aload 9\n 89: checkcast #89 // class java/lang/String\n 92: astore 10\n 94: iconst_0\n 95: istore 11\n 97: aload 5\n 99: aload 10\n 101: checkcast #112 // class java/lang/CharSequence\n 104: invokevirtual #175 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;\n 107: dup\n 108: ifnull 235\n 111: astore 12\n 113: aload 12\n 115: astore 13\n 117: iconst_0\n 118: istore 14\n 120: aload 13\n 122: invokeinterface #181, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 127: astore 15\n 129: aload 15\n 131: invokevirtual #187 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 134: invokeinterface #191, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 139: iconst_1\n 140: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 145: checkcast #89 // class java/lang/String\n 148: astore 16\n 150: aload 15\n 152: invokevirtual #187 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 155: invokeinterface #191, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 160: iconst_2\n 161: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 166: checkcast #89 // class java/lang/String\n 169: astore 17\n 171: aload 15\n 173: invokevirtual #187 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 176: invokeinterface #191, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 181: iconst_3\n 182: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 187: checkcast #89 // class java/lang/String\n 190: astore 18\n 192: aload_1\n 193: aload_3\n 194: new #193 // class kotlin/Triple\n 197: dup\n 198: aload 16\n 200: invokestatic #199 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 203: invokestatic #202 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 206: aload 17\n 208: invokestatic #199 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 211: invokestatic #202 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 214: aload 18\n 216: invokestatic #199 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 219: invokestatic #202 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 222: invokespecial #205 // Method kotlin/Triple.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V\n 225: invokeinterface #211, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 230: pop\n 231: nop\n 232: goto 237\n 235: pop\n 236: nop\n 237: nop\n 238: nop\n 239: goto 68\n 242: nop\n 243: aload_3\n 244: checkcast #157 // class java/lang/Iterable\n 247: astore 6\n 249: iconst_0\n 250: istore 7\n 252: aload 6\n 254: astore 8\n 256: new #77 // class java/util/ArrayList\n 259: dup\n 260: aload 6\n 262: bipush 10\n 264: invokestatic #217 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 267: invokespecial #220 // Method java/util/ArrayList.\"<init>\":(I)V\n 270: checkcast #94 // class java/util/Collection\n 273: astore 9\n 275: iconst_0\n 276: istore 10\n 278: aload 8\n 280: invokeinterface #161, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 285: astore 11\n 287: aload 11\n 289: invokeinterface #167, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 294: ifeq 346\n 297: aload 11\n 299: invokeinterface #171, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 304: astore 12\n 306: aload 9\n 308: aload 12\n 310: checkcast #67 // class java/util/List\n 313: astore 13\n 315: astore 19\n 317: iconst_0\n 318: istore 14\n 320: aload 13\n 322: invokestatic #224 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 325: checkcast #122 // class java/lang/Character\n 328: invokevirtual #228 // Method java/lang/Character.charValue:()C\n 331: invokestatic #126 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 334: aload 19\n 336: swap\n 337: invokeinterface #98, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 342: pop\n 343: goto 287\n 346: aload 9\n 348: checkcast #67 // class java/util/List\n 351: nop\n 352: checkcast #157 // class java/lang/Iterable\n 355: ldc #140 // String\n 357: checkcast #112 // 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 #232 // 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 private static final kotlin.Unit main$part1$lambda$4(java.util.List, kotlin.Triple);\n Code:\n 0: aload_0\n 1: ldc_w #264 // String stacks\n 4: invokestatic #268 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: ldc_w #270 // String <destruct>\n 11: invokestatic #268 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: aload_1\n 15: invokevirtual #273 // Method kotlin/Triple.component1:()Ljava/lang/Object;\n 18: checkcast #275 // class java/lang/Number\n 21: invokevirtual #278 // Method java/lang/Number.intValue:()I\n 24: istore_2\n 25: aload_1\n 26: invokevirtual #281 // Method kotlin/Triple.component2:()Ljava/lang/Object;\n 29: checkcast #275 // class java/lang/Number\n 32: invokevirtual #278 // Method java/lang/Number.intValue:()I\n 35: istore_3\n 36: aload_1\n 37: invokevirtual #284 // Method kotlin/Triple.component3:()Ljava/lang/Object;\n 40: checkcast #275 // class java/lang/Number\n 43: invokevirtual #278 // Method java/lang/Number.intValue:()I\n 46: istore 4\n 48: iconst_0\n 49: istore 5\n 51: iload 5\n 53: iload_2\n 54: if_icmpge 123\n 57: iconst_0\n 58: istore 6\n 60: aload_0\n 61: iload_3\n 62: iconst_1\n 63: isub\n 64: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 69: checkcast #67 // class java/util/List\n 72: invokeinterface #287, 1 // InterfaceMethod java/util/List.removeLast:()Ljava/lang/Object;\n 77: dup\n 78: ldc_w #289 // String removeLast(...)\n 81: invokestatic #292 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 84: checkcast #122 // class java/lang/Character\n 87: invokevirtual #228 // Method java/lang/Character.charValue:()C\n 90: istore 7\n 92: aload_0\n 93: iload 4\n 95: iconst_1\n 96: isub\n 97: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 102: checkcast #67 // class java/util/List\n 105: iload 7\n 107: invokestatic #126 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 110: invokeinterface #127, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 115: pop\n 116: nop\n 117: iinc 5, 1\n 120: goto 51\n 123: getstatic #298 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 126: areturn\n\n private static final java.lang.String main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokedynamic #317, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;\n 6: invokestatic #319 // Method main$parseAndApplyMoves:(Ljava/util/List;Lkotlin/jvm/functions/Function2;)Ljava/lang/String;\n 9: areturn\n\n private static final kotlin.Unit main$part2$lambda$6(java.util.List, kotlin.Triple);\n Code:\n 0: aload_0\n 1: ldc_w #264 // String stacks\n 4: invokestatic #268 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: ldc_w #270 // String <destruct>\n 11: invokestatic #268 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: aload_1\n 15: invokevirtual #273 // Method kotlin/Triple.component1:()Ljava/lang/Object;\n 18: checkcast #275 // class java/lang/Number\n 21: invokevirtual #278 // Method java/lang/Number.intValue:()I\n 24: istore_2\n 25: aload_1\n 26: invokevirtual #281 // Method kotlin/Triple.component2:()Ljava/lang/Object;\n 29: checkcast #275 // class java/lang/Number\n 32: invokevirtual #278 // Method java/lang/Number.intValue:()I\n 35: istore_3\n 36: aload_1\n 37: invokevirtual #284 // Method kotlin/Triple.component3:()Ljava/lang/Object;\n 40: checkcast #275 // class java/lang/Number\n 43: invokevirtual #278 // Method java/lang/Number.intValue:()I\n 46: istore 4\n 48: new #322 // class kotlin/ranges/IntRange\n 51: dup\n 52: iconst_1\n 53: iload_2\n 54: invokespecial #325 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 57: checkcast #157 // class java/lang/Iterable\n 60: astore 6\n 62: iconst_0\n 63: istore 7\n 65: aload 6\n 67: astore 8\n 69: new #77 // class java/util/ArrayList\n 72: dup\n 73: aload 6\n 75: bipush 10\n 77: invokestatic #217 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 80: invokespecial #220 // Method java/util/ArrayList.\"<init>\":(I)V\n 83: checkcast #94 // class java/util/Collection\n 86: astore 9\n 88: iconst_0\n 89: istore 10\n 91: aload 8\n 93: invokeinterface #161, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 98: astore 11\n 100: aload 11\n 102: invokeinterface #167, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 107: ifeq 159\n 110: aload 11\n 112: checkcast #327 // class kotlin/collections/IntIterator\n 115: invokevirtual #330 // Method kotlin/collections/IntIterator.nextInt:()I\n 118: istore 12\n 120: aload 9\n 122: astore 14\n 124: iconst_0\n 125: istore 13\n 127: aload_0\n 128: iload_3\n 129: iconst_1\n 130: isub\n 131: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 136: checkcast #67 // class java/util/List\n 139: invokeinterface #287, 1 // InterfaceMethod java/util/List.removeLast:()Ljava/lang/Object;\n 144: checkcast #122 // class java/lang/Character\n 147: aload 14\n 149: swap\n 150: invokeinterface #98, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 155: pop\n 156: goto 100\n 159: aload 9\n 161: checkcast #67 // class java/util/List\n 164: nop\n 165: astore 5\n 167: aload_0\n 168: iload 4\n 170: iconst_1\n 171: isub\n 172: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 177: checkcast #67 // class java/util/List\n 180: aload 5\n 182: checkcast #157 // class java/lang/Iterable\n 185: invokestatic #334 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 188: checkcast #94 // class java/util/Collection\n 191: invokeinterface #338, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 196: pop\n 197: getstatic #298 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 200: areturn\n\n private static final java.lang.String main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokedynamic #344, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function2;\n 6: invokestatic #319 // Method main$parseAndApplyMoves:(Ljava/util/List;Lkotlin/jvm/functions/Function2;)Ljava/lang/String;\n 9: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day05.class",
"javap": "Compiled from \"Day05.kt\"\npublic final class Day05 {\n public static final Day05 INSTANCE;\n\n public static final java.lang.String dayNumber;\n\n public static final java.lang.String EXPECTED_PART1_CHECK_ANSWER;\n\n public static final java.lang.String EXPECTED_PART2_CHECK_ANSWER;\n\n public static final int STACK_SETUP_ENTRY_WITH_SPACE_SIZE;\n\n public static final int STACK_SETUP_ENTRY_SIZE;\n\n private Day05();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n static {};\n Code:\n 0: new #2 // class Day05\n 3: dup\n 4: invokespecial #12 // Method \"<init>\":()V\n 7: putstatic #15 // Field INSTANCE:LDay05;\n 10: return\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day11.kt
|
object Day11 {
const val EXPECTED_PART1_CHECK_ANSWER = 10605L
const val EXPECTED_PART2_CHECK_ANSWER = 2713310158
const val PART1_RUNS = 20
const val PART2_RUNS = 10_000
const val WORRY_LEVEL_DIVISION_AMOUNT = 3
val MONKEY_LINE_ITEMS = Regex("\\s+Starting items: ([, \\d]+)")
val MONKEY_LINE_OPERATION = Regex("\\s+Operation: new = old ([+*]) (\\w+)")
val MONKEY_LINE_TEST = Regex("\\s+Test: divisible by (\\d+)")
val MONKEY_LINE_THROW = Regex("\\s+If (true|false): throw to monkey (\\d+)")
}
data class Item(var worryLevel: Long)
class Monkey(
startingItems: List<Item>,
val operation: (Long) -> Long,
val testDivisibleBy: Int,
private val testTrueDestinationMonkey: Int,
private val testFalseDestinationMonkey: Int,
private val relieve: Boolean = true,
) {
private val items: MutableList<Item> = startingItems.toMutableList()
var itemsInspected = 0
private set
fun addItems(items: List<Item>) {
this.items.addAll(items)
}
fun turn(worryReduceVale: Int): Map<Int, List<Item>> {
val itemsToThrow = mutableMapOf<Int, List<Item>>()
for (item in items) {
item.worryLevel = operation(item.worryLevel)
if (relieve) {
item.worryLevel /= Day11.WORRY_LEVEL_DIVISION_AMOUNT
}
item.worryLevel %= worryReduceVale
itemsToThrow.compute(
if (item.worryLevel % testDivisibleBy == 0L) testTrueDestinationMonkey else testFalseDestinationMonkey
) { _, currentItems ->
(currentItems ?: emptyList()) + item
}
itemsInspected++
}
items.clear()
return itemsToThrow
}
}
class MonkeyBusiness(private val monkeys: List<Monkey>) {
private val worryReduceVale = monkeys.map { it.testDivisibleBy }.reduce(Int::times)
private fun round() {
monkeys.forEach { monkey ->
val itemsToPass = monkey.turn(worryReduceVale)
itemsToPass.forEach { (toMonkey, items) ->
monkeys[toMonkey].addItems(items)
}
}
}
fun process(numberOfRounds: Int): Long {
repeat(numberOfRounds) {
round()
}
return monkeys.map { it.itemsInspected }.sortedDescending().take(2).let { it[0].toLong() * it[1].toLong() }
}
}
fun main() {
fun List<String>.parseMonkeyBusiness(doRelieve: Boolean = true): MonkeyBusiness {
val monkeys = mutableListOf<Monkey>()
var inputIdx = 1
while (inputIdx < size) {
val (itemsWorryLevels) = Day11.MONKEY_LINE_ITEMS.matchEntire(this[inputIdx++])!!.destructured
val items = itemsWorryLevels.split(",").map(String::trim).map { Item(it.toLong()) }
val (operation, operationValue) = Day11.MONKEY_LINE_OPERATION.matchEntire(this[inputIdx++])!!.destructured
val (testDivisibleValue) = Day11.MONKEY_LINE_TEST.matchEntire(this[inputIdx++])!!.destructured
val (_, throwToWhenTrue) = Day11.MONKEY_LINE_THROW.matchEntire(this[inputIdx++])!!.destructured
val (_, throwToWhenFalse) = Day11.MONKEY_LINE_THROW.matchEntire(this[inputIdx++])!!.destructured
monkeys.add(
Monkey(
items,
{
val operand = when (operationValue) {
"old" -> it
else -> operationValue.toLong()
}
when (operation) {
"*" -> it * operand
"+" -> it + operand
else -> error("Unknown operation $operation")
}
},
testDivisibleValue.toInt(),
throwToWhenTrue.toInt(),
throwToWhenFalse.toInt(),
doRelieve,
)
)
inputIdx += 2
}
return MonkeyBusiness(monkeys)
}
fun part1(input: List<String>): Long {
val monkeyBusiness = input.parseMonkeyBusiness()
return monkeyBusiness.process(Day11.PART1_RUNS)
}
fun part2(input: List<String>): Long {
val monkeyBusiness = input.parseMonkeyBusiness(false)
return monkeyBusiness.process(Day11.PART2_RUNS)
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day11_test")
check(part1(testInput) == Day11.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
check(part2(testInput) == Day11.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }
val input = readInput("Day11")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day11.class",
"javap": "Compiled from \"Day11.kt\"\npublic final class Day11 {\n public static final Day11 INSTANCE;\n\n public static final long EXPECTED_PART1_CHECK_ANSWER;\n\n public static final long EXPECTED_PART2_CHECK_ANSWER;\n\n public static final int PART1_RUNS;\n\n public static final int PART2_RUNS;\n\n public static final int WORRY_LEVEL_DIVISION_AMOUNT;\n\n private static final kotlin.text.Regex MONKEY_LINE_ITEMS;\n\n private static final kotlin.text.Regex MONKEY_LINE_OPERATION;\n\n private static final kotlin.text.Regex MONKEY_LINE_TEST;\n\n private static final kotlin.text.Regex MONKEY_LINE_THROW;\n\n private Day11();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final kotlin.text.Regex getMONKEY_LINE_ITEMS();\n Code:\n 0: getstatic #17 // Field MONKEY_LINE_ITEMS:Lkotlin/text/Regex;\n 3: areturn\n\n public final kotlin.text.Regex getMONKEY_LINE_OPERATION();\n Code:\n 0: getstatic #21 // Field MONKEY_LINE_OPERATION:Lkotlin/text/Regex;\n 3: areturn\n\n public final kotlin.text.Regex getMONKEY_LINE_TEST();\n Code:\n 0: getstatic #25 // Field MONKEY_LINE_TEST:Lkotlin/text/Regex;\n 3: areturn\n\n public final kotlin.text.Regex getMONKEY_LINE_THROW();\n Code:\n 0: getstatic #29 // Field MONKEY_LINE_THROW:Lkotlin/text/Regex;\n 3: areturn\n\n static {};\n Code:\n 0: new #2 // class Day11\n 3: dup\n 4: invokespecial #31 // Method \"<init>\":()V\n 7: putstatic #34 // Field INSTANCE:LDay11;\n 10: new #36 // class kotlin/text/Regex\n 13: dup\n 14: ldc #38 // String \\\\s+Starting items: ([, \\\\d]+)\n 16: invokespecial #41 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 19: putstatic #17 // Field MONKEY_LINE_ITEMS:Lkotlin/text/Regex;\n 22: new #36 // class kotlin/text/Regex\n 25: dup\n 26: ldc #43 // String \\\\s+Operation: new = old ([+*]) (\\\\w+)\n 28: invokespecial #41 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 31: putstatic #21 // Field MONKEY_LINE_OPERATION:Lkotlin/text/Regex;\n 34: new #36 // class kotlin/text/Regex\n 37: dup\n 38: ldc #45 // String \\\\s+Test: divisible by (\\\\d+)\n 40: invokespecial #41 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 43: putstatic #25 // Field MONKEY_LINE_TEST:Lkotlin/text/Regex;\n 46: new #36 // class kotlin/text/Regex\n 49: dup\n 50: ldc #47 // String \\\\s+If (true|false): throw to monkey (\\\\d+)\n 52: invokespecial #41 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 55: putstatic #29 // Field MONKEY_LINE_THROW:Lkotlin/text/Regex;\n 58: return\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day11Kt.class",
"javap": "Compiled from \"Day11.kt\"\npublic final class Day11Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day11_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method main$part1:(Ljava/util/List;)J\n 10: ldc2_w #19 // long 10605l\n 13: lcmp\n 14: ifne 21\n 17: iconst_1\n 18: goto 22\n 21: iconst_0\n 22: ifne 42\n 25: iconst_0\n 26: istore_2\n 27: ldc #22 // String Part 1 failed\n 29: astore_2\n 30: new #24 // class java/lang/IllegalStateException\n 33: dup\n 34: aload_2\n 35: invokevirtual #28 // Method java/lang/Object.toString:()Ljava/lang/String;\n 38: invokespecial #32 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 41: athrow\n 42: aload_0\n 43: invokestatic #35 // Method main$part2:(Ljava/util/List;)J\n 46: ldc2_w #36 // long 2713310158l\n 49: lcmp\n 50: ifne 57\n 53: iconst_1\n 54: goto 58\n 57: iconst_0\n 58: ifne 78\n 61: iconst_0\n 62: istore_2\n 63: ldc #39 // String Part 2 failed\n 65: astore_2\n 66: new #24 // class java/lang/IllegalStateException\n 69: dup\n 70: aload_2\n 71: invokevirtual #28 // Method java/lang/Object.toString:()Ljava/lang/String;\n 74: invokespecial #32 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 77: athrow\n 78: ldc #41 // String Day11\n 80: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 83: astore_1\n 84: aload_1\n 85: invokestatic #18 // Method main$part1:(Ljava/util/List;)J\n 88: lstore_2\n 89: getstatic #47 // Field java/lang/System.out:Ljava/io/PrintStream;\n 92: lload_2\n 93: invokevirtual #53 // Method java/io/PrintStream.println:(J)V\n 96: aload_1\n 97: invokestatic #35 // Method main$part2:(Ljava/util/List;)J\n 100: lstore_2\n 101: getstatic #47 // Field java/lang/System.out:Ljava/io/PrintStream;\n 104: lload_2\n 105: invokevirtual #53 // Method java/io/PrintStream.println:(J)V\n 108: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #64 // Method main:()V\n 3: return\n\n private static final long main$parseMonkeyBusiness$lambda$1(java.lang.String, java.lang.String, long);\n Code:\n 0: aload_0\n 1: ldc #70 // String old\n 3: invokestatic #76 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 6: ifeq 13\n 9: lload_2\n 10: goto 17\n 13: aload_0\n 14: invokestatic #82 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 17: lstore 4\n 19: aload_1\n 20: astore 6\n 22: aload 6\n 24: ldc #84 // String *\n 26: invokestatic #76 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 29: ifeq 39\n 32: lload_2\n 33: lload 4\n 35: lmul\n 36: goto 86\n 39: aload 6\n 41: ldc #86 // String +\n 43: invokestatic #76 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 46: ifeq 56\n 49: lload_2\n 50: lload 4\n 52: ladd\n 53: goto 86\n 56: new #24 // class java/lang/IllegalStateException\n 59: dup\n 60: new #88 // class java/lang/StringBuilder\n 63: dup\n 64: invokespecial #90 // Method java/lang/StringBuilder.\"<init>\":()V\n 67: ldc #92 // String Unknown operation\n 69: invokevirtual #96 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 72: aload_1\n 73: invokevirtual #96 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 76: invokevirtual #97 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 79: invokevirtual #28 // Method java/lang/Object.toString:()Ljava/lang/String;\n 82: invokespecial #32 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 85: athrow\n 86: lreturn\n\n private static final MonkeyBusiness main$parseMonkeyBusiness(java.util.List<java.lang.String>, boolean);\n Code:\n 0: new #110 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #111 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #61 // class java/util/List\n 10: astore_2\n 11: iconst_1\n 12: istore_3\n 13: iload_3\n 14: aload_0\n 15: invokeinterface #115, 1 // InterfaceMethod java/util/List.size:()I\n 20: if_icmpge 587\n 23: getstatic #120 // Field Day11.INSTANCE:LDay11;\n 26: invokevirtual #124 // Method Day11.getMONKEY_LINE_ITEMS:()Lkotlin/text/Regex;\n 29: aload_0\n 30: iload_3\n 31: iinc 3, 1\n 34: invokeinterface #128, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 39: checkcast #130 // class java/lang/CharSequence\n 42: invokevirtual #136 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;\n 45: dup\n 46: invokestatic #140 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 49: invokeinterface #146, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 54: invokevirtual #152 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 57: invokeinterface #156, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 62: iconst_1\n 63: invokeinterface #128, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 68: checkcast #105 // class java/lang/String\n 71: astore 4\n 73: aload 4\n 75: checkcast #130 // class java/lang/CharSequence\n 78: iconst_1\n 79: anewarray #105 // class java/lang/String\n 82: astore 6\n 84: aload 6\n 86: iconst_0\n 87: ldc #158 // String ,\n 89: aastore\n 90: aload 6\n 92: iconst_0\n 93: iconst_0\n 94: bipush 6\n 96: aconst_null\n 97: invokestatic #164 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 100: checkcast #166 // class java/lang/Iterable\n 103: astore 6\n 105: iconst_0\n 106: istore 7\n 108: aload 6\n 110: astore 8\n 112: new #110 // class java/util/ArrayList\n 115: dup\n 116: aload 6\n 118: bipush 10\n 120: invokestatic #172 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 123: invokespecial #175 // Method java/util/ArrayList.\"<init>\":(I)V\n 126: checkcast #177 // class java/util/Collection\n 129: astore 9\n 131: iconst_0\n 132: istore 10\n 134: aload 8\n 136: invokeinterface #181, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 141: astore 11\n 143: aload 11\n 145: invokeinterface #187, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 150: ifeq 200\n 153: aload 11\n 155: invokeinterface #191, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 160: astore 12\n 162: aload 9\n 164: aload 12\n 166: checkcast #105 // class java/lang/String\n 169: astore 13\n 171: astore 15\n 173: iconst_0\n 174: istore 14\n 176: aload 13\n 178: checkcast #130 // class java/lang/CharSequence\n 181: invokestatic #195 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 184: invokevirtual #28 // Method java/lang/Object.toString:()Ljava/lang/String;\n 187: nop\n 188: aload 15\n 190: swap\n 191: invokeinterface #199, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 196: pop\n 197: goto 143\n 200: aload 9\n 202: checkcast #61 // class java/util/List\n 205: nop\n 206: checkcast #166 // class java/lang/Iterable\n 209: astore 6\n 211: nop\n 212: iconst_0\n 213: istore 7\n 215: aload 6\n 217: astore 8\n 219: new #110 // class java/util/ArrayList\n 222: dup\n 223: aload 6\n 225: bipush 10\n 227: invokestatic #172 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 230: invokespecial #175 // Method java/util/ArrayList.\"<init>\":(I)V\n 233: checkcast #177 // class java/util/Collection\n 236: astore 9\n 238: iconst_0\n 239: istore 10\n 241: aload 8\n 243: invokeinterface #181, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 248: astore 11\n 250: aload 11\n 252: invokeinterface #187, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 257: ifeq 307\n 260: aload 11\n 262: invokeinterface #191, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 267: astore 12\n 269: aload 9\n 271: aload 12\n 273: checkcast #105 // class java/lang/String\n 276: astore 13\n 278: astore 15\n 280: iconst_0\n 281: istore 14\n 283: new #201 // class Item\n 286: dup\n 287: aload 13\n 289: invokestatic #82 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 292: invokespecial #203 // Method Item.\"<init>\":(J)V\n 295: aload 15\n 297: swap\n 298: invokeinterface #199, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 303: pop\n 304: goto 250\n 307: aload 9\n 309: checkcast #61 // class java/util/List\n 312: nop\n 313: astore 5\n 315: getstatic #120 // Field Day11.INSTANCE:LDay11;\n 318: invokevirtual #206 // Method Day11.getMONKEY_LINE_OPERATION:()Lkotlin/text/Regex;\n 321: aload_0\n 322: iload_3\n 323: iinc 3, 1\n 326: invokeinterface #128, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 331: checkcast #130 // class java/lang/CharSequence\n 334: invokevirtual #136 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;\n 337: dup\n 338: invokestatic #140 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 341: invokeinterface #146, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 346: astore 6\n 348: aload 6\n 350: invokevirtual #152 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 353: invokeinterface #156, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 358: iconst_1\n 359: invokeinterface #128, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 364: checkcast #105 // class java/lang/String\n 367: astore 7\n 369: aload 6\n 371: invokevirtual #152 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 374: invokeinterface #156, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 379: iconst_2\n 380: invokeinterface #128, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 385: checkcast #105 // class java/lang/String\n 388: astore 8\n 390: getstatic #120 // Field Day11.INSTANCE:LDay11;\n 393: invokevirtual #209 // Method Day11.getMONKEY_LINE_TEST:()Lkotlin/text/Regex;\n 396: aload_0\n 397: iload_3\n 398: iinc 3, 1\n 401: invokeinterface #128, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 406: checkcast #130 // class java/lang/CharSequence\n 409: invokevirtual #136 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;\n 412: dup\n 413: invokestatic #140 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 416: invokeinterface #146, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 421: invokevirtual #152 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 424: invokeinterface #156, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 429: iconst_1\n 430: invokeinterface #128, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 435: checkcast #105 // class java/lang/String\n 438: astore 10\n 440: getstatic #120 // Field Day11.INSTANCE:LDay11;\n 443: invokevirtual #212 // Method Day11.getMONKEY_LINE_THROW:()Lkotlin/text/Regex;\n 446: aload_0\n 447: iload_3\n 448: iinc 3, 1\n 451: invokeinterface #128, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 456: checkcast #130 // class java/lang/CharSequence\n 459: invokevirtual #136 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;\n 462: dup\n 463: invokestatic #140 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 466: invokeinterface #146, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 471: invokevirtual #152 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 474: invokeinterface #156, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 479: iconst_2\n 480: invokeinterface #128, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 485: checkcast #105 // class java/lang/String\n 488: astore 12\n 490: getstatic #120 // Field Day11.INSTANCE:LDay11;\n 493: invokevirtual #212 // Method Day11.getMONKEY_LINE_THROW:()Lkotlin/text/Regex;\n 496: aload_0\n 497: iload_3\n 498: iinc 3, 1\n 501: invokeinterface #128, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 506: checkcast #130 // class java/lang/CharSequence\n 509: invokevirtual #136 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;\n 512: dup\n 513: invokestatic #140 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 516: invokeinterface #146, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 521: invokevirtual #152 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 524: invokeinterface #156, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 529: iconst_2\n 530: invokeinterface #128, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 535: checkcast #105 // class java/lang/String\n 538: astore 14\n 540: aload_2\n 541: new #214 // class Monkey\n 544: dup\n 545: aload 5\n 547: aload 8\n 549: aload 7\n 551: invokedynamic #232, 0 // InvokeDynamic #0:invoke:(Ljava/lang/String;Ljava/lang/String;)Lkotlin/jvm/functions/Function1;\n 556: aload 10\n 558: invokestatic #238 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 561: aload 12\n 563: invokestatic #238 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 566: aload 14\n 568: invokestatic #238 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 571: iload_1\n 572: invokespecial #241 // Method Monkey.\"<init>\":(Ljava/util/List;Lkotlin/jvm/functions/Function1;IIIZ)V\n 575: invokeinterface #242, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 580: pop\n 581: iinc 3, 2\n 584: goto 13\n 587: new #244 // class MonkeyBusiness\n 590: dup\n 591: aload_2\n 592: invokespecial #247 // Method MonkeyBusiness.\"<init>\":(Ljava/util/List;)V\n 595: areturn\n\n static MonkeyBusiness main$parseMonkeyBusiness$default(java.util.List, boolean, int, java.lang.Object);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: iand\n 3: ifeq 8\n 6: iconst_1\n 7: istore_1\n 8: aload_0\n 9: iload_1\n 10: invokestatic #275 // Method main$parseMonkeyBusiness:(Ljava/util/List;Z)LMonkeyBusiness;\n 13: areturn\n\n private static final long main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: iconst_0\n 2: iconst_1\n 3: aconst_null\n 4: invokestatic #278 // Method main$parseMonkeyBusiness$default:(Ljava/util/List;ZILjava/lang/Object;)LMonkeyBusiness;\n 7: astore_1\n 8: aload_1\n 9: bipush 20\n 11: invokevirtual #282 // Method MonkeyBusiness.process:(I)J\n 14: lreturn\n\n private static final long main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: iconst_0\n 2: invokestatic #275 // Method main$parseMonkeyBusiness:(Ljava/util/List;Z)LMonkeyBusiness;\n 5: astore_1\n 6: aload_1\n 7: sipush 10000\n 10: invokevirtual #282 // Method MonkeyBusiness.process:(I)J\n 13: lreturn\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day09.kt
|
import kotlin.math.abs
import kotlin.math.sign
object Day09 {
const val EXPECTED_PART1_CHECK_ANSWER = 13
const val EXPECTED_PART2_CHECK_ANSWER = 1
const val TAIL_SIZE_PART_2 = 9
}
enum class MovementDirection { U, D, L, R }
fun main() {
data class Location(val x: Int, val y: Int) {
fun move(direction: MovementDirection) = when (direction) {
MovementDirection.U -> copy(y = y + 1)
MovementDirection.D -> copy(y = y - 1)
MovementDirection.R -> copy(x = x + 1)
MovementDirection.L -> copy(x = x - 1)
}
fun moveAfterPrecursor(precursorPosition: Location): Location {
val xDiff = precursorPosition.x - x
val yDiff = precursorPosition.y - y
if (abs(xDiff) > 1 || abs(yDiff) > 1) {
return copy(
x = x + (xDiff + xDiff.sign) / 2,
y = y + (yDiff + yDiff.sign) / 2,
)
}
return this
}
}
fun part1(input: List<String>): Int {
val tailVisitedPositions = mutableSetOf<Location>()
var currentHeadPosition = Location(0, 0)
var currentTailPosition = Location(0, 0)
tailVisitedPositions.add(currentTailPosition)
input.forEach { movement ->
val directionAndSteps = movement.split(" ")
val (direction, steps) = Pair(MovementDirection.valueOf(directionAndSteps[0]), directionAndSteps[1].toInt())
repeat(steps) {
currentHeadPosition = currentHeadPosition.move(direction)
currentTailPosition = currentTailPosition.moveAfterPrecursor(currentHeadPosition)
tailVisitedPositions.add(currentTailPosition)
}
}
return tailVisitedPositions.size
}
fun part2(input: List<String>): Int {
val tailVisitedPositions = mutableSetOf<Location>()
var currentHeadPosition = Location(0, 0)
val trailPositions = MutableList(Day09.TAIL_SIZE_PART_2) { Location(0, 0) }
tailVisitedPositions.add(trailPositions.last())
input.forEach { movement ->
val directionAndSteps = movement.split(" ")
val (direction, steps) = Pair(MovementDirection.valueOf(directionAndSteps[0]), directionAndSteps[1].toInt())
repeat(steps) {
currentHeadPosition = currentHeadPosition.move(direction)
trailPositions.forEachIndexed { idx, trailPosition ->
val newTrailPosition =
trailPosition.moveAfterPrecursor(if (idx == 0) currentHeadPosition else trailPositions[idx - 1])
trailPositions[idx] = newTrailPosition
}
tailVisitedPositions.add(trailPositions.last())
}
}
return tailVisitedPositions.size
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day09_test")
check(part1(testInput) == Day09.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
check(part2(testInput) == Day09.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }
val input = readInput("Day09")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day09Kt$main$Location.class",
"javap": "Compiled from \"Day09.kt\"\npublic final class Day09Kt$main$Location {\n private final int x;\n\n private final int y;\n\n public Day09Kt$main$Location(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 Day09Kt$main$Location move(MovementDirection);\n Code:\n 0: aload_1\n 1: ldc #25 // String direction\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: getstatic #37 // Field Day09Kt$main$Location$WhenMappings.$EnumSwitchMapping$0:[I\n 10: swap\n 11: invokevirtual #42 // Method MovementDirection.ordinal:()I\n 14: iaload\n 15: tableswitch { // 1 to 4\n 1: 44\n 2: 60\n 3: 76\n 4: 92\n default: 108\n }\n 44: aload_0\n 45: iconst_0\n 46: aload_0\n 47: getfield #16 // Field y:I\n 50: iconst_1\n 51: iadd\n 52: iconst_1\n 53: aconst_null\n 54: invokestatic #46 // Method copy$default:(LDay09Kt$main$Location;IIILjava/lang/Object;)LDay09Kt$main$Location;\n 57: goto 116\n 60: aload_0\n 61: iconst_0\n 62: aload_0\n 63: getfield #16 // Field y:I\n 66: iconst_1\n 67: isub\n 68: iconst_1\n 69: aconst_null\n 70: invokestatic #46 // Method copy$default:(LDay09Kt$main$Location;IIILjava/lang/Object;)LDay09Kt$main$Location;\n 73: goto 116\n 76: aload_0\n 77: aload_0\n 78: getfield #13 // Field x:I\n 81: iconst_1\n 82: iadd\n 83: iconst_0\n 84: iconst_2\n 85: aconst_null\n 86: invokestatic #46 // Method copy$default:(LDay09Kt$main$Location;IIILjava/lang/Object;)LDay09Kt$main$Location;\n 89: goto 116\n 92: aload_0\n 93: aload_0\n 94: getfield #13 // Field x:I\n 97: iconst_1\n 98: isub\n 99: iconst_0\n 100: iconst_2\n 101: aconst_null\n 102: invokestatic #46 // Method copy$default:(LDay09Kt$main$Location;IIILjava/lang/Object;)LDay09Kt$main$Location;\n 105: goto 116\n 108: new #48 // class kotlin/NoWhenBranchMatchedException\n 111: dup\n 112: invokespecial #49 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 115: athrow\n 116: areturn\n\n public final Day09Kt$main$Location moveAfterPrecursor(Day09Kt$main$Location);\n Code:\n 0: aload_1\n 1: ldc #54 // String precursorPosition\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: getfield #13 // Field x:I\n 10: aload_0\n 11: getfield #13 // Field x:I\n 14: isub\n 15: istore_2\n 16: aload_1\n 17: getfield #16 // Field y:I\n 20: aload_0\n 21: getfield #16 // Field y:I\n 24: isub\n 25: istore_3\n 26: iload_2\n 27: invokestatic #60 // Method java/lang/Math.abs:(I)I\n 30: iconst_1\n 31: if_icmpgt 42\n 34: iload_3\n 35: invokestatic #60 // Method java/lang/Math.abs:(I)I\n 38: iconst_1\n 39: if_icmple 73\n 42: aload_0\n 43: aload_0\n 44: getfield #13 // Field x:I\n 47: iload_2\n 48: iload_2\n 49: invokestatic #65 // Method kotlin/math/MathKt.getSign:(I)I\n 52: iadd\n 53: iconst_2\n 54: idiv\n 55: iadd\n 56: aload_0\n 57: getfield #16 // Field y:I\n 60: iload_3\n 61: iload_3\n 62: invokestatic #65 // Method kotlin/math/MathKt.getSign:(I)I\n 65: iadd\n 66: iconst_2\n 67: idiv\n 68: iadd\n 69: invokevirtual #69 // Method copy:(II)LDay09Kt$main$Location;\n 72: areturn\n 73: aload_0\n 74: 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 Day09Kt$main$Location copy(int, int);\n Code:\n 0: new #2 // class Day09Kt$main$Location\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: invokespecial #75 // Method \"<init>\":(II)V\n 9: areturn\n\n public static Day09Kt$main$Location copy$default(Day09Kt$main$Location, 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 #69 // Method copy:(II)LDay09Kt$main$Location;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #79 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #80 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #82 // String Location(x=\n 9: invokevirtual #86 // 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 #89 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #91 // String , y=\n 21: invokevirtual #86 // 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 #89 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #94 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #96 // 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 #101 // 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 #101 // 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 Day09Kt$main$Location\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day09Kt$main$Location\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": "dizney__aoc-2022-in-kotlin__f684a4e/Day09.class",
"javap": "Compiled from \"Day09.kt\"\npublic final class Day09 {\n public static final Day09 INSTANCE;\n\n public static final int EXPECTED_PART1_CHECK_ANSWER;\n\n public static final int EXPECTED_PART2_CHECK_ANSWER;\n\n public static final int TAIL_SIZE_PART_2;\n\n private Day09();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n static {};\n Code:\n 0: new #2 // class Day09\n 3: dup\n 4: invokespecial #12 // Method \"<init>\":()V\n 7: putstatic #15 // Field INSTANCE:LDay09;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day09Kt$main$Location$WhenMappings.class",
"javap": "Compiled from \"Day09.kt\"\npublic final class Day09Kt$main$Location$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method MovementDirection.values:()[LMovementDirection;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field MovementDirection.U:LMovementDirection;\n 12: invokevirtual #22 // Method MovementDirection.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 MovementDirection.D:LMovementDirection;\n 26: invokevirtual #22 // Method MovementDirection.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 MovementDirection.R:LMovementDirection;\n 40: invokevirtual #22 // Method MovementDirection.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 MovementDirection.L:LMovementDirection;\n 54: invokevirtual #22 // Method MovementDirection.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": "dizney__aoc-2022-in-kotlin__f684a4e/Day09Kt.class",
"javap": "Compiled from \"Day09.kt\"\npublic final class Day09Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day09_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: bipush 13\n 12: if_icmpne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 40\n 23: iconst_0\n 24: istore_2\n 25: ldc #20 // String Part 1 failed\n 27: astore_2\n 28: new #22 // class java/lang/IllegalStateException\n 31: dup\n 32: aload_2\n 33: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 36: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 39: athrow\n 40: aload_0\n 41: invokestatic #33 // Method main$part2:(Ljava/util/List;)I\n 44: iconst_1\n 45: if_icmpne 52\n 48: iconst_1\n 49: goto 53\n 52: iconst_0\n 53: ifne 73\n 56: iconst_0\n 57: istore_2\n 58: ldc #35 // String Part 2 failed\n 60: astore_2\n 61: new #22 // class java/lang/IllegalStateException\n 64: dup\n 65: aload_2\n 66: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 69: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 72: athrow\n 73: ldc #37 // String Day09\n 75: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 78: astore_1\n 79: aload_1\n 80: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 83: istore_2\n 84: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 87: iload_2\n 88: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 91: aload_1\n 92: invokestatic #33 // Method main$part2:(Ljava/util/List;)I\n 95: istore_2\n 96: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 99: iload_2\n 100: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 103: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #60 // 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 #65 // class java/util/LinkedHashSet\n 3: dup\n 4: invokespecial #67 // Method java/util/LinkedHashSet.\"<init>\":()V\n 7: checkcast #69 // class java/util/Set\n 10: astore_1\n 11: aconst_null\n 12: astore_2\n 13: new #71 // class Day09Kt$main$Location\n 16: dup\n 17: iconst_0\n 18: iconst_0\n 19: invokespecial #74 // Method Day09Kt$main$Location.\"<init>\":(II)V\n 22: astore_2\n 23: aconst_null\n 24: astore_3\n 25: new #71 // class Day09Kt$main$Location\n 28: dup\n 29: iconst_0\n 30: iconst_0\n 31: invokespecial #74 // Method Day09Kt$main$Location.\"<init>\":(II)V\n 34: astore_3\n 35: aload_1\n 36: aload_3\n 37: invokeinterface #78, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 42: pop\n 43: aload_0\n 44: checkcast #80 // class java/lang/Iterable\n 47: astore 4\n 49: iconst_0\n 50: istore 5\n 52: aload 4\n 54: invokeinterface #84, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 59: astore 6\n 61: aload 6\n 63: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 68: ifeq 232\n 71: aload 6\n 73: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 78: astore 7\n 80: aload 7\n 82: checkcast #96 // class java/lang/String\n 85: astore 8\n 87: iconst_0\n 88: istore 9\n 90: aload 8\n 92: checkcast #98 // class java/lang/CharSequence\n 95: iconst_1\n 96: anewarray #96 // class java/lang/String\n 99: astore 10\n 101: aload 10\n 103: iconst_0\n 104: ldc #100 // String\n 106: aastore\n 107: aload 10\n 109: iconst_0\n 110: iconst_0\n 111: bipush 6\n 113: aconst_null\n 114: invokestatic #106 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 117: astore 11\n 119: new #108 // class kotlin/Pair\n 122: dup\n 123: aload 11\n 125: iconst_0\n 126: invokeinterface #112, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 131: checkcast #96 // class java/lang/String\n 134: invokestatic #118 // Method MovementDirection.valueOf:(Ljava/lang/String;)LMovementDirection;\n 137: aload 11\n 139: iconst_1\n 140: invokeinterface #112, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 145: checkcast #96 // class java/lang/String\n 148: invokestatic #124 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 151: invokestatic #127 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 154: invokespecial #130 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 157: astore 10\n 159: aload 10\n 161: invokevirtual #133 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 164: checkcast #114 // class MovementDirection\n 167: astore 12\n 169: aload 10\n 171: invokevirtual #136 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 174: checkcast #138 // class java/lang/Number\n 177: invokevirtual #142 // Method java/lang/Number.intValue:()I\n 180: istore 13\n 182: iconst_0\n 183: istore 14\n 185: iload 14\n 187: iload 13\n 189: if_icmpge 227\n 192: iload 14\n 194: istore 15\n 196: iconst_0\n 197: istore 16\n 199: aload_2\n 200: aload 12\n 202: invokevirtual #146 // Method Day09Kt$main$Location.move:(LMovementDirection;)LDay09Kt$main$Location;\n 205: astore_2\n 206: aload_3\n 207: aload_2\n 208: invokevirtual #150 // Method Day09Kt$main$Location.moveAfterPrecursor:(LDay09Kt$main$Location;)LDay09Kt$main$Location;\n 211: astore_3\n 212: aload_1\n 213: aload_3\n 214: invokeinterface #78, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 219: pop\n 220: nop\n 221: iinc 14, 1\n 224: goto 185\n 227: nop\n 228: nop\n 229: goto 61\n 232: nop\n 233: aload_1\n 234: invokeinterface #153, 1 // InterfaceMethod java/util/Set.size:()I\n 239: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: new #65 // class java/util/LinkedHashSet\n 3: dup\n 4: invokespecial #67 // Method java/util/LinkedHashSet.\"<init>\":()V\n 7: checkcast #69 // class java/util/Set\n 10: astore_1\n 11: aconst_null\n 12: astore_2\n 13: new #71 // class Day09Kt$main$Location\n 16: dup\n 17: iconst_0\n 18: iconst_0\n 19: invokespecial #74 // Method Day09Kt$main$Location.\"<init>\":(II)V\n 22: astore_2\n 23: bipush 9\n 25: istore 4\n 27: new #173 // class java/util/ArrayList\n 30: dup\n 31: iload 4\n 33: invokespecial #175 // Method java/util/ArrayList.\"<init>\":(I)V\n 36: astore 5\n 38: iconst_0\n 39: istore 6\n 41: iload 6\n 43: iload 4\n 45: if_icmpge 85\n 48: iload 6\n 50: istore 7\n 52: aload 5\n 54: iload 7\n 56: istore 8\n 58: astore 27\n 60: iconst_0\n 61: istore 9\n 63: new #71 // class Day09Kt$main$Location\n 66: dup\n 67: iconst_0\n 68: iconst_0\n 69: invokespecial #74 // Method Day09Kt$main$Location.\"<init>\":(II)V\n 72: aload 27\n 74: swap\n 75: invokevirtual #176 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 78: pop\n 79: iinc 6, 1\n 82: goto 41\n 85: aload 5\n 87: checkcast #57 // class java/util/List\n 90: astore_3\n 91: aload_1\n 92: aload_3\n 93: invokestatic #182 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 96: invokeinterface #78, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 101: pop\n 102: aload_0\n 103: checkcast #80 // class java/lang/Iterable\n 106: astore 4\n 108: iconst_0\n 109: istore 5\n 111: aload 4\n 113: invokeinterface #84, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 118: astore 6\n 120: aload 6\n 122: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 127: ifeq 403\n 130: aload 6\n 132: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 137: astore 7\n 139: aload 7\n 141: checkcast #96 // class java/lang/String\n 144: astore 8\n 146: iconst_0\n 147: istore 9\n 149: aload 8\n 151: checkcast #98 // class java/lang/CharSequence\n 154: iconst_1\n 155: anewarray #96 // class java/lang/String\n 158: astore 10\n 160: aload 10\n 162: iconst_0\n 163: ldc #100 // String\n 165: aastore\n 166: aload 10\n 168: iconst_0\n 169: iconst_0\n 170: bipush 6\n 172: aconst_null\n 173: invokestatic #106 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 176: astore 11\n 178: new #108 // class kotlin/Pair\n 181: dup\n 182: aload 11\n 184: iconst_0\n 185: invokeinterface #112, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 190: checkcast #96 // class java/lang/String\n 193: invokestatic #118 // Method MovementDirection.valueOf:(Ljava/lang/String;)LMovementDirection;\n 196: aload 11\n 198: iconst_1\n 199: invokeinterface #112, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 204: checkcast #96 // class java/lang/String\n 207: invokestatic #124 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 210: invokestatic #127 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 213: invokespecial #130 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 216: astore 10\n 218: aload 10\n 220: invokevirtual #133 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 223: checkcast #114 // class MovementDirection\n 226: astore 12\n 228: aload 10\n 230: invokevirtual #136 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 233: checkcast #138 // class java/lang/Number\n 236: invokevirtual #142 // Method java/lang/Number.intValue:()I\n 239: istore 13\n 241: iconst_0\n 242: istore 14\n 244: iload 14\n 246: iload 13\n 248: if_icmpge 398\n 251: iload 14\n 253: istore 15\n 255: iconst_0\n 256: istore 16\n 258: aload_2\n 259: aload 12\n 261: invokevirtual #146 // Method Day09Kt$main$Location.move:(LMovementDirection;)LDay09Kt$main$Location;\n 264: astore_2\n 265: aload_3\n 266: checkcast #80 // class java/lang/Iterable\n 269: astore 17\n 271: iconst_0\n 272: istore 18\n 274: iconst_0\n 275: istore 19\n 277: aload 17\n 279: invokeinterface #84, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 284: astore 20\n 286: aload 20\n 288: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 293: ifeq 379\n 296: aload 20\n 298: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 303: astore 21\n 305: iload 19\n 307: iinc 19, 1\n 310: istore 22\n 312: iload 22\n 314: ifge 320\n 317: invokestatic #185 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 320: iload 22\n 322: aload 21\n 324: checkcast #71 // class Day09Kt$main$Location\n 327: astore 23\n 329: istore 24\n 331: iconst_0\n 332: istore 25\n 334: aload 23\n 336: iload 24\n 338: ifne 345\n 341: aload_2\n 342: goto 358\n 345: aload_3\n 346: iload 24\n 348: iconst_1\n 349: isub\n 350: invokeinterface #112, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 355: checkcast #71 // class Day09Kt$main$Location\n 358: invokevirtual #150 // Method Day09Kt$main$Location.moveAfterPrecursor:(LDay09Kt$main$Location;)LDay09Kt$main$Location;\n 361: astore 26\n 363: aload_3\n 364: iload 24\n 366: aload 26\n 368: invokeinterface #189, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 373: pop\n 374: nop\n 375: nop\n 376: goto 286\n 379: nop\n 380: aload_1\n 381: aload_3\n 382: invokestatic #182 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 385: invokeinterface #78, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 390: pop\n 391: nop\n 392: iinc 14, 1\n 395: goto 244\n 398: nop\n 399: nop\n 400: goto 120\n 403: nop\n 404: aload_1\n 405: invokeinterface #153, 1 // InterfaceMethod java/util/Set.size:()I\n 410: ireturn\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day07.kt
|
object Day07 {
const val EXPECTED_PART1_CHECK_ANSWER = 95437
const val EXPECTED_PART2_CHECK_ANSWER = 24933642
const val DIR_SIZE_THRESHOLD = 100_000
const val FS_TOTAL_SIZE = 70_000_000
const val FS_NEEDED_FREE_SPACE = 30_000_000
}
sealed class Entry(val name: String)
class File(name: String, val size: Int) : Entry(name)
class Dir(name: String, val parentDir: Dir? = null) : Entry(name) {
private var content: List<Entry> = emptyList()
fun add(entry: Entry): Entry {
content += entry
return this
}
fun dirContent() = content
}
fun main() {
val fileListingRegex = Regex("(\\d+) (\\S+)")
fun parseDirTree(input: List<String>): Dir {
val rootDir = Dir("/")
var currentDir = rootDir
input.drop(1).forEach { entry ->
when {
entry.startsWith("$ cd ..") -> {
if (currentDir.parentDir != null) {
currentDir = currentDir.parentDir!!
}
}
entry.startsWith("$ cd") -> {
val newDir = Dir(entry.substring("$ cd ".length), currentDir)
currentDir.add(newDir)
currentDir = newDir
}
entry.matches(fileListingRegex) -> {
val match = fileListingRegex.matchEntire(entry)
if (match != null) {
currentDir.add(File(match.groupValues[2], match.groupValues[1].toInt()))
}
}
}
}
return rootDir
}
fun dirSizes(dir: Dir, sizes: MutableList<Int>): Int {
var totalDirSize = 0
dir.dirContent().forEach { subEntry ->
totalDirSize += when (subEntry) {
is File -> subEntry.size
is Dir -> dirSizes(subEntry, sizes)
}
}
sizes += totalDirSize
return totalDirSize
}
fun part1(input: List<String>): Int {
val rootDir = parseDirTree(input)
val sizesOfDirs = mutableListOf<Int>()
dirSizes(rootDir, sizesOfDirs)
return sizesOfDirs.filter { it <= Day07.DIR_SIZE_THRESHOLD }.sum()
}
fun part2(input: List<String>): Int {
val rootDir = parseDirTree(input)
val sizesOfDirs = mutableListOf<Int>()
val rootDirSize = dirSizes(rootDir, sizesOfDirs)
val currentFreeSpace = Day07.FS_TOTAL_SIZE - rootDirSize
val needToFreeUp = Day07.FS_NEEDED_FREE_SPACE - currentFreeSpace
return sizesOfDirs.filter { it >= needToFreeUp }.sorted()[0]
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day07_test")
check(part1(testInput) == Day07.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
check(part2(testInput) == Day07.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }
val input = readInput("Day07")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day07Kt.class",
"javap": "Compiled from \"Day07.kt\"\npublic final class Day07Kt {\n public static final void main();\n Code:\n 0: new #8 // class kotlin/text/Regex\n 3: dup\n 4: ldc #10 // String (\\\\d+) (\\\\S+)\n 6: invokespecial #14 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 9: astore_0\n 10: ldc #16 // String Day07_test\n 12: invokestatic #22 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 15: astore_1\n 16: aload_0\n 17: aload_1\n 18: invokestatic #26 // Method main$part1:(Lkotlin/text/Regex;Ljava/util/List;)I\n 21: ldc #27 // int 95437\n 23: if_icmpne 30\n 26: iconst_1\n 27: goto 31\n 30: iconst_0\n 31: ifne 51\n 34: iconst_0\n 35: istore_3\n 36: ldc #29 // String Part 1 failed\n 38: astore_3\n 39: new #31 // class java/lang/IllegalStateException\n 42: dup\n 43: aload_3\n 44: invokevirtual #35 // Method java/lang/Object.toString:()Ljava/lang/String;\n 47: invokespecial #36 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 50: athrow\n 51: aload_0\n 52: aload_1\n 53: invokestatic #39 // Method main$part2:(Lkotlin/text/Regex;Ljava/util/List;)I\n 56: ldc #40 // int 24933642\n 58: if_icmpne 65\n 61: iconst_1\n 62: goto 66\n 65: iconst_0\n 66: ifne 86\n 69: iconst_0\n 70: istore_3\n 71: ldc #42 // String Part 2 failed\n 73: astore_3\n 74: new #31 // class java/lang/IllegalStateException\n 77: dup\n 78: aload_3\n 79: invokevirtual #35 // Method java/lang/Object.toString:()Ljava/lang/String;\n 82: invokespecial #36 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 85: athrow\n 86: ldc #44 // String Day07\n 88: invokestatic #22 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 91: astore_2\n 92: aload_0\n 93: aload_2\n 94: invokestatic #26 // Method main$part1:(Lkotlin/text/Regex;Ljava/util/List;)I\n 97: istore_3\n 98: getstatic #50 // Field java/lang/System.out:Ljava/io/PrintStream;\n 101: iload_3\n 102: invokevirtual #56 // Method java/io/PrintStream.println:(I)V\n 105: aload_0\n 106: aload_2\n 107: invokestatic #39 // Method main$part2:(Lkotlin/text/Regex;Ljava/util/List;)I\n 110: istore_3\n 111: getstatic #50 // Field java/lang/System.out:Ljava/io/PrintStream;\n 114: iload_3\n 115: invokevirtual #56 // Method java/io/PrintStream.println:(I)V\n 118: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #69 // Method main:()V\n 3: return\n\n private static final Dir main$parseDirTree(kotlin.text.Regex, java.util.List<java.lang.String>);\n Code:\n 0: new #76 // class Dir\n 3: dup\n 4: ldc #78 // String /\n 6: aconst_null\n 7: iconst_2\n 8: aconst_null\n 9: invokespecial #81 // Method Dir.\"<init>\":(Ljava/lang/String;LDir;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 12: astore_2\n 13: aconst_null\n 14: astore_3\n 15: aload_2\n 16: astore_3\n 17: aload_1\n 18: checkcast #83 // class java/lang/Iterable\n 21: iconst_1\n 22: invokestatic #89 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 25: checkcast #83 // class java/lang/Iterable\n 28: astore 4\n 30: iconst_0\n 31: istore 5\n 33: aload 4\n 35: invokeinterface #93, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 40: astore 6\n 42: aload 6\n 44: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 49: ifeq 239\n 52: aload 6\n 54: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 59: astore 7\n 61: aload 7\n 63: checkcast #105 // class java/lang/String\n 66: astore 8\n 68: iconst_0\n 69: istore 9\n 71: nop\n 72: aload 8\n 74: ldc #107 // String $ cd ..\n 76: iconst_0\n 77: iconst_2\n 78: aconst_null\n 79: invokestatic #113 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 82: ifeq 104\n 85: aload_3\n 86: invokevirtual #117 // Method Dir.getParentDir:()LDir;\n 89: ifnull 234\n 92: aload_3\n 93: invokevirtual #117 // Method Dir.getParentDir:()LDir;\n 96: dup\n 97: invokestatic #123 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 100: astore_3\n 101: goto 234\n 104: aload 8\n 106: ldc #125 // String $ cd\n 108: iconst_0\n 109: iconst_2\n 110: aconst_null\n 111: invokestatic #113 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 114: ifeq 155\n 117: new #76 // class Dir\n 120: dup\n 121: aload 8\n 123: iconst_5\n 124: invokevirtual #129 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 127: dup\n 128: ldc #131 // String substring(...)\n 130: invokestatic #135 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 133: aload_3\n 134: invokespecial #138 // Method Dir.\"<init>\":(Ljava/lang/String;LDir;)V\n 137: astore 10\n 139: aload_3\n 140: aload 10\n 142: checkcast #140 // class Entry\n 145: invokevirtual #144 // Method Dir.add:(LEntry;)LEntry;\n 148: pop\n 149: aload 10\n 151: astore_3\n 152: goto 234\n 155: aload 8\n 157: checkcast #146 // class java/lang/CharSequence\n 160: aload_0\n 161: swap\n 162: invokevirtual #150 // Method kotlin/text/Regex.matches:(Ljava/lang/CharSequence;)Z\n 165: ifeq 234\n 168: aload_0\n 169: aload 8\n 171: checkcast #146 // class java/lang/CharSequence\n 174: invokevirtual #154 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;\n 177: astore 10\n 179: aload 10\n 181: ifnull 234\n 184: aload_3\n 185: new #156 // class File\n 188: dup\n 189: aload 10\n 191: invokeinterface #162, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 196: iconst_2\n 197: invokeinterface #166, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 202: checkcast #105 // class java/lang/String\n 205: aload 10\n 207: invokeinterface #162, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 212: iconst_1\n 213: invokeinterface #166, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 218: checkcast #105 // class java/lang/String\n 221: invokestatic #172 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 224: invokespecial #175 // Method File.\"<init>\":(Ljava/lang/String;I)V\n 227: checkcast #140 // class Entry\n 230: invokevirtual #144 // Method Dir.add:(LEntry;)LEntry;\n 233: pop\n 234: nop\n 235: nop\n 236: goto 42\n 239: nop\n 240: aload_2\n 241: areturn\n\n private static final int main$dirSizes(Dir, java.util.List<java.lang.Integer>);\n Code:\n 0: iconst_0\n 1: istore_2\n 2: aload_0\n 3: invokevirtual #195 // Method Dir.dirContent:()Ljava/util/List;\n 6: checkcast #83 // class java/lang/Iterable\n 9: astore_3\n 10: iconst_0\n 11: istore 4\n 13: aload_3\n 14: invokeinterface #93, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 19: astore 5\n 21: aload 5\n 23: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 28: ifeq 109\n 31: aload 5\n 33: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 38: astore 6\n 40: aload 6\n 42: checkcast #140 // class Entry\n 45: astore 7\n 47: iconst_0\n 48: istore 8\n 50: iload_2\n 51: aload 7\n 53: astore 9\n 55: aload 9\n 57: instanceof #156 // class File\n 60: ifeq 74\n 63: aload 7\n 65: checkcast #156 // class File\n 68: invokevirtual #199 // Method File.getSize:()I\n 71: goto 102\n 74: aload 9\n 76: instanceof #76 // class Dir\n 79: ifeq 94\n 82: aload 7\n 84: checkcast #76 // class Dir\n 87: aload_1\n 88: invokestatic #201 // Method main$dirSizes:(LDir;Ljava/util/List;)I\n 91: goto 102\n 94: new #203 // class kotlin/NoWhenBranchMatchedException\n 97: dup\n 98: invokespecial #205 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 101: athrow\n 102: iadd\n 103: istore_2\n 104: nop\n 105: nop\n 106: goto 21\n 109: nop\n 110: aload_1\n 111: checkcast #207 // class java/util/Collection\n 114: iload_2\n 115: invokestatic #211 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 118: invokeinterface #214, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 123: pop\n 124: iload_2\n 125: ireturn\n\n private static final int main$part1(kotlin.text.Regex, java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #223 // Method main$parseDirTree:(Lkotlin/text/Regex;Ljava/util/List;)LDir;\n 5: astore_2\n 6: new #225 // class java/util/ArrayList\n 9: dup\n 10: invokespecial #226 // Method java/util/ArrayList.\"<init>\":()V\n 13: checkcast #66 // class java/util/List\n 16: astore_3\n 17: aload_2\n 18: aload_3\n 19: invokestatic #201 // Method main$dirSizes:(LDir;Ljava/util/List;)I\n 22: pop\n 23: aload_3\n 24: checkcast #83 // class java/lang/Iterable\n 27: astore 4\n 29: iconst_0\n 30: istore 5\n 32: aload 4\n 34: astore 6\n 36: new #225 // class java/util/ArrayList\n 39: dup\n 40: invokespecial #226 // Method java/util/ArrayList.\"<init>\":()V\n 43: checkcast #207 // class java/util/Collection\n 46: astore 7\n 48: iconst_0\n 49: istore 8\n 51: aload 6\n 53: invokeinterface #93, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 58: astore 9\n 60: aload 9\n 62: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 67: ifeq 120\n 70: aload 9\n 72: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 77: astore 10\n 79: aload 10\n 81: checkcast #228 // class java/lang/Number\n 84: invokevirtual #231 // Method java/lang/Number.intValue:()I\n 87: istore 11\n 89: iconst_0\n 90: istore 12\n 92: iload 11\n 94: ldc #232 // int 100000\n 96: if_icmpgt 103\n 99: iconst_1\n 100: goto 104\n 103: iconst_0\n 104: ifeq 60\n 107: aload 7\n 109: aload 10\n 111: invokeinterface #214, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 116: pop\n 117: goto 60\n 120: aload 7\n 122: checkcast #66 // class java/util/List\n 125: nop\n 126: checkcast #83 // class java/lang/Iterable\n 129: invokestatic #236 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 132: ireturn\n\n private static final int main$part2(kotlin.text.Regex, java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #223 // Method main$parseDirTree:(Lkotlin/text/Regex;Ljava/util/List;)LDir;\n 5: astore_2\n 6: new #225 // class java/util/ArrayList\n 9: dup\n 10: invokespecial #226 // Method java/util/ArrayList.\"<init>\":()V\n 13: checkcast #66 // class java/util/List\n 16: astore_3\n 17: aload_2\n 18: aload_3\n 19: invokestatic #201 // Method main$dirSizes:(LDir;Ljava/util/List;)I\n 22: istore 4\n 24: ldc #247 // int 70000000\n 26: iload 4\n 28: isub\n 29: istore 5\n 31: ldc #248 // int 30000000\n 33: iload 5\n 35: isub\n 36: istore 6\n 38: aload_3\n 39: checkcast #83 // class java/lang/Iterable\n 42: astore 7\n 44: iconst_0\n 45: istore 8\n 47: aload 7\n 49: astore 9\n 51: new #225 // class java/util/ArrayList\n 54: dup\n 55: invokespecial #226 // Method java/util/ArrayList.\"<init>\":()V\n 58: checkcast #207 // class java/util/Collection\n 61: astore 10\n 63: iconst_0\n 64: istore 11\n 66: aload 9\n 68: invokeinterface #93, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 73: astore 12\n 75: aload 12\n 77: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 82: ifeq 135\n 85: aload 12\n 87: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 92: astore 13\n 94: aload 13\n 96: checkcast #228 // class java/lang/Number\n 99: invokevirtual #231 // Method java/lang/Number.intValue:()I\n 102: istore 14\n 104: iconst_0\n 105: istore 15\n 107: iload 14\n 109: iload 6\n 111: if_icmplt 118\n 114: iconst_1\n 115: goto 119\n 118: iconst_0\n 119: ifeq 75\n 122: aload 10\n 124: aload 13\n 126: invokeinterface #214, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 131: pop\n 132: goto 75\n 135: aload 10\n 137: checkcast #66 // class java/util/List\n 140: nop\n 141: checkcast #83 // class java/lang/Iterable\n 144: invokestatic #252 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;\n 147: iconst_0\n 148: invokeinterface #166, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 153: checkcast #228 // class java/lang/Number\n 156: invokevirtual #231 // Method java/lang/Number.intValue:()I\n 159: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day07.class",
"javap": "Compiled from \"Day07.kt\"\npublic final class Day07 {\n public static final Day07 INSTANCE;\n\n public static final int EXPECTED_PART1_CHECK_ANSWER;\n\n public static final int EXPECTED_PART2_CHECK_ANSWER;\n\n public static final int DIR_SIZE_THRESHOLD;\n\n public static final int FS_TOTAL_SIZE;\n\n public static final int FS_NEEDED_FREE_SPACE;\n\n private Day07();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n static {};\n Code:\n 0: new #2 // class Day07\n 3: dup\n 4: invokespecial #12 // Method \"<init>\":()V\n 7: putstatic #15 // Field INSTANCE:LDay07;\n 10: return\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day10.kt
|
object Day10 {
const val EXPECTED_PART1_CHECK_ANSWER = 13140
const val EXPECTED_PART2_CHECK_ANSWER = 1
val CYCLE_PROBE_POINTS = listOf(20, 60, 100, 140, 180, 220)
const val CRT_LINE_WIDTH = 40
}
sealed class CpuInstruction(val cycles: Int)
class Noop : CpuInstruction(1)
class AddX(val arg: Int) : CpuInstruction(2)
class Cpu(val instructions: List<CpuInstruction>) : ClockListener {
private var instructionPointer: Int = 0
private var instructionCyclesDone: Int = 0
private val x: MutableList<Int> = mutableListOf(1)
fun isDone() = instructionPointer >= instructions.size
fun xAtCycle(cycle: Int) = x[cycle - 1]
fun x() = x.last()
override fun tickStart(cycle: Int) {
// NOOP
}
override fun tickEnd(cycle: Int) {
instructionCyclesDone++
val currentXValue = if (x.isEmpty()) 1 else x.last()
when (val currentInstruction = instructions[instructionPointer]) {
is Noop -> {
x.add(currentXValue)
instructionPointer++
instructionCyclesDone = 0
}
is AddX -> {
if (currentInstruction.cycles == instructionCyclesDone) {
x.addAll(listOf(currentXValue, currentXValue + currentInstruction.arg))
instructionPointer++
instructionCyclesDone = 0
}
}
}
}
}
class Crt(private val cpu: Cpu) : ClockListener {
override fun tickStart(cycle: Int) {
val crtPos = cycle - 1
val lineNumber = crtPos / Day10.CRT_LINE_WIDTH
val positionInLine = crtPos - lineNumber * Day10.CRT_LINE_WIDTH
print(if (positionInLine in (cpu.x() - 1)..(cpu.x() + 1)) "#" else ".")
if (crtPos > 0 && cycle % Day10.CRT_LINE_WIDTH == 0) println()
}
override fun tickEnd(cycle: Int) {
// NOOP
}
}
interface ClockListener {
fun tickStart(cycle: Int)
fun tickEnd(cycle: Int)
}
fun main() {
fun List<String>.parseInstructions(): List<CpuInstruction> =
map { it.split(" ") }.map {
when (it[0]) {
"noop" -> Noop()
"addx" -> AddX(it[1].toInt())
else -> error("Unknown operation ${it[0]}")
}
}
fun part1(input: List<String>): Int {
val cpu = Cpu(input.parseInstructions())
var cycle = 1
while (!cpu.isDone()) {
cpu.tickStart(cycle)
cpu.tickEnd(cycle)
cycle++
}
return Day10.CYCLE_PROBE_POINTS.sumOf { cpu.xAtCycle(it) * it }
}
fun part2(input: List<String>): Int {
println("\n\n")
val cpu = Cpu(input.parseInstructions())
val crt = Crt(cpu)
var cycle = 1
while (!cpu.isDone()) {
cpu.tickStart(cycle)
crt.tickStart(cycle)
cpu.tickEnd(cycle)
crt.tickEnd(cycle)
cycle++
}
return 1
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day10_test")
check(part1(testInput) == Day10.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
check(part2(testInput) == Day10.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }
val input = readInput("Day10")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day10.class",
"javap": "Compiled from \"Day10.kt\"\npublic final class Day10 {\n public static final Day10 INSTANCE;\n\n public static final int EXPECTED_PART1_CHECK_ANSWER;\n\n public static final int EXPECTED_PART2_CHECK_ANSWER;\n\n private static final java.util.List<java.lang.Integer> CYCLE_PROBE_POINTS;\n\n public static final int CRT_LINE_WIDTH;\n\n private Day10();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final java.util.List<java.lang.Integer> getCYCLE_PROBE_POINTS();\n Code:\n 0: getstatic #18 // Field CYCLE_PROBE_POINTS:Ljava/util/List;\n 3: areturn\n\n static {};\n Code:\n 0: new #2 // class Day10\n 3: dup\n 4: invokespecial #20 // Method \"<init>\":()V\n 7: putstatic #23 // Field INSTANCE:LDay10;\n 10: bipush 6\n 12: anewarray #25 // class java/lang/Integer\n 15: astore_0\n 16: aload_0\n 17: iconst_0\n 18: bipush 20\n 20: invokestatic #29 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 23: aastore\n 24: aload_0\n 25: iconst_1\n 26: bipush 60\n 28: invokestatic #29 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 31: aastore\n 32: aload_0\n 33: iconst_2\n 34: bipush 100\n 36: invokestatic #29 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 39: aastore\n 40: aload_0\n 41: iconst_3\n 42: sipush 140\n 45: invokestatic #29 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 48: aastore\n 49: aload_0\n 50: iconst_4\n 51: sipush 180\n 54: invokestatic #29 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 57: aastore\n 58: aload_0\n 59: iconst_5\n 60: sipush 220\n 63: invokestatic #29 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 66: aastore\n 67: aload_0\n 68: invokestatic #35 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 71: putstatic #18 // Field CYCLE_PROBE_POINTS:Ljava/util/List;\n 74: return\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/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 41\n 24: iconst_0\n 25: istore_2\n 26: ldc #20 // String Part 1 failed\n 28: astore_2\n 29: new #22 // class java/lang/IllegalStateException\n 32: dup\n 33: aload_2\n 34: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 37: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 40: athrow\n 41: aload_0\n 42: invokestatic #33 // Method main$part2:(Ljava/util/List;)I\n 45: iconst_1\n 46: if_icmpne 53\n 49: iconst_1\n 50: goto 54\n 53: iconst_0\n 54: ifne 74\n 57: iconst_0\n 58: istore_2\n 59: ldc #35 // String Part 2 failed\n 61: astore_2\n 62: new #22 // class java/lang/IllegalStateException\n 65: dup\n 66: aload_2\n 67: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 70: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 73: athrow\n 74: ldc #37 // String Day10\n 76: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 79: astore_1\n 80: aload_1\n 81: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 84: istore_2\n 85: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 88: iload_2\n 89: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 92: aload_1\n 93: invokestatic #33 // Method main$part2:(Ljava/util/List;)I\n 96: istore_2\n 97: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 100: iload_2\n 101: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 104: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #60 // Method main:()V\n 3: return\n\n private static final java.util.List<CpuInstruction> main$parseInstructions(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #67 // 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 #69 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #75 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #79 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 110\n 48: aload 6\n 50: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #95 // class java/lang/String\n 64: astore 8\n 66: astore 11\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: checkcast #97 // class java/lang/CharSequence\n 76: iconst_1\n 77: anewarray #95 // class java/lang/String\n 80: astore 10\n 82: aload 10\n 84: iconst_0\n 85: ldc #99 // String\n 87: aastore\n 88: aload 10\n 90: iconst_0\n 91: iconst_0\n 92: bipush 6\n 94: aconst_null\n 95: invokestatic #105 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 98: aload 11\n 100: swap\n 101: invokeinterface #109, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 106: pop\n 107: goto 38\n 110: aload 4\n 112: checkcast #57 // class java/util/List\n 115: nop\n 116: checkcast #67 // class java/lang/Iterable\n 119: astore_1\n 120: nop\n 121: iconst_0\n 122: istore_2\n 123: aload_1\n 124: astore_3\n 125: new #69 // class java/util/ArrayList\n 128: dup\n 129: aload_1\n 130: bipush 10\n 132: invokestatic #75 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 135: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 138: checkcast #79 // class java/util/Collection\n 141: astore 4\n 143: iconst_0\n 144: istore 5\n 146: aload_3\n 147: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 152: astore 6\n 154: aload 6\n 156: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 161: ifeq 313\n 164: aload 6\n 166: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 171: astore 7\n 173: aload 4\n 175: aload 7\n 177: checkcast #57 // class java/util/List\n 180: astore 8\n 182: astore 11\n 184: iconst_0\n 185: istore 9\n 187: aload 8\n 189: iconst_0\n 190: invokeinterface #113, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 195: checkcast #95 // class java/lang/String\n 198: astore 10\n 200: aload 10\n 202: ldc #115 // String noop\n 204: invokestatic #121 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 207: ifeq 223\n 210: new #123 // class Noop\n 213: dup\n 214: invokespecial #125 // Method Noop.\"<init>\":()V\n 217: checkcast #127 // class CpuInstruction\n 220: goto 300\n 223: aload 10\n 225: ldc #129 // String addx\n 227: invokestatic #121 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 230: ifeq 260\n 233: new #131 // class AddX\n 236: dup\n 237: aload 8\n 239: iconst_1\n 240: invokeinterface #113, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 245: checkcast #95 // class java/lang/String\n 248: invokestatic #137 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 251: invokespecial #138 // Method AddX.\"<init>\":(I)V\n 254: checkcast #127 // class CpuInstruction\n 257: goto 300\n 260: new #22 // class java/lang/IllegalStateException\n 263: dup\n 264: new #140 // class java/lang/StringBuilder\n 267: dup\n 268: invokespecial #141 // Method java/lang/StringBuilder.\"<init>\":()V\n 271: ldc #143 // String Unknown operation\n 273: invokevirtual #147 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 276: aload 8\n 278: iconst_0\n 279: invokeinterface #113, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 284: checkcast #95 // class java/lang/String\n 287: invokevirtual #147 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 290: invokevirtual #148 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 293: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 296: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 299: athrow\n 300: nop\n 301: aload 11\n 303: swap\n 304: invokeinterface #109, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 309: pop\n 310: goto 154\n 313: aload 4\n 315: checkcast #57 // class java/util/List\n 318: nop\n 319: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: new #165 // class Cpu\n 3: dup\n 4: aload_0\n 5: invokestatic #167 // Method main$parseInstructions:(Ljava/util/List;)Ljava/util/List;\n 8: invokespecial #170 // Method Cpu.\"<init>\":(Ljava/util/List;)V\n 11: astore_1\n 12: iconst_1\n 13: istore_2\n 14: aload_1\n 15: invokevirtual #173 // Method Cpu.isDone:()Z\n 18: ifne 37\n 21: aload_1\n 22: iload_2\n 23: invokevirtual #176 // Method Cpu.tickStart:(I)V\n 26: aload_1\n 27: iload_2\n 28: invokevirtual #179 // Method Cpu.tickEnd:(I)V\n 31: iinc 2, 1\n 34: goto 14\n 37: getstatic #184 // Field Day10.INSTANCE:LDay10;\n 40: invokevirtual #188 // Method Day10.getCYCLE_PROBE_POINTS:()Ljava/util/List;\n 43: checkcast #67 // class java/lang/Iterable\n 46: astore_3\n 47: iconst_0\n 48: istore 4\n 50: aload_3\n 51: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 56: astore 5\n 58: aload 5\n 60: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 65: ifeq 115\n 68: aload 5\n 70: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 75: astore 6\n 77: iload 4\n 79: aload 6\n 81: checkcast #190 // class java/lang/Number\n 84: invokevirtual #194 // Method java/lang/Number.intValue:()I\n 87: istore 7\n 89: istore 9\n 91: iconst_0\n 92: istore 8\n 94: aload_1\n 95: iload 7\n 97: invokevirtual #198 // Method Cpu.xAtCycle:(I)I\n 100: iload 7\n 102: imul\n 103: istore 10\n 105: iload 9\n 107: iload 10\n 109: iadd\n 110: istore 4\n 112: goto 58\n 115: iload 4\n 117: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: ldc #204 // String \\n\\n\n 2: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 5: swap\n 6: invokevirtual #207 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 9: new #165 // class Cpu\n 12: dup\n 13: aload_0\n 14: invokestatic #167 // Method main$parseInstructions:(Ljava/util/List;)Ljava/util/List;\n 17: invokespecial #170 // Method Cpu.\"<init>\":(Ljava/util/List;)V\n 20: astore_1\n 21: new #209 // class Crt\n 24: dup\n 25: aload_1\n 26: invokespecial #212 // Method Crt.\"<init>\":(LCpu;)V\n 29: astore_2\n 30: iconst_1\n 31: istore_3\n 32: aload_1\n 33: invokevirtual #173 // Method Cpu.isDone:()Z\n 36: ifne 65\n 39: aload_1\n 40: iload_3\n 41: invokevirtual #176 // Method Cpu.tickStart:(I)V\n 44: aload_2\n 45: iload_3\n 46: invokevirtual #213 // Method Crt.tickStart:(I)V\n 49: aload_1\n 50: iload_3\n 51: invokevirtual #179 // Method Cpu.tickEnd:(I)V\n 54: aload_2\n 55: iload_3\n 56: invokevirtual #214 // Method Crt.tickEnd:(I)V\n 59: iinc 3, 1\n 62: goto 32\n 65: iconst_1\n 66: ireturn\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day06.kt
|
import kotlin.system.measureNanoTime
object Day06 {
const val EXPECTED_PART1_CHECK_ANSWER = 7
const val EXPECTED_PART2_CHECK_ANSWER = 19
const val MARKER_PACKET_LENGTH = 4
const val MARKER_MESSAGE_LENGTH = 14
}
fun main() {
fun String.findLengthUntilMarker(markerLength: Int): Int {
var pointerInData = 0
var potentialMarker = ""
do {
when (val indexOfDuplicate = potentialMarker.indexOf(this[pointerInData])) {
-1 -> potentialMarker += this[pointerInData]
else -> potentialMarker = potentialMarker.drop(indexOfDuplicate + 1) + this[pointerInData]
}
pointerInData++
} while (potentialMarker.length < markerLength && pointerInData < this.length)
return pointerInData
}
fun String.findLengthUntilMarkerWindowed(markerLength: Int) =
windowedSequence(markerLength) { it.toSet().size }.indexOfFirst { it == markerLength } + markerLength
fun part1(input: List<String>): Int {
val windowedDuration = measureNanoTime {
input.first().findLengthUntilMarkerWindowed(Day06.MARKER_PACKET_LENGTH)
}
val nonWindowedDuration = measureNanoTime {
input.first().findLengthUntilMarker(Day06.MARKER_PACKET_LENGTH)
}
println("Windowed: $windowedDuration, Non windowed: $nonWindowedDuration")
return input.first().findLengthUntilMarkerWindowed(Day06.MARKER_PACKET_LENGTH)
}
fun part2(input: List<String>): Int {
val windowedDuration = measureNanoTime {
input.first().findLengthUntilMarkerWindowed(Day06.MARKER_MESSAGE_LENGTH)
}
val nonWindowedDuration = measureNanoTime {
input.first().findLengthUntilMarker(Day06.MARKER_MESSAGE_LENGTH)
}
println("Windowed: $windowedDuration, Non windowed: $nonWindowedDuration")
return input.first().findLengthUntilMarkerWindowed(Day06.MARKER_MESSAGE_LENGTH)
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day06_test")
check(part1(testInput) == Day06.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
check(part2(testInput) == Day06.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }
val input = readInput("Day06")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day06Kt.class",
"javap": "Compiled from \"Day06.kt\"\npublic final class Day06Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day06_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 10: bipush 7\n 12: if_icmpne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 40\n 23: iconst_0\n 24: istore_2\n 25: ldc #20 // String Part 1 failed\n 27: astore_2\n 28: new #22 // class java/lang/IllegalStateException\n 31: dup\n 32: aload_2\n 33: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 36: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 39: athrow\n 40: aload_0\n 41: invokestatic #33 // Method main$part2:(Ljava/util/List;)I\n 44: bipush 19\n 46: if_icmpne 53\n 49: iconst_1\n 50: goto 54\n 53: iconst_0\n 54: ifne 74\n 57: iconst_0\n 58: istore_2\n 59: ldc #35 // String Part 2 failed\n 61: astore_2\n 62: new #22 // class java/lang/IllegalStateException\n 65: dup\n 66: aload_2\n 67: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 70: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 73: athrow\n 74: ldc #37 // String Day06\n 76: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 79: astore_1\n 80: aload_1\n 81: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 84: istore_2\n 85: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 88: iload_2\n 89: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 92: aload_1\n 93: invokestatic #33 // Method main$part2:(Ljava/util/List;)I\n 96: istore_2\n 97: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 100: iload_2\n 101: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 104: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #60 // Method main:()V\n 3: return\n\n private static final int main$findLengthUntilMarker(java.lang.String, int);\n Code:\n 0: iconst_0\n 1: istore_2\n 2: ldc #66 // String\n 4: astore_3\n 5: aload_3\n 6: checkcast #68 // class java/lang/CharSequence\n 9: aload_0\n 10: iload_2\n 11: invokevirtual #74 // Method java/lang/String.charAt:(I)C\n 14: iconst_0\n 15: iconst_0\n 16: bipush 6\n 18: aconst_null\n 19: invokestatic #80 // Method kotlin/text/StringsKt.indexOf$default:(Ljava/lang/CharSequence;CIZILjava/lang/Object;)I\n 22: istore 4\n 24: iload 4\n 26: iconst_m1\n 27: if_icmpne 56\n 30: new #82 // class java/lang/StringBuilder\n 33: dup\n 34: invokespecial #84 // Method java/lang/StringBuilder.\"<init>\":()V\n 37: aload_3\n 38: invokevirtual #88 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 41: aload_0\n 42: iload_2\n 43: invokevirtual #74 // Method java/lang/String.charAt:(I)C\n 46: invokevirtual #91 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 49: invokevirtual #92 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 52: astore_3\n 53: goto 86\n 56: new #82 // class java/lang/StringBuilder\n 59: dup\n 60: invokespecial #84 // Method java/lang/StringBuilder.\"<init>\":()V\n 63: aload_3\n 64: iload 4\n 66: iconst_1\n 67: iadd\n 68: invokestatic #96 // Method kotlin/text/StringsKt.drop:(Ljava/lang/String;I)Ljava/lang/String;\n 71: invokevirtual #88 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 74: aload_0\n 75: iload_2\n 76: invokevirtual #74 // Method java/lang/String.charAt:(I)C\n 79: invokevirtual #91 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 82: invokevirtual #92 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 85: astore_3\n 86: iinc 2, 1\n 89: aload_3\n 90: invokevirtual #100 // Method java/lang/String.length:()I\n 93: iload_1\n 94: if_icmpge 105\n 97: iload_2\n 98: aload_0\n 99: invokevirtual #100 // Method java/lang/String.length:()I\n 102: if_icmplt 5\n 105: iload_2\n 106: ireturn\n\n private static final int main$findLengthUntilMarkerWindowed$lambda$0(java.lang.CharSequence);\n Code:\n 0: aload_0\n 1: ldc #110 // String it\n 3: invokestatic #116 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #120 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 10: invokeinterface #125, 1 // InterfaceMethod java/util/Set.size:()I\n 15: ireturn\n\n private static final int main$findLengthUntilMarkerWindowed(java.lang.String, int);\n Code:\n 0: aload_0\n 1: checkcast #68 // class java/lang/CharSequence\n 4: iload_1\n 5: iconst_0\n 6: iconst_0\n 7: invokedynamic #145, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 12: bipush 6\n 14: aconst_null\n 15: invokestatic #149 // Method kotlin/text/StringsKt.windowedSequence$default:(Ljava/lang/CharSequence;IIZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 18: astore_2\n 19: iconst_0\n 20: istore_3\n 21: iconst_0\n 22: istore 4\n 24: aload_2\n 25: invokeinterface #155, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 30: astore 5\n 32: aload 5\n 34: invokeinterface #161, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 39: ifeq 97\n 42: aload 5\n 44: invokeinterface #165, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 49: astore 6\n 51: iload 4\n 53: ifge 59\n 56: invokestatic #170 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 59: aload 6\n 61: checkcast #172 // class java/lang/Number\n 64: invokevirtual #175 // Method java/lang/Number.intValue:()I\n 67: istore 7\n 69: iconst_0\n 70: istore 8\n 72: iload 7\n 74: iload_1\n 75: if_icmpne 82\n 78: iconst_1\n 79: goto 83\n 82: iconst_0\n 83: ifeq 91\n 86: iload 4\n 88: goto 98\n 91: iinc 4, 1\n 94: goto 32\n 97: iconst_m1\n 98: iload_1\n 99: iadd\n 100: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: iconst_0\n 1: istore_3\n 2: invokestatic #188 // Method java/lang/System.nanoTime:()J\n 5: lstore 4\n 7: iconst_0\n 8: istore 6\n 10: aload_0\n 11: invokestatic #192 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 14: checkcast #70 // class java/lang/String\n 17: iconst_4\n 18: invokestatic #194 // Method main$findLengthUntilMarkerWindowed:(Ljava/lang/String;I)I\n 21: pop\n 22: nop\n 23: nop\n 24: invokestatic #188 // Method java/lang/System.nanoTime:()J\n 27: lload 4\n 29: lsub\n 30: lstore_1\n 31: iconst_0\n 32: istore 5\n 34: invokestatic #188 // Method java/lang/System.nanoTime:()J\n 37: lstore 6\n 39: iconst_0\n 40: istore 8\n 42: aload_0\n 43: invokestatic #192 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 46: checkcast #70 // class java/lang/String\n 49: iconst_4\n 50: invokestatic #196 // Method main$findLengthUntilMarker:(Ljava/lang/String;I)I\n 53: pop\n 54: nop\n 55: nop\n 56: invokestatic #188 // Method java/lang/System.nanoTime:()J\n 59: lload 6\n 61: lsub\n 62: lstore_3\n 63: new #82 // class java/lang/StringBuilder\n 66: dup\n 67: invokespecial #84 // Method java/lang/StringBuilder.\"<init>\":()V\n 70: ldc #198 // String Windowed:\n 72: invokevirtual #88 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 75: lload_1\n 76: invokevirtual #201 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 79: ldc #203 // String , Non windowed:\n 81: invokevirtual #88 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 84: lload_3\n 85: invokevirtual #201 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 88: invokevirtual #92 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 91: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 94: swap\n 95: invokevirtual #206 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 98: aload_0\n 99: invokestatic #192 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 102: checkcast #70 // class java/lang/String\n 105: iconst_4\n 106: invokestatic #194 // Method main$findLengthUntilMarkerWindowed:(Ljava/lang/String;I)I\n 109: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: iconst_0\n 1: istore_3\n 2: invokestatic #188 // Method java/lang/System.nanoTime:()J\n 5: lstore 4\n 7: iconst_0\n 8: istore 6\n 10: aload_0\n 11: invokestatic #192 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 14: checkcast #70 // class java/lang/String\n 17: bipush 14\n 19: invokestatic #194 // Method main$findLengthUntilMarkerWindowed:(Ljava/lang/String;I)I\n 22: pop\n 23: nop\n 24: nop\n 25: invokestatic #188 // Method java/lang/System.nanoTime:()J\n 28: lload 4\n 30: lsub\n 31: lstore_1\n 32: iconst_0\n 33: istore 5\n 35: invokestatic #188 // Method java/lang/System.nanoTime:()J\n 38: lstore 6\n 40: iconst_0\n 41: istore 8\n 43: aload_0\n 44: invokestatic #192 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 47: checkcast #70 // class java/lang/String\n 50: bipush 14\n 52: invokestatic #196 // Method main$findLengthUntilMarker:(Ljava/lang/String;I)I\n 55: pop\n 56: nop\n 57: nop\n 58: invokestatic #188 // Method java/lang/System.nanoTime:()J\n 61: lload 6\n 63: lsub\n 64: lstore_3\n 65: new #82 // class java/lang/StringBuilder\n 68: dup\n 69: invokespecial #84 // Method java/lang/StringBuilder.\"<init>\":()V\n 72: ldc #198 // String Windowed:\n 74: invokevirtual #88 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 77: lload_1\n 78: invokevirtual #201 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 81: ldc #203 // String , Non windowed:\n 83: invokevirtual #88 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 86: lload_3\n 87: invokevirtual #201 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 90: invokevirtual #92 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 93: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 96: swap\n 97: invokevirtual #206 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 100: aload_0\n 101: invokestatic #192 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 104: checkcast #70 // class java/lang/String\n 107: bipush 14\n 109: invokestatic #194 // Method main$findLengthUntilMarkerWindowed:(Ljava/lang/String;I)I\n 112: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day06.class",
"javap": "Compiled from \"Day06.kt\"\npublic final class Day06 {\n public static final Day06 INSTANCE;\n\n public static final int EXPECTED_PART1_CHECK_ANSWER;\n\n public static final int EXPECTED_PART2_CHECK_ANSWER;\n\n public static final int MARKER_PACKET_LENGTH;\n\n public static final int MARKER_MESSAGE_LENGTH;\n\n private Day06();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n static {};\n Code:\n 0: new #2 // class Day06\n 3: dup\n 4: invokespecial #12 // Method \"<init>\":()V\n 7: putstatic #15 // Field INSTANCE:LDay06;\n 10: return\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day12.kt
|
import java.util.LinkedList
object Day12 {
const val EXPECTED_PART1_CHECK_ANSWER = 31
const val EXPECTED_PART2_CHECK_ANSWER = 29
const val CHAR_START = 'S'
const val CHAR_DESTINATION = 'E'
const val CHAR_LOWEST = 'a'
}
fun main() {
fun List<String>.parseData(): Array<CharArray> =
map { it.toCharArray() }.toTypedArray()
fun Array<CharArray>.findLocationOfChar(char: Char) =
this.indexOfFirst { it.contains(char) }.let { vertIndex -> Location(this[vertIndex].indexOf(char), vertIndex) }
fun Array<CharArray>.findLocationsOfChar(char: Char): List<Location> {
val locationsOfChar = mutableListOf<Location>()
this.forEachIndexed { yIndex, listOfChars ->
listOfChars.forEachIndexed { xIndex, possibleChar ->
if (char == possibleChar) {
locationsOfChar.add(Location(xIndex, yIndex))
}
}
}
return locationsOfChar
}
fun Array<CharArray>.getValueAt(location: Location) = this[location.y][location.x]
fun Array<CharArray>.width() = this[0].size
fun Array<CharArray>.height() = this.size
fun Char.mapToHeightValue() = when (this) {
Day12.CHAR_START -> 'a'
Day12.CHAR_DESTINATION -> 'z'
else -> this
}
fun findShortestPath(grid: Array<CharArray>, start: Location): Int {
val destination = grid.findLocationOfChar('E')
val queue = LinkedList<Pair<Location, Int>>()
val visited = mutableSetOf<Location>()
queue.add(start to 0)
visited.add(start)
do {
val locationAndDistance = queue.remove()
val locationHeight = grid.getValueAt(locationAndDistance.first).mapToHeightValue()
if (locationAndDistance.first == destination) {
return locationAndDistance.second
}
val adjCells = listOf(
Location(locationAndDistance.first.x - 1, locationAndDistance.first.y),
Location(locationAndDistance.first.x + 1, locationAndDistance.first.y),
Location(locationAndDistance.first.x, locationAndDistance.first.y - 1),
Location(locationAndDistance.first.x, locationAndDistance.first.y + 1),
).filter { it.x >= 0 && it.y >= 0 && it.x < grid.width() && it.y < grid.height() }
for (adjLocation in adjCells) {
val height = grid.getValueAt(adjLocation).mapToHeightValue()
if ((height - locationHeight <= 1) && !visited.contains(
adjLocation
)
) {
queue.add(adjLocation to locationAndDistance.second + 1)
visited.add(adjLocation)
}
}
} while (queue.isNotEmpty())
return -1
}
fun part1(input: List<String>): Int {
val grid = input.parseData()
return findShortestPath(grid, grid.findLocationOfChar(Day12.CHAR_START))
}
fun part2(input: List<String>): Int {
val grid = input.parseData()
val locationsOfLowest = grid.findLocationsOfChar(Day12.CHAR_LOWEST) + grid.findLocationOfChar(Day12.CHAR_START)
return locationsOfLowest.map { findShortestPath(grid, it) }.filter { it != -1 }.also { println(it) }.min()
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day12_test")
check(part1(testInput) == Day12.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
check(part2(testInput) == Day12.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }
val input = readInput("Day12")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day12.class",
"javap": "Compiled from \"Day12.kt\"\npublic final class Day12 {\n public static final Day12 INSTANCE;\n\n public static final int EXPECTED_PART1_CHECK_ANSWER;\n\n public static final int EXPECTED_PART2_CHECK_ANSWER;\n\n public static final char CHAR_START;\n\n public static final char CHAR_DESTINATION;\n\n public static final char CHAR_LOWEST;\n\n private Day12();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n static {};\n Code:\n 0: new #2 // class Day12\n 3: dup\n 4: invokespecial #12 // Method \"<init>\":()V\n 7: putstatic #15 // Field INSTANCE:LDay12;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day12Kt.class",
"javap": "Compiled from \"Day12.kt\"\npublic final class Day12Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day12_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 10: bipush 31\n 12: if_icmpne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 40\n 23: iconst_0\n 24: istore_2\n 25: ldc #20 // String Part 1 failed\n 27: astore_2\n 28: new #22 // class java/lang/IllegalStateException\n 31: dup\n 32: aload_2\n 33: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 36: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 39: athrow\n 40: aload_0\n 41: invokestatic #33 // Method main$part2:(Ljava/util/List;)I\n 44: bipush 29\n 46: if_icmpne 53\n 49: iconst_1\n 50: goto 54\n 53: iconst_0\n 54: ifne 74\n 57: iconst_0\n 58: istore_2\n 59: ldc #35 // String Part 2 failed\n 61: astore_2\n 62: new #22 // class java/lang/IllegalStateException\n 65: dup\n 66: aload_2\n 67: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 70: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 73: athrow\n 74: ldc #37 // String Day12\n 76: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 79: astore_1\n 80: aload_1\n 81: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 84: istore_2\n 85: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 88: iload_2\n 89: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 92: aload_1\n 93: invokestatic #33 // Method main$part2:(Ljava/util/List;)I\n 96: istore_2\n 97: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 100: iload_2\n 101: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 104: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #60 // Method main:()V\n 3: return\n\n private static final char[][] main$parseData(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #67 // 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 #69 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #75 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #79 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 95\n 48: aload 6\n 50: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #95 // 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: invokevirtual #99 // Method java/lang/String.toCharArray:()[C\n 76: dup\n 77: ldc #101 // String toCharArray(...)\n 79: invokestatic #107 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 82: nop\n 83: aload 10\n 85: swap\n 86: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 91: pop\n 92: goto 38\n 95: aload 4\n 97: checkcast #57 // class java/util/List\n 100: nop\n 101: checkcast #79 // class java/util/Collection\n 104: astore_1\n 105: nop\n 106: iconst_0\n 107: istore_2\n 108: aload_1\n 109: astore_3\n 110: aload_3\n 111: iconst_0\n 112: anewarray #113 // class \"[C\"\n 115: invokeinterface #117, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 120: checkcast #119 // class \"[[C\"\n 123: areturn\n\n private static final Location main$findLocationOfChar(char[][], char);\n Code:\n 0: aload_0\n 1: checkcast #139 // class \"[Ljava/lang/Object;\"\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: arraylength\n 12: istore 5\n 14: iload 4\n 16: iload 5\n 18: if_icmpge 53\n 21: aload_2\n 22: iload 4\n 24: aaload\n 25: checkcast #113 // class \"[C\"\n 28: astore 6\n 30: iconst_0\n 31: istore 7\n 33: aload 6\n 35: iload_1\n 36: invokestatic #145 // Method kotlin/collections/ArraysKt.contains:([CC)Z\n 39: ifeq 47\n 42: iload 4\n 44: goto 54\n 47: iinc 4, 1\n 50: goto 14\n 53: iconst_m1\n 54: istore_3\n 55: iconst_0\n 56: istore 4\n 58: new #147 // class Location\n 61: dup\n 62: aload_0\n 63: iload_3\n 64: aaload\n 65: iload_1\n 66: invokestatic #151 // Method kotlin/collections/ArraysKt.indexOf:([CC)I\n 69: iload_3\n 70: invokespecial #154 // Method Location.\"<init>\":(II)V\n 73: nop\n 74: areturn\n\n private static final java.util.List<Location> main$findLocationsOfChar(char[][], char);\n Code:\n 0: new #69 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #168 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #57 // class java/util/List\n 10: astore_2\n 11: aload_0\n 12: checkcast #139 // class \"[Ljava/lang/Object;\"\n 15: astore_3\n 16: iconst_0\n 17: istore 4\n 19: iconst_0\n 20: istore 5\n 22: iconst_0\n 23: istore 6\n 25: aload_3\n 26: arraylength\n 27: istore 7\n 29: iload 6\n 31: iload 7\n 33: if_icmpge 146\n 36: aload_3\n 37: iload 6\n 39: aaload\n 40: astore 8\n 42: iload 5\n 44: iinc 5, 1\n 47: aload 8\n 49: checkcast #113 // class \"[C\"\n 52: astore 9\n 54: istore 10\n 56: iconst_0\n 57: istore 11\n 59: aload 9\n 61: astore 12\n 63: iconst_0\n 64: istore 13\n 66: iconst_0\n 67: istore 14\n 69: iconst_0\n 70: istore 15\n 72: aload 12\n 74: arraylength\n 75: istore 16\n 77: iload 15\n 79: iload 16\n 81: if_icmpge 137\n 84: aload 12\n 86: iload 15\n 88: caload\n 89: istore 17\n 91: iload 14\n 93: iinc 14, 1\n 96: iload 17\n 98: istore 18\n 100: istore 19\n 102: iconst_0\n 103: istore 20\n 105: iload_1\n 106: iload 18\n 108: if_icmpne 129\n 111: aload_2\n 112: new #147 // class Location\n 115: dup\n 116: iload 19\n 118: iload 10\n 120: invokespecial #154 // Method Location.\"<init>\":(II)V\n 123: invokeinterface #169, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 128: pop\n 129: nop\n 130: nop\n 131: iinc 15, 1\n 134: goto 77\n 137: nop\n 138: nop\n 139: nop\n 140: iinc 6, 1\n 143: goto 29\n 146: nop\n 147: aload_2\n 148: areturn\n\n private static final char main$getValueAt(char[][], Location);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokevirtual #186 // Method Location.getY:()I\n 5: aaload\n 6: aload_1\n 7: invokevirtual #189 // Method Location.getX:()I\n 10: caload\n 11: ireturn\n\n private static final int main$width(char[][]);\n Code:\n 0: aload_0\n 1: iconst_0\n 2: aaload\n 3: arraylength\n 4: ireturn\n\n private static final int main$height(char[][]);\n Code:\n 0: aload_0\n 1: checkcast #139 // class \"[Ljava/lang/Object;\"\n 4: arraylength\n 5: ireturn\n\n private static final char main$mapToHeightValue(char);\n Code:\n 0: iload_0\n 1: lookupswitch { // 2\n 69: 33\n 83: 28\n default: 38\n }\n 28: bipush 97\n 30: goto 39\n 33: bipush 122\n 35: goto 39\n 38: iload_0\n 39: ireturn\n\n private static final int main$findShortestPath(char[][], Location);\n Code:\n 0: aload_0\n 1: bipush 69\n 3: invokestatic #204 // Method main$findLocationOfChar:([[CC)LLocation;\n 6: astore_2\n 7: new #206 // class java/util/LinkedList\n 10: dup\n 11: invokespecial #207 // Method java/util/LinkedList.\"<init>\":()V\n 14: astore_3\n 15: new #209 // class java/util/LinkedHashSet\n 18: dup\n 19: invokespecial #210 // Method java/util/LinkedHashSet.\"<init>\":()V\n 22: checkcast #212 // class java/util/Set\n 25: astore 4\n 27: aload_3\n 28: aload_1\n 29: iconst_0\n 30: invokestatic #218 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 33: invokestatic #224 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 36: invokevirtual #225 // Method java/util/LinkedList.add:(Ljava/lang/Object;)Z\n 39: pop\n 40: aload 4\n 42: aload_1\n 43: invokeinterface #226, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 48: pop\n 49: aload_3\n 50: invokevirtual #229 // Method java/util/LinkedList.remove:()Ljava/lang/Object;\n 53: checkcast #231 // class kotlin/Pair\n 56: astore 5\n 58: aload_0\n 59: aload 5\n 61: invokevirtual #234 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 64: checkcast #147 // class Location\n 67: invokestatic #236 // Method main$getValueAt:([[CLLocation;)C\n 70: invokestatic #238 // Method main$mapToHeightValue:(C)C\n 73: istore 6\n 75: aload 5\n 77: invokevirtual #234 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 80: aload_2\n 81: invokestatic #242 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 84: ifeq 99\n 87: aload 5\n 89: invokevirtual #245 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 92: checkcast #247 // class java/lang/Number\n 95: invokevirtual #250 // Method java/lang/Number.intValue:()I\n 98: ireturn\n 99: iconst_4\n 100: anewarray #147 // class Location\n 103: astore 8\n 105: aload 8\n 107: iconst_0\n 108: new #147 // class Location\n 111: dup\n 112: aload 5\n 114: invokevirtual #234 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 117: checkcast #147 // class Location\n 120: invokevirtual #189 // Method Location.getX:()I\n 123: iconst_1\n 124: isub\n 125: aload 5\n 127: invokevirtual #234 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 130: checkcast #147 // class Location\n 133: invokevirtual #186 // Method Location.getY:()I\n 136: invokespecial #154 // Method Location.\"<init>\":(II)V\n 139: aastore\n 140: aload 8\n 142: iconst_1\n 143: new #147 // class Location\n 146: dup\n 147: aload 5\n 149: invokevirtual #234 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 152: checkcast #147 // class Location\n 155: invokevirtual #189 // Method Location.getX:()I\n 158: iconst_1\n 159: iadd\n 160: aload 5\n 162: invokevirtual #234 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 165: checkcast #147 // class Location\n 168: invokevirtual #186 // Method Location.getY:()I\n 171: invokespecial #154 // Method Location.\"<init>\":(II)V\n 174: aastore\n 175: aload 8\n 177: iconst_2\n 178: new #147 // class Location\n 181: dup\n 182: aload 5\n 184: invokevirtual #234 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 187: checkcast #147 // class Location\n 190: invokevirtual #189 // Method Location.getX:()I\n 193: aload 5\n 195: invokevirtual #234 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 198: checkcast #147 // class Location\n 201: invokevirtual #186 // Method Location.getY:()I\n 204: iconst_1\n 205: isub\n 206: invokespecial #154 // Method Location.\"<init>\":(II)V\n 209: aastore\n 210: aload 8\n 212: iconst_3\n 213: new #147 // class Location\n 216: dup\n 217: aload 5\n 219: invokevirtual #234 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 222: checkcast #147 // class Location\n 225: invokevirtual #189 // Method Location.getX:()I\n 228: aload 5\n 230: invokevirtual #234 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 233: checkcast #147 // class Location\n 236: invokevirtual #186 // Method Location.getY:()I\n 239: iconst_1\n 240: iadd\n 241: invokespecial #154 // Method Location.\"<init>\":(II)V\n 244: aastore\n 245: aload 8\n 247: invokestatic #254 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 250: checkcast #67 // class java/lang/Iterable\n 253: astore 8\n 255: nop\n 256: iconst_0\n 257: istore 9\n 259: aload 8\n 261: astore 10\n 263: new #69 // class java/util/ArrayList\n 266: dup\n 267: invokespecial #168 // Method java/util/ArrayList.\"<init>\":()V\n 270: checkcast #79 // class java/util/Collection\n 273: astore 11\n 275: iconst_0\n 276: istore 12\n 278: aload 10\n 280: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 285: astore 13\n 287: aload 13\n 289: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 294: ifeq 377\n 297: aload 13\n 299: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 304: astore 14\n 306: aload 14\n 308: checkcast #147 // class Location\n 311: astore 15\n 313: iconst_0\n 314: istore 16\n 316: aload 15\n 318: invokevirtual #189 // Method Location.getX:()I\n 321: iflt 360\n 324: aload 15\n 326: invokevirtual #186 // Method Location.getY:()I\n 329: iflt 360\n 332: aload 15\n 334: invokevirtual #189 // Method Location.getX:()I\n 337: aload_0\n 338: invokestatic #256 // Method main$width:([[C)I\n 341: if_icmpge 360\n 344: aload 15\n 346: invokevirtual #186 // Method Location.getY:()I\n 349: aload_0\n 350: invokestatic #258 // Method main$height:([[C)I\n 353: if_icmpge 360\n 356: iconst_1\n 357: goto 361\n 360: iconst_0\n 361: ifeq 287\n 364: aload 11\n 366: aload 14\n 368: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 373: pop\n 374: goto 287\n 377: aload 11\n 379: checkcast #57 // class java/util/List\n 382: nop\n 383: astore 7\n 385: aload 7\n 387: invokeinterface #259, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 392: astore 8\n 394: aload 8\n 396: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 401: ifeq 487\n 404: aload 8\n 406: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 411: checkcast #147 // class Location\n 414: astore 9\n 416: aload_0\n 417: aload 9\n 419: invokestatic #236 // Method main$getValueAt:([[CLLocation;)C\n 422: invokestatic #238 // Method main$mapToHeightValue:(C)C\n 425: istore 10\n 427: iload 10\n 429: iload 6\n 431: isub\n 432: iconst_1\n 433: if_icmpgt 394\n 436: aload 4\n 438: aload 9\n 440: invokeinterface #261, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 445: ifne 394\n 448: aload_3\n 449: aload 9\n 451: aload 5\n 453: invokevirtual #245 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 456: checkcast #247 // class java/lang/Number\n 459: invokevirtual #250 // Method java/lang/Number.intValue:()I\n 462: iconst_1\n 463: iadd\n 464: invokestatic #218 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 467: invokestatic #224 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 470: invokevirtual #225 // Method java/util/LinkedList.add:(Ljava/lang/Object;)Z\n 473: pop\n 474: aload 4\n 476: aload 9\n 478: invokeinterface #226, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 483: pop\n 484: goto 394\n 487: aload_3\n 488: checkcast #79 // class java/util/Collection\n 491: invokeinterface #264, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 496: ifne 503\n 499: iconst_1\n 500: goto 504\n 503: iconst_0\n 504: ifne 49\n 507: iconst_m1\n 508: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #286 // Method main$parseData:(Ljava/util/List;)[[C\n 4: astore_1\n 5: aload_1\n 6: aload_1\n 7: bipush 83\n 9: invokestatic #204 // Method main$findLocationOfChar:([[CC)LLocation;\n 12: invokestatic #288 // Method main$findShortestPath:([[CLLocation;)I\n 15: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #286 // Method main$parseData:(Ljava/util/List;)[[C\n 4: astore_1\n 5: aload_1\n 6: bipush 97\n 8: invokestatic #290 // Method main$findLocationsOfChar:([[CC)Ljava/util/List;\n 11: checkcast #79 // class java/util/Collection\n 14: aload_1\n 15: bipush 83\n 17: invokestatic #204 // Method main$findLocationOfChar:([[CC)LLocation;\n 20: invokestatic #294 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 23: astore_2\n 24: aload_2\n 25: checkcast #67 // class java/lang/Iterable\n 28: astore_3\n 29: iconst_0\n 30: istore 4\n 32: aload_3\n 33: astore 5\n 35: new #69 // class java/util/ArrayList\n 38: dup\n 39: aload_3\n 40: bipush 10\n 42: invokestatic #75 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 45: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 48: checkcast #79 // class java/util/Collection\n 51: astore 6\n 53: iconst_0\n 54: istore 7\n 56: aload 5\n 58: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 63: astore 8\n 65: aload 8\n 67: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 72: ifeq 119\n 75: aload 8\n 77: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 82: astore 9\n 84: aload 6\n 86: aload 9\n 88: checkcast #147 // class Location\n 91: astore 10\n 93: astore 12\n 95: iconst_0\n 96: istore 11\n 98: aload_1\n 99: aload 10\n 101: invokestatic #288 // Method main$findShortestPath:([[CLLocation;)I\n 104: invokestatic #218 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 107: aload 12\n 109: swap\n 110: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 115: pop\n 116: goto 65\n 119: aload 6\n 121: checkcast #57 // class java/util/List\n 124: nop\n 125: checkcast #67 // 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 #69 // class java/util/ArrayList\n 139: dup\n 140: invokespecial #168 // Method java/util/ArrayList.\"<init>\":()V\n 143: checkcast #79 // class java/util/Collection\n 146: astore 6\n 148: iconst_0\n 149: istore 7\n 151: aload 5\n 153: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 158: astore 8\n 160: aload 8\n 162: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 167: ifeq 219\n 170: aload 8\n 172: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 177: astore 9\n 179: aload 9\n 181: checkcast #247 // class java/lang/Number\n 184: invokevirtual #250 // Method java/lang/Number.intValue:()I\n 187: istore 10\n 189: iconst_0\n 190: istore 11\n 192: iload 10\n 194: iconst_m1\n 195: if_icmpeq 202\n 198: iconst_1\n 199: goto 203\n 202: iconst_0\n 203: ifeq 160\n 206: aload 6\n 208: aload 9\n 210: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 215: pop\n 216: goto 160\n 219: aload 6\n 221: checkcast #57 // class java/util/List\n 224: nop\n 225: astore_3\n 226: aload_3\n 227: astore 4\n 229: iconst_0\n 230: istore 5\n 232: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 235: aload 4\n 237: invokevirtual #297 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 240: nop\n 241: aload_3\n 242: checkcast #67 // class java/lang/Iterable\n 245: invokestatic #301 // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 248: checkcast #247 // class java/lang/Number\n 251: invokevirtual #250 // Method java/lang/Number.intValue:()I\n 254: ireturn\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day20.kt
|
import java.util.LinkedList
object Day20 {
const val EXPECTED_PART1_CHECK_ANSWER = 3
const val EXPECTED_PART2_CHECK_ANSWER = 1623178306L
val ANSWER_POSITIONS = setOf(1000, 2000, 3000)
const val DECRYPTION_KEY = 811589153L
}
fun main() {
fun List<String>.parse() = map(String::toLong).foldIndexed(LinkedList<Pair<Long, Int>>()) { idx, acc, nr ->
acc.add(nr to idx)
acc
}
fun LinkedList<Pair<Long, Int>>.mixIt(orgList: List<Pair<Long, Int>>) {
orgList.forEach { nrAndOrgIndex ->
val nr = nrAndOrgIndex.first
val currentIndex = indexOf(nrAndOrgIndex)
val uncappedNewIndex = currentIndex + nr
val moveToIndex = uncappedNewIndex.mod(lastIndex)
remove(nrAndOrgIndex)
add(moveToIndex, nrAndOrgIndex)
}
}
fun part1(input: List<String>): Int {
val numbers = input.parse()
val newList = LinkedList(numbers)
newList.mixIt(numbers)
println(newList)
val indexOfZero = newList.indexOf(newList.find { it.first == 0L })
val result = Day20.ANSWER_POSITIONS.sumOf {
val indexOfNr = indexOfZero + it
val wrappedIndex = indexOfNr % newList.size
newList[wrappedIndex].first
}
return result.toInt()
}
fun part2(input: List<String>): Long {
val numbers = input.parse().map { Pair(it.first * Day20.DECRYPTION_KEY, it.second) }
val newList = LinkedList(numbers)
repeat(10) { newList.mixIt(numbers) }
println(newList)
val indexOfZero = newList.indexOf(newList.find { it.first == 0L })
val result = Day20.ANSWER_POSITIONS.map(Int::toLong).sumOf {
val indexOfNr = indexOfZero + it
val wrappedIndex = indexOfNr % newList.size
newList[wrappedIndex.toInt()].first
}
return result
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day20_test")
check(part1(testInput) == Day20.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
check(part2(testInput) == Day20.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }
val input = readInput("Day20")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day20Kt.class",
"javap": "Compiled from \"Day20.kt\"\npublic final class Day20Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day20_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 10: iconst_3\n 11: if_icmpne 18\n 14: iconst_1\n 15: goto 19\n 18: iconst_0\n 19: ifne 39\n 22: iconst_0\n 23: istore_2\n 24: ldc #20 // String Part 1 failed\n 26: astore_2\n 27: new #22 // class java/lang/IllegalStateException\n 30: dup\n 31: aload_2\n 32: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 35: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 38: athrow\n 39: aload_0\n 40: invokestatic #34 // Method main$part2:(Ljava/util/List;)J\n 43: ldc2_w #35 // long 1623178306l\n 46: lcmp\n 47: ifne 54\n 50: iconst_1\n 51: goto 55\n 54: iconst_0\n 55: ifne 75\n 58: iconst_0\n 59: istore_2\n 60: ldc #38 // String Part 2 failed\n 62: astore_2\n 63: new #22 // class java/lang/IllegalStateException\n 66: dup\n 67: aload_2\n 68: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 71: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 74: athrow\n 75: ldc #40 // String Day20\n 77: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 80: astore_1\n 81: aload_1\n 82: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 85: istore_2\n 86: getstatic #46 // Field java/lang/System.out:Ljava/io/PrintStream;\n 89: iload_2\n 90: invokevirtual #52 // Method java/io/PrintStream.println:(I)V\n 93: aload_1\n 94: invokestatic #34 // Method main$part2:(Ljava/util/List;)J\n 97: lstore_2\n 98: getstatic #46 // Field java/lang/System.out:Ljava/io/PrintStream;\n 101: lload_2\n 102: invokevirtual #55 // Method java/io/PrintStream.println:(J)V\n 105: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #66 // Method main:()V\n 3: return\n\n private static final java.util.LinkedList<kotlin.Pair<java.lang.Long, java.lang.Integer>> main$parse(java.util.List<java.lang.String>);\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: astore_3\n 9: new #75 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #81 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #83 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #85 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 92\n 48: aload 6\n 50: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #101 // class java/lang/String\n 64: astore 8\n 66: astore 14\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: invokestatic #107 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 76: nop\n 77: invokestatic #111 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 80: aload 14\n 82: swap\n 83: invokeinterface #115, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 88: pop\n 89: goto 38\n 92: aload 4\n 94: checkcast #63 // class java/util/List\n 97: nop\n 98: checkcast #73 // class java/lang/Iterable\n 101: astore_1\n 102: new #117 // class java/util/LinkedList\n 105: dup\n 106: invokespecial #119 // Method java/util/LinkedList.\"<init>\":()V\n 109: astore_2\n 110: iconst_0\n 111: istore_3\n 112: iconst_0\n 113: istore 4\n 115: aload_2\n 116: astore 5\n 118: aload_1\n 119: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 124: astore 6\n 126: aload 6\n 128: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 133: ifeq 207\n 136: aload 6\n 138: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 143: astore 7\n 145: iload 4\n 147: iinc 4, 1\n 150: istore 8\n 152: iload 8\n 154: ifge 160\n 157: invokestatic #122 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 160: iload 8\n 162: aload 5\n 164: aload 7\n 166: checkcast #124 // class java/lang/Number\n 169: invokevirtual #128 // Method java/lang/Number.longValue:()J\n 172: lstore 9\n 174: astore 11\n 176: istore 12\n 178: iconst_0\n 179: istore 13\n 181: aload 11\n 183: lload 9\n 185: invokestatic #111 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 188: iload 12\n 190: invokestatic #133 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 193: invokestatic #139 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 196: invokevirtual #140 // Method java/util/LinkedList.add:(Ljava/lang/Object;)Z\n 199: pop\n 200: aload 11\n 202: astore 5\n 204: goto 126\n 207: aload 5\n 209: areturn\n\n private static final void main$mixIt(java.util.LinkedList<kotlin.Pair<java.lang.Long, java.lang.Integer>>, java.util.List<kotlin.Pair<java.lang.Long, java.lang.Integer>>);\n Code:\n 0: aload_1\n 1: checkcast #73 // class java/lang/Iterable\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: aload_2\n 8: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore 4\n 15: aload 4\n 17: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 22: ifeq 138\n 25: aload 4\n 27: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 32: astore 5\n 34: aload 5\n 36: checkcast #170 // class kotlin/Pair\n 39: astore 6\n 41: iconst_0\n 42: istore 7\n 44: aload 6\n 46: invokevirtual #173 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 49: checkcast #124 // class java/lang/Number\n 52: invokevirtual #128 // Method java/lang/Number.longValue:()J\n 55: lstore 8\n 57: aload_0\n 58: aload 6\n 60: invokevirtual #177 // Method java/util/LinkedList.indexOf:(Ljava/lang/Object;)I\n 63: istore 10\n 65: iload 10\n 67: i2l\n 68: lload 8\n 70: ladd\n 71: lstore 11\n 73: lload 11\n 75: lstore 13\n 77: aload_0\n 78: checkcast #63 // class java/util/List\n 81: invokestatic #180 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I\n 84: i2l\n 85: lstore 15\n 87: lload 13\n 89: lload 15\n 91: lrem\n 92: lstore 17\n 94: lload 17\n 96: lload 15\n 98: lload 17\n 100: lload 15\n 102: lxor\n 103: lload 17\n 105: lload 17\n 107: lneg\n 108: lor\n 109: land\n 110: bipush 63\n 112: lshr\n 113: land\n 114: ladd\n 115: l2i\n 116: istore 19\n 118: aload_0\n 119: aload 6\n 121: invokevirtual #183 // Method java/util/LinkedList.remove:(Ljava/lang/Object;)Z\n 124: pop\n 125: aload_0\n 126: iload 19\n 128: aload 6\n 130: invokevirtual #186 // Method java/util/LinkedList.add:(ILjava/lang/Object;)V\n 133: nop\n 134: nop\n 135: goto 15\n 138: nop\n 139: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #199 // Method main$parse:(Ljava/util/List;)Ljava/util/LinkedList;\n 4: astore_1\n 5: new #117 // class java/util/LinkedList\n 8: dup\n 9: aload_1\n 10: checkcast #85 // class java/util/Collection\n 13: invokespecial #202 // Method java/util/LinkedList.\"<init>\":(Ljava/util/Collection;)V\n 16: astore_2\n 17: aload_2\n 18: aload_1\n 19: checkcast #63 // class java/util/List\n 22: invokestatic #204 // Method main$mixIt:(Ljava/util/LinkedList;Ljava/util/List;)V\n 25: getstatic #46 // Field java/lang/System.out:Ljava/io/PrintStream;\n 28: aload_2\n 29: invokevirtual #207 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 32: aload_2\n 33: aload_2\n 34: checkcast #73 // class java/lang/Iterable\n 37: astore 4\n 39: astore 15\n 41: aload 4\n 43: astore 5\n 45: aload 5\n 47: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 52: astore 6\n 54: aload 6\n 56: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 61: ifeq 112\n 64: aload 6\n 66: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 71: astore 7\n 73: aload 7\n 75: checkcast #170 // class kotlin/Pair\n 78: astore 8\n 80: iconst_0\n 81: istore 9\n 83: aload 8\n 85: invokevirtual #173 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 88: checkcast #124 // class java/lang/Number\n 91: invokevirtual #128 // Method java/lang/Number.longValue:()J\n 94: lconst_0\n 95: lcmp\n 96: ifne 103\n 99: iconst_1\n 100: goto 104\n 103: iconst_0\n 104: ifeq 54\n 107: aload 7\n 109: goto 113\n 112: aconst_null\n 113: aload 15\n 115: swap\n 116: invokevirtual #177 // Method java/util/LinkedList.indexOf:(Ljava/lang/Object;)I\n 119: istore_3\n 120: getstatic #212 // Field Day20.INSTANCE:LDay20;\n 123: invokevirtual #216 // Method Day20.getANSWER_POSITIONS:()Ljava/util/Set;\n 126: checkcast #73 // class java/lang/Iterable\n 129: astore 6\n 131: lconst_0\n 132: lstore 7\n 134: aload 6\n 136: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 141: astore 9\n 143: aload 9\n 145: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 150: ifeq 224\n 153: aload 9\n 155: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 160: astore 10\n 162: lload 7\n 164: aload 10\n 166: checkcast #124 // class java/lang/Number\n 169: invokevirtual #220 // Method java/lang/Number.intValue:()I\n 172: istore 11\n 174: lstore 15\n 176: iconst_0\n 177: istore 12\n 179: iload_3\n 180: iload 11\n 182: iadd\n 183: istore 13\n 185: iload 13\n 187: aload_2\n 188: invokevirtual #223 // Method java/util/LinkedList.size:()I\n 191: irem\n 192: istore 14\n 194: aload_2\n 195: iload 14\n 197: invokevirtual #227 // Method java/util/LinkedList.get:(I)Ljava/lang/Object;\n 200: checkcast #170 // class kotlin/Pair\n 203: invokevirtual #173 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 206: checkcast #124 // class java/lang/Number\n 209: invokevirtual #128 // Method java/lang/Number.longValue:()J\n 212: lstore 17\n 214: lload 15\n 216: lload 17\n 218: ladd\n 219: lstore 7\n 221: goto 143\n 224: lload 7\n 226: lstore 4\n 228: lload 4\n 230: l2i\n 231: ireturn\n\n private static final long main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #199 // Method main$parse:(Ljava/util/List;)Ljava/util/LinkedList;\n 4: checkcast #73 // 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 #75 // class java/util/ArrayList\n 16: dup\n 17: aload_2\n 18: bipush 10\n 20: invokestatic #81 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 23: invokespecial #83 // Method java/util/ArrayList.\"<init>\":(I)V\n 26: checkcast #85 // class java/util/Collection\n 29: astore 5\n 31: iconst_0\n 32: istore 6\n 34: aload 4\n 36: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 41: astore 7\n 43: aload 7\n 45: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 50: ifeq 118\n 53: aload 7\n 55: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 60: astore 8\n 62: aload 5\n 64: aload 8\n 66: checkcast #170 // class kotlin/Pair\n 69: astore 9\n 71: astore 18\n 73: iconst_0\n 74: istore 10\n 76: new #170 // class kotlin/Pair\n 79: dup\n 80: aload 9\n 82: invokevirtual #173 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 85: checkcast #124 // class java/lang/Number\n 88: invokevirtual #128 // Method java/lang/Number.longValue:()J\n 91: ldc2_w #238 // long 811589153l\n 94: lmul\n 95: invokestatic #111 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 98: aload 9\n 100: invokevirtual #242 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 103: invokespecial #245 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 106: aload 18\n 108: swap\n 109: invokeinterface #115, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 114: pop\n 115: goto 43\n 118: aload 5\n 120: checkcast #63 // class java/util/List\n 123: nop\n 124: astore_1\n 125: new #117 // class java/util/LinkedList\n 128: dup\n 129: aload_1\n 130: checkcast #85 // class java/util/Collection\n 133: invokespecial #202 // Method java/util/LinkedList.\"<init>\":(Ljava/util/Collection;)V\n 136: astore_2\n 137: bipush 10\n 139: istore_3\n 140: iconst_0\n 141: istore 4\n 143: iload 4\n 145: iload_3\n 146: if_icmpge 167\n 149: iload 4\n 151: istore 5\n 153: iconst_0\n 154: istore 6\n 156: aload_2\n 157: aload_1\n 158: invokestatic #204 // Method main$mixIt:(Ljava/util/LinkedList;Ljava/util/List;)V\n 161: iinc 4, 1\n 164: goto 143\n 167: getstatic #46 // Field java/lang/System.out:Ljava/io/PrintStream;\n 170: aload_2\n 171: invokevirtual #207 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 174: aload_2\n 175: aload_2\n 176: checkcast #73 // class java/lang/Iterable\n 179: astore 4\n 181: astore 18\n 183: aload 4\n 185: astore 5\n 187: aload 5\n 189: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 194: astore 6\n 196: aload 6\n 198: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 203: ifeq 254\n 206: aload 6\n 208: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 213: astore 7\n 215: aload 7\n 217: checkcast #170 // class kotlin/Pair\n 220: astore 8\n 222: iconst_0\n 223: istore 9\n 225: aload 8\n 227: invokevirtual #173 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 230: checkcast #124 // class java/lang/Number\n 233: invokevirtual #128 // Method java/lang/Number.longValue:()J\n 236: lconst_0\n 237: lcmp\n 238: ifne 245\n 241: iconst_1\n 242: goto 246\n 245: iconst_0\n 246: ifeq 196\n 249: aload 7\n 251: goto 255\n 254: aconst_null\n 255: aload 18\n 257: swap\n 258: invokevirtual #177 // Method java/util/LinkedList.indexOf:(Ljava/lang/Object;)I\n 261: istore_3\n 262: getstatic #212 // Field Day20.INSTANCE:LDay20;\n 265: invokevirtual #216 // Method Day20.getANSWER_POSITIONS:()Ljava/util/Set;\n 268: checkcast #73 // class java/lang/Iterable\n 271: astore 6\n 273: iconst_0\n 274: istore 7\n 276: aload 6\n 278: astore 8\n 280: new #75 // class java/util/ArrayList\n 283: dup\n 284: aload 6\n 286: bipush 10\n 288: invokestatic #81 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 291: invokespecial #83 // Method java/util/ArrayList.\"<init>\":(I)V\n 294: checkcast #85 // class java/util/Collection\n 297: astore 9\n 299: iconst_0\n 300: istore 10\n 302: aload 8\n 304: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 309: astore 11\n 311: aload 11\n 313: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 318: ifeq 365\n 321: aload 11\n 323: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 328: astore 12\n 330: aload 9\n 332: aload 12\n 334: checkcast #124 // class java/lang/Number\n 337: invokevirtual #220 // Method java/lang/Number.intValue:()I\n 340: istore 13\n 342: astore 18\n 344: iconst_0\n 345: istore 14\n 347: iload 13\n 349: i2l\n 350: invokestatic #111 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 353: aload 18\n 355: swap\n 356: invokeinterface #115, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 361: pop\n 362: goto 311\n 365: aload 9\n 367: checkcast #63 // class java/util/List\n 370: nop\n 371: checkcast #73 // class java/lang/Iterable\n 374: astore 6\n 376: lconst_0\n 377: lstore 7\n 379: aload 6\n 381: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 386: astore 9\n 388: aload 9\n 390: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 395: ifeq 472\n 398: aload 9\n 400: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 405: astore 10\n 407: lload 7\n 409: aload 10\n 411: checkcast #124 // class java/lang/Number\n 414: invokevirtual #128 // Method java/lang/Number.longValue:()J\n 417: lstore 11\n 419: lstore 18\n 421: iconst_0\n 422: istore 13\n 424: iload_3\n 425: i2l\n 426: lload 11\n 428: ladd\n 429: lstore 14\n 431: lload 14\n 433: aload_2\n 434: invokevirtual #223 // Method java/util/LinkedList.size:()I\n 437: i2l\n 438: lrem\n 439: lstore 16\n 441: aload_2\n 442: lload 16\n 444: l2i\n 445: invokevirtual #227 // Method java/util/LinkedList.get:(I)Ljava/lang/Object;\n 448: checkcast #170 // class kotlin/Pair\n 451: invokevirtual #173 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 454: checkcast #124 // class java/lang/Number\n 457: invokevirtual #128 // Method java/lang/Number.longValue:()J\n 460: lstore 20\n 462: lload 18\n 464: lload 20\n 466: ladd\n 467: lstore 7\n 469: goto 388\n 472: lload 7\n 474: lstore 4\n 476: lload 4\n 478: lreturn\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day20.class",
"javap": "Compiled from \"Day20.kt\"\npublic final class Day20 {\n public static final Day20 INSTANCE;\n\n public static final int EXPECTED_PART1_CHECK_ANSWER;\n\n public static final long EXPECTED_PART2_CHECK_ANSWER;\n\n private static final java.util.Set<java.lang.Integer> ANSWER_POSITIONS;\n\n public static final long DECRYPTION_KEY;\n\n private Day20();\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.Set<java.lang.Integer> getANSWER_POSITIONS();\n Code:\n 0: getstatic #18 // Field ANSWER_POSITIONS:Ljava/util/Set;\n 3: areturn\n\n static {};\n Code:\n 0: new #2 // class Day20\n 3: dup\n 4: invokespecial #20 // Method \"<init>\":()V\n 7: putstatic #23 // Field INSTANCE:LDay20;\n 10: iconst_3\n 11: anewarray #25 // class java/lang/Integer\n 14: astore_0\n 15: aload_0\n 16: iconst_0\n 17: sipush 1000\n 20: invokestatic #29 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 23: aastore\n 24: aload_0\n 25: iconst_1\n 26: sipush 2000\n 29: invokestatic #29 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 32: aastore\n 33: aload_0\n 34: iconst_2\n 35: sipush 3000\n 38: invokestatic #29 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 41: aastore\n 42: aload_0\n 43: invokestatic #35 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 46: putstatic #18 // Field ANSWER_POSITIONS:Ljava/util/Set;\n 49: return\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day25.kt
|
import kotlin.math.pow
object Day25 {
const val EXPECTED_PART1_CHECK_ANSWER = "2=-1=0"
const val EXPECTED_PART2_CHECK_ANSWER = 1
}
fun main() {
fun fivesValueForDigit(char: Char) = when (char) {
'2' -> 2
'1' -> 1
'0' -> 0
'-' -> -1
'=' -> -2
else -> error("Unknown char $char")
}
fun digitForFivesValue(value: Long) = when (value) {
0L -> '0'
1L -> '1'
2L -> '2'
3L -> '='
4L -> '-'
else -> error("Unsupported value $value")
}
fun convertFivePowerNumberToDecimalNumber(fivePowerNumber: String): Long {
return fivePowerNumber.reversed().foldIndexed(0L) { idx, total, curFive ->
total + fivesValueForDigit(curFive) * (5.toDouble().pow(idx).toLong())
}
}
fun convertDecimalNumberToFivePowerNumber(decimalNumber: Long): String {
if (decimalNumber == 0L) return "0"
return generateSequence(decimalNumber to "") { (rest, totalNumber) ->
val low = rest % 5
(rest + 2) / 5 to digitForFivesValue(low) + totalNumber
}.first { it.first <= 0L }.second
}
fun part1(input: List<String>): String {
val sumInDecimal = input.sumOf { convertFivePowerNumberToDecimalNumber(it) }
val snafuValue = convertDecimalNumberToFivePowerNumber(sumInDecimal)
return snafuValue
}
fun part2(input: List<String>): Int {
return 1
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day25_test")
val input = readInput("Day25")
val part1TestResult = part1(testInput)
println("Part 1 test: $part1TestResult")
check(part1TestResult == Day25.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
println(part1(input))
val part2TestResult = part2(testInput)
println("Part 2 test: $part2TestResult")
check(part2TestResult == Day25.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }
println(part2(input))
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day25Kt.class",
"javap": "Compiled from \"Day25.kt\"\npublic final class Day25Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day25_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: ldc #16 // String Day25\n 8: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 11: astore_1\n 12: aload_0\n 13: invokestatic #20 // Method main$part1:(Ljava/util/List;)Ljava/lang/String;\n 16: astore_2\n 17: new #22 // class java/lang/StringBuilder\n 20: dup\n 21: invokespecial #25 // Method java/lang/StringBuilder.\"<init>\":()V\n 24: ldc #27 // String Part 1 test:\n 26: invokevirtual #31 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 29: aload_2\n 30: invokevirtual #31 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 33: invokevirtual #35 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 36: getstatic #41 // Field java/lang/System.out:Ljava/io/PrintStream;\n 39: swap\n 40: invokevirtual #47 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 43: aload_2\n 44: ldc #49 // String 2=-1=0\n 46: invokestatic #55 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 49: ifne 72\n 52: iconst_0\n 53: istore 4\n 55: ldc #57 // String Part 1 failed\n 57: astore 4\n 59: new #59 // class java/lang/IllegalStateException\n 62: dup\n 63: aload 4\n 65: invokevirtual #60 // Method java/lang/Object.toString:()Ljava/lang/String;\n 68: invokespecial #63 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 71: athrow\n 72: aload_1\n 73: invokestatic #20 // Method main$part1:(Ljava/util/List;)Ljava/lang/String;\n 76: getstatic #41 // Field java/lang/System.out:Ljava/io/PrintStream;\n 79: swap\n 80: invokevirtual #47 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 83: aload_0\n 84: invokestatic #67 // Method main$part2:(Ljava/util/List;)I\n 87: istore_3\n 88: new #22 // class java/lang/StringBuilder\n 91: dup\n 92: invokespecial #25 // Method java/lang/StringBuilder.\"<init>\":()V\n 95: ldc #69 // String Part 2 test:\n 97: invokevirtual #31 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 100: iload_3\n 101: invokevirtual #72 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 104: invokevirtual #35 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 107: getstatic #41 // Field java/lang/System.out:Ljava/io/PrintStream;\n 110: swap\n 111: invokevirtual #47 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 114: iload_3\n 115: iconst_1\n 116: if_icmpne 123\n 119: iconst_1\n 120: goto 124\n 123: iconst_0\n 124: ifne 147\n 127: iconst_0\n 128: istore 5\n 130: ldc #74 // String Part 2 failed\n 132: astore 5\n 134: new #59 // class java/lang/IllegalStateException\n 137: dup\n 138: aload 5\n 140: invokevirtual #60 // Method java/lang/Object.toString:()Ljava/lang/String;\n 143: invokespecial #63 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 146: athrow\n 147: aload_1\n 148: invokestatic #67 // Method main$part2:(Ljava/util/List;)I\n 151: istore 4\n 153: getstatic #41 // Field java/lang/System.out:Ljava/io/PrintStream;\n 156: iload 4\n 158: invokevirtual #77 // Method java/io/PrintStream.println:(I)V\n 161: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #93 // Method main:()V\n 3: return\n\n private static final int main$fivesValueForDigit(char);\n Code:\n 0: iload_0\n 1: lookupswitch { // 5\n 45: 64\n 48: 60\n 49: 56\n 50: 52\n 61: 68\n default: 73\n }\n 52: iconst_2\n 53: goto 103\n 56: iconst_1\n 57: goto 103\n 60: iconst_0\n 61: goto 103\n 64: iconst_m1\n 65: goto 103\n 68: bipush -2\n 70: goto 103\n 73: new #59 // class java/lang/IllegalStateException\n 76: dup\n 77: new #22 // class java/lang/StringBuilder\n 80: dup\n 81: invokespecial #25 // Method java/lang/StringBuilder.\"<init>\":()V\n 84: ldc #99 // String Unknown char\n 86: invokevirtual #31 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 89: iload_0\n 90: invokevirtual #102 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 93: invokevirtual #35 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 96: invokevirtual #60 // Method java/lang/Object.toString:()Ljava/lang/String;\n 99: invokespecial #63 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 102: athrow\n 103: ireturn\n\n private static final char main$digitForFivesValue(long);\n Code:\n 0: lload_0\n 1: lstore_2\n 2: lload_2\n 3: lconst_0\n 4: lcmp\n 5: ifne 13\n 8: bipush 48\n 10: goto 93\n 13: lload_2\n 14: lconst_1\n 15: lcmp\n 16: ifne 24\n 19: bipush 49\n 21: goto 93\n 24: lload_2\n 25: ldc2_w #107 // long 2l\n 28: lcmp\n 29: ifne 37\n 32: bipush 50\n 34: goto 93\n 37: lload_2\n 38: ldc2_w #109 // long 3l\n 41: lcmp\n 42: ifne 50\n 45: bipush 61\n 47: goto 93\n 50: lload_2\n 51: ldc2_w #111 // long 4l\n 54: lcmp\n 55: ifne 63\n 58: bipush 45\n 60: goto 93\n 63: new #59 // class java/lang/IllegalStateException\n 66: dup\n 67: new #22 // class java/lang/StringBuilder\n 70: dup\n 71: invokespecial #25 // Method java/lang/StringBuilder.\"<init>\":()V\n 74: ldc #114 // String Unsupported value\n 76: invokevirtual #31 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 79: lload_0\n 80: invokevirtual #117 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 83: invokevirtual #35 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 86: invokevirtual #60 // Method java/lang/Object.toString:()Ljava/lang/String;\n 89: invokespecial #63 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 92: athrow\n 93: ireturn\n\n private static final long main$convertFivePowerNumberToDecimalNumber(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #123 // class java/lang/CharSequence\n 4: invokestatic #129 // Method kotlin/text/StringsKt.reversed:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 7: invokevirtual #60 // Method java/lang/Object.toString:()Ljava/lang/String;\n 10: checkcast #123 // class java/lang/CharSequence\n 13: astore_1\n 14: lconst_0\n 15: lstore_2\n 16: iconst_0\n 17: istore 4\n 19: iconst_0\n 20: istore 5\n 22: lload_2\n 23: lstore 6\n 25: iconst_0\n 26: istore 8\n 28: iload 8\n 30: aload_1\n 31: invokeinterface #133, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 36: if_icmpge 95\n 39: aload_1\n 40: iload 8\n 42: invokeinterface #137, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 47: istore 9\n 49: iload 5\n 51: iinc 5, 1\n 54: lload 6\n 56: iload 9\n 58: istore 10\n 60: lstore 11\n 62: istore 13\n 64: iconst_0\n 65: istore 14\n 67: lload 11\n 69: iload 10\n 71: invokestatic #139 // Method main$fivesValueForDigit:(C)I\n 74: i2l\n 75: ldc2_w #140 // double 5.0d\n 78: iload 13\n 80: i2d\n 81: invokestatic #147 // Method java/lang/Math.pow:(DD)D\n 84: d2l\n 85: lmul\n 86: ladd\n 87: lstore 6\n 89: iinc 8, 1\n 92: goto 28\n 95: lload 6\n 97: lreturn\n\n private static final kotlin.Pair main$convertDecimalNumberToFivePowerNumber$lambda$1(kotlin.Pair);\n Code:\n 0: aload_0\n 1: ldc #163 // String <destruct>\n 3: invokestatic #167 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokevirtual #173 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 10: checkcast #175 // class java/lang/Number\n 13: invokevirtual #179 // Method java/lang/Number.longValue:()J\n 16: lstore_1\n 17: aload_0\n 18: invokevirtual #182 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 21: checkcast #90 // class java/lang/String\n 24: astore_3\n 25: lload_1\n 26: iconst_5\n 27: i2l\n 28: lrem\n 29: lstore 4\n 31: lload_1\n 32: iconst_2\n 33: i2l\n 34: ladd\n 35: iconst_5\n 36: i2l\n 37: ldiv\n 38: invokestatic #188 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 41: lload 4\n 43: invokestatic #190 // Method main$digitForFivesValue:(J)C\n 46: istore 6\n 48: new #22 // class java/lang/StringBuilder\n 51: dup\n 52: invokespecial #25 // Method java/lang/StringBuilder.\"<init>\":()V\n 55: iload 6\n 57: invokevirtual #102 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 60: aload_3\n 61: invokevirtual #31 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 64: invokevirtual #35 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 67: invokestatic #196 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 70: areturn\n\n private static final java.lang.String main$convertDecimalNumberToFivePowerNumber(long);\n Code:\n 0: lload_0\n 1: lconst_0\n 2: lcmp\n 3: ifne 9\n 6: ldc #203 // String 0\n 8: areturn\n 9: lload_0\n 10: invokestatic #188 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 13: ldc #205 // String\n 15: invokestatic #196 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 18: invokedynamic #222, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 23: invokestatic #228 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 26: astore_2\n 27: nop\n 28: iconst_0\n 29: istore_3\n 30: aload_2\n 31: invokeinterface #234, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 36: astore 4\n 38: aload 4\n 40: invokeinterface #240, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 96\n 48: aload 4\n 50: invokeinterface #243, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 5\n 57: aload 5\n 59: checkcast #169 // class kotlin/Pair\n 62: astore 6\n 64: iconst_0\n 65: istore 7\n 67: aload 6\n 69: invokevirtual #246 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 72: checkcast #175 // class java/lang/Number\n 75: invokevirtual #179 // Method java/lang/Number.longValue:()J\n 78: lconst_0\n 79: lcmp\n 80: ifgt 87\n 83: iconst_1\n 84: goto 88\n 87: iconst_0\n 88: ifeq 38\n 91: aload 5\n 93: goto 106\n 96: new #248 // class java/util/NoSuchElementException\n 99: dup\n 100: ldc #250 // String Sequence contains no element matching the predicate.\n 102: invokespecial #251 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 105: athrow\n 106: checkcast #169 // class kotlin/Pair\n 109: invokevirtual #254 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 112: checkcast #90 // class java/lang/String\n 115: areturn\n\n private static final java.lang.String main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #265 // class java/lang/Iterable\n 4: astore_3\n 5: lconst_0\n 6: lstore 4\n 8: aload_3\n 9: invokeinterface #266, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 14: astore 6\n 16: aload 6\n 18: invokeinterface #240, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 23: ifeq 66\n 26: aload 6\n 28: invokeinterface #243, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 33: astore 7\n 35: lload 4\n 37: aload 7\n 39: checkcast #90 // class java/lang/String\n 42: astore 8\n 44: lstore 10\n 46: iconst_0\n 47: istore 9\n 49: aload 8\n 51: invokestatic #268 // Method main$convertFivePowerNumberToDecimalNumber:(Ljava/lang/String;)J\n 54: lstore 12\n 56: lload 10\n 58: lload 12\n 60: ladd\n 61: lstore 4\n 63: goto 16\n 66: lload 4\n 68: lstore_1\n 69: lload_1\n 70: invokestatic #270 // Method main$convertDecimalNumberToFivePowerNumber:(J)Ljava/lang/String;\n 73: astore_3\n 74: aload_3\n 75: areturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: iconst_1\n 1: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day25.class",
"javap": "Compiled from \"Day25.kt\"\npublic final class Day25 {\n public static final Day25 INSTANCE;\n\n public static final java.lang.String EXPECTED_PART1_CHECK_ANSWER;\n\n public static final int EXPECTED_PART2_CHECK_ANSWER;\n\n private Day25();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n static {};\n Code:\n 0: new #2 // class Day25\n 3: dup\n 4: invokespecial #12 // Method \"<init>\":()V\n 7: putstatic #15 // Field INSTANCE:LDay25;\n 10: return\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day03.kt
|
object Day03 {
const val EXPECTED_PART1_CHECK_ANSWER = 157
const val EXPECTED_PART2_CHECK_ANSWER = 70
const val ELF_GROUP_SIZE = 3
}
fun main() {
fun Char.mapToItemValue() = if (this.isUpperCase()) (this.minus('A') + 27) else (this.minus('a') + 1)
fun part1(input: List<String>): Int {
return input.sumOf {
val compartment1 = it
.take(it.length / 2)
val compartment2 = it
.takeLast(it.length / 2)
val inBothCompartments = compartment1.toSet().intersect(compartment2.toSet())
val itemValue = if (inBothCompartments.isEmpty()) 0 else inBothCompartments.first().mapToItemValue()
itemValue
}
}
fun part2(input: List<String>): Int {
val commonItemsValues = input.chunked(Day03.ELF_GROUP_SIZE) {
it
.map { rucksackContent -> rucksackContent.toSet() }
.foldIndexed(emptySet<Char>()) { idx, acc, chars -> if (idx == 0) chars else acc.intersect(chars) }
.firstOrNull()
?.mapToItemValue()
?: 0
}
return commonItemsValues.sum()
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day03_test")
check(part1(testInput) == Day03.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
check(part2(testInput) == Day03.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }
val input = readInput("Day03")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/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 41\n 24: iconst_0\n 25: istore_2\n 26: ldc #20 // String Part 1 failed\n 28: astore_2\n 29: new #22 // class java/lang/IllegalStateException\n 32: dup\n 33: aload_2\n 34: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 37: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 40: athrow\n 41: aload_0\n 42: invokestatic #33 // Method main$part2:(Ljava/util/List;)I\n 45: bipush 70\n 47: if_icmpne 54\n 50: iconst_1\n 51: goto 55\n 54: iconst_0\n 55: ifne 75\n 58: iconst_0\n 59: istore_2\n 60: ldc #35 // String Part 2 failed\n 62: astore_2\n 63: new #22 // class java/lang/IllegalStateException\n 66: dup\n 67: aload_2\n 68: invokevirtual #26 // Method java/lang/Object.toString:()Ljava/lang/String;\n 71: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 74: athrow\n 75: ldc #37 // String Day03\n 77: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 80: astore_1\n 81: aload_1\n 82: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 85: istore_2\n 86: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 89: iload_2\n 90: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 93: aload_1\n 94: invokestatic #33 // Method main$part2:(Ljava/util/List;)I\n 97: istore_2\n 98: getstatic #43 // Field java/lang/System.out:Ljava/io/PrintStream;\n 101: iload_2\n 102: invokevirtual #49 // Method java/io/PrintStream.println:(I)V\n 105: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #60 // Method main:()V\n 3: return\n\n private static final int main$mapToItemValue(char);\n Code:\n 0: iload_0\n 1: invokestatic #70 // Method java/lang/Character.isUpperCase:(C)Z\n 4: ifeq 17\n 7: iload_0\n 8: bipush 65\n 10: isub\n 11: bipush 27\n 13: iadd\n 14: goto 23\n 17: iload_0\n 18: bipush 97\n 20: isub\n 21: iconst_1\n 22: iadd\n 23: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #75 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: invokeinterface #79, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore_3\n 14: aload_3\n 15: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 20: ifeq 145\n 23: aload_3\n 24: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 29: astore 4\n 31: iload_2\n 32: aload 4\n 34: checkcast #91 // class java/lang/String\n 37: astore 5\n 39: istore 11\n 41: iconst_0\n 42: istore 6\n 44: aload 5\n 46: aload 5\n 48: invokevirtual #95 // Method java/lang/String.length:()I\n 51: iconst_2\n 52: idiv\n 53: invokestatic #101 // Method kotlin/text/StringsKt.take:(Ljava/lang/String;I)Ljava/lang/String;\n 56: astore 7\n 58: aload 5\n 60: aload 5\n 62: invokevirtual #95 // Method java/lang/String.length:()I\n 65: iconst_2\n 66: idiv\n 67: invokestatic #104 // Method kotlin/text/StringsKt.takeLast:(Ljava/lang/String;I)Ljava/lang/String;\n 70: astore 8\n 72: aload 7\n 74: checkcast #106 // class java/lang/CharSequence\n 77: invokestatic #110 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 80: checkcast #75 // class java/lang/Iterable\n 83: aload 8\n 85: checkcast #106 // class java/lang/CharSequence\n 88: invokestatic #110 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 91: checkcast #75 // class java/lang/Iterable\n 94: invokestatic #116 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 97: astore 9\n 99: aload 9\n 101: invokeinterface #121, 1 // InterfaceMethod java/util/Set.isEmpty:()Z\n 106: ifeq 113\n 109: iconst_0\n 110: goto 130\n 113: aload 9\n 115: checkcast #75 // class java/lang/Iterable\n 118: invokestatic #125 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 121: checkcast #66 // class java/lang/Character\n 124: invokevirtual #129 // Method java/lang/Character.charValue:()C\n 127: invokestatic #131 // Method main$mapToItemValue:(C)I\n 130: istore 10\n 132: iload 10\n 134: istore 12\n 136: iload 11\n 138: iload 12\n 140: iadd\n 141: istore_2\n 142: goto 14\n 145: iload_2\n 146: ireturn\n\n private static final int main$part2$lambda$3(java.util.List);\n Code:\n 0: aload_0\n 1: ldc #141 // String it\n 3: invokestatic #147 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #75 // class java/lang/Iterable\n 10: astore_2\n 11: nop\n 12: iconst_0\n 13: istore_3\n 14: aload_2\n 15: astore 4\n 17: new #149 // class java/util/ArrayList\n 20: dup\n 21: aload_2\n 22: bipush 10\n 24: invokestatic #153 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 27: invokespecial #155 // Method java/util/ArrayList.\"<init>\":(I)V\n 30: checkcast #157 // class java/util/Collection\n 33: astore 5\n 35: iconst_0\n 36: istore 6\n 38: aload 4\n 40: invokeinterface #79, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 7\n 47: aload 7\n 49: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 100\n 57: aload 7\n 59: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 8\n 66: aload 5\n 68: aload 8\n 70: checkcast #91 // class java/lang/String\n 73: astore 9\n 75: astore 14\n 77: iconst_0\n 78: istore 10\n 80: aload 9\n 82: checkcast #106 // class java/lang/CharSequence\n 85: invokestatic #110 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 88: aload 14\n 90: swap\n 91: invokeinterface #161, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 96: pop\n 97: goto 47\n 100: aload 5\n 102: checkcast #57 // class java/util/List\n 105: nop\n 106: checkcast #75 // class java/lang/Iterable\n 109: astore_2\n 110: invokestatic #167 // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;\n 113: astore_3\n 114: iconst_0\n 115: istore 4\n 117: iconst_0\n 118: istore 5\n 120: aload_3\n 121: astore 6\n 123: aload_2\n 124: invokeinterface #79, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 129: astore 7\n 131: aload 7\n 133: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 138: ifeq 211\n 141: aload 7\n 143: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 148: astore 8\n 150: iload 5\n 152: iinc 5, 1\n 155: istore 9\n 157: iload 9\n 159: ifge 165\n 162: invokestatic #170 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 165: iload 9\n 167: aload 6\n 169: aload 8\n 171: checkcast #118 // class java/util/Set\n 174: astore 10\n 176: astore 11\n 178: istore 12\n 180: iconst_0\n 181: istore 13\n 183: iload 12\n 185: ifne 193\n 188: aload 10\n 190: goto 206\n 193: aload 11\n 195: checkcast #75 // class java/lang/Iterable\n 198: aload 10\n 200: checkcast #75 // class java/lang/Iterable\n 203: invokestatic #116 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 206: astore 6\n 208: goto 131\n 211: aload 6\n 213: checkcast #75 // class java/lang/Iterable\n 216: invokestatic #173 // Method kotlin/collections/CollectionsKt.firstOrNull:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 219: checkcast #66 // class java/lang/Character\n 222: astore_1\n 223: aload_1\n 224: ifnull 237\n 227: aload_1\n 228: invokevirtual #129 // Method java/lang/Character.charValue:()C\n 231: invokestatic #131 // Method main$mapToItemValue:(C)I\n 234: goto 238\n 237: iconst_0\n 238: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #75 // class java/lang/Iterable\n 4: iconst_3\n 5: invokedynamic #212, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 10: invokestatic #216 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;ILkotlin/jvm/functions/Function1;)Ljava/util/List;\n 13: astore_1\n 14: aload_1\n 15: checkcast #75 // class java/lang/Iterable\n 18: invokestatic #220 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 21: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day03.class",
"javap": "Compiled from \"Day03.kt\"\npublic final class Day03 {\n public static final Day03 INSTANCE;\n\n public static final int EXPECTED_PART1_CHECK_ANSWER;\n\n public static final int EXPECTED_PART2_CHECK_ANSWER;\n\n public static final int ELF_GROUP_SIZE;\n\n private Day03();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n static {};\n Code:\n 0: new #2 // class Day03\n 3: dup\n 4: invokespecial #12 // Method \"<init>\":()V\n 7: putstatic #15 // Field INSTANCE:LDay03;\n 10: return\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day02.kt
|
const val SCORE_ROCK = 1
const val SCORE_PAPER = 2
const val SCORE_SCISSORS = 3
const val DRAW = 'Y'
const val LOSE = 'X'
const val WIN = 'Z'
const val EXPECTED_PART1_CHECK_ANSWER = 15
const val EXPECTED_PART2_CHECK_ANSWER = 12
const val POS_THEIR_CHOICE = 0
const val POS_OUR_CHOICE = 2
const val SCORE_WIN = 6
const val SCORE_DRAW = 3
const val SCORE_LOSE = 0
enum class Shape(val shapeScore: Int) {
Rock(SCORE_ROCK),
Paper(SCORE_PAPER),
Scissors(SCORE_SCISSORS);
companion object {
fun from(char: Char): Shape =
when (char) {
'A', 'X' -> Rock
'B', 'Y' -> Paper
'C', 'Z' -> Scissors
else -> error("Unknown value $char")
}
}
}
val BEATS = mapOf(
Shape.Rock to Shape.Scissors,
Shape.Paper to Shape.Rock,
Shape.Scissors to Shape.Paper,
)
val BEATEN_BY = mapOf(
Shape.Scissors to Shape.Rock,
Shape.Rock to Shape.Paper,
Shape.Paper to Shape.Scissors,
)
fun main() {
fun getScore(theirs: Shape, ours: Shape) = when {
ours == theirs -> ours.shapeScore + SCORE_DRAW
BEATS[ours] == theirs -> ours.shapeScore + SCORE_WIN
else -> ours.shapeScore + SCORE_LOSE
}
fun part1(input: List<String>): Int {
return input.sumOf {
val theirs = Shape.from(it[POS_THEIR_CHOICE])
val ours = Shape.from(it[POS_OUR_CHOICE])
getScore(theirs, ours)
}
}
fun part2(input: List<String>): Int {
return input.sumOf {
val theirs = Shape.from(it[POS_THEIR_CHOICE])
val ours = when (it[POS_OUR_CHOICE]) {
DRAW -> theirs
LOSE -> BEATS[theirs]!!
WIN -> BEATEN_BY[theirs]!!
else -> error("Wrong input")
}
getScore(theirs, ours)
}
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day02_test")
check(part1(testInput) == EXPECTED_PART1_CHECK_ANSWER)
check(part2(testInput) == EXPECTED_PART2_CHECK_ANSWER)
val input = readInput("Day02")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day02Kt.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class Day02Kt {\n public static final int SCORE_ROCK;\n\n public static final int SCORE_PAPER;\n\n public static final int SCORE_SCISSORS;\n\n public static final char DRAW;\n\n public static final char LOSE;\n\n public static final char WIN;\n\n public static final int EXPECTED_PART1_CHECK_ANSWER;\n\n public static final int EXPECTED_PART2_CHECK_ANSWER;\n\n public static final int POS_THEIR_CHOICE;\n\n public static final int POS_OUR_CHOICE;\n\n public static final int SCORE_WIN;\n\n public static final int SCORE_DRAW;\n\n public static final int SCORE_LOSE;\n\n private static final java.util.Map<Shape, Shape> BEATS;\n\n private static final java.util.Map<Shape, Shape> BEATEN_BY;\n\n public static final java.util.Map<Shape, Shape> getBEATS();\n Code:\n 0: getstatic #12 // Field BEATS:Ljava/util/Map;\n 3: areturn\n\n public static final java.util.Map<Shape, Shape> getBEATEN_BY();\n Code:\n 0: getstatic #16 // Field BEATEN_BY:Ljava/util/Map;\n 3: areturn\n\n public static final void main();\n Code:\n 0: ldc #20 // String Day02_test\n 2: invokestatic #26 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #30 // Method main$part1:(Ljava/util/List;)I\n 10: bipush 15\n 12: if_icmpne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 33\n 23: new #32 // class java/lang/IllegalStateException\n 26: dup\n 27: ldc #34 // String Check failed.\n 29: invokespecial #38 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 32: athrow\n 33: aload_0\n 34: invokestatic #41 // Method main$part2:(Ljava/util/List;)I\n 37: bipush 12\n 39: if_icmpne 46\n 42: iconst_1\n 43: goto 47\n 46: iconst_0\n 47: ifne 60\n 50: new #32 // class java/lang/IllegalStateException\n 53: dup\n 54: ldc #34 // String Check failed.\n 56: invokespecial #38 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 59: athrow\n 60: ldc #43 // String Day02\n 62: invokestatic #26 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 65: astore_1\n 66: aload_1\n 67: invokestatic #30 // Method main$part1:(Ljava/util/List;)I\n 70: istore_2\n 71: getstatic #49 // Field java/lang/System.out:Ljava/io/PrintStream;\n 74: iload_2\n 75: invokevirtual #55 // Method java/io/PrintStream.println:(I)V\n 78: aload_1\n 79: invokestatic #41 // Method main$part2:(Ljava/util/List;)I\n 82: istore_2\n 83: getstatic #49 // Field java/lang/System.out:Ljava/io/PrintStream;\n 86: iload_2\n 87: invokevirtual #55 // Method java/io/PrintStream.println:(I)V\n 90: 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 int main$getScore(Shape, Shape);\n Code:\n 0: nop\n 1: aload_1\n 2: aload_0\n 3: if_acmpne 15\n 6: aload_1\n 7: invokevirtual #73 // Method Shape.getShapeScore:()I\n 10: iconst_3\n 11: iadd\n 12: goto 44\n 15: getstatic #12 // Field BEATS:Ljava/util/Map;\n 18: aload_1\n 19: invokeinterface #79, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 24: aload_0\n 25: if_acmpne 38\n 28: aload_1\n 29: invokevirtual #73 // Method Shape.getShapeScore:()I\n 32: bipush 6\n 34: iadd\n 35: goto 44\n 38: aload_1\n 39: invokevirtual #73 // Method Shape.getShapeScore:()I\n 42: iconst_0\n 43: iadd\n 44: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #85 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore_3\n 14: aload_3\n 15: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 20: ifeq 90\n 23: aload_3\n 24: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 29: astore 4\n 31: iload_2\n 32: aload 4\n 34: checkcast #101 // class java/lang/String\n 37: astore 5\n 39: istore 9\n 41: iconst_0\n 42: istore 6\n 44: getstatic #105 // Field Shape.Companion:LShape$Companion;\n 47: aload 5\n 49: iconst_0\n 50: invokevirtual #109 // Method java/lang/String.charAt:(I)C\n 53: invokevirtual #115 // Method Shape$Companion.from:(C)LShape;\n 56: astore 7\n 58: getstatic #105 // Field Shape.Companion:LShape$Companion;\n 61: aload 5\n 63: iconst_2\n 64: invokevirtual #109 // Method java/lang/String.charAt:(I)C\n 67: invokevirtual #115 // Method Shape$Companion.from:(C)LShape;\n 70: astore 8\n 72: aload 7\n 74: aload 8\n 76: invokestatic #117 // Method main$getScore:(LShape;LShape;)I\n 79: istore 10\n 81: iload 9\n 83: iload 10\n 85: iadd\n 86: istore_2\n 87: goto 14\n 90: iload_2\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: checkcast #85 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore_3\n 14: aload_3\n 15: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 20: ifeq 170\n 23: aload_3\n 24: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 29: astore 4\n 31: iload_2\n 32: aload 4\n 34: checkcast #101 // class java/lang/String\n 37: astore 5\n 39: istore 9\n 41: iconst_0\n 42: istore 6\n 44: getstatic #105 // Field Shape.Companion:LShape$Companion;\n 47: aload 5\n 49: iconst_0\n 50: invokevirtual #109 // Method java/lang/String.charAt:(I)C\n 53: invokevirtual #115 // Method Shape$Companion.from:(C)LShape;\n 56: astore 7\n 58: aload 5\n 60: iconst_2\n 61: invokevirtual #109 // Method java/lang/String.charAt:(I)C\n 64: tableswitch { // 88 to 90\n 88: 97\n 89: 92\n 90: 117\n default: 137\n }\n 92: aload 7\n 94: goto 150\n 97: getstatic #12 // Field BEATS:Ljava/util/Map;\n 100: aload 7\n 102: invokeinterface #79, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 107: dup\n 108: invokestatic #127 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 111: checkcast #69 // class Shape\n 114: goto 150\n 117: getstatic #16 // Field BEATEN_BY:Ljava/util/Map;\n 120: aload 7\n 122: invokeinterface #79, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 127: dup\n 128: invokestatic #127 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 131: checkcast #69 // class Shape\n 134: goto 150\n 137: new #32 // class java/lang/IllegalStateException\n 140: dup\n 141: ldc #129 // String Wrong input\n 143: invokevirtual #133 // Method java/lang/Object.toString:()Ljava/lang/String;\n 146: invokespecial #38 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 149: athrow\n 150: astore 8\n 152: aload 7\n 154: aload 8\n 156: invokestatic #117 // Method main$getScore:(LShape;LShape;)I\n 159: istore 10\n 161: iload 9\n 163: iload 10\n 165: iadd\n 166: istore_2\n 167: goto 14\n 170: iload_2\n 171: ireturn\n\n static {};\n Code:\n 0: iconst_3\n 1: anewarray #137 // class kotlin/Pair\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: getstatic #140 // Field Shape.Rock:LShape;\n 10: getstatic #143 // Field Shape.Scissors:LShape;\n 13: invokestatic #149 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 16: aastore\n 17: aload_0\n 18: iconst_1\n 19: getstatic #152 // Field Shape.Paper:LShape;\n 22: getstatic #140 // Field Shape.Rock:LShape;\n 25: invokestatic #149 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 28: aastore\n 29: aload_0\n 30: iconst_2\n 31: getstatic #143 // Field Shape.Scissors:LShape;\n 34: getstatic #152 // Field Shape.Paper:LShape;\n 37: invokestatic #149 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 40: aastore\n 41: aload_0\n 42: invokestatic #158 // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 45: putstatic #12 // Field BEATS:Ljava/util/Map;\n 48: iconst_3\n 49: anewarray #137 // class kotlin/Pair\n 52: astore_0\n 53: aload_0\n 54: iconst_0\n 55: getstatic #143 // Field Shape.Scissors:LShape;\n 58: getstatic #140 // Field Shape.Rock:LShape;\n 61: invokestatic #149 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 64: aastore\n 65: aload_0\n 66: iconst_1\n 67: getstatic #140 // Field Shape.Rock:LShape;\n 70: getstatic #152 // Field Shape.Paper:LShape;\n 73: invokestatic #149 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 76: aastore\n 77: aload_0\n 78: iconst_2\n 79: getstatic #152 // Field Shape.Paper:LShape;\n 82: getstatic #143 // Field Shape.Scissors:LShape;\n 85: invokestatic #149 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 88: aastore\n 89: aload_0\n 90: invokestatic #158 // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 93: putstatic #16 // Field BEATEN_BY:Ljava/util/Map;\n 96: return\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day18.kt
|
object Day18 {
const val EXPECTED_PART1_CHECK_ANSWER = 64
const val EXPECTED_PART2_CHECK_ANSWER = 58
}
fun main() {
val air = mutableMapOf<Point3D, Boolean>()
fun List<String>.parsePoints() =
map { line ->
val xyz = line.split(',')
Point3D(xyz[0].toInt(), xyz[1].toInt(), xyz[2].toInt())
}
fun Point3D.sides() =
listOf(
Triple(-1, 0, 0),
Triple(0, 1, 0),
Triple(1, 0, 0),
Triple(0, -1, 0),
Triple(0, 0, 1),
Triple(0, 0, -1),
).map { (xMove, yMove, zMove) ->
Point3D(x + xMove, y +yMove, z + zMove)
}
fun addToCache(points: Iterable<Point3D>, isAir: Boolean): Boolean {
points.forEach { air[it] = isAir }
return isAir
}
fun Point3D.outsideRange(pMin: Point3D, pMax: Point3D) = x < pMin.x || x > pMax.x || y < pMin.y || y > pMax.y || z < pMin.z || z > pMax.z
fun Point3D.isAir(points: List<Point3D>, pMin: Point3D, pMax: Point3D): Boolean {
air[this]?.let { return it }
val frontier = ArrayDeque(listOf(this))
val visited = mutableSetOf<Point3D>()
while (!frontier.isEmpty()) {
val current = frontier.removeFirst()
when {
!visited.add(current) -> continue
current in air -> return addToCache(visited, air.getValue(current))
current.outsideRange(pMin, pMax) -> return addToCache(visited, false)
else -> frontier.addAll(current.sides().filter { it !in points })
}
}
return addToCache(visited, true)
}
fun part1(input: List<String>): Int {
val points = input.parsePoints()
return points.sumOf { point ->
point.sides().count { it !in points }
}
}
fun part2(input: List<String>): Int {
val points = input.parsePoints()
val pMin = Point3D(points.minOf { it.x }, points.minOf { it.y }, points.minOf { it.z })
val pMax = Point3D(points.maxOf { it.x }, points.maxOf { it.y }, points.maxOf { it.z })
val result = points.sumOf { point ->
point.sides().filter { it !in points }.count { !it.isAir(points, pMin, pMax) }
}
return result
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day18_test")
check(part1(testInput) == Day18.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
check(part2(testInput) == Day18.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }
val input = readInput("Day18")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day18.class",
"javap": "Compiled from \"Day18.kt\"\npublic final class Day18 {\n public static final Day18 INSTANCE;\n\n public static final int EXPECTED_PART1_CHECK_ANSWER;\n\n public static final int EXPECTED_PART2_CHECK_ANSWER;\n\n private Day18();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n static {};\n Code:\n 0: new #2 // class Day18\n 3: dup\n 4: invokespecial #12 // Method \"<init>\":()V\n 7: putstatic #15 // Field INSTANCE:LDay18;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day18Kt.class",
"javap": "Compiled from \"Day18.kt\"\npublic final class Day18Kt {\n public static final void main();\n Code:\n 0: new #8 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #11 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #13 // class java/util/Map\n 10: astore_0\n 11: ldc #15 // String Day18_test\n 13: invokestatic #21 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 16: astore_1\n 17: aload_1\n 18: invokestatic #25 // Method main$part1:(Ljava/util/List;)I\n 21: bipush 64\n 23: if_icmpne 30\n 26: iconst_1\n 27: goto 31\n 30: iconst_0\n 31: ifne 51\n 34: iconst_0\n 35: istore_3\n 36: ldc #27 // String Part 1 failed\n 38: astore_3\n 39: new #29 // class java/lang/IllegalStateException\n 42: dup\n 43: aload_3\n 44: invokevirtual #33 // Method java/lang/Object.toString:()Ljava/lang/String;\n 47: invokespecial #36 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 50: athrow\n 51: aload_0\n 52: aload_1\n 53: invokestatic #40 // Method main$part2:(Ljava/util/Map;Ljava/util/List;)I\n 56: bipush 58\n 58: if_icmpne 65\n 61: iconst_1\n 62: goto 66\n 65: iconst_0\n 66: ifne 86\n 69: iconst_0\n 70: istore_3\n 71: ldc #42 // String Part 2 failed\n 73: astore_3\n 74: new #29 // class java/lang/IllegalStateException\n 77: dup\n 78: aload_3\n 79: invokevirtual #33 // Method java/lang/Object.toString:()Ljava/lang/String;\n 82: invokespecial #36 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 85: athrow\n 86: ldc #44 // String Day18\n 88: invokestatic #21 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 91: astore_2\n 92: aload_2\n 93: invokestatic #25 // Method main$part1:(Ljava/util/List;)I\n 96: istore_3\n 97: getstatic #50 // Field java/lang/System.out:Ljava/io/PrintStream;\n 100: iload_3\n 101: invokevirtual #56 // Method java/io/PrintStream.println:(I)V\n 104: aload_0\n 105: aload_2\n 106: invokestatic #40 // Method main$part2:(Ljava/util/Map;Ljava/util/List;)I\n 109: istore_3\n 110: getstatic #50 // Field java/lang/System.out:Ljava/io/PrintStream;\n 113: iload_3\n 114: invokevirtual #56 // Method java/io/PrintStream.println:(I)V\n 117: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #69 // Method main:()V\n 3: return\n\n private static final java.util.List<Point3D> main$parsePoints(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #76 // 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 #78 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #84 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #86 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #88 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 160\n 48: aload 6\n 50: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #104 // class java/lang/String\n 64: astore 8\n 66: astore 12\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: checkcast #106 // class java/lang/CharSequence\n 76: iconst_1\n 77: newarray char\n 79: astore 10\n 81: aload 10\n 83: iconst_0\n 84: bipush 44\n 86: castore\n 87: aload 10\n 89: iconst_0\n 90: iconst_0\n 91: bipush 6\n 93: aconst_null\n 94: invokestatic #112 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 97: astore 11\n 99: new #114 // class Point3D\n 102: dup\n 103: aload 11\n 105: iconst_0\n 106: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 111: checkcast #104 // class java/lang/String\n 114: invokestatic #124 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 117: aload 11\n 119: iconst_1\n 120: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 125: checkcast #104 // class java/lang/String\n 128: invokestatic #124 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 131: aload 11\n 133: iconst_2\n 134: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 139: checkcast #104 // class java/lang/String\n 142: invokestatic #124 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 145: invokespecial #127 // Method Point3D.\"<init>\":(III)V\n 148: aload 12\n 150: swap\n 151: invokeinterface #131, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 156: pop\n 157: goto 38\n 160: aload 4\n 162: checkcast #66 // class java/util/List\n 165: nop\n 166: areturn\n\n private static final java.util.List<Point3D> main$sides(Point3D);\n Code:\n 0: bipush 6\n 2: anewarray #150 // class kotlin/Triple\n 5: astore_1\n 6: aload_1\n 7: iconst_0\n 8: new #150 // class kotlin/Triple\n 11: dup\n 12: iconst_m1\n 13: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 16: iconst_0\n 17: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 20: iconst_0\n 21: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 24: invokespecial #157 // Method kotlin/Triple.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V\n 27: aastore\n 28: aload_1\n 29: iconst_1\n 30: new #150 // class kotlin/Triple\n 33: dup\n 34: iconst_0\n 35: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 38: iconst_1\n 39: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 42: iconst_0\n 43: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 46: invokespecial #157 // Method kotlin/Triple.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V\n 49: aastore\n 50: aload_1\n 51: iconst_2\n 52: new #150 // class kotlin/Triple\n 55: dup\n 56: iconst_1\n 57: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 60: iconst_0\n 61: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 64: iconst_0\n 65: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 68: invokespecial #157 // Method kotlin/Triple.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V\n 71: aastore\n 72: aload_1\n 73: iconst_3\n 74: new #150 // class kotlin/Triple\n 77: dup\n 78: iconst_0\n 79: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 82: iconst_m1\n 83: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 86: iconst_0\n 87: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 90: invokespecial #157 // Method kotlin/Triple.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V\n 93: aastore\n 94: aload_1\n 95: iconst_4\n 96: new #150 // class kotlin/Triple\n 99: dup\n 100: iconst_0\n 101: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 104: iconst_0\n 105: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 108: iconst_1\n 109: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 112: invokespecial #157 // Method kotlin/Triple.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V\n 115: aastore\n 116: aload_1\n 117: iconst_5\n 118: new #150 // class kotlin/Triple\n 121: dup\n 122: iconst_0\n 123: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 126: iconst_0\n 127: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 130: iconst_m1\n 131: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 134: invokespecial #157 // Method kotlin/Triple.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V\n 137: aastore\n 138: aload_1\n 139: invokestatic #161 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 142: checkcast #76 // class java/lang/Iterable\n 145: astore_1\n 146: nop\n 147: iconst_0\n 148: istore_2\n 149: aload_1\n 150: astore_3\n 151: new #78 // class java/util/ArrayList\n 154: dup\n 155: aload_1\n 156: bipush 10\n 158: invokestatic #84 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 161: invokespecial #86 // Method java/util/ArrayList.\"<init>\":(I)V\n 164: checkcast #88 // class java/util/Collection\n 167: astore 4\n 169: iconst_0\n 170: istore 5\n 172: aload_3\n 173: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 178: astore 6\n 180: aload 6\n 182: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 187: ifeq 292\n 190: aload 6\n 192: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 197: astore 7\n 199: aload 4\n 201: aload 7\n 203: checkcast #150 // class kotlin/Triple\n 206: astore 8\n 208: astore 13\n 210: iconst_0\n 211: istore 9\n 213: aload 8\n 215: invokevirtual #164 // Method kotlin/Triple.component1:()Ljava/lang/Object;\n 218: checkcast #166 // class java/lang/Number\n 221: invokevirtual #170 // Method java/lang/Number.intValue:()I\n 224: istore 10\n 226: aload 8\n 228: invokevirtual #173 // Method kotlin/Triple.component2:()Ljava/lang/Object;\n 231: checkcast #166 // class java/lang/Number\n 234: invokevirtual #170 // Method java/lang/Number.intValue:()I\n 237: istore 11\n 239: aload 8\n 241: invokevirtual #176 // Method kotlin/Triple.component3:()Ljava/lang/Object;\n 244: checkcast #166 // class java/lang/Number\n 247: invokevirtual #170 // Method java/lang/Number.intValue:()I\n 250: istore 12\n 252: new #114 // class Point3D\n 255: dup\n 256: aload_0\n 257: invokevirtual #179 // Method Point3D.getX:()I\n 260: iload 10\n 262: iadd\n 263: aload_0\n 264: invokevirtual #182 // Method Point3D.getY:()I\n 267: iload 11\n 269: iadd\n 270: aload_0\n 271: invokevirtual #185 // Method Point3D.getZ:()I\n 274: iload 12\n 276: iadd\n 277: invokespecial #127 // Method Point3D.\"<init>\":(III)V\n 280: aload 13\n 282: swap\n 283: invokeinterface #131, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 288: pop\n 289: goto 180\n 292: aload 4\n 294: checkcast #66 // class java/util/List\n 297: nop\n 298: areturn\n\n private static final boolean main$addToCache(java.util.Map<Point3D, java.lang.Boolean>, java.lang.Iterable<Point3D>, boolean);\n Code:\n 0: aload_1\n 1: astore_3\n 2: iconst_0\n 3: istore 4\n 5: aload_3\n 6: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 11: astore 5\n 13: aload 5\n 15: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 20: ifeq 64\n 23: aload 5\n 25: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 30: astore 6\n 32: aload 6\n 34: checkcast #114 // class Point3D\n 37: astore 7\n 39: iconst_0\n 40: istore 8\n 42: iload_2\n 43: invokestatic #199 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 46: astore 9\n 48: aload_0\n 49: aload 7\n 51: aload 9\n 53: invokeinterface #203, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 58: pop\n 59: nop\n 60: nop\n 61: goto 13\n 64: nop\n 65: iload_2\n 66: ireturn\n\n private static final boolean main$outsideRange(Point3D, Point3D, Point3D);\n Code:\n 0: aload_0\n 1: invokevirtual #179 // Method Point3D.getX:()I\n 4: aload_1\n 5: invokevirtual #179 // Method Point3D.getX:()I\n 8: if_icmplt 66\n 11: aload_0\n 12: invokevirtual #179 // Method Point3D.getX:()I\n 15: aload_2\n 16: invokevirtual #179 // Method Point3D.getX:()I\n 19: if_icmpgt 66\n 22: aload_0\n 23: invokevirtual #182 // Method Point3D.getY:()I\n 26: aload_1\n 27: invokevirtual #182 // Method Point3D.getY:()I\n 30: if_icmplt 66\n 33: aload_0\n 34: invokevirtual #182 // Method Point3D.getY:()I\n 37: aload_2\n 38: invokevirtual #182 // Method Point3D.getY:()I\n 41: if_icmpgt 66\n 44: aload_0\n 45: invokevirtual #185 // Method Point3D.getZ:()I\n 48: aload_1\n 49: invokevirtual #185 // Method Point3D.getZ:()I\n 52: if_icmplt 66\n 55: aload_0\n 56: invokevirtual #185 // Method Point3D.getZ:()I\n 59: aload_2\n 60: invokevirtual #185 // Method Point3D.getZ:()I\n 63: if_icmple 70\n 66: iconst_1\n 67: goto 71\n 70: iconst_0\n 71: ireturn\n\n private static final boolean main$isAir(Point3D, java.util.Map<Point3D, java.lang.Boolean>, java.util.List<Point3D>, Point3D, Point3D);\n Code:\n 0: aload_1\n 1: aload_0\n 2: invokeinterface #222, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: checkcast #196 // class java/lang/Boolean\n 10: astore 5\n 12: aload 5\n 14: ifnull 30\n 17: aload 5\n 19: invokevirtual #225 // Method java/lang/Boolean.booleanValue:()Z\n 22: istore 7\n 24: iconst_0\n 25: istore 8\n 27: iload 7\n 29: ireturn\n 30: new #227 // class kotlin/collections/ArrayDeque\n 33: dup\n 34: aload_0\n 35: invokestatic #230 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 38: checkcast #88 // class java/util/Collection\n 41: invokespecial #233 // Method kotlin/collections/ArrayDeque.\"<init>\":(Ljava/util/Collection;)V\n 44: astore 5\n 46: new #235 // class java/util/LinkedHashSet\n 49: dup\n 50: invokespecial #236 // Method java/util/LinkedHashSet.\"<init>\":()V\n 53: checkcast #238 // class java/util/Set\n 56: astore 6\n 58: aload 5\n 60: invokevirtual #241 // Method kotlin/collections/ArrayDeque.isEmpty:()Z\n 63: ifne 269\n 66: aload 5\n 68: invokevirtual #244 // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;\n 71: checkcast #114 // class Point3D\n 74: astore 7\n 76: nop\n 77: aload 6\n 79: aload 7\n 81: invokeinterface #245, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 86: ifeq 58\n 89: aload_1\n 90: aload 7\n 92: invokeinterface #248, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 97: ifeq 122\n 100: aload_1\n 101: aload 6\n 103: checkcast #76 // class java/lang/Iterable\n 106: aload_1\n 107: aload 7\n 109: invokestatic #254 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 112: checkcast #196 // class java/lang/Boolean\n 115: invokevirtual #225 // Method java/lang/Boolean.booleanValue:()Z\n 118: invokestatic #256 // Method main$addToCache:(Ljava/util/Map;Ljava/lang/Iterable;Z)Z\n 121: ireturn\n 122: aload 7\n 124: aload_3\n 125: aload 4\n 127: invokestatic #258 // Method main$outsideRange:(LPoint3D;LPoint3D;LPoint3D;)Z\n 130: ifeq 144\n 133: aload_1\n 134: aload 6\n 136: checkcast #76 // class java/lang/Iterable\n 139: iconst_0\n 140: invokestatic #256 // Method main$addToCache:(Ljava/util/Map;Ljava/lang/Iterable;Z)Z\n 143: ireturn\n 144: aload 5\n 146: aload 7\n 148: invokestatic #260 // Method main$sides:(LPoint3D;)Ljava/util/List;\n 151: checkcast #76 // class java/lang/Iterable\n 154: astore 8\n 156: astore 17\n 158: iconst_0\n 159: istore 9\n 161: aload 8\n 163: astore 10\n 165: new #78 // class java/util/ArrayList\n 168: dup\n 169: invokespecial #261 // Method java/util/ArrayList.\"<init>\":()V\n 172: checkcast #88 // class java/util/Collection\n 175: astore 11\n 177: iconst_0\n 178: istore 12\n 180: aload 10\n 182: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 187: astore 13\n 189: aload 13\n 191: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 196: ifeq 250\n 199: aload 13\n 201: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 206: astore 14\n 208: aload 14\n 210: checkcast #114 // class Point3D\n 213: astore 15\n 215: iconst_0\n 216: istore 16\n 218: aload_2\n 219: aload 15\n 221: invokeinterface #264, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 226: ifne 233\n 229: iconst_1\n 230: goto 234\n 233: iconst_0\n 234: ifeq 189\n 237: aload 11\n 239: aload 14\n 241: invokeinterface #131, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 246: pop\n 247: goto 189\n 250: aload 11\n 252: checkcast #66 // class java/util/List\n 255: nop\n 256: aload 17\n 258: swap\n 259: checkcast #88 // class java/util/Collection\n 262: invokevirtual #268 // Method kotlin/collections/ArrayDeque.addAll:(Ljava/util/Collection;)Z\n 265: pop\n 266: goto 58\n 269: aload_1\n 270: aload 6\n 272: checkcast #76 // class java/lang/Iterable\n 275: iconst_1\n 276: invokestatic #256 // Method main$addToCache:(Ljava/util/Map;Ljava/lang/Iterable;Z)Z\n 279: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #284 // Method main$parsePoints:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: aload_1\n 6: checkcast #76 // class java/lang/Iterable\n 9: astore_2\n 10: iconst_0\n 11: istore_3\n 12: aload_2\n 13: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 18: astore 4\n 20: aload 4\n 22: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 27: ifeq 178\n 30: aload 4\n 32: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 37: astore 5\n 39: iload_3\n 40: aload 5\n 42: checkcast #114 // class Point3D\n 45: astore 6\n 47: istore 15\n 49: iconst_0\n 50: istore 7\n 52: aload 6\n 54: invokestatic #260 // Method main$sides:(LPoint3D;)Ljava/util/List;\n 57: checkcast #76 // class java/lang/Iterable\n 60: astore 8\n 62: iconst_0\n 63: istore 9\n 65: aload 8\n 67: instanceof #88 // class java/util/Collection\n 70: ifeq 90\n 73: aload 8\n 75: checkcast #88 // class java/util/Collection\n 78: invokeinterface #285, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 83: ifeq 90\n 86: iconst_0\n 87: goto 166\n 90: iconst_0\n 91: istore 10\n 93: aload 8\n 95: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 100: astore 11\n 102: aload 11\n 104: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 109: ifeq 164\n 112: aload 11\n 114: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 119: astore 12\n 121: aload 12\n 123: checkcast #114 // class Point3D\n 126: astore 13\n 128: iconst_0\n 129: istore 14\n 131: aload_1\n 132: aload 13\n 134: invokeinterface #264, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 139: ifne 146\n 142: iconst_1\n 143: goto 147\n 146: iconst_0\n 147: ifeq 102\n 150: iinc 10, 1\n 153: iload 10\n 155: ifge 102\n 158: invokestatic #288 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 161: goto 102\n 164: iload 10\n 166: nop\n 167: istore 16\n 169: iload 15\n 171: iload 16\n 173: iadd\n 174: istore_3\n 175: goto 20\n 178: iload_3\n 179: ireturn\n\n private static final int main$part2(java.util.Map<Point3D, java.lang.Boolean>, java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: invokestatic #284 // Method main$parsePoints:(Ljava/util/List;)Ljava/util/List;\n 4: astore_2\n 5: aload_2\n 6: checkcast #76 // class java/lang/Iterable\n 9: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 14: astore 5\n 16: aload 5\n 18: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 23: ifne 34\n 26: new #297 // class java/util/NoSuchElementException\n 29: dup\n 30: invokespecial #298 // Method java/util/NoSuchElementException.\"<init>\":()V\n 33: athrow\n 34: aload 5\n 36: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 41: checkcast #114 // class Point3D\n 44: astore 6\n 46: iconst_0\n 47: istore 7\n 49: aload 6\n 51: invokevirtual #179 // Method Point3D.getX:()I\n 54: istore 6\n 56: aload 5\n 58: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 63: ifeq 102\n 66: aload 5\n 68: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 73: checkcast #114 // class Point3D\n 76: astore 7\n 78: iconst_0\n 79: istore 8\n 81: aload 7\n 83: invokevirtual #179 // Method Point3D.getX:()I\n 86: istore 7\n 88: iload 6\n 90: iload 7\n 92: if_icmple 56\n 95: iload 7\n 97: istore 6\n 99: goto 56\n 102: iload 6\n 104: aload_2\n 105: checkcast #76 // class java/lang/Iterable\n 108: astore 4\n 110: istore 23\n 112: aload 4\n 114: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 119: astore 5\n 121: aload 5\n 123: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 128: ifne 139\n 131: new #297 // class java/util/NoSuchElementException\n 134: dup\n 135: invokespecial #298 // Method java/util/NoSuchElementException.\"<init>\":()V\n 138: athrow\n 139: aload 5\n 141: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 146: checkcast #114 // class Point3D\n 149: astore 6\n 151: iconst_0\n 152: istore 7\n 154: aload 6\n 156: invokevirtual #182 // Method Point3D.getY:()I\n 159: istore 6\n 161: aload 5\n 163: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 168: ifeq 207\n 171: aload 5\n 173: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 178: checkcast #114 // class Point3D\n 181: astore 7\n 183: iconst_0\n 184: istore 8\n 186: aload 7\n 188: invokevirtual #182 // Method Point3D.getY:()I\n 191: istore 7\n 193: iload 6\n 195: iload 7\n 197: if_icmple 161\n 200: iload 7\n 202: istore 6\n 204: goto 161\n 207: iload 6\n 209: istore 24\n 211: iload 23\n 213: iload 24\n 215: aload_2\n 216: checkcast #76 // class java/lang/Iterable\n 219: astore 4\n 221: istore 24\n 223: istore 23\n 225: aload 4\n 227: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 232: astore 5\n 234: aload 5\n 236: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 241: ifne 252\n 244: new #297 // class java/util/NoSuchElementException\n 247: dup\n 248: invokespecial #298 // Method java/util/NoSuchElementException.\"<init>\":()V\n 251: athrow\n 252: aload 5\n 254: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 259: checkcast #114 // class Point3D\n 262: astore 6\n 264: iconst_0\n 265: istore 7\n 267: aload 6\n 269: invokevirtual #185 // Method Point3D.getZ:()I\n 272: istore 6\n 274: aload 5\n 276: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 281: ifeq 320\n 284: aload 5\n 286: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 291: checkcast #114 // class Point3D\n 294: astore 7\n 296: iconst_0\n 297: istore 8\n 299: aload 7\n 301: invokevirtual #185 // Method Point3D.getZ:()I\n 304: istore 7\n 306: iload 6\n 308: iload 7\n 310: if_icmple 274\n 313: iload 7\n 315: istore 6\n 317: goto 274\n 320: iload 6\n 322: istore 25\n 324: iload 23\n 326: iload 24\n 328: iload 25\n 330: istore 26\n 332: istore 27\n 334: istore 28\n 336: new #114 // class Point3D\n 339: dup\n 340: iload 28\n 342: iload 27\n 344: iload 26\n 346: invokespecial #127 // Method Point3D.\"<init>\":(III)V\n 349: astore_3\n 350: aload_2\n 351: checkcast #76 // class java/lang/Iterable\n 354: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 359: astore 6\n 361: aload 6\n 363: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 368: ifne 379\n 371: new #297 // class java/util/NoSuchElementException\n 374: dup\n 375: invokespecial #298 // Method java/util/NoSuchElementException.\"<init>\":()V\n 378: athrow\n 379: aload 6\n 381: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 386: checkcast #114 // class Point3D\n 389: astore 7\n 391: iconst_0\n 392: istore 8\n 394: aload 7\n 396: invokevirtual #179 // Method Point3D.getX:()I\n 399: istore 7\n 401: aload 6\n 403: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 408: ifeq 447\n 411: aload 6\n 413: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 418: checkcast #114 // class Point3D\n 421: astore 8\n 423: iconst_0\n 424: istore 9\n 426: aload 8\n 428: invokevirtual #179 // Method Point3D.getX:()I\n 431: istore 8\n 433: iload 7\n 435: iload 8\n 437: if_icmpge 401\n 440: iload 8\n 442: istore 7\n 444: goto 401\n 447: iload 7\n 449: aload_2\n 450: checkcast #76 // class java/lang/Iterable\n 453: astore 5\n 455: istore 23\n 457: aload 5\n 459: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 464: astore 6\n 466: aload 6\n 468: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 473: ifne 484\n 476: new #297 // class java/util/NoSuchElementException\n 479: dup\n 480: invokespecial #298 // Method java/util/NoSuchElementException.\"<init>\":()V\n 483: athrow\n 484: aload 6\n 486: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 491: checkcast #114 // class Point3D\n 494: astore 7\n 496: iconst_0\n 497: istore 8\n 499: aload 7\n 501: invokevirtual #182 // Method Point3D.getY:()I\n 504: istore 7\n 506: aload 6\n 508: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 513: ifeq 552\n 516: aload 6\n 518: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 523: checkcast #114 // class Point3D\n 526: astore 8\n 528: iconst_0\n 529: istore 9\n 531: aload 8\n 533: invokevirtual #182 // Method Point3D.getY:()I\n 536: istore 8\n 538: iload 7\n 540: iload 8\n 542: if_icmpge 506\n 545: iload 8\n 547: istore 7\n 549: goto 506\n 552: iload 7\n 554: istore 24\n 556: iload 23\n 558: iload 24\n 560: aload_2\n 561: checkcast #76 // class java/lang/Iterable\n 564: astore 5\n 566: istore 24\n 568: istore 23\n 570: aload 5\n 572: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 577: astore 6\n 579: aload 6\n 581: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 586: ifne 597\n 589: new #297 // class java/util/NoSuchElementException\n 592: dup\n 593: invokespecial #298 // Method java/util/NoSuchElementException.\"<init>\":()V\n 596: athrow\n 597: aload 6\n 599: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 604: checkcast #114 // class Point3D\n 607: astore 7\n 609: iconst_0\n 610: istore 8\n 612: aload 7\n 614: invokevirtual #185 // Method Point3D.getZ:()I\n 617: istore 7\n 619: aload 6\n 621: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 626: ifeq 665\n 629: aload 6\n 631: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 636: checkcast #114 // class Point3D\n 639: astore 8\n 641: iconst_0\n 642: istore 9\n 644: aload 8\n 646: invokevirtual #185 // Method Point3D.getZ:()I\n 649: istore 8\n 651: iload 7\n 653: iload 8\n 655: if_icmpge 619\n 658: iload 8\n 660: istore 7\n 662: goto 619\n 665: iload 7\n 667: istore 25\n 669: iload 23\n 671: iload 24\n 673: iload 25\n 675: istore 29\n 677: istore 30\n 679: istore 31\n 681: new #114 // class Point3D\n 684: dup\n 685: iload 31\n 687: iload 30\n 689: iload 29\n 691: invokespecial #127 // Method Point3D.\"<init>\":(III)V\n 694: astore 4\n 696: aload_2\n 697: checkcast #76 // class java/lang/Iterable\n 700: astore 6\n 702: iconst_0\n 703: istore 7\n 705: aload 6\n 707: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 712: astore 8\n 714: aload 8\n 716: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 721: ifeq 980\n 724: aload 8\n 726: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 731: astore 9\n 733: iload 7\n 735: aload 9\n 737: checkcast #114 // class Point3D\n 740: astore 10\n 742: istore 21\n 744: iconst_0\n 745: istore 11\n 747: aload 10\n 749: invokestatic #260 // Method main$sides:(LPoint3D;)Ljava/util/List;\n 752: checkcast #76 // class java/lang/Iterable\n 755: astore 12\n 757: iconst_0\n 758: istore 13\n 760: aload 12\n 762: astore 14\n 764: new #78 // class java/util/ArrayList\n 767: dup\n 768: invokespecial #261 // Method java/util/ArrayList.\"<init>\":()V\n 771: checkcast #88 // class java/util/Collection\n 774: astore 15\n 776: iconst_0\n 777: istore 16\n 779: aload 14\n 781: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 786: astore 17\n 788: aload 17\n 790: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 795: ifeq 849\n 798: aload 17\n 800: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 805: astore 18\n 807: aload 18\n 809: checkcast #114 // class Point3D\n 812: astore 19\n 814: iconst_0\n 815: istore 20\n 817: aload_2\n 818: aload 19\n 820: invokeinterface #264, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 825: ifne 832\n 828: iconst_1\n 829: goto 833\n 832: iconst_0\n 833: ifeq 788\n 836: aload 15\n 838: aload 18\n 840: invokeinterface #131, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 845: pop\n 846: goto 788\n 849: aload 15\n 851: checkcast #66 // class java/util/List\n 854: nop\n 855: checkcast #76 // class java/lang/Iterable\n 858: astore 12\n 860: nop\n 861: iconst_0\n 862: istore 13\n 864: aload 12\n 866: instanceof #88 // class java/util/Collection\n 869: ifeq 889\n 872: aload 12\n 874: checkcast #88 // class java/util/Collection\n 877: invokeinterface #285, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 882: ifeq 889\n 885: iconst_0\n 886: goto 967\n 889: iconst_0\n 890: istore 14\n 892: aload 12\n 894: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 899: astore 15\n 901: aload 15\n 903: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 908: ifeq 965\n 911: aload 15\n 913: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 918: astore 16\n 920: aload 16\n 922: checkcast #114 // class Point3D\n 925: astore 17\n 927: iconst_0\n 928: istore 18\n 930: aload 17\n 932: aload_0\n 933: aload_2\n 934: aload_3\n 935: aload 4\n 937: invokestatic #300 // Method main$isAir:(LPoint3D;Ljava/util/Map;Ljava/util/List;LPoint3D;LPoint3D;)Z\n 940: ifne 947\n 943: iconst_1\n 944: goto 948\n 947: iconst_0\n 948: ifeq 901\n 951: iinc 14, 1\n 954: iload 14\n 956: ifge 901\n 959: invokestatic #288 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 962: goto 901\n 965: iload 14\n 967: nop\n 968: istore 22\n 970: iload 21\n 972: iload 22\n 974: iadd\n 975: istore 7\n 977: goto 714\n 980: iload 7\n 982: istore 5\n 984: iload 5\n 986: ireturn\n}\n",
"javap_err": ""
}
] |
dizney__aoc-2022-in-kotlin__f684a4e/src/Day01.kt
|
const val PART1_EXPECTED_HIGHEST_CALORIES = 24000
const val PART2_EXPECTED_HIGHEST_3_CALORIES_SUM = 45000
const val PART2_TOP_ELF_COUNT = 3
fun main() {
fun elfTotals(input: List<String>, idx: Int = 0, elfAmount: Int = 0, totals: List<Int> = emptyList()): List<Int> {
if (idx >= input.size) return totals + elfAmount
return elfTotals(
input,
idx + 1,
if (input[idx].isBlank()) 0 else elfAmount + input[idx].toInt(),
if (input[idx].isBlank()) totals + elfAmount else totals
)
}
fun part1(input: List<String>): Int {
return elfTotals(input).maxOf { it }
}
fun part2(input: List<String>): Int {
val elfTotals = elfTotals(input)
return elfTotals.sortedDescending().take(PART2_TOP_ELF_COUNT).sum()
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day01_test")
check(part1(testInput) == PART1_EXPECTED_HIGHEST_CALORIES)
check(part2(testInput) == PART2_EXPECTED_HIGHEST_3_CALORIES_SUM)
val input = readInput("Day01")
println(part1(input))
println(part2(input))
// fun part1(input: List<String>): Int {
// var currentMax = 0
// var elfTotal = 0
// input.forEach {
// if (it.isBlank()) {
// if (elfTotal > currentMax) {
// currentMax = elfTotal
// }
// elfTotal = 0
// } else {
// elfTotal += it.toInt()
// }
// }
// return currentMax
// }
//
}
|
[
{
"class_path": "dizney__aoc-2022-in-kotlin__f684a4e/Day01Kt.class",
"javap": "Compiled from \"Day01.kt\"\npublic final class Day01Kt {\n public static final int PART1_EXPECTED_HIGHEST_CALORIES;\n\n public static final int PART2_EXPECTED_HIGHEST_3_CALORIES_SUM;\n\n public static final int PART2_TOP_ELF_COUNT;\n\n public static final void main();\n Code:\n 0: ldc #8 // String Day01_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 10: sipush 24000\n 13: if_icmpne 20\n 16: iconst_1\n 17: goto 21\n 20: iconst_0\n 21: ifne 34\n 24: new #20 // class java/lang/IllegalStateException\n 27: dup\n 28: ldc #22 // String Check failed.\n 30: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 33: athrow\n 34: aload_0\n 35: invokestatic #29 // Method main$part2:(Ljava/util/List;)I\n 38: ldc #30 // int 45000\n 40: if_icmpne 47\n 43: iconst_1\n 44: goto 48\n 47: iconst_0\n 48: ifne 61\n 51: new #20 // class java/lang/IllegalStateException\n 54: dup\n 55: ldc #22 // String Check failed.\n 57: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 60: athrow\n 61: ldc #32 // String Day01\n 63: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 66: astore_1\n 67: aload_1\n 68: invokestatic #18 // Method main$part1:(Ljava/util/List;)I\n 71: istore_2\n 72: getstatic #38 // Field java/lang/System.out:Ljava/io/PrintStream;\n 75: iload_2\n 76: invokevirtual #44 // Method java/io/PrintStream.println:(I)V\n 79: aload_1\n 80: invokestatic #29 // Method main$part2:(Ljava/util/List;)I\n 83: istore_2\n 84: getstatic #38 // Field java/lang/System.out:Ljava/io/PrintStream;\n 87: iload_2\n 88: invokevirtual #44 // Method java/io/PrintStream.println:(I)V\n 91: return\n\n 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$elfTotals(java.util.List<java.lang.String>, int, int, java.util.List<java.lang.Integer>);\n Code:\n 0: iload_1\n 1: aload_0\n 2: invokeinterface #61, 1 // InterfaceMethod java/util/List.size:()I\n 7: if_icmplt 22\n 10: aload_3\n 11: checkcast #63 // class java/util/Collection\n 14: iload_2\n 15: invokestatic #69 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 18: invokestatic #75 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 21: areturn\n 22: aload_0\n 23: iload_1\n 24: iconst_1\n 25: iadd\n 26: aload_0\n 27: iload_1\n 28: invokeinterface #79, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 33: checkcast #81 // class java/lang/CharSequence\n 36: invokestatic #87 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 39: ifeq 46\n 42: iconst_0\n 43: goto 61\n 46: iload_2\n 47: aload_0\n 48: iload_1\n 49: invokeinterface #79, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 54: checkcast #89 // class java/lang/String\n 57: invokestatic #93 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 60: iadd\n 61: aload_0\n 62: iload_1\n 63: invokeinterface #79, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 68: checkcast #81 // class java/lang/CharSequence\n 71: invokestatic #87 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 74: ifeq 91\n 77: aload_3\n 78: checkcast #63 // class java/util/Collection\n 81: iload_2\n 82: invokestatic #69 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 85: invokestatic #75 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 88: goto 92\n 91: aload_3\n 92: invokestatic #95 // Method main$elfTotals:(Ljava/util/List;IILjava/util/List;)Ljava/util/List;\n 95: areturn\n\n static java.util.List main$elfTotals$default(java.util.List, int, int, java.util.List, int, java.lang.Object);\n Code:\n 0: iload 4\n 2: iconst_2\n 3: iand\n 4: ifeq 9\n 7: iconst_0\n 8: istore_1\n 9: iload 4\n 11: iconst_4\n 12: iand\n 13: ifeq 18\n 16: iconst_0\n 17: istore_2\n 18: iload 4\n 20: bipush 8\n 22: iand\n 23: ifeq 30\n 26: invokestatic #105 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 29: astore_3\n 30: aload_0\n 31: iload_1\n 32: iload_2\n 33: aload_3\n 34: invokestatic #95 // Method main$elfTotals:(Ljava/util/List;IILjava/util/List;)Ljava/util/List;\n 37: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: iconst_0\n 2: iconst_0\n 3: aconst_null\n 4: bipush 14\n 6: aconst_null\n 7: invokestatic #108 // Method main$elfTotals$default:(Ljava/util/List;IILjava/util/List;ILjava/lang/Object;)Ljava/util/List;\n 10: checkcast #110 // class java/lang/Iterable\n 13: invokeinterface #114, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 18: astore_1\n 19: aload_1\n 20: invokeinterface #120, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 25: ifne 36\n 28: new #122 // class java/util/NoSuchElementException\n 31: dup\n 32: invokespecial #124 // Method java/util/NoSuchElementException.\"<init>\":()V\n 35: athrow\n 36: aload_1\n 37: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 42: checkcast #130 // class java/lang/Number\n 45: invokevirtual #133 // Method java/lang/Number.intValue:()I\n 48: istore_2\n 49: iconst_0\n 50: istore_3\n 51: iload_2\n 52: istore_2\n 53: aload_1\n 54: invokeinterface #120, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 90\n 62: aload_1\n 63: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 68: checkcast #130 // class java/lang/Number\n 71: invokevirtual #133 // Method java/lang/Number.intValue:()I\n 74: istore_3\n 75: iconst_0\n 76: istore 4\n 78: iload_3\n 79: istore_3\n 80: iload_2\n 81: iload_3\n 82: if_icmpge 53\n 85: iload_3\n 86: istore_2\n 87: goto 53\n 90: iload_2\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: iconst_0\n 2: iconst_0\n 3: aconst_null\n 4: bipush 14\n 6: aconst_null\n 7: invokestatic #108 // Method main$elfTotals$default:(Ljava/util/List;IILjava/util/List;ILjava/lang/Object;)Ljava/util/List;\n 10: astore_1\n 11: aload_1\n 12: checkcast #110 // class java/lang/Iterable\n 15: invokestatic #139 // Method kotlin/collections/CollectionsKt.sortedDescending:(Ljava/lang/Iterable;)Ljava/util/List;\n 18: checkcast #110 // class java/lang/Iterable\n 21: iconst_3\n 22: invokestatic #143 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 25: checkcast #110 // class java/lang/Iterable\n 28: invokestatic #147 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 31: ireturn\n}\n",
"javap_err": ""
}
] |
Jeff-Gillot__word-clique__4b11007/src/main/kotlin/Main.kt
|
import java.io.File
import kotlin.system.measureTimeMillis
fun main() {
val time = measureTimeMillis {
// Read the words and keep only 5 letters words
val textWords = File(Signature::class.java.getResource("words_alpha.txt")!!.toURI())
.readLines()
.filter { it.length == 5 }
// Let's group the words by their signature and only keep the words that have 5 distinct letters
// Also the signature is the same for anagrams since we don't keep track of the order of letters in the signature
val wordsBySignature: Map<Signature, List<String>> = textWords
.groupBy { it.toSignature() }
.filterKeys { it.distinctLetters() == 5 }
// We get the letters and the number of time those letters appears in each signature
// We'll use that to start with the least common letters first
val letterCount = letters.values
.associateWith { letter -> wordsBySignature.keys.fold(0) { acc, signature -> if (letter in signature) acc + 1 else acc } }.toList()
.sortedBy { it.second }
.toMap()
println("--- Letters and occurrences")
letterCount.forEach { (letterSignature, count) -> println("${letterSignature.letter()} -> $count") }
// Fortunately all of those methods keep the order so it's very useful
val orderedLetters = letterCount.keys
// We group the word signatures by the first of the letter from the ordered letters
// This works because we will try to fill in the letters using the same order
val wordsByLetter = wordsBySignature
.keys
.groupBy { word -> orderedLetters.first { letter -> letter in word } }
println("--- Letters and words count associated to it")
wordsByLetter.forEach { (letterSignature, words) -> println("${letterSignature.letter()} -> ${words.size}") }
println("--- Starting the solver loop")
var solution = listOf(WordGroup(emptyList(), Signature.empty))
orderedLetters.forEachIndexed { index, letter ->
val newSolution = mutableListOf<WordGroup>()
//This is all the letters that we tried to add so far + the current one
val expectedLetters = letterCount.keys.take(index + 1).merge()
//We add the previous groups that have all the letters - 1 (we want solution that have 25 of the 26 letters so we can have 1 gap)
solution
.filter { it.signature.commonLetters(expectedLetters).distinctLetters() >= index }
.let { newSolution.addAll(it) }
val wordsToCheck = wordsByLetter[letter] ?: emptyList()
println("${lettersInverted[letter]} -> Words to check ${wordsToCheck.size}")
// Do a cartesian product of the current solutions and words for this letter
// Ignore any word that creates has duplicate letters or that do not have enough distinct letters (1 gap max)
wordsToCheck
.flatMap { word ->
solution
.filter { word !in it }
.map { it + word }
.filter { it.signature.commonLetters(expectedLetters).distinctLetters() >= index }
}
.let { newSolution.addAll(it) }
// Update the solution with the new result
solution = newSolution
println("${lettersInverted[letter]} -> Current solution ${solution.size}")
}
// Now that we the solutions but we probably want to output it
// The solution removed the anagrams and only contains the signatures we need to transform that back into words
val words = solution
.flatMap { it.toWords(wordsBySignature) }
.onEach { println(it.joinToString(" ")) }
println()
println("Total possibilities including anagrams: ${words.size}")
println()
println("Total possibilities excluding anagrams: ${solution.size}")
}
println("${time / 1000.0} seconds")
}
// The signature is a bitset representation of the word each bit represent whether a letter is present or not
@JvmInline
value class Signature(private val value: Int) {
operator fun plus(other: Signature): Signature = Signature(value or other.value)
operator fun contains(other: Signature): Boolean = value and other.value != 0
fun distinctLetters(): Int = value.countOneBits()
fun commonLetters(other: Signature) = Signature(value and other.value)
fun letter(): Char {
if (distinctLetters() == 1) {
return lettersInverted[this]!!
} else {
throw IllegalStateException("There is more than one letter in this signature")
}
}
companion object {
val empty = Signature(0)
}
}
fun Iterable<Signature>.merge(): Signature = fold(Signature.empty) { acc, signature -> acc + signature }
data class WordGroup(
val words: List<Signature>,
val signature: Signature,
) {
operator fun contains(word: Signature): Boolean = word in signature
operator fun plus(word: Signature): WordGroup = WordGroup(words + word, signature + word)
fun toWords(wordsBySignature: Map<Signature, List<String>>): List<List<String>> {
return words
.map { wordSignature -> wordsBySignature[wordSignature]!! }
.fold(emptyList()) { acc, words ->
if (acc.isEmpty()) {
words.map { listOf(it) }
} else {
words.flatMap { word -> acc.map { it + word } }
}
}
}
}
// Each letter has its own signature
val letters = mapOf(
'a' to Signature(0b00000000000000000000000001),
'b' to Signature(0b00000000000000000000000010),
'c' to Signature(0b00000000000000000000000100),
'd' to Signature(0b00000000000000000000001000),
'e' to Signature(0b00000000000000000000010000),
'f' to Signature(0b00000000000000000000100000),
'g' to Signature(0b00000000000000000001000000),
'h' to Signature(0b00000000000000000010000000),
'i' to Signature(0b00000000000000000100000000),
'j' to Signature(0b00000000000000001000000000),
'k' to Signature(0b00000000000000010000000000),
'l' to Signature(0b00000000000000100000000000),
'm' to Signature(0b00000000000001000000000000),
'n' to Signature(0b00000000000010000000000000),
'o' to Signature(0b00000000000100000000000000),
'p' to Signature(0b00000000001000000000000000),
'q' to Signature(0b00000000010000000000000000),
'r' to Signature(0b00000000100000000000000000),
's' to Signature(0b00000001000000000000000000),
't' to Signature(0b00000010000000000000000000),
'u' to Signature(0b00000100000000000000000000),
'v' to Signature(0b00001000000000000000000000),
'w' to Signature(0b00010000000000000000000000),
'x' to Signature(0b00100000000000000000000000),
'y' to Signature(0b01000000000000000000000000),
'z' to Signature(0b10000000000000000000000000),
)
val lettersInverted = mapOf(
Signature(0b00000000000000000000000001) to 'a',
Signature(0b00000000000000000000000010) to 'b',
Signature(0b00000000000000000000000100) to 'c',
Signature(0b00000000000000000000001000) to 'd',
Signature(0b00000000000000000000010000) to 'e',
Signature(0b00000000000000000000100000) to 'f',
Signature(0b00000000000000000001000000) to 'g',
Signature(0b00000000000000000010000000) to 'h',
Signature(0b00000000000000000100000000) to 'i',
Signature(0b00000000000000001000000000) to 'j',
Signature(0b00000000000000010000000000) to 'k',
Signature(0b00000000000000100000000000) to 'l',
Signature(0b00000000000001000000000000) to 'm',
Signature(0b00000000000010000000000000) to 'n',
Signature(0b00000000000100000000000000) to 'o',
Signature(0b00000000001000000000000000) to 'p',
Signature(0b00000000010000000000000000) to 'q',
Signature(0b00000000100000000000000000) to 'r',
Signature(0b00000001000000000000000000) to 's',
Signature(0b00000010000000000000000000) to 't',
Signature(0b00000100000000000000000000) to 'u',
Signature(0b00001000000000000000000000) to 'v',
Signature(0b00010000000000000000000000) to 'w',
Signature(0b00100000000000000000000000) to 'x',
Signature(0b01000000000000000000000000) to 'y',
Signature(0b10000000000000000000000000) to 'z',
)
fun String.toSignature(): Signature = map { letters[it]!! }.merge()
|
[
{
"class_path": "Jeff-Gillot__word-clique__4b11007/MainKt$main$lambda$20$$inlined$sortedBy$1.class",
"javap": "Compiled from \"Comparisons.kt\"\npublic final class MainKt$main$lambda$20$$inlined$sortedBy$1<T> implements java.util.Comparator {\n public MainKt$main$lambda$20$$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": ""
},
{
"class_path": "Jeff-Gillot__word-clique__4b11007/MainKt.class",
"javap": "Compiled from \"Main.kt\"\npublic final class MainKt {\n private static final java.util.Map<java.lang.Character, Signature> letters;\n\n private static final java.util.Map<Signature, java.lang.Character> lettersInverted;\n\n public static final void main();\n Code:\n 0: iconst_0\n 1: istore_2\n 2: invokestatic #12 // Method java/lang/System.currentTimeMillis:()J\n 5: lstore_3\n 6: iconst_0\n 7: istore 5\n 9: new #14 // class java/io/File\n 12: dup\n 13: ldc #16 // class Signature\n 15: ldc #18 // String words_alpha.txt\n 17: invokevirtual #24 // Method java/lang/Class.getResource:(Ljava/lang/String;)Ljava/net/URL;\n 20: dup\n 21: invokestatic #30 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 24: invokevirtual #36 // Method java/net/URL.toURI:()Ljava/net/URI;\n 27: invokespecial #40 // Method java/io/File.\"<init>\":(Ljava/net/URI;)V\n 30: aconst_null\n 31: iconst_1\n 32: aconst_null\n 33: invokestatic #46 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 36: checkcast #48 // class java/lang/Iterable\n 39: astore 6\n 41: nop\n 42: iconst_0\n 43: istore 7\n 45: aload 6\n 47: astore 8\n 49: new #50 // class java/util/ArrayList\n 52: dup\n 53: invokespecial #52 // Method java/util/ArrayList.\"<init>\":()V\n 56: checkcast #54 // class java/util/Collection\n 59: astore 9\n 61: iconst_0\n 62: istore 10\n 64: aload 8\n 66: invokeinterface #58, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 71: astore 11\n 73: aload 11\n 75: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 80: ifeq 132\n 83: aload 11\n 85: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 90: astore 12\n 92: aload 12\n 94: checkcast #70 // class java/lang/String\n 97: astore 13\n 99: iconst_0\n 100: istore 14\n 102: aload 13\n 104: invokevirtual #74 // Method java/lang/String.length:()I\n 107: iconst_5\n 108: if_icmpne 115\n 111: iconst_1\n 112: goto 116\n 115: iconst_0\n 116: ifeq 73\n 119: aload 9\n 121: aload 12\n 123: invokeinterface #78, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 128: pop\n 129: goto 73\n 132: aload 9\n 134: checkcast #80 // class java/util/List\n 137: nop\n 138: astore 15\n 140: aload 15\n 142: checkcast #48 // class java/lang/Iterable\n 145: astore 7\n 147: nop\n 148: iconst_0\n 149: istore 8\n 151: aload 7\n 153: astore 9\n 155: new #82 // class java/util/LinkedHashMap\n 158: dup\n 159: invokespecial #83 // Method java/util/LinkedHashMap.\"<init>\":()V\n 162: checkcast #85 // class java/util/Map\n 165: astore 10\n 167: iconst_0\n 168: istore 11\n 170: aload 9\n 172: invokeinterface #58, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 177: astore 12\n 179: aload 12\n 181: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 186: ifeq 294\n 189: aload 12\n 191: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 196: astore 13\n 198: aload 13\n 200: checkcast #70 // class java/lang/String\n 203: astore 14\n 205: iconst_0\n 206: istore 16\n 208: aload 14\n 210: invokestatic #89 // Method toSignature:(Ljava/lang/String;)I\n 213: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 216: astore 17\n 218: aload 10\n 220: astore 18\n 222: iconst_0\n 223: istore 19\n 225: aload 18\n 227: aload 17\n 229: invokeinterface #97, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 234: astore 20\n 236: aload 20\n 238: ifnonnull 273\n 241: iconst_0\n 242: istore 21\n 244: new #50 // class java/util/ArrayList\n 247: dup\n 248: invokespecial #52 // Method java/util/ArrayList.\"<init>\":()V\n 251: checkcast #80 // class java/util/List\n 254: astore 21\n 256: aload 18\n 258: aload 17\n 260: aload 21\n 262: invokeinterface #101, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 267: pop\n 268: aload 21\n 270: goto 275\n 273: aload 20\n 275: nop\n 276: checkcast #80 // class java/util/List\n 279: astore 14\n 281: aload 14\n 283: aload 13\n 285: invokeinterface #102, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 290: pop\n 291: goto 179\n 294: aload 10\n 296: nop\n 297: astore 7\n 299: nop\n 300: iconst_0\n 301: istore 8\n 303: new #82 // class java/util/LinkedHashMap\n 306: dup\n 307: invokespecial #83 // Method java/util/LinkedHashMap.\"<init>\":()V\n 310: astore 9\n 312: aload 7\n 314: invokeinterface #106, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 319: invokeinterface #109, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 324: astore 10\n 326: aload 10\n 328: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 333: ifeq 406\n 336: aload 10\n 338: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 343: checkcast #111 // class java/util/Map$Entry\n 346: astore 11\n 348: aload 11\n 350: invokeinterface #114, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 355: checkcast #16 // class Signature\n 358: invokevirtual #117 // Method Signature.\"unbox-impl\":()I\n 361: istore 12\n 363: iconst_0\n 364: istore 13\n 366: iload 12\n 368: invokestatic #121 // Method Signature.\"distinctLetters-impl\":(I)I\n 371: iconst_5\n 372: if_icmpne 379\n 375: iconst_1\n 376: goto 380\n 379: iconst_0\n 380: ifeq 326\n 383: aload 9\n 385: aload 11\n 387: invokeinterface #114, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 392: aload 11\n 394: invokeinterface #124, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 399: invokevirtual #125 // Method java/util/LinkedHashMap.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 402: pop\n 403: goto 326\n 406: aload 9\n 408: checkcast #85 // class java/util/Map\n 411: astore 6\n 413: getstatic #129 // Field letters:Ljava/util/Map;\n 416: invokeinterface #133, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 421: checkcast #48 // class java/lang/Iterable\n 424: astore 8\n 426: nop\n 427: iconst_0\n 428: istore 9\n 430: new #82 // class java/util/LinkedHashMap\n 433: dup\n 434: aload 8\n 436: bipush 10\n 438: invokestatic #139 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 441: invokestatic #144 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 444: bipush 16\n 446: invokestatic #150 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 449: invokespecial #153 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 452: astore 10\n 454: aload 8\n 456: astore 11\n 458: iconst_0\n 459: istore 12\n 461: aload 11\n 463: invokeinterface #58, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 468: astore 13\n 470: aload 13\n 472: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 477: ifeq 627\n 480: aload 13\n 482: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 487: astore 14\n 489: aload 10\n 491: checkcast #85 // class java/util/Map\n 494: aload 14\n 496: aload 14\n 498: checkcast #16 // class Signature\n 501: invokevirtual #117 // Method Signature.\"unbox-impl\":()I\n 504: istore 16\n 506: astore 22\n 508: astore 23\n 510: iconst_0\n 511: istore 17\n 513: aload 6\n 515: invokeinterface #156, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 520: checkcast #48 // class java/lang/Iterable\n 523: astore 18\n 525: iconst_0\n 526: istore 19\n 528: iconst_0\n 529: istore 20\n 531: iload 19\n 533: istore 21\n 535: aload 18\n 537: invokeinterface #58, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 542: astore 24\n 544: aload 24\n 546: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 551: ifeq 604\n 554: aload 24\n 556: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 561: astore 25\n 563: iload 21\n 565: aload 25\n 567: checkcast #16 // class Signature\n 570: invokevirtual #117 // Method Signature.\"unbox-impl\":()I\n 573: istore 26\n 575: istore 27\n 577: iconst_0\n 578: istore 28\n 580: iload 26\n 582: iload 16\n 584: invokestatic #160 // Method Signature.\"contains-yueV81A\":(II)Z\n 587: ifeq 597\n 590: iload 27\n 592: iconst_1\n 593: iadd\n 594: goto 599\n 597: iload 27\n 599: istore 21\n 601: goto 544\n 604: iload 21\n 606: nop\n 607: invokestatic #166 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 610: astore 29\n 612: aload 23\n 614: aload 22\n 616: aload 29\n 618: invokeinterface #101, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 623: pop\n 624: goto 470\n 627: aload 10\n 629: checkcast #85 // class java/util/Map\n 632: nop\n 633: invokestatic #170 // Method kotlin/collections/MapsKt.toList:(Ljava/util/Map;)Ljava/util/List;\n 636: checkcast #48 // class java/lang/Iterable\n 639: astore 8\n 641: nop\n 642: iconst_0\n 643: istore 9\n 645: aload 8\n 647: new #172 // class MainKt$main$lambda$20$$inlined$sortedBy$1\n 650: dup\n 651: invokespecial #173 // Method MainKt$main$lambda$20$$inlined$sortedBy$1.\"<init>\":()V\n 654: checkcast #175 // class java/util/Comparator\n 657: invokestatic #179 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 660: checkcast #48 // class java/lang/Iterable\n 663: invokestatic #183 // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;\n 666: astore 7\n 668: ldc #185 // String --- Letters and occurrences\n 670: getstatic #189 // Field java/lang/System.out:Ljava/io/PrintStream;\n 673: swap\n 674: invokevirtual #194 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 677: aload 7\n 679: astore 8\n 681: iconst_0\n 682: istore 9\n 684: aload 8\n 686: invokeinterface #106, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 691: invokeinterface #109, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 696: astore 10\n 698: aload 10\n 700: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 705: ifeq 797\n 708: aload 10\n 710: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 715: checkcast #111 // class java/util/Map$Entry\n 718: astore 11\n 720: aload 11\n 722: astore 12\n 724: iconst_0\n 725: istore 13\n 727: aload 12\n 729: invokeinterface #114, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 734: checkcast #16 // class Signature\n 737: invokevirtual #117 // Method Signature.\"unbox-impl\":()I\n 740: istore 14\n 742: aload 12\n 744: invokeinterface #124, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 749: checkcast #196 // class java/lang/Number\n 752: invokevirtual #199 // Method java/lang/Number.intValue:()I\n 755: istore 16\n 757: new #201 // class java/lang/StringBuilder\n 760: dup\n 761: invokespecial #202 // Method java/lang/StringBuilder.\"<init>\":()V\n 764: iload 14\n 766: invokestatic #206 // Method Signature.\"letter-impl\":(I)C\n 769: invokevirtual #210 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 772: ldc #212 // String ->\n 774: invokevirtual #215 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 777: iload 16\n 779: invokevirtual #218 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 782: invokevirtual #222 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 785: getstatic #189 // Field java/lang/System.out:Ljava/io/PrintStream;\n 788: swap\n 789: invokevirtual #194 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 792: nop\n 793: nop\n 794: goto 698\n 797: nop\n 798: aload 7\n 800: invokeinterface #156, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 805: astore 8\n 807: aload 6\n 809: invokeinterface #156, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 814: checkcast #48 // class java/lang/Iterable\n 817: astore 10\n 819: nop\n 820: iconst_0\n 821: istore 11\n 823: aload 10\n 825: astore 12\n 827: new #82 // class java/util/LinkedHashMap\n 830: dup\n 831: invokespecial #83 // Method java/util/LinkedHashMap.\"<init>\":()V\n 834: checkcast #85 // class java/util/Map\n 837: astore 13\n 839: iconst_0\n 840: istore 14\n 842: aload 12\n 844: invokeinterface #58, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 849: astore 16\n 851: aload 16\n 853: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 858: ifeq 1047\n 861: aload 16\n 863: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 868: astore 17\n 870: aload 17\n 872: checkcast #16 // class Signature\n 875: invokevirtual #117 // Method Signature.\"unbox-impl\":()I\n 878: istore 18\n 880: iconst_0\n 881: istore 19\n 883: aload 8\n 885: checkcast #48 // class java/lang/Iterable\n 888: astore 20\n 890: iconst_0\n 891: istore 21\n 893: aload 20\n 895: invokeinterface #58, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 900: astore 24\n 902: aload 24\n 904: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 909: ifeq 949\n 912: aload 24\n 914: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 919: astore 25\n 921: aload 25\n 923: checkcast #16 // class Signature\n 926: invokevirtual #117 // Method Signature.\"unbox-impl\":()I\n 929: istore 26\n 931: iconst_0\n 932: istore 27\n 934: iload 18\n 936: iload 26\n 938: invokestatic #160 // Method Signature.\"contains-yueV81A\":(II)Z\n 941: ifeq 902\n 944: aload 25\n 946: goto 959\n 949: new #224 // class java/util/NoSuchElementException\n 952: dup\n 953: ldc #226 // String Collection contains no element matching the predicate.\n 955: invokespecial #229 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 958: athrow\n 959: checkcast #16 // class Signature\n 962: invokevirtual #117 // Method Signature.\"unbox-impl\":()I\n 965: nop\n 966: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 969: astore 28\n 971: aload 13\n 973: astore 30\n 975: iconst_0\n 976: istore 31\n 978: aload 30\n 980: aload 28\n 982: invokeinterface #97, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 987: astore 32\n 989: aload 32\n 991: ifnonnull 1026\n 994: iconst_0\n 995: istore 33\n 997: new #50 // class java/util/ArrayList\n 1000: dup\n 1001: invokespecial #52 // Method java/util/ArrayList.\"<init>\":()V\n 1004: checkcast #80 // class java/util/List\n 1007: astore 33\n 1009: aload 30\n 1011: aload 28\n 1013: aload 33\n 1015: invokeinterface #101, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 1020: pop\n 1021: aload 33\n 1023: goto 1028\n 1026: aload 32\n 1028: nop\n 1029: checkcast #80 // class java/util/List\n 1032: astore 34\n 1034: aload 34\n 1036: aload 17\n 1038: invokeinterface #102, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 1043: pop\n 1044: goto 851\n 1047: aload 13\n 1049: nop\n 1050: astore 9\n 1052: ldc #231 // String --- Letters and words count associated to it\n 1054: getstatic #189 // Field java/lang/System.out:Ljava/io/PrintStream;\n 1057: swap\n 1058: invokevirtual #194 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 1061: aload 9\n 1063: astore 10\n 1065: iconst_0\n 1066: istore 11\n 1068: aload 10\n 1070: invokeinterface #106, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 1075: invokeinterface #109, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 1080: astore 12\n 1082: aload 12\n 1084: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1089: ifeq 1183\n 1092: aload 12\n 1094: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1099: checkcast #111 // class java/util/Map$Entry\n 1102: astore 13\n 1104: aload 13\n 1106: astore 14\n 1108: iconst_0\n 1109: istore 16\n 1111: aload 14\n 1113: invokeinterface #114, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 1118: checkcast #16 // class Signature\n 1121: invokevirtual #117 // Method Signature.\"unbox-impl\":()I\n 1124: istore 17\n 1126: aload 14\n 1128: invokeinterface #124, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 1133: checkcast #80 // class java/util/List\n 1136: astore 18\n 1138: new #201 // class java/lang/StringBuilder\n 1141: dup\n 1142: invokespecial #202 // Method java/lang/StringBuilder.\"<init>\":()V\n 1145: iload 17\n 1147: invokestatic #206 // Method Signature.\"letter-impl\":(I)C\n 1150: invokevirtual #210 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 1153: ldc #212 // String ->\n 1155: invokevirtual #215 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 1158: aload 18\n 1160: invokeinterface #234, 1 // InterfaceMethod java/util/List.size:()I\n 1165: invokevirtual #218 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 1168: invokevirtual #222 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 1171: getstatic #189 // Field java/lang/System.out:Ljava/io/PrintStream;\n 1174: swap\n 1175: invokevirtual #194 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 1178: nop\n 1179: nop\n 1180: goto 1082\n 1183: nop\n 1184: ldc #236 // String --- Starting the solver loop\n 1186: getstatic #189 // Field java/lang/System.out:Ljava/io/PrintStream;\n 1189: swap\n 1190: invokevirtual #194 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 1193: aconst_null\n 1194: astore 10\n 1196: new #238 // class WordGroup\n 1199: dup\n 1200: invokestatic #242 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 1203: getstatic #246 // Field Signature.Companion:LSignature$Companion;\n 1206: invokevirtual #251 // Method Signature$Companion.\"getEmpty-MrUGAVo\":()I\n 1209: aconst_null\n 1210: invokespecial #254 // Method WordGroup.\"<init>\":(Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 1213: invokestatic #258 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 1216: astore 10\n 1218: aload 8\n 1220: checkcast #48 // class java/lang/Iterable\n 1223: astore 11\n 1225: iconst_0\n 1226: istore 12\n 1228: iconst_0\n 1229: istore 13\n 1231: aload 11\n 1233: invokeinterface #58, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1238: astore 14\n 1240: aload 14\n 1242: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1247: ifeq 2021\n 1250: aload 14\n 1252: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1257: astore 16\n 1259: iload 13\n 1261: iinc 13, 1\n 1264: istore 17\n 1266: iload 17\n 1268: ifge 1274\n 1271: invokestatic #261 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 1274: iload 17\n 1276: aload 16\n 1278: checkcast #16 // class Signature\n 1281: invokevirtual #117 // Method Signature.\"unbox-impl\":()I\n 1284: istore 18\n 1286: istore 19\n 1288: iconst_0\n 1289: istore 20\n 1291: new #50 // class java/util/ArrayList\n 1294: dup\n 1295: invokespecial #52 // Method java/util/ArrayList.\"<init>\":()V\n 1298: checkcast #80 // class java/util/List\n 1301: astore 21\n 1303: aload 7\n 1305: invokeinterface #156, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 1310: checkcast #48 // class java/lang/Iterable\n 1313: iload 19\n 1315: iconst_1\n 1316: iadd\n 1317: invokestatic #265 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 1320: checkcast #48 // class java/lang/Iterable\n 1323: invokestatic #269 // Method merge:(Ljava/lang/Iterable;)I\n 1326: istore 24\n 1328: aload 10\n 1330: checkcast #48 // class java/lang/Iterable\n 1333: astore 25\n 1335: nop\n 1336: iconst_0\n 1337: istore 26\n 1339: aload 25\n 1341: astore 27\n 1343: new #50 // class java/util/ArrayList\n 1346: dup\n 1347: invokespecial #52 // Method java/util/ArrayList.\"<init>\":()V\n 1350: checkcast #54 // class java/util/Collection\n 1353: astore 28\n 1355: iconst_0\n 1356: istore 30\n 1358: aload 27\n 1360: invokeinterface #58, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1365: astore 31\n 1367: aload 31\n 1369: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1374: ifeq 1435\n 1377: aload 31\n 1379: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1384: astore 32\n 1386: aload 32\n 1388: checkcast #238 // class WordGroup\n 1391: astore 33\n 1393: iconst_0\n 1394: istore 34\n 1396: aload 33\n 1398: invokevirtual #272 // Method WordGroup.\"getSignature-MrUGAVo\":()I\n 1401: iload 24\n 1403: invokestatic #275 // Method Signature.\"commonLetters-VbpjEXU\":(II)I\n 1406: invokestatic #121 // Method Signature.\"distinctLetters-impl\":(I)I\n 1409: iload 19\n 1411: if_icmplt 1418\n 1414: iconst_1\n 1415: goto 1419\n 1418: iconst_0\n 1419: ifeq 1367\n 1422: aload 28\n 1424: aload 32\n 1426: invokeinterface #78, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 1431: pop\n 1432: goto 1367\n 1435: aload 28\n 1437: checkcast #80 // class java/util/List\n 1440: nop\n 1441: astore 26\n 1443: iconst_0\n 1444: istore 27\n 1446: aload 21\n 1448: aload 26\n 1450: checkcast #54 // class java/util/Collection\n 1453: invokeinterface #279, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 1458: pop\n 1459: aload 9\n 1461: iload 18\n 1463: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 1466: invokeinterface #97, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 1471: checkcast #80 // class java/util/List\n 1474: dup\n 1475: ifnonnull 1482\n 1478: pop\n 1479: invokestatic #242 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 1482: astore 25\n 1484: new #201 // class java/lang/StringBuilder\n 1487: dup\n 1488: invokespecial #202 // Method java/lang/StringBuilder.\"<init>\":()V\n 1491: getstatic #282 // Field lettersInverted:Ljava/util/Map;\n 1494: iload 18\n 1496: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 1499: invokeinterface #97, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 1504: invokevirtual #285 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 1507: ldc_w #287 // String -> Words to check\n 1510: invokevirtual #215 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 1513: aload 25\n 1515: invokeinterface #234, 1 // InterfaceMethod java/util/List.size:()I\n 1520: invokevirtual #218 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 1523: invokevirtual #222 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 1526: getstatic #189 // Field java/lang/System.out:Ljava/io/PrintStream;\n 1529: swap\n 1530: invokevirtual #194 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 1533: aload 25\n 1535: checkcast #48 // class java/lang/Iterable\n 1538: astore 26\n 1540: nop\n 1541: iconst_0\n 1542: istore 27\n 1544: aload 26\n 1546: astore 28\n 1548: new #50 // class java/util/ArrayList\n 1551: dup\n 1552: invokespecial #52 // Method java/util/ArrayList.\"<init>\":()V\n 1555: checkcast #54 // class java/util/Collection\n 1558: astore 30\n 1560: iconst_0\n 1561: istore 31\n 1563: aload 28\n 1565: invokeinterface #58, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1570: astore 32\n 1572: aload 32\n 1574: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1579: ifeq 1939\n 1582: aload 32\n 1584: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1589: astore 33\n 1591: aload 33\n 1593: checkcast #16 // class Signature\n 1596: invokevirtual #117 // Method Signature.\"unbox-impl\":()I\n 1599: istore 34\n 1601: iconst_0\n 1602: istore 35\n 1604: aload 10\n 1606: checkcast #48 // class java/lang/Iterable\n 1609: astore 36\n 1611: nop\n 1612: iconst_0\n 1613: istore 37\n 1615: aload 36\n 1617: astore 38\n 1619: new #50 // class java/util/ArrayList\n 1622: dup\n 1623: invokespecial #52 // Method java/util/ArrayList.\"<init>\":()V\n 1626: checkcast #54 // class java/util/Collection\n 1629: astore 39\n 1631: iconst_0\n 1632: istore 40\n 1634: aload 38\n 1636: invokeinterface #58, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1641: astore 41\n 1643: aload 41\n 1645: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1650: ifeq 1703\n 1653: aload 41\n 1655: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1660: astore 42\n 1662: aload 42\n 1664: checkcast #238 // class WordGroup\n 1667: astore 43\n 1669: iconst_0\n 1670: istore 44\n 1672: aload 43\n 1674: iload 34\n 1676: invokevirtual #290 // Method WordGroup.\"contains-yueV81A\":(I)Z\n 1679: ifne 1686\n 1682: iconst_1\n 1683: goto 1687\n 1686: iconst_0\n 1687: ifeq 1643\n 1690: aload 39\n 1692: aload 42\n 1694: invokeinterface #78, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 1699: pop\n 1700: goto 1643\n 1703: aload 39\n 1705: checkcast #80 // class java/util/List\n 1708: nop\n 1709: checkcast #48 // class java/lang/Iterable\n 1712: astore 36\n 1714: nop\n 1715: iconst_0\n 1716: istore 37\n 1718: aload 36\n 1720: astore 38\n 1722: new #50 // class java/util/ArrayList\n 1725: dup\n 1726: aload 36\n 1728: bipush 10\n 1730: invokestatic #139 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 1733: invokespecial #291 // Method java/util/ArrayList.\"<init>\":(I)V\n 1736: checkcast #54 // class java/util/Collection\n 1739: astore 39\n 1741: iconst_0\n 1742: istore 40\n 1744: aload 38\n 1746: invokeinterface #58, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1751: astore 41\n 1753: aload 41\n 1755: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1760: ifeq 1805\n 1763: aload 41\n 1765: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1770: astore 42\n 1772: aload 39\n 1774: aload 42\n 1776: checkcast #238 // class WordGroup\n 1779: astore 43\n 1781: astore 45\n 1783: iconst_0\n 1784: istore 44\n 1786: aload 43\n 1788: iload 34\n 1790: invokevirtual #295 // Method WordGroup.\"plus-yueV81A\":(I)LWordGroup;\n 1793: aload 45\n 1795: swap\n 1796: invokeinterface #78, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 1801: pop\n 1802: goto 1753\n 1805: aload 39\n 1807: checkcast #80 // class java/util/List\n 1810: nop\n 1811: checkcast #48 // class java/lang/Iterable\n 1814: astore 36\n 1816: nop\n 1817: iconst_0\n 1818: istore 37\n 1820: aload 36\n 1822: astore 38\n 1824: new #50 // class java/util/ArrayList\n 1827: dup\n 1828: invokespecial #52 // Method java/util/ArrayList.\"<init>\":()V\n 1831: checkcast #54 // class java/util/Collection\n 1834: astore 39\n 1836: iconst_0\n 1837: istore 40\n 1839: aload 38\n 1841: invokeinterface #58, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1846: astore 41\n 1848: aload 41\n 1850: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1855: ifeq 1916\n 1858: aload 41\n 1860: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1865: astore 42\n 1867: aload 42\n 1869: checkcast #238 // class WordGroup\n 1872: astore 43\n 1874: iconst_0\n 1875: istore 44\n 1877: aload 43\n 1879: invokevirtual #272 // Method WordGroup.\"getSignature-MrUGAVo\":()I\n 1882: iload 24\n 1884: invokestatic #275 // Method Signature.\"commonLetters-VbpjEXU\":(II)I\n 1887: invokestatic #121 // Method Signature.\"distinctLetters-impl\":(I)I\n 1890: iload 19\n 1892: if_icmplt 1899\n 1895: iconst_1\n 1896: goto 1900\n 1899: iconst_0\n 1900: ifeq 1848\n 1903: aload 39\n 1905: aload 42\n 1907: invokeinterface #78, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 1912: pop\n 1913: goto 1848\n 1916: aload 39\n 1918: checkcast #80 // class java/util/List\n 1921: nop\n 1922: checkcast #48 // class java/lang/Iterable\n 1925: nop\n 1926: astore 46\n 1928: aload 30\n 1930: aload 46\n 1932: invokestatic #298 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 1935: pop\n 1936: goto 1572\n 1939: aload 30\n 1941: checkcast #80 // class java/util/List\n 1944: nop\n 1945: astore 27\n 1947: iconst_0\n 1948: istore 28\n 1950: aload 21\n 1952: aload 27\n 1954: checkcast #54 // class java/util/Collection\n 1957: invokeinterface #279, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 1962: pop\n 1963: aload 21\n 1965: astore 10\n 1967: new #201 // class java/lang/StringBuilder\n 1970: dup\n 1971: invokespecial #202 // Method java/lang/StringBuilder.\"<init>\":()V\n 1974: getstatic #282 // Field lettersInverted:Ljava/util/Map;\n 1977: iload 18\n 1979: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 1982: invokeinterface #97, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 1987: invokevirtual #285 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 1990: ldc_w #300 // String -> Current solution\n 1993: invokevirtual #215 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 1996: aload 10\n 1998: invokeinterface #234, 1 // InterfaceMethod java/util/List.size:()I\n 2003: invokevirtual #218 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 2006: invokevirtual #222 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 2009: getstatic #189 // Field java/lang/System.out:Ljava/io/PrintStream;\n 2012: swap\n 2013: invokevirtual #194 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 2016: nop\n 2017: nop\n 2018: goto 1240\n 2021: nop\n 2022: aload 10\n 2024: checkcast #48 // class java/lang/Iterable\n 2027: astore 12\n 2029: nop\n 2030: iconst_0\n 2031: istore 13\n 2033: aload 12\n 2035: astore 14\n 2037: new #50 // class java/util/ArrayList\n 2040: dup\n 2041: invokespecial #52 // Method java/util/ArrayList.\"<init>\":()V\n 2044: checkcast #54 // class java/util/Collection\n 2047: astore 16\n 2049: iconst_0\n 2050: istore 17\n 2052: aload 14\n 2054: invokeinterface #58, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 2059: astore 18\n 2061: aload 18\n 2063: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 2068: ifeq 2113\n 2071: aload 18\n 2073: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 2078: astore 19\n 2080: aload 19\n 2082: checkcast #238 // class WordGroup\n 2085: astore 20\n 2087: iconst_0\n 2088: istore 21\n 2090: aload 20\n 2092: aload 6\n 2094: invokevirtual #303 // Method WordGroup.toWords:(Ljava/util/Map;)Ljava/util/List;\n 2097: checkcast #48 // class java/lang/Iterable\n 2100: astore 20\n 2102: aload 16\n 2104: aload 20\n 2106: invokestatic #298 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 2109: pop\n 2110: goto 2061\n 2113: aload 16\n 2115: checkcast #80 // class java/util/List\n 2118: nop\n 2119: checkcast #48 // class java/lang/Iterable\n 2122: astore 12\n 2124: nop\n 2125: iconst_0\n 2126: istore 13\n 2128: aload 12\n 2130: astore 14\n 2132: aload 14\n 2134: astore 16\n 2136: iconst_0\n 2137: istore 17\n 2139: aload 16\n 2141: invokeinterface #58, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 2146: astore 18\n 2148: aload 18\n 2150: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 2155: ifeq 2211\n 2158: aload 18\n 2160: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 2165: astore 19\n 2167: aload 19\n 2169: checkcast #80 // class java/util/List\n 2172: astore 20\n 2174: iconst_0\n 2175: istore 21\n 2177: aload 20\n 2179: checkcast #48 // class java/lang/Iterable\n 2182: ldc_w #305 // String\n 2185: checkcast #307 // class java/lang/CharSequence\n 2188: aconst_null\n 2189: aconst_null\n 2190: iconst_0\n 2191: aconst_null\n 2192: aconst_null\n 2193: bipush 62\n 2195: aconst_null\n 2196: invokestatic #311 // 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 2199: getstatic #189 // Field java/lang/System.out:Ljava/io/PrintStream;\n 2202: swap\n 2203: invokevirtual #194 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 2206: nop\n 2207: nop\n 2208: goto 2148\n 2211: aload 14\n 2213: nop\n 2214: checkcast #80 // class java/util/List\n 2217: astore 11\n 2219: getstatic #189 // Field java/lang/System.out:Ljava/io/PrintStream;\n 2222: invokevirtual #313 // Method java/io/PrintStream.println:()V\n 2225: new #201 // class java/lang/StringBuilder\n 2228: dup\n 2229: invokespecial #202 // Method java/lang/StringBuilder.\"<init>\":()V\n 2232: ldc_w #315 // String Total possibilities including anagrams:\n 2235: invokevirtual #215 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 2238: aload 11\n 2240: invokeinterface #234, 1 // InterfaceMethod java/util/List.size:()I\n 2245: invokevirtual #218 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 2248: invokevirtual #222 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 2251: getstatic #189 // Field java/lang/System.out:Ljava/io/PrintStream;\n 2254: swap\n 2255: invokevirtual #194 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 2258: getstatic #189 // Field java/lang/System.out:Ljava/io/PrintStream;\n 2261: invokevirtual #313 // Method java/io/PrintStream.println:()V\n 2264: new #201 // class java/lang/StringBuilder\n 2267: dup\n 2268: invokespecial #202 // Method java/lang/StringBuilder.\"<init>\":()V\n 2271: ldc_w #317 // String Total possibilities excluding anagrams:\n 2274: invokevirtual #215 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 2277: aload 10\n 2279: invokeinterface #234, 1 // InterfaceMethod java/util/List.size:()I\n 2284: invokevirtual #218 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 2287: invokevirtual #222 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 2290: getstatic #189 // Field java/lang/System.out:Ljava/io/PrintStream;\n 2293: swap\n 2294: invokevirtual #194 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 2297: nop\n 2298: nop\n 2299: invokestatic #12 // Method java/lang/System.currentTimeMillis:()J\n 2302: lload_3\n 2303: lsub\n 2304: lstore_0\n 2305: new #201 // class java/lang/StringBuilder\n 2308: dup\n 2309: invokespecial #202 // Method java/lang/StringBuilder.\"<init>\":()V\n 2312: lload_0\n 2313: l2d\n 2314: ldc2_w #318 // double 1000.0d\n 2317: ddiv\n 2318: invokevirtual #322 // Method java/lang/StringBuilder.append:(D)Ljava/lang/StringBuilder;\n 2321: ldc_w #324 // String seconds\n 2324: invokevirtual #215 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 2327: invokevirtual #222 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 2330: getstatic #189 // Field java/lang/System.out:Ljava/io/PrintStream;\n 2333: swap\n 2334: invokevirtual #194 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 2337: return\n\n public static final int merge(java.lang.Iterable<Signature>);\n Code:\n 0: aload_0\n 1: ldc_w #433 // String <this>\n 4: invokestatic #437 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: astore_1\n 9: getstatic #246 // Field Signature.Companion:LSignature$Companion;\n 12: invokevirtual #251 // Method Signature$Companion.\"getEmpty-MrUGAVo\":()I\n 15: istore_2\n 16: iconst_0\n 17: istore_3\n 18: iload_2\n 19: istore 4\n 21: aload_1\n 22: invokeinterface #58, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 27: astore 5\n 29: aload 5\n 31: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 36: ifeq 77\n 39: aload 5\n 41: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 46: astore 6\n 48: iload 4\n 50: aload 6\n 52: checkcast #16 // class Signature\n 55: invokevirtual #117 // Method Signature.\"unbox-impl\":()I\n 58: istore 7\n 60: istore 8\n 62: iconst_0\n 63: istore 9\n 65: iload 8\n 67: iload 7\n 69: invokestatic #440 // Method Signature.\"plus-VbpjEXU\":(II)I\n 72: istore 4\n 74: goto 29\n 77: iload 4\n 79: ireturn\n\n public static final java.util.Map<java.lang.Character, Signature> getLetters();\n Code:\n 0: getstatic #129 // Field letters:Ljava/util/Map;\n 3: areturn\n\n public static final java.util.Map<Signature, java.lang.Character> getLettersInverted();\n Code:\n 0: getstatic #282 // Field lettersInverted:Ljava/util/Map;\n 3: areturn\n\n public static final int toSignature(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #433 // String <this>\n 4: invokestatic #437 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: checkcast #307 // class java/lang/CharSequence\n 11: astore_1\n 12: iconst_0\n 13: istore_2\n 14: aload_1\n 15: astore_3\n 16: new #50 // class java/util/ArrayList\n 19: dup\n 20: aload_1\n 21: invokeinterface #448, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 26: invokespecial #291 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #54 // class java/util/Collection\n 32: astore 4\n 34: iconst_0\n 35: istore 5\n 37: iconst_0\n 38: istore 6\n 40: iload 6\n 42: aload_3\n 43: invokeinterface #448, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 48: if_icmpge 113\n 51: aload_3\n 52: iload 6\n 54: invokeinterface #451, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 59: istore 7\n 61: aload 4\n 63: iload 7\n 65: istore 8\n 67: astore 10\n 69: iconst_0\n 70: istore 9\n 72: getstatic #129 // Field letters:Ljava/util/Map;\n 75: iload 8\n 77: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 80: invokeinterface #97, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 85: dup\n 86: invokestatic #30 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 89: checkcast #16 // class Signature\n 92: invokevirtual #117 // Method Signature.\"unbox-impl\":()I\n 95: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 98: aload 10\n 100: swap\n 101: invokeinterface #78, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 106: pop\n 107: iinc 6, 1\n 110: goto 40\n 113: aload 4\n 115: checkcast #80 // class java/util/List\n 118: nop\n 119: checkcast #48 // class java/lang/Iterable\n 122: invokestatic #269 // Method merge:(Ljava/lang/Iterable;)I\n 125: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #463 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: bipush 26\n 2: anewarray #468 // class kotlin/Pair\n 5: astore_0\n 6: aload_0\n 7: iconst_0\n 8: bipush 97\n 10: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 13: iconst_1\n 14: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 17: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 20: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 23: aastore\n 24: aload_0\n 25: iconst_1\n 26: bipush 98\n 28: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 31: iconst_2\n 32: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 35: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 38: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 41: aastore\n 42: aload_0\n 43: iconst_2\n 44: bipush 99\n 46: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 49: iconst_4\n 50: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 53: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 56: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 59: aastore\n 60: aload_0\n 61: iconst_3\n 62: bipush 100\n 64: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 67: bipush 8\n 69: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 72: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 75: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 78: aastore\n 79: aload_0\n 80: iconst_4\n 81: bipush 101\n 83: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 86: bipush 16\n 88: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 91: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 94: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 97: aastore\n 98: aload_0\n 99: iconst_5\n 100: bipush 102\n 102: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 105: bipush 32\n 107: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 110: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 113: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 116: aastore\n 117: aload_0\n 118: bipush 6\n 120: bipush 103\n 122: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 125: bipush 64\n 127: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 130: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 133: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 136: aastore\n 137: aload_0\n 138: bipush 7\n 140: bipush 104\n 142: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 145: sipush 128\n 148: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 151: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 154: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 157: aastore\n 158: aload_0\n 159: bipush 8\n 161: bipush 105\n 163: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 166: sipush 256\n 169: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 172: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 175: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 178: aastore\n 179: aload_0\n 180: bipush 9\n 182: bipush 106\n 184: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 187: sipush 512\n 190: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 193: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 196: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 199: aastore\n 200: aload_0\n 201: bipush 10\n 203: bipush 107\n 205: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 208: sipush 1024\n 211: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 214: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 217: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 220: aastore\n 221: aload_0\n 222: bipush 11\n 224: bipush 108\n 226: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 229: sipush 2048\n 232: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 235: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 238: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 241: aastore\n 242: aload_0\n 243: bipush 12\n 245: bipush 109\n 247: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 250: sipush 4096\n 253: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 256: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 259: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 262: aastore\n 263: aload_0\n 264: bipush 13\n 266: bipush 110\n 268: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 271: sipush 8192\n 274: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 277: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 280: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 283: aastore\n 284: aload_0\n 285: bipush 14\n 287: bipush 111\n 289: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 292: sipush 16384\n 295: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 298: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 301: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 304: aastore\n 305: aload_0\n 306: bipush 15\n 308: bipush 112\n 310: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 313: ldc_w #478 // int 32768\n 316: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 319: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 322: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 325: aastore\n 326: aload_0\n 327: bipush 16\n 329: bipush 113\n 331: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 334: ldc_w #479 // int 65536\n 337: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 340: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 343: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 346: aastore\n 347: aload_0\n 348: bipush 17\n 350: bipush 114\n 352: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 355: ldc_w #480 // int 131072\n 358: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 361: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 364: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 367: aastore\n 368: aload_0\n 369: bipush 18\n 371: bipush 115\n 373: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 376: ldc_w #481 // int 262144\n 379: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 382: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 385: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 388: aastore\n 389: aload_0\n 390: bipush 19\n 392: bipush 116\n 394: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 397: ldc_w #482 // int 524288\n 400: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 403: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 406: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 409: aastore\n 410: aload_0\n 411: bipush 20\n 413: bipush 117\n 415: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 418: ldc_w #483 // int 1048576\n 421: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 424: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 427: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 430: aastore\n 431: aload_0\n 432: bipush 21\n 434: bipush 118\n 436: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 439: ldc_w #484 // int 2097152\n 442: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 445: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 448: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 451: aastore\n 452: aload_0\n 453: bipush 22\n 455: bipush 119\n 457: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 460: ldc_w #485 // int 4194304\n 463: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 466: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 469: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 472: aastore\n 473: aload_0\n 474: bipush 23\n 476: bipush 120\n 478: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 481: ldc_w #486 // int 8388608\n 484: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 487: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 490: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 493: aastore\n 494: aload_0\n 495: bipush 24\n 497: bipush 121\n 499: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 502: ldc_w #487 // int 16777216\n 505: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 508: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 511: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 514: aastore\n 515: aload_0\n 516: bipush 25\n 518: bipush 122\n 520: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 523: ldc_w #488 // int 33554432\n 526: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 529: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 532: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 535: aastore\n 536: aload_0\n 537: invokestatic #492 // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 540: putstatic #129 // Field letters:Ljava/util/Map;\n 543: bipush 26\n 545: anewarray #468 // class kotlin/Pair\n 548: astore_0\n 549: aload_0\n 550: iconst_0\n 551: iconst_1\n 552: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 555: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 558: bipush 97\n 560: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 563: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 566: aastore\n 567: aload_0\n 568: iconst_1\n 569: iconst_2\n 570: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 573: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 576: bipush 98\n 578: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 581: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 584: aastore\n 585: aload_0\n 586: iconst_2\n 587: iconst_4\n 588: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 591: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 594: bipush 99\n 596: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 599: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 602: aastore\n 603: aload_0\n 604: iconst_3\n 605: bipush 8\n 607: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 610: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 613: bipush 100\n 615: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 618: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 621: aastore\n 622: aload_0\n 623: iconst_4\n 624: bipush 16\n 626: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 629: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 632: bipush 101\n 634: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 637: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 640: aastore\n 641: aload_0\n 642: iconst_5\n 643: bipush 32\n 645: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 648: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 651: bipush 102\n 653: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 656: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 659: aastore\n 660: aload_0\n 661: bipush 6\n 663: bipush 64\n 665: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 668: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 671: bipush 103\n 673: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 676: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 679: aastore\n 680: aload_0\n 681: bipush 7\n 683: sipush 128\n 686: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 689: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 692: bipush 104\n 694: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 697: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 700: aastore\n 701: aload_0\n 702: bipush 8\n 704: sipush 256\n 707: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 710: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 713: bipush 105\n 715: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 718: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 721: aastore\n 722: aload_0\n 723: bipush 9\n 725: sipush 512\n 728: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 731: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 734: bipush 106\n 736: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 739: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 742: aastore\n 743: aload_0\n 744: bipush 10\n 746: sipush 1024\n 749: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 752: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 755: bipush 107\n 757: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 760: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 763: aastore\n 764: aload_0\n 765: bipush 11\n 767: sipush 2048\n 770: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 773: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 776: bipush 108\n 778: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 781: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 784: aastore\n 785: aload_0\n 786: bipush 12\n 788: sipush 4096\n 791: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 794: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 797: bipush 109\n 799: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 802: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 805: aastore\n 806: aload_0\n 807: bipush 13\n 809: sipush 8192\n 812: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 815: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 818: bipush 110\n 820: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 823: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 826: aastore\n 827: aload_0\n 828: bipush 14\n 830: sipush 16384\n 833: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 836: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 839: bipush 111\n 841: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 844: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 847: aastore\n 848: aload_0\n 849: bipush 15\n 851: ldc_w #478 // int 32768\n 854: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 857: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 860: bipush 112\n 862: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 865: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 868: aastore\n 869: aload_0\n 870: bipush 16\n 872: ldc_w #479 // int 65536\n 875: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 878: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 881: bipush 113\n 883: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 886: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 889: aastore\n 890: aload_0\n 891: bipush 17\n 893: ldc_w #480 // int 131072\n 896: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 899: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 902: bipush 114\n 904: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 907: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 910: aastore\n 911: aload_0\n 912: bipush 18\n 914: ldc_w #481 // int 262144\n 917: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 920: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 923: bipush 115\n 925: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 928: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 931: aastore\n 932: aload_0\n 933: bipush 19\n 935: ldc_w #482 // int 524288\n 938: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 941: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 944: bipush 116\n 946: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 949: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 952: aastore\n 953: aload_0\n 954: bipush 20\n 956: ldc_w #483 // int 1048576\n 959: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 962: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 965: bipush 117\n 967: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 970: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 973: aastore\n 974: aload_0\n 975: bipush 21\n 977: ldc_w #484 // int 2097152\n 980: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 983: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 986: bipush 118\n 988: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 991: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 994: aastore\n 995: aload_0\n 996: bipush 22\n 998: ldc_w #485 // int 4194304\n 1001: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 1004: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 1007: bipush 119\n 1009: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 1012: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 1015: aastore\n 1016: aload_0\n 1017: bipush 23\n 1019: ldc_w #486 // int 8388608\n 1022: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 1025: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 1028: bipush 120\n 1030: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 1033: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 1036: aastore\n 1037: aload_0\n 1038: bipush 24\n 1040: ldc_w #487 // int 16777216\n 1043: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 1046: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 1049: bipush 121\n 1051: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 1054: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 1057: aastore\n 1058: aload_0\n 1059: bipush 25\n 1061: ldc_w #488 // int 33554432\n 1064: invokestatic #471 // Method Signature.\"constructor-impl\":(I)I\n 1067: invokestatic #93 // Method Signature.\"box-impl\":(I)LSignature;\n 1070: bipush 122\n 1072: invokestatic #456 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 1075: invokestatic #477 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 1078: aastore\n 1079: aload_0\n 1080: invokestatic #492 // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 1083: putstatic #282 // Field lettersInverted:Ljava/util/Map;\n 1086: return\n}\n",
"javap_err": ""
}
] |
jjrodcast__CompetitiveProblems__a91868c/leetcode/UniquePathsTwo.kt
|
/*
Enlace al problema:
https://leetcode.com/problems/unique-paths-ii/
La solución se encuentra dentro de la función `uniquePathsWithObstacles`, el resto del código es para
ejecutarlo de manera local.
Explanation:
Given the grid:
[0,0,0]
[0,1,0]
[0,0,0]
Initial information:
*) We are at position (0,0) and the target is (2,2)
*) Inside the grid there are obstacles (1's)
Question:
How many paths can we find from initial position to target position?
Solution
--------
1) Add a new `row` and `column` to the grid.
[I,0,0,0]
[0,X,0,0]
[0,0,T,0]
[0,0,0,0]
2) Check if initial position is and obstacle, if true assign `0` otherwise `1`
[1,0,0,0]
[0,X,0,0]
[0,0,T,0]
[0,0,0,0]
3) Now check for the first `row` and the first `column` and if is and
obstacle assign `0` otherwise the previous value (in this case just `row` or `column`)
[1,1,1,1]
[1,X,0,0]
[1,0,T,0]
[1,0,0,0]
4) Finally we pre-calculate all the other values to the target.
To do this we need to assign to the current value (x,y) the sum
of the paths that can lead us to the `target` which are:
(row, col-1) and (row-1, col)
* If there is an obstacle in the current position (x,y), we assign `0`
[1,1,1,1]
[1,0,1,2]
[1,1,2,4]
[1,2,4,8]
Time complexity: O(m*n)
*/
class Solution {
fun uniquePathsWithObstacles(obstacleGrid: Array<IntArray>): Int {
val rows = obstacleGrid.size
val cols = obstacleGrid[0].size
val grid = Array(rows + 1) { IntArray(cols + 1) { 0 } }
grid[0][0] = if (obstacleGrid[0][0] == 0) 1 else 0
for (i in 1 until rows) if (obstacleGrid[i][0] == 0) grid[i][0] = grid[i - 1][0]
for (i in 1 until cols) if (obstacleGrid[0][i] == 0) grid[0][i] = grid[0][i - 1]
for (i in 1 until rows) {
for (j in 1 until cols) {
grid[i][j] = if (obstacleGrid[i][j] == 0) grid[i - 1][j] + grid[i][j - 1] else 0
}
}
return grid[rows - 1][cols - 1]
}
}
fun main() {
// Class for Solution
val solution = Solution()
// Test #1: Input grid
val grid = arrayOf(
intArrayOf(0, 0, 0),
intArrayOf(0, 1, 0),
intArrayOf(0, 0, 0)
)
// Test #1: Output solution
println(solution.uniquePathsWithObstacles(grid))
}
|
[
{
"class_path": "jjrodcast__CompetitiveProblems__a91868c/UniquePathsTwoKt.class",
"javap": "Compiled from \"UniquePathsTwo.kt\"\npublic final class UniquePathsTwoKt {\n public static final void main();\n Code:\n 0: new #8 // class Solution\n 3: dup\n 4: invokespecial #11 // Method Solution.\"<init>\":()V\n 7: astore_0\n 8: iconst_3\n 9: anewarray #13 // class \"[I\"\n 12: astore_2\n 13: aload_2\n 14: iconst_0\n 15: iconst_3\n 16: newarray int\n 18: astore_3\n 19: aload_3\n 20: iconst_0\n 21: iconst_0\n 22: iastore\n 23: aload_3\n 24: iconst_1\n 25: iconst_0\n 26: iastore\n 27: aload_3\n 28: iconst_2\n 29: iconst_0\n 30: iastore\n 31: aload_3\n 32: aastore\n 33: aload_2\n 34: iconst_1\n 35: iconst_3\n 36: newarray int\n 38: astore_3\n 39: aload_3\n 40: iconst_0\n 41: iconst_0\n 42: iastore\n 43: aload_3\n 44: iconst_1\n 45: iconst_1\n 46: iastore\n 47: aload_3\n 48: iconst_2\n 49: iconst_0\n 50: iastore\n 51: aload_3\n 52: aastore\n 53: aload_2\n 54: iconst_2\n 55: iconst_3\n 56: newarray int\n 58: astore_3\n 59: aload_3\n 60: iconst_0\n 61: iconst_0\n 62: iastore\n 63: aload_3\n 64: iconst_1\n 65: iconst_0\n 66: iastore\n 67: aload_3\n 68: iconst_2\n 69: iconst_0\n 70: iastore\n 71: aload_3\n 72: aastore\n 73: aload_2\n 74: astore_1\n 75: aload_0\n 76: aload_1\n 77: invokevirtual #17 // Method Solution.uniquePathsWithObstacles:([[I)I\n 80: istore_2\n 81: getstatic #23 // Field java/lang/System.out:Ljava/io/PrintStream;\n 84: iload_2\n 85: invokevirtual #29 // Method java/io/PrintStream.println:(I)V\n 88: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #36 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
polydisc__codelibrary__be589a7/kotlin/MaxBipartiteMatchingEV.kt
|
// https://en.wikipedia.org/wiki/Matching_(graph_theory)#In_unweighted_bipartite_graphs in O(V * E)
fun maxMatching(graph: Array<out List<Int>>): Int {
val n1 = graph.size
val n2 = (graph.flatMap { it }.maxOrNull() ?: -1) + 1
val matching = IntArray(n2) { -1 }
return (0 until n1).sumOf { findPath(graph, it, matching, BooleanArray(n1)) }
}
fun findPath(graph: Array<out List<Int>>, u1: Int, matching: IntArray, vis: BooleanArray): Int {
vis[u1] = true
for (v in graph[u1]) {
val u2 = matching[v]
if (u2 == -1 || !vis[u2] && findPath(graph, u2, matching, vis) == 1) {
matching[v] = u1
return 1
}
}
return 0
}
// Usage example
fun main(args: Array<String>) {
val g = (1..2).map { arrayListOf<Int>() }.toTypedArray()
g[0].add(0)
g[0].add(1)
g[1].add(1)
println(2 == maxMatching(g))
}
|
[
{
"class_path": "polydisc__codelibrary__be589a7/MaxBipartiteMatchingEVKt.class",
"javap": "Compiled from \"MaxBipartiteMatchingEV.kt\"\npublic final class MaxBipartiteMatchingEVKt {\n public static final int maxMatching(java.util.List<java.lang.Integer>[]);\n Code:\n 0: aload_0\n 1: ldc #10 // String graph\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: arraylength\n 8: istore_1\n 9: aload_0\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: invokespecial #22 // Method java/util/ArrayList.\"<init>\":()V\n 26: checkcast #24 // class java/util/Collection\n 29: astore 7\n 31: iconst_0\n 32: istore 8\n 34: iconst_0\n 35: istore 9\n 37: aload 6\n 39: arraylength\n 40: istore 10\n 42: iload 9\n 44: iload 10\n 46: if_icmpge 84\n 49: aload 6\n 51: iload 9\n 53: aaload\n 54: astore 11\n 56: aload 11\n 58: astore 12\n 60: iconst_0\n 61: istore 13\n 63: aload 12\n 65: checkcast #26 // class java/lang/Iterable\n 68: astore 12\n 70: aload 7\n 72: aload 12\n 74: invokestatic #32 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 77: pop\n 78: iinc 9, 1\n 81: goto 42\n 84: aload 7\n 86: checkcast #34 // class java/util/List\n 89: nop\n 90: checkcast #26 // class java/lang/Iterable\n 93: invokestatic #38 // Method kotlin/collections/CollectionsKt.maxOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 96: checkcast #40 // class java/lang/Integer\n 99: dup\n 100: ifnull 109\n 103: invokevirtual #44 // Method java/lang/Integer.intValue:()I\n 106: goto 111\n 109: pop\n 110: iconst_m1\n 111: iconst_1\n 112: iadd\n 113: istore_2\n 114: iconst_0\n 115: istore 4\n 117: iload_2\n 118: newarray int\n 120: astore 5\n 122: iload 4\n 124: iload_2\n 125: if_icmpge 144\n 128: iload 4\n 130: istore 6\n 132: aload 5\n 134: iload 6\n 136: iconst_m1\n 137: iastore\n 138: iinc 4, 1\n 141: goto 122\n 144: aload 5\n 146: astore_3\n 147: iconst_0\n 148: iload_1\n 149: invokestatic #50 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 152: checkcast #26 // class java/lang/Iterable\n 155: astore 4\n 157: iconst_0\n 158: istore 5\n 160: aload 4\n 162: invokeinterface #54, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 167: astore 6\n 169: aload 6\n 171: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 176: ifeq 222\n 179: aload 6\n 181: checkcast #62 // class kotlin/collections/IntIterator\n 184: invokevirtual #65 // Method kotlin/collections/IntIterator.nextInt:()I\n 187: istore 7\n 189: iload 5\n 191: iload 7\n 193: istore 8\n 195: istore 14\n 197: iconst_0\n 198: istore 9\n 200: aload_0\n 201: iload 8\n 203: aload_3\n 204: iload_1\n 205: newarray boolean\n 207: invokestatic #69 // Method findPath:([Ljava/util/List;I[I[Z)I\n 210: istore 15\n 212: iload 14\n 214: iload 15\n 216: iadd\n 217: istore 5\n 219: goto 169\n 222: iload 5\n 224: ireturn\n\n public static final int findPath(java.util.List<java.lang.Integer>[], int, int[], boolean[]);\n Code:\n 0: aload_0\n 1: ldc #10 // String graph\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #94 // String matching\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_3\n 13: ldc #96 // String vis\n 15: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: aload_3\n 19: iload_1\n 20: iconst_1\n 21: bastore\n 22: aload_0\n 23: iload_1\n 24: aaload\n 25: invokeinterface #97, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 30: astore 4\n 32: aload 4\n 34: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 39: ifeq 95\n 42: aload 4\n 44: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 49: checkcast #103 // class java/lang/Number\n 52: invokevirtual #104 // Method java/lang/Number.intValue:()I\n 55: istore 5\n 57: aload_2\n 58: iload 5\n 60: iaload\n 61: istore 6\n 63: iload 6\n 65: iconst_m1\n 66: if_icmpeq 88\n 69: aload_3\n 70: iload 6\n 72: baload\n 73: ifne 32\n 76: aload_0\n 77: iload 6\n 79: aload_2\n 80: aload_3\n 81: invokestatic #69 // Method findPath:([Ljava/util/List;I[I[Z)I\n 84: iconst_1\n 85: if_icmpne 32\n 88: aload_2\n 89: iload 5\n 91: iload_1\n 92: iastore\n 93: iconst_1\n 94: ireturn\n 95: iconst_0\n 96: ireturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #112 // String args\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #114 // class kotlin/ranges/IntRange\n 9: dup\n 10: iconst_1\n 11: iconst_2\n 12: invokespecial #117 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\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 #18 // class java/util/ArrayList\n 27: dup\n 28: aload_2\n 29: bipush 10\n 31: invokestatic #121 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 34: invokespecial #124 // Method java/util/ArrayList.\"<init>\":(I)V\n 37: checkcast #24 // class java/util/Collection\n 40: astore 5\n 42: iconst_0\n 43: istore 6\n 45: aload 4\n 47: invokeinterface #54, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 52: astore 7\n 54: aload 7\n 56: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 61: ifeq 105\n 64: aload 7\n 66: checkcast #62 // class kotlin/collections/IntIterator\n 69: invokevirtual #65 // 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 #18 // class java/util/ArrayList\n 88: dup\n 89: invokespecial #22 // Method java/util/ArrayList.\"<init>\":()V\n 92: nop\n 93: aload 11\n 95: swap\n 96: invokeinterface #128, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 101: pop\n 102: goto 54\n 105: aload 5\n 107: checkcast #34 // class java/util/List\n 110: nop\n 111: checkcast #24 // 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 #18 // class java/util/ArrayList\n 127: invokeinterface #132, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 132: checkcast #134 // class \"[Ljava/util/ArrayList;\"\n 135: astore_1\n 136: aload_1\n 137: iconst_0\n 138: aaload\n 139: iconst_0\n 140: invokestatic #138 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 143: invokevirtual #139 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 146: pop\n 147: aload_1\n 148: iconst_0\n 149: aaload\n 150: iconst_1\n 151: invokestatic #138 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 154: invokevirtual #139 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 157: pop\n 158: aload_1\n 159: iconst_1\n 160: aaload\n 161: iconst_1\n 162: invokestatic #138 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 165: invokevirtual #139 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 168: pop\n 169: iconst_2\n 170: aload_1\n 171: checkcast #91 // class \"[Ljava/util/List;\"\n 174: invokestatic #141 // Method maxMatching:([Ljava/util/List;)I\n 177: if_icmpne 184\n 180: iconst_1\n 181: goto 185\n 184: iconst_0\n 185: istore_2\n 186: getstatic #147 // Field java/lang/System.out:Ljava/io/PrintStream;\n 189: iload_2\n 190: invokevirtual #153 // Method java/io/PrintStream.println:(Z)V\n 193: return\n}\n",
"javap_err": ""
}
] |
cznno__advent-of-code-kotlin__423e711/src/Day02.kt
|
import java.nio.file.Files
import java.nio.file.Path
object Day02 {
private val map1 = mapOf("X" to 1, "Y" to 2, "Z" to 3)
private val map2 = mapOf(
"A X" to 3, "A Y" to 6, "A Z" to 0,
"B X" to 0, "B Y" to 3, "B Z" to 6,
"C X" to 6, "C Y" to 0, "C Z" to 3,
)
private val list = listOf(
"001", "012", "020",
"100", "111", "122",
"202", "210", "221"
)
fun toDigi(t: String): Char {
return when (t) {
"X", "A" -> '0'
"Y", "B" -> '1'
else -> '2'
}
}
fun part1(data: List<String>) {
var sum = 0
for (s in data) {
val k = s.split(" ")
val m = toDigi(k[0])
val n = toDigi(k[1])
for (t in list) {
if (t[0] == m && t[1] == n) {
sum += when (t[1]) {
'0' -> 1
'1' -> 2
else -> 3
}
sum += when (t[2]) {
'0' -> 0
'1' -> 3
else -> 6
}
}
}
// sum += map1[s.split(" ")[1]]!!
// sum += map2[s]!!
}
println(sum) //8890
}
fun part2(data: List<String>) {
var sum = 0
for (s in data) {
val k = s.split(" ")
val m = toDigi(k[0])
val n = toDigi(k[1])
for (t in list) {
if (t[0] == m && t[2] == n) {
sum += when (t[1]) {
'0' -> 1
'1' -> 2
else -> 3
}
sum += when (t[2]) {
'0' -> 0
'1' -> 3
else -> 6
}
}
}
}
println(sum)
}
}
fun main() {
val data = Files.readAllLines(Path.of("./input/Day02.txt"))
Day02.part1(data)
Day02.part2(data)
}
|
[
{
"class_path": "cznno__advent-of-code-kotlin__423e711/Day02Kt.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class Day02Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String ./input/Day02.txt\n 2: iconst_0\n 3: anewarray #10 // class java/lang/String\n 6: invokestatic #16 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 9: invokestatic #22 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;)Ljava/util/List;\n 12: astore_0\n 13: getstatic #28 // Field Day02.INSTANCE:LDay02;\n 16: aload_0\n 17: invokestatic #34 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 20: aload_0\n 21: invokevirtual #38 // Method Day02.part1:(Ljava/util/List;)V\n 24: getstatic #28 // Field Day02.INSTANCE:LDay02;\n 27: aload_0\n 28: invokevirtual #41 // Method Day02.part2:(Ljava/util/List;)V\n 31: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #46 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
},
{
"class_path": "cznno__advent-of-code-kotlin__423e711/Day02.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class Day02 {\n public static final Day02 INSTANCE;\n\n private static final java.util.Map<java.lang.String, java.lang.Integer> map1;\n\n private static final java.util.Map<java.lang.String, java.lang.Integer> map2;\n\n private static final java.util.List<java.lang.String> list;\n\n private Day02();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final char toDigi(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String t\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: astore_2\n 8: aload_2\n 9: invokevirtual #27 // Method java/lang/String.hashCode:()I\n 12: lookupswitch { // 4\n 65: 56\n 66: 68\n 88: 80\n 89: 92\n default: 114\n }\n 56: aload_2\n 57: ldc #29 // String A\n 59: invokevirtual #33 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 62: ifne 104\n 65: goto 114\n 68: aload_2\n 69: ldc #35 // String B\n 71: invokevirtual #33 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 74: ifne 109\n 77: goto 114\n 80: aload_2\n 81: ldc #37 // String X\n 83: invokevirtual #33 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 86: ifne 104\n 89: goto 114\n 92: aload_2\n 93: ldc #39 // String Y\n 95: invokevirtual #33 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 98: ifne 109\n 101: goto 114\n 104: bipush 48\n 106: goto 116\n 109: bipush 49\n 111: goto 116\n 114: bipush 50\n 116: ireturn\n\n public final void part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #45 // String data\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_2\n 8: aload_1\n 9: invokeinterface #51, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 14: astore_3\n 15: aload_3\n 16: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 21: ifeq 235\n 24: aload_3\n 25: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 30: checkcast #23 // class java/lang/String\n 33: astore 4\n 35: aload 4\n 37: checkcast #63 // class java/lang/CharSequence\n 40: iconst_1\n 41: anewarray #23 // class java/lang/String\n 44: astore 6\n 46: aload 6\n 48: iconst_0\n 49: ldc #65 // String\n 51: aastore\n 52: aload 6\n 54: iconst_0\n 55: iconst_0\n 56: bipush 6\n 58: aconst_null\n 59: invokestatic #71 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 62: astore 5\n 64: aload_0\n 65: aload 5\n 67: iconst_0\n 68: invokeinterface #75, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 73: checkcast #23 // class java/lang/String\n 76: invokevirtual #77 // Method toDigi:(Ljava/lang/String;)C\n 79: istore 6\n 81: aload_0\n 82: aload 5\n 84: iconst_1\n 85: invokeinterface #75, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 90: checkcast #23 // class java/lang/String\n 93: invokevirtual #77 // Method toDigi:(Ljava/lang/String;)C\n 96: istore 7\n 98: getstatic #81 // Field list:Ljava/util/List;\n 101: invokeinterface #51, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 106: astore 8\n 108: aload 8\n 110: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 115: ifeq 15\n 118: aload 8\n 120: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 125: checkcast #23 // class java/lang/String\n 128: astore 9\n 130: aload 9\n 132: iconst_0\n 133: invokevirtual #85 // Method java/lang/String.charAt:(I)C\n 136: iload 6\n 138: if_icmpne 108\n 141: aload 9\n 143: iconst_1\n 144: invokevirtual #85 // Method java/lang/String.charAt:(I)C\n 147: iload 7\n 149: if_icmpne 108\n 152: iload_2\n 153: aload 9\n 155: iconst_1\n 156: invokevirtual #85 // Method java/lang/String.charAt:(I)C\n 159: tableswitch { // 48 to 49\n 48: 180\n 49: 184\n default: 188\n }\n 180: iconst_1\n 181: goto 189\n 184: iconst_2\n 185: goto 189\n 188: iconst_3\n 189: iadd\n 190: istore_2\n 191: iload_2\n 192: aload 9\n 194: iconst_2\n 195: invokevirtual #85 // Method java/lang/String.charAt:(I)C\n 198: tableswitch { // 48 to 49\n 48: 220\n 49: 224\n default: 228\n }\n 220: iconst_0\n 221: goto 230\n 224: iconst_3\n 225: goto 230\n 228: bipush 6\n 230: iadd\n 231: istore_2\n 232: goto 108\n 235: getstatic #91 // Field java/lang/System.out:Ljava/io/PrintStream;\n 238: iload_2\n 239: invokevirtual #97 // Method java/io/PrintStream.println:(I)V\n 242: return\n\n public final void part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #45 // String data\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_2\n 8: aload_1\n 9: invokeinterface #51, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 14: astore_3\n 15: aload_3\n 16: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 21: ifeq 235\n 24: aload_3\n 25: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 30: checkcast #23 // class java/lang/String\n 33: astore 4\n 35: aload 4\n 37: checkcast #63 // class java/lang/CharSequence\n 40: iconst_1\n 41: anewarray #23 // class java/lang/String\n 44: astore 6\n 46: aload 6\n 48: iconst_0\n 49: ldc #65 // String\n 51: aastore\n 52: aload 6\n 54: iconst_0\n 55: iconst_0\n 56: bipush 6\n 58: aconst_null\n 59: invokestatic #71 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 62: astore 5\n 64: aload_0\n 65: aload 5\n 67: iconst_0\n 68: invokeinterface #75, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 73: checkcast #23 // class java/lang/String\n 76: invokevirtual #77 // Method toDigi:(Ljava/lang/String;)C\n 79: istore 6\n 81: aload_0\n 82: aload 5\n 84: iconst_1\n 85: invokeinterface #75, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 90: checkcast #23 // class java/lang/String\n 93: invokevirtual #77 // Method toDigi:(Ljava/lang/String;)C\n 96: istore 7\n 98: getstatic #81 // Field list:Ljava/util/List;\n 101: invokeinterface #51, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 106: astore 8\n 108: aload 8\n 110: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 115: ifeq 15\n 118: aload 8\n 120: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 125: checkcast #23 // class java/lang/String\n 128: astore 9\n 130: aload 9\n 132: iconst_0\n 133: invokevirtual #85 // Method java/lang/String.charAt:(I)C\n 136: iload 6\n 138: if_icmpne 108\n 141: aload 9\n 143: iconst_2\n 144: invokevirtual #85 // Method java/lang/String.charAt:(I)C\n 147: iload 7\n 149: if_icmpne 108\n 152: iload_2\n 153: aload 9\n 155: iconst_1\n 156: invokevirtual #85 // Method java/lang/String.charAt:(I)C\n 159: tableswitch { // 48 to 49\n 48: 180\n 49: 184\n default: 188\n }\n 180: iconst_1\n 181: goto 189\n 184: iconst_2\n 185: goto 189\n 188: iconst_3\n 189: iadd\n 190: istore_2\n 191: iload_2\n 192: aload 9\n 194: iconst_2\n 195: invokevirtual #85 // Method java/lang/String.charAt:(I)C\n 198: tableswitch { // 48 to 49\n 48: 220\n 49: 224\n default: 228\n }\n 220: iconst_0\n 221: goto 230\n 224: iconst_3\n 225: goto 230\n 228: bipush 6\n 230: iadd\n 231: istore_2\n 232: goto 108\n 235: getstatic #91 // Field java/lang/System.out:Ljava/io/PrintStream;\n 238: iload_2\n 239: invokevirtual #97 // Method java/io/PrintStream.println:(I)V\n 242: return\n\n static {};\n Code:\n 0: new #2 // class Day02\n 3: dup\n 4: invokespecial #107 // Method \"<init>\":()V\n 7: putstatic #110 // Field INSTANCE:LDay02;\n 10: iconst_3\n 11: anewarray #112 // class kotlin/Pair\n 14: astore_0\n 15: aload_0\n 16: iconst_0\n 17: ldc #37 // String X\n 19: iconst_1\n 20: invokestatic #118 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 23: invokestatic #124 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 26: aastore\n 27: aload_0\n 28: iconst_1\n 29: ldc #39 // String Y\n 31: iconst_2\n 32: invokestatic #118 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 35: invokestatic #124 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 38: aastore\n 39: aload_0\n 40: iconst_2\n 41: ldc #126 // String Z\n 43: iconst_3\n 44: invokestatic #118 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 47: invokestatic #124 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 50: aastore\n 51: aload_0\n 52: invokestatic #132 // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 55: putstatic #136 // Field map1:Ljava/util/Map;\n 58: bipush 9\n 60: anewarray #112 // class kotlin/Pair\n 63: astore_0\n 64: aload_0\n 65: iconst_0\n 66: ldc #138 // String A X\n 68: iconst_3\n 69: invokestatic #118 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 72: invokestatic #124 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 75: aastore\n 76: aload_0\n 77: iconst_1\n 78: ldc #140 // String A Y\n 80: bipush 6\n 82: invokestatic #118 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 85: invokestatic #124 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 88: aastore\n 89: aload_0\n 90: iconst_2\n 91: ldc #142 // String A Z\n 93: iconst_0\n 94: invokestatic #118 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 97: invokestatic #124 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 100: aastore\n 101: aload_0\n 102: iconst_3\n 103: ldc #144 // String B X\n 105: iconst_0\n 106: invokestatic #118 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 109: invokestatic #124 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 112: aastore\n 113: aload_0\n 114: iconst_4\n 115: ldc #146 // String B Y\n 117: iconst_3\n 118: invokestatic #118 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 121: invokestatic #124 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 124: aastore\n 125: aload_0\n 126: iconst_5\n 127: ldc #148 // String B Z\n 129: bipush 6\n 131: invokestatic #118 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 134: invokestatic #124 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 137: aastore\n 138: aload_0\n 139: bipush 6\n 141: ldc #150 // String C X\n 143: bipush 6\n 145: invokestatic #118 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 148: invokestatic #124 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 151: aastore\n 152: aload_0\n 153: bipush 7\n 155: ldc #152 // String C Y\n 157: iconst_0\n 158: invokestatic #118 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 161: invokestatic #124 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 164: aastore\n 165: aload_0\n 166: bipush 8\n 168: ldc #154 // String C Z\n 170: iconst_3\n 171: invokestatic #118 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 174: invokestatic #124 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 177: aastore\n 178: aload_0\n 179: invokestatic #132 // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 182: putstatic #157 // Field map2:Ljava/util/Map;\n 185: bipush 9\n 187: anewarray #23 // class java/lang/String\n 190: astore_0\n 191: aload_0\n 192: iconst_0\n 193: ldc #159 // String 001\n 195: aastore\n 196: aload_0\n 197: iconst_1\n 198: ldc #161 // String 012\n 200: aastore\n 201: aload_0\n 202: iconst_2\n 203: ldc #163 // String 020\n 205: aastore\n 206: aload_0\n 207: iconst_3\n 208: ldc #165 // String 100\n 210: aastore\n 211: aload_0\n 212: iconst_4\n 213: ldc #167 // String 111\n 215: aastore\n 216: aload_0\n 217: iconst_5\n 218: ldc #169 // String 122\n 220: aastore\n 221: aload_0\n 222: bipush 6\n 224: ldc #171 // String 202\n 226: aastore\n 227: aload_0\n 228: bipush 7\n 230: ldc #173 // String 210\n 232: aastore\n 233: aload_0\n 234: bipush 8\n 236: ldc #175 // String 221\n 238: aastore\n 239: aload_0\n 240: invokestatic #181 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 243: putstatic #81 // Field list:Ljava/util/List;\n 246: return\n}\n",
"javap_err": ""
}
] |
ShuffleZZZ__advent-of-code-kotlin__5a3cff1/src/Utils.kt
|
import java.io.File
import java.math.BigInteger
import java.security.MessageDigest
import kotlin.math.absoluteValue
import kotlin.math.sign
fun Boolean.toInt() = if (this) 1 else 0
fun IntProgression.isRange() = step.sign > 0
operator fun <T> List<List<T>>.get(ind: Pair<Int, Int>) = this[ind.first][ind.second]
operator fun <T> List<MutableList<T>>.set(ind: Pair<Int, Int>, value: T) {
this[ind.first][ind.second] = value
}
fun <T> List<List<T>>.indexPairs(predicate: (T) -> Boolean = { true }) =
this.indices.flatMap { i ->
this.first().indices.map { j -> i to j }
}.filter { predicate(this[it]) }
operator fun Pair<Int, Int>.plus(other: Pair<Int, Int>) = first + other.first to second + other.second
operator fun Pair<Int, Int>.minus(other: Pair<Int, Int>) = first - other.first to second - other.second
fun Pair<Int, Int>.diff() = (second - first).absoluteValue
operator fun <T, K> Pair<T, K>.compareTo(other: Pair<T, K>) where T : Comparable<T>, K : Comparable<K> =
if (first == other.first) second.compareTo(other.second) else first.compareTo(other.first)
infix fun Pair<Int, Int>.manhattan(other: Pair<Int, Int>) =
(first - other.first).absoluteValue + (second - other.second).absoluteValue
/**
* Pairs intersect as ranges.
*/
fun <T> Pair<T, T>.intersect(other: Pair<T, T>) where T : Comparable<T> =
if (this.compareTo(other) < 0) second >= other.first else first <= other.second
/**
* One of pairs fully includes other as range.
*/
fun <T, K> Pair<T, K>.include(other: Pair<T, K>) where T : Comparable<T>, K : Comparable<K> =
first.compareTo(other.first).sign + second.compareTo(other.second).sign in -1..1
/**
* Returns list of pairs with indexes of non-diagonal neighbours' shifts in 2D array.
*/
fun neighbours() =
(-1..1).flatMap { i ->
(-1..1).filter { j -> (i + j).absoluteValue == 1 }.map { j -> i to j }
}
/**
* Returns list of pairs with indexes of given point non-diagonal neighbours in 2D array.
*/
fun neighbours(point: Pair<Int, Int>) = neighbours().map { it + point }
/**
* Reads lines from the given input txt file.
*/
fun readInput(name: String) = File("src", "$name.txt")
.readLines()
/**
* Reads blocks of lines separated by empty line.
*/
fun readBlocks(name: String) = File("src", "$name.txt")
.readText()
.trim('\n')
.split("\n\n")
.map { it.split('\n') }
/**
* Reads blocks separated by empty line.
*/
fun readRawBlocks(name: String) = File("src", "$name.txt")
.readText()
.trim('\n')
.split("\n\n")
/**
* Converts string to md5 hash.
*/
fun String.md5() = BigInteger(1, MessageDigest.getInstance("MD5").digest(toByteArray()))
.toString(16)
.padStart(32, '0')
|
[
{
"class_path": "ShuffleZZZ__advent-of-code-kotlin__5a3cff1/UtilsKt.class",
"javap": "Compiled from \"Utils.kt\"\npublic final class UtilsKt {\n public static final int toInt(boolean);\n Code:\n 0: iload_0\n 1: ifeq 8\n 4: iconst_1\n 5: goto 9\n 8: iconst_0\n 9: ireturn\n\n public static final boolean isRange(kotlin.ranges.IntProgression);\n Code:\n 0: aload_0\n 1: ldc #13 // String <this>\n 3: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokevirtual #25 // Method kotlin/ranges/IntProgression.getStep:()I\n 10: invokestatic #31 // Method kotlin/math/MathKt.getSign:(I)I\n 13: ifle 20\n 16: iconst_1\n 17: goto 21\n 20: iconst_0\n 21: ireturn\n\n public static final <T> T get(java.util.List<? extends java.util.List<? extends T>>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #13 // String <this>\n 3: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #38 // String ind\n 9: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: aload_1\n 14: invokevirtual #44 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 17: checkcast #46 // class java/lang/Number\n 20: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 23: invokeinterface #54, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 28: checkcast #51 // class java/util/List\n 31: aload_1\n 32: invokevirtual #57 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 35: checkcast #46 // class java/lang/Number\n 38: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 41: invokeinterface #54, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 46: areturn\n\n public static final <T> void set(java.util.List<? extends java.util.List<T>>, kotlin.Pair<java.lang.Integer, java.lang.Integer>, T);\n Code:\n 0: aload_0\n 1: ldc #13 // String <this>\n 3: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #38 // String ind\n 9: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: aload_1\n 14: invokevirtual #44 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 17: checkcast #46 // class java/lang/Number\n 20: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 23: invokeinterface #54, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 28: checkcast #51 // class java/util/List\n 31: aload_1\n 32: invokevirtual #57 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 35: checkcast #46 // class java/lang/Number\n 38: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 41: aload_2\n 42: invokeinterface #66, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 47: pop\n 48: return\n\n public static final <T> java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> indexPairs(java.util.List<? extends java.util.List<? extends T>>, kotlin.jvm.functions.Function1<? super T, java.lang.Boolean>);\n Code:\n 0: aload_0\n 1: ldc #13 // String <this>\n 3: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #74 // String predicate\n 9: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: checkcast #76 // class java/util/Collection\n 16: invokestatic #82 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 19: checkcast #84 // class java/lang/Iterable\n 22: astore_2\n 23: iconst_0\n 24: istore_3\n 25: aload_2\n 26: astore 4\n 28: new #86 // class java/util/ArrayList\n 31: dup\n 32: invokespecial #90 // Method java/util/ArrayList.\"<init>\":()V\n 35: checkcast #76 // class java/util/Collection\n 38: astore 5\n 40: iconst_0\n 41: istore 6\n 43: aload 4\n 45: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 50: astore 7\n 52: aload 7\n 54: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 211\n 62: aload 7\n 64: checkcast #102 // class kotlin/collections/IntIterator\n 67: invokevirtual #105 // Method kotlin/collections/IntIterator.nextInt:()I\n 70: istore 8\n 72: iload 8\n 74: istore 9\n 76: iconst_0\n 77: istore 10\n 79: aload_0\n 80: invokestatic #109 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 83: checkcast #76 // class java/util/Collection\n 86: invokestatic #82 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 89: checkcast #84 // class java/lang/Iterable\n 92: astore 11\n 94: iconst_0\n 95: istore 12\n 97: aload 11\n 99: astore 13\n 101: new #86 // class java/util/ArrayList\n 104: dup\n 105: aload 11\n 107: bipush 10\n 109: invokestatic #113 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 112: invokespecial #116 // Method java/util/ArrayList.\"<init>\":(I)V\n 115: checkcast #76 // class java/util/Collection\n 118: astore 14\n 120: iconst_0\n 121: istore 15\n 123: aload 13\n 125: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 130: astore 16\n 132: aload 16\n 134: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 139: ifeq 188\n 142: aload 16\n 144: checkcast #102 // class kotlin/collections/IntIterator\n 147: invokevirtual #105 // Method kotlin/collections/IntIterator.nextInt:()I\n 150: istore 17\n 152: aload 14\n 154: iload 17\n 156: istore 18\n 158: astore 19\n 160: iconst_0\n 161: istore 20\n 163: iload 9\n 165: invokestatic #122 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 168: iload 18\n 170: invokestatic #122 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 173: invokestatic #128 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 176: aload 19\n 178: swap\n 179: invokeinterface #132, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 184: pop\n 185: goto 132\n 188: aload 14\n 190: checkcast #51 // class java/util/List\n 193: nop\n 194: checkcast #84 // class java/lang/Iterable\n 197: nop\n 198: astore 9\n 200: aload 5\n 202: aload 9\n 204: invokestatic #136 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 207: pop\n 208: goto 52\n 211: aload 5\n 213: checkcast #51 // class java/util/List\n 216: nop\n 217: checkcast #84 // class java/lang/Iterable\n 220: astore_2\n 221: nop\n 222: iconst_0\n 223: istore_3\n 224: aload_2\n 225: astore 4\n 227: new #86 // class java/util/ArrayList\n 230: dup\n 231: invokespecial #90 // Method java/util/ArrayList.\"<init>\":()V\n 234: checkcast #76 // class java/util/Collection\n 237: astore 5\n 239: iconst_0\n 240: istore 6\n 242: aload 4\n 244: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 249: astore 7\n 251: aload 7\n 253: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 258: ifeq 314\n 261: aload 7\n 263: invokeinterface #139, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 268: astore 8\n 270: aload 8\n 272: checkcast #40 // class kotlin/Pair\n 275: astore 9\n 277: iconst_0\n 278: istore 10\n 280: aload_1\n 281: aload_0\n 282: aload 9\n 284: invokestatic #141 // Method get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;\n 287: invokeinterface #147, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 292: checkcast #149 // class java/lang/Boolean\n 295: invokevirtual #152 // Method java/lang/Boolean.booleanValue:()Z\n 298: ifeq 251\n 301: aload 5\n 303: aload 8\n 305: invokeinterface #132, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 310: pop\n 311: goto 251\n 314: aload 5\n 316: checkcast #51 // class java/util/List\n 319: nop\n 320: areturn\n\n public static java.util.List indexPairs$default(java.util.List, kotlin.jvm.functions.Function1, int, java.lang.Object);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: iand\n 3: ifeq 12\n 6: invokedynamic #198, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 11: astore_1\n 12: aload_0\n 13: aload_1\n 14: invokestatic #200 // Method indexPairs:(Ljava/util/List;Lkotlin/jvm/functions/Function1;)Ljava/util/List;\n 17: areturn\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 #13 // String <this>\n 3: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #205 // String other\n 9: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokevirtual #44 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 16: checkcast #46 // class java/lang/Number\n 19: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 22: aload_1\n 23: invokevirtual #44 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 26: checkcast #46 // class java/lang/Number\n 29: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 32: iadd\n 33: invokestatic #122 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 36: aload_0\n 37: invokevirtual #57 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 40: checkcast #46 // class java/lang/Number\n 43: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 46: aload_1\n 47: invokevirtual #57 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 50: checkcast #46 // class java/lang/Number\n 53: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 56: iadd\n 57: invokestatic #122 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 60: invokestatic #128 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 63: 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 #13 // String <this>\n 3: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #205 // String other\n 9: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokevirtual #44 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 16: checkcast #46 // class java/lang/Number\n 19: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 22: aload_1\n 23: invokevirtual #44 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 26: checkcast #46 // class java/lang/Number\n 29: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 32: isub\n 33: invokestatic #122 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 36: aload_0\n 37: invokevirtual #57 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 40: checkcast #46 // class java/lang/Number\n 43: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 46: aload_1\n 47: invokevirtual #57 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 50: checkcast #46 // class java/lang/Number\n 53: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 56: isub\n 57: invokestatic #122 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 60: invokestatic #128 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 63: areturn\n\n public static final int diff(kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #13 // String <this>\n 3: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokevirtual #57 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 10: checkcast #46 // class java/lang/Number\n 13: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 16: aload_0\n 17: invokevirtual #44 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 20: checkcast #46 // class java/lang/Number\n 23: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 26: isub\n 27: invokestatic #216 // Method java/lang/Math.abs:(I)I\n 30: ireturn\n\n public static final <T extends java.lang.Comparable<? super T>, K extends java.lang.Comparable<? super K>> int compareTo(kotlin.Pair<? extends T, ? extends K>, kotlin.Pair<? extends T, ? extends K>);\n Code:\n 0: aload_0\n 1: ldc #13 // String <this>\n 3: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #205 // String other\n 9: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokevirtual #44 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 16: aload_1\n 17: invokevirtual #44 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 20: invokestatic #224 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 23: ifeq 45\n 26: aload_0\n 27: invokevirtual #57 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 30: checkcast #226 // class java/lang/Comparable\n 33: aload_1\n 34: invokevirtual #57 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 37: invokeinterface #229, 2 // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I\n 42: goto 61\n 45: aload_0\n 46: invokevirtual #44 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 49: checkcast #226 // class java/lang/Comparable\n 52: aload_1\n 53: invokevirtual #44 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 56: invokeinterface #229, 2 // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I\n 61: ireturn\n\n public static final int manhattan(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 #13 // String <this>\n 3: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #205 // String other\n 9: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokevirtual #44 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 16: checkcast #46 // class java/lang/Number\n 19: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 22: aload_1\n 23: invokevirtual #44 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 26: checkcast #46 // class java/lang/Number\n 29: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 32: isub\n 33: invokestatic #216 // Method java/lang/Math.abs:(I)I\n 36: aload_0\n 37: invokevirtual #57 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 40: checkcast #46 // class java/lang/Number\n 43: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 46: aload_1\n 47: invokevirtual #57 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 50: checkcast #46 // class java/lang/Number\n 53: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 56: isub\n 57: invokestatic #216 // Method java/lang/Math.abs:(I)I\n 60: iadd\n 61: ireturn\n\n public static final <T extends java.lang.Comparable<? super T>> boolean intersect(kotlin.Pair<? extends T, ? extends T>, kotlin.Pair<? extends T, ? extends T>);\n Code:\n 0: aload_0\n 1: ldc #13 // String <this>\n 3: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #205 // String other\n 9: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: aload_1\n 14: invokestatic #238 // Method compareTo:(Lkotlin/Pair;Lkotlin/Pair;)I\n 17: ifge 47\n 20: aload_0\n 21: invokevirtual #57 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 24: checkcast #226 // class java/lang/Comparable\n 27: aload_1\n 28: invokevirtual #44 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 31: invokeinterface #229, 2 // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I\n 36: iflt 43\n 39: iconst_1\n 40: goto 71\n 43: iconst_0\n 44: goto 71\n 47: aload_0\n 48: invokevirtual #44 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 51: checkcast #226 // class java/lang/Comparable\n 54: aload_1\n 55: invokevirtual #57 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 58: invokeinterface #229, 2 // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I\n 63: ifgt 70\n 66: iconst_1\n 67: goto 71\n 70: iconst_0\n 71: ireturn\n\n public static final <T extends java.lang.Comparable<? super T>, K extends java.lang.Comparable<? super K>> boolean include(kotlin.Pair<? extends T, ? extends K>, kotlin.Pair<? extends T, ? extends K>);\n Code:\n 0: aload_0\n 1: ldc #13 // String <this>\n 3: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #205 // String other\n 9: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokevirtual #44 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 16: checkcast #226 // class java/lang/Comparable\n 19: aload_1\n 20: invokevirtual #44 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 23: invokeinterface #229, 2 // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I\n 28: invokestatic #31 // Method kotlin/math/MathKt.getSign:(I)I\n 31: aload_0\n 32: invokevirtual #57 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 35: checkcast #226 // class java/lang/Comparable\n 38: aload_1\n 39: invokevirtual #57 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 42: invokeinterface #229, 2 // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I\n 47: invokestatic #31 // Method kotlin/math/MathKt.getSign:(I)I\n 50: iadd\n 51: istore_2\n 52: iconst_m1\n 53: iload_2\n 54: if_icmpgt 70\n 57: iload_2\n 58: iconst_2\n 59: if_icmpge 66\n 62: iconst_1\n 63: goto 71\n 66: iconst_0\n 67: goto 71\n 70: iconst_0\n 71: ireturn\n\n public static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> neighbours();\n Code:\n 0: new #247 // class kotlin/ranges/IntRange\n 3: dup\n 4: iconst_m1\n 5: iconst_1\n 6: invokespecial #250 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 9: checkcast #84 // class java/lang/Iterable\n 12: astore_0\n 13: iconst_0\n 14: istore_1\n 15: aload_0\n 16: astore_2\n 17: new #86 // class java/util/ArrayList\n 20: dup\n 21: invokespecial #90 // Method java/util/ArrayList.\"<init>\":()V\n 24: checkcast #76 // class java/util/Collection\n 27: astore_3\n 28: iconst_0\n 29: istore 4\n 31: aload_2\n 32: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 37: astore 5\n 39: aload 5\n 41: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 46: ifeq 309\n 49: aload 5\n 51: checkcast #102 // class kotlin/collections/IntIterator\n 54: invokevirtual #105 // Method kotlin/collections/IntIterator.nextInt:()I\n 57: istore 6\n 59: iload 6\n 61: istore 7\n 63: iconst_0\n 64: istore 8\n 66: new #247 // class kotlin/ranges/IntRange\n 69: dup\n 70: iconst_m1\n 71: iconst_1\n 72: invokespecial #250 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 75: checkcast #84 // class java/lang/Iterable\n 78: astore 9\n 80: iconst_0\n 81: istore 10\n 83: aload 9\n 85: astore 11\n 87: new #86 // class java/util/ArrayList\n 90: dup\n 91: invokespecial #90 // Method java/util/ArrayList.\"<init>\":()V\n 94: checkcast #76 // class java/util/Collection\n 97: astore 12\n 99: iconst_0\n 100: istore 13\n 102: aload 11\n 104: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 109: astore 14\n 111: aload 14\n 113: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 118: ifeq 176\n 121: aload 14\n 123: invokeinterface #139, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 128: astore 15\n 130: aload 15\n 132: checkcast #46 // class java/lang/Number\n 135: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 138: istore 16\n 140: iconst_0\n 141: istore 17\n 143: iload 7\n 145: iload 16\n 147: iadd\n 148: invokestatic #216 // Method java/lang/Math.abs:(I)I\n 151: iconst_1\n 152: if_icmpne 159\n 155: iconst_1\n 156: goto 160\n 159: iconst_0\n 160: ifeq 111\n 163: aload 12\n 165: aload 15\n 167: invokeinterface #132, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 172: pop\n 173: goto 111\n 176: aload 12\n 178: checkcast #51 // class java/util/List\n 181: nop\n 182: checkcast #84 // 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 #86 // class java/util/ArrayList\n 198: dup\n 199: aload 9\n 201: bipush 10\n 203: invokestatic #113 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 206: invokespecial #116 // Method java/util/ArrayList.\"<init>\":(I)V\n 209: checkcast #76 // class java/util/Collection\n 212: astore 12\n 214: iconst_0\n 215: istore 13\n 217: aload 11\n 219: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 224: astore 14\n 226: aload 14\n 228: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 233: ifeq 287\n 236: aload 14\n 238: invokeinterface #139, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 243: astore 15\n 245: aload 12\n 247: aload 15\n 249: checkcast #46 // class java/lang/Number\n 252: invokevirtual #49 // Method java/lang/Number.intValue:()I\n 255: istore 16\n 257: astore 18\n 259: iconst_0\n 260: istore 17\n 262: iload 7\n 264: invokestatic #122 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 267: iload 16\n 269: invokestatic #122 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 272: invokestatic #128 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 275: aload 18\n 277: swap\n 278: invokeinterface #132, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 283: pop\n 284: goto 226\n 287: aload 12\n 289: checkcast #51 // class java/util/List\n 292: nop\n 293: checkcast #84 // class java/lang/Iterable\n 296: nop\n 297: astore 7\n 299: aload_3\n 300: aload 7\n 302: invokestatic #136 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 305: pop\n 306: goto 39\n 309: aload_3\n 310: checkcast #51 // class java/util/List\n 313: nop\n 314: areturn\n\n public static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> neighbours(kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc_w #257 // String point\n 4: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: invokestatic #259 // Method neighbours:()Ljava/util/List;\n 10: checkcast #84 // 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 #86 // class java/util/ArrayList\n 21: dup\n 22: aload_1\n 23: bipush 10\n 25: invokestatic #113 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 28: invokespecial #116 // Method java/util/ArrayList.\"<init>\":(I)V\n 31: checkcast #76 // class java/util/Collection\n 34: astore 4\n 36: iconst_0\n 37: istore 5\n 39: aload_3\n 40: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 6\n 47: aload 6\n 49: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 98\n 57: aload 6\n 59: invokeinterface #139, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 7\n 66: aload 4\n 68: aload 7\n 70: checkcast #40 // class kotlin/Pair\n 73: astore 8\n 75: astore 10\n 77: iconst_0\n 78: istore 9\n 80: aload 8\n 82: aload_0\n 83: invokestatic #261 // Method plus:(Lkotlin/Pair;Lkotlin/Pair;)Lkotlin/Pair;\n 86: aload 10\n 88: swap\n 89: invokeinterface #132, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 94: pop\n 95: goto 47\n 98: aload 4\n 100: checkcast #51 // class java/util/List\n 103: nop\n 104: areturn\n\n public static final java.util.List<java.lang.String> readInput(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #267 // String name\n 4: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: new #269 // class java/io/File\n 10: dup\n 11: ldc_w #271 // String src\n 14: new #273 // class java/lang/StringBuilder\n 17: dup\n 18: invokespecial #274 // Method java/lang/StringBuilder.\"<init>\":()V\n 21: aload_0\n 22: invokevirtual #278 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 25: ldc_w #280 // String .txt\n 28: invokevirtual #278 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 31: invokevirtual #284 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 34: invokespecial #287 // Method java/io/File.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 37: aconst_null\n 38: iconst_1\n 39: aconst_null\n 40: invokestatic #293 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 43: areturn\n\n public static final java.util.List<java.util.List<java.lang.String>> readBlocks(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #267 // String name\n 4: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: new #269 // class java/io/File\n 10: dup\n 11: ldc_w #271 // String src\n 14: new #273 // class java/lang/StringBuilder\n 17: dup\n 18: invokespecial #274 // Method java/lang/StringBuilder.\"<init>\":()V\n 21: aload_0\n 22: invokevirtual #278 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 25: ldc_w #280 // String .txt\n 28: invokevirtual #278 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 31: invokevirtual #284 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 34: invokespecial #287 // Method java/io/File.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 37: aconst_null\n 38: iconst_1\n 39: aconst_null\n 40: invokestatic #300 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;\n 43: iconst_1\n 44: newarray char\n 46: astore_1\n 47: aload_1\n 48: iconst_0\n 49: bipush 10\n 51: castore\n 52: aload_1\n 53: invokestatic #306 // Method kotlin/text/StringsKt.trim:(Ljava/lang/String;[C)Ljava/lang/String;\n 56: checkcast #308 // class java/lang/CharSequence\n 59: iconst_1\n 60: anewarray #310 // class java/lang/String\n 63: astore_1\n 64: aload_1\n 65: iconst_0\n 66: ldc_w #312 // String \\n\\n\n 69: aastore\n 70: aload_1\n 71: iconst_0\n 72: iconst_0\n 73: bipush 6\n 75: aconst_null\n 76: invokestatic #316 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 79: checkcast #84 // class java/lang/Iterable\n 82: astore_1\n 83: nop\n 84: iconst_0\n 85: istore_2\n 86: aload_1\n 87: astore_3\n 88: new #86 // class java/util/ArrayList\n 91: dup\n 92: aload_1\n 93: bipush 10\n 95: invokestatic #113 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 98: invokespecial #116 // Method java/util/ArrayList.\"<init>\":(I)V\n 101: checkcast #76 // class java/util/Collection\n 104: astore 4\n 106: iconst_0\n 107: istore 5\n 109: aload_3\n 110: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 115: astore 6\n 117: aload 6\n 119: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 124: ifeq 188\n 127: aload 6\n 129: invokeinterface #139, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 134: astore 7\n 136: aload 4\n 138: aload 7\n 140: checkcast #310 // class java/lang/String\n 143: astore 8\n 145: astore 11\n 147: iconst_0\n 148: istore 9\n 150: aload 8\n 152: checkcast #308 // class java/lang/CharSequence\n 155: iconst_1\n 156: newarray char\n 158: astore 10\n 160: aload 10\n 162: iconst_0\n 163: bipush 10\n 165: castore\n 166: aload 10\n 168: iconst_0\n 169: iconst_0\n 170: bipush 6\n 172: aconst_null\n 173: invokestatic #319 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 176: aload 11\n 178: swap\n 179: invokeinterface #132, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 184: pop\n 185: goto 117\n 188: aload 4\n 190: checkcast #51 // class java/util/List\n 193: nop\n 194: areturn\n\n public static final java.util.List<java.lang.String> readRawBlocks(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #267 // String name\n 4: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: new #269 // class java/io/File\n 10: dup\n 11: ldc_w #271 // String src\n 14: new #273 // class java/lang/StringBuilder\n 17: dup\n 18: invokespecial #274 // Method java/lang/StringBuilder.\"<init>\":()V\n 21: aload_0\n 22: invokevirtual #278 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 25: ldc_w #280 // String .txt\n 28: invokevirtual #278 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 31: invokevirtual #284 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 34: invokespecial #287 // Method java/io/File.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 37: aconst_null\n 38: iconst_1\n 39: aconst_null\n 40: invokestatic #300 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;\n 43: iconst_1\n 44: newarray char\n 46: astore_1\n 47: aload_1\n 48: iconst_0\n 49: bipush 10\n 51: castore\n 52: aload_1\n 53: invokestatic #306 // Method kotlin/text/StringsKt.trim:(Ljava/lang/String;[C)Ljava/lang/String;\n 56: checkcast #308 // class java/lang/CharSequence\n 59: iconst_1\n 60: anewarray #310 // class java/lang/String\n 63: astore_1\n 64: aload_1\n 65: iconst_0\n 66: ldc_w #312 // String \\n\\n\n 69: aastore\n 70: aload_1\n 71: iconst_0\n 72: iconst_0\n 73: bipush 6\n 75: aconst_null\n 76: invokestatic #316 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 79: areturn\n\n public static final java.lang.String md5(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #13 // String <this>\n 3: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #325 // class java/math/BigInteger\n 9: dup\n 10: iconst_1\n 11: ldc_w #327 // String MD5\n 14: invokestatic #333 // Method java/security/MessageDigest.getInstance:(Ljava/lang/String;)Ljava/security/MessageDigest;\n 17: aload_0\n 18: astore_1\n 19: getstatic #339 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 22: aload_1\n 23: swap\n 24: invokevirtual #343 // Method java/lang/String.getBytes:(Ljava/nio/charset/Charset;)[B\n 27: dup\n 28: ldc_w #345 // String getBytes(...)\n 31: invokestatic #348 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 34: invokevirtual #352 // Method java/security/MessageDigest.digest:([B)[B\n 37: invokespecial #355 // Method java/math/BigInteger.\"<init>\":(I[B)V\n 40: bipush 16\n 42: invokevirtual #358 // Method java/math/BigInteger.toString:(I)Ljava/lang/String;\n 45: dup\n 46: ldc_w #360 // String toString(...)\n 49: invokestatic #348 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 52: bipush 32\n 54: bipush 48\n 56: invokestatic #364 // Method kotlin/text/StringsKt.padStart:(Ljava/lang/String;IC)Ljava/lang/String;\n 59: areturn\n\n private static final boolean indexPairs$lambda$0(java.lang.Object);\n Code:\n 0: iconst_1\n 1: ireturn\n}\n",
"javap_err": ""
}
] |
ShuffleZZZ__advent-of-code-kotlin__5a3cff1/src/Day14.kt
|
private data class CurrentUnit(var pile: Int = 500, var height: Int = 0) {
fun diagonalMove(piles: Map<Int, Set<Int>>): Boolean {
if (piles[pile - 1] == null || !piles[pile - 1]!!.contains(height + 1)) {
pile--
height++
return true
}
if (piles[pile + 1] == null || !piles[pile + 1]!!.contains(height + 1)) {
pile++
height++
return true
}
return false
}
fun reset(): Boolean {
if (pile == 500 && height == 0) return false
pile = 500
height = 0
return true
}
}
private fun getPoints(input: List<String>) = input.map { line ->
line.split(" -> ")
.map { it.split(',').map(String::toInt) }
.map { (first, second) -> first to second }
}
private fun getPiles(points: List<List<Pair<Int, Int>>>): MutableMap<Int, MutableSet<Int>> {
val piles = mutableMapOf<Int, MutableSet<Int>>()
points.forEach { line ->
line.zipWithNext().forEach { (start, end) ->
val (minPoint, maxPoint) = if (start < end) start to end else end to start
val (x, y) = maxPoint - minPoint
for (i in 0..x) {
for (j in 0..y) {
piles.computeIfAbsent(minPoint.first + i) { mutableSetOf() }.add(minPoint.second + j)
}
}
}
}
return piles
}
private fun Set<Int>.fallUnitOrNull(height: Int) = this.filter { it > height }.minOrNull()
fun main() {
fun part1(input: List<String>): Int {
val piles = getPiles(getPoints(input))
var cnt = 0
val point = CurrentUnit()
while (true) {
val pile = piles[point.pile]
point.height = pile?.fallUnitOrNull(point.height) ?: return cnt
point.height--
if (point.diagonalMove(piles)) continue
pile.add(point.height)
cnt++
point.reset()
}
}
fun part2(input: List<String>): Int {
val piles = getPiles(getPoints(input))
val floor = piles.values.maxOf { it.max() } + 2
var cnt = 0
val point = CurrentUnit()
while (true) {
val pile = piles.computeIfAbsent(point.pile) { mutableSetOf(floor) }
point.height = pile.fallUnitOrNull(point.height) ?: floor
point.height--
if (point.height != floor - 1 && point.diagonalMove(piles)) continue
pile.add(point.height)
cnt++
if (!point.reset()) return cnt
}
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day14_test")
check(part1(testInput) == 24)
check(part2(testInput) == 93)
val input = readInput("Day14")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "ShuffleZZZ__advent-of-code-kotlin__5a3cff1/Day14Kt.class",
"javap": "Compiled from \"Day14.kt\"\npublic final class Day14Kt {\n private static final java.util.List<java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>>> getPoints(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #9 // 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 #11 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #23 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 476\n 48: aload 6\n 50: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #39 // class java/lang/String\n 64: astore 8\n 66: astore 30\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: checkcast #41 // class java/lang/CharSequence\n 76: iconst_1\n 77: anewarray #39 // class java/lang/String\n 80: astore 10\n 82: aload 10\n 84: iconst_0\n 85: ldc #43 // String ->\n 87: aastore\n 88: aload 10\n 90: iconst_0\n 91: iconst_0\n 92: bipush 6\n 94: aconst_null\n 95: invokestatic #49 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 98: checkcast #9 // class java/lang/Iterable\n 101: astore 10\n 103: nop\n 104: iconst_0\n 105: istore 11\n 107: aload 10\n 109: astore 12\n 111: new #11 // class java/util/ArrayList\n 114: dup\n 115: aload 10\n 117: bipush 10\n 119: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 122: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 125: checkcast #23 // class java/util/Collection\n 128: astore 13\n 130: iconst_0\n 131: istore 14\n 133: aload 12\n 135: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 140: astore 15\n 142: aload 15\n 144: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 149: ifeq 317\n 152: aload 15\n 154: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 159: astore 16\n 161: aload 13\n 163: aload 16\n 165: checkcast #39 // class java/lang/String\n 168: astore 17\n 170: astore 18\n 172: iconst_0\n 173: istore 19\n 175: aload 17\n 177: checkcast #41 // class java/lang/CharSequence\n 180: iconst_1\n 181: newarray char\n 183: astore 20\n 185: aload 20\n 187: iconst_0\n 188: bipush 44\n 190: castore\n 191: aload 20\n 193: iconst_0\n 194: iconst_0\n 195: bipush 6\n 197: aconst_null\n 198: invokestatic #52 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 201: checkcast #9 // class java/lang/Iterable\n 204: astore 20\n 206: iconst_0\n 207: istore 21\n 209: aload 20\n 211: astore 22\n 213: new #11 // class java/util/ArrayList\n 216: dup\n 217: aload 20\n 219: bipush 10\n 221: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 224: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 227: checkcast #23 // class java/util/Collection\n 230: astore 23\n 232: iconst_0\n 233: istore 24\n 235: aload 22\n 237: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 242: astore 25\n 244: aload 25\n 246: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 251: ifeq 298\n 254: aload 25\n 256: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 261: astore 26\n 263: aload 23\n 265: aload 26\n 267: checkcast #39 // class java/lang/String\n 270: astore 27\n 272: astore 28\n 274: iconst_0\n 275: istore 29\n 277: aload 27\n 279: invokestatic #58 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 282: nop\n 283: invokestatic #62 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 286: aload 28\n 288: swap\n 289: invokeinterface #66, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 294: pop\n 295: goto 244\n 298: aload 23\n 300: checkcast #68 // class java/util/List\n 303: nop\n 304: nop\n 305: aload 18\n 307: swap\n 308: invokeinterface #66, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 313: pop\n 314: goto 142\n 317: aload 13\n 319: checkcast #68 // class java/util/List\n 322: nop\n 323: checkcast #9 // class java/lang/Iterable\n 326: astore 10\n 328: nop\n 329: iconst_0\n 330: istore 11\n 332: aload 10\n 334: astore 12\n 336: new #11 // class java/util/ArrayList\n 339: dup\n 340: aload 10\n 342: bipush 10\n 344: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 347: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 350: checkcast #23 // class java/util/Collection\n 353: astore 13\n 355: iconst_0\n 356: istore 14\n 358: aload 12\n 360: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 365: astore 15\n 367: aload 15\n 369: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 374: ifeq 457\n 377: aload 15\n 379: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 384: astore 16\n 386: aload 13\n 388: aload 16\n 390: checkcast #68 // class java/util/List\n 393: astore 17\n 395: astore 18\n 397: iconst_0\n 398: istore 19\n 400: aload 17\n 402: iconst_0\n 403: invokeinterface #72, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 408: checkcast #74 // class java/lang/Number\n 411: invokevirtual #78 // Method java/lang/Number.intValue:()I\n 414: istore 20\n 416: aload 17\n 418: iconst_1\n 419: invokeinterface #72, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 424: checkcast #74 // class java/lang/Number\n 427: invokevirtual #78 // Method java/lang/Number.intValue:()I\n 430: istore 21\n 432: iload 20\n 434: invokestatic #62 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 437: iload 21\n 439: invokestatic #62 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 442: invokestatic #84 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 445: aload 18\n 447: swap\n 448: invokeinterface #66, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 453: pop\n 454: goto 367\n 457: aload 13\n 459: checkcast #68 // class java/util/List\n 462: nop\n 463: nop\n 464: aload 30\n 466: swap\n 467: invokeinterface #66, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 472: pop\n 473: goto 38\n 476: aload 4\n 478: checkcast #68 // class java/util/List\n 481: nop\n 482: areturn\n\n private static final java.util.Map<java.lang.Integer, java.util.Set<java.lang.Integer>> getPiles(java.util.List<? extends java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>>>);\n Code:\n 0: new #111 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #114 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #116 // class java/util/Map\n 10: astore_1\n 11: aload_0\n 12: checkcast #9 // class java/lang/Iterable\n 15: astore_2\n 16: iconst_0\n 17: istore_3\n 18: aload_2\n 19: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 24: astore 4\n 26: aload 4\n 28: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 33: ifeq 329\n 36: aload 4\n 38: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 43: astore 5\n 45: aload 5\n 47: checkcast #68 // class java/util/List\n 50: astore 6\n 52: iconst_0\n 53: istore 7\n 55: aload 6\n 57: checkcast #9 // class java/lang/Iterable\n 60: invokestatic #120 // Method kotlin/collections/CollectionsKt.zipWithNext:(Ljava/lang/Iterable;)Ljava/util/List;\n 63: checkcast #9 // class java/lang/Iterable\n 66: astore 8\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 78: astore 10\n 80: aload 10\n 82: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 87: ifeq 323\n 90: aload 10\n 92: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 97: astore 11\n 99: aload 11\n 101: checkcast #122 // class kotlin/Pair\n 104: astore 12\n 106: iconst_0\n 107: istore 13\n 109: aload 12\n 111: invokevirtual #125 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 114: checkcast #122 // class kotlin/Pair\n 117: astore 14\n 119: aload 12\n 121: invokevirtual #128 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 124: checkcast #122 // class kotlin/Pair\n 127: astore 15\n 129: aload 14\n 131: aload 15\n 133: invokestatic #134 // Method UtilsKt.compareTo:(Lkotlin/Pair;Lkotlin/Pair;)I\n 136: ifge 149\n 139: aload 14\n 141: aload 15\n 143: invokestatic #84 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 146: goto 156\n 149: aload 15\n 151: aload 14\n 153: invokestatic #84 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 156: astore 16\n 158: aload 16\n 160: invokevirtual #125 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 163: checkcast #122 // class kotlin/Pair\n 166: astore 17\n 168: aload 16\n 170: invokevirtual #128 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 173: checkcast #122 // class kotlin/Pair\n 176: astore 18\n 178: aload 18\n 180: aload 17\n 182: invokestatic #138 // Method UtilsKt.minus:(Lkotlin/Pair;Lkotlin/Pair;)Lkotlin/Pair;\n 185: astore 19\n 187: aload 19\n 189: invokevirtual #125 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 192: checkcast #74 // class java/lang/Number\n 195: invokevirtual #78 // Method java/lang/Number.intValue:()I\n 198: istore 20\n 200: aload 19\n 202: invokevirtual #128 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 205: checkcast #74 // class java/lang/Number\n 208: invokevirtual #78 // Method java/lang/Number.intValue:()I\n 211: istore 21\n 213: iconst_0\n 214: istore 22\n 216: iload 22\n 218: iload 20\n 220: if_icmpgt 318\n 223: iconst_0\n 224: istore 23\n 226: iload 23\n 228: iload 21\n 230: if_icmpgt 305\n 233: aload_1\n 234: aload 17\n 236: invokevirtual #141 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 239: checkcast #74 // class java/lang/Number\n 242: invokevirtual #78 // Method java/lang/Number.intValue:()I\n 245: iload 22\n 247: iadd\n 248: invokestatic #62 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 251: invokedynamic #160, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 256: invokedynamic #171, 0 // InvokeDynamic #1:apply:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Function;\n 261: invokeinterface #175, 3 // InterfaceMethod java/util/Map.computeIfAbsent:(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;\n 266: checkcast #177 // class java/util/Set\n 269: aload 17\n 271: invokevirtual #180 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 274: checkcast #74 // class java/lang/Number\n 277: invokevirtual #78 // Method java/lang/Number.intValue:()I\n 280: iload 23\n 282: iadd\n 283: invokestatic #62 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 286: invokeinterface #181, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 291: pop\n 292: iload 23\n 294: iload 21\n 296: if_icmpeq 305\n 299: iinc 23, 1\n 302: goto 233\n 305: iload 22\n 307: iload 20\n 309: if_icmpeq 318\n 312: iinc 22, 1\n 315: goto 223\n 318: nop\n 319: nop\n 320: goto 80\n 323: nop\n 324: nop\n 325: nop\n 326: goto 26\n 329: nop\n 330: aload_1\n 331: areturn\n\n private static final java.lang.Integer fallUnitOrNull(java.util.Set<java.lang.Integer>, int);\n Code:\n 0: aload_0\n 1: checkcast #9 // class java/lang/Iterable\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: aload_2\n 8: astore 4\n 10: new #11 // class java/util/ArrayList\n 13: dup\n 14: invokespecial #202 // Method java/util/ArrayList.\"<init>\":()V\n 17: checkcast #23 // class java/util/Collection\n 20: astore 5\n 22: iconst_0\n 23: istore 6\n 25: aload 4\n 27: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 32: astore 7\n 34: aload 7\n 36: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 41: ifeq 93\n 44: aload 7\n 46: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 51: astore 8\n 53: aload 8\n 55: checkcast #74 // class java/lang/Number\n 58: invokevirtual #78 // Method java/lang/Number.intValue:()I\n 61: istore 9\n 63: iconst_0\n 64: istore 10\n 66: iload 9\n 68: iload_1\n 69: if_icmple 76\n 72: iconst_1\n 73: goto 77\n 76: iconst_0\n 77: ifeq 34\n 80: aload 5\n 82: aload 8\n 84: invokeinterface #66, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 89: pop\n 90: goto 34\n 93: aload 5\n 95: checkcast #68 // class java/util/List\n 98: nop\n 99: checkcast #9 // class java/lang/Iterable\n 102: invokestatic #206 // Method kotlin/collections/CollectionsKt.minOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 105: checkcast #54 // class java/lang/Integer\n 108: areturn\n\n public static final void main();\n Code:\n 0: ldc #218 // String Day14_test\n 2: invokestatic #222 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #226 // Method main$part1:(Ljava/util/List;)I\n 10: bipush 24\n 12: if_icmpne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 33\n 23: new #228 // class java/lang/IllegalStateException\n 26: dup\n 27: ldc #230 // String Check failed.\n 29: invokespecial #233 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 32: athrow\n 33: aload_0\n 34: invokestatic #236 // Method main$part2:(Ljava/util/List;)I\n 37: bipush 93\n 39: if_icmpne 46\n 42: iconst_1\n 43: goto 47\n 46: iconst_0\n 47: ifne 60\n 50: new #228 // class java/lang/IllegalStateException\n 53: dup\n 54: ldc #230 // String Check failed.\n 56: invokespecial #233 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 59: athrow\n 60: ldc #238 // String Day14\n 62: invokestatic #222 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 65: astore_1\n 66: aload_1\n 67: invokestatic #226 // Method main$part1:(Ljava/util/List;)I\n 70: istore_2\n 71: getstatic #244 // Field java/lang/System.out:Ljava/io/PrintStream;\n 74: iload_2\n 75: invokevirtual #249 // Method java/io/PrintStream.println:(I)V\n 78: aload_1\n 79: invokestatic #236 // Method main$part2:(Ljava/util/List;)I\n 82: istore_2\n 83: getstatic #244 // Field java/lang/System.out:Ljava/io/PrintStream;\n 86: iload_2\n 87: invokevirtual #249 // Method java/io/PrintStream.println:(I)V\n 90: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #253 // Method main:()V\n 3: return\n\n private static final java.util.Set getPiles$lambda$6$lambda$5$lambda$3(java.lang.Integer);\n Code:\n 0: aload_0\n 1: ldc_w #256 // String it\n 4: invokestatic #262 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: new #264 // class java/util/LinkedHashSet\n 10: dup\n 11: invokespecial #265 // Method java/util/LinkedHashSet.\"<init>\":()V\n 14: checkcast #177 // class java/util/Set\n 17: areturn\n\n private static final java.util.Set getPiles$lambda$6$lambda$5$lambda$4(kotlin.jvm.functions.Function1, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokeinterface #270, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: checkcast #177 // class java/util/Set\n 10: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #275 // Method getPoints:(Ljava/util/List;)Ljava/util/List;\n 4: invokestatic #277 // Method getPiles:(Ljava/util/List;)Ljava/util/Map;\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: new #279 // class CurrentUnit\n 13: dup\n 14: iconst_0\n 15: iconst_0\n 16: iconst_3\n 17: aconst_null\n 18: invokespecial #282 // Method CurrentUnit.\"<init>\":(IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 21: astore_3\n 22: nop\n 23: aload_1\n 24: aload_3\n 25: invokevirtual #285 // Method CurrentUnit.getPile:()I\n 28: invokestatic #62 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 31: invokeinterface #287, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 36: checkcast #177 // class java/util/Set\n 39: astore 4\n 41: aload_3\n 42: aload 4\n 44: dup\n 45: ifnull 65\n 48: aload_3\n 49: invokevirtual #290 // Method CurrentUnit.getHeight:()I\n 52: invokestatic #292 // Method fallUnitOrNull:(Ljava/util/Set;I)Ljava/lang/Integer;\n 55: dup\n 56: ifnull 65\n 59: invokevirtual #293 // Method java/lang/Integer.intValue:()I\n 62: goto 68\n 65: pop\n 66: iload_2\n 67: ireturn\n 68: invokevirtual #296 // Method CurrentUnit.setHeight:(I)V\n 71: aload_3\n 72: invokevirtual #290 // Method CurrentUnit.getHeight:()I\n 75: istore 5\n 77: aload_3\n 78: iload 5\n 80: iconst_m1\n 81: iadd\n 82: invokevirtual #296 // Method CurrentUnit.setHeight:(I)V\n 85: aload_3\n 86: aload_1\n 87: invokevirtual #300 // Method CurrentUnit.diagonalMove:(Ljava/util/Map;)Z\n 90: ifne 22\n 93: aload 4\n 95: aload_3\n 96: invokevirtual #290 // Method CurrentUnit.getHeight:()I\n 99: invokestatic #62 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 102: invokeinterface #181, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 107: pop\n 108: iinc 2, 1\n 111: aload_3\n 112: invokevirtual #303 // Method CurrentUnit.reset:()Z\n 115: pop\n 116: goto 22\n\n private static final java.util.Set main$part2$lambda$9(int, java.lang.Integer);\n Code:\n 0: aload_1\n 1: ldc_w #256 // String it\n 4: invokestatic #262 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: iconst_1\n 8: anewarray #54 // class java/lang/Integer\n 11: astore_2\n 12: aload_2\n 13: iconst_0\n 14: iload_0\n 15: invokestatic #62 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 18: aastore\n 19: aload_2\n 20: invokestatic #315 // Method kotlin/collections/SetsKt.mutableSetOf:([Ljava/lang/Object;)Ljava/util/Set;\n 23: areturn\n\n private static final java.util.Set main$part2$lambda$10(kotlin.jvm.functions.Function1, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokeinterface #270, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: checkcast #177 // class java/util/Set\n 10: areturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #275 // Method getPoints:(Ljava/util/List;)Ljava/util/List;\n 4: invokestatic #277 // Method getPiles:(Ljava/util/List;)Ljava/util/Map;\n 7: astore_1\n 8: aload_1\n 9: invokeinterface #321, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 14: checkcast #9 // class java/lang/Iterable\n 17: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 22: astore 4\n 24: aload 4\n 26: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 31: ifne 42\n 34: new #323 // class java/util/NoSuchElementException\n 37: dup\n 38: invokespecial #324 // Method java/util/NoSuchElementException.\"<init>\":()V\n 41: athrow\n 42: aload 4\n 44: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 49: checkcast #177 // class java/util/Set\n 52: astore 5\n 54: iconst_0\n 55: istore 6\n 57: aload 5\n 59: checkcast #9 // class java/lang/Iterable\n 62: invokestatic #327 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 65: checkcast #74 // class java/lang/Number\n 68: invokevirtual #78 // Method java/lang/Number.intValue:()I\n 71: istore 5\n 73: aload 4\n 75: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 80: ifeq 128\n 83: aload 4\n 85: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 90: checkcast #177 // class java/util/Set\n 93: astore 6\n 95: iconst_0\n 96: istore 7\n 98: aload 6\n 100: checkcast #9 // class java/lang/Iterable\n 103: invokestatic #327 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 106: checkcast #74 // class java/lang/Number\n 109: invokevirtual #78 // Method java/lang/Number.intValue:()I\n 112: istore 6\n 114: iload 5\n 116: iload 6\n 118: if_icmpge 73\n 121: iload 6\n 123: istore 5\n 125: goto 73\n 128: iload 5\n 130: iconst_2\n 131: iadd\n 132: istore_2\n 133: iconst_0\n 134: istore_3\n 135: new #279 // class CurrentUnit\n 138: dup\n 139: iconst_0\n 140: iconst_0\n 141: iconst_3\n 142: aconst_null\n 143: invokespecial #282 // Method CurrentUnit.\"<init>\":(IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 146: astore 4\n 148: nop\n 149: aload_1\n 150: aload 4\n 152: invokevirtual #285 // Method CurrentUnit.getPile:()I\n 155: invokestatic #62 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 158: iload_2\n 159: invokedynamic #333, 0 // InvokeDynamic #2:invoke:(I)Lkotlin/jvm/functions/Function1;\n 164: invokedynamic #337, 0 // InvokeDynamic #3:apply:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Function;\n 169: invokeinterface #175, 3 // InterfaceMethod java/util/Map.computeIfAbsent:(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;\n 174: dup\n 175: ldc_w #339 // String computeIfAbsent(...)\n 178: invokestatic #342 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 181: checkcast #177 // class java/util/Set\n 184: astore 5\n 186: aload 4\n 188: aload 5\n 190: aload 4\n 192: invokevirtual #290 // Method CurrentUnit.getHeight:()I\n 195: invokestatic #292 // Method fallUnitOrNull:(Ljava/util/Set;I)Ljava/lang/Integer;\n 198: dup\n 199: ifnull 208\n 202: invokevirtual #293 // Method java/lang/Integer.intValue:()I\n 205: goto 210\n 208: pop\n 209: iload_2\n 210: invokevirtual #296 // Method CurrentUnit.setHeight:(I)V\n 213: aload 4\n 215: invokevirtual #290 // Method CurrentUnit.getHeight:()I\n 218: istore 6\n 220: aload 4\n 222: iload 6\n 224: iconst_m1\n 225: iadd\n 226: invokevirtual #296 // Method CurrentUnit.setHeight:(I)V\n 229: aload 4\n 231: invokevirtual #290 // Method CurrentUnit.getHeight:()I\n 234: iload_2\n 235: iconst_1\n 236: isub\n 237: if_icmpeq 249\n 240: aload 4\n 242: aload_1\n 243: invokevirtual #300 // Method CurrentUnit.diagonalMove:(Ljava/util/Map;)Z\n 246: ifne 148\n 249: aload 5\n 251: aload 4\n 253: invokevirtual #290 // Method CurrentUnit.getHeight:()I\n 256: invokestatic #62 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 259: invokeinterface #181, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 264: pop\n 265: iinc 3, 1\n 268: aload 4\n 270: invokevirtual #303 // Method CurrentUnit.reset:()Z\n 273: ifne 148\n 276: iload_3\n 277: ireturn\n}\n",
"javap_err": ""
}
] |
ShuffleZZZ__advent-of-code-kotlin__5a3cff1/src/Day04.kt
|
private fun rangesPairList(input: List<String>) = input.map { "(\\d+)-(\\d+),(\\d+)-(\\d+)".toRegex().find(it)!!.destructured }
.map { (l1, l2, r1, r2) -> (l1.toInt() to l2.toInt()) to (r1.toInt() to r2.toInt()) }
fun main() {
fun part1(input: List<String>) = rangesPairList(input).sumOf { (first, second) -> first.include(second).toInt() }
fun part2(input: List<String>) = rangesPairList(input).sumOf { (first, second) -> first.intersect(second).toInt() }
// 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))
}
|
[
{
"class_path": "ShuffleZZZ__advent-of-code-kotlin__5a3cff1/Day04Kt.class",
"javap": "Compiled from \"Day04.kt\"\npublic final class Day04Kt {\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>>> rangesPairList(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #9 // 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 #11 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #23 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 112\n 48: aload 6\n 50: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #39 // class java/lang/String\n 64: astore 8\n 66: astore 14\n 68: iconst_0\n 69: istore 9\n 71: new #41 // class kotlin/text/Regex\n 74: dup\n 75: ldc #43 // String (\\\\d+)-(\\\\d+),(\\\\d+)-(\\\\d+)\n 77: invokespecial #46 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 80: aload 8\n 82: checkcast #48 // class java/lang/CharSequence\n 85: iconst_0\n 86: iconst_2\n 87: aconst_null\n 88: invokestatic #52 // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;\n 91: dup\n 92: invokestatic #58 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 95: invokeinterface #64, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 100: aload 14\n 102: swap\n 103: invokeinterface #68, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 108: pop\n 109: goto 38\n 112: aload 4\n 114: checkcast #70 // class java/util/List\n 117: nop\n 118: checkcast #9 // class java/lang/Iterable\n 121: astore_1\n 122: nop\n 123: iconst_0\n 124: istore_2\n 125: aload_1\n 126: astore_3\n 127: new #11 // class java/util/ArrayList\n 130: dup\n 131: aload_1\n 132: bipush 10\n 134: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 137: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 140: checkcast #23 // class java/util/Collection\n 143: astore 4\n 145: iconst_0\n 146: istore 5\n 148: aload_3\n 149: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 154: astore 6\n 156: aload 6\n 158: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 163: ifeq 326\n 166: aload 6\n 168: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 173: astore 7\n 175: aload 4\n 177: aload 7\n 179: checkcast #72 // class kotlin/text/MatchResult$Destructured\n 182: astore 8\n 184: astore 14\n 186: iconst_0\n 187: istore 9\n 189: aload 8\n 191: invokevirtual #76 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 194: invokeinterface #80, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 199: iconst_1\n 200: invokeinterface #84, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 205: checkcast #39 // class java/lang/String\n 208: astore 10\n 210: aload 8\n 212: invokevirtual #76 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 215: invokeinterface #80, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 220: iconst_2\n 221: invokeinterface #84, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 226: checkcast #39 // class java/lang/String\n 229: astore 11\n 231: aload 8\n 233: invokevirtual #76 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 236: invokeinterface #80, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 241: iconst_3\n 242: invokeinterface #84, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 247: checkcast #39 // class java/lang/String\n 250: astore 12\n 252: aload 8\n 254: invokevirtual #76 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 257: invokeinterface #80, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 262: iconst_4\n 263: invokeinterface #84, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 268: checkcast #39 // class java/lang/String\n 271: astore 13\n 273: aload 10\n 275: invokestatic #90 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 278: invokestatic #94 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 281: aload 11\n 283: invokestatic #90 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 286: invokestatic #94 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 289: invokestatic #100 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 292: aload 12\n 294: invokestatic #90 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 297: invokestatic #94 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 300: aload 13\n 302: invokestatic #90 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 305: invokestatic #94 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 308: invokestatic #100 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 311: invokestatic #100 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 314: aload 14\n 316: swap\n 317: invokeinterface #68, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 322: pop\n 323: goto 156\n 326: aload 4\n 328: checkcast #70 // class java/util/List\n 331: nop\n 332: areturn\n\n public static final void main();\n Code:\n 0: ldc #124 // String Day04_test\n 2: invokestatic #130 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #134 // 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 #136 // class java/lang/IllegalStateException\n 25: dup\n 26: ldc #138 // String Check failed.\n 28: invokespecial #139 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 31: athrow\n 32: aload_0\n 33: invokestatic #142 // 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 #136 // class java/lang/IllegalStateException\n 51: dup\n 52: ldc #138 // String Check failed.\n 54: invokespecial #139 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 57: athrow\n 58: ldc #144 // String Day04\n 60: invokestatic #130 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 63: astore_1\n 64: aload_1\n 65: invokestatic #134 // Method main$part1:(Ljava/util/List;)I\n 68: istore_2\n 69: getstatic #150 // Field java/lang/System.out:Ljava/io/PrintStream;\n 72: iload_2\n 73: invokevirtual #155 // Method java/io/PrintStream.println:(I)V\n 76: aload_1\n 77: invokestatic #142 // Method main$part2:(Ljava/util/List;)I\n 80: istore_2\n 81: getstatic #150 // Field java/lang/System.out:Ljava/io/PrintStream;\n 84: iload_2\n 85: invokevirtual #155 // Method java/io/PrintStream.println:(I)V\n 88: return\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: invokestatic #164 // Method rangesPairList:(Ljava/util/List;)Ljava/util/List;\n 4: checkcast #9 // class java/lang/Iterable\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 16: astore_3\n 17: aload_3\n 18: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 23: ifeq 88\n 26: aload_3\n 27: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 32: astore 4\n 34: iload_2\n 35: aload 4\n 37: checkcast #166 // class kotlin/Pair\n 40: astore 5\n 42: istore 9\n 44: iconst_0\n 45: istore 6\n 47: aload 5\n 49: invokevirtual #169 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 52: checkcast #166 // class kotlin/Pair\n 55: astore 7\n 57: aload 5\n 59: invokevirtual #172 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 62: checkcast #166 // class kotlin/Pair\n 65: astore 8\n 67: aload 7\n 69: aload 8\n 71: invokestatic #176 // Method UtilsKt.include:(Lkotlin/Pair;Lkotlin/Pair;)Z\n 74: invokestatic #180 // Method UtilsKt.toInt:(Z)I\n 77: istore 10\n 79: iload 9\n 81: iload 10\n 83: iadd\n 84: istore_2\n 85: goto 17\n 88: iload_2\n 89: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #164 // Method rangesPairList:(Ljava/util/List;)Ljava/util/List;\n 4: checkcast #9 // class java/lang/Iterable\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 16: astore_3\n 17: aload_3\n 18: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 23: ifeq 88\n 26: aload_3\n 27: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 32: astore 4\n 34: iload_2\n 35: aload 4\n 37: checkcast #166 // class kotlin/Pair\n 40: astore 5\n 42: istore 9\n 44: iconst_0\n 45: istore 6\n 47: aload 5\n 49: invokevirtual #169 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 52: checkcast #166 // class kotlin/Pair\n 55: astore 7\n 57: aload 5\n 59: invokevirtual #172 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 62: checkcast #166 // class kotlin/Pair\n 65: astore 8\n 67: aload 7\n 69: aload 8\n 71: invokestatic #187 // Method UtilsKt.intersect:(Lkotlin/Pair;Lkotlin/Pair;)Z\n 74: invokestatic #180 // Method UtilsKt.toInt:(Z)I\n 77: istore 10\n 79: iload 9\n 81: iload 10\n 83: iadd\n 84: istore_2\n 85: goto 17\n 88: iload_2\n 89: ireturn\n}\n",
"javap_err": ""
}
] |
ShuffleZZZ__advent-of-code-kotlin__5a3cff1/src/Day05.kt
|
import java.util.*
private fun stackPeeks(input: List<List<String>>, move: (List<Stack<Char>>, Int, Int, Int) -> Unit): String {
val (towers, instructions) = input
val stacksSize = towers.last().split("\\s+".toRegex()).last().toInt()
val stacks = List(stacksSize) { Stack<Char>() }
for (i in (0 until towers.size - 1).reversed()) {
for (j in 1 until towers[i].length step 4) {
if (towers[i][j] != ' ') {
stacks[j / 4].push(towers[i][j])
}
}
}
for (instruction in instructions) {
val (amount, from, to) = "move (\\d+) from (\\d+) to (\\d+)".toRegex().find(instruction)!!.destructured
move(stacks, amount.toInt(), from.toInt(), to.toInt())
}
return stacks.map { it.peek() }.joinToString("")
}
fun main() {
fun part1(input: List<List<String>>) =
stackPeeks(input) { stacks: List<Stack<Char>>, amount: Int, from: Int, to: Int ->
repeat(amount) { stacks[to - 1].push(stacks[from - 1].pop()) }
}
fun part2(input: List<List<String>>) =
stackPeeks(input) { stacks: List<Stack<Char>>, amount: Int, from: Int, to: Int ->
stacks[to - 1].addAll(stacks[from - 1].takeLast(amount))
repeat(amount) { stacks[from - 1].pop() }
}
// test if implementation meets criteria from the description, like:
val testInput = readBlocks("Day05_test")
check(part1(testInput) == "CMZ")
check(part2(testInput) == "MCD")
val input = readBlocks("Day05")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "ShuffleZZZ__advent-of-code-kotlin__5a3cff1/Day05Kt.class",
"javap": "Compiled from \"Day05.kt\"\npublic final class Day05Kt {\n private static final java.lang.String stackPeeks(java.util.List<? extends java.util.List<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, kotlin.Unit>);\n Code:\n 0: aload_0\n 1: iconst_0\n 2: invokeinterface #13, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #9 // class java/util/List\n 10: astore_2\n 11: aload_0\n 12: iconst_1\n 13: invokeinterface #13, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 18: checkcast #9 // class java/util/List\n 21: astore_3\n 22: aload_2\n 23: invokestatic #19 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 26: checkcast #21 // class java/lang/CharSequence\n 29: astore 5\n 31: new #23 // class kotlin/text/Regex\n 34: dup\n 35: ldc #25 // String \\\\s+\n 37: invokespecial #29 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 40: astore 6\n 42: iconst_0\n 43: istore 7\n 45: aload 6\n 47: aload 5\n 49: iload 7\n 51: invokevirtual #33 // Method kotlin/text/Regex.split:(Ljava/lang/CharSequence;I)Ljava/util/List;\n 54: invokestatic #19 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 57: checkcast #35 // class java/lang/String\n 60: invokestatic #41 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 63: istore 4\n 65: new #43 // class java/util/ArrayList\n 68: dup\n 69: iload 4\n 71: invokespecial #46 // Method java/util/ArrayList.\"<init>\":(I)V\n 74: astore 6\n 76: iconst_0\n 77: istore 7\n 79: iload 7\n 81: iload 4\n 83: if_icmpge 121\n 86: iload 7\n 88: istore 8\n 90: aload 6\n 92: iload 8\n 94: istore 9\n 96: astore 15\n 98: iconst_0\n 99: istore 10\n 101: new #48 // class java/util/Stack\n 104: dup\n 105: invokespecial #51 // Method java/util/Stack.\"<init>\":()V\n 108: aload 15\n 110: swap\n 111: invokevirtual #55 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 114: pop\n 115: iinc 7, 1\n 118: goto 79\n 121: aload 6\n 123: checkcast #9 // class java/util/List\n 126: astore 5\n 128: iconst_0\n 129: aload_2\n 130: invokeinterface #59, 1 // InterfaceMethod java/util/List.size:()I\n 135: iconst_1\n 136: isub\n 137: invokestatic #65 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 140: checkcast #67 // class kotlin/ranges/IntProgression\n 143: invokestatic #71 // Method kotlin/ranges/RangesKt.reversed:(Lkotlin/ranges/IntProgression;)Lkotlin/ranges/IntProgression;\n 146: astore 6\n 148: aload 6\n 150: invokevirtual #74 // Method kotlin/ranges/IntProgression.getFirst:()I\n 153: istore 7\n 155: aload 6\n 157: invokevirtual #77 // Method kotlin/ranges/IntProgression.getLast:()I\n 160: istore 8\n 162: aload 6\n 164: invokevirtual #80 // Method kotlin/ranges/IntProgression.getStep:()I\n 167: istore 9\n 169: iload 9\n 171: ifle 181\n 174: iload 7\n 176: iload 8\n 178: if_icmple 193\n 181: iload 9\n 183: ifge 357\n 186: iload 8\n 188: iload 7\n 190: if_icmpgt 357\n 193: iconst_1\n 194: aload_2\n 195: iload 7\n 197: invokeinterface #13, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 202: checkcast #35 // class java/lang/String\n 205: invokevirtual #83 // Method java/lang/String.length:()I\n 208: invokestatic #65 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 211: checkcast #67 // class kotlin/ranges/IntProgression\n 214: iconst_4\n 215: invokestatic #87 // Method kotlin/ranges/RangesKt.step:(Lkotlin/ranges/IntProgression;I)Lkotlin/ranges/IntProgression;\n 218: astore 10\n 220: aload 10\n 222: invokevirtual #74 // Method kotlin/ranges/IntProgression.getFirst:()I\n 225: istore 11\n 227: aload 10\n 229: invokevirtual #77 // Method kotlin/ranges/IntProgression.getLast:()I\n 232: istore 12\n 234: aload 10\n 236: invokevirtual #80 // Method kotlin/ranges/IntProgression.getStep:()I\n 239: istore 13\n 241: iload 13\n 243: ifle 253\n 246: iload 11\n 248: iload 12\n 250: if_icmple 265\n 253: iload 13\n 255: ifge 340\n 258: iload 12\n 260: iload 11\n 262: if_icmpgt 340\n 265: aload_2\n 266: iload 7\n 268: invokeinterface #13, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 273: checkcast #35 // class java/lang/String\n 276: iload 11\n 278: invokevirtual #91 // Method java/lang/String.charAt:(I)C\n 281: bipush 32\n 283: if_icmpeq 323\n 286: aload 5\n 288: iload 11\n 290: iconst_4\n 291: idiv\n 292: invokeinterface #13, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 297: checkcast #48 // class java/util/Stack\n 300: aload_2\n 301: iload 7\n 303: invokeinterface #13, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 308: checkcast #35 // class java/lang/String\n 311: iload 11\n 313: invokevirtual #91 // Method java/lang/String.charAt:(I)C\n 316: invokestatic #97 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 319: invokevirtual #101 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 322: pop\n 323: iload 11\n 325: iload 12\n 327: if_icmpeq 340\n 330: iload 11\n 332: iload 13\n 334: iadd\n 335: istore 11\n 337: goto 265\n 340: iload 7\n 342: iload 8\n 344: if_icmpeq 357\n 347: iload 7\n 349: iload 9\n 351: iadd\n 352: istore 7\n 354: goto 193\n 357: aload_3\n 358: invokeinterface #105, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 363: astore 6\n 365: aload 6\n 367: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 372: ifeq 517\n 375: aload 6\n 377: invokeinterface #115, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 382: checkcast #35 // class java/lang/String\n 385: astore 7\n 387: new #23 // class kotlin/text/Regex\n 390: dup\n 391: ldc #117 // String move (\\\\d+) from (\\\\d+) to (\\\\d+)\n 393: invokespecial #29 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 396: aload 7\n 398: checkcast #21 // class java/lang/CharSequence\n 401: iconst_0\n 402: iconst_2\n 403: aconst_null\n 404: invokestatic #121 // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;\n 407: dup\n 408: invokestatic #127 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 411: invokeinterface #133, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 416: astore 8\n 418: aload 8\n 420: invokevirtual #139 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 423: invokeinterface #143, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 428: iconst_1\n 429: invokeinterface #13, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 434: checkcast #35 // class java/lang/String\n 437: astore 9\n 439: aload 8\n 441: invokevirtual #139 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 444: invokeinterface #143, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 449: iconst_2\n 450: invokeinterface #13, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 455: checkcast #35 // class java/lang/String\n 458: astore 10\n 460: aload 8\n 462: invokevirtual #139 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 465: invokeinterface #143, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 470: iconst_3\n 471: invokeinterface #13, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 476: checkcast #35 // class java/lang/String\n 479: astore 11\n 481: aload_1\n 482: aload 5\n 484: aload 9\n 486: invokestatic #41 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 489: invokestatic #146 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 492: aload 10\n 494: invokestatic #41 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 497: invokestatic #146 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 500: aload 11\n 502: invokestatic #41 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 505: invokestatic #146 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 508: invokeinterface #152, 5 // InterfaceMethod kotlin/jvm/functions/Function4.invoke:(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 513: pop\n 514: goto 365\n 517: aload 5\n 519: checkcast #154 // class java/lang/Iterable\n 522: astore 6\n 524: iconst_0\n 525: istore 7\n 527: aload 6\n 529: astore 8\n 531: new #43 // class java/util/ArrayList\n 534: dup\n 535: aload 6\n 537: bipush 10\n 539: invokestatic #158 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 542: invokespecial #46 // Method java/util/ArrayList.\"<init>\":(I)V\n 545: checkcast #160 // class java/util/Collection\n 548: astore 9\n 550: iconst_0\n 551: istore 10\n 553: aload 8\n 555: invokeinterface #161, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 560: astore 11\n 562: aload 11\n 564: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 569: ifeq 615\n 572: aload 11\n 574: invokeinterface #115, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 579: astore 12\n 581: aload 9\n 583: aload 12\n 585: checkcast #48 // class java/util/Stack\n 588: astore 13\n 590: astore 15\n 592: iconst_0\n 593: istore 14\n 595: aload 13\n 597: invokevirtual #164 // Method java/util/Stack.peek:()Ljava/lang/Object;\n 600: checkcast #93 // class java/lang/Character\n 603: aload 15\n 605: swap\n 606: invokeinterface #165, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 611: pop\n 612: goto 562\n 615: aload 9\n 617: checkcast #9 // class java/util/List\n 620: nop\n 621: checkcast #154 // class java/lang/Iterable\n 624: ldc #167 // String\n 626: checkcast #21 // class java/lang/CharSequence\n 629: aconst_null\n 630: aconst_null\n 631: iconst_0\n 632: aconst_null\n 633: aconst_null\n 634: bipush 62\n 636: aconst_null\n 637: invokestatic #171 // 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 640: areturn\n\n public static final void main();\n Code:\n 0: ldc #203 // String Day05_test\n 2: invokestatic #209 // Method UtilsKt.readBlocks:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #213 // Method main$part1:(Ljava/util/List;)Ljava/lang/String;\n 10: ldc #215 // String CMZ\n 12: invokestatic #219 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 15: ifne 28\n 18: new #221 // class java/lang/IllegalStateException\n 21: dup\n 22: ldc #223 // String Check failed.\n 24: invokespecial #224 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 27: athrow\n 28: aload_0\n 29: invokestatic #227 // Method main$part2:(Ljava/util/List;)Ljava/lang/String;\n 32: ldc #229 // String MCD\n 34: invokestatic #219 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 37: ifne 50\n 40: new #221 // class java/lang/IllegalStateException\n 43: dup\n 44: ldc #223 // String Check failed.\n 46: invokespecial #224 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 49: athrow\n 50: ldc #231 // String Day05\n 52: invokestatic #209 // Method UtilsKt.readBlocks:(Ljava/lang/String;)Ljava/util/List;\n 55: astore_1\n 56: aload_1\n 57: invokestatic #213 // Method main$part1:(Ljava/util/List;)Ljava/lang/String;\n 60: getstatic #237 // Field java/lang/System.out:Ljava/io/PrintStream;\n 63: swap\n 64: invokevirtual #242 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 67: aload_1\n 68: invokestatic #227 // Method main$part2:(Ljava/util/List;)Ljava/lang/String;\n 71: getstatic #237 // Field java/lang/System.out:Ljava/io/PrintStream;\n 74: swap\n 75: invokevirtual #242 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 78: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #246 // Method main:()V\n 3: return\n\n private static final kotlin.Unit main$part1$lambda$3(java.util.List, int, int, int);\n Code:\n 0: aload_0\n 1: ldc #251 // String stacks\n 3: invokestatic #255 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore 4\n 9: iload 4\n 11: iload_1\n 12: if_icmpge 59\n 15: iload 4\n 17: istore 5\n 19: iconst_0\n 20: istore 6\n 22: aload_0\n 23: iload_3\n 24: iconst_1\n 25: isub\n 26: invokeinterface #13, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 31: checkcast #48 // class java/util/Stack\n 34: aload_0\n 35: iload_2\n 36: iconst_1\n 37: isub\n 38: invokeinterface #13, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 43: checkcast #48 // class java/util/Stack\n 46: invokevirtual #258 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 49: invokevirtual #101 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 52: pop\n 53: iinc 4, 1\n 56: goto 9\n 59: getstatic #264 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 62: areturn\n\n private static final java.lang.String main$part1(java.util.List<? extends java.util.List<java.lang.String>>);\n Code:\n 0: aload_0\n 1: invokedynamic #282, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function4;\n 6: invokestatic #284 // Method stackPeeks:(Ljava/util/List;Lkotlin/jvm/functions/Function4;)Ljava/lang/String;\n 9: areturn\n\n private static final kotlin.Unit main$part2$lambda$5(java.util.List, int, int, int);\n Code:\n 0: aload_0\n 1: ldc #251 // String stacks\n 3: invokestatic #255 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iload_3\n 8: iconst_1\n 9: isub\n 10: invokeinterface #13, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 15: checkcast #48 // class java/util/Stack\n 18: aload_0\n 19: iload_2\n 20: iconst_1\n 21: isub\n 22: invokeinterface #13, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 27: checkcast #9 // class java/util/List\n 30: iload_1\n 31: invokestatic #289 // Method kotlin/collections/CollectionsKt.takeLast:(Ljava/util/List;I)Ljava/util/List;\n 34: checkcast #160 // class java/util/Collection\n 37: invokevirtual #293 // Method java/util/Stack.addAll:(Ljava/util/Collection;)Z\n 40: pop\n 41: iconst_0\n 42: istore 4\n 44: iload 4\n 46: iload_1\n 47: if_icmpge 79\n 50: iload 4\n 52: istore 5\n 54: iconst_0\n 55: istore 6\n 57: aload_0\n 58: iload_2\n 59: iconst_1\n 60: isub\n 61: invokeinterface #13, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 66: checkcast #48 // class java/util/Stack\n 69: invokevirtual #258 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 72: pop\n 73: iinc 4, 1\n 76: goto 44\n 79: getstatic #264 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 82: areturn\n\n private static final java.lang.String main$part2(java.util.List<? extends java.util.List<java.lang.String>>);\n Code:\n 0: aload_0\n 1: invokedynamic #298, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function4;\n 6: invokestatic #284 // Method stackPeeks:(Ljava/util/List;Lkotlin/jvm/functions/Function4;)Ljava/lang/String;\n 9: areturn\n}\n",
"javap_err": ""
}
] |
ShuffleZZZ__advent-of-code-kotlin__5a3cff1/src/Day15.kt
|
import kotlin.math.absoluteValue
private const val TEST_LINE = 10
private const val LINE = 2_000_000
private const val TEST_SIZE = 20
private const val SIZE = 4_000_000
private val template = "Sensor at x=(-?\\d+), y=(-?\\d+): closest beacon is at x=(-?\\d+), y=(-?\\d+)".toRegex()
private fun getCoordinates(input: List<String>) = input.map { template.matchEntire(it)!!.destructured }
.map { (x, y, bx, by) -> (x.toInt() to y.toInt()) to (bx.toInt() to by.toInt()) }
private fun MutableSet<Pair<Int, Int>>.addRange(other: Pair<Int, Int>) {
for (pair in this) {
if (pair.include(other)) {
if (other.diff() > pair.diff()) {
remove(pair)
addRange(other)
}
return
}
}
for (pair in this) {
if (pair.intersect(other)) {
remove(pair)
addRange(
pair.first.coerceAtMost(other.first)
to pair.second.coerceAtLeast(other.second)
)
return
}
}
add(other)
}
private fun Set<Pair<Int, Int>>.amount() = sumOf { it.diff() + 1 }
private fun fillLine(
coordinates: List<Pair<Pair<Int, Int>, Pair<Int, Int>>>,
line: Int,
leastX: Int = Int.MIN_VALUE,
mostX: Int = Int.MAX_VALUE,
): Set<Pair<Int, Int>> {
val xs = mutableSetOf<Pair<Int, Int>>()
for ((sensor, beacon) in coordinates) {
val beaconDistance = sensor.manhattan(beacon)
val lineDistance = (line - sensor.second).absoluteValue
val rangeWidth = beaconDistance - lineDistance
if (rangeWidth < 0) continue
xs.addRange(
(sensor.first - rangeWidth).coerceAtLeast(leastX)
to (sensor.first + rangeWidth).coerceAtMost(mostX)
)
}
return xs
}
private fun frequency(x: Int, y: Int) = 1L * SIZE * x + y
fun main() {
fun part1(input: List<String>, line: Int) = fillLine(getCoordinates(input), line).amount() - 1
fun part2(input: List<String>, size: Int): Long? {
val coordinates = getCoordinates(input)
for (line in 0..size) {
val xs = fillLine(coordinates, line, 0, size)
if (xs.amount() != size + 1) {
if (xs.size == 2) {
assert(xs.first().second + 1 == xs.last().first - 1)
return frequency(xs.first().second + 1, line)
}
assert(xs.size == 1)
return frequency(if (xs.first().first == 0) size else 0, line)
}
}
return null
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day15_test")
check(part1(testInput, TEST_LINE) == 26)
check(part2(testInput, TEST_SIZE) == 56_000_011L)
val input = readInput("Day15")
println(part1(input, LINE))
println(part2(input, SIZE))
}
|
[
{
"class_path": "ShuffleZZZ__advent-of-code-kotlin__5a3cff1/Day15Kt.class",
"javap": "Compiled from \"Day15.kt\"\npublic final class Day15Kt {\n private static final int TEST_LINE;\n\n private static final int LINE;\n\n private static final int TEST_SIZE;\n\n private static final int SIZE;\n\n private static final kotlin.text.Regex template;\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>>> getCoordinates(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #9 // 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 #11 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #23 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 103\n 48: aload 6\n 50: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #39 // class java/lang/String\n 64: astore 8\n 66: astore 14\n 68: iconst_0\n 69: istore 9\n 71: getstatic #43 // Field template:Lkotlin/text/Regex;\n 74: aload 8\n 76: checkcast #45 // class java/lang/CharSequence\n 79: invokevirtual #51 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;\n 82: dup\n 83: invokestatic #57 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 86: invokeinterface #63, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 91: aload 14\n 93: swap\n 94: invokeinterface #67, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 99: pop\n 100: goto 38\n 103: aload 4\n 105: checkcast #69 // class java/util/List\n 108: nop\n 109: checkcast #9 // class java/lang/Iterable\n 112: astore_1\n 113: nop\n 114: iconst_0\n 115: istore_2\n 116: aload_1\n 117: astore_3\n 118: new #11 // class java/util/ArrayList\n 121: dup\n 122: aload_1\n 123: bipush 10\n 125: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 128: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 131: checkcast #23 // class java/util/Collection\n 134: astore 4\n 136: iconst_0\n 137: istore 5\n 139: aload_3\n 140: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 145: astore 6\n 147: aload 6\n 149: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 154: ifeq 317\n 157: aload 6\n 159: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 164: astore 7\n 166: aload 4\n 168: aload 7\n 170: checkcast #71 // class kotlin/text/MatchResult$Destructured\n 173: astore 8\n 175: astore 14\n 177: iconst_0\n 178: istore 9\n 180: aload 8\n 182: invokevirtual #75 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 185: invokeinterface #79, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 190: iconst_1\n 191: invokeinterface #83, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 196: checkcast #39 // class java/lang/String\n 199: astore 10\n 201: aload 8\n 203: invokevirtual #75 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 206: invokeinterface #79, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 211: iconst_2\n 212: invokeinterface #83, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 217: checkcast #39 // class java/lang/String\n 220: astore 11\n 222: aload 8\n 224: invokevirtual #75 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 227: invokeinterface #79, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 232: iconst_3\n 233: invokeinterface #83, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 238: checkcast #39 // class java/lang/String\n 241: astore 12\n 243: aload 8\n 245: invokevirtual #75 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 248: invokeinterface #79, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 253: iconst_4\n 254: invokeinterface #83, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 259: checkcast #39 // class java/lang/String\n 262: astore 13\n 264: aload 10\n 266: invokestatic #89 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 269: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 272: aload 11\n 274: invokestatic #89 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 277: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 280: invokestatic #99 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 283: aload 12\n 285: invokestatic #89 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 288: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 291: aload 13\n 293: invokestatic #89 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 296: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 299: invokestatic #99 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 302: invokestatic #99 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 305: aload 14\n 307: swap\n 308: invokeinterface #67, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 313: pop\n 314: goto 147\n 317: aload 4\n 319: checkcast #69 // class java/util/List\n 322: nop\n 323: areturn\n\n private static final void addRange(java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: invokeinterface #125, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 6: astore_2\n 7: aload_2\n 8: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 13: ifeq 59\n 16: aload_2\n 17: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 22: checkcast #127 // class kotlin/Pair\n 25: astore_3\n 26: aload_3\n 27: aload_1\n 28: invokestatic #133 // Method UtilsKt.include:(Lkotlin/Pair;Lkotlin/Pair;)Z\n 31: ifeq 7\n 34: aload_1\n 35: invokestatic #137 // Method UtilsKt.diff:(Lkotlin/Pair;)I\n 38: aload_3\n 39: invokestatic #137 // Method UtilsKt.diff:(Lkotlin/Pair;)I\n 42: if_icmple 58\n 45: aload_0\n 46: aload_3\n 47: invokeinterface #140, 2 // InterfaceMethod java/util/Set.remove:(Ljava/lang/Object;)Z\n 52: pop\n 53: aload_0\n 54: aload_1\n 55: invokestatic #142 // Method addRange:(Ljava/util/Set;Lkotlin/Pair;)V\n 58: return\n 59: aload_0\n 60: invokeinterface #125, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 65: astore_2\n 66: aload_2\n 67: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 72: ifeq 161\n 75: aload_2\n 76: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 81: checkcast #127 // class kotlin/Pair\n 84: astore_3\n 85: aload_3\n 86: aload_1\n 87: invokestatic #145 // Method UtilsKt.intersect:(Lkotlin/Pair;Lkotlin/Pair;)Z\n 90: ifeq 66\n 93: aload_0\n 94: aload_3\n 95: invokeinterface #140, 2 // InterfaceMethod java/util/Set.remove:(Ljava/lang/Object;)Z\n 100: pop\n 101: aload_0\n 102: aload_3\n 103: invokevirtual #148 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 106: checkcast #150 // class java/lang/Number\n 109: invokevirtual #154 // Method java/lang/Number.intValue:()I\n 112: aload_1\n 113: invokevirtual #148 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 116: checkcast #150 // class java/lang/Number\n 119: invokevirtual #154 // Method java/lang/Number.intValue:()I\n 122: invokestatic #160 // Method kotlin/ranges/RangesKt.coerceAtMost:(II)I\n 125: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 128: aload_3\n 129: invokevirtual #163 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 132: checkcast #150 // class java/lang/Number\n 135: invokevirtual #154 // Method java/lang/Number.intValue:()I\n 138: aload_1\n 139: invokevirtual #163 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 142: checkcast #150 // class java/lang/Number\n 145: invokevirtual #154 // Method java/lang/Number.intValue:()I\n 148: invokestatic #166 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 151: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 154: invokestatic #99 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 157: invokestatic #142 // Method addRange:(Ljava/util/Set;Lkotlin/Pair;)V\n 160: return\n 161: aload_0\n 162: aload_1\n 163: invokeinterface #167, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 168: pop\n 169: return\n\n private static final int amount(java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: checkcast #9 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore_3\n 14: aload_3\n 15: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 20: ifeq 62\n 23: aload_3\n 24: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 29: astore 4\n 31: iload_2\n 32: aload 4\n 34: checkcast #127 // class kotlin/Pair\n 37: astore 5\n 39: istore 7\n 41: iconst_0\n 42: istore 6\n 44: aload 5\n 46: invokestatic #137 // Method UtilsKt.diff:(Lkotlin/Pair;)I\n 49: iconst_1\n 50: iadd\n 51: istore 8\n 53: iload 7\n 55: iload 8\n 57: iadd\n 58: istore_2\n 59: goto 14\n 62: iload_2\n 63: ireturn\n\n private static final java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>> fillLine(java.util.List<kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>>, int, int, int);\n Code:\n 0: new #182 // class java/util/LinkedHashSet\n 3: dup\n 4: invokespecial #185 // Method java/util/LinkedHashSet.\"<init>\":()V\n 7: checkcast #124 // class java/util/Set\n 10: astore 4\n 12: aload_0\n 13: invokeinterface #186, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 18: astore 5\n 20: aload 5\n 22: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 27: ifeq 154\n 30: aload 5\n 32: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 37: checkcast #127 // class kotlin/Pair\n 40: astore 6\n 42: aload 6\n 44: invokevirtual #189 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 47: checkcast #127 // class kotlin/Pair\n 50: astore 7\n 52: aload 6\n 54: invokevirtual #192 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 57: checkcast #127 // class kotlin/Pair\n 60: astore 8\n 62: aload 7\n 64: aload 8\n 66: invokestatic #196 // Method UtilsKt.manhattan:(Lkotlin/Pair;Lkotlin/Pair;)I\n 69: istore 9\n 71: iload_1\n 72: aload 7\n 74: invokevirtual #163 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 77: checkcast #150 // class java/lang/Number\n 80: invokevirtual #154 // Method java/lang/Number.intValue:()I\n 83: isub\n 84: invokestatic #202 // Method java/lang/Math.abs:(I)I\n 87: istore 10\n 89: iload 9\n 91: iload 10\n 93: isub\n 94: istore 11\n 96: iload 11\n 98: iflt 20\n 101: aload 4\n 103: aload 7\n 105: invokevirtual #148 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 108: checkcast #150 // class java/lang/Number\n 111: invokevirtual #154 // Method java/lang/Number.intValue:()I\n 114: iload 11\n 116: isub\n 117: iload_2\n 118: invokestatic #166 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 121: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 124: aload 7\n 126: invokevirtual #148 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 129: checkcast #150 // class java/lang/Number\n 132: invokevirtual #154 // Method java/lang/Number.intValue:()I\n 135: iload 11\n 137: iadd\n 138: iload_3\n 139: invokestatic #160 // Method kotlin/ranges/RangesKt.coerceAtMost:(II)I\n 142: invokestatic #93 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 145: invokestatic #99 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 148: invokestatic #142 // Method addRange:(Ljava/util/Set;Lkotlin/Pair;)V\n 151: goto 20\n 154: aload 4\n 156: areturn\n\n static java.util.Set fillLine$default(java.util.List, int, int, int, int, java.lang.Object);\n Code:\n 0: iload 4\n 2: iconst_4\n 3: iand\n 4: ifeq 10\n 7: ldc #215 // int -2147483648\n 9: istore_2\n 10: iload 4\n 12: bipush 8\n 14: iand\n 15: ifeq 21\n 18: ldc #216 // int 2147483647\n 20: istore_3\n 21: aload_0\n 22: iload_1\n 23: iload_2\n 24: iload_3\n 25: invokestatic #218 // Method fillLine:(Ljava/util/List;III)Ljava/util/Set;\n 28: areturn\n\n private static final long frequency(int, int);\n Code:\n 0: ldc2_w #221 // long 4000000l\n 3: iload_0\n 4: i2l\n 5: lmul\n 6: iload_1\n 7: i2l\n 8: ladd\n 9: lreturn\n\n public static final void main();\n Code:\n 0: ldc #225 // String Day15_test\n 2: invokestatic #229 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: bipush 10\n 9: invokestatic #233 // 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 #235 // class java/lang/IllegalStateException\n 28: dup\n 29: ldc #237 // String Check failed.\n 31: invokespecial #240 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 34: athrow\n 35: aload_0\n 36: bipush 20\n 38: invokestatic #244 // Method main$part2:(Ljava/util/List;I)Ljava/lang/Long;\n 41: ldc2_w #245 // long 56000011l\n 44: lstore_1\n 45: dup\n 46: ifnonnull 53\n 49: pop\n 50: goto 65\n 53: invokevirtual #252 // Method java/lang/Long.longValue:()J\n 56: lload_1\n 57: lcmp\n 58: ifne 65\n 61: iconst_1\n 62: goto 66\n 65: iconst_0\n 66: ifne 79\n 69: new #235 // class java/lang/IllegalStateException\n 72: dup\n 73: ldc #237 // String Check failed.\n 75: invokespecial #240 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 78: athrow\n 79: ldc #254 // String Day15\n 81: invokestatic #229 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 84: astore_1\n 85: aload_1\n 86: ldc #255 // int 2000000\n 88: invokestatic #233 // Method main$part1:(Ljava/util/List;I)I\n 91: istore_2\n 92: getstatic #261 // Field java/lang/System.out:Ljava/io/PrintStream;\n 95: iload_2\n 96: invokevirtual #266 // Method java/io/PrintStream.println:(I)V\n 99: aload_1\n 100: ldc_w #267 // int 4000000\n 103: invokestatic #244 // Method main$part2:(Ljava/util/List;I)Ljava/lang/Long;\n 106: getstatic #261 // Field java/lang/System.out:Ljava/io/PrintStream;\n 109: swap\n 110: invokevirtual #269 // 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 #273 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.String>, int);\n Code:\n 0: aload_0\n 1: invokestatic #278 // Method getCoordinates:(Ljava/util/List;)Ljava/util/List;\n 4: iload_1\n 5: iconst_0\n 6: iconst_0\n 7: bipush 12\n 9: aconst_null\n 10: invokestatic #280 // Method fillLine$default:(Ljava/util/List;IIIILjava/lang/Object;)Ljava/util/Set;\n 13: invokestatic #282 // Method amount:(Ljava/util/Set;)I\n 16: iconst_1\n 17: isub\n 18: ireturn\n\n private static final java.lang.Long main$part2(java.util.List<java.lang.String>, int);\n Code:\n 0: aload_0\n 1: invokestatic #278 // Method getCoordinates:(Ljava/util/List;)Ljava/util/List;\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: iload_3\n 8: iload_1\n 9: if_icmpgt 244\n 12: aload_2\n 13: iload_3\n 14: iconst_0\n 15: iload_1\n 16: invokestatic #218 // Method fillLine:(Ljava/util/List;III)Ljava/util/Set;\n 19: astore 4\n 21: aload 4\n 23: invokestatic #282 // Method amount:(Ljava/util/Set;)I\n 26: iload_1\n 27: iconst_1\n 28: iadd\n 29: if_icmpeq 233\n 32: aload 4\n 34: invokeinterface #286, 1 // InterfaceMethod java/util/Set.size:()I\n 39: iconst_2\n 40: if_icmpne 153\n 43: aload 4\n 45: checkcast #9 // class java/lang/Iterable\n 48: invokestatic #290 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 51: checkcast #127 // class kotlin/Pair\n 54: invokevirtual #163 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 57: checkcast #150 // class java/lang/Number\n 60: invokevirtual #154 // Method java/lang/Number.intValue:()I\n 63: iconst_1\n 64: iadd\n 65: aload 4\n 67: checkcast #9 // class java/lang/Iterable\n 70: invokestatic #293 // Method kotlin/collections/CollectionsKt.last:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 73: checkcast #127 // class kotlin/Pair\n 76: invokevirtual #148 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 79: checkcast #150 // class java/lang/Number\n 82: invokevirtual #154 // Method java/lang/Number.intValue:()I\n 85: iconst_1\n 86: isub\n 87: if_icmpne 94\n 90: iconst_1\n 91: goto 95\n 94: iconst_0\n 95: istore 5\n 97: getstatic #299 // Field kotlin/_Assertions.ENABLED:Z\n 100: ifeq 123\n 103: iload 5\n 105: ifne 123\n 108: ldc_w #301 // String Assertion failed\n 111: astore 6\n 113: new #303 // class java/lang/AssertionError\n 116: dup\n 117: aload 6\n 119: invokespecial #305 // Method java/lang/AssertionError.\"<init>\":(Ljava/lang/Object;)V\n 122: athrow\n 123: aload 4\n 125: checkcast #9 // class java/lang/Iterable\n 128: invokestatic #290 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 131: checkcast #127 // class kotlin/Pair\n 134: invokevirtual #163 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 137: checkcast #150 // class java/lang/Number\n 140: invokevirtual #154 // Method java/lang/Number.intValue:()I\n 143: iconst_1\n 144: iadd\n 145: iload_3\n 146: invokestatic #307 // Method frequency:(II)J\n 149: invokestatic #310 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 152: areturn\n 153: aload 4\n 155: invokeinterface #286, 1 // InterfaceMethod java/util/Set.size:()I\n 160: iconst_1\n 161: if_icmpne 168\n 164: iconst_1\n 165: goto 169\n 168: iconst_0\n 169: istore 5\n 171: getstatic #299 // Field kotlin/_Assertions.ENABLED:Z\n 174: ifeq 197\n 177: iload 5\n 179: ifne 197\n 182: ldc_w #301 // String Assertion failed\n 185: astore 6\n 187: new #303 // class java/lang/AssertionError\n 190: dup\n 191: aload 6\n 193: invokespecial #305 // Method java/lang/AssertionError.\"<init>\":(Ljava/lang/Object;)V\n 196: athrow\n 197: aload 4\n 199: checkcast #9 // class java/lang/Iterable\n 202: invokestatic #290 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 205: checkcast #127 // class kotlin/Pair\n 208: invokevirtual #148 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 211: checkcast #150 // class java/lang/Number\n 214: invokevirtual #154 // Method java/lang/Number.intValue:()I\n 217: ifne 224\n 220: iload_1\n 221: goto 225\n 224: iconst_0\n 225: iload_3\n 226: invokestatic #307 // Method frequency:(II)J\n 229: invokestatic #310 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 232: areturn\n 233: iload_3\n 234: iload_1\n 235: if_icmpeq 244\n 238: iinc 3, 1\n 241: goto 12\n 244: aconst_null\n 245: areturn\n\n static {};\n Code:\n 0: new #47 // class kotlin/text/Regex\n 3: dup\n 4: ldc_w #313 // String Sensor at x=(-?\\\\d+), y=(-?\\\\d+): closest beacon is at x=(-?\\\\d+), y=(-?\\\\d+)\n 7: invokespecial #314 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 10: putstatic #43 // Field template:Lkotlin/text/Regex;\n 13: return\n}\n",
"javap_err": ""
}
] |
ShuffleZZZ__advent-of-code-kotlin__5a3cff1/src/Day07.kt
|
private const val MAX_DIR_SIZE = 100_000
private const val DISK_SPACE = 70_000_000
private const val UPDATE_SIZE = 30_000_000
private data class FS(
val name: String,
val parent: FS?, // null for root dir only.
) {
val files: MutableList<Int> = mutableListOf()
val folders: MutableList<FS> = mutableListOf()
var size: Int = 0
get() {
if (field == 0) field = files.sum() + folders.sumOf { it.size }
return field
}
fun fill(instructions: List<String>): FS {
var curDir = this
for (instruction in instructions) {
when {
instruction.startsWith("cd ") -> curDir = curDir.handleCd(instruction)
instruction.startsWith("ls ") -> curDir.handleLs(instruction)
else -> error("Incorrect input")
}
}
return this
}
private fun handleCd(instruction: String): FS {
val dir = instruction.split(" ").last()
if (dir == "/") return this
return if (dir == "..") this.parent!! else this.cd(dir)
}
private fun cd(name: String) = this.folders.first { it.name == name } // presuming absolute paths unique.
private fun handleLs(instruction: String): FS {
val content = instruction.split(" ").drop(1).chunked(2).map { it.first() to it.last() }
for ((first, second) in content) {
when {
first == "dir" -> this.folders.add(FS(second, this))
first.toIntOrNull() != null -> this.files.add(first.toInt()) // presuming file names unique.
else -> error("Incorrect input")
}
}
return this
}
fun <T> map(f: (FS) -> T): List<T> {
val res = mutableListOf(f(this))
res.addAll(folders.flatMap { it.map(f) })
return res
}
fun print(indent: Int = 0) {
repeat(indent) { print(" - ") }
println(this)
folders.map { it.print(indent + 1) }
}
override fun toString() = "FS($name, $files, $size)"
}
fun getInstructions(input: List<String>) = input.joinToString(" ").split("$ ").drop(1).map(String::trim)
fun main() {
fun part1(input: List<String>) =
FS("/", null).fill(getInstructions(input)).map { it.size }.filter { it <= MAX_DIR_SIZE }.sum()
fun part2(input: List<String>): Int {
val root = FS("/", null)
root.fill(getInstructions(input))
val sizes = root.map { it.size }
val required = UPDATE_SIZE - (DISK_SPACE - sizes.first())
return sizes.filter { it >= required }.min()
}
// test if implementation meets criteria from the description, like:
val testInput = readBlocks("Day07_test").first()
check(part1(testInput) == 95_437)
check(part2(testInput) == 24_933_642)
val input = readBlocks("Day07").first()
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "ShuffleZZZ__advent-of-code-kotlin__5a3cff1/Day07Kt.class",
"javap": "Compiled from \"Day07.kt\"\npublic final class Day07Kt {\n private static final int MAX_DIR_SIZE;\n\n private static final int DISK_SPACE;\n\n private static final int UPDATE_SIZE;\n\n public static final java.util.List<java.lang.String> getInstructions(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #18 // class java/lang/Iterable\n 10: ldc #20 // String\n 12: checkcast #22 // class java/lang/CharSequence\n 15: aconst_null\n 16: aconst_null\n 17: iconst_0\n 18: aconst_null\n 19: aconst_null\n 20: bipush 62\n 22: aconst_null\n 23: invokestatic #28 // 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 26: checkcast #22 // class java/lang/CharSequence\n 29: iconst_1\n 30: anewarray #30 // class java/lang/String\n 33: astore_1\n 34: aload_1\n 35: iconst_0\n 36: ldc #32 // String $\n 38: aastore\n 39: aload_1\n 40: iconst_0\n 41: iconst_0\n 42: bipush 6\n 44: aconst_null\n 45: invokestatic #38 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 48: checkcast #18 // class java/lang/Iterable\n 51: iconst_1\n 52: invokestatic #42 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 55: checkcast #18 // class java/lang/Iterable\n 58: astore_1\n 59: iconst_0\n 60: istore_2\n 61: aload_1\n 62: astore_3\n 63: new #44 // class java/util/ArrayList\n 66: dup\n 67: aload_1\n 68: bipush 10\n 70: invokestatic #48 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 73: invokespecial #52 // Method java/util/ArrayList.\"<init>\":(I)V\n 76: checkcast #54 // class java/util/Collection\n 79: astore 4\n 81: iconst_0\n 82: istore 5\n 84: aload_3\n 85: invokeinterface #58, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 90: astore 6\n 92: aload 6\n 94: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 99: ifeq 149\n 102: aload 6\n 104: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 109: astore 7\n 111: aload 4\n 113: aload 7\n 115: checkcast #30 // class java/lang/String\n 118: astore 8\n 120: astore 10\n 122: iconst_0\n 123: istore 9\n 125: aload 8\n 127: checkcast #22 // class java/lang/CharSequence\n 130: invokestatic #72 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 133: invokevirtual #76 // Method java/lang/Object.toString:()Ljava/lang/String;\n 136: nop\n 137: aload 10\n 139: swap\n 140: invokeinterface #80, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 145: pop\n 146: goto 92\n 149: aload 4\n 151: checkcast #82 // class java/util/List\n 154: nop\n 155: areturn\n\n public static final void main();\n Code:\n 0: ldc #100 // String Day07_test\n 2: invokestatic #106 // Method UtilsKt.readBlocks:(Ljava/lang/String;)Ljava/util/List;\n 5: invokestatic #110 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 8: checkcast #82 // class java/util/List\n 11: astore_0\n 12: aload_0\n 13: invokestatic #114 // Method main$part1:(Ljava/util/List;)I\n 16: ldc #115 // int 95437\n 18: if_icmpne 25\n 21: iconst_1\n 22: goto 26\n 25: iconst_0\n 26: ifne 39\n 29: new #117 // class java/lang/IllegalStateException\n 32: dup\n 33: ldc #119 // String Check failed.\n 35: invokespecial #122 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 38: athrow\n 39: aload_0\n 40: invokestatic #125 // Method main$part2:(Ljava/util/List;)I\n 43: ldc #126 // int 24933642\n 45: if_icmpne 52\n 48: iconst_1\n 49: goto 53\n 52: iconst_0\n 53: ifne 66\n 56: new #117 // class java/lang/IllegalStateException\n 59: dup\n 60: ldc #119 // String Check failed.\n 62: invokespecial #122 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 65: athrow\n 66: ldc #128 // String Day07\n 68: invokestatic #106 // Method UtilsKt.readBlocks:(Ljava/lang/String;)Ljava/util/List;\n 71: invokestatic #110 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 74: checkcast #82 // class java/util/List\n 77: astore_1\n 78: aload_1\n 79: invokestatic #114 // Method main$part1:(Ljava/util/List;)I\n 82: istore_2\n 83: getstatic #134 // Field java/lang/System.out:Ljava/io/PrintStream;\n 86: iload_2\n 87: invokevirtual #139 // Method java/io/PrintStream.println:(I)V\n 90: aload_1\n 91: invokestatic #125 // Method main$part2:(Ljava/util/List;)I\n 94: istore_2\n 95: getstatic #134 // Field java/lang/System.out:Ljava/io/PrintStream;\n 98: iload_2\n 99: invokevirtual #139 // Method java/io/PrintStream.println:(I)V\n 102: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #143 // Method main:()V\n 3: return\n\n private static final int main$part1$lambda$0(FS);\n Code:\n 0: aload_0\n 1: ldc #149 // String it\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokevirtual #155 // Method FS.getSize:()I\n 10: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: new #151 // class FS\n 3: dup\n 4: ldc #159 // String /\n 6: aconst_null\n 7: invokespecial #162 // Method FS.\"<init>\":(Ljava/lang/String;LFS;)V\n 10: aload_0\n 11: invokestatic #164 // Method getInstructions:(Ljava/util/List;)Ljava/util/List;\n 14: invokevirtual #168 // Method FS.fill:(Ljava/util/List;)LFS;\n 17: invokedynamic #186, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 22: invokevirtual #190 // Method FS.map:(Lkotlin/jvm/functions/Function1;)Ljava/util/List;\n 25: checkcast #18 // class java/lang/Iterable\n 28: astore_1\n 29: iconst_0\n 30: istore_2\n 31: aload_1\n 32: astore_3\n 33: new #44 // class java/util/ArrayList\n 36: dup\n 37: invokespecial #192 // Method java/util/ArrayList.\"<init>\":()V\n 40: checkcast #54 // class java/util/Collection\n 43: astore 4\n 45: iconst_0\n 46: istore 5\n 48: aload_3\n 49: invokeinterface #58, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 54: astore 6\n 56: aload 6\n 58: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 63: ifeq 116\n 66: aload 6\n 68: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 73: astore 7\n 75: aload 7\n 77: checkcast #194 // class java/lang/Number\n 80: invokevirtual #197 // Method java/lang/Number.intValue:()I\n 83: istore 8\n 85: iconst_0\n 86: istore 9\n 88: iload 8\n 90: ldc #198 // int 100000\n 92: if_icmpgt 99\n 95: iconst_1\n 96: goto 100\n 99: iconst_0\n 100: ifeq 56\n 103: aload 4\n 105: aload 7\n 107: invokeinterface #80, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 112: pop\n 113: goto 56\n 116: aload 4\n 118: checkcast #82 // class java/util/List\n 121: nop\n 122: checkcast #18 // class java/lang/Iterable\n 125: invokestatic #202 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 128: ireturn\n\n private static final int main$part2$lambda$2(FS);\n Code:\n 0: aload_0\n 1: ldc #149 // String it\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokevirtual #155 // Method FS.getSize:()I\n 10: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: new #151 // class FS\n 3: dup\n 4: ldc #159 // String /\n 6: aconst_null\n 7: invokespecial #162 // Method FS.\"<init>\":(Ljava/lang/String;LFS;)V\n 10: astore_1\n 11: aload_1\n 12: aload_0\n 13: invokestatic #164 // Method getInstructions:(Ljava/util/List;)Ljava/util/List;\n 16: invokevirtual #168 // Method FS.fill:(Ljava/util/List;)LFS;\n 19: pop\n 20: aload_1\n 21: invokedynamic #213, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 26: invokevirtual #190 // Method FS.map:(Lkotlin/jvm/functions/Function1;)Ljava/util/List;\n 29: astore_2\n 30: ldc #214 // int 30000000\n 32: ldc #215 // int 70000000\n 34: aload_2\n 35: invokestatic #110 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 38: checkcast #194 // class java/lang/Number\n 41: invokevirtual #197 // Method java/lang/Number.intValue:()I\n 44: isub\n 45: isub\n 46: istore_3\n 47: aload_2\n 48: checkcast #18 // class java/lang/Iterable\n 51: astore 4\n 53: iconst_0\n 54: istore 5\n 56: aload 4\n 58: astore 6\n 60: new #44 // class java/util/ArrayList\n 63: dup\n 64: invokespecial #192 // Method java/util/ArrayList.\"<init>\":()V\n 67: checkcast #54 // class java/util/Collection\n 70: astore 7\n 72: iconst_0\n 73: istore 8\n 75: aload 6\n 77: invokeinterface #58, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 82: astore 9\n 84: aload 9\n 86: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 91: ifeq 143\n 94: aload 9\n 96: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 101: astore 10\n 103: aload 10\n 105: checkcast #194 // class java/lang/Number\n 108: invokevirtual #197 // Method java/lang/Number.intValue:()I\n 111: istore 11\n 113: iconst_0\n 114: istore 12\n 116: iload 11\n 118: iload_3\n 119: if_icmplt 126\n 122: iconst_1\n 123: goto 127\n 126: iconst_0\n 127: ifeq 84\n 130: aload 7\n 132: aload 10\n 134: invokeinterface #80, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 139: pop\n 140: goto 84\n 143: aload 7\n 145: checkcast #82 // class java/util/List\n 148: nop\n 149: checkcast #18 // class java/lang/Iterable\n 152: invokestatic #219 // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 155: checkcast #194 // class java/lang/Number\n 158: invokevirtual #197 // Method java/lang/Number.intValue:()I\n 161: ireturn\n}\n",
"javap_err": ""
}
] |
ShuffleZZZ__advent-of-code-kotlin__5a3cff1/src/Day13.kt
|
private val DIVIDER_PACKETS = listOf("[[2]]", "[[6]]")
private sealed interface Signal : Comparable<Signal?> {
override operator fun compareTo(signal: Signal?): Int
}
private data class SingleSignal(val element: Int) : Signal {
fun toMultiSignal() = MultiSignal(listOf(this))
override fun compareTo(signal: Signal?) = when (signal) {
null -> 1
is SingleSignal -> element.compareTo(signal.element)
is MultiSignal -> toMultiSignal().compareTo(signal)
}
}
private data class MultiSignal(val items: List<Signal>) : Signal {
override fun compareTo(signal: Signal?): Int = when (signal) {
null -> 1
is SingleSignal -> compareTo(signal.toMultiSignal())
is MultiSignal -> items.mapIndexed { i, e -> e.compareTo(signal.items.getOrNull(i)) }.firstOrNull { it != 0 }
?: items.size.compareTo(signal.items.size)
}
}
private fun parseSignal(input: String): Signal {
val res = mutableListOf<Signal>()
var values = input.substring(1, input.length - 1)
while (values.contains(',')) {
val number = values.substringBefore(',').toIntOrNull()
res += if (number != null) {
SingleSignal(number)
} else {
val list = values.firstInnerList()
parseSignal(list).also { values = values.substringAfter(list) }
}
values = values.substringAfter(',')
}
if (values.contains('[')) {
res += parseSignal(values)
} else if (values.isNotEmpty()) {
res += SingleSignal(values.toInt())
}
return MultiSignal(res)
}
private fun String.firstInnerList(): String {
var balance = 0
for (i in indices) {
when (get(i)) {
'[' -> balance++
']' -> balance--
}
if (balance == 0) return substring(0, i + 1) // assuming given string starts with '['.
}
return this
}
fun main() {
fun part1(input: List<List<String>>) =
input.map { (first, second) -> parseSignal(first) to parseSignal(second) }.withIndex()
.filter { (_, value) -> value.first < value.second }.sumOf { (i) -> i + 1 }
fun part2(input: List<List<String>>): Int {
val signals = input.flatten().toMutableList()
signals.addAll(DIVIDER_PACKETS)
val sortedSignals = signals.map(::parseSignal).sorted()
return DIVIDER_PACKETS.map { sortedSignals.indexOf(parseSignal(it)) + 1 }.reduce(Int::times)
}
// test if implementation meets criteria from the description, like:
val testInput = readBlocks("Day13_test")
check(part1(testInput) == 13)
check(part2(testInput) == 140)
val input = readBlocks("Day13")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "ShuffleZZZ__advent-of-code-kotlin__5a3cff1/Day13Kt.class",
"javap": "Compiled from \"Day13.kt\"\npublic final class Day13Kt {\n private static final java.util.List<java.lang.String> DIVIDER_PACKETS;\n\n private static final Signal parseSignal(java.lang.String);\n Code:\n 0: new #8 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #12 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #14 // class java/util/List\n 10: astore_1\n 11: aconst_null\n 12: astore_2\n 13: aload_0\n 14: iconst_1\n 15: aload_0\n 16: invokevirtual #20 // Method java/lang/String.length:()I\n 19: iconst_1\n 20: isub\n 21: invokevirtual #24 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 24: dup\n 25: ldc #26 // String substring(...)\n 27: invokestatic #32 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 30: astore_2\n 31: aload_2\n 32: checkcast #34 // class java/lang/CharSequence\n 35: bipush 44\n 37: iconst_0\n 38: iconst_2\n 39: aconst_null\n 40: invokestatic #40 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;CZILjava/lang/Object;)Z\n 43: ifeq 143\n 46: aload_2\n 47: bipush 44\n 49: aconst_null\n 50: iconst_2\n 51: aconst_null\n 52: invokestatic #44 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;CLjava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 55: invokestatic #48 // Method kotlin/text/StringsKt.toIntOrNull:(Ljava/lang/String;)Ljava/lang/Integer;\n 58: astore_3\n 59: aload_1\n 60: checkcast #50 // class java/util/Collection\n 63: astore 4\n 65: aload_3\n 66: ifnull 86\n 69: new #52 // class SingleSignal\n 72: dup\n 73: aload_3\n 74: invokevirtual #57 // Method java/lang/Integer.intValue:()I\n 77: invokespecial #60 // Method SingleSignal.\"<init>\":(I)V\n 80: checkcast #62 // class Signal\n 83: goto 118\n 86: aload_2\n 87: invokestatic #66 // Method firstInnerList:(Ljava/lang/String;)Ljava/lang/String;\n 90: astore 5\n 92: aload 5\n 94: invokestatic #68 // Method parseSignal:(Ljava/lang/String;)LSignal;\n 97: astore 6\n 99: aload 6\n 101: astore 7\n 103: iconst_0\n 104: istore 8\n 106: aload_2\n 107: aload 5\n 109: aconst_null\n 110: iconst_2\n 111: aconst_null\n 112: invokestatic #72 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 115: astore_2\n 116: aload 6\n 118: astore 5\n 120: aload 4\n 122: aload 5\n 124: invokeinterface #76, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 129: pop\n 130: aload_2\n 131: bipush 44\n 133: aconst_null\n 134: iconst_2\n 135: aconst_null\n 136: invokestatic #78 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;CLjava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 139: astore_2\n 140: goto 31\n 143: aload_2\n 144: checkcast #34 // class java/lang/CharSequence\n 147: bipush 91\n 149: iconst_0\n 150: iconst_2\n 151: aconst_null\n 152: invokestatic #40 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;CZILjava/lang/Object;)Z\n 155: ifeq 175\n 158: aload_1\n 159: checkcast #50 // class java/util/Collection\n 162: aload_2\n 163: invokestatic #68 // Method parseSignal:(Ljava/lang/String;)LSignal;\n 166: invokeinterface #76, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 171: pop\n 172: goto 216\n 175: aload_2\n 176: checkcast #34 // class java/lang/CharSequence\n 179: invokeinterface #79, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 184: ifle 191\n 187: iconst_1\n 188: goto 192\n 191: iconst_0\n 192: ifeq 216\n 195: aload_1\n 196: checkcast #50 // class java/util/Collection\n 199: new #52 // class SingleSignal\n 202: dup\n 203: aload_2\n 204: invokestatic #83 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 207: invokespecial #60 // Method SingleSignal.\"<init>\":(I)V\n 210: invokeinterface #76, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 215: pop\n 216: new #85 // class MultiSignal\n 219: dup\n 220: aload_1\n 221: invokespecial #88 // Method MultiSignal.\"<init>\":(Ljava/util/List;)V\n 224: checkcast #62 // class Signal\n 227: areturn\n\n private static final java.lang.String firstInnerList(java.lang.String);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: iconst_0\n 3: istore_2\n 4: aload_0\n 5: checkcast #34 // class java/lang/CharSequence\n 8: invokeinterface #79, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 13: istore_3\n 14: iload_2\n 15: iload_3\n 16: if_icmpge 86\n 19: aload_0\n 20: iload_2\n 21: invokevirtual #105 // Method java/lang/String.charAt:(I)C\n 24: tableswitch { // 91 to 93\n 91: 52\n 92: 61\n 93: 58\n default: 61\n }\n 52: iinc 1, 1\n 55: goto 61\n 58: iinc 1, -1\n 61: iload_1\n 62: ifne 80\n 65: aload_0\n 66: iconst_0\n 67: iload_2\n 68: iconst_1\n 69: iadd\n 70: invokevirtual #24 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 73: dup\n 74: ldc #26 // String substring(...)\n 76: invokestatic #32 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 79: areturn\n 80: iinc 2, 1\n 83: goto 14\n 86: aload_0\n 87: areturn\n\n public static final void main();\n Code:\n 0: ldc #111 // String Day13_test\n 2: invokestatic #117 // Method UtilsKt.readBlocks:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #121 // Method main$part1:(Ljava/util/List;)I\n 10: bipush 13\n 12: if_icmpne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 33\n 23: new #123 // class java/lang/IllegalStateException\n 26: dup\n 27: ldc #125 // String Check failed.\n 29: invokespecial #128 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 32: athrow\n 33: aload_0\n 34: invokestatic #131 // Method main$part2:(Ljava/util/List;)I\n 37: sipush 140\n 40: if_icmpne 47\n 43: iconst_1\n 44: goto 48\n 47: iconst_0\n 48: ifne 61\n 51: new #123 // class java/lang/IllegalStateException\n 54: dup\n 55: ldc #125 // String Check failed.\n 57: invokespecial #128 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 60: athrow\n 61: ldc #133 // String Day13\n 63: invokestatic #117 // Method UtilsKt.readBlocks:(Ljava/lang/String;)Ljava/util/List;\n 66: astore_1\n 67: aload_1\n 68: invokestatic #121 // Method main$part1:(Ljava/util/List;)I\n 71: istore_2\n 72: getstatic #139 // Field java/lang/System.out:Ljava/io/PrintStream;\n 75: iload_2\n 76: invokevirtual #144 // Method java/io/PrintStream.println:(I)V\n 79: aload_1\n 80: invokestatic #131 // Method main$part2:(Ljava/util/List;)I\n 83: istore_2\n 84: getstatic #139 // Field java/lang/System.out:Ljava/io/PrintStream;\n 87: iload_2\n 88: invokevirtual #144 // Method java/io/PrintStream.println:(I)V\n 91: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #148 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<? extends java.util.List<java.lang.String>>);\n Code:\n 0: aload_0\n 1: checkcast #153 // 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 #8 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #159 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #160 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #50 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #164, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #170, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 122\n 48: aload 6\n 50: invokeinterface #174, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #14 // class java/util/List\n 64: astore 8\n 66: astore 12\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: iconst_0\n 74: invokeinterface #178, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 79: checkcast #16 // class java/lang/String\n 82: astore 10\n 84: aload 8\n 86: iconst_1\n 87: invokeinterface #178, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 92: checkcast #16 // class java/lang/String\n 95: astore 11\n 97: aload 10\n 99: invokestatic #68 // Method parseSignal:(Ljava/lang/String;)LSignal;\n 102: aload 11\n 104: invokestatic #68 // Method parseSignal:(Ljava/lang/String;)LSignal;\n 107: invokestatic #184 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 110: aload 12\n 112: swap\n 113: invokeinterface #76, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 118: pop\n 119: goto 38\n 122: aload 4\n 124: checkcast #14 // class java/util/List\n 127: nop\n 128: checkcast #153 // class java/lang/Iterable\n 131: invokestatic #188 // Method kotlin/collections/CollectionsKt.withIndex:(Ljava/lang/Iterable;)Ljava/lang/Iterable;\n 134: astore_1\n 135: nop\n 136: iconst_0\n 137: istore_2\n 138: aload_1\n 139: astore_3\n 140: new #8 // class java/util/ArrayList\n 143: dup\n 144: invokespecial #12 // Method java/util/ArrayList.\"<init>\":()V\n 147: checkcast #50 // class java/util/Collection\n 150: astore 4\n 152: iconst_0\n 153: istore 5\n 155: aload_3\n 156: invokeinterface #164, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 161: astore 6\n 163: aload 6\n 165: invokeinterface #170, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 170: ifeq 247\n 173: aload 6\n 175: invokeinterface #174, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 180: astore 7\n 182: aload 7\n 184: checkcast #190 // class kotlin/collections/IndexedValue\n 187: astore 8\n 189: iconst_0\n 190: istore 9\n 192: aload 8\n 194: invokevirtual #193 // Method kotlin/collections/IndexedValue.component2:()Ljava/lang/Object;\n 197: checkcast #195 // class kotlin/Pair\n 200: astore 10\n 202: aload 10\n 204: invokevirtual #198 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 207: checkcast #62 // class Signal\n 210: aload 10\n 212: invokevirtual #201 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 215: checkcast #62 // class Signal\n 218: invokeinterface #205, 2 // InterfaceMethod Signal.compareTo:(LSignal;)I\n 223: ifge 230\n 226: iconst_1\n 227: goto 231\n 230: iconst_0\n 231: ifeq 163\n 234: aload 4\n 236: aload 7\n 238: invokeinterface #76, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 243: pop\n 244: goto 163\n 247: aload 4\n 249: checkcast #14 // class java/util/List\n 252: nop\n 253: checkcast #153 // class java/lang/Iterable\n 256: astore_1\n 257: iconst_0\n 258: istore_2\n 259: aload_1\n 260: invokeinterface #164, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 265: astore_3\n 266: aload_3\n 267: invokeinterface #170, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 272: ifeq 318\n 275: aload_3\n 276: invokeinterface #174, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 281: astore 4\n 283: iload_2\n 284: aload 4\n 286: checkcast #190 // class kotlin/collections/IndexedValue\n 289: astore 5\n 291: istore 12\n 293: iconst_0\n 294: istore 6\n 296: aload 5\n 298: invokevirtual #208 // Method kotlin/collections/IndexedValue.component1:()I\n 301: istore 7\n 303: iload 7\n 305: iconst_1\n 306: iadd\n 307: istore 13\n 309: iload 12\n 311: iload 13\n 313: iadd\n 314: istore_2\n 315: goto 266\n 318: iload_2\n 319: ireturn\n\n private static final int main$part2(java.util.List<? extends java.util.List<java.lang.String>>);\n Code:\n 0: aload_0\n 1: checkcast #153 // class java/lang/Iterable\n 4: invokestatic #232 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 7: checkcast #50 // class java/util/Collection\n 10: invokestatic #236 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 13: astore_1\n 14: aload_1\n 15: getstatic #239 // Field DIVIDER_PACKETS:Ljava/util/List;\n 18: checkcast #50 // class java/util/Collection\n 21: invokeinterface #243, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 26: pop\n 27: aload_1\n 28: checkcast #153 // class java/lang/Iterable\n 31: astore_3\n 32: iconst_0\n 33: istore 4\n 35: aload_3\n 36: astore 5\n 38: new #8 // class java/util/ArrayList\n 41: dup\n 42: aload_3\n 43: bipush 10\n 45: invokestatic #159 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 48: invokespecial #160 // Method java/util/ArrayList.\"<init>\":(I)V\n 51: checkcast #50 // class java/util/Collection\n 54: astore 6\n 56: iconst_0\n 57: istore 7\n 59: aload 5\n 61: invokeinterface #164, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 66: astore 8\n 68: aload 8\n 70: invokeinterface #170, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 75: ifeq 118\n 78: aload 8\n 80: invokeinterface #174, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 85: astore 9\n 87: aload 6\n 89: aload 9\n 91: checkcast #16 // class java/lang/String\n 94: astore 10\n 96: astore 12\n 98: iconst_0\n 99: istore 11\n 101: aload 10\n 103: invokestatic #68 // Method parseSignal:(Ljava/lang/String;)LSignal;\n 106: aload 12\n 108: swap\n 109: invokeinterface #76, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 114: pop\n 115: goto 68\n 118: aload 6\n 120: checkcast #14 // class java/util/List\n 123: nop\n 124: checkcast #153 // class java/lang/Iterable\n 127: invokestatic #246 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;\n 130: astore_2\n 131: getstatic #239 // Field DIVIDER_PACKETS:Ljava/util/List;\n 134: checkcast #153 // class java/lang/Iterable\n 137: astore_3\n 138: iconst_0\n 139: istore 4\n 141: aload_3\n 142: astore 5\n 144: new #8 // class java/util/ArrayList\n 147: dup\n 148: aload_3\n 149: bipush 10\n 151: invokestatic #159 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 154: invokespecial #160 // Method java/util/ArrayList.\"<init>\":(I)V\n 157: checkcast #50 // class java/util/Collection\n 160: astore 6\n 162: iconst_0\n 163: istore 7\n 165: aload 5\n 167: invokeinterface #164, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 172: astore 8\n 174: aload 8\n 176: invokeinterface #170, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 181: ifeq 235\n 184: aload 8\n 186: invokeinterface #174, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 191: astore 9\n 193: aload 6\n 195: aload 9\n 197: checkcast #16 // class java/lang/String\n 200: astore 10\n 202: astore 12\n 204: iconst_0\n 205: istore 11\n 207: aload_2\n 208: aload 10\n 210: invokestatic #68 // Method parseSignal:(Ljava/lang/String;)LSignal;\n 213: invokeinterface #250, 2 // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I\n 218: iconst_1\n 219: iadd\n 220: invokestatic #254 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 223: aload 12\n 225: swap\n 226: invokeinterface #76, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 231: pop\n 232: goto 174\n 235: aload 6\n 237: checkcast #14 // class java/util/List\n 240: nop\n 241: checkcast #153 // class java/lang/Iterable\n 244: astore_3\n 245: nop\n 246: iconst_0\n 247: istore 4\n 249: aload_3\n 250: invokeinterface #164, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 255: astore 5\n 257: aload 5\n 259: invokeinterface #170, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 264: ifne 278\n 267: new #256 // class java/lang/UnsupportedOperationException\n 270: dup\n 271: ldc_w #258 // String Empty collection can\\'t be reduced.\n 274: invokespecial #259 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 277: athrow\n 278: aload 5\n 280: invokeinterface #174, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 285: astore 6\n 287: aload 5\n 289: invokeinterface #170, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 294: ifeq 338\n 297: aload 6\n 299: aload 5\n 301: invokeinterface #174, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 306: checkcast #261 // class java/lang/Number\n 309: invokevirtual #262 // Method java/lang/Number.intValue:()I\n 312: istore 7\n 314: checkcast #261 // class java/lang/Number\n 317: invokevirtual #262 // Method java/lang/Number.intValue:()I\n 320: istore 8\n 322: iconst_0\n 323: istore 9\n 325: iload 8\n 327: iload 7\n 329: imul\n 330: invokestatic #254 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 333: astore 6\n 335: goto 287\n 338: aload 6\n 340: checkcast #261 // class java/lang/Number\n 343: invokevirtual #262 // Method java/lang/Number.intValue:()I\n 346: ireturn\n\n static {};\n Code:\n 0: iconst_2\n 1: anewarray #16 // class java/lang/String\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: ldc_w #277 // String [[2]]\n 10: aastore\n 11: aload_0\n 12: iconst_1\n 13: ldc_w #279 // String [[6]]\n 16: aastore\n 17: aload_0\n 18: invokestatic #283 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 21: putstatic #239 // Field DIVIDER_PACKETS:Ljava/util/List;\n 24: return\n}\n",
"javap_err": ""
}
] |
ShuffleZZZ__advent-of-code-kotlin__5a3cff1/src/Day03.kt
|
private fun compartments(input: List<String>) = input.map { it.trim().chunked(it.length / 2) }
private fun groups(input: List<String>) = input.windowed(3, 3)
private fun List<List<String>>.intersect() = flatMap { it.map(String::toSet).reduce(Set<Char>::intersect) }
private fun Char.toPriority() = if (isLowerCase()) this - 'a' + 1 else this - 'A' + 27
fun main() {
fun part1(input: List<String>) = compartments(input).intersect().sumOf { it.toPriority() }
fun part2(input: List<String>) = groups(input).intersect().sumOf { it.toPriority() }
// 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))
}
|
[
{
"class_path": "ShuffleZZZ__advent-of-code-kotlin__5a3cff1/Day03Kt.class",
"javap": "Compiled from \"Day03.kt\"\npublic final class Day03Kt {\n private static final java.util.List<java.util.List<java.lang.String>> compartments(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #9 // 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 #11 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #23 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 107\n 48: aload 6\n 50: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #39 // 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: checkcast #41 // class java/lang/CharSequence\n 76: invokestatic #47 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 79: invokevirtual #51 // Method java/lang/Object.toString:()Ljava/lang/String;\n 82: checkcast #41 // class java/lang/CharSequence\n 85: aload 8\n 87: invokevirtual #55 // Method java/lang/String.length:()I\n 90: iconst_2\n 91: idiv\n 92: invokestatic #59 // Method kotlin/text/StringsKt.chunked:(Ljava/lang/CharSequence;I)Ljava/util/List;\n 95: aload 10\n 97: swap\n 98: invokeinterface #63, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 103: pop\n 104: goto 38\n 107: aload 4\n 109: checkcast #65 // class java/util/List\n 112: nop\n 113: areturn\n\n private static final java.util.List<java.util.List<java.lang.String>> groups(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #9 // 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 #85 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;\n 12: areturn\n\n private static final java.util.List<java.lang.Character> intersect(java.util.List<? extends java.util.List<java.lang.String>>);\n Code:\n 0: aload_0\n 1: checkcast #9 // 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 #11 // class java/util/ArrayList\n 12: dup\n 13: invokespecial #90 // Method java/util/ArrayList.\"<init>\":()V\n 16: checkcast #23 // class java/util/Collection\n 19: astore 4\n 21: iconst_0\n 22: istore 5\n 24: aload_3\n 25: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 30: astore 6\n 32: aload 6\n 34: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 39: ifeq 278\n 42: aload 6\n 44: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 49: astore 7\n 51: aload 7\n 53: checkcast #65 // class java/util/List\n 56: astore 8\n 58: iconst_0\n 59: istore 9\n 61: aload 8\n 63: checkcast #9 // class java/lang/Iterable\n 66: astore 10\n 68: iconst_0\n 69: istore 11\n 71: aload 10\n 73: astore 12\n 75: new #11 // class java/util/ArrayList\n 78: dup\n 79: aload 10\n 81: bipush 10\n 83: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 86: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 89: checkcast #23 // class java/util/Collection\n 92: astore 13\n 94: iconst_0\n 95: istore 14\n 97: aload 12\n 99: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 104: astore 15\n 106: aload 15\n 108: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 113: ifeq 159\n 116: aload 15\n 118: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 123: astore 16\n 125: aload 13\n 127: aload 16\n 129: checkcast #39 // class java/lang/String\n 132: astore 17\n 134: astore 18\n 136: iconst_0\n 137: istore 19\n 139: aload 17\n 141: checkcast #41 // class java/lang/CharSequence\n 144: invokestatic #94 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 147: aload 18\n 149: swap\n 150: invokeinterface #63, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 155: pop\n 156: goto 106\n 159: aload 13\n 161: checkcast #65 // class java/util/List\n 164: nop\n 165: checkcast #9 // class java/lang/Iterable\n 168: astore 10\n 170: nop\n 171: iconst_0\n 172: istore 11\n 174: aload 10\n 176: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 181: astore 12\n 183: aload 12\n 185: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 190: ifne 203\n 193: new #96 // class java/lang/UnsupportedOperationException\n 196: dup\n 197: ldc #98 // String Empty collection can\\'t be reduced.\n 199: invokespecial #101 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 202: athrow\n 203: aload 12\n 205: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 210: astore 13\n 212: aload 12\n 214: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 219: ifeq 259\n 222: aload 13\n 224: aload 12\n 226: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 231: checkcast #9 // class java/lang/Iterable\n 234: astore 14\n 236: checkcast #103 // class java/util/Set\n 239: astore 15\n 241: iconst_0\n 242: istore 16\n 244: aload 15\n 246: checkcast #9 // class java/lang/Iterable\n 249: aload 14\n 251: invokestatic #106 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 254: astore 13\n 256: goto 212\n 259: aload 13\n 261: checkcast #9 // class java/lang/Iterable\n 264: nop\n 265: astore 8\n 267: aload 4\n 269: aload 8\n 271: invokestatic #110 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 274: pop\n 275: goto 32\n 278: aload 4\n 280: checkcast #65 // class java/util/List\n 283: nop\n 284: areturn\n\n private static final int toPriority(char);\n Code:\n 0: iload_0\n 1: invokestatic #136 // Method java/lang/Character.isLowerCase:(C)Z\n 4: ifeq 16\n 7: iload_0\n 8: bipush 97\n 10: isub\n 11: iconst_1\n 12: iadd\n 13: goto 23\n 16: iload_0\n 17: bipush 65\n 19: isub\n 20: bipush 27\n 22: iadd\n 23: ireturn\n\n public static final void main();\n Code:\n 0: ldc #141 // String Day03_test\n 2: invokestatic #147 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #151 // 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 #153 // class java/lang/IllegalStateException\n 27: dup\n 28: ldc #155 // String Check failed.\n 30: invokespecial #156 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 33: athrow\n 34: aload_0\n 35: invokestatic #159 // 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 #153 // class java/lang/IllegalStateException\n 54: dup\n 55: ldc #155 // String Check failed.\n 57: invokespecial #156 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 60: athrow\n 61: ldc #161 // String Day03\n 63: invokestatic #147 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 66: astore_1\n 67: aload_1\n 68: invokestatic #151 // Method main$part1:(Ljava/util/List;)I\n 71: istore_2\n 72: getstatic #167 // Field java/lang/System.out:Ljava/io/PrintStream;\n 75: iload_2\n 76: invokevirtual #172 // Method java/io/PrintStream.println:(I)V\n 79: aload_1\n 80: invokestatic #159 // Method main$part2:(Ljava/util/List;)I\n 83: istore_2\n 84: getstatic #167 // Field java/lang/System.out:Ljava/io/PrintStream;\n 87: iload_2\n 88: invokevirtual #172 // Method java/io/PrintStream.println:(I)V\n 91: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #176 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #181 // Method compartments:(Ljava/util/List;)Ljava/util/List;\n 4: invokestatic #183 // Method intersect:(Ljava/util/List;)Ljava/util/List;\n 7: checkcast #9 // class java/lang/Iterable\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: aload_1\n 14: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 19: astore_3\n 20: aload_3\n 21: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 26: ifeq 69\n 29: aload_3\n 30: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 35: astore 4\n 37: iload_2\n 38: aload 4\n 40: checkcast #132 // class java/lang/Character\n 43: invokevirtual #187 // Method java/lang/Character.charValue:()C\n 46: istore 5\n 48: istore 7\n 50: iconst_0\n 51: istore 6\n 53: iload 5\n 55: invokestatic #189 // Method toPriority:(C)I\n 58: istore 8\n 60: iload 7\n 62: iload 8\n 64: iadd\n 65: istore_2\n 66: goto 20\n 69: iload_2\n 70: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #192 // Method groups:(Ljava/util/List;)Ljava/util/List;\n 4: invokestatic #183 // Method intersect:(Ljava/util/List;)Ljava/util/List;\n 7: checkcast #9 // class java/lang/Iterable\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: aload_1\n 14: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 19: astore_3\n 20: aload_3\n 21: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 26: ifeq 69\n 29: aload_3\n 30: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 35: astore 4\n 37: iload_2\n 38: aload 4\n 40: checkcast #132 // class java/lang/Character\n 43: invokevirtual #187 // Method java/lang/Character.charValue:()C\n 46: istore 5\n 48: istore 7\n 50: iconst_0\n 51: istore 6\n 53: iload 5\n 55: invokestatic #189 // Method toPriority:(C)I\n 58: istore 8\n 60: iload 7\n 62: iload 8\n 64: iadd\n 65: istore_2\n 66: goto 20\n 69: iload_2\n 70: ireturn\n}\n",
"javap_err": ""
}
] |
ShuffleZZZ__advent-of-code-kotlin__5a3cff1/src/Day02.kt
|
private const val RPS_SIZE = 3
private fun String.toInt() = when (this) {
"A", "X" -> 1
"B", "Y" -> 2
"C", "Z" -> 3
else -> error("Incorrect input")
}
private fun Pair<Int, Int>.game1() = second + when {
first % RPS_SIZE + 1 == second -> 6
first == second -> 3
(first + 1) % RPS_SIZE + 1 == second -> 0
else -> error("Incorrect input game 1")
}
private fun Pair<Int, Int>.game2() = when (second) {
1 -> (first + 1) % RPS_SIZE + 1
2 -> 3 + first
3 -> 6 + first % RPS_SIZE + 1
else -> error("Incorrect input game 2")
}
private fun parseInput(input: List<String>) =
input.map { it.trim().split(' ', limit = 2) }.map { it.first().toInt() to it.last().toInt() }
fun main() {
fun part1(input: List<String>) = parseInput(input).sumOf { it.game1() }
fun part2(input: List<String>) = parseInput(input).sumOf { it.game2() }
// 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": "ShuffleZZZ__advent-of-code-kotlin__5a3cff1/Day02Kt.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class Day02Kt {\n private static final int RPS_SIZE;\n\n private static final int toInt(java.lang.String);\n Code:\n 0: aload_0\n 1: astore_1\n 2: aload_1\n 3: invokevirtual #12 // 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: 148\n }\n 64: aload_1\n 65: ldc #14 // String A\n 67: invokevirtual #18 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 70: ifne 136\n 73: goto 148\n 76: aload_1\n 77: ldc #20 // String B\n 79: invokevirtual #18 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 82: ifne 140\n 85: goto 148\n 88: aload_1\n 89: ldc #22 // String C\n 91: invokevirtual #18 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 94: ifne 144\n 97: goto 148\n 100: aload_1\n 101: ldc #24 // String X\n 103: invokevirtual #18 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 106: ifne 136\n 109: goto 148\n 112: aload_1\n 113: ldc #26 // String Y\n 115: invokevirtual #18 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 118: ifne 140\n 121: goto 148\n 124: aload_1\n 125: ldc #28 // String Z\n 127: invokevirtual #18 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 130: ifne 144\n 133: goto 148\n 136: iconst_1\n 137: goto 161\n 140: iconst_2\n 141: goto 161\n 144: iconst_3\n 145: goto 161\n 148: new #30 // class java/lang/IllegalStateException\n 151: dup\n 152: ldc #32 // String Incorrect input\n 154: invokevirtual #36 // Method java/lang/Object.toString:()Ljava/lang/String;\n 157: invokespecial #40 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 160: athrow\n 161: ireturn\n\n private static final int game1(kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: invokevirtual #51 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 4: checkcast #53 // class java/lang/Number\n 7: invokevirtual #56 // Method java/lang/Number.intValue:()I\n 10: aload_0\n 11: invokevirtual #59 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 14: checkcast #53 // class java/lang/Number\n 17: invokevirtual #56 // Method java/lang/Number.intValue:()I\n 20: iconst_3\n 21: irem\n 22: iconst_1\n 23: iadd\n 24: aload_0\n 25: invokevirtual #51 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 28: checkcast #53 // class java/lang/Number\n 31: invokevirtual #56 // Method java/lang/Number.intValue:()I\n 34: if_icmpne 42\n 37: bipush 6\n 39: goto 115\n 42: aload_0\n 43: invokevirtual #59 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 46: checkcast #53 // class java/lang/Number\n 49: invokevirtual #56 // Method java/lang/Number.intValue:()I\n 52: aload_0\n 53: invokevirtual #51 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 56: checkcast #53 // class java/lang/Number\n 59: invokevirtual #56 // Method java/lang/Number.intValue:()I\n 62: if_icmpne 69\n 65: iconst_3\n 66: goto 115\n 69: aload_0\n 70: invokevirtual #59 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 73: checkcast #53 // class java/lang/Number\n 76: invokevirtual #56 // Method java/lang/Number.intValue:()I\n 79: iconst_1\n 80: iadd\n 81: iconst_3\n 82: irem\n 83: iconst_1\n 84: iadd\n 85: aload_0\n 86: invokevirtual #51 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 89: checkcast #53 // class java/lang/Number\n 92: invokevirtual #56 // Method java/lang/Number.intValue:()I\n 95: if_icmpne 102\n 98: iconst_0\n 99: goto 115\n 102: new #30 // class java/lang/IllegalStateException\n 105: dup\n 106: ldc #61 // String Incorrect input game 1\n 108: invokevirtual #36 // Method java/lang/Object.toString:()Ljava/lang/String;\n 111: invokespecial #40 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 114: athrow\n 115: iadd\n 116: ireturn\n\n private static final int game2(kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: invokevirtual #51 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 4: checkcast #53 // class java/lang/Number\n 7: invokevirtual #56 // Method java/lang/Number.intValue:()I\n 10: tableswitch { // 1 to 3\n 1: 36\n 2: 55\n 3: 70\n default: 90\n }\n 36: aload_0\n 37: invokevirtual #59 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 40: checkcast #53 // class java/lang/Number\n 43: invokevirtual #56 // Method java/lang/Number.intValue:()I\n 46: iconst_1\n 47: iadd\n 48: iconst_3\n 49: irem\n 50: iconst_1\n 51: iadd\n 52: goto 103\n 55: iconst_3\n 56: aload_0\n 57: invokevirtual #59 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 60: checkcast #53 // class java/lang/Number\n 63: invokevirtual #56 // Method java/lang/Number.intValue:()I\n 66: iadd\n 67: goto 103\n 70: bipush 6\n 72: aload_0\n 73: invokevirtual #59 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 76: checkcast #53 // class java/lang/Number\n 79: invokevirtual #56 // Method java/lang/Number.intValue:()I\n 82: iconst_3\n 83: irem\n 84: iadd\n 85: iconst_1\n 86: iadd\n 87: goto 103\n 90: new #30 // class java/lang/IllegalStateException\n 93: dup\n 94: ldc #66 // String Incorrect input game 2\n 96: invokevirtual #36 // Method java/lang/Object.toString:()Ljava/lang/String;\n 99: invokespecial #40 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 102: athrow\n 103: ireturn\n\n private static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> parseInput(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #72 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: astore_3\n 9: new #74 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #80 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #83 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #85 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 117\n 48: aload 6\n 50: invokeinterface #98, 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 11\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: checkcast #100 // class java/lang/CharSequence\n 76: invokestatic #106 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 79: invokevirtual #36 // Method java/lang/Object.toString:()Ljava/lang/String;\n 82: checkcast #100 // class java/lang/CharSequence\n 85: iconst_1\n 86: newarray char\n 88: astore 10\n 90: aload 10\n 92: iconst_0\n 93: bipush 32\n 95: castore\n 96: aload 10\n 98: iconst_0\n 99: iconst_2\n 100: iconst_2\n 101: aconst_null\n 102: invokestatic #110 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 105: aload 11\n 107: swap\n 108: invokeinterface #113, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 113: pop\n 114: goto 38\n 117: aload 4\n 119: checkcast #115 // class java/util/List\n 122: nop\n 123: checkcast #72 // 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 #74 // class java/util/ArrayList\n 135: dup\n 136: aload_1\n 137: bipush 10\n 139: invokestatic #80 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 142: invokespecial #83 // Method java/util/ArrayList.\"<init>\":(I)V\n 145: checkcast #85 // class java/util/Collection\n 148: astore 4\n 150: iconst_0\n 151: istore 5\n 153: aload_3\n 154: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 159: astore 6\n 161: aload 6\n 163: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 168: ifeq 237\n 171: aload 6\n 173: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 178: astore 7\n 180: aload 4\n 182: aload 7\n 184: checkcast #115 // class java/util/List\n 187: astore 8\n 189: astore 11\n 191: iconst_0\n 192: istore 9\n 194: aload 8\n 196: invokestatic #119 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 199: checkcast #8 // class java/lang/String\n 202: invokestatic #121 // Method toInt:(Ljava/lang/String;)I\n 205: invokestatic #127 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 208: aload 8\n 210: invokestatic #130 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 213: checkcast #8 // class java/lang/String\n 216: invokestatic #121 // Method toInt:(Ljava/lang/String;)I\n 219: invokestatic #127 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 222: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 225: aload 11\n 227: swap\n 228: invokeinterface #113, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 233: pop\n 234: goto 161\n 237: aload 4\n 239: checkcast #115 // class java/util/List\n 242: nop\n 243: areturn\n\n public static final void main();\n Code:\n 0: ldc #155 // String Day02_test\n 2: invokestatic #161 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #165 // Method main$part1:(Ljava/util/List;)I\n 10: bipush 15\n 12: if_icmpne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 33\n 23: new #30 // class java/lang/IllegalStateException\n 26: dup\n 27: ldc #167 // String Check failed.\n 29: invokespecial #40 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 32: athrow\n 33: aload_0\n 34: invokestatic #170 // Method main$part2:(Ljava/util/List;)I\n 37: bipush 12\n 39: if_icmpne 46\n 42: iconst_1\n 43: goto 47\n 46: iconst_0\n 47: ifne 60\n 50: new #30 // class java/lang/IllegalStateException\n 53: dup\n 54: ldc #167 // String Check failed.\n 56: invokespecial #40 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 59: athrow\n 60: ldc #172 // String Day02\n 62: invokestatic #161 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 65: astore_1\n 66: aload_1\n 67: invokestatic #165 // Method main$part1:(Ljava/util/List;)I\n 70: istore_2\n 71: getstatic #178 // Field java/lang/System.out:Ljava/io/PrintStream;\n 74: iload_2\n 75: invokevirtual #183 // Method java/io/PrintStream.println:(I)V\n 78: aload_1\n 79: invokestatic #170 // Method main$part2:(Ljava/util/List;)I\n 82: istore_2\n 83: getstatic #178 // Field java/lang/System.out:Ljava/io/PrintStream;\n 86: iload_2\n 87: invokevirtual #183 // Method java/io/PrintStream.println:(I)V\n 90: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #187 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #192 // Method parseInput:(Ljava/util/List;)Ljava/util/List;\n 4: checkcast #72 // class java/lang/Iterable\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 16: astore_3\n 17: aload_3\n 18: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 23: ifeq 63\n 26: aload_3\n 27: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 32: astore 4\n 34: iload_2\n 35: aload 4\n 37: checkcast #47 // class kotlin/Pair\n 40: astore 5\n 42: istore 7\n 44: iconst_0\n 45: istore 6\n 47: aload 5\n 49: invokestatic #194 // Method game1:(Lkotlin/Pair;)I\n 52: istore 8\n 54: iload 7\n 56: iload 8\n 58: iadd\n 59: istore_2\n 60: goto 17\n 63: iload_2\n 64: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #192 // Method parseInput:(Ljava/util/List;)Ljava/util/List;\n 4: checkcast #72 // class java/lang/Iterable\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 16: astore_3\n 17: aload_3\n 18: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 23: ifeq 63\n 26: aload_3\n 27: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 32: astore 4\n 34: iload_2\n 35: aload 4\n 37: checkcast #47 // class kotlin/Pair\n 40: astore 5\n 42: istore 7\n 44: iconst_0\n 45: istore 6\n 47: aload 5\n 49: invokestatic #197 // Method game2:(Lkotlin/Pair;)I\n 52: istore 8\n 54: iload 7\n 56: iload 8\n 58: iadd\n 59: istore_2\n 60: goto 17\n 63: iload_2\n 64: ireturn\n}\n",
"javap_err": ""
}
] |
ShuffleZZZ__advent-of-code-kotlin__5a3cff1/src/Day12.kt
|
var start = 0 to 0
var end = 0 to 0
private fun heights(input: List<String>) =
input.mapIndexed { i, line ->
line.mapIndexed { j, char ->
when (char) {
'S' -> 'a'.also { start = i to j }
'E' -> 'z'.also { end = i to j }
else -> char
} - 'a'
}
}
private fun dijkstra(heights: List<List<Int>>, start: Pair<Int, Int>): List<List<Int>> {
val distances = List(heights.size) { MutableList(heights.first().size) { Int.MAX_VALUE } }
val unvisited = distances.indexPairs().toMutableSet()
distances[start] = 0
var cur = start
while (true) {
unvisited.remove(cur)
neighbours(cur).filter { (i, j) -> i in distances.indices && j in distances.first().indices }
.filter { unvisited.contains(it) }.forEach {
if (heights[it] <= heights[cur] + 1) {
distances[it] = distances[it].coerceAtMost(distances[cur] + 1)
}
}
val next = unvisited.minByOrNull { distances[it] }
if (next == null || distances[next] == Int.MAX_VALUE) break
cur = next
}
return distances
}
fun main() {
fun part1(input: List<String>) = dijkstra(heights(input), start)[end]
fun part2(input: List<String>): Int {
val heights = heights(input)
return heights.indexPairs { it == 0 }.minOf { dijkstra(heights, it)[end] }
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day12_test")
check(part1(testInput) == 31)
check(part2(testInput) == 29)
val input = readInput("Day12")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "ShuffleZZZ__advent-of-code-kotlin__5a3cff1/Day12Kt.class",
"javap": "Compiled from \"Day12.kt\"\npublic final class Day12Kt {\n private static kotlin.Pair<java.lang.Integer, java.lang.Integer> start;\n\n private static kotlin.Pair<java.lang.Integer, java.lang.Integer> end;\n\n public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> getStart();\n Code:\n 0: getstatic #12 // Field start:Lkotlin/Pair;\n 3: areturn\n\n public static final void setStart(kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #17 // String <set-?>\n 3: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: putstatic #12 // Field start:Lkotlin/Pair;\n 10: return\n\n public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> getEnd();\n Code:\n 0: getstatic #27 // Field end:Lkotlin/Pair;\n 3: areturn\n\n public static final void setEnd(kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #17 // String <set-?>\n 3: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: putstatic #27 // Field end:Lkotlin/Pair;\n 10: return\n\n private static final java.util.List<java.util.List<java.lang.Integer>> heights(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #33 // 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 #35 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #41 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #45 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #47 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: iconst_0\n 31: istore 6\n 33: aload_3\n 34: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 7\n 41: aload 7\n 43: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 311\n 51: aload 7\n 53: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 8\n 60: aload 4\n 62: iload 6\n 64: iinc 6, 1\n 67: istore 9\n 69: iload 9\n 71: ifge 77\n 74: invokestatic #65 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 77: iload 9\n 79: aload 8\n 81: checkcast #67 // class java/lang/String\n 84: astore 10\n 86: istore 11\n 88: astore 28\n 90: iconst_0\n 91: istore 12\n 93: aload 10\n 95: checkcast #69 // class java/lang/CharSequence\n 98: astore 13\n 100: iconst_0\n 101: istore 14\n 103: aload 13\n 105: astore 15\n 107: new #35 // class java/util/ArrayList\n 110: dup\n 111: aload 13\n 113: invokeinterface #73, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 118: invokespecial #45 // Method java/util/ArrayList.\"<init>\":(I)V\n 121: checkcast #47 // class java/util/Collection\n 124: astore 16\n 126: iconst_0\n 127: istore 17\n 129: iconst_0\n 130: istore 18\n 132: iconst_0\n 133: istore 19\n 135: iload 19\n 137: aload 15\n 139: invokeinterface #73, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 144: if_icmpge 292\n 147: aload 15\n 149: iload 19\n 151: invokeinterface #77, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 156: istore 20\n 158: aload 16\n 160: iload 18\n 162: iinc 18, 1\n 165: iload 20\n 167: istore 21\n 169: istore 22\n 171: astore 23\n 173: iconst_0\n 174: istore 24\n 176: iload 21\n 178: lookupswitch { // 2\n 69: 236\n 83: 204\n default: 268\n }\n 204: bipush 97\n 206: istore 25\n 208: iload 25\n 210: istore 26\n 212: iconst_0\n 213: istore 27\n 215: iload 11\n 217: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 220: iload 22\n 222: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 225: invokestatic #89 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 228: putstatic #12 // Field start:Lkotlin/Pair;\n 231: iload 25\n 233: goto 270\n 236: bipush 122\n 238: istore 25\n 240: iload 25\n 242: istore 26\n 244: iconst_0\n 245: istore 27\n 247: iload 11\n 249: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 252: iload 22\n 254: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 257: invokestatic #89 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 260: putstatic #27 // Field end:Lkotlin/Pair;\n 263: iload 25\n 265: goto 270\n 268: iload 21\n 270: bipush 97\n 272: isub\n 273: nop\n 274: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 277: aload 23\n 279: swap\n 280: invokeinterface #93, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 285: pop\n 286: iinc 19, 1\n 289: goto 135\n 292: aload 16\n 294: checkcast #95 // class java/util/List\n 297: nop\n 298: nop\n 299: aload 28\n 301: swap\n 302: invokeinterface #93, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 307: pop\n 308: goto 41\n 311: aload 4\n 313: checkcast #95 // class java/util/List\n 316: nop\n 317: areturn\n\n private static final java.util.List<java.util.List<java.lang.Integer>> dijkstra(java.util.List<? extends java.util.List<java.lang.Integer>>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: invokeinterface #126, 1 // InterfaceMethod java/util/List.size:()I\n 6: istore_3\n 7: new #35 // class java/util/ArrayList\n 10: dup\n 11: iload_3\n 12: invokespecial #45 // Method java/util/ArrayList.\"<init>\":(I)V\n 15: astore 4\n 17: iconst_0\n 18: istore 5\n 20: iload 5\n 22: iload_3\n 23: if_icmpge 128\n 26: iload 5\n 28: istore 6\n 30: aload 4\n 32: iload 6\n 34: istore 7\n 36: astore 16\n 38: iconst_0\n 39: istore 8\n 41: aload_0\n 42: invokestatic #130 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 45: checkcast #95 // class java/util/List\n 48: invokeinterface #126, 1 // InterfaceMethod java/util/List.size:()I\n 53: istore 9\n 55: new #35 // class java/util/ArrayList\n 58: dup\n 59: iload 9\n 61: invokespecial #45 // Method java/util/ArrayList.\"<init>\":(I)V\n 64: astore 10\n 66: iconst_0\n 67: istore 11\n 69: iload 11\n 71: iload 9\n 73: if_icmpge 109\n 76: iload 11\n 78: istore 12\n 80: aload 10\n 82: iload 12\n 84: istore 13\n 86: astore 14\n 88: iconst_0\n 89: istore 15\n 91: ldc #131 // int 2147483647\n 93: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 96: aload 14\n 98: swap\n 99: invokevirtual #132 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 102: pop\n 103: iinc 11, 1\n 106: goto 69\n 109: aload 10\n 111: checkcast #95 // class java/util/List\n 114: nop\n 115: aload 16\n 117: swap\n 118: invokevirtual #132 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 121: pop\n 122: iinc 5, 1\n 125: goto 20\n 128: aload 4\n 130: checkcast #95 // class java/util/List\n 133: astore_2\n 134: aload_2\n 135: aconst_null\n 136: iconst_1\n 137: aconst_null\n 138: invokestatic #138 // Method UtilsKt.indexPairs$default:(Ljava/util/List;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/util/List;\n 141: checkcast #33 // class java/lang/Iterable\n 144: invokestatic #142 // Method kotlin/collections/CollectionsKt.toMutableSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 147: astore_3\n 148: aload_2\n 149: aload_1\n 150: iconst_0\n 151: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 154: invokestatic #146 // Method UtilsKt.set:(Ljava/util/List;Lkotlin/Pair;Ljava/lang/Object;)V\n 157: aconst_null\n 158: astore 4\n 160: aload_1\n 161: astore 4\n 163: nop\n 164: aload_3\n 165: aload 4\n 167: invokeinterface #151, 2 // InterfaceMethod java/util/Set.remove:(Ljava/lang/Object;)Z\n 172: pop\n 173: aload 4\n 175: invokestatic #155 // Method UtilsKt.neighbours:(Lkotlin/Pair;)Ljava/util/List;\n 178: checkcast #33 // class java/lang/Iterable\n 181: astore 5\n 183: iconst_0\n 184: istore 6\n 186: aload 5\n 188: astore 7\n 190: new #35 // class java/util/ArrayList\n 193: dup\n 194: invokespecial #157 // Method java/util/ArrayList.\"<init>\":()V\n 197: checkcast #47 // class java/util/Collection\n 200: astore 8\n 202: iconst_0\n 203: istore 9\n 205: aload 7\n 207: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 212: astore 10\n 214: aload 10\n 216: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 221: ifeq 357\n 224: aload 10\n 226: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 231: astore 11\n 233: aload 11\n 235: checkcast #159 // class kotlin/Pair\n 238: astore 12\n 240: iconst_0\n 241: istore 13\n 243: aload 12\n 245: invokevirtual #162 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 248: checkcast #164 // class java/lang/Number\n 251: invokevirtual #167 // Method java/lang/Number.intValue:()I\n 254: istore 14\n 256: aload 12\n 258: invokevirtual #170 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 261: checkcast #164 // class java/lang/Number\n 264: invokevirtual #167 // Method java/lang/Number.intValue:()I\n 267: istore 15\n 269: iconst_0\n 270: iload 14\n 272: if_icmpgt 297\n 275: iload 14\n 277: aload_2\n 278: checkcast #47 // class java/util/Collection\n 281: invokeinterface #171, 1 // InterfaceMethod java/util/Collection.size:()I\n 286: if_icmpge 293\n 289: iconst_1\n 290: goto 298\n 293: iconst_0\n 294: goto 298\n 297: iconst_0\n 298: ifeq 340\n 301: iconst_0\n 302: iload 15\n 304: if_icmpgt 332\n 307: iload 15\n 309: aload_2\n 310: invokestatic #130 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 313: checkcast #47 // class java/util/Collection\n 316: invokeinterface #171, 1 // InterfaceMethod java/util/Collection.size:()I\n 321: if_icmpge 328\n 324: iconst_1\n 325: goto 333\n 328: iconst_0\n 329: goto 333\n 332: iconst_0\n 333: ifeq 340\n 336: iconst_1\n 337: goto 341\n 340: iconst_0\n 341: ifeq 214\n 344: aload 8\n 346: aload 11\n 348: invokeinterface #93, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 353: pop\n 354: goto 214\n 357: aload 8\n 359: checkcast #95 // class java/util/List\n 362: nop\n 363: checkcast #33 // class java/lang/Iterable\n 366: astore 5\n 368: nop\n 369: iconst_0\n 370: istore 6\n 372: aload 5\n 374: astore 7\n 376: new #35 // class java/util/ArrayList\n 379: dup\n 380: invokespecial #157 // Method java/util/ArrayList.\"<init>\":()V\n 383: checkcast #47 // class java/util/Collection\n 386: astore 8\n 388: iconst_0\n 389: istore 9\n 391: aload 7\n 393: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 398: astore 10\n 400: aload 10\n 402: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 407: ifeq 453\n 410: aload 10\n 412: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 417: astore 11\n 419: aload 11\n 421: checkcast #159 // class kotlin/Pair\n 424: astore 12\n 426: iconst_0\n 427: istore 13\n 429: aload_3\n 430: aload 12\n 432: invokeinterface #174, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 437: ifeq 400\n 440: aload 8\n 442: aload 11\n 444: invokeinterface #93, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 449: pop\n 450: goto 400\n 453: aload 8\n 455: checkcast #95 // class java/util/List\n 458: nop\n 459: checkcast #33 // class java/lang/Iterable\n 462: astore 5\n 464: nop\n 465: iconst_0\n 466: istore 6\n 468: aload 5\n 470: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 475: astore 7\n 477: aload 7\n 479: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 484: ifeq 578\n 487: aload 7\n 489: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 494: astore 8\n 496: aload 8\n 498: checkcast #159 // class kotlin/Pair\n 501: astore 9\n 503: iconst_0\n 504: istore 10\n 506: aload_0\n 507: aload 9\n 509: invokestatic #178 // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;\n 512: checkcast #164 // class java/lang/Number\n 515: invokevirtual #167 // Method java/lang/Number.intValue:()I\n 518: aload_0\n 519: aload 4\n 521: invokestatic #178 // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;\n 524: checkcast #164 // class java/lang/Number\n 527: invokevirtual #167 // Method java/lang/Number.intValue:()I\n 530: iconst_1\n 531: iadd\n 532: if_icmpgt 573\n 535: aload_2\n 536: aload 9\n 538: aload_2\n 539: aload 9\n 541: invokestatic #178 // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;\n 544: checkcast #164 // class java/lang/Number\n 547: invokevirtual #167 // Method java/lang/Number.intValue:()I\n 550: aload_2\n 551: aload 4\n 553: invokestatic #178 // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;\n 556: checkcast #164 // class java/lang/Number\n 559: invokevirtual #167 // Method java/lang/Number.intValue:()I\n 562: iconst_1\n 563: iadd\n 564: invokestatic #184 // Method kotlin/ranges/RangesKt.coerceAtMost:(II)I\n 567: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 570: invokestatic #146 // Method UtilsKt.set:(Ljava/util/List;Lkotlin/Pair;Ljava/lang/Object;)V\n 573: nop\n 574: nop\n 575: goto 477\n 578: nop\n 579: aload_3\n 580: checkcast #33 // class java/lang/Iterable\n 583: astore 6\n 585: iconst_0\n 586: istore 7\n 588: aload 6\n 590: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 595: astore 8\n 597: aload 8\n 599: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 604: ifne 611\n 607: aconst_null\n 608: goto 719\n 611: aload 8\n 613: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 618: astore 9\n 620: aload 8\n 622: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 627: ifne 635\n 630: aload 9\n 632: goto 719\n 635: aload 9\n 637: checkcast #159 // class kotlin/Pair\n 640: astore 10\n 642: iconst_0\n 643: istore 11\n 645: aload_2\n 646: aload 10\n 648: invokestatic #178 // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;\n 651: checkcast #164 // class java/lang/Number\n 654: invokevirtual #167 // Method java/lang/Number.intValue:()I\n 657: istore 10\n 659: aload 8\n 661: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 666: astore 11\n 668: aload 11\n 670: checkcast #159 // class kotlin/Pair\n 673: astore 12\n 675: iconst_0\n 676: istore 13\n 678: aload_2\n 679: aload 12\n 681: invokestatic #178 // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;\n 684: checkcast #164 // class java/lang/Number\n 687: invokevirtual #167 // Method java/lang/Number.intValue:()I\n 690: istore 12\n 692: iload 10\n 694: iload 12\n 696: if_icmple 707\n 699: aload 11\n 701: astore 9\n 703: iload 12\n 705: istore 10\n 707: aload 8\n 709: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 714: ifne 659\n 717: aload 9\n 719: checkcast #159 // class kotlin/Pair\n 722: astore 5\n 724: aload 5\n 726: ifnull 756\n 729: aload_2\n 730: aload 5\n 732: invokestatic #178 // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;\n 735: checkcast #164 // class java/lang/Number\n 738: invokevirtual #167 // Method java/lang/Number.intValue:()I\n 741: ldc #131 // int 2147483647\n 743: if_icmpne 749\n 746: goto 756\n 749: aload 5\n 751: astore 4\n 753: goto 163\n 756: aload_2\n 757: areturn\n\n public static final void main();\n Code:\n 0: ldc #213 // String Day12_test\n 2: invokestatic #217 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #221 // Method main$part1:(Ljava/util/List;)I\n 10: bipush 31\n 12: if_icmpne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 33\n 23: new #223 // class java/lang/IllegalStateException\n 26: dup\n 27: ldc #225 // String Check failed.\n 29: invokespecial #228 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 32: athrow\n 33: aload_0\n 34: invokestatic #231 // Method main$part2:(Ljava/util/List;)I\n 37: bipush 29\n 39: if_icmpne 46\n 42: iconst_1\n 43: goto 47\n 46: iconst_0\n 47: ifne 60\n 50: new #223 // class java/lang/IllegalStateException\n 53: dup\n 54: ldc #225 // String Check failed.\n 56: invokespecial #228 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 59: athrow\n 60: ldc #233 // String Day12\n 62: invokestatic #217 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 65: astore_1\n 66: aload_1\n 67: invokestatic #221 // Method main$part1:(Ljava/util/List;)I\n 70: istore_2\n 71: getstatic #239 // Field java/lang/System.out:Ljava/io/PrintStream;\n 74: iload_2\n 75: invokevirtual #244 // Method java/io/PrintStream.println:(I)V\n 78: aload_1\n 79: invokestatic #231 // Method main$part2:(Ljava/util/List;)I\n 82: istore_2\n 83: getstatic #239 // Field java/lang/System.out:Ljava/io/PrintStream;\n 86: iload_2\n 87: invokevirtual #244 // Method java/io/PrintStream.println:(I)V\n 90: return\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: aload_0\n 1: invokestatic #253 // Method heights:(Ljava/util/List;)Ljava/util/List;\n 4: getstatic #12 // Field start:Lkotlin/Pair;\n 7: invokestatic #255 // Method dijkstra:(Ljava/util/List;Lkotlin/Pair;)Ljava/util/List;\n 10: getstatic #27 // Field end:Lkotlin/Pair;\n 13: invokestatic #178 // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;\n 16: checkcast #164 // class java/lang/Number\n 19: invokevirtual #167 // Method java/lang/Number.intValue:()I\n 22: ireturn\n\n private static final boolean main$part2$lambda$10(int);\n Code:\n 0: iload_0\n 1: ifne 8\n 4: iconst_1\n 5: goto 9\n 8: iconst_0\n 9: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #253 // Method heights:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: aload_1\n 6: invokedynamic #275, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 11: invokestatic #279 // Method UtilsKt.indexPairs:(Ljava/util/List;Lkotlin/jvm/functions/Function1;)Ljava/util/List;\n 14: checkcast #33 // class java/lang/Iterable\n 17: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 22: astore_2\n 23: aload_2\n 24: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 29: ifne 40\n 32: new #281 // class java/util/NoSuchElementException\n 35: dup\n 36: invokespecial #282 // Method java/util/NoSuchElementException.\"<init>\":()V\n 39: athrow\n 40: aload_2\n 41: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 46: checkcast #159 // class kotlin/Pair\n 49: astore_3\n 50: iconst_0\n 51: istore 4\n 53: aload_1\n 54: aload_3\n 55: invokestatic #255 // Method dijkstra:(Ljava/util/List;Lkotlin/Pair;)Ljava/util/List;\n 58: getstatic #27 // Field end:Lkotlin/Pair;\n 61: invokestatic #178 // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;\n 64: checkcast #164 // class java/lang/Number\n 67: invokevirtual #167 // Method java/lang/Number.intValue:()I\n 70: istore_3\n 71: aload_2\n 72: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 77: ifeq 126\n 80: aload_2\n 81: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 86: checkcast #159 // class kotlin/Pair\n 89: astore 4\n 91: iconst_0\n 92: istore 5\n 94: aload_1\n 95: aload 4\n 97: invokestatic #255 // Method dijkstra:(Ljava/util/List;Lkotlin/Pair;)Ljava/util/List;\n 100: getstatic #27 // Field end:Lkotlin/Pair;\n 103: invokestatic #178 // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;\n 106: checkcast #164 // class java/lang/Number\n 109: invokevirtual #167 // Method java/lang/Number.intValue:()I\n 112: istore 4\n 114: iload_3\n 115: iload 4\n 117: if_icmple 71\n 120: iload 4\n 122: istore_3\n 123: goto 71\n 126: iload_3\n 127: ireturn\n\n static {};\n Code:\n 0: iconst_0\n 1: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 4: iconst_0\n 5: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 8: invokestatic #89 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 11: putstatic #12 // Field start:Lkotlin/Pair;\n 14: iconst_0\n 15: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 18: iconst_0\n 19: invokestatic #83 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 22: invokestatic #89 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 25: putstatic #27 // Field end:Lkotlin/Pair;\n 28: return\n}\n",
"javap_err": ""
}
] |
ShuffleZZZ__advent-of-code-kotlin__5a3cff1/src/Day11.kt
|
private val template = """
Monkey (\d+):
Starting items: (.*?)
Operation: new = old (.) (.+)
Test: divisible by (\d+)
If true: throw to monkey (\d+)
If false: throw to monkey (\d+)
""".trim().toRegex()
private data class MonkeyBusiness(
val items: MutableList<ULong>,
val op: (ULong, ULong) -> ULong,
val value: String,
val divider: ULong,
val onTrue: Int,
val onFalse: Int,
var inspected: ULong = 0U,
) {
fun throwDecision(worryLevel: ULong) = if (worryLevel % divider == 0.toULong()) onTrue else onFalse
fun roundEnd() {
inspected += items.size.toUInt()
items.clear()
}
}
private fun parseMonkeys(input: List<String>) = input.map { monkey ->
val (_, list, sign, value, divider, onTrue, onFalse) = template.matchEntire(monkey)!!.destructured
val items = list.split(", ").map(String::toULong).toMutableList()
val operation: (ULong, ULong) -> ULong = when (sign.first()) {
'+' -> ULong::plus
'*' -> ULong::times
else -> error("Incorrect input")
}
MonkeyBusiness(items, operation, value, divider.toULong(), onTrue.toInt(), onFalse.toInt())
}
private fun throwRounds(monkeys: List<MonkeyBusiness>, times: Int, calming: (ULong) -> ULong): ULong {
val greatDivider = monkeys.map { it.divider }.reduce(ULong::times)
repeat(times) {
for (monkey in monkeys) {
for (item in monkey.items) {
val numberValue = monkey.value.toULongOrNull() ?: item
val worryLevel = calming(monkey.op(item, numberValue)) % greatDivider
monkeys[monkey.throwDecision(worryLevel)].items.add(worryLevel)
}
monkey.roundEnd()
}
}
return monkeys.map { it.inspected }.sorted().takeLast(2).reduce(ULong::times)
}
fun main() {
fun part1(input: List<String>) = throwRounds(parseMonkeys(input), 20) { it / 3U }
fun part2(input: List<String>) = throwRounds(parseMonkeys(input), 10_000) { it }
// test if implementation meets criteria from the description, like:
val testInput = readRawBlocks("Day11_test")
check(part1(testInput) == 10_605.toULong())
check(part2(testInput) == 2_713_310_158.toULong())
val input = readRawBlocks("Day11")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "ShuffleZZZ__advent-of-code-kotlin__5a3cff1/Day11Kt$parseMonkeys$1$operation$2.class",
"javap": "Compiled from \"Day11.kt\"\nfinal class Day11Kt$parseMonkeys$1$operation$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<kotlin.ULong, kotlin.ULong, kotlin.ULong> {\n public static final Day11Kt$parseMonkeys$1$operation$2 INSTANCE;\n\n Day11Kt$parseMonkeys$1$operation$2();\n Code:\n 0: aload_0\n 1: iconst_2\n 2: ldc #11 // class kotlin/ULong\n 4: ldc #13 // String times\n 6: ldc #15 // String times-VKZWuLQ(JJ)J\n 8: iconst_0\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final long invoke-oku0oEs(long, long);\n Code:\n 0: lload_1\n 1: lload_3\n 2: lmul\n 3: invokestatic #26 // Method kotlin/ULong.\"constructor-impl\":(J)J\n 6: lreturn\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 #11 // class kotlin/ULong\n 5: invokevirtual #35 // Method kotlin/ULong.\"unbox-impl\":()J\n 8: aload_2\n 9: checkcast #11 // class kotlin/ULong\n 12: invokevirtual #35 // Method kotlin/ULong.\"unbox-impl\":()J\n 15: invokevirtual #37 // Method \"invoke-oku0oEs\":(JJ)J\n 18: invokestatic #41 // Method kotlin/ULong.\"box-impl\":(J)Lkotlin/ULong;\n 21: areturn\n\n static {};\n Code:\n 0: new #2 // class Day11Kt$parseMonkeys$1$operation$2\n 3: dup\n 4: invokespecial #46 // Method \"<init>\":()V\n 7: putstatic #49 // Field INSTANCE:LDay11Kt$parseMonkeys$1$operation$2;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "ShuffleZZZ__advent-of-code-kotlin__5a3cff1/Day11Kt$parseMonkeys$1$operation$1.class",
"javap": "Compiled from \"Day11.kt\"\nfinal class Day11Kt$parseMonkeys$1$operation$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<kotlin.ULong, kotlin.ULong, kotlin.ULong> {\n public static final Day11Kt$parseMonkeys$1$operation$1 INSTANCE;\n\n Day11Kt$parseMonkeys$1$operation$1();\n Code:\n 0: aload_0\n 1: iconst_2\n 2: ldc #11 // class kotlin/ULong\n 4: ldc #13 // String plus\n 6: ldc #15 // String plus-VKZWuLQ(JJ)J\n 8: iconst_0\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final long invoke-oku0oEs(long, long);\n Code:\n 0: lload_1\n 1: lload_3\n 2: ladd\n 3: invokestatic #26 // Method kotlin/ULong.\"constructor-impl\":(J)J\n 6: lreturn\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 #11 // class kotlin/ULong\n 5: invokevirtual #35 // Method kotlin/ULong.\"unbox-impl\":()J\n 8: aload_2\n 9: checkcast #11 // class kotlin/ULong\n 12: invokevirtual #35 // Method kotlin/ULong.\"unbox-impl\":()J\n 15: invokevirtual #37 // Method \"invoke-oku0oEs\":(JJ)J\n 18: invokestatic #41 // Method kotlin/ULong.\"box-impl\":(J)Lkotlin/ULong;\n 21: areturn\n\n static {};\n Code:\n 0: new #2 // class Day11Kt$parseMonkeys$1$operation$1\n 3: dup\n 4: invokespecial #46 // Method \"<init>\":()V\n 7: putstatic #49 // Field INSTANCE:LDay11Kt$parseMonkeys$1$operation$1;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "ShuffleZZZ__advent-of-code-kotlin__5a3cff1/Day11Kt.class",
"javap": "Compiled from \"Day11.kt\"\npublic final class Day11Kt {\n private static final kotlin.text.Regex template;\n\n private static final java.util.List<MonkeyBusiness> parseMonkeys(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #9 // 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 #11 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #23 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 465\n 48: aload 6\n 50: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #39 // class java/lang/String\n 64: astore 8\n 66: astore 28\n 68: iconst_0\n 69: istore 9\n 71: getstatic #43 // Field template:Lkotlin/text/Regex;\n 74: aload 8\n 76: checkcast #45 // class java/lang/CharSequence\n 79: invokevirtual #51 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;\n 82: dup\n 83: invokestatic #57 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 86: invokeinterface #63, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 91: astore 10\n 93: aload 10\n 95: invokevirtual #69 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 98: invokeinterface #73, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 103: iconst_2\n 104: invokeinterface #79, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 109: checkcast #39 // class java/lang/String\n 112: astore 11\n 114: aload 10\n 116: invokevirtual #69 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 119: invokeinterface #73, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 124: iconst_3\n 125: invokeinterface #79, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 130: checkcast #39 // class java/lang/String\n 133: astore 12\n 135: aload 10\n 137: invokevirtual #69 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 140: invokeinterface #73, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 145: iconst_4\n 146: invokeinterface #79, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 151: checkcast #39 // class java/lang/String\n 154: astore 13\n 156: aload 10\n 158: invokevirtual #69 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 161: invokeinterface #73, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 166: iconst_5\n 167: invokeinterface #79, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 172: checkcast #39 // class java/lang/String\n 175: astore 14\n 177: aload 10\n 179: invokevirtual #69 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 182: invokeinterface #73, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 187: bipush 6\n 189: invokeinterface #79, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 194: checkcast #39 // class java/lang/String\n 197: astore 15\n 199: aload 10\n 201: invokevirtual #69 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 204: invokeinterface #73, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 209: bipush 7\n 211: invokeinterface #79, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 216: checkcast #39 // class java/lang/String\n 219: astore 16\n 221: aload 11\n 223: checkcast #45 // class java/lang/CharSequence\n 226: iconst_1\n 227: anewarray #39 // class java/lang/String\n 230: astore 17\n 232: aload 17\n 234: iconst_0\n 235: ldc #81 // String ,\n 237: aastore\n 238: aload 17\n 240: iconst_0\n 241: iconst_0\n 242: bipush 6\n 244: aconst_null\n 245: invokestatic #87 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 248: checkcast #9 // class java/lang/Iterable\n 251: astore 17\n 253: iconst_0\n 254: istore 18\n 256: aload 17\n 258: astore 19\n 260: new #11 // class java/util/ArrayList\n 263: dup\n 264: aload 17\n 266: bipush 10\n 268: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 271: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 274: checkcast #23 // class java/util/Collection\n 277: astore 20\n 279: iconst_0\n 280: istore 21\n 282: aload 19\n 284: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 289: astore 22\n 291: aload 22\n 293: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 298: ifeq 344\n 301: aload 22\n 303: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 308: astore 23\n 310: aload 20\n 312: aload 23\n 314: checkcast #39 // class java/lang/String\n 317: astore 24\n 319: astore 25\n 321: iconst_0\n 322: istore 26\n 324: aload 24\n 326: invokestatic #93 // Method kotlin/text/UStringsKt.toULong:(Ljava/lang/String;)J\n 329: invokestatic #99 // Method kotlin/ULong.\"box-impl\":(J)Lkotlin/ULong;\n 332: aload 25\n 334: swap\n 335: invokeinterface #103, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 340: pop\n 341: goto 291\n 344: aload 20\n 346: checkcast #75 // class java/util/List\n 349: nop\n 350: checkcast #23 // class java/util/Collection\n 353: invokestatic #107 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 356: astore 27\n 358: aload 12\n 360: checkcast #45 // class java/lang/CharSequence\n 363: invokestatic #111 // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C\n 366: tableswitch { // 42 to 43\n 42: 397\n 43: 388\n default: 406\n }\n 388: getstatic #117 // Field Day11Kt$parseMonkeys$1$operation$1.INSTANCE:LDay11Kt$parseMonkeys$1$operation$1;\n 391: checkcast #119 // class kotlin/jvm/functions/Function2\n 394: goto 419\n 397: getstatic #124 // Field Day11Kt$parseMonkeys$1$operation$2.INSTANCE:LDay11Kt$parseMonkeys$1$operation$2;\n 400: checkcast #119 // class kotlin/jvm/functions/Function2\n 403: goto 419\n 406: new #126 // class java/lang/IllegalStateException\n 409: dup\n 410: ldc #128 // String Incorrect input\n 412: invokevirtual #132 // Method java/lang/Object.toString:()Ljava/lang/String;\n 415: invokespecial #135 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 418: athrow\n 419: astore 17\n 421: new #137 // class MonkeyBusiness\n 424: dup\n 425: aload 27\n 427: aload 17\n 429: aload 13\n 431: aload 14\n 433: invokestatic #93 // Method kotlin/text/UStringsKt.toULong:(Ljava/lang/String;)J\n 436: aload 15\n 438: invokestatic #143 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 441: aload 16\n 443: invokestatic #143 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 446: lconst_0\n 447: bipush 64\n 449: aconst_null\n 450: invokespecial #146 // Method MonkeyBusiness.\"<init>\":(Ljava/util/List;Lkotlin/jvm/functions/Function2;Ljava/lang/String;JIIJILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 453: aload 28\n 455: swap\n 456: invokeinterface #103, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 461: pop\n 462: goto 38\n 465: aload 4\n 467: checkcast #75 // class java/util/List\n 470: nop\n 471: areturn\n\n private static final long throwRounds(java.util.List<MonkeyBusiness>, int, kotlin.jvm.functions.Function1<? super kotlin.ULong, kotlin.ULong>);\n Code:\n 0: aload_0\n 1: checkcast #9 // class java/lang/Iterable\n 4: astore 5\n 6: iconst_0\n 7: istore 6\n 9: aload 5\n 11: astore 7\n 13: new #11 // class java/util/ArrayList\n 16: dup\n 17: aload 5\n 19: bipush 10\n 21: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 24: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 27: checkcast #23 // class java/util/Collection\n 30: astore 8\n 32: iconst_0\n 33: istore 9\n 35: aload 7\n 37: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 10\n 44: aload 10\n 46: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 97\n 54: aload 10\n 56: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 11\n 63: aload 8\n 65: aload 11\n 67: checkcast #137 // class MonkeyBusiness\n 70: astore 12\n 72: astore 17\n 74: iconst_0\n 75: istore 13\n 77: aload 12\n 79: invokevirtual #179 // Method MonkeyBusiness.\"getDivider-s-VKNKU\":()J\n 82: invokestatic #99 // Method kotlin/ULong.\"box-impl\":(J)Lkotlin/ULong;\n 85: aload 17\n 87: swap\n 88: invokeinterface #103, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 93: pop\n 94: goto 44\n 97: aload 8\n 99: checkcast #75 // class java/util/List\n 102: nop\n 103: checkcast #9 // class java/lang/Iterable\n 106: astore 5\n 108: nop\n 109: iconst_0\n 110: istore 6\n 112: aload 5\n 114: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 119: astore 7\n 121: aload 7\n 123: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 128: ifne 141\n 131: new #181 // class java/lang/UnsupportedOperationException\n 134: dup\n 135: ldc #183 // String Empty collection can\\'t be reduced.\n 137: invokespecial #184 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 140: athrow\n 141: aload 7\n 143: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 148: astore 8\n 150: aload 7\n 152: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 157: ifeq 205\n 160: aload 8\n 162: aload 7\n 164: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 169: checkcast #95 // class kotlin/ULong\n 172: invokevirtual #187 // Method kotlin/ULong.\"unbox-impl\":()J\n 175: lstore 9\n 177: checkcast #95 // class kotlin/ULong\n 180: invokevirtual #187 // Method kotlin/ULong.\"unbox-impl\":()J\n 183: lstore 11\n 185: iconst_0\n 186: istore 13\n 188: lload 11\n 190: lload 9\n 192: lmul\n 193: invokestatic #191 // Method kotlin/ULong.\"constructor-impl\":(J)J\n 196: nop\n 197: invokestatic #99 // Method kotlin/ULong.\"box-impl\":(J)Lkotlin/ULong;\n 200: astore 8\n 202: goto 150\n 205: aload 8\n 207: checkcast #95 // class kotlin/ULong\n 210: invokevirtual #187 // Method kotlin/ULong.\"unbox-impl\":()J\n 213: lstore_3\n 214: iconst_0\n 215: istore 5\n 217: iload 5\n 219: iload_1\n 220: if_icmpge 406\n 223: iload 5\n 225: istore 6\n 227: iconst_0\n 228: istore 7\n 230: aload_0\n 231: invokeinterface #192, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 236: astore 8\n 238: aload 8\n 240: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 245: ifeq 399\n 248: aload 8\n 250: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 255: checkcast #137 // class MonkeyBusiness\n 258: astore 9\n 260: aload 9\n 262: invokevirtual #195 // Method MonkeyBusiness.getItems:()Ljava/util/List;\n 265: invokeinterface #192, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 270: astore 10\n 272: aload 10\n 274: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 279: ifeq 391\n 282: aload 10\n 284: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 289: checkcast #95 // class kotlin/ULong\n 292: invokevirtual #187 // Method kotlin/ULong.\"unbox-impl\":()J\n 295: lstore 11\n 297: aload 9\n 299: invokevirtual #198 // Method MonkeyBusiness.getValue:()Ljava/lang/String;\n 302: invokestatic #202 // Method kotlin/text/UStringsKt.toULongOrNull:(Ljava/lang/String;)Lkotlin/ULong;\n 305: dup\n 306: ifnull 315\n 309: invokevirtual #187 // Method kotlin/ULong.\"unbox-impl\":()J\n 312: goto 318\n 315: pop\n 316: lload 11\n 318: lstore 13\n 320: aload_2\n 321: aload 9\n 323: invokevirtual #206 // Method MonkeyBusiness.getOp:()Lkotlin/jvm/functions/Function2;\n 326: lload 11\n 328: invokestatic #99 // Method kotlin/ULong.\"box-impl\":(J)Lkotlin/ULong;\n 331: lload 13\n 333: invokestatic #99 // Method kotlin/ULong.\"box-impl\":(J)Lkotlin/ULong;\n 336: invokeinterface #210, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 341: invokeinterface #215, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 346: checkcast #95 // class kotlin/ULong\n 349: invokevirtual #187 // Method kotlin/ULong.\"unbox-impl\":()J\n 352: lload_3\n 353: invokestatic #221 // Method java/lang/Long.remainderUnsigned:(JJ)J\n 356: lstore 15\n 358: aload_0\n 359: aload 9\n 361: lload 15\n 363: invokevirtual #225 // Method MonkeyBusiness.\"throwDecision-VKZWuLQ\":(J)I\n 366: invokeinterface #79, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 371: checkcast #137 // class MonkeyBusiness\n 374: invokevirtual #195 // Method MonkeyBusiness.getItems:()Ljava/util/List;\n 377: lload 15\n 379: invokestatic #99 // Method kotlin/ULong.\"box-impl\":(J)Lkotlin/ULong;\n 382: invokeinterface #226, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 387: pop\n 388: goto 272\n 391: aload 9\n 393: invokevirtual #230 // Method MonkeyBusiness.roundEnd:()V\n 396: goto 238\n 399: nop\n 400: iinc 5, 1\n 403: goto 217\n 406: aload_0\n 407: checkcast #9 // class java/lang/Iterable\n 410: astore 5\n 412: iconst_0\n 413: istore 6\n 415: aload 5\n 417: astore 7\n 419: new #11 // class java/util/ArrayList\n 422: dup\n 423: aload 5\n 425: bipush 10\n 427: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 430: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 433: checkcast #23 // class java/util/Collection\n 436: astore 8\n 438: iconst_0\n 439: istore 9\n 441: aload 7\n 443: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 448: astore 10\n 450: aload 10\n 452: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 457: ifeq 503\n 460: aload 10\n 462: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 467: astore 11\n 469: aload 8\n 471: aload 11\n 473: checkcast #137 // class MonkeyBusiness\n 476: astore 12\n 478: astore 17\n 480: iconst_0\n 481: istore 13\n 483: aload 12\n 485: invokevirtual #233 // Method MonkeyBusiness.\"getInspected-s-VKNKU\":()J\n 488: invokestatic #99 // Method kotlin/ULong.\"box-impl\":(J)Lkotlin/ULong;\n 491: aload 17\n 493: swap\n 494: invokeinterface #103, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 499: pop\n 500: goto 450\n 503: aload 8\n 505: checkcast #75 // class java/util/List\n 508: nop\n 509: checkcast #9 // class java/lang/Iterable\n 512: invokestatic #237 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;\n 515: iconst_2\n 516: invokestatic #241 // Method kotlin/collections/CollectionsKt.takeLast:(Ljava/util/List;I)Ljava/util/List;\n 519: checkcast #9 // class java/lang/Iterable\n 522: astore 5\n 524: iconst_0\n 525: istore 6\n 527: aload 5\n 529: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 534: astore 7\n 536: aload 7\n 538: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 543: ifne 556\n 546: new #181 // class java/lang/UnsupportedOperationException\n 549: dup\n 550: ldc #183 // String Empty collection can\\'t be reduced.\n 552: invokespecial #184 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 555: athrow\n 556: aload 7\n 558: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 563: astore 8\n 565: aload 7\n 567: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 572: ifeq 620\n 575: aload 8\n 577: aload 7\n 579: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 584: checkcast #95 // class kotlin/ULong\n 587: invokevirtual #187 // Method kotlin/ULong.\"unbox-impl\":()J\n 590: lstore 9\n 592: checkcast #95 // class kotlin/ULong\n 595: invokevirtual #187 // Method kotlin/ULong.\"unbox-impl\":()J\n 598: lstore 11\n 600: iconst_0\n 601: istore 13\n 603: lload 11\n 605: lload 9\n 607: lmul\n 608: invokestatic #191 // Method kotlin/ULong.\"constructor-impl\":(J)J\n 611: nop\n 612: invokestatic #99 // Method kotlin/ULong.\"box-impl\":(J)Lkotlin/ULong;\n 615: astore 8\n 617: goto 565\n 620: aload 8\n 622: checkcast #95 // class kotlin/ULong\n 625: invokevirtual #187 // Method kotlin/ULong.\"unbox-impl\":()J\n 628: lreturn\n\n public static final void main();\n Code:\n 0: ldc_w #266 // String Day11_test\n 3: invokestatic #272 // Method UtilsKt.readRawBlocks:(Ljava/lang/String;)Ljava/util/List;\n 6: astore_0\n 7: aload_0\n 8: invokestatic #276 // Method main$part1:(Ljava/util/List;)J\n 11: sipush 10605\n 14: i2l\n 15: invokestatic #191 // Method kotlin/ULong.\"constructor-impl\":(J)J\n 18: lcmp\n 19: ifne 26\n 22: iconst_1\n 23: goto 27\n 26: iconst_0\n 27: ifne 41\n 30: new #126 // class java/lang/IllegalStateException\n 33: dup\n 34: ldc_w #278 // String Check failed.\n 37: invokespecial #135 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 40: athrow\n 41: aload_0\n 42: invokestatic #281 // Method main$part2:(Ljava/util/List;)J\n 45: ldc2_w #282 // long 2713310158l\n 48: invokestatic #191 // Method kotlin/ULong.\"constructor-impl\":(J)J\n 51: lcmp\n 52: ifne 59\n 55: iconst_1\n 56: goto 60\n 59: iconst_0\n 60: ifne 74\n 63: new #126 // class java/lang/IllegalStateException\n 66: dup\n 67: ldc_w #278 // String Check failed.\n 70: invokespecial #135 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 73: athrow\n 74: ldc_w #285 // String Day11\n 77: invokestatic #272 // Method UtilsKt.readRawBlocks:(Ljava/lang/String;)Ljava/util/List;\n 80: astore_1\n 81: aload_1\n 82: invokestatic #276 // Method main$part1:(Ljava/util/List;)J\n 85: invokestatic #99 // Method kotlin/ULong.\"box-impl\":(J)Lkotlin/ULong;\n 88: getstatic #291 // Field java/lang/System.out:Ljava/io/PrintStream;\n 91: swap\n 92: invokevirtual #296 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 95: aload_1\n 96: invokestatic #281 // Method main$part2:(Ljava/util/List;)J\n 99: invokestatic #99 // Method kotlin/ULong.\"box-impl\":(J)Lkotlin/ULong;\n 102: getstatic #291 // Field java/lang/System.out:Ljava/io/PrintStream;\n 105: swap\n 106: invokevirtual #296 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 109: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #300 // Method main:()V\n 3: return\n\n private static final kotlin.ULong main$part1$lambda$6(kotlin.ULong);\n Code:\n 0: aload_0\n 1: invokevirtual #187 // Method kotlin/ULong.\"unbox-impl\":()J\n 4: iconst_3\n 5: i2l\n 6: ldc2_w #305 // long 4294967295l\n 9: land\n 10: invokestatic #191 // Method kotlin/ULong.\"constructor-impl\":(J)J\n 13: invokestatic #309 // Method java/lang/Long.divideUnsigned:(JJ)J\n 16: invokestatic #99 // Method kotlin/ULong.\"box-impl\":(J)Lkotlin/ULong;\n 19: areturn\n\n private static final long main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #313 // Method parseMonkeys:(Ljava/util/List;)Ljava/util/List;\n 4: bipush 20\n 6: invokedynamic #328, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 11: invokestatic #330 // Method throwRounds:(Ljava/util/List;ILkotlin/jvm/functions/Function1;)J\n 14: lreturn\n\n private static final kotlin.ULong main$part2$lambda$7(kotlin.ULong);\n Code:\n 0: aload_0\n 1: areturn\n\n private static final long main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #313 // Method parseMonkeys:(Ljava/util/List;)Ljava/util/List;\n 4: sipush 10000\n 7: invokedynamic #335, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 12: invokestatic #330 // Method throwRounds:(Ljava/util/List;ILkotlin/jvm/functions/Function1;)J\n 15: lreturn\n\n static {};\n Code:\n 0: new #47 // class kotlin/text/Regex\n 3: dup\n 4: nop\n 5: ldc_w #338 // String \\nMonkey (\\\\d+):\\n Starting items: (.*?)\\n Operation: new = old (.) (.+)\\n Test: divisible by (\\\\d+)\\n If true: throw to monkey (\\\\d+)\\n If false: throw to monkey (\\\\d+)\\n\n 8: checkcast #45 // class java/lang/CharSequence\n 11: invokestatic #342 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 14: invokevirtual #132 // Method java/lang/Object.toString:()Ljava/lang/String;\n 17: invokespecial #343 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 20: putstatic #43 // Field template:Lkotlin/text/Regex;\n 23: return\n}\n",
"javap_err": ""
}
] |
ShuffleZZZ__advent-of-code-kotlin__5a3cff1/src/Day10.kt
|
private const val SCREEN_WIDTH = 40
private const val SCREEN_SIZE = 6 * SCREEN_WIDTH
private const val SIGNAL_STRENGTH = SCREEN_WIDTH / 2
private fun cycleSignals(input: List<String>): List<Int> {
val signals = MutableList(2 * input.size + 1) { 1 }
var cycle = 0
for (i in input.indices) {
signals[cycle + 1] = signals[cycle]
val instruction = input[i].split(" ")
if (instruction.first() == "addx") {
signals[++cycle + 1] = signals[cycle] + instruction.last().toInt()
}
cycle++
}
return signals
}
fun main() {
fun part1(input: List<String>): Int {
val signals = cycleSignals(input)
return (SIGNAL_STRENGTH..SCREEN_SIZE - SIGNAL_STRENGTH step SCREEN_WIDTH).sumOf { it * signals[it - 1] }
}
fun part2(input: List<String>): String {
val signals = cycleSignals(input).take(SCREEN_SIZE)
return signals.chunked(SCREEN_WIDTH) { line ->
line.mapIndexed { ind, signal -> if (signal in ind - 1..ind + 1) '#' else '.' }.joinToString("")
}.joinToString("\n")
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day10_test")
check(part1(testInput) == 13_140)
println(part2(testInput))
val input = readInput("Day10")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "ShuffleZZZ__advent-of-code-kotlin__5a3cff1/Day10Kt.class",
"javap": "Compiled from \"Day10.kt\"\npublic final class Day10Kt {\n private static final int SCREEN_WIDTH;\n\n private static final int SCREEN_SIZE;\n\n private static final int SIGNAL_STRENGTH;\n\n private static final java.util.List<java.lang.Integer> cycleSignals(java.util.List<java.lang.String>);\n Code:\n 0: iconst_2\n 1: aload_0\n 2: invokeinterface #13, 1 // InterfaceMethod java/util/List.size:()I\n 7: imul\n 8: iconst_1\n 9: iadd\n 10: istore_2\n 11: new #15 // class java/util/ArrayList\n 14: dup\n 15: iload_2\n 16: invokespecial #19 // Method java/util/ArrayList.\"<init>\":(I)V\n 19: astore_3\n 20: iconst_0\n 21: istore 4\n 23: iload 4\n 25: iload_2\n 26: if_icmpge 60\n 29: iload 4\n 31: istore 5\n 33: aload_3\n 34: iload 5\n 36: istore 6\n 38: astore 8\n 40: iconst_0\n 41: istore 7\n 43: iconst_1\n 44: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 47: aload 8\n 49: swap\n 50: invokevirtual #29 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 53: pop\n 54: iinc 4, 1\n 57: goto 23\n 60: aload_3\n 61: checkcast #9 // class java/util/List\n 64: astore_1\n 65: iconst_0\n 66: istore_2\n 67: iconst_0\n 68: istore_3\n 69: aload_0\n 70: checkcast #31 // class java/util/Collection\n 73: invokeinterface #32, 1 // InterfaceMethod java/util/Collection.size:()I\n 78: istore 4\n 80: iload_3\n 81: iload 4\n 83: if_icmpge 200\n 86: aload_1\n 87: iload_2\n 88: iconst_1\n 89: iadd\n 90: aload_1\n 91: iload_2\n 92: invokeinterface #36, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 97: invokeinterface #40, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 102: pop\n 103: aload_0\n 104: iload_3\n 105: invokeinterface #36, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 110: checkcast #42 // class java/lang/CharSequence\n 113: iconst_1\n 114: anewarray #44 // class java/lang/String\n 117: astore 6\n 119: aload 6\n 121: iconst_0\n 122: ldc #46 // String\n 124: aastore\n 125: aload 6\n 127: iconst_0\n 128: iconst_0\n 129: bipush 6\n 131: aconst_null\n 132: invokestatic #52 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 135: astore 5\n 137: aload 5\n 139: invokestatic #58 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 142: ldc #60 // String addx\n 144: invokestatic #66 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 147: ifeq 191\n 150: aload_1\n 151: iinc 2, 1\n 154: iload_2\n 155: iconst_1\n 156: iadd\n 157: aload_1\n 158: iload_2\n 159: invokeinterface #36, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 164: checkcast #68 // class java/lang/Number\n 167: invokevirtual #71 // Method java/lang/Number.intValue:()I\n 170: aload 5\n 172: invokestatic #74 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 175: checkcast #44 // class java/lang/String\n 178: invokestatic #78 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 181: iadd\n 182: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 185: invokeinterface #40, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 190: pop\n 191: iinc 2, 1\n 194: iinc 3, 1\n 197: goto 80\n 200: aload_1\n 201: areturn\n\n public static final void main();\n Code:\n 0: ldc #93 // String Day10_test\n 2: invokestatic #99 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #103 // 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 #105 // class java/lang/IllegalStateException\n 27: dup\n 28: ldc #107 // String Check failed.\n 30: invokespecial #110 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 33: athrow\n 34: aload_0\n 35: invokestatic #114 // Method main$part2:(Ljava/util/List;)Ljava/lang/String;\n 38: getstatic #120 // Field java/lang/System.out:Ljava/io/PrintStream;\n 41: swap\n 42: invokevirtual #126 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 45: ldc #128 // String Day10\n 47: invokestatic #99 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 50: astore_1\n 51: aload_1\n 52: invokestatic #103 // Method main$part1:(Ljava/util/List;)I\n 55: istore_2\n 56: getstatic #120 // Field java/lang/System.out:Ljava/io/PrintStream;\n 59: iload_2\n 60: invokevirtual #130 // Method java/io/PrintStream.println:(I)V\n 63: aload_1\n 64: invokestatic #114 // Method main$part2:(Ljava/util/List;)Ljava/lang/String;\n 67: getstatic #120 // Field java/lang/System.out:Ljava/io/PrintStream;\n 70: swap\n 71: invokevirtual #126 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 74: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #134 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #138 // Method cycleSignals:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: new #140 // class kotlin/ranges/IntRange\n 8: dup\n 9: bipush 20\n 11: sipush 220\n 14: invokespecial #143 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 17: checkcast #145 // class kotlin/ranges/IntProgression\n 20: bipush 40\n 22: invokestatic #151 // Method kotlin/ranges/RangesKt.step:(Lkotlin/ranges/IntProgression;I)Lkotlin/ranges/IntProgression;\n 25: checkcast #153 // class java/lang/Iterable\n 28: astore_2\n 29: iconst_0\n 30: istore_3\n 31: aload_2\n 32: invokeinterface #157, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 37: astore 4\n 39: aload 4\n 41: invokeinterface #163, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 46: ifeq 99\n 49: aload 4\n 51: checkcast #165 // class kotlin/collections/IntIterator\n 54: invokevirtual #168 // Method kotlin/collections/IntIterator.nextInt:()I\n 57: istore 5\n 59: iload_3\n 60: iload 5\n 62: istore 6\n 64: istore 8\n 66: iconst_0\n 67: istore 7\n 69: iload 6\n 71: aload_1\n 72: iload 6\n 74: iconst_1\n 75: isub\n 76: invokeinterface #36, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 81: checkcast #68 // class java/lang/Number\n 84: invokevirtual #71 // Method java/lang/Number.intValue:()I\n 87: imul\n 88: istore 9\n 90: iload 8\n 92: iload 9\n 94: iadd\n 95: istore_3\n 96: goto 39\n 99: iload_3\n 100: ireturn\n\n private static final java.lang.String main$part2$lambda$3(java.util.List);\n Code:\n 0: aload_0\n 1: ldc #172 // String line\n 3: invokestatic #176 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #153 // 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 #15 // class java/util/ArrayList\n 18: dup\n 19: aload_1\n 20: bipush 10\n 22: invokestatic #180 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 25: invokespecial #19 // Method java/util/ArrayList.\"<init>\":(I)V\n 28: checkcast #31 // class java/util/Collection\n 31: astore 4\n 33: iconst_0\n 34: istore 5\n 36: iconst_0\n 37: istore 6\n 39: aload_3\n 40: invokeinterface #157, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 7\n 47: aload 7\n 49: invokeinterface #163, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 158\n 57: aload 7\n 59: invokeinterface #184, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 8\n 66: aload 4\n 68: iload 6\n 70: iinc 6, 1\n 73: istore 9\n 75: iload 9\n 77: ifge 83\n 80: invokestatic #187 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 83: iload 9\n 85: aload 8\n 87: checkcast #68 // class java/lang/Number\n 90: invokevirtual #71 // Method java/lang/Number.intValue:()I\n 93: istore 10\n 95: istore 11\n 97: astore 14\n 99: iconst_0\n 100: istore 12\n 102: iload 11\n 104: iconst_1\n 105: isub\n 106: istore 13\n 108: iload 10\n 110: iload 11\n 112: iconst_1\n 113: iadd\n 114: if_icmpgt 132\n 117: iload 13\n 119: iload 10\n 121: if_icmpgt 128\n 124: iconst_1\n 125: goto 133\n 128: iconst_0\n 129: goto 133\n 132: iconst_0\n 133: ifeq 141\n 136: bipush 35\n 138: goto 143\n 141: bipush 46\n 143: invokestatic #192 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 146: aload 14\n 148: swap\n 149: invokeinterface #193, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 154: pop\n 155: goto 47\n 158: aload 4\n 160: checkcast #9 // class java/util/List\n 163: nop\n 164: checkcast #153 // class java/lang/Iterable\n 167: ldc #195 // String\n 169: checkcast #42 // class java/lang/CharSequence\n 172: aconst_null\n 173: aconst_null\n 174: iconst_0\n 175: aconst_null\n 176: aconst_null\n 177: bipush 62\n 179: aconst_null\n 180: invokestatic #199 // 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 183: areturn\n\n private static final java.lang.String main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #138 // Method cycleSignals:(Ljava/util/List;)Ljava/util/List;\n 4: checkcast #153 // class java/lang/Iterable\n 7: sipush 240\n 10: invokestatic #217 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 13: astore_1\n 14: aload_1\n 15: checkcast #153 // class java/lang/Iterable\n 18: bipush 40\n 20: invokedynamic #234, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 25: invokestatic #238 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;ILkotlin/jvm/functions/Function1;)Ljava/util/List;\n 28: checkcast #153 // class java/lang/Iterable\n 31: ldc #240 // String \\n\n 33: checkcast #42 // class java/lang/CharSequence\n 36: aconst_null\n 37: aconst_null\n 38: iconst_0\n 39: aconst_null\n 40: aconst_null\n 41: bipush 62\n 43: aconst_null\n 44: invokestatic #199 // 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 47: areturn\n}\n",
"javap_err": ""
}
] |
ShuffleZZZ__advent-of-code-kotlin__5a3cff1/src/Day09.kt
|
import kotlin.math.absoluteValue
import kotlin.math.sign
private data class Cell(var x: Int = 0, var y: Int = 0) {
fun move(other: Cell) {
x += other.x
y += other.y
}
fun isAttached(other: Cell) = (x - other.x).absoluteValue < 2 && (y - other.y).absoluteValue < 2
fun follow(other: Cell) {
x += (other.x - x).sign
y += (other.y - y).sign
}
}
private fun moveTheRope(moves: List<String>, rope: List<Cell>): Int {
val res = HashSet<Cell>()
res.add(Cell())
for (move in moves) {
val (direction, value) = move.split(" ")
val step = when (direction) {
"R" -> Cell(1)
"L" -> Cell(-1)
"U" -> Cell(y = 1)
"D" -> Cell(y = -1)
else -> error("incorrect input")
}
for (i in 0 until value.toInt()) {
rope.first().move(step)
for (j in 1 until rope.size) {
if (rope[j].isAttached(rope[j - 1])) continue
rope[j].follow(rope[j - 1])
}
res.add(rope.last().copy())
}
}
return res.size
}
fun main() {
fun part1(input: List<String>) = moveTheRope(input, List(2) { Cell() })
fun part2(input: List<String>) = moveTheRope(input, List(10) { Cell() })
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day09_test")
check(part1(testInput) == 13)
check(part2(testInput) == 1)
val input = readInput("Day09")
println(part1(input))
println(part2(input))
}
|
[
{
"class_path": "ShuffleZZZ__advent-of-code-kotlin__5a3cff1/Day09Kt.class",
"javap": "Compiled from \"Day09.kt\"\npublic final class Day09Kt {\n private static final int moveTheRope(java.util.List<java.lang.String>, java.util.List<Cell>);\n Code:\n 0: new #9 // class java/util/HashSet\n 3: dup\n 4: invokespecial #13 // Method java/util/HashSet.\"<init>\":()V\n 7: astore_2\n 8: aload_2\n 9: new #15 // class Cell\n 12: dup\n 13: iconst_0\n 14: iconst_0\n 15: iconst_3\n 16: aconst_null\n 17: invokespecial #18 // Method Cell.\"<init>\":(IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 20: invokevirtual #22 // Method java/util/HashSet.add:(Ljava/lang/Object;)Z\n 23: pop\n 24: aload_0\n 25: invokeinterface #28, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 30: astore_3\n 31: aload_3\n 32: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 37: ifeq 414\n 40: aload_3\n 41: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 46: checkcast #40 // class java/lang/String\n 49: astore 4\n 51: aload 4\n 53: checkcast #42 // class java/lang/CharSequence\n 56: iconst_1\n 57: anewarray #40 // class java/lang/String\n 60: astore 6\n 62: aload 6\n 64: iconst_0\n 65: ldc #44 // String\n 67: aastore\n 68: aload 6\n 70: iconst_0\n 71: iconst_0\n 72: bipush 6\n 74: aconst_null\n 75: invokestatic #50 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 78: astore 5\n 80: aload 5\n 82: iconst_0\n 83: invokeinterface #54, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 88: checkcast #40 // class java/lang/String\n 91: astore 6\n 93: aload 5\n 95: iconst_1\n 96: invokeinterface #54, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 101: checkcast #40 // class java/lang/String\n 104: astore 7\n 106: aload 6\n 108: astore 9\n 110: aload 9\n 112: invokevirtual #58 // Method java/lang/String.hashCode:()I\n 115: lookupswitch { // 4\n 68: 169\n 76: 195\n 82: 156\n 85: 182\n default: 264\n }\n 156: aload 9\n 158: ldc #60 // String R\n 160: invokevirtual #63 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 163: ifne 208\n 166: goto 264\n 169: aload 9\n 171: ldc #65 // String D\n 173: invokevirtual #63 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 176: ifne 250\n 179: goto 264\n 182: aload 9\n 184: ldc #67 // String U\n 186: invokevirtual #63 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 189: ifne 236\n 192: goto 264\n 195: aload 9\n 197: ldc #69 // String L\n 199: invokevirtual #63 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 202: ifne 222\n 205: goto 264\n 208: new #15 // class Cell\n 211: dup\n 212: iconst_1\n 213: iconst_0\n 214: iconst_2\n 215: aconst_null\n 216: invokespecial #18 // Method Cell.\"<init>\":(IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 219: goto 277\n 222: new #15 // class Cell\n 225: dup\n 226: iconst_m1\n 227: iconst_0\n 228: iconst_2\n 229: aconst_null\n 230: invokespecial #18 // Method Cell.\"<init>\":(IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 233: goto 277\n 236: new #15 // class Cell\n 239: dup\n 240: iconst_0\n 241: iconst_1\n 242: iconst_1\n 243: aconst_null\n 244: invokespecial #18 // Method Cell.\"<init>\":(IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 247: goto 277\n 250: new #15 // class Cell\n 253: dup\n 254: iconst_0\n 255: iconst_m1\n 256: iconst_1\n 257: aconst_null\n 258: invokespecial #18 // Method Cell.\"<init>\":(IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 261: goto 277\n 264: new #71 // class java/lang/IllegalStateException\n 267: dup\n 268: ldc #73 // String incorrect input\n 270: invokevirtual #77 // Method java/lang/Object.toString:()Ljava/lang/String;\n 273: invokespecial #80 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 276: athrow\n 277: astore 8\n 279: iconst_0\n 280: istore 9\n 282: aload 7\n 284: invokestatic #86 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 287: istore 10\n 289: iload 9\n 291: iload 10\n 293: if_icmpge 31\n 296: aload_1\n 297: invokestatic #92 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 300: checkcast #15 // class Cell\n 303: aload 8\n 305: invokevirtual #96 // Method Cell.move:(LCell;)V\n 308: iconst_1\n 309: istore 11\n 311: aload_1\n 312: invokeinterface #99, 1 // InterfaceMethod java/util/List.size:()I\n 317: istore 12\n 319: iload 11\n 321: iload 12\n 323: if_icmpge 389\n 326: aload_1\n 327: iload 11\n 329: invokeinterface #54, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 334: checkcast #15 // class Cell\n 337: aload_1\n 338: iload 11\n 340: iconst_1\n 341: isub\n 342: invokeinterface #54, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 347: checkcast #15 // class Cell\n 350: invokevirtual #103 // Method Cell.isAttached:(LCell;)Z\n 353: ifne 383\n 356: aload_1\n 357: iload 11\n 359: invokeinterface #54, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 364: checkcast #15 // class Cell\n 367: aload_1\n 368: iload 11\n 370: iconst_1\n 371: isub\n 372: invokeinterface #54, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 377: checkcast #15 // class Cell\n 380: invokevirtual #106 // Method Cell.follow:(LCell;)V\n 383: iinc 11, 1\n 386: goto 319\n 389: aload_2\n 390: aload_1\n 391: invokestatic #109 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 394: checkcast #15 // class Cell\n 397: iconst_0\n 398: iconst_0\n 399: iconst_3\n 400: aconst_null\n 401: invokestatic #113 // Method Cell.copy$default:(LCell;IIILjava/lang/Object;)LCell;\n 404: invokevirtual #22 // Method java/util/HashSet.add:(Ljava/lang/Object;)Z\n 407: pop\n 408: iinc 9, 1\n 411: goto 289\n 414: aload_2\n 415: invokevirtual #114 // Method java/util/HashSet.size:()I\n 418: ireturn\n\n public static final void main();\n Code:\n 0: ldc #130 // String Day09_test\n 2: invokestatic #136 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #140 // Method main$part1:(Ljava/util/List;)I\n 10: bipush 13\n 12: if_icmpne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 33\n 23: new #71 // class java/lang/IllegalStateException\n 26: dup\n 27: ldc #142 // String Check failed.\n 29: invokespecial #80 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 32: athrow\n 33: aload_0\n 34: invokestatic #145 // Method main$part2:(Ljava/util/List;)I\n 37: iconst_1\n 38: if_icmpne 45\n 41: iconst_1\n 42: goto 46\n 45: iconst_0\n 46: ifne 59\n 49: new #71 // class java/lang/IllegalStateException\n 52: dup\n 53: ldc #142 // String Check failed.\n 55: invokespecial #80 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 58: athrow\n 59: ldc #147 // String Day09\n 61: invokestatic #136 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 64: astore_1\n 65: aload_1\n 66: invokestatic #140 // Method main$part1:(Ljava/util/List;)I\n 69: istore_2\n 70: getstatic #153 // Field java/lang/System.out:Ljava/io/PrintStream;\n 73: iload_2\n 74: invokevirtual #159 // Method java/io/PrintStream.println:(I)V\n 77: aload_1\n 78: invokestatic #145 // Method main$part2:(Ljava/util/List;)I\n 81: istore_2\n 82: getstatic #153 // Field java/lang/System.out:Ljava/io/PrintStream;\n 85: iload_2\n 86: invokevirtual #159 // Method java/io/PrintStream.println:(I)V\n 89: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #164 // 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: iconst_2\n 2: istore_1\n 3: astore 7\n 5: new #169 // class java/util/ArrayList\n 8: dup\n 9: iload_1\n 10: invokespecial #171 // Method java/util/ArrayList.\"<init>\":(I)V\n 13: astore_2\n 14: iconst_0\n 15: istore_3\n 16: iload_3\n 17: iload_1\n 18: if_icmpge 58\n 21: iload_3\n 22: istore 4\n 24: aload_2\n 25: iload 4\n 27: istore 5\n 29: astore 8\n 31: iconst_0\n 32: istore 6\n 34: new #15 // class Cell\n 37: dup\n 38: iconst_0\n 39: iconst_0\n 40: iconst_3\n 41: aconst_null\n 42: invokespecial #18 // Method Cell.\"<init>\":(IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 45: aload 8\n 47: swap\n 48: invokevirtual #172 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 51: pop\n 52: iinc 3, 1\n 55: goto 16\n 58: aload_2\n 59: checkcast #24 // class java/util/List\n 62: aload 7\n 64: swap\n 65: invokestatic #174 // Method moveTheRope:(Ljava/util/List;Ljava/util/List;)I\n 68: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: bipush 10\n 3: istore_1\n 4: astore 7\n 6: new #169 // class java/util/ArrayList\n 9: dup\n 10: iload_1\n 11: invokespecial #171 // Method java/util/ArrayList.\"<init>\":(I)V\n 14: astore_2\n 15: iconst_0\n 16: istore_3\n 17: iload_3\n 18: iload_1\n 19: if_icmpge 59\n 22: iload_3\n 23: istore 4\n 25: aload_2\n 26: iload 4\n 28: istore 5\n 30: astore 8\n 32: iconst_0\n 33: istore 6\n 35: new #15 // class Cell\n 38: dup\n 39: iconst_0\n 40: iconst_0\n 41: iconst_3\n 42: aconst_null\n 43: invokespecial #18 // Method Cell.\"<init>\":(IIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 46: aload 8\n 48: swap\n 49: invokevirtual #172 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 52: pop\n 53: iinc 3, 1\n 56: goto 17\n 59: aload_2\n 60: checkcast #24 // class java/util/List\n 63: aload 7\n 65: swap\n 66: invokestatic #174 // Method moveTheRope:(Ljava/util/List;Ljava/util/List;)I\n 69: ireturn\n}\n",
"javap_err": ""
}
] |
ShuffleZZZ__advent-of-code-kotlin__5a3cff1/src/Day08.kt
|
private fun getGrid(input: List<String>) = input.map { it.map(Char::digitToInt).toTypedArray() }.toTypedArray()
private fun observeLines(grid: Array<Array<Int>>, res: Array<BooleanArray>, lineInds: IntRange, rowInds: IntProgression) {
val maxRowInd = if (rowInds.isRange()) 0 else grid.first().size - 1
for (i in lineInds) {
var max = grid[i + 1][maxRowInd]
for (j in rowInds) {
if (grid[i + 1][j + 1] > max) {
res[i][j] = true
max = grid[i + 1][j + 1]
}
}
}
if (rowInds.isRange()) observeLines(grid, res, lineInds, rowInds.reversed())
}
private fun observeRows(grid: Array<Array<Int>>, res: Array<BooleanArray>, lineInds: IntProgression, rowInds: IntRange) {
val maxLineInd = if (lineInds.isRange()) 0 else grid.size - 1
for (j in rowInds) {
var max = grid[maxLineInd][j + 1]
for (i in lineInds) {
if (grid[i + 1][j + 1] > max) {
res[i][j] = true
max = grid[i + 1][j + 1]
}
}
}
if (lineInds.isRange()) observeRows(grid, res, lineInds.reversed(), rowInds)
}
private fun scenicScore(grid: Array<Array<Int>>, spot: Pair<Int, Int>) =
neighbours().map { observeTree(grid, spot, it) }.reduce(Int::times)
private fun observeTree(grid: Array<Array<Int>>, spot: Pair<Int, Int>, shift: Pair<Int, Int>): Int {
var dist = 0
var indexes = spot + shift
while (indexes.first in grid.indices && indexes.second in grid.first().indices) {
dist++
if (grid[indexes.first][indexes.second] >= grid[spot.first][spot.second]) break
indexes += shift
}
return dist
}
fun main() {
fun part1(input: List<String>): Int {
val grid = getGrid(input)
val n = grid.size
val m = grid.first().size
val res = Array(n - 2) { BooleanArray(m - 2) { false } }
observeLines(grid, res, res.indices, res.first().indices)
observeRows(grid, res, res.indices, res.first().indices)
return res.sumOf { it.count { e -> e } } + 2 * (n + m - 2)
}
fun part2(input: List<String>): Int {
val grid = getGrid(input)
val res = Array(grid.size - 2) { IntArray(grid.first().size - 2) { 0 } }
for (i in res.indices) {
for (j in res.indices) {
res[i][j] = scenicScore(grid, i + 1 to j + 1)
}
}
return res.maxOf { it.max() }
}
// 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))
}
|
[
{
"class_path": "ShuffleZZZ__advent-of-code-kotlin__5a3cff1/Day08Kt.class",
"javap": "Compiled from \"Day08.kt\"\npublic final class Day08Kt {\n private static final java.lang.Integer[][] getGrid(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #9 // 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 #11 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #23 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 213\n 48: aload 6\n 50: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #39 // 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 #41 // class java/lang/CharSequence\n 76: astore 10\n 78: iconst_0\n 79: istore 11\n 81: aload 10\n 83: astore 12\n 85: new #11 // class java/util/ArrayList\n 88: dup\n 89: aload 10\n 91: invokeinterface #45, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 96: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 99: checkcast #23 // class java/util/Collection\n 102: astore 13\n 104: iconst_0\n 105: istore 14\n 107: iconst_0\n 108: istore 15\n 110: iload 15\n 112: aload 12\n 114: invokeinterface #45, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 119: if_icmpge 167\n 122: aload 12\n 124: iload 15\n 126: invokeinterface #49, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 131: istore 16\n 133: aload 13\n 135: iload 16\n 137: istore 17\n 139: astore 18\n 141: iconst_0\n 142: istore 19\n 144: iload 17\n 146: invokestatic #55 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 149: invokestatic #61 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 152: aload 18\n 154: swap\n 155: invokeinterface #65, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 160: pop\n 161: iinc 15, 1\n 164: goto 110\n 167: aload 13\n 169: checkcast #67 // class java/util/List\n 172: nop\n 173: checkcast #23 // class java/util/Collection\n 176: astore 10\n 178: nop\n 179: iconst_0\n 180: istore 11\n 182: aload 10\n 184: astore 12\n 186: aload 12\n 188: iconst_0\n 189: anewarray #57 // class java/lang/Integer\n 192: invokeinterface #71, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 197: checkcast #73 // class \"[Ljava/lang/Integer;\"\n 200: nop\n 201: aload 20\n 203: swap\n 204: invokeinterface #65, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 209: pop\n 210: goto 38\n 213: aload 4\n 215: checkcast #67 // class java/util/List\n 218: nop\n 219: checkcast #23 // class java/util/Collection\n 222: astore_1\n 223: nop\n 224: iconst_0\n 225: istore_2\n 226: aload_1\n 227: astore_3\n 228: aload_3\n 229: iconst_0\n 230: anewarray #73 // class \"[Ljava/lang/Integer;\"\n 233: invokeinterface #71, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 238: checkcast #75 // class \"[[Ljava/lang/Integer;\"\n 241: areturn\n\n private static final void observeLines(java.lang.Integer[][], boolean[][], kotlin.ranges.IntRange, kotlin.ranges.IntProgression);\n Code:\n 0: aload_3\n 1: invokestatic #105 // Method UtilsKt.isRange:(Lkotlin/ranges/IntProgression;)Z\n 4: ifeq 11\n 7: iconst_0\n 8: goto 24\n 11: aload_0\n 12: checkcast #107 // class \"[Ljava/lang/Object;\"\n 15: invokestatic #113 // Method kotlin/collections/ArraysKt.first:([Ljava/lang/Object;)Ljava/lang/Object;\n 18: checkcast #107 // class \"[Ljava/lang/Object;\"\n 21: arraylength\n 22: iconst_1\n 23: isub\n 24: istore 4\n 26: aload_2\n 27: invokevirtual #118 // Method kotlin/ranges/IntRange.getFirst:()I\n 30: istore 5\n 32: aload_2\n 33: invokevirtual #121 // Method kotlin/ranges/IntRange.getLast:()I\n 36: istore 6\n 38: iload 5\n 40: iload 6\n 42: if_icmpgt 174\n 45: aload_0\n 46: iload 5\n 48: iconst_1\n 49: iadd\n 50: aaload\n 51: iload 4\n 53: aaload\n 54: invokevirtual #124 // Method java/lang/Integer.intValue:()I\n 57: istore 7\n 59: aload_3\n 60: invokevirtual #127 // Method kotlin/ranges/IntProgression.getFirst:()I\n 63: istore 8\n 65: aload_3\n 66: invokevirtual #128 // Method kotlin/ranges/IntProgression.getLast:()I\n 69: istore 9\n 71: aload_3\n 72: invokevirtual #131 // Method kotlin/ranges/IntProgression.getStep:()I\n 75: istore 10\n 77: iload 10\n 79: ifle 89\n 82: iload 8\n 84: iload 9\n 86: if_icmple 101\n 89: iload 10\n 91: ifge 161\n 94: iload 9\n 96: iload 8\n 98: if_icmpgt 161\n 101: aload_0\n 102: iload 5\n 104: iconst_1\n 105: iadd\n 106: aaload\n 107: iload 8\n 109: iconst_1\n 110: iadd\n 111: aaload\n 112: invokevirtual #124 // Method java/lang/Integer.intValue:()I\n 115: iload 7\n 117: if_icmple 144\n 120: aload_1\n 121: iload 5\n 123: aaload\n 124: iload 8\n 126: iconst_1\n 127: bastore\n 128: aload_0\n 129: iload 5\n 131: iconst_1\n 132: iadd\n 133: aaload\n 134: iload 8\n 136: iconst_1\n 137: iadd\n 138: aaload\n 139: invokevirtual #124 // Method java/lang/Integer.intValue:()I\n 142: istore 7\n 144: iload 8\n 146: iload 9\n 148: if_icmpeq 161\n 151: iload 8\n 153: iload 10\n 155: iadd\n 156: istore 8\n 158: goto 101\n 161: iload 5\n 163: iload 6\n 165: if_icmpeq 174\n 168: iinc 5, 1\n 171: goto 45\n 174: aload_3\n 175: invokestatic #105 // Method UtilsKt.isRange:(Lkotlin/ranges/IntProgression;)Z\n 178: ifeq 191\n 181: aload_0\n 182: aload_1\n 183: aload_2\n 184: aload_3\n 185: invokestatic #137 // Method kotlin/ranges/RangesKt.reversed:(Lkotlin/ranges/IntProgression;)Lkotlin/ranges/IntProgression;\n 188: invokestatic #139 // Method observeLines:([[Ljava/lang/Integer;[[ZLkotlin/ranges/IntRange;Lkotlin/ranges/IntProgression;)V\n 191: return\n\n private static final void observeRows(java.lang.Integer[][], boolean[][], kotlin.ranges.IntProgression, kotlin.ranges.IntRange);\n Code:\n 0: aload_2\n 1: invokestatic #105 // Method UtilsKt.isRange:(Lkotlin/ranges/IntProgression;)Z\n 4: ifeq 11\n 7: iconst_0\n 8: goto 18\n 11: aload_0\n 12: checkcast #107 // class \"[Ljava/lang/Object;\"\n 15: arraylength\n 16: iconst_1\n 17: isub\n 18: istore 4\n 20: aload_3\n 21: invokevirtual #118 // Method kotlin/ranges/IntRange.getFirst:()I\n 24: istore 5\n 26: aload_3\n 27: invokevirtual #121 // Method kotlin/ranges/IntRange.getLast:()I\n 30: istore 6\n 32: iload 5\n 34: iload 6\n 36: if_icmpgt 168\n 39: aload_0\n 40: iload 4\n 42: aaload\n 43: iload 5\n 45: iconst_1\n 46: iadd\n 47: aaload\n 48: invokevirtual #124 // Method java/lang/Integer.intValue:()I\n 51: istore 7\n 53: aload_2\n 54: invokevirtual #127 // Method kotlin/ranges/IntProgression.getFirst:()I\n 57: istore 8\n 59: aload_2\n 60: invokevirtual #128 // Method kotlin/ranges/IntProgression.getLast:()I\n 63: istore 9\n 65: aload_2\n 66: invokevirtual #131 // Method kotlin/ranges/IntProgression.getStep:()I\n 69: istore 10\n 71: iload 10\n 73: ifle 83\n 76: iload 8\n 78: iload 9\n 80: if_icmple 95\n 83: iload 10\n 85: ifge 155\n 88: iload 9\n 90: iload 8\n 92: if_icmpgt 155\n 95: aload_0\n 96: iload 8\n 98: iconst_1\n 99: iadd\n 100: aaload\n 101: iload 5\n 103: iconst_1\n 104: iadd\n 105: aaload\n 106: invokevirtual #124 // Method java/lang/Integer.intValue:()I\n 109: iload 7\n 111: if_icmple 138\n 114: aload_1\n 115: iload 8\n 117: aaload\n 118: iload 5\n 120: iconst_1\n 121: bastore\n 122: aload_0\n 123: iload 8\n 125: iconst_1\n 126: iadd\n 127: aaload\n 128: iload 5\n 130: iconst_1\n 131: iadd\n 132: aaload\n 133: invokevirtual #124 // Method java/lang/Integer.intValue:()I\n 136: istore 7\n 138: iload 8\n 140: iload 9\n 142: if_icmpeq 155\n 145: iload 8\n 147: iload 10\n 149: iadd\n 150: istore 8\n 152: goto 95\n 155: iload 5\n 157: iload 6\n 159: if_icmpeq 168\n 162: iinc 5, 1\n 165: goto 39\n 168: aload_2\n 169: invokestatic #105 // Method UtilsKt.isRange:(Lkotlin/ranges/IntProgression;)Z\n 172: ifeq 185\n 175: aload_0\n 176: aload_1\n 177: aload_2\n 178: invokestatic #137 // Method kotlin/ranges/RangesKt.reversed:(Lkotlin/ranges/IntProgression;)Lkotlin/ranges/IntProgression;\n 181: aload_3\n 182: invokestatic #155 // Method observeRows:([[Ljava/lang/Integer;[[ZLkotlin/ranges/IntProgression;Lkotlin/ranges/IntRange;)V\n 185: return\n\n private static final int scenicScore(java.lang.Integer[][], kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: invokestatic #163 // Method UtilsKt.neighbours:()Ljava/util/List;\n 3: checkcast #9 // class java/lang/Iterable\n 6: astore_2\n 7: iconst_0\n 8: istore_3\n 9: aload_2\n 10: astore 4\n 12: new #11 // class java/util/ArrayList\n 15: dup\n 16: aload_2\n 17: bipush 10\n 19: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 22: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 25: checkcast #23 // class java/util/Collection\n 28: astore 5\n 30: iconst_0\n 31: istore 6\n 33: aload 4\n 35: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 40: astore 7\n 42: aload 7\n 44: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 49: ifeq 97\n 52: aload 7\n 54: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 59: astore 8\n 61: aload 5\n 63: aload 8\n 65: checkcast #165 // class kotlin/Pair\n 68: astore 9\n 70: astore 11\n 72: iconst_0\n 73: istore 10\n 75: aload_0\n 76: aload_1\n 77: aload 9\n 79: invokestatic #169 // Method observeTree:([[Ljava/lang/Integer;Lkotlin/Pair;Lkotlin/Pair;)I\n 82: invokestatic #61 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 85: aload 11\n 87: swap\n 88: invokeinterface #65, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 93: pop\n 94: goto 42\n 97: aload 5\n 99: checkcast #67 // class java/util/List\n 102: nop\n 103: checkcast #9 // class java/lang/Iterable\n 106: astore_2\n 107: nop\n 108: iconst_0\n 109: istore_3\n 110: aload_2\n 111: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 116: astore 4\n 118: aload 4\n 120: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 125: ifne 138\n 128: new #171 // class java/lang/UnsupportedOperationException\n 131: dup\n 132: ldc #173 // String Empty collection can\\'t be reduced.\n 134: invokespecial #176 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 137: athrow\n 138: aload 4\n 140: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 145: astore 5\n 147: aload 4\n 149: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 154: ifeq 198\n 157: aload 5\n 159: aload 4\n 161: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 166: checkcast #178 // class java/lang/Number\n 169: invokevirtual #179 // Method java/lang/Number.intValue:()I\n 172: istore 6\n 174: checkcast #178 // class java/lang/Number\n 177: invokevirtual #179 // Method java/lang/Number.intValue:()I\n 180: istore 7\n 182: iconst_0\n 183: istore 8\n 185: iload 7\n 187: iload 6\n 189: imul\n 190: invokestatic #61 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 193: astore 5\n 195: goto 147\n 198: aload 5\n 200: checkcast #178 // class java/lang/Number\n 203: invokevirtual #179 // Method java/lang/Number.intValue:()I\n 206: ireturn\n\n private static final int observeTree(java.lang.Integer[][], kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: iconst_0\n 1: istore_3\n 2: aload_1\n 3: aload_2\n 4: invokestatic #194 // Method UtilsKt.plus:(Lkotlin/Pair;Lkotlin/Pair;)Lkotlin/Pair;\n 7: astore 4\n 9: aload_0\n 10: checkcast #107 // class \"[Ljava/lang/Object;\"\n 13: arraylength\n 14: istore 5\n 16: aload 4\n 18: invokevirtual #196 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 21: checkcast #178 // class java/lang/Number\n 24: invokevirtual #179 // Method java/lang/Number.intValue:()I\n 27: istore 6\n 29: iconst_0\n 30: iload 6\n 32: if_icmpgt 50\n 35: iload 6\n 37: iload 5\n 39: if_icmpge 46\n 42: iconst_1\n 43: goto 51\n 46: iconst_0\n 47: goto 51\n 50: iconst_0\n 51: ifeq 176\n 54: aload_0\n 55: checkcast #107 // class \"[Ljava/lang/Object;\"\n 58: invokestatic #113 // Method kotlin/collections/ArraysKt.first:([Ljava/lang/Object;)Ljava/lang/Object;\n 61: checkcast #107 // class \"[Ljava/lang/Object;\"\n 64: arraylength\n 65: istore 5\n 67: aload 4\n 69: invokevirtual #199 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 72: checkcast #178 // class java/lang/Number\n 75: invokevirtual #179 // Method java/lang/Number.intValue:()I\n 78: istore 6\n 80: iconst_0\n 81: iload 6\n 83: if_icmpgt 101\n 86: iload 6\n 88: iload 5\n 90: if_icmpge 97\n 93: iconst_1\n 94: goto 102\n 97: iconst_0\n 98: goto 102\n 101: iconst_0\n 102: ifeq 176\n 105: iinc 3, 1\n 108: aload_0\n 109: aload 4\n 111: invokevirtual #196 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 114: checkcast #178 // class java/lang/Number\n 117: invokevirtual #179 // Method java/lang/Number.intValue:()I\n 120: aaload\n 121: aload 4\n 123: invokevirtual #199 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 126: checkcast #178 // class java/lang/Number\n 129: invokevirtual #179 // Method java/lang/Number.intValue:()I\n 132: aaload\n 133: invokevirtual #124 // Method java/lang/Integer.intValue:()I\n 136: aload_0\n 137: aload_1\n 138: invokevirtual #196 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 141: checkcast #178 // class java/lang/Number\n 144: invokevirtual #179 // Method java/lang/Number.intValue:()I\n 147: aaload\n 148: aload_1\n 149: invokevirtual #199 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 152: checkcast #178 // class java/lang/Number\n 155: invokevirtual #179 // Method java/lang/Number.intValue:()I\n 158: aaload\n 159: invokevirtual #124 // Method java/lang/Integer.intValue:()I\n 162: if_icmpge 176\n 165: aload 4\n 167: aload_2\n 168: invokestatic #194 // Method UtilsKt.plus:(Lkotlin/Pair;Lkotlin/Pair;)Lkotlin/Pair;\n 171: astore 4\n 173: goto 9\n 176: iload_3\n 177: ireturn\n\n public static final void main();\n Code:\n 0: ldc #206 // String Day08_test\n 2: invokestatic #210 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #214 // Method main$part1:(Ljava/util/List;)I\n 10: bipush 21\n 12: if_icmpne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 33\n 23: new #216 // class java/lang/IllegalStateException\n 26: dup\n 27: ldc #218 // String Check failed.\n 29: invokespecial #219 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 32: athrow\n 33: aload_0\n 34: invokestatic #222 // Method main$part2:(Ljava/util/List;)I\n 37: bipush 8\n 39: if_icmpne 46\n 42: iconst_1\n 43: goto 47\n 46: iconst_0\n 47: ifne 60\n 50: new #216 // class java/lang/IllegalStateException\n 53: dup\n 54: ldc #218 // String Check failed.\n 56: invokespecial #219 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 59: athrow\n 60: ldc #224 // String Day08\n 62: invokestatic #210 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 65: astore_1\n 66: aload_1\n 67: invokestatic #214 // Method main$part1:(Ljava/util/List;)I\n 70: istore_2\n 71: getstatic #230 // Field java/lang/System.out:Ljava/io/PrintStream;\n 74: iload_2\n 75: invokevirtual #235 // Method java/io/PrintStream.println:(I)V\n 78: aload_1\n 79: invokestatic #222 // Method main$part2:(Ljava/util/List;)I\n 82: istore_2\n 83: getstatic #230 // Field java/lang/System.out:Ljava/io/PrintStream;\n 86: iload_2\n 87: invokevirtual #235 // Method java/io/PrintStream.println:(I)V\n 90: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #239 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #244 // Method getGrid:(Ljava/util/List;)[[Ljava/lang/Integer;\n 4: astore_1\n 5: aload_1\n 6: checkcast #107 // class \"[Ljava/lang/Object;\"\n 9: arraylength\n 10: istore_2\n 11: aload_1\n 12: checkcast #107 // class \"[Ljava/lang/Object;\"\n 15: invokestatic #113 // Method kotlin/collections/ArraysKt.first:([Ljava/lang/Object;)Ljava/lang/Object;\n 18: checkcast #107 // class \"[Ljava/lang/Object;\"\n 21: arraylength\n 22: istore_3\n 23: iconst_0\n 24: istore 5\n 26: iload_2\n 27: iconst_2\n 28: isub\n 29: istore 6\n 31: iload 6\n 33: anewarray #246 // class \"[Z\"\n 36: astore 7\n 38: iload 5\n 40: iload 6\n 42: if_icmpge 107\n 45: iload 5\n 47: istore 8\n 49: aload 7\n 51: iload 8\n 53: iconst_0\n 54: istore 9\n 56: iload_3\n 57: iconst_2\n 58: isub\n 59: istore 10\n 61: iload 10\n 63: newarray boolean\n 65: astore 11\n 67: istore 21\n 69: astore 20\n 71: iload 9\n 73: iload 10\n 75: if_icmpge 94\n 78: iload 9\n 80: istore 12\n 82: aload 11\n 84: iload 12\n 86: iconst_0\n 87: bastore\n 88: iinc 9, 1\n 91: goto 71\n 94: aload 20\n 96: iload 21\n 98: aload 11\n 100: aastore\n 101: iinc 5, 1\n 104: goto 38\n 107: aload 7\n 109: astore 4\n 111: aload_1\n 112: aload 4\n 114: aload 4\n 116: checkcast #107 // class \"[Ljava/lang/Object;\"\n 119: invokestatic #250 // Method kotlin/collections/ArraysKt.getIndices:([Ljava/lang/Object;)Lkotlin/ranges/IntRange;\n 122: aload 4\n 124: checkcast #107 // class \"[Ljava/lang/Object;\"\n 127: invokestatic #113 // Method kotlin/collections/ArraysKt.first:([Ljava/lang/Object;)Ljava/lang/Object;\n 130: checkcast #246 // class \"[Z\"\n 133: invokestatic #253 // Method kotlin/collections/ArraysKt.getIndices:([Z)Lkotlin/ranges/IntRange;\n 136: checkcast #126 // class kotlin/ranges/IntProgression\n 139: invokestatic #139 // Method observeLines:([[Ljava/lang/Integer;[[ZLkotlin/ranges/IntRange;Lkotlin/ranges/IntProgression;)V\n 142: aload_1\n 143: aload 4\n 145: aload 4\n 147: checkcast #107 // class \"[Ljava/lang/Object;\"\n 150: invokestatic #250 // Method kotlin/collections/ArraysKt.getIndices:([Ljava/lang/Object;)Lkotlin/ranges/IntRange;\n 153: checkcast #126 // class kotlin/ranges/IntProgression\n 156: aload 4\n 158: checkcast #107 // class \"[Ljava/lang/Object;\"\n 161: invokestatic #113 // Method kotlin/collections/ArraysKt.first:([Ljava/lang/Object;)Ljava/lang/Object;\n 164: checkcast #246 // class \"[Z\"\n 167: invokestatic #253 // Method kotlin/collections/ArraysKt.getIndices:([Z)Lkotlin/ranges/IntRange;\n 170: invokestatic #155 // Method observeRows:([[Ljava/lang/Integer;[[ZLkotlin/ranges/IntProgression;Lkotlin/ranges/IntRange;)V\n 173: aload 4\n 175: checkcast #107 // class \"[Ljava/lang/Object;\"\n 178: astore 5\n 180: iconst_0\n 181: istore 6\n 183: iconst_0\n 184: istore 7\n 186: aload 5\n 188: arraylength\n 189: istore 8\n 191: iload 7\n 193: iload 8\n 195: if_icmpge 290\n 198: aload 5\n 200: iload 7\n 202: aaload\n 203: astore 9\n 205: iload 6\n 207: aload 9\n 209: checkcast #246 // class \"[Z\"\n 212: astore 10\n 214: istore 20\n 216: iconst_0\n 217: istore 11\n 219: aload 10\n 221: astore 12\n 223: iconst_0\n 224: istore 13\n 226: iconst_0\n 227: istore 14\n 229: iconst_0\n 230: istore 15\n 232: aload 12\n 234: arraylength\n 235: istore 16\n 237: iload 15\n 239: iload 16\n 241: if_icmpge 272\n 244: aload 12\n 246: iload 15\n 248: baload\n 249: istore 17\n 251: iload 17\n 253: istore 18\n 255: iconst_0\n 256: istore 19\n 258: iload 18\n 260: ifeq 266\n 263: iinc 14, 1\n 266: iinc 15, 1\n 269: goto 237\n 272: iload 14\n 274: nop\n 275: istore 21\n 277: iload 20\n 279: iload 21\n 281: iadd\n 282: istore 6\n 284: iinc 7, 1\n 287: goto 191\n 290: iload 6\n 292: iconst_2\n 293: iload_2\n 294: iload_3\n 295: iadd\n 296: iconst_2\n 297: isub\n 298: imul\n 299: iadd\n 300: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #244 // Method getGrid:(Ljava/util/List;)[[Ljava/lang/Integer;\n 4: astore_1\n 5: iconst_0\n 6: istore_3\n 7: aload_1\n 8: checkcast #107 // class \"[Ljava/lang/Object;\"\n 11: arraylength\n 12: iconst_2\n 13: isub\n 14: istore 4\n 16: iload 4\n 18: anewarray #265 // class \"[I\"\n 21: astore 5\n 23: iload_3\n 24: iload 4\n 26: if_icmpge 100\n 29: iload_3\n 30: istore 6\n 32: aload 5\n 34: iload 6\n 36: iconst_0\n 37: istore 7\n 39: aload_1\n 40: checkcast #107 // class \"[Ljava/lang/Object;\"\n 43: invokestatic #113 // Method kotlin/collections/ArraysKt.first:([Ljava/lang/Object;)Ljava/lang/Object;\n 46: checkcast #107 // class \"[Ljava/lang/Object;\"\n 49: arraylength\n 50: iconst_2\n 51: isub\n 52: istore 8\n 54: iload 8\n 56: newarray int\n 58: astore 9\n 60: istore 12\n 62: astore 11\n 64: iload 7\n 66: iload 8\n 68: if_icmpge 87\n 71: iload 7\n 73: istore 10\n 75: aload 9\n 77: iload 10\n 79: iconst_0\n 80: iastore\n 81: iinc 7, 1\n 84: goto 64\n 87: aload 11\n 89: iload 12\n 91: aload 9\n 93: aastore\n 94: iinc 3, 1\n 97: goto 23\n 100: aload 5\n 102: astore_2\n 103: iconst_0\n 104: istore_3\n 105: aload_2\n 106: checkcast #107 // class \"[Ljava/lang/Object;\"\n 109: arraylength\n 110: istore 4\n 112: iload_3\n 113: iload 4\n 115: if_icmpge 173\n 118: iconst_0\n 119: istore 5\n 121: aload_2\n 122: checkcast #107 // class \"[Ljava/lang/Object;\"\n 125: arraylength\n 126: istore 6\n 128: iload 5\n 130: iload 6\n 132: if_icmpge 167\n 135: aload_2\n 136: iload_3\n 137: aaload\n 138: iload 5\n 140: aload_1\n 141: iload_3\n 142: iconst_1\n 143: iadd\n 144: invokestatic #61 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 147: iload 5\n 149: iconst_1\n 150: iadd\n 151: invokestatic #61 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 154: invokestatic #271 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 157: invokestatic #273 // Method scenicScore:([[Ljava/lang/Integer;Lkotlin/Pair;)I\n 160: iastore\n 161: iinc 5, 1\n 164: goto 128\n 167: iinc 3, 1\n 170: goto 112\n 173: aload_2\n 174: checkcast #107 // class \"[Ljava/lang/Object;\"\n 177: astore_3\n 178: aload_3\n 179: arraylength\n 180: ifne 187\n 183: iconst_1\n 184: goto 188\n 187: iconst_0\n 188: ifeq 199\n 191: new #275 // class java/util/NoSuchElementException\n 194: dup\n 195: invokespecial #277 // Method java/util/NoSuchElementException.\"<init>\":()V\n 198: athrow\n 199: aload_3\n 200: iconst_0\n 201: aaload\n 202: checkcast #265 // class \"[I\"\n 205: astore 4\n 207: iconst_0\n 208: istore 5\n 210: aload 4\n 212: invokestatic #281 // Method kotlin/collections/ArraysKt.maxOrThrow:([I)I\n 215: istore 4\n 217: iconst_1\n 218: istore 5\n 220: aload_3\n 221: invokestatic #285 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I\n 224: istore 6\n 226: iload 5\n 228: iload 6\n 230: if_icmpgt 276\n 233: aload_3\n 234: iload 5\n 236: aaload\n 237: checkcast #265 // class \"[I\"\n 240: astore 7\n 242: iconst_0\n 243: istore 8\n 245: aload 7\n 247: invokestatic #281 // Method kotlin/collections/ArraysKt.maxOrThrow:([I)I\n 250: istore 7\n 252: iload 4\n 254: iload 7\n 256: if_icmpge 263\n 259: iload 7\n 261: istore 4\n 263: iload 5\n 265: iload 6\n 267: if_icmpeq 276\n 270: iinc 5, 1\n 273: goto 233\n 276: iload 4\n 278: ireturn\n}\n",
"javap_err": ""
}
] |
Kirchberg__BigDataPL__b6a459a/LR6/src/main/kotlin/Task2V1.kt
|
// Списки (стеки, очереди) I(1..n) и U(1..n) содержат результаты n измерений тока и напряжения на неизвестном
// сопротивлении R. Найти приближенное число R методом наименьших квадратов.
import kotlin.math.pow
// Create a class LeastSquaresR that takes two lists of measurements, currents, and voltages
class LeastSquaresR(private val currents: List<Double>, private val voltages: List<Double>) {
// Check if the input lists have the same size
init {
require(currents.size == voltages.size) { "Currents and voltages lists must have the same size" }
}
// Implement a method that calculates the least squares approximation of R based on the input data
fun calculateR(): Double {
// Calculate the sum of the product of each current and voltage measurement
val sumIU = currents.zip(voltages) { i, u -> i * u }.sum()
// Calculate the sum of the square of each current measurement
val sumISquared = currents.map { it.pow(2) }.sum()
// Calculate the number of measurements
val n = currents.size
// Calculate the approximate value of the unknown resistance R using the least squares method
val r = sumIU / sumISquared
return r
}
}
fun task2V1() {
// Provide sample data: two lists of current and voltage measurements
val currents = listOf(0.5, 1.0, 1.5, 2.0, 2.5)
val voltages = listOf(1.0, 2.1, 3.1, 4.1, 5.0)
// Create a LeastSquaresR object with the sample data
val leastSquaresR = LeastSquaresR(currents, voltages)
// Calculate the approximate value of the unknown resistance R
val r = leastSquaresR.calculateR()
// Print the result
println("The approximate value of the unknown resistance R is: $r Ω")
}
|
[
{
"class_path": "Kirchberg__BigDataPL__b6a459a/Task2V1Kt.class",
"javap": "Compiled from \"Task2V1.kt\"\npublic final class Task2V1Kt {\n public static final void task2V1();\n Code:\n 0: iconst_5\n 1: anewarray #8 // class java/lang/Double\n 4: astore_1\n 5: aload_1\n 6: iconst_0\n 7: ldc2_w #9 // double 0.5d\n 10: invokestatic #14 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 13: aastore\n 14: aload_1\n 15: iconst_1\n 16: dconst_1\n 17: invokestatic #14 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 20: aastore\n 21: aload_1\n 22: iconst_2\n 23: ldc2_w #15 // double 1.5d\n 26: invokestatic #14 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 29: aastore\n 30: aload_1\n 31: iconst_3\n 32: ldc2_w #17 // double 2.0d\n 35: invokestatic #14 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 38: aastore\n 39: aload_1\n 40: iconst_4\n 41: ldc2_w #19 // double 2.5d\n 44: invokestatic #14 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\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: iconst_5\n 54: anewarray #8 // class java/lang/Double\n 57: astore_2\n 58: aload_2\n 59: iconst_0\n 60: dconst_1\n 61: invokestatic #14 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 64: aastore\n 65: aload_2\n 66: iconst_1\n 67: ldc2_w #27 // double 2.1d\n 70: invokestatic #14 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 73: aastore\n 74: aload_2\n 75: iconst_2\n 76: ldc2_w #29 // double 3.1d\n 79: invokestatic #14 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 82: aastore\n 83: aload_2\n 84: iconst_3\n 85: ldc2_w #31 // double 4.1d\n 88: invokestatic #14 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 91: aastore\n 92: aload_2\n 93: iconst_4\n 94: ldc2_w #33 // double 5.0d\n 97: invokestatic #14 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\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: new #36 // class LeastSquaresR\n 109: dup\n 110: aload_0\n 111: aload_1\n 112: invokespecial #40 // Method LeastSquaresR.\"<init>\":(Ljava/util/List;Ljava/util/List;)V\n 115: astore_2\n 116: aload_2\n 117: invokevirtual #44 // Method LeastSquaresR.calculateR:()D\n 120: dstore_3\n 121: new #46 // class java/lang/StringBuilder\n 124: dup\n 125: invokespecial #48 // Method java/lang/StringBuilder.\"<init>\":()V\n 128: ldc #50 // String The approximate value of the unknown resistance R is:\n 130: invokevirtual #54 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 133: dload_3\n 134: invokevirtual #57 // Method java/lang/StringBuilder.append:(D)Ljava/lang/StringBuilder;\n 137: ldc #59 // String Ω\n 139: invokevirtual #54 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 142: invokevirtual #63 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 145: getstatic #69 // Field java/lang/System.out:Ljava/io/PrintStream;\n 148: swap\n 149: invokevirtual #75 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 152: return\n}\n",
"javap_err": ""
}
] |
Kirchberg__BigDataPL__b6a459a/LR7/src/main/kotlin/Task1V3.kt
|
// В тексте нет слов, начинающихся одинаковыми буквами. Напечатать слова текста в таком порядке, чтобы последняя буква
// каждого слова совпадала с первой буквой последующего слова. Если все слова нельзя напечатать в таком порядке, найти
// такую цепочку, состоящую из наибольшего количества слов.
// The WordChainFinder class takes a list of words and finds the longest word chain
class WordChainFinder(private val words: List<String>) {
// A recursive method to find a word chain given a current chain and a list of remaining words
private fun findWordChain(currentChain: List<String>, remainingWords: List<String>): List<String> {
// If there are no remaining words, return the current chain
if (remainingWords.isEmpty()) {
return currentChain
}
// Get the last letter of the last word in the current chain
val lastLetter = currentChain.last().last()
// Find the candidate words in the remaining words that start with the last letter of the current chain
val candidates = remainingWords.filter { it.first() == lastLetter }
// If there are no candidates, return the current chain
if (candidates.isEmpty()) {
return currentChain
}
// For each candidate word, extend the current chain with the candidate and remove it from the remaining words
val chains = candidates.map { candidate ->
val newRemainingWords = remainingWords.toMutableList().apply { remove(candidate) }
findWordChain(currentChain + candidate, newRemainingWords)
}
// Return the longest chain found among the chains extended with the candidates
return chains.maxByOrNull { it.size } ?: currentChain
}
// The findLongestWordChain method finds the longest word chain by starting a search from each word in the list
fun findLongestWordChain(): List<String> {
return words.map { word ->
val remainingWords = words.toMutableList().apply { remove(word) }
findWordChain(listOf(word), remainingWords)
}.maxByOrNull { it.size } ?: emptyList()
}
}
fun task1V3() {
// Provide an example input text
val text = "java android kotlin rust"
// Split the input text into words
val words = text.split(" ")
// Create a WordChainFinder object with the list of words
val wordChainFinder = WordChainFinder(words)
// Call the findLongestWordChain method to find the longest chain of words
val longestWordChain = wordChainFinder.findLongestWordChain()
// Print the longest word chain to the console
println("Longest word chain: ${longestWordChain.joinToString(", ")}")
}
|
[
{
"class_path": "Kirchberg__BigDataPL__b6a459a/Task1V3Kt.class",
"javap": "Compiled from \"Task1V3.kt\"\npublic final class Task1V3Kt {\n public static final void task1V3();\n Code:\n 0: ldc #8 // String java android kotlin rust\n 2: astore_0\n 3: aload_0\n 4: checkcast #10 // class java/lang/CharSequence\n 7: iconst_1\n 8: anewarray #12 // class java/lang/String\n 11: astore_2\n 12: aload_2\n 13: iconst_0\n 14: ldc #14 // String\n 16: aastore\n 17: aload_2\n 18: iconst_0\n 19: iconst_0\n 20: bipush 6\n 22: aconst_null\n 23: invokestatic #20 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 26: astore_1\n 27: new #22 // class WordChainFinder\n 30: dup\n 31: aload_1\n 32: invokespecial #26 // Method WordChainFinder.\"<init>\":(Ljava/util/List;)V\n 35: astore_2\n 36: aload_2\n 37: invokevirtual #30 // Method WordChainFinder.findLongestWordChain:()Ljava/util/List;\n 40: astore_3\n 41: new #32 // class java/lang/StringBuilder\n 44: dup\n 45: invokespecial #34 // Method java/lang/StringBuilder.\"<init>\":()V\n 48: ldc #36 // String Longest word chain:\n 50: invokevirtual #40 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 53: aload_3\n 54: checkcast #42 // class java/lang/Iterable\n 57: ldc #44 // String ,\n 59: checkcast #10 // class java/lang/CharSequence\n 62: aconst_null\n 63: aconst_null\n 64: iconst_0\n 65: aconst_null\n 66: aconst_null\n 67: bipush 62\n 69: aconst_null\n 70: invokestatic #50 // 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 73: invokevirtual #40 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 76: invokevirtual #54 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 79: getstatic #60 // Field java/lang/System.out:Ljava/io/PrintStream;\n 82: swap\n 83: invokevirtual #66 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 86: return\n}\n",
"javap_err": ""
}
] |
austin226__codeforces-kt__4377021/contest1904/src/main/kotlin/D1.kt
|
// https://codeforces.com/contest/1904/problem/D1
private fun String.splitWhitespace() = split("\\s+".toRegex())
private fun readInt(): Int = readln().toInt()
private fun readInts(): List<Int> = readln().splitWhitespace().map { it.toInt() }
fun canABecomeB(n: Int, a: MutableList<Int>, b: List<Int>): Boolean {
// If any b[i] < a[a], return false
if ((0..<n).any { i -> b[i] < a[i] }) {
return false
}
for (g in 0..n) {
for (i in 0..<n) {
if (b[i] == g && a[i] < g) {
// Find an l to the left
var l = i
while (l > 0 && a[l - 1] <= g && b[l - 1] >= g) {
l--
}
// Find r
var r = i
while (r < n - 1 && a[r + 1] <= g && b[r + 1] >= g) {
r++
}
if (!(l..r).any { j -> a[j] == g }) {
return false
}
for (j in l..r) {
a[j] = g
}
}
}
}
return a == b
}
fun main() {
val t = readInt()
(0..<t).forEach { _ ->
val n = readInt()
val a = readInts().toMutableList()
val b = readInts()
// operation: Choose l and r, where 1 <= l <= r <= n
// let x = max(a[l]..a[r])
// Set all a[l]..a[r] to max
// Output YES if a can become b with any number of operations
// Output NO if not
if (canABecomeB(n, a, b)) {
println("YES")
} else {
println("NO")
}
}
}
|
[
{
"class_path": "austin226__codeforces-kt__4377021/D1Kt.class",
"javap": "Compiled from \"D1.kt\"\npublic final class D1Kt {\n private static final java.util.List<java.lang.String> splitWhitespace(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #9 // class java/lang/CharSequence\n 4: astore_1\n 5: new #11 // class kotlin/text/Regex\n 8: dup\n 9: ldc #13 // String \\\\s+\n 11: invokespecial #17 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 14: astore_2\n 15: iconst_0\n 16: istore_3\n 17: aload_2\n 18: aload_1\n 19: iload_3\n 20: invokevirtual #21 // Method kotlin/text/Regex.split:(Ljava/lang/CharSequence;I)Ljava/util/List;\n 23: areturn\n\n private static final int readInt();\n Code:\n 0: invokestatic #31 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;\n 3: invokestatic #37 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 6: ireturn\n\n private static final java.util.List<java.lang.Integer> readInts();\n Code:\n 0: invokestatic #31 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;\n 3: invokestatic #42 // Method splitWhitespace:(Ljava/lang/String;)Ljava/util/List;\n 6: checkcast #44 // class java/lang/Iterable\n 9: astore_0\n 10: iconst_0\n 11: istore_1\n 12: aload_0\n 13: astore_2\n 14: new #46 // class java/util/ArrayList\n 17: dup\n 18: aload_0\n 19: bipush 10\n 21: invokestatic #52 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 24: invokespecial #55 // Method java/util/ArrayList.\"<init>\":(I)V\n 27: checkcast #57 // class java/util/Collection\n 30: astore_3\n 31: iconst_0\n 32: istore 4\n 34: aload_2\n 35: invokeinterface #61, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 40: astore 5\n 42: aload 5\n 44: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 49: ifeq 95\n 52: aload 5\n 54: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 59: astore 6\n 61: aload_3\n 62: aload 6\n 64: checkcast #73 // class java/lang/String\n 67: astore 7\n 69: astore 9\n 71: iconst_0\n 72: istore 8\n 74: aload 7\n 76: invokestatic #37 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 79: nop\n 80: invokestatic #77 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 83: aload 9\n 85: swap\n 86: invokeinterface #81, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 91: pop\n 92: goto 42\n 95: aload_3\n 96: checkcast #83 // class java/util/List\n 99: nop\n 100: areturn\n\n public static final boolean canABecomeB(int, java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>);\n Code:\n 0: aload_1\n 1: ldc #101 // String a\n 3: invokestatic #107 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #109 // String b\n 9: invokestatic #107 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: iconst_0\n 13: iload_0\n 14: invokestatic #115 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 17: checkcast #44 // class java/lang/Iterable\n 20: astore_3\n 21: iconst_0\n 22: istore 4\n 24: aload_3\n 25: instanceof #57 // class java/util/Collection\n 28: ifeq 47\n 31: aload_3\n 32: checkcast #57 // class java/util/Collection\n 35: invokeinterface #118, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 40: ifeq 47\n 43: iconst_0\n 44: goto 126\n 47: aload_3\n 48: invokeinterface #61, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 53: astore 5\n 55: aload 5\n 57: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 62: ifeq 125\n 65: aload 5\n 67: checkcast #120 // class kotlin/collections/IntIterator\n 70: invokevirtual #123 // Method kotlin/collections/IntIterator.nextInt:()I\n 73: istore 6\n 75: iload 6\n 77: istore 7\n 79: iconst_0\n 80: istore 8\n 82: aload_2\n 83: iload 7\n 85: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 90: checkcast #129 // class java/lang/Number\n 93: invokevirtual #132 // Method java/lang/Number.intValue:()I\n 96: aload_1\n 97: iload 7\n 99: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 104: checkcast #129 // class java/lang/Number\n 107: invokevirtual #132 // Method java/lang/Number.intValue:()I\n 110: if_icmpge 117\n 113: iconst_1\n 114: goto 118\n 117: iconst_0\n 118: ifeq 55\n 121: iconst_1\n 122: goto 126\n 125: iconst_0\n 126: ifeq 131\n 129: iconst_0\n 130: ireturn\n 131: iconst_0\n 132: istore_3\n 133: iload_3\n 134: iload_0\n 135: if_icmpgt 470\n 138: iconst_0\n 139: istore 4\n 141: iload 4\n 143: iload_0\n 144: if_icmpge 459\n 147: aload_2\n 148: iload 4\n 150: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 155: checkcast #129 // class java/lang/Number\n 158: invokevirtual #132 // Method java/lang/Number.intValue:()I\n 161: iload_3\n 162: if_icmpne 453\n 165: aload_1\n 166: iload 4\n 168: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 173: checkcast #129 // class java/lang/Number\n 176: invokevirtual #132 // Method java/lang/Number.intValue:()I\n 179: iload_3\n 180: if_icmpge 453\n 183: iload 4\n 185: istore 5\n 187: iload 5\n 189: ifle 238\n 192: aload_1\n 193: iload 5\n 195: iconst_1\n 196: isub\n 197: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 202: checkcast #129 // class java/lang/Number\n 205: invokevirtual #132 // Method java/lang/Number.intValue:()I\n 208: iload_3\n 209: if_icmpgt 238\n 212: aload_2\n 213: iload 5\n 215: iconst_1\n 216: isub\n 217: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 222: checkcast #129 // class java/lang/Number\n 225: invokevirtual #132 // Method java/lang/Number.intValue:()I\n 228: iload_3\n 229: if_icmplt 238\n 232: iinc 5, -1\n 235: goto 187\n 238: iload 4\n 240: istore 6\n 242: iload 6\n 244: iload_0\n 245: iconst_1\n 246: isub\n 247: if_icmpge 296\n 250: aload_1\n 251: iload 6\n 253: iconst_1\n 254: iadd\n 255: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 260: checkcast #129 // class java/lang/Number\n 263: invokevirtual #132 // Method java/lang/Number.intValue:()I\n 266: iload_3\n 267: if_icmpgt 296\n 270: aload_2\n 271: iload 6\n 273: iconst_1\n 274: iadd\n 275: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 280: checkcast #129 // class java/lang/Number\n 283: invokevirtual #132 // Method java/lang/Number.intValue:()I\n 286: iload_3\n 287: if_icmplt 296\n 290: iinc 6, 1\n 293: goto 242\n 296: new #134 // class kotlin/ranges/IntRange\n 299: dup\n 300: iload 5\n 302: iload 6\n 304: invokespecial #137 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 307: checkcast #44 // class java/lang/Iterable\n 310: astore 7\n 312: iconst_0\n 313: istore 8\n 315: aload 7\n 317: instanceof #57 // class java/util/Collection\n 320: ifeq 340\n 323: aload 7\n 325: checkcast #57 // class java/util/Collection\n 328: invokeinterface #118, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 333: ifeq 340\n 336: iconst_0\n 337: goto 407\n 340: aload 7\n 342: invokeinterface #61, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 347: astore 9\n 349: aload 9\n 351: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 356: ifeq 406\n 359: aload 9\n 361: checkcast #120 // class kotlin/collections/IntIterator\n 364: invokevirtual #123 // Method kotlin/collections/IntIterator.nextInt:()I\n 367: istore 10\n 369: iload 10\n 371: istore 11\n 373: iconst_0\n 374: istore 12\n 376: aload_1\n 377: iload 11\n 379: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 384: checkcast #129 // class java/lang/Number\n 387: invokevirtual #132 // Method java/lang/Number.intValue:()I\n 390: iload_3\n 391: if_icmpne 398\n 394: iconst_1\n 395: goto 399\n 398: iconst_0\n 399: ifeq 349\n 402: iconst_1\n 403: goto 407\n 406: iconst_0\n 407: ifne 412\n 410: iconst_0\n 411: ireturn\n 412: iload 5\n 414: istore 7\n 416: iload 6\n 418: istore 8\n 420: iload 7\n 422: iload 8\n 424: if_icmpgt 453\n 427: aload_1\n 428: iload 7\n 430: iload_3\n 431: invokestatic #77 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 434: invokeinterface #141, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 439: pop\n 440: iload 7\n 442: iload 8\n 444: if_icmpeq 453\n 447: iinc 7, 1\n 450: goto 427\n 453: iinc 4, 1\n 456: goto 141\n 459: iload_3\n 460: iload_0\n 461: if_icmpeq 470\n 464: iinc 3, 1\n 467: goto 138\n 470: aload_1\n 471: aload_2\n 472: invokestatic #145 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 475: ireturn\n\n public static final void main();\n Code:\n 0: invokestatic #161 // Method readInt:()I\n 3: istore_0\n 4: iconst_0\n 5: iload_0\n 6: invokestatic #115 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 9: checkcast #44 // class java/lang/Iterable\n 12: astore_1\n 13: iconst_0\n 14: istore_2\n 15: aload_1\n 16: invokeinterface #61, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 21: astore_3\n 22: aload_3\n 23: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 28: ifeq 102\n 31: aload_3\n 32: checkcast #120 // class kotlin/collections/IntIterator\n 35: invokevirtual #123 // Method kotlin/collections/IntIterator.nextInt:()I\n 38: istore 4\n 40: iconst_0\n 41: istore 5\n 43: invokestatic #161 // Method readInt:()I\n 46: istore 6\n 48: invokestatic #163 // Method readInts:()Ljava/util/List;\n 51: checkcast #57 // class java/util/Collection\n 54: invokestatic #167 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 57: astore 7\n 59: invokestatic #163 // Method readInts:()Ljava/util/List;\n 62: astore 8\n 64: iload 6\n 66: aload 7\n 68: aload 8\n 70: invokestatic #169 // Method canABecomeB:(ILjava/util/List;Ljava/util/List;)Z\n 73: ifeq 88\n 76: ldc #171 // String YES\n 78: getstatic #177 // Field java/lang/System.out:Ljava/io/PrintStream;\n 81: swap\n 82: invokevirtual #183 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 85: goto 97\n 88: ldc #185 // String NO\n 90: getstatic #177 // Field java/lang/System.out:Ljava/io/PrintStream;\n 93: swap\n 94: invokevirtual #183 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 97: nop\n 98: nop\n 99: goto 22\n 102: nop\n 103: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #192 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.