fun main() {
    val input = readInput("Day12")
    printTime { println(Day12.part1(input)) }
    printTime { println(Day12.part2(input)) }
}

class Day12 {
    companion object {
        fun part1(input: List<String>): Int {
            val (end, start) = input.toHeightGraph()
            return end.getShortestPathBfs { it == start }
        }

        fun part2(input: List<String>): Int {
            val (end) = input.toHeightGraph()
            return end.getShortestPathBfs { it.height == 0 }
        }
    }

}

class Node(val height: Int, val neighbors: MutableList<Node> = mutableListOf()) {
    var distance = 0

    fun getShortestPathBfs(isDestination: (Node) -> Boolean): Int {
        val queue: ArrayDeque<Node> = ArrayDeque()
        val visited = mutableSetOf(this)
        queue.add(this)

        while (queue.isNotEmpty()) {
            val node = queue.removeFirst()
            if (isDestination(node)) return node.distance
            node.neighbors.filter { it.height >= node.height - 1 }.filter { it !in visited }.forEach {
                it.distance = node.distance + 1
                queue.add(it)
                visited.add(it)
            }
        }
        throw IllegalStateException("Could not find a path to the target node")
    }

    //private fun getShortestPathDfs(from: Node, to: Node, path: List<Node> = listOf()): Long {
    //    if (from == to) {
    //        return 0L
    //    }
    //    val validPaths = from.neighbors.filter { !path.contains(it) }
    //    if (validPaths.isNotEmpty()) {
    //        return validPaths.minOf { 1L + getShortestPathDfs(it, to, listOf(*path.toTypedArray(), from)) }
    //    }
    //    return Int.MAX_VALUE.toLong()
    //}
}

fun List<String>.toHeightGraph(): List<Node> {
    var start = Node(0)
    var end = Node(0)
    val nodes: List<List<Node>> = this.map {
        it.toCharArray().map { height ->
            val newNode: Node
            when (height) {
                'S' -> {
                    newNode = Node(0)
                    start = newNode
                }

                'E' -> {
                    newNode = Node('z' - 'a')
                    end = newNode
                }

                else -> newNode = Node(height - 'a')
            }
            newNode
        }
    }
    nodes.matrixForEachIndexed { i, j, _ ->
        if (i > 0) {
            nodes[i][j].neighbors.add(nodes[i - 1][j])
        }
        if (i < nodes.lastIndex) {
            nodes[i][j].neighbors.add(nodes[i + 1][j])
        }
        if (j > 0) {
            nodes[i][j].neighbors.add(nodes[i][j - 1])
        }
        if (j < nodes[i].lastIndex) {
            nodes[i][j].neighbors.add(nodes[i][j + 1])
        }
    }
    return listOf(end, start)
}

Compiled from "Day12.kt"
public final class Day12$Companion {
  private Day12$Companion();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int part1(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokestatic  #28                 // Method Day12Kt.toHeightGraph:(Ljava/util/List;)Ljava/util/List;
      10: astore_2
      11: aload_2
      12: iconst_0
      13: invokeinterface #34,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      18: checkcast     #36                 // class Node
      21: astore_3
      22: aload_2
      23: iconst_1
      24: invokeinterface #34,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      29: checkcast     #36                 // class Node
      32: astore        4
      34: aload_3
      35: aload         4
      37: invokedynamic #56,  0             // InvokeDynamic #0:invoke:(LNode;)Lkotlin/jvm/functions/Function1;
      42: invokevirtual #60                 // Method Node.getShortestPathBfs:(Lkotlin/jvm/functions/Function1;)I
      45: ireturn

  public final int part2(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokestatic  #28                 // Method Day12Kt.toHeightGraph:(Ljava/util/List;)Ljava/util/List;
      10: iconst_0
      11: invokeinterface #34,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      16: checkcast     #36                 // class Node
      19: astore_2
      20: aload_2
      21: invokedynamic #73,  0             // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
      26: invokevirtual #60                 // Method Node.getShortestPathBfs:(Lkotlin/jvm/functions/Function1;)I
      29: ireturn

  private static final boolean part1$lambda$0(Node, Node);
    Code:
       0: aload_1
       1: ldc           #75                 // String it
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: aload_0
       8: invokestatic  #79                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      11: ireturn

  private static final boolean part2$lambda$1(Node);
    Code:
       0: aload_0
       1: ldc           #75                 // String it
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #84                 // Method Node.getHeight:()I
      10: ifne          17
      13: iconst_1
      14: goto          18
      17: iconst_0
      18: ireturn

  public Day12$Companion(kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: aload_0
       1: invokespecial #86                 // Method "<init>":()V
       4: return
}

Compiled from "Day12.kt"
public final class Day12 {
  public static final Day12$Companion Companion;

  public Day12();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  static {};
    Code:
       0: new           #13                 // class Day12$Companion
       3: dup
       4: aconst_null
       5: invokespecial #16                 // Method Day12$Companion."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: putstatic     #20                 // Field Companion:LDay12$Companion;
      11: return
}

Compiled from "Day12.kt"
public final class Day12Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day12
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aconst_null
       7: aconst_null
       8: aload_0
       9: invokedynamic #34,  0             // InvokeDynamic #0:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function0;
      14: iconst_3
      15: aconst_null
      16: invokestatic  #38                 // Method UtilsKt.printTime$default:(Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)V
      19: aconst_null
      20: aconst_null
      21: aload_0
      22: invokedynamic #43,  0             // InvokeDynamic #1:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function0;
      27: iconst_3
      28: aconst_null
      29: invokestatic  #38                 // Method UtilsKt.printTime$default:(Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)V
      32: return

  public static final java.util.List<Node> toHeightGraph(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #51                 // String <this>
       3: invokestatic  #57                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aconst_null
       7: astore_1
       8: new           #59                 // class Node
      11: dup
      12: iconst_0
      13: aconst_null
      14: iconst_2
      15: aconst_null
      16: invokespecial #63                 // Method Node."<init>":(ILjava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
      19: astore_1
      20: aconst_null
      21: astore_2
      22: new           #59                 // class Node
      25: dup
      26: iconst_0
      27: aconst_null
      28: iconst_2
      29: aconst_null
      30: invokespecial #63                 // Method Node."<init>":(ILjava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
      33: astore_2
      34: aload_0
      35: checkcast     #65                 // class java/lang/Iterable
      38: astore        4
      40: iconst_0
      41: istore        5
      43: aload         4
      45: astore        6
      47: new           #67                 // class java/util/ArrayList
      50: dup
      51: aload         4
      53: bipush        10
      55: invokestatic  #73                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      58: invokespecial #76                 // Method java/util/ArrayList."<init>":(I)V
      61: checkcast     #78                 // class java/util/Collection
      64: astore        7
      66: iconst_0
      67: istore        8
      69: aload         6
      71: invokeinterface #82,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      76: astore        9
      78: aload         9
      80: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      85: ifeq          308
      88: aload         9
      90: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      95: astore        10
      97: aload         7
      99: aload         10
     101: checkcast     #93                 // class java/lang/String
     104: astore        11
     106: astore        25
     108: iconst_0
     109: istore        12
     111: aload         11
     113: invokevirtual #97                 // Method java/lang/String.toCharArray:()[C
     116: dup
     117: ldc           #99                 // String toCharArray(...)
     119: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     122: astore        13
     124: nop
     125: iconst_0
     126: istore        14
     128: aload         13
     130: astore        15
     132: new           #67                 // class java/util/ArrayList
     135: dup
     136: aload         13
     138: arraylength
     139: invokespecial #76                 // Method java/util/ArrayList."<init>":(I)V
     142: checkcast     #78                 // class java/util/Collection
     145: astore        16
     147: iconst_0
     148: istore        17
     150: iconst_0
     151: istore        18
     153: aload         15
     155: arraylength
     156: istore        19
     158: iload         18
     160: iload         19
     162: if_icmpge     289
     165: aload         15
     167: iload         18
     169: caload
     170: istore        20
     172: aload         16
     174: iload         20
     176: istore        21
     178: astore        22
     180: iconst_0
     181: istore        23
     183: aconst_null
     184: astore        24
     186: iload         21
     188: lookupswitch  { // 2
                    69: 235
                    83: 216
               default: 255
          }
     216: new           #59                 // class Node
     219: dup
     220: iconst_0
     221: aconst_null
     222: iconst_2
     223: aconst_null
     224: invokespecial #63                 // Method Node."<init>":(ILjava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
     227: astore        24
     229: aload         24
     231: astore_1
     232: goto          272
     235: new           #59                 // class Node
     238: dup
     239: bipush        25
     241: aconst_null
     242: iconst_2
     243: aconst_null
     244: invokespecial #63                 // Method Node."<init>":(ILjava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
     247: astore        24
     249: aload         24
     251: astore_2
     252: goto          272
     255: new           #59                 // class Node
     258: dup
     259: iload         21
     261: bipush        97
     263: isub
     264: aconst_null
     265: iconst_2
     266: aconst_null
     267: invokespecial #63                 // Method Node."<init>":(ILjava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
     270: astore        24
     272: aload         24
     274: aload         22
     276: swap
     277: invokeinterface #106,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     282: pop
     283: iinc          18, 1
     286: goto          158
     289: aload         16
     291: checkcast     #108                // class java/util/List
     294: nop
     295: nop
     296: aload         25
     298: swap
     299: invokeinterface #106,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     304: pop
     305: goto          78
     308: aload         7
     310: checkcast     #108                // class java/util/List
     313: nop
     314: astore_3
     315: aload_3
     316: aload_3
     317: invokedynamic #120,  0            // InvokeDynamic #2:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function3;
     322: invokestatic  #124                // Method UtilsKt.matrixForEachIndexed:(Ljava/util/List;Lkotlin/jvm/functions/Function3;)V
     325: iconst_2
     326: anewarray     #59                 // class Node
     329: astore        4
     331: aload         4
     333: iconst_0
     334: aload_2
     335: aastore
     336: aload         4
     338: iconst_1
     339: aload_1
     340: aastore
     341: aload         4
     343: invokestatic  #128                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     346: areturn

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #155                // Method main:()V
       3: return

  private static final kotlin.Unit main$lambda$0(java.util.List);
    Code:
       0: getstatic     #162                // Field Day12.Companion:LDay12$Companion;
       3: aload_0
       4: invokevirtual #168                // Method Day12$Companion.part1:(Ljava/util/List;)I
       7: istore_1
       8: getstatic     #174                // Field java/lang/System.out:Ljava/io/PrintStream;
      11: iload_1
      12: invokevirtual #179                // Method java/io/PrintStream.println:(I)V
      15: getstatic     #185                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      18: areturn

  private static final kotlin.Unit main$lambda$1(java.util.List);
    Code:
       0: getstatic     #162                // Field Day12.Companion:LDay12$Companion;
       3: aload_0
       4: invokevirtual #189                // Method Day12$Companion.part2:(Ljava/util/List;)I
       7: istore_1
       8: getstatic     #174                // Field java/lang/System.out:Ljava/io/PrintStream;
      11: iload_1
      12: invokevirtual #179                // Method java/io/PrintStream.println:(I)V
      15: getstatic     #185                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      18: areturn

  private static final kotlin.Unit toHeightGraph$lambda$4(java.util.List, int, int, Node);
    Code:
       0: aload_3
       1: ldc           #191                // String <unused var>
       3: invokestatic  #57                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iload_1
       7: ifle          56
      10: aload_0
      11: iload_1
      12: invokeinterface #195,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      17: checkcast     #108                // class java/util/List
      20: iload_2
      21: invokeinterface #195,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      26: checkcast     #59                 // class Node
      29: invokevirtual #199                // Method Node.getNeighbors:()Ljava/util/List;
      32: aload_0
      33: iload_1
      34: iconst_1
      35: isub
      36: invokeinterface #195,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      41: checkcast     #108                // class java/util/List
      44: iload_2
      45: invokeinterface #195,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      50: invokeinterface #200,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      55: pop
      56: iload_1
      57: aload_0
      58: invokestatic  #203                // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
      61: if_icmpge     110
      64: aload_0
      65: iload_1
      66: invokeinterface #195,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      71: checkcast     #108                // class java/util/List
      74: iload_2
      75: invokeinterface #195,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      80: checkcast     #59                 // class Node
      83: invokevirtual #199                // Method Node.getNeighbors:()Ljava/util/List;
      86: aload_0
      87: iload_1
      88: iconst_1
      89: iadd
      90: invokeinterface #195,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      95: checkcast     #108                // class java/util/List
      98: iload_2
      99: invokeinterface #195,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     104: invokeinterface #200,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     109: pop
     110: iload_2
     111: ifle          160
     114: aload_0
     115: iload_1
     116: invokeinterface #195,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     121: checkcast     #108                // class java/util/List
     124: iload_2
     125: invokeinterface #195,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     130: checkcast     #59                 // class Node
     133: invokevirtual #199                // Method Node.getNeighbors:()Ljava/util/List;
     136: aload_0
     137: iload_1
     138: invokeinterface #195,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     143: checkcast     #108                // class java/util/List
     146: iload_2
     147: iconst_1
     148: isub
     149: invokeinterface #195,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     154: invokeinterface #200,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     159: pop
     160: iload_2
     161: aload_0
     162: iload_1
     163: invokeinterface #195,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     168: checkcast     #108                // class java/util/List
     171: invokestatic  #203                // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
     174: if_icmpge     223
     177: aload_0
     178: iload_1
     179: invokeinterface #195,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     184: checkcast     #108                // class java/util/List
     187: iload_2
     188: invokeinterface #195,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     193: checkcast     #59                 // class Node
     196: invokevirtual #199                // Method Node.getNeighbors:()Ljava/util/List;
     199: aload_0
     200: iload_1
     201: invokeinterface #195,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     206: checkcast     #108                // class java/util/List
     209: iload_2
     210: iconst_1
     211: iadd
     212: invokeinterface #195,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     217: invokeinterface #200,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     222: pop
     223: getstatic     #185                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     226: areturn
}


import kotlin.math.max

fun main() {
    val input = readInput("Day13")
    printTime { println(Day13.part1(input)) }
    printTime { println(Day13.part2(input)) }
}

class Day13 {
    companion object {
        fun part1(input: List<String>): Int {
            val packetPairs = input.partitionOnElement("").map { it.map { parsePacket(it.substring(1, it.lastIndex)) } }
            val packetComparisons: List<Int> = packetPairs.map { (first, second) -> comparePackets(first, second) }
            return packetComparisons.withIndex().filter { it.value <= 0 }.sumOf { it.index + 1 }
        }

        fun part2(input: List<String>): Int {
            val packet2 = parsePacket("[2]")
            val packet6 = parsePacket("[6]")
            val packets = input.filter { it != "" }
                .map { parsePacket(it.substring(1, it.lastIndex)) }.toMutableList().apply { add(packet2); add(packet6) }
            val sortedPackets = packets.sortedWith { p0, p1 -> comparePackets(p0, p1) }
            return sortedPackets.withIndex()
                .filter { comparePackets(packet2, it.value) == 0 || comparePackets(packet6, it.value) == 0 }
                .map { it.index + 1 }.product()
        }

        private fun comparePackets(first: Any, second: Any): Int {
            if (first is List<*> && second is List<*>) {
                for (index in 0..max(first.lastIndex, second.lastIndex)) {
                    if (first.lastIndex < index) return -1
                    if (second.lastIndex < index) return 1
                    val packetComparison = comparePackets(first[index]!!, second[index]!!)
                    if (packetComparison == 0) continue
                    else return packetComparison
                }
                return 0
            }

            if (first is List<*>) return comparePackets(first, listOf(second))
            if (second is List<*>) return comparePackets(listOf(first), second)
            return (first as Int) - (second as Int)
        }

        private fun parsePacket(substring: String): List<Any> {
            val root = mutableListOf<Any>()
            val stack: ArrayDeque<MutableList<Any>> = ArrayDeque()
            stack.add(root)
            var index = 0

            while (index < substring.length) {
                when (substring[index]) {
                    '[' -> {
                        val newStack = mutableListOf<Any>()
                        stack.last().add(newStack)
                        stack.addLast(newStack)
                        index++
                    }

                    ']' -> {
                        stack.removeLast()
                        index++
                    }

                    ',' -> index++
                    else -> {
                        val fromNumber = substring.substring(index)
                        var indexOfNextClose = fromNumber.indexOfFirst { it == ']' || it == ',' }
                        if (indexOfNextClose < 0) indexOfNextClose = fromNumber.length
                        val number = fromNumber.substring(0, indexOfNextClose).toInt()
                        stack.last().add(number)
                        index += indexOfNextClose
                    }
                }
            }
            return root
        }
    }
}

Compiled from "Day13.kt"
public final class Day13 {
  public static final Day13$Companion Companion;

  public Day13();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  static {};
    Code:
       0: new           #13                 // class Day13$Companion
       3: dup
       4: aconst_null
       5: invokespecial #16                 // Method Day13$Companion."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: putstatic     #20                 // Field Companion:LDay13$Companion;
      11: return
}

Compiled from "Day13.kt"
public final class Day13$Companion {
  private Day13$Companion();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int part1(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #24                 // String
       9: invokestatic  #30                 // Method UtilsKt.partitionOnElement:(Ljava/util/List;Ljava/lang/Object;)Ljava/util/List;
      12: checkcast     #32                 // class java/lang/Iterable
      15: astore_3
      16: iconst_0
      17: istore        4
      19: aload_3
      20: astore        5
      22: new           #34                 // class java/util/ArrayList
      25: dup
      26: aload_3
      27: bipush        10
      29: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      32: invokespecial #43                 // Method java/util/ArrayList."<init>":(I)V
      35: checkcast     #45                 // class java/util/Collection
      38: astore        6
      40: iconst_0
      41: istore        7
      43: aload         5
      45: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      50: astore        8
      52: aload         8
      54: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      59: ifeq          220
      62: aload         8
      64: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      69: astore        9
      71: aload         6
      73: aload         9
      75: checkcast     #61                 // class java/util/List
      78: astore        10
      80: astore        22
      82: iconst_0
      83: istore        11
      85: aload         10
      87: checkcast     #32                 // class java/lang/Iterable
      90: astore        12
      92: iconst_0
      93: istore        13
      95: aload         12
      97: astore        14
      99: new           #34                 // class java/util/ArrayList
     102: dup
     103: aload         12
     105: bipush        10
     107: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     110: invokespecial #43                 // Method java/util/ArrayList."<init>":(I)V
     113: checkcast     #45                 // class java/util/Collection
     116: astore        15
     118: iconst_0
     119: istore        16
     121: aload         14
     123: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     128: astore        17
     130: aload         17
     132: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     137: ifeq          201
     140: aload         17
     142: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     147: astore        18
     149: aload         15
     151: aload         18
     153: checkcast     #63                 // class java/lang/String
     156: astore        19
     158: astore        20
     160: iconst_0
     161: istore        21
     163: getstatic     #68                 // Field Day13.Companion:LDay13$Companion;
     166: aload         19
     168: iconst_1
     169: aload         19
     171: checkcast     #70                 // class java/lang/CharSequence
     174: invokestatic  #76                 // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I
     177: invokevirtual #80                 // Method java/lang/String.substring:(II)Ljava/lang/String;
     180: dup
     181: ldc           #82                 // String substring(...)
     183: invokestatic  #85                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     186: invokespecial #89                 // Method parsePacket:(Ljava/lang/String;)Ljava/util/List;
     189: aload         20
     191: swap
     192: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     197: pop
     198: goto          130
     201: aload         15
     203: checkcast     #61                 // class java/util/List
     206: nop
     207: nop
     208: aload         22
     210: swap
     211: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     216: pop
     217: goto          52
     220: aload         6
     222: checkcast     #61                 // class java/util/List
     225: nop
     226: astore_2
     227: aload_2
     228: checkcast     #32                 // class java/lang/Iterable
     231: astore        4
     233: iconst_0
     234: istore        5
     236: aload         4
     238: astore        6
     240: new           #34                 // class java/util/ArrayList
     243: dup
     244: aload         4
     246: bipush        10
     248: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     251: invokespecial #43                 // Method java/util/ArrayList."<init>":(I)V
     254: checkcast     #45                 // class java/util/Collection
     257: astore        7
     259: iconst_0
     260: istore        8
     262: aload         6
     264: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     269: astore        9
     271: aload         9
     273: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     278: ifeq          355
     281: aload         9
     283: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     288: astore        10
     290: aload         7
     292: aload         10
     294: checkcast     #61                 // class java/util/List
     297: astore        11
     299: astore        22
     301: iconst_0
     302: istore        12
     304: aload         11
     306: iconst_0
     307: invokeinterface #97,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     312: checkcast     #61                 // class java/util/List
     315: astore        13
     317: aload         11
     319: iconst_1
     320: invokeinterface #97,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     325: checkcast     #61                 // class java/util/List
     328: astore        14
     330: getstatic     #68                 // Field Day13.Companion:LDay13$Companion;
     333: aload         13
     335: aload         14
     337: invokespecial #101                // Method comparePackets:(Ljava/lang/Object;Ljava/lang/Object;)I
     340: invokestatic  #107                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     343: aload         22
     345: swap
     346: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     351: pop
     352: goto          271
     355: aload         7
     357: checkcast     #61                 // class java/util/List
     360: nop
     361: astore_3
     362: aload_3
     363: checkcast     #32                 // class java/lang/Iterable
     366: invokestatic  #111                // Method kotlin/collections/CollectionsKt.withIndex:(Ljava/lang/Iterable;)Ljava/lang/Iterable;
     369: astore        4
     371: iconst_0
     372: istore        5
     374: aload         4
     376: astore        6
     378: new           #34                 // class java/util/ArrayList
     381: dup
     382: invokespecial #112                // Method java/util/ArrayList."<init>":()V
     385: checkcast     #45                 // class java/util/Collection
     388: astore        7
     390: iconst_0
     391: istore        8
     393: aload         6
     395: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     400: astore        9
     402: aload         9
     404: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     409: ifeq          466
     412: aload         9
     414: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     419: astore        10
     421: aload         10
     423: checkcast     #114                // class kotlin/collections/IndexedValue
     426: astore        11
     428: iconst_0
     429: istore        12
     431: aload         11
     433: invokevirtual #117                // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
     436: checkcast     #119                // class java/lang/Number
     439: invokevirtual #123                // Method java/lang/Number.intValue:()I
     442: ifgt          449
     445: iconst_1
     446: goto          450
     449: iconst_0
     450: ifeq          402
     453: aload         7
     455: aload         10
     457: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     462: pop
     463: goto          402
     466: aload         7
     468: checkcast     #61                 // class java/util/List
     471: nop
     472: checkcast     #32                 // class java/lang/Iterable
     475: astore        4
     477: iconst_0
     478: istore        5
     480: aload         4
     482: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     487: astore        6
     489: aload         6
     491: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     496: ifeq          541
     499: aload         6
     501: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     506: astore        7
     508: iload         5
     510: aload         7
     512: checkcast     #114                // class kotlin/collections/IndexedValue
     515: astore        8
     517: istore        22
     519: iconst_0
     520: istore        9
     522: aload         8
     524: invokevirtual #126                // Method kotlin/collections/IndexedValue.getIndex:()I
     527: iconst_1
     528: iadd
     529: istore        23
     531: iload         22
     533: iload         23
     535: iadd
     536: istore        5
     538: goto          489
     541: iload         5
     543: ireturn

  public final int part2(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: ldc           #157                // String [2]
       9: invokespecial #89                 // Method parsePacket:(Ljava/lang/String;)Ljava/util/List;
      12: astore_2
      13: aload_0
      14: ldc           #159                // String [6]
      16: invokespecial #89                 // Method parsePacket:(Ljava/lang/String;)Ljava/util/List;
      19: astore_3
      20: aload_1
      21: checkcast     #32                 // class java/lang/Iterable
      24: astore        5
      26: iconst_0
      27: istore        6
      29: aload         5
      31: astore        7
      33: new           #34                 // class java/util/ArrayList
      36: dup
      37: invokespecial #112                // Method java/util/ArrayList."<init>":()V
      40: checkcast     #45                 // class java/util/Collection
      43: astore        8
      45: iconst_0
      46: istore        9
      48: aload         7
      50: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      55: astore        10
      57: aload         10
      59: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      64: ifeq          117
      67: aload         10
      69: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      74: astore        11
      76: aload         11
      78: checkcast     #63                 // class java/lang/String
      81: astore        12
      83: iconst_0
      84: istore        13
      86: aload         12
      88: ldc           #24                 // String
      90: invokestatic  #163                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      93: ifne          100
      96: iconst_1
      97: goto          101
     100: iconst_0
     101: ifeq          57
     104: aload         8
     106: aload         11
     108: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     113: pop
     114: goto          57
     117: aload         8
     119: checkcast     #61                 // class java/util/List
     122: nop
     123: checkcast     #32                 // class java/lang/Iterable
     126: astore        5
     128: nop
     129: iconst_0
     130: istore        6
     132: aload         5
     134: astore        7
     136: new           #34                 // class java/util/ArrayList
     139: dup
     140: aload         5
     142: bipush        10
     144: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     147: invokespecial #43                 // Method java/util/ArrayList."<init>":(I)V
     150: checkcast     #45                 // class java/util/Collection
     153: astore        8
     155: iconst_0
     156: istore        9
     158: aload         7
     160: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     165: astore        10
     167: aload         10
     169: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     174: ifeq          238
     177: aload         10
     179: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     184: astore        11
     186: aload         8
     188: aload         11
     190: checkcast     #63                 // class java/lang/String
     193: astore        12
     195: astore        15
     197: iconst_0
     198: istore        13
     200: getstatic     #68                 // Field Day13.Companion:LDay13$Companion;
     203: aload         12
     205: iconst_1
     206: aload         12
     208: checkcast     #70                 // class java/lang/CharSequence
     211: invokestatic  #76                 // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I
     214: invokevirtual #80                 // Method java/lang/String.substring:(II)Ljava/lang/String;
     217: dup
     218: ldc           #82                 // String substring(...)
     220: invokestatic  #85                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     223: invokespecial #89                 // Method parsePacket:(Ljava/lang/String;)Ljava/util/List;
     226: aload         15
     228: swap
     229: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     234: pop
     235: goto          167
     238: aload         8
     240: checkcast     #61                 // class java/util/List
     243: nop
     244: checkcast     #45                 // class java/util/Collection
     247: invokestatic  #167                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     250: astore        5
     252: aload         5
     254: astore        6
     256: iconst_0
     257: istore        7
     259: aload         6
     261: aload_2
     262: invokeinterface #168,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     267: pop
     268: aload         6
     270: aload_3
     271: invokeinterface #168,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     276: pop
     277: aload         5
     279: astore        4
     281: aload         4
     283: checkcast     #32                 // class java/lang/Iterable
     286: invokedynamic #188,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;
     291: invokedynamic #198,  0            // InvokeDynamic #1:compare:(Lkotlin/jvm/functions/Function2;)Ljava/util/Comparator;
     296: invokestatic  #202                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
     299: astore        5
     301: aload         5
     303: checkcast     #32                 // class java/lang/Iterable
     306: invokestatic  #111                // Method kotlin/collections/CollectionsKt.withIndex:(Ljava/lang/Iterable;)Ljava/lang/Iterable;
     309: astore        6
     311: nop
     312: iconst_0
     313: istore        7
     315: aload         6
     317: astore        8
     319: new           #34                 // class java/util/ArrayList
     322: dup
     323: invokespecial #112                // Method java/util/ArrayList."<init>":()V
     326: checkcast     #45                 // class java/util/Collection
     329: astore        9
     331: iconst_0
     332: istore        10
     334: aload         8
     336: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     341: astore        11
     343: aload         11
     345: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     350: ifeq          423
     353: aload         11
     355: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     360: astore        12
     362: aload         12
     364: checkcast     #114                // class kotlin/collections/IndexedValue
     367: astore        13
     369: iconst_0
     370: istore        14
     372: getstatic     #68                 // Field Day13.Companion:LDay13$Companion;
     375: aload_2
     376: aload         13
     378: invokevirtual #117                // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
     381: invokespecial #101                // Method comparePackets:(Ljava/lang/Object;Ljava/lang/Object;)I
     384: ifeq          402
     387: getstatic     #68                 // Field Day13.Companion:LDay13$Companion;
     390: aload_3
     391: aload         13
     393: invokevirtual #117                // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
     396: invokespecial #101                // Method comparePackets:(Ljava/lang/Object;Ljava/lang/Object;)I
     399: ifne          406
     402: iconst_1
     403: goto          407
     406: iconst_0
     407: ifeq          343
     410: aload         9
     412: aload         12
     414: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     419: pop
     420: goto          343
     423: aload         9
     425: checkcast     #61                 // class java/util/List
     428: nop
     429: checkcast     #32                 // class java/lang/Iterable
     432: astore        6
     434: nop
     435: iconst_0
     436: istore        7
     438: aload         6
     440: astore        8
     442: new           #34                 // class java/util/ArrayList
     445: dup
     446: aload         6
     448: bipush        10
     450: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     453: invokespecial #43                 // Method java/util/ArrayList."<init>":(I)V
     456: checkcast     #45                 // class java/util/Collection
     459: astore        9
     461: iconst_0
     462: istore        10
     464: aload         8
     466: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     471: astore        11
     473: aload         11
     475: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     480: ifeq          528
     483: aload         11
     485: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     490: astore        12
     492: aload         9
     494: aload         12
     496: checkcast     #114                // class kotlin/collections/IndexedValue
     499: astore        13
     501: astore        15
     503: iconst_0
     504: istore        14
     506: aload         13
     508: invokevirtual #126                // Method kotlin/collections/IndexedValue.getIndex:()I
     511: iconst_1
     512: iadd
     513: invokestatic  #107                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     516: aload         15
     518: swap
     519: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     524: pop
     525: goto          473
     528: aload         9
     530: checkcast     #61                 // class java/util/List
     533: nop
     534: checkcast     #32                 // class java/lang/Iterable
     537: invokestatic  #206                // Method UtilsKt.product:(Ljava/lang/Iterable;)I
     540: ireturn

  private final int comparePackets(java.lang.Object, java.lang.Object);
    Code:
       0: aload_1
       1: instanceof    #61                 // class java/util/List
       4: ifeq          123
       7: aload_2
       8: instanceof    #61                 // class java/util/List
      11: ifeq          123
      14: iconst_0
      15: istore_3
      16: aload_1
      17: checkcast     #61                 // class java/util/List
      20: invokestatic  #218                // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
      23: aload_2
      24: checkcast     #61                 // class java/util/List
      27: invokestatic  #218                // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
      30: invokestatic  #224                // Method java/lang/Math.max:(II)I
      33: istore        4
      35: iload_3
      36: iload         4
      38: if_icmpgt     121
      41: aload_1
      42: checkcast     #61                 // class java/util/List
      45: invokestatic  #218                // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
      48: iload_3
      49: if_icmpge     54
      52: iconst_m1
      53: ireturn
      54: aload_2
      55: checkcast     #61                 // class java/util/List
      58: invokestatic  #218                // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
      61: iload_3
      62: if_icmpge     67
      65: iconst_1
      66: ireturn
      67: aload_0
      68: aload_1
      69: checkcast     #61                 // class java/util/List
      72: iload_3
      73: invokeinterface #97,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      78: dup
      79: invokestatic  #228                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      82: aload_2
      83: checkcast     #61                 // class java/util/List
      86: iload_3
      87: invokeinterface #97,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      92: dup
      93: invokestatic  #228                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      96: invokespecial #101                // Method comparePackets:(Ljava/lang/Object;Ljava/lang/Object;)I
      99: istore        5
     101: iload         5
     103: ifeq          109
     106: iload         5
     108: ireturn
     109: iload_3
     110: iload         4
     112: if_icmpeq     121
     115: iinc          3, 1
     118: goto          41
     121: iconst_0
     122: ireturn
     123: aload_1
     124: instanceof    #61                 // class java/util/List
     127: ifeq          140
     130: aload_0
     131: aload_1
     132: aload_2
     133: invokestatic  #232                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     136: invokespecial #101                // Method comparePackets:(Ljava/lang/Object;Ljava/lang/Object;)I
     139: ireturn
     140: aload_2
     141: instanceof    #61                 // class java/util/List
     144: ifeq          157
     147: aload_0
     148: aload_1
     149: invokestatic  #232                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     152: aload_2
     153: invokespecial #101                // Method comparePackets:(Ljava/lang/Object;Ljava/lang/Object;)I
     156: ireturn
     157: aload_1
     158: ldc           #234                // String null cannot be cast to non-null type kotlin.Int
     160: invokestatic  #236                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V
     163: aload_1
     164: checkcast     #103                // class java/lang/Integer
     167: invokevirtual #237                // Method java/lang/Integer.intValue:()I
     170: aload_2
     171: ldc           #234                // String null cannot be cast to non-null type kotlin.Int
     173: invokestatic  #236                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V
     176: aload_2
     177: checkcast     #103                // class java/lang/Integer
     180: invokevirtual #237                // Method java/lang/Integer.intValue:()I
     183: isub
     184: ireturn

  private final java.util.List<java.lang.Object> parsePacket(java.lang.String);
    Code:
       0: new           #34                 // class java/util/ArrayList
       3: dup
       4: invokespecial #112                // Method java/util/ArrayList."<init>":()V
       7: checkcast     #61                 // class java/util/List
      10: astore_2
      11: new           #242                // class kotlin/collections/ArrayDeque
      14: dup
      15: invokespecial #243                // Method kotlin/collections/ArrayDeque."<init>":()V
      18: astore_3
      19: aload_3
      20: aload_2
      21: invokevirtual #244                // Method kotlin/collections/ArrayDeque.add:(Ljava/lang/Object;)Z
      24: pop
      25: iconst_0
      26: istore        4
      28: iload         4
      30: aload_1
      31: invokevirtual #247                // Method java/lang/String.length:()I
      34: if_icmpge     294
      37: aload_1
      38: iload         4
      40: invokevirtual #251                // Method java/lang/String.charAt:(I)C
      43: lookupswitch  { // 3
                    44: 132
                    91: 76
                    93: 118
               default: 141
          }
      76: new           #34                 // class java/util/ArrayList
      79: dup
      80: invokespecial #112                // Method java/util/ArrayList."<init>":()V
      83: checkcast     #61                 // class java/util/List
      86: astore        5
      88: aload_3
      89: invokevirtual #254                // Method kotlin/collections/ArrayDeque.last:()Ljava/lang/Object;
      92: checkcast     #61                 // class java/util/List
      95: aload         5
      97: invokeinterface #168,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     102: pop
     103: aload_3
     104: aload         5
     106: invokevirtual #257                // Method kotlin/collections/ArrayDeque.addLast:(Ljava/lang/Object;)V
     109: iload         4
     111: iinc          4, 1
     114: pop
     115: goto          28
     118: aload_3
     119: invokevirtual #260                // Method kotlin/collections/ArrayDeque.removeLast:()Ljava/lang/Object;
     122: pop
     123: iload         4
     125: iinc          4, 1
     128: pop
     129: goto          28
     132: iload         4
     134: iinc          4, 1
     137: pop
     138: goto          28
     141: aload_1
     142: iload         4
     144: invokevirtual #263                // Method java/lang/String.substring:(I)Ljava/lang/String;
     147: dup
     148: ldc           #82                 // String substring(...)
     150: invokestatic  #85                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     153: astore        5
     155: aload         5
     157: checkcast     #70                 // class java/lang/CharSequence
     160: astore        7
     162: iconst_0
     163: istore        8
     165: iconst_0
     166: istore        9
     168: aload         7
     170: invokeinterface #264,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     175: istore        10
     177: iload         9
     179: iload         10
     181: if_icmpge     231
     184: aload         7
     186: iload         9
     188: invokeinterface #265,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     193: istore        11
     195: iconst_0
     196: istore        12
     198: iload         11
     200: bipush        93
     202: if_icmpeq     212
     205: iload         11
     207: bipush        44
     209: if_icmpne     216
     212: iconst_1
     213: goto          217
     216: iconst_0
     217: ifeq          225
     220: iload         9
     222: goto          232
     225: iinc          9, 1
     228: goto          177
     231: iconst_m1
     232: istore        6
     234: iload         6
     236: ifge          246
     239: aload         5
     241: invokevirtual #247                // Method java/lang/String.length:()I
     244: istore        6
     246: nop
     247: aload         5
     249: iconst_0
     250: iload         6
     252: invokevirtual #80                 // Method java/lang/String.substring:(II)Ljava/lang/String;
     255: dup
     256: ldc           #82                 // String substring(...)
     258: invokestatic  #85                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     261: invokestatic  #269                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     264: istore        7
     266: aload_3
     267: invokevirtual #254                // Method kotlin/collections/ArrayDeque.last:()Ljava/lang/Object;
     270: checkcast     #61                 // class java/util/List
     273: iload         7
     275: invokestatic  #107                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     278: invokeinterface #168,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     283: pop
     284: iload         4
     286: iload         6
     288: iadd
     289: istore        4
     291: goto          28
     294: aload_2
     295: areturn

  private static final int part2$lambda$8(java.util.List, java.util.List);
    Code:
       0: getstatic     #68                 // Field Day13.Companion:LDay13$Companion;
       3: aload_0
       4: invokestatic  #228                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       7: aload_0
       8: aload_1
       9: invokestatic  #228                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      12: aload_1
      13: invokespecial #101                // Method comparePackets:(Ljava/lang/Object;Ljava/lang/Object;)I
      16: ireturn

  private static final int part2$lambda$9(kotlin.jvm.functions.Function2, java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokeinterface #288,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
       8: checkcast     #119                // class java/lang/Number
      11: invokevirtual #123                // Method java/lang/Number.intValue:()I
      14: ireturn

  public Day13$Companion(kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: aload_0
       1: invokespecial #292                // Method "<init>":()V
       4: return
}

Compiled from "Day13.kt"
public final class Day13Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day13
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aconst_null
       7: aconst_null
       8: aload_0
       9: invokedynamic #34,  0             // InvokeDynamic #0:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function0;
      14: iconst_3
      15: aconst_null
      16: invokestatic  #38                 // Method UtilsKt.printTime$default:(Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)V
      19: aconst_null
      20: aconst_null
      21: aload_0
      22: invokedynamic #43,  0             // InvokeDynamic #1:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function0;
      27: iconst_3
      28: aconst_null
      29: invokestatic  #38                 // Method UtilsKt.printTime$default:(Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)V
      32: return

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #48                 // Method main:()V
       3: return

  private static final kotlin.Unit main$lambda$0(java.util.List);
    Code:
       0: getstatic     #55                 // Field Day13.Companion:LDay13$Companion;
       3: aload_0
       4: invokevirtual #61                 // Method Day13$Companion.part1:(Ljava/util/List;)I
       7: istore_1
       8: getstatic     #67                 // Field java/lang/System.out:Ljava/io/PrintStream;
      11: iload_1
      12: invokevirtual #73                 // Method java/io/PrintStream.println:(I)V
      15: getstatic     #79                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      18: areturn

  private static final kotlin.Unit main$lambda$1(java.util.List);
    Code:
       0: getstatic     #55                 // Field Day13.Companion:LDay13$Companion;
       3: aload_0
       4: invokevirtual #83                 // Method Day13$Companion.part2:(Ljava/util/List;)I
       7: istore_1
       8: getstatic     #67                 // Field java/lang/System.out:Ljava/io/PrintStream;
      11: iload_1
      12: invokevirtual #73                 // Method java/io/PrintStream.println:(I)V
      15: getstatic     #79                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      18: areturn
}