fun main() {
    lateinit var flowRates: Map<String, Int>
    lateinit var connections: Map<String, List<String>>
    lateinit var workingValves: List<String>
    lateinit var distances: Map<Pair<String, String>, Int>

    fun getDistanceToValve(
        current: String,
        destination: String,
        visited: List<String> = emptyList(),
        depth: Int = 1
    ): Int {
        val nextValves =
            (connections[current]!!).filter { !visited.contains(it) }.takeIf { it.isNotEmpty() }
                ?: return Int.MAX_VALUE
        return if (nextValves.contains(destination)) {
            depth
        } else {
            val newVisited = visited + current
            nextValves.minOf { getDistanceToValve(it, destination, newVisited, depth + 1) }
        }
    }

    fun parseInput(fileName: String) {
        val valves = mutableMapOf<String, Int>()
        val tunnels = mutableMapOf<String, List<String>>()

        readInput(fileName)
            .map { it.split(";") }
            .forEach { (valveRaw, tunnelsRaw) ->
                val label = valveRaw.getAllByRegex("[A-Z][A-Z]".toRegex()).single()
                val flowRate = valveRaw.getAllInts().single()
                val accessibleValves = tunnelsRaw.getAllByRegex("[A-Z][A-Z]".toRegex())

                valves[label] = flowRate
                tunnels[label] = accessibleValves
            }
        flowRates = valves
        connections = tunnels
        workingValves = flowRates.keys.filter { flowRates[it]!! > 0 }
    }

    fun calculateDistancesBetweenValves(valves: List<String>): Map<Pair<String, String>, Int> {
        val resultDistances = mutableMapOf<Pair<String, String>, Int>()
        for (start in valves) {
            for (end in valves) {
                resultDistances[start to end] = getDistanceToValve(start, end)
            }
        }
        return resultDistances
    }

    fun maxPath(node: String, countDown: Int, opened: Set<String> = emptySet(), pressure: Int = 0): Int {
        val nextOpened = opened + node
        val openedFlowRate = nextOpened.sumOf { flowRates[it]!! }
        return distances
            .filter { (path, distance) -> path.first == node && !opened.contains(path.second) && distance <= countDown - 1 }
            .map { (path, distance) -> Pair(path.second, distance) }
            .map { (nextNode, distance) ->
                val nextCountDown = countDown - distance - 1
                val nextPressure = pressure + (distance + 1) * openedFlowRate
                maxPath(nextNode, nextCountDown, nextOpened, nextPressure)
            }.plus(pressure + countDown * openedFlowRate)
            .max()
    }

    fun part1(): Int {
        val startingValve = "AA"
        distances = calculateDistancesBetweenValves(workingValves + startingValve)
        return maxPath(startingValve, 30)
    }

    parseInput("Day16_test")
    check(part1() == 1651)

    parseInput("Day16")
    println(part1())
}

Compiled from "Day16.kt"
public final class Day16Kt {
  public static final void main();
    Code:
       0: new           #8                  // class kotlin/jvm/internal/Ref$ObjectRef
       3: dup
       4: invokespecial #11                 // Method kotlin/jvm/internal/Ref$ObjectRef."<init>":()V
       7: astore_0
       8: new           #8                  // class kotlin/jvm/internal/Ref$ObjectRef
      11: dup
      12: invokespecial #11                 // Method kotlin/jvm/internal/Ref$ObjectRef."<init>":()V
      15: astore_1
      16: new           #8                  // class kotlin/jvm/internal/Ref$ObjectRef
      19: dup
      20: invokespecial #11                 // Method kotlin/jvm/internal/Ref$ObjectRef."<init>":()V
      23: astore_2
      24: new           #8                  // class kotlin/jvm/internal/Ref$ObjectRef
      27: dup
      28: invokespecial #11                 // Method kotlin/jvm/internal/Ref$ObjectRef."<init>":()V
      31: astore_3
      32: aload_0
      33: aload_1
      34: aload_2
      35: ldc           #13                 // String Day16_test
      37: invokestatic  #17                 // Method main$parseInput:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;)V
      40: aload_3
      41: aload_2
      42: aload_1
      43: aload_0
      44: invokestatic  #21                 // Method main$part1:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;)I
      47: sipush        1651
      50: if_icmpne     57
      53: iconst_1
      54: goto          58
      57: iconst_0
      58: ifne          71
      61: new           #23                 // class java/lang/IllegalStateException
      64: dup
      65: ldc           #25                 // String Check failed.
      67: invokespecial #28                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      70: athrow
      71: aload_0
      72: aload_1
      73: aload_2
      74: ldc           #30                 // String Day16
      76: invokestatic  #17                 // Method main$parseInput:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;)V
      79: aload_3
      80: aload_2
      81: aload_1
      82: aload_0
      83: invokestatic  #21                 // Method main$part1:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;)I
      86: istore        4
      88: getstatic     #36                 // Field java/lang/System.out:Ljava/io/PrintStream;
      91: iload         4
      93: invokevirtual #42                 // Method java/io/PrintStream.println:(I)V
      96: return

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

  private static final int main$getDistanceToValve(kotlin.jvm.internal.Ref$ObjectRef<java.util.Map<java.lang.String, java.util.List<java.lang.String>>>, java.lang.String, java.lang.String, java.util.List<java.lang.String>, int);
    Code:
       0: aload_0
       1: getfield      #59                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
       4: ifnonnull     16
       7: ldc           #60                 // String connections
       9: invokestatic  #65                 // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V
      12: aconst_null
      13: goto          23
      16: aload_0
      17: getfield      #59                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      20: checkcast     #67                 // class java/util/Map
      23: aload_1
      24: invokeinterface #71,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      29: dup
      30: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      33: checkcast     #77                 // class java/lang/Iterable
      36: astore        7
      38: iconst_0
      39: istore        8
      41: aload         7
      43: astore        9
      45: new           #79                 // class java/util/ArrayList
      48: dup
      49: invokespecial #80                 // Method java/util/ArrayList."<init>":()V
      52: checkcast     #82                 // class java/util/Collection
      55: astore        10
      57: iconst_0
      58: istore        11
      60: aload         9
      62: invokeinterface #86,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      67: astore        12
      69: aload         12
      71: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      76: ifeq          130
      79: aload         12
      81: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      86: astore        13
      88: aload         13
      90: checkcast     #98                 // class java/lang/String
      93: astore        14
      95: iconst_0
      96: istore        15
      98: aload_3
      99: aload         14
     101: invokeinterface #104,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     106: ifne          113
     109: iconst_1
     110: goto          114
     113: iconst_0
     114: ifeq          69
     117: aload         10
     119: aload         13
     121: invokeinterface #107,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     126: pop
     127: goto          69
     130: aload         10
     132: checkcast     #100                // class java/util/List
     135: nop
     136: astore        7
     138: aload         7
     140: astore        8
     142: iconst_0
     143: istore        9
     145: aload         8
     147: checkcast     #82                 // class java/util/Collection
     150: invokeinterface #110,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     155: ifne          162
     158: iconst_1
     159: goto          163
     162: iconst_0
     163: nop
     164: ifeq          172
     167: aload         7
     169: goto          173
     172: aconst_null
     173: dup
     174: ifnonnull     181
     177: pop
     178: ldc           #111                // int 2147483647
     180: ireturn
     181: astore        5
     183: aload         5
     185: aload_2
     186: invokeinterface #104,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     191: ifeq          199
     194: iload         4
     196: goto          325
     199: aload_3
     200: checkcast     #82                 // class java/util/Collection
     203: aload_1
     204: invokestatic  #117                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     207: astore        6
     209: aload         5
     211: checkcast     #77                 // class java/lang/Iterable
     214: invokeinterface #86,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     219: astore        8
     221: aload         8
     223: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     228: ifne          239
     231: new           #119                // class java/util/NoSuchElementException
     234: dup
     235: invokespecial #120                // Method java/util/NoSuchElementException."<init>":()V
     238: athrow
     239: aload         8
     241: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     246: checkcast     #98                 // class java/lang/String
     249: astore        9
     251: iconst_0
     252: istore        10
     254: aload_0
     255: aload         9
     257: aload_2
     258: aload         6
     260: iload         4
     262: iconst_1
     263: iadd
     264: invokestatic  #122                // Method main$getDistanceToValve:(Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;I)I
     267: istore        9
     269: aload         8
     271: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     276: ifeq          323
     279: aload         8
     281: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     286: checkcast     #98                 // class java/lang/String
     289: astore        10
     291: iconst_0
     292: istore        11
     294: aload_0
     295: aload         10
     297: aload_2
     298: aload         6
     300: iload         4
     302: iconst_1
     303: iadd
     304: invokestatic  #122                // Method main$getDistanceToValve:(Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;I)I
     307: istore        10
     309: iload         9
     311: iload         10
     313: if_icmple     269
     316: iload         10
     318: istore        9
     320: goto          269
     323: iload         9
     325: ireturn

  static int main$getDistanceToValve$default(kotlin.jvm.internal.Ref$ObjectRef, java.lang.String, java.lang.String, java.util.List, int, int, java.lang.Object);
    Code:
       0: iload         5
       2: bipush        8
       4: iand
       5: ifeq          12
       8: invokestatic  #149                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      11: astore_3
      12: iload         5
      14: bipush        16
      16: iand
      17: ifeq          23
      20: iconst_1
      21: istore        4
      23: aload_0
      24: aload_1
      25: aload_2
      26: aload_3
      27: iload         4
      29: invokestatic  #122                // Method main$getDistanceToValve:(Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;I)I
      32: ireturn

  private static final void main$parseInput(kotlin.jvm.internal.Ref$ObjectRef<java.util.Map<java.lang.String, java.lang.Integer>>, kotlin.jvm.internal.Ref$ObjectRef<java.util.Map<java.lang.String, java.util.List<java.lang.String>>>, kotlin.jvm.internal.Ref$ObjectRef<java.util.List<java.lang.String>>, java.lang.String);
    Code:
       0: new           #152                // class java/util/LinkedHashMap
       3: dup
       4: invokespecial #153                // Method java/util/LinkedHashMap."<init>":()V
       7: checkcast     #67                 // class java/util/Map
      10: astore        4
      12: new           #152                // class java/util/LinkedHashMap
      15: dup
      16: invokespecial #153                // Method java/util/LinkedHashMap."<init>":()V
      19: checkcast     #67                 // class java/util/Map
      22: astore        5
      24: aload_3
      25: invokestatic  #159                // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      28: checkcast     #77                 // class java/lang/Iterable
      31: astore        6
      33: nop
      34: iconst_0
      35: istore        7
      37: aload         6
      39: astore        8
      41: new           #79                 // class java/util/ArrayList
      44: dup
      45: aload         6
      47: bipush        10
      49: invokestatic  #163                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      52: invokespecial #165                // Method java/util/ArrayList."<init>":(I)V
      55: checkcast     #82                 // class java/util/Collection
      58: astore        9
      60: iconst_0
      61: istore        10
      63: aload         8
      65: invokeinterface #86,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      70: astore        11
      72: aload         11
      74: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      79: ifeq          144
      82: aload         11
      84: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      89: astore        12
      91: aload         9
      93: aload         12
      95: checkcast     #98                 // class java/lang/String
      98: astore        13
     100: astore        18
     102: iconst_0
     103: istore        14
     105: aload         13
     107: checkcast     #167                // class java/lang/CharSequence
     110: iconst_1
     111: anewarray     #98                 // class java/lang/String
     114: astore        15
     116: aload         15
     118: iconst_0
     119: ldc           #169                // String ;
     121: aastore
     122: aload         15
     124: iconst_0
     125: iconst_0
     126: bipush        6
     128: aconst_null
     129: invokestatic  #175                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     132: aload         18
     134: swap
     135: invokeinterface #107,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     140: pop
     141: goto          72
     144: aload         9
     146: checkcast     #100                // class java/util/List
     149: nop
     150: checkcast     #77                 // class java/lang/Iterable
     153: astore        6
     155: nop
     156: iconst_0
     157: istore        7
     159: aload         6
     161: invokeinterface #86,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     166: astore        8
     168: aload         8
     170: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     175: ifeq          313
     178: aload         8
     180: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     185: astore        9
     187: aload         9
     189: checkcast     #100                // class java/util/List
     192: astore        10
     194: iconst_0
     195: istore        11
     197: aload         10
     199: iconst_0
     200: invokeinterface #178,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     205: checkcast     #98                 // class java/lang/String
     208: astore        12
     210: aload         10
     212: iconst_1
     213: invokeinterface #178,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     218: checkcast     #98                 // class java/lang/String
     221: astore        13
     223: aload         12
     225: new           #180                // class kotlin/text/Regex
     228: dup
     229: ldc           #182                // String [A-Z][A-Z]
     231: invokespecial #183                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
     234: invokestatic  #187                // Method UtilsKt.getAllByRegex:(Ljava/lang/String;Lkotlin/text/Regex;)Ljava/util/List;
     237: invokestatic  #191                // Method kotlin/collections/CollectionsKt.single:(Ljava/util/List;)Ljava/lang/Object;
     240: checkcast     #98                 // class java/lang/String
     243: astore        14
     245: aload         12
     247: invokestatic  #194                // Method UtilsKt.getAllInts:(Ljava/lang/String;)Ljava/util/List;
     250: invokestatic  #191                // Method kotlin/collections/CollectionsKt.single:(Ljava/util/List;)Ljava/lang/Object;
     253: checkcast     #196                // class java/lang/Number
     256: invokevirtual #200                // Method java/lang/Number.intValue:()I
     259: istore        15
     261: aload         13
     263: new           #180                // class kotlin/text/Regex
     266: dup
     267: ldc           #182                // String [A-Z][A-Z]
     269: invokespecial #183                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
     272: invokestatic  #187                // Method UtilsKt.getAllByRegex:(Ljava/lang/String;Lkotlin/text/Regex;)Ljava/util/List;
     275: astore        16
     277: iload         15
     279: invokestatic  #206                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     282: astore        17
     284: aload         4
     286: aload         14
     288: aload         17
     290: invokeinterface #210,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     295: pop
     296: aload         5
     298: aload         14
     300: aload         16
     302: invokeinterface #210,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     307: pop
     308: nop
     309: nop
     310: goto          168
     313: nop
     314: aload_0
     315: aload         4
     317: putfield      #59                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     320: aload_1
     321: aload         5
     323: putfield      #59                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     326: aload_2
     327: aload_0
     328: getfield      #59                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     331: ifnonnull     343
     334: ldc           #211                // String flowRates
     336: invokestatic  #65                 // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V
     339: aconst_null
     340: goto          350
     343: aload_0
     344: getfield      #59                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     347: checkcast     #67                 // class java/util/Map
     350: invokeinterface #215,  1          // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;
     355: checkcast     #77                 // class java/lang/Iterable
     358: astore        6
     360: astore        18
     362: iconst_0
     363: istore        7
     365: aload         6
     367: astore        8
     369: new           #79                 // class java/util/ArrayList
     372: dup
     373: invokespecial #80                 // Method java/util/ArrayList."<init>":()V
     376: checkcast     #82                 // class java/util/Collection
     379: astore        9
     381: iconst_0
     382: istore        10
     384: aload         8
     386: invokeinterface #86,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     391: astore        11
     393: aload         11
     395: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     400: ifeq          486
     403: aload         11
     405: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     410: astore        12
     412: aload         12
     414: checkcast     #98                 // class java/lang/String
     417: astore        13
     419: iconst_0
     420: istore        14
     422: aload_0
     423: getfield      #59                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     426: ifnonnull     438
     429: ldc           #211                // String flowRates
     431: invokestatic  #65                 // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V
     434: aconst_null
     435: goto          445
     438: aload_0
     439: getfield      #59                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     442: checkcast     #67                 // class java/util/Map
     445: aload         13
     447: invokeinterface #71,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     452: dup
     453: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     456: checkcast     #196                // class java/lang/Number
     459: invokevirtual #200                // Method java/lang/Number.intValue:()I
     462: ifle          469
     465: iconst_1
     466: goto          470
     469: iconst_0
     470: ifeq          393
     473: aload         9
     475: aload         12
     477: invokeinterface #107,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     482: pop
     483: goto          393
     486: aload         9
     488: checkcast     #100                // class java/util/List
     491: nop
     492: aload         18
     494: swap
     495: putfield      #59                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     498: return

  private static final java.util.Map<kotlin.Pair<java.lang.String, java.lang.String>, java.lang.Integer> main$calculateDistancesBetweenValves(kotlin.jvm.internal.Ref$ObjectRef<java.util.Map<java.lang.String, java.util.List<java.lang.String>>>, java.util.List<java.lang.String>);
    Code:
       0: new           #152                // class java/util/LinkedHashMap
       3: dup
       4: invokespecial #153                // Method java/util/LinkedHashMap."<init>":()V
       7: checkcast     #67                 // class java/util/Map
      10: astore_2
      11: aload_1
      12: invokeinterface #239,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      17: astore_3
      18: aload_3
      19: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      24: ifeq          101
      27: aload_3
      28: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      33: checkcast     #98                 // class java/lang/String
      36: astore        4
      38: aload_1
      39: invokeinterface #239,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      44: astore        5
      46: aload         5
      48: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      53: ifeq          18
      56: aload         5
      58: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: checkcast     #98                 // class java/lang/String
      66: astore        6
      68: aload_2
      69: aload         4
      71: aload         6
      73: invokestatic  #245                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      76: aload_0
      77: aload         4
      79: aload         6
      81: aconst_null
      82: iconst_0
      83: bipush        24
      85: aconst_null
      86: invokestatic  #247                // Method main$getDistanceToValve$default:(Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;IILjava/lang/Object;)I
      89: invokestatic  #206                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      92: invokeinterface #210,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      97: pop
      98: goto          46
     101: aload_2
     102: areturn

  private static final int main$maxPath(kotlin.jvm.internal.Ref$ObjectRef<java.util.Map<kotlin.Pair<java.lang.String, java.lang.String>, java.lang.Integer>>, kotlin.jvm.internal.Ref$ObjectRef<java.util.Map<java.lang.String, java.lang.Integer>>, java.lang.String, int, java.util.Set<java.lang.String>, int);
    Code:
       0: aload         4
       2: aload_2
       3: invokestatic  #258                // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Object;)Ljava/util/Set;
       6: astore        6
       8: aload         6
      10: checkcast     #77                 // class java/lang/Iterable
      13: astore        8
      15: iconst_0
      16: istore        9
      18: aload         8
      20: invokeinterface #86,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      25: astore        10
      27: aload         10
      29: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      34: ifeq          112
      37: aload         10
      39: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      44: astore        11
      46: iload         9
      48: aload         11
      50: checkcast     #98                 // class java/lang/String
      53: astore        12
      55: istore        21
      57: iconst_0
      58: istore        13
      60: aload_1
      61: getfield      #59                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      64: ifnonnull     76
      67: ldc           #211                // String flowRates
      69: invokestatic  #65                 // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V
      72: aconst_null
      73: goto          83
      76: aload_1
      77: getfield      #59                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      80: checkcast     #67                 // class java/util/Map
      83: aload         12
      85: invokeinterface #71,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      90: dup
      91: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      94: checkcast     #196                // class java/lang/Number
      97: invokevirtual #200                // Method java/lang/Number.intValue:()I
     100: istore        22
     102: iload         21
     104: iload         22
     106: iadd
     107: istore        9
     109: goto          27
     112: iload         9
     114: istore        7
     116: aload_0
     117: getfield      #59                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     120: ifnonnull     133
     123: ldc_w         #259                // String distances
     126: invokestatic  #65                 // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V
     129: aconst_null
     130: goto          140
     133: aload_0
     134: getfield      #59                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     137: checkcast     #67                 // class java/util/Map
     140: astore        8
     142: nop
     143: iconst_0
     144: istore        9
     146: aload         8
     148: astore        10
     150: new           #152                // class java/util/LinkedHashMap
     153: dup
     154: invokespecial #153                // Method java/util/LinkedHashMap."<init>":()V
     157: checkcast     #67                 // class java/util/Map
     160: astore        11
     162: iconst_0
     163: istore        12
     165: aload         10
     167: invokeinterface #262,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     172: invokeinterface #265,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     177: astore        13
     179: aload         13
     181: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     186: ifeq          303
     189: aload         13
     191: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     196: checkcast     #267                // class java/util/Map$Entry
     199: astore        14
     201: aload         14
     203: astore        15
     205: iconst_0
     206: istore        16
     208: aload         15
     210: invokeinterface #270,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     215: checkcast     #272                // class kotlin/Pair
     218: astore        17
     220: aload         15
     222: invokeinterface #275,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     227: checkcast     #196                // class java/lang/Number
     230: invokevirtual #200                // Method java/lang/Number.intValue:()I
     233: istore        18
     235: aload         17
     237: invokevirtual #278                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     240: aload_2
     241: invokestatic  #282                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     244: ifeq          274
     247: aload         4
     249: aload         17
     251: invokevirtual #285                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     254: invokeinterface #286,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     259: ifne          274
     262: iload         18
     264: iload_3
     265: iconst_1
     266: isub
     267: if_icmpgt     274
     270: iconst_1
     271: goto          275
     274: iconst_0
     275: ifeq          179
     278: aload         11
     280: aload         14
     282: invokeinterface #270,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     287: aload         14
     289: invokeinterface #275,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     294: invokeinterface #210,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     299: pop
     300: goto          179
     303: aload         11
     305: nop
     306: astore        8
     308: nop
     309: iconst_0
     310: istore        9
     312: aload         8
     314: astore        10
     316: new           #79                 // class java/util/ArrayList
     319: dup
     320: aload         8
     322: invokeinterface #289,  1          // InterfaceMethod java/util/Map.size:()I
     327: invokespecial #165                // Method java/util/ArrayList."<init>":(I)V
     330: checkcast     #82                 // class java/util/Collection
     333: astore        11
     335: iconst_0
     336: istore        12
     338: aload         10
     340: invokeinterface #262,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     345: invokeinterface #265,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     350: astore        13
     352: aload         13
     354: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     359: ifeq          441
     362: aload         13
     364: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     369: checkcast     #267                // class java/util/Map$Entry
     372: astore        14
     374: aload         11
     376: aload         14
     378: astore        15
     380: astore        21
     382: iconst_0
     383: istore        16
     385: aload         15
     387: invokeinterface #270,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     392: checkcast     #272                // class kotlin/Pair
     395: astore        17
     397: aload         15
     399: invokeinterface #275,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     404: checkcast     #196                // class java/lang/Number
     407: invokevirtual #200                // Method java/lang/Number.intValue:()I
     410: istore        18
     412: new           #272                // class kotlin/Pair
     415: dup
     416: aload         17
     418: invokevirtual #285                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     421: iload         18
     423: invokestatic  #206                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     426: invokespecial #292                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     429: aload         21
     431: swap
     432: invokeinterface #107,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     437: pop
     438: goto          352
     441: aload         11
     443: checkcast     #100                // class java/util/List
     446: nop
     447: checkcast     #77                 // class java/lang/Iterable
     450: astore        8
     452: nop
     453: iconst_0
     454: istore        9
     456: aload         8
     458: astore        10
     460: new           #79                 // class java/util/ArrayList
     463: dup
     464: aload         8
     466: bipush        10
     468: invokestatic  #163                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     471: invokespecial #165                // Method java/util/ArrayList."<init>":(I)V
     474: checkcast     #82                 // class java/util/Collection
     477: astore        11
     479: iconst_0
     480: istore        12
     482: aload         10
     484: invokeinterface #86,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     489: astore        13
     491: aload         13
     493: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     498: ifeq          595
     501: aload         13
     503: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     508: astore        14
     510: aload         11
     512: aload         14
     514: checkcast     #272                // class kotlin/Pair
     517: astore        15
     519: astore        21
     521: iconst_0
     522: istore        16
     524: aload         15
     526: invokevirtual #295                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     529: checkcast     #98                 // class java/lang/String
     532: astore        17
     534: aload         15
     536: invokevirtual #298                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     539: checkcast     #196                // class java/lang/Number
     542: invokevirtual #200                // Method java/lang/Number.intValue:()I
     545: istore        18
     547: iload_3
     548: iload         18
     550: isub
     551: iconst_1
     552: isub
     553: istore        19
     555: iload         5
     557: iload         18
     559: iconst_1
     560: iadd
     561: iload         7
     563: imul
     564: iadd
     565: istore        20
     567: aload_0
     568: aload_1
     569: aload         17
     571: iload         19
     573: aload         6
     575: iload         20
     577: invokestatic  #300                // Method main$maxPath:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;ILjava/util/Set;I)I
     580: invokestatic  #206                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     583: aload         21
     585: swap
     586: invokeinterface #107,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     591: pop
     592: goto          491
     595: aload         11
     597: checkcast     #100                // class java/util/List
     600: nop
     601: checkcast     #82                 // class java/util/Collection
     604: iload         5
     606: iload_3
     607: iload         7
     609: imul
     610: iadd
     611: invokestatic  #206                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     614: invokestatic  #117                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     617: checkcast     #77                 // class java/lang/Iterable
     620: invokestatic  #304                // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     623: checkcast     #196                // class java/lang/Number
     626: invokevirtual #200                // Method java/lang/Number.intValue:()I
     629: ireturn

  static int main$maxPath$default(kotlin.jvm.internal.Ref$ObjectRef, kotlin.jvm.internal.Ref$ObjectRef, java.lang.String, int, java.util.Set, int, int, java.lang.Object);
    Code:
       0: iload         6
       2: bipush        16
       4: iand
       5: ifeq          13
       8: invokestatic  #327                // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;
      11: astore        4
      13: iload         6
      15: bipush        32
      17: iand
      18: ifeq          24
      21: iconst_0
      22: istore        5
      24: aload_0
      25: aload_1
      26: aload_2
      27: iload_3
      28: aload         4
      30: iload         5
      32: invokestatic  #300                // Method main$maxPath:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;ILjava/util/Set;I)I
      35: ireturn

  private static final int main$part1(kotlin.jvm.internal.Ref$ObjectRef<java.util.Map<kotlin.Pair<java.lang.String, java.lang.String>, java.lang.Integer>>, kotlin.jvm.internal.Ref$ObjectRef<java.util.List<java.lang.String>>, kotlin.jvm.internal.Ref$ObjectRef<java.util.Map<java.lang.String, java.util.List<java.lang.String>>>, kotlin.jvm.internal.Ref$ObjectRef<java.util.Map<java.lang.String, java.lang.Integer>>);
    Code:
       0: ldc_w         #330                // String AA
       3: astore        4
       5: aload_0
       6: aload_2
       7: aload_1
       8: getfield      #59                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      11: ifnonnull     24
      14: ldc_w         #331                // String workingValves
      17: invokestatic  #65                 // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V
      20: aconst_null
      21: goto          31
      24: aload_1
      25: getfield      #59                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      28: checkcast     #100                // class java/util/List
      31: checkcast     #82                 // class java/util/Collection
      34: aload         4
      36: invokestatic  #117                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
      39: invokestatic  #333                // Method main$calculateDistancesBetweenValves:(Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/util/List;)Ljava/util/Map;
      42: putfield      #59                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      45: aload_0
      46: aload_3
      47: aload         4
      49: bipush        30
      51: aconst_null
      52: iconst_0
      53: bipush        48
      55: aconst_null
      56: invokestatic  #335                // Method main$maxPath$default:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;ILjava/util/Set;IILjava/lang/Object;)I
      59: ireturn
}


fun main() {
    fun parseArray(arrayText: String): List<Any> {
        fun nodeToList(node: Node): List<Any> {
            return node.children.map { child ->
                if (child is Leaf) {
                    child.value ?: emptyList<Any>()
                } else {
                    nodeToList(child)
                }
            }
        }

        fun addLeaf(builder: StringBuilder, node: Node?) {
            if (builder.isNotEmpty()) {
                node?.addChild(Leaf(node, builder.toString().toInt()))
                builder.clear()
            }
        }

        var node: Node? = null
        val numberBuilder = StringBuilder()
        arrayText.forEach {
            when {
                it == '[' -> {
                    val newNode = Node(node)
                    node?.addChild(newNode)
                    node = newNode
                }

                it.isDigit() -> {
                    numberBuilder.append(it)
                }

                it == ',' -> {
                    addLeaf(numberBuilder, node)
                }

                it == ']' -> {
                    addLeaf(numberBuilder, node)
                    node = node?.parent ?: node
                }
            }
        }
        return node?.let { nodeToList(it) } ?: emptyList()
    }

    fun compare(first: Any?, second: Any?): Int {
        if (first is Int && second is Int) {
            return first.compareTo(second)
        } else if (first is Int && second is List<*>) {
            return compare(listOf(first), second)
        } else if (first is List<*> && second is Int) {
            return compare(first, listOf(second))
        } else if (first is List<*> && second is List<*>) {
            val pairs = first.zip(second)
            for (pair in pairs) {
                val result = compare(pair.first, pair.second)
                if (result != 0) {
                    return result
                }
            }
            return first.size.compareTo(second.size)
        } else {
            return 0
        }
    }

    fun part1(inputName: String) =
        readGroupedInput(inputName)
            .map { group ->
                group.split("\n").map { parseArray(it) }.pair()
            }.map {
                compare(it.first, it.second)
            }.mapIndexed { index, it ->
                if (it < 0) index + 1 else 0
            }.sum()

    fun part2(inputName: String): Int {
        val dividerPackets = listOf(listOf(listOf(2)), listOf(listOf(6)))
        val packets = readInput(inputName)
            .filter { it.isNotBlank() }
            .map { parseArray(it) }
            .toMutableList()
            .also { it.addAll(dividerPackets) }

        val sortedPackets = packets.sortedWith { o1, o2 -> compare(o1, o2) }
        return dividerPackets.map { sortedPackets.indexOf(it) + 1 }.factorial()
    }

    val testInputName = "Day13_test"
    check(part1(testInputName) == 13)
    check(part2(testInputName) == 140)

    val inputName = "Day13"
    println(part1(inputName))
    println(part2(inputName))

}

private open class Node(parent: Node?) {
    var parent: Node? = parent
        private set

    private val _children: MutableList<Node> = mutableListOf()
    val children: List<Node>
        get() = _children.toList()

    fun addChild(child: Node) {
        child.parent = this
        _children.add(child)
    }
}

private class Leaf(parent: Node?, val value: Int?) : Node(parent)

Compiled from "Day13.kt"
public final class Day13Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day13_test
       2: astore_0
       3: aload_0
       4: invokestatic  #12                 // Method main$part1:(Ljava/lang/String;)I
       7: bipush        13
       9: if_icmpne     16
      12: iconst_1
      13: goto          17
      16: iconst_0
      17: ifne          30
      20: new           #14                 // class java/lang/IllegalStateException
      23: dup
      24: ldc           #16                 // String Check failed.
      26: invokespecial #20                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      29: athrow
      30: aload_0
      31: invokestatic  #23                 // Method main$part2:(Ljava/lang/String;)I
      34: sipush        140
      37: if_icmpne     44
      40: iconst_1
      41: goto          45
      44: iconst_0
      45: ifne          58
      48: new           #14                 // class java/lang/IllegalStateException
      51: dup
      52: ldc           #16                 // String Check failed.
      54: invokespecial #20                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      57: athrow
      58: ldc           #25                 // String Day13
      60: astore_1
      61: aload_1
      62: invokestatic  #12                 // Method main$part1:(Ljava/lang/String;)I
      65: istore_2
      66: getstatic     #31                 // Field java/lang/System.out:Ljava/io/PrintStream;
      69: iload_2
      70: invokevirtual #37                 // Method java/io/PrintStream.println:(I)V
      73: aload_1
      74: invokestatic  #23                 // Method main$part2:(Ljava/lang/String;)I
      77: istore_2
      78: getstatic     #31                 // Field java/lang/System.out:Ljava/io/PrintStream;
      81: iload_2
      82: invokevirtual #37                 // Method java/io/PrintStream.println:(I)V
      85: return

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

  private static final java.util.List<java.lang.Object> main$parseArray$nodeToList(Node);
    Code:
       0: aload_0
       1: invokevirtual #56                 // Method Node.getChildren:()Ljava/util/List;
       4: checkcast     #58                 // class java/lang/Iterable
       7: astore_1
       8: iconst_0
       9: istore_2
      10: aload_1
      11: astore_3
      12: new           #60                 // class java/util/ArrayList
      15: dup
      16: aload_1
      17: bipush        10
      19: invokestatic  #66                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      22: invokespecial #68                 // Method java/util/ArrayList."<init>":(I)V
      25: checkcast     #70                 // class java/util/Collection
      28: astore        4
      30: iconst_0
      31: istore        5
      33: aload_3
      34: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      39: astore        6
      41: aload         6
      43: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      48: ifeq          119
      51: aload         6
      53: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      58: astore        7
      60: aload         4
      62: aload         7
      64: checkcast     #52                 // class Node
      67: astore        8
      69: astore        10
      71: iconst_0
      72: istore        9
      74: aload         8
      76: instanceof    #86                 // class Leaf
      79: ifeq          101
      82: aload         8
      84: checkcast     #86                 // class Leaf
      87: invokevirtual #90                 // Method Leaf.getValue:()Ljava/lang/Integer;
      90: dup
      91: ifnonnull     106
      94: pop
      95: invokestatic  #93                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      98: goto          106
     101: aload         8
     103: invokestatic  #95                 // Method main$parseArray$nodeToList:(LNode;)Ljava/util/List;
     106: nop
     107: aload         10
     109: swap
     110: invokeinterface #99,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     115: pop
     116: goto          41
     119: aload         4
     121: checkcast     #101                // class java/util/List
     124: nop
     125: areturn

  private static final void main$parseArray$addLeaf(java.lang.StringBuilder, Node);
    Code:
       0: aload_0
       1: checkcast     #119                // class java/lang/CharSequence
       4: invokeinterface #123,  1          // InterfaceMethod java/lang/CharSequence.length:()I
       9: ifle          16
      12: iconst_1
      13: goto          17
      16: iconst_0
      17: ifeq          64
      20: aload_1
      21: dup
      22: ifnull        58
      25: new           #86                 // class Leaf
      28: dup
      29: aload_1
      30: aload_0
      31: invokevirtual #129                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      34: dup
      35: ldc           #131                // String toString(...)
      37: invokestatic  #137                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      40: invokestatic  #142                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      43: invokestatic  #146                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      46: invokespecial #149                // Method Leaf."<init>":(LNode;Ljava/lang/Integer;)V
      49: checkcast     #52                 // class Node
      52: invokevirtual #153                // Method Node.addChild:(LNode;)V
      55: goto          59
      58: pop
      59: aload_0
      60: invokestatic  #159                // Method kotlin/text/StringsKt.clear:(Ljava/lang/StringBuilder;)Ljava/lang/StringBuilder;
      63: pop
      64: return

  private static final java.util.List<java.lang.Object> main$parseArray(java.lang.String);
    Code:
       0: aconst_null
       1: astore_1
       2: new           #125                // class java/lang/StringBuilder
       5: dup
       6: invokespecial #166                // Method java/lang/StringBuilder."<init>":()V
       9: astore_2
      10: aload_0
      11: checkcast     #119                // class java/lang/CharSequence
      14: astore_3
      15: iconst_0
      16: istore        4
      18: iconst_0
      19: istore        5
      21: iload         5
      23: aload_3
      24: invokeinterface #123,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      29: if_icmpge     155
      32: aload_3
      33: iload         5
      35: invokeinterface #170,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
      40: istore        6
      42: iload         6
      44: istore        7
      46: iconst_0
      47: istore        8
      49: nop
      50: iload         7
      52: bipush        91
      54: if_icmpne     87
      57: new           #52                 // class Node
      60: dup
      61: aload_1
      62: invokespecial #172                // Method Node."<init>":(LNode;)V
      65: astore        9
      67: aload_1
      68: dup
      69: ifnull        80
      72: aload         9
      74: invokevirtual #153                // Method Node.addChild:(LNode;)V
      77: goto          81
      80: pop
      81: aload         9
      83: astore_1
      84: goto          147
      87: iload         7
      89: invokestatic  #178                // Method java/lang/Character.isDigit:(C)Z
      92: ifeq          105
      95: aload_2
      96: iload         7
      98: invokevirtual #182                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     101: pop
     102: goto          147
     105: iload         7
     107: bipush        44
     109: if_icmpne     120
     112: aload_2
     113: aload_1
     114: invokestatic  #184                // Method main$parseArray$addLeaf:(Ljava/lang/StringBuilder;LNode;)V
     117: goto          147
     120: iload         7
     122: bipush        93
     124: if_icmpne     147
     127: aload_2
     128: aload_1
     129: invokestatic  #184                // Method main$parseArray$addLeaf:(Ljava/lang/StringBuilder;LNode;)V
     132: aload_1
     133: dup
     134: ifnull        144
     137: invokevirtual #188                // Method Node.getParent:()LNode;
     140: dup
     141: ifnonnull     146
     144: pop
     145: aload_1
     146: astore_1
     147: nop
     148: nop
     149: iinc          5, 1
     152: goto          21
     155: nop
     156: aload_1
     157: dup
     158: ifnull        176
     161: astore        6
     163: iconst_0
     164: istore        7
     166: aload         6
     168: invokestatic  #95                 // Method main$parseArray$nodeToList:(LNode;)Ljava/util/List;
     171: nop
     172: dup
     173: ifnonnull     180
     176: pop
     177: invokestatic  #93                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     180: areturn

  private static final int main$compare(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: instanceof    #139                // class java/lang/Integer
       4: ifeq          32
       7: aload_1
       8: instanceof    #139                // class java/lang/Integer
      11: ifeq          32
      14: aload_0
      15: checkcast     #203                // class java/lang/Number
      18: invokevirtual #206                // Method java/lang/Number.intValue:()I
      21: aload_1
      22: checkcast     #203                // class java/lang/Number
      25: invokevirtual #206                // Method java/lang/Number.intValue:()I
      28: invokestatic  #210                // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
      31: ireturn
      32: aload_0
      33: instanceof    #139                // class java/lang/Integer
      36: ifeq          55
      39: aload_1
      40: instanceof    #101                // class java/util/List
      43: ifeq          55
      46: aload_0
      47: invokestatic  #214                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      50: aload_1
      51: invokestatic  #216                // Method main$compare:(Ljava/lang/Object;Ljava/lang/Object;)I
      54: ireturn
      55: aload_0
      56: instanceof    #101                // class java/util/List
      59: ifeq          78
      62: aload_1
      63: instanceof    #139                // class java/lang/Integer
      66: ifeq          78
      69: aload_0
      70: aload_1
      71: invokestatic  #214                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      74: invokestatic  #216                // Method main$compare:(Ljava/lang/Object;Ljava/lang/Object;)I
      77: ireturn
      78: aload_0
      79: instanceof    #101                // class java/util/List
      82: ifeq          176
      85: aload_1
      86: instanceof    #101                // class java/util/List
      89: ifeq          176
      92: aload_0
      93: checkcast     #58                 // class java/lang/Iterable
      96: aload_1
      97: checkcast     #58                 // class java/lang/Iterable
     100: invokestatic  #220                // Method kotlin/collections/CollectionsKt.zip:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;
     103: astore_2
     104: aload_2
     105: invokeinterface #221,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     110: astore_3
     111: aload_3
     112: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     117: ifeq          154
     120: aload_3
     121: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     126: checkcast     #223                // class kotlin/Pair
     129: astore        4
     131: aload         4
     133: invokevirtual #226                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     136: aload         4
     138: invokevirtual #229                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     141: invokestatic  #216                // Method main$compare:(Ljava/lang/Object;Ljava/lang/Object;)I
     144: istore        5
     146: iload         5
     148: ifeq          111
     151: iload         5
     153: ireturn
     154: aload_0
     155: checkcast     #101                // class java/util/List
     158: invokeinterface #232,  1          // InterfaceMethod java/util/List.size:()I
     163: aload_1
     164: checkcast     #101                // class java/util/List
     167: invokeinterface #232,  1          // InterfaceMethod java/util/List.size:()I
     172: invokestatic  #210                // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
     175: ireturn
     176: iconst_0
     177: ireturn

  private static final int main$part1(java.lang.String);
    Code:
       0: aload_0
       1: invokestatic  #244                // Method UtilsKt.readGroupedInput:(Ljava/lang/String;)Ljava/util/List;
       4: checkcast     #58                 // class java/lang/Iterable
       7: astore_1
       8: nop
       9: iconst_0
      10: istore_2
      11: aload_1
      12: astore_3
      13: new           #60                 // class java/util/ArrayList
      16: dup
      17: aload_1
      18: bipush        10
      20: invokestatic  #66                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      23: invokespecial #68                 // Method java/util/ArrayList."<init>":(I)V
      26: checkcast     #70                 // class java/util/Collection
      29: astore        4
      31: iconst_0
      32: istore        5
      34: aload_3
      35: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      40: astore        6
      42: aload         6
      44: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      49: ifeq          216
      52: aload         6
      54: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      59: astore        7
      61: aload         4
      63: aload         7
      65: checkcast     #42                 // class java/lang/String
      68: astore        8
      70: astore        20
      72: iconst_0
      73: istore        9
      75: aload         8
      77: checkcast     #119                // class java/lang/CharSequence
      80: iconst_1
      81: anewarray     #42                 // class java/lang/String
      84: astore        10
      86: aload         10
      88: iconst_0
      89: ldc           #246                // String \n
      91: aastore
      92: aload         10
      94: iconst_0
      95: iconst_0
      96: bipush        6
      98: aconst_null
      99: invokestatic  #250                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     102: checkcast     #58                 // class java/lang/Iterable
     105: astore        10
     107: iconst_0
     108: istore        11
     110: aload         10
     112: astore        12
     114: new           #60                 // class java/util/ArrayList
     117: dup
     118: aload         10
     120: bipush        10
     122: invokestatic  #66                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     125: invokespecial #68                 // Method java/util/ArrayList."<init>":(I)V
     128: checkcast     #70                 // class java/util/Collection
     131: astore        13
     133: iconst_0
     134: istore        14
     136: aload         12
     138: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     143: astore        15
     145: aload         15
     147: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     152: ifeq          195
     155: aload         15
     157: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     162: astore        16
     164: aload         13
     166: aload         16
     168: checkcast     #42                 // class java/lang/String
     171: astore        17
     173: astore        18
     175: iconst_0
     176: istore        19
     178: aload         17
     180: invokestatic  #252                // Method main$parseArray:(Ljava/lang/String;)Ljava/util/List;
     183: aload         18
     185: swap
     186: invokeinterface #99,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     191: pop
     192: goto          145
     195: aload         13
     197: checkcast     #101                // class java/util/List
     200: nop
     201: invokestatic  #255                // Method UtilsKt.pair:(Ljava/util/List;)Lkotlin/Pair;
     204: aload         20
     206: swap
     207: invokeinterface #99,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     212: pop
     213: goto          42
     216: aload         4
     218: checkcast     #101                // class java/util/List
     221: nop
     222: checkcast     #58                 // class java/lang/Iterable
     225: astore_1
     226: nop
     227: iconst_0
     228: istore_2
     229: aload_1
     230: astore_3
     231: new           #60                 // class java/util/ArrayList
     234: dup
     235: aload_1
     236: bipush        10
     238: invokestatic  #66                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     241: invokespecial #68                 // Method java/util/ArrayList."<init>":(I)V
     244: checkcast     #70                 // class java/util/Collection
     247: astore        4
     249: iconst_0
     250: istore        5
     252: aload_3
     253: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     258: astore        6
     260: aload         6
     262: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     267: ifeq          321
     270: aload         6
     272: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     277: astore        7
     279: aload         4
     281: aload         7
     283: checkcast     #223                // class kotlin/Pair
     286: astore        8
     288: astore        20
     290: iconst_0
     291: istore        9
     293: aload         8
     295: invokevirtual #226                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     298: aload         8
     300: invokevirtual #229                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     303: invokestatic  #216                // Method main$compare:(Ljava/lang/Object;Ljava/lang/Object;)I
     306: invokestatic  #146                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     309: aload         20
     311: swap
     312: invokeinterface #99,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     317: pop
     318: goto          260
     321: aload         4
     323: checkcast     #101                // class java/util/List
     326: nop
     327: checkcast     #58                 // class java/lang/Iterable
     330: astore_1
     331: nop
     332: iconst_0
     333: istore_2
     334: aload_1
     335: astore_3
     336: new           #60                 // class java/util/ArrayList
     339: dup
     340: aload_1
     341: bipush        10
     343: invokestatic  #66                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     346: invokespecial #68                 // Method java/util/ArrayList."<init>":(I)V
     349: checkcast     #70                 // class java/util/Collection
     352: astore        4
     354: iconst_0
     355: istore        5
     357: iconst_0
     358: istore        6
     360: aload_3
     361: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     366: astore        7
     368: aload         7
     370: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     375: ifeq          451
     378: aload         7
     380: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     385: astore        8
     387: aload         4
     389: iload         6
     391: iinc          6, 1
     394: istore        9
     396: iload         9
     398: ifge          404
     401: invokestatic  #258                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     404: iload         9
     406: aload         8
     408: checkcast     #203                // class java/lang/Number
     411: invokevirtual #206                // Method java/lang/Number.intValue:()I
     414: istore        10
     416: istore        11
     418: astore        20
     420: iconst_0
     421: istore        12
     423: iload         10
     425: ifge          435
     428: iload         11
     430: iconst_1
     431: iadd
     432: goto          436
     435: iconst_0
     436: invokestatic  #146                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     439: aload         20
     441: swap
     442: invokeinterface #99,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     447: pop
     448: goto          368
     451: aload         4
     453: checkcast     #101                // class java/util/List
     456: nop
     457: checkcast     #58                 // class java/lang/Iterable
     460: invokestatic  #262                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     463: ireturn

  private static final int main$part2$lambda$10(java.util.List, java.util.List);
    Code:
       0: aload_0
       1: aload_1
       2: invokestatic  #216                // Method main$compare:(Ljava/lang/Object;Ljava/lang/Object;)I
       5: ireturn

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

  private static final int main$part2(java.lang.String);
    Code:
       0: iconst_2
       1: anewarray     #101                // class java/util/List
       4: astore_2
       5: aload_2
       6: iconst_0
       7: iconst_2
       8: invokestatic  #146                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      11: invokestatic  #214                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      14: invokestatic  #214                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      17: aastore
      18: aload_2
      19: iconst_1
      20: bipush        6
      22: invokestatic  #146                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      25: invokestatic  #214                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      28: invokestatic  #214                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      31: aastore
      32: aload_2
      33: invokestatic  #292                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      36: astore_1
      37: aload_0
      38: invokestatic  #295                // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      41: checkcast     #58                 // class java/lang/Iterable
      44: astore_3
      45: nop
      46: iconst_0
      47: istore        4
      49: aload_3
      50: astore        5
      52: new           #60                 // class java/util/ArrayList
      55: dup
      56: invokespecial #296                // Method java/util/ArrayList."<init>":()V
      59: checkcast     #70                 // class java/util/Collection
      62: astore        6
      64: iconst_0
      65: istore        7
      67: aload         5
      69: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      74: astore        8
      76: aload         8
      78: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      83: ifeq          138
      86: aload         8
      88: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      93: astore        9
      95: aload         9
      97: checkcast     #42                 // class java/lang/String
     100: astore        10
     102: iconst_0
     103: istore        11
     105: aload         10
     107: checkcast     #119                // class java/lang/CharSequence
     110: invokestatic  #300                // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z
     113: ifne          120
     116: iconst_1
     117: goto          121
     120: iconst_0
     121: nop
     122: ifeq          76
     125: aload         6
     127: aload         9
     129: invokeinterface #99,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     134: pop
     135: goto          76
     138: aload         6
     140: checkcast     #101                // class java/util/List
     143: nop
     144: checkcast     #58                 // class java/lang/Iterable
     147: astore_3
     148: nop
     149: iconst_0
     150: istore        4
     152: aload_3
     153: astore        5
     155: new           #60                 // class java/util/ArrayList
     158: dup
     159: aload_3
     160: bipush        10
     162: invokestatic  #66                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     165: invokespecial #68                 // Method java/util/ArrayList."<init>":(I)V
     168: checkcast     #70                 // class java/util/Collection
     171: astore        6
     173: iconst_0
     174: istore        7
     176: aload         5
     178: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     183: astore        8
     185: aload         8
     187: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     192: ifeq          235
     195: aload         8
     197: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     202: astore        9
     204: aload         6
     206: aload         9
     208: checkcast     #42                 // class java/lang/String
     211: astore        10
     213: astore        13
     215: iconst_0
     216: istore        11
     218: aload         10
     220: invokestatic  #252                // Method main$parseArray:(Ljava/lang/String;)Ljava/util/List;
     223: aload         13
     225: swap
     226: invokeinterface #99,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     231: pop
     232: goto          185
     235: aload         6
     237: checkcast     #101                // class java/util/List
     240: nop
     241: checkcast     #70                 // class java/util/Collection
     244: invokestatic  #304                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     247: astore_3
     248: aload_3
     249: astore        4
     251: iconst_0
     252: istore        5
     254: aload         4
     256: aload_1
     257: checkcast     #70                 // class java/util/Collection
     260: invokeinterface #308,  2          // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z
     265: pop
     266: aload_3
     267: astore_2
     268: aload_2
     269: checkcast     #58                 // class java/lang/Iterable
     272: invokedynamic #324,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;
     277: invokedynamic #331,  0            // InvokeDynamic #1:compare:(Lkotlin/jvm/functions/Function2;)Ljava/util/Comparator;
     282: invokestatic  #335                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
     285: astore_3
     286: aload_1
     287: checkcast     #58                 // class java/lang/Iterable
     290: astore        4
     292: iconst_0
     293: istore        5
     295: aload         4
     297: astore        6
     299: new           #60                 // class java/util/ArrayList
     302: dup
     303: aload         4
     305: bipush        10
     307: invokestatic  #66                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     310: invokespecial #68                 // Method java/util/ArrayList."<init>":(I)V
     313: checkcast     #70                 // class java/util/Collection
     316: astore        7
     318: iconst_0
     319: istore        8
     321: aload         6
     323: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     328: astore        9
     330: aload         9
     332: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     337: ifeq          388
     340: aload         9
     342: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     347: astore        10
     349: aload         7
     351: aload         10
     353: checkcast     #101                // class java/util/List
     356: astore        11
     358: astore        13
     360: iconst_0
     361: istore        12
     363: aload_3
     364: aload         11
     366: invokeinterface #339,  2          // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I
     371: iconst_1
     372: iadd
     373: invokestatic  #146                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     376: aload         13
     378: swap
     379: invokeinterface #99,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     384: pop
     385: goto          330
     388: aload         7
     390: checkcast     #101                // class java/util/List
     393: nop
     394: invokestatic  #343                // Method UtilsKt.factorial:(Ljava/util/List;)I
     397: ireturn
}


fun main() {
    fun Char.getPriority() =
        (('a'..'z') + ('A'..'Z')).indexOf(this) + 1

    fun part1(input: List<String>) =
        input.map { sack -> sack.chunked(sack.length / 2).map { comp -> comp.toList() } }
            .map { (comp1, comp2) -> (comp1 intersect comp2.toSet()).single() }
            .sumOf { it.getPriority() }

    fun part2(input: List<String>) =
        input.chunked(3)
            .map { (a, b, c) -> (a.toSet() intersect b.toSet() intersect c.toSet()).single() }
            .sumOf { it.getPriority() }

    val testInput = readInput("Day03_test")
    check(part1(testInput) == 157)
    check(part2(testInput) == 70)

    val input = readInput("Day03")
    println(part1(input))
    println(part2(input))
}

Compiled from "Day03.kt"
public final class Day03Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day03_test
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)I
      10: sipush        157
      13: if_icmpne     20
      16: iconst_1
      17: goto          21
      20: iconst_0
      21: ifne          34
      24: new           #20                 // class java/lang/IllegalStateException
      27: dup
      28: ldc           #22                 // String Check failed.
      30: invokespecial #26                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      33: athrow
      34: aload_0
      35: invokestatic  #29                 // Method main$part2:(Ljava/util/List;)I
      38: bipush        70
      40: if_icmpne     47
      43: iconst_1
      44: goto          48
      47: iconst_0
      48: ifne          61
      51: new           #20                 // class java/lang/IllegalStateException
      54: dup
      55: ldc           #22                 // String Check failed.
      57: invokespecial #26                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      60: athrow
      61: ldc           #31                 // String Day03
      63: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      66: astore_1
      67: aload_1
      68: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)I
      71: istore_2
      72: getstatic     #37                 // Field java/lang/System.out:Ljava/io/PrintStream;
      75: iload_2
      76: invokevirtual #43                 // Method java/io/PrintStream.println:(I)V
      79: aload_1
      80: invokestatic  #29                 // Method main$part2:(Ljava/util/List;)I
      83: istore_2
      84: getstatic     #37                 // Field java/lang/System.out:Ljava/io/PrintStream;
      87: iload_2
      88: invokevirtual #43                 // Method java/io/PrintStream.println:(I)V
      91: return

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

  private static final int main$getPriority(char);
    Code:
       0: new           #57                 // class kotlin/ranges/CharRange
       3: dup
       4: bipush        97
       6: bipush        122
       8: invokespecial #60                 // Method kotlin/ranges/CharRange."<init>":(CC)V
      11: checkcast     #62                 // class java/lang/Iterable
      14: new           #57                 // class kotlin/ranges/CharRange
      17: dup
      18: bipush        65
      20: bipush        90
      22: invokespecial #60                 // Method kotlin/ranges/CharRange."<init>":(CC)V
      25: checkcast     #62                 // class java/lang/Iterable
      28: invokestatic  #68                 // Method kotlin/collections/CollectionsKt.plus:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;
      31: iload_0
      32: invokestatic  #74                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      35: invokeinterface #78,  2           // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I
      40: iconst_1
      41: iadd
      42: ireturn

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #62                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: astore_3
       9: new           #83                 // class java/util/ArrayList
      12: dup
      13: aload_1
      14: bipush        10
      16: invokestatic  #87                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      19: invokespecial #89                 // Method java/util/ArrayList."<init>":(I)V
      22: checkcast     #91                 // class java/util/Collection
      25: astore        4
      27: iconst_0
      28: istore        5
      30: aload_3
      31: invokeinterface #95,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      36: astore        6
      38: aload         6
      40: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      45: ifeq          201
      48: aload         6
      50: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      55: astore        7
      57: aload         4
      59: aload         7
      61: checkcast     #107                // class java/lang/String
      64: astore        8
      66: astore        20
      68: iconst_0
      69: istore        9
      71: aload         8
      73: checkcast     #109                // class java/lang/CharSequence
      76: aload         8
      78: invokevirtual #113                // Method java/lang/String.length:()I
      81: iconst_2
      82: idiv
      83: invokestatic  #119                // Method kotlin/text/StringsKt.chunked:(Ljava/lang/CharSequence;I)Ljava/util/List;
      86: checkcast     #62                 // class java/lang/Iterable
      89: astore        10
      91: iconst_0
      92: istore        11
      94: aload         10
      96: astore        12
      98: new           #83                 // class java/util/ArrayList
     101: dup
     102: aload         10
     104: bipush        10
     106: invokestatic  #87                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     109: invokespecial #89                 // Method java/util/ArrayList."<init>":(I)V
     112: checkcast     #91                 // class java/util/Collection
     115: astore        13
     117: iconst_0
     118: istore        14
     120: aload         12
     122: invokeinterface #95,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     127: astore        15
     129: aload         15
     131: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     136: ifeq          182
     139: aload         15
     141: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     146: astore        16
     148: aload         13
     150: aload         16
     152: checkcast     #107                // class java/lang/String
     155: astore        17
     157: astore        18
     159: iconst_0
     160: istore        19
     162: aload         17
     164: checkcast     #109                // class java/lang/CharSequence
     167: invokestatic  #123                // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;
     170: aload         18
     172: swap
     173: invokeinterface #127,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     178: pop
     179: goto          129
     182: aload         13
     184: checkcast     #48                 // class java/util/List
     187: nop
     188: nop
     189: aload         20
     191: swap
     192: invokeinterface #127,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     197: pop
     198: goto          38
     201: aload         4
     203: checkcast     #48                 // class java/util/List
     206: nop
     207: checkcast     #62                 // class java/lang/Iterable
     210: astore_1
     211: nop
     212: iconst_0
     213: istore_2
     214: aload_1
     215: astore_3
     216: new           #83                 // class java/util/ArrayList
     219: dup
     220: aload_1
     221: bipush        10
     223: invokestatic  #87                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     226: invokespecial #89                 // Method java/util/ArrayList."<init>":(I)V
     229: checkcast     #91                 // class java/util/Collection
     232: astore        4
     234: iconst_0
     235: istore        5
     237: aload_3
     238: invokeinterface #95,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     243: astore        6
     245: aload         6
     247: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     252: ifeq          350
     255: aload         6
     257: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     262: astore        7
     264: aload         4
     266: aload         7
     268: checkcast     #48                 // class java/util/List
     271: astore        8
     273: astore        20
     275: iconst_0
     276: istore        9
     278: aload         8
     280: iconst_0
     281: invokeinterface #131,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     286: checkcast     #48                 // class java/util/List
     289: astore        10
     291: aload         8
     293: iconst_1
     294: invokeinterface #131,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     299: checkcast     #48                 // class java/util/List
     302: astore        11
     304: aload         10
     306: checkcast     #62                 // class java/lang/Iterable
     309: aload         11
     311: checkcast     #62                 // class java/lang/Iterable
     314: invokestatic  #135                // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     317: checkcast     #62                 // class java/lang/Iterable
     320: invokestatic  #139                // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
     323: checkcast     #62                 // class java/lang/Iterable
     326: invokestatic  #143                // Method kotlin/collections/CollectionsKt.single:(Ljava/lang/Iterable;)Ljava/lang/Object;
     329: checkcast     #70                 // class java/lang/Character
     332: invokevirtual #147                // Method java/lang/Character.charValue:()C
     335: invokestatic  #74                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     338: aload         20
     340: swap
     341: invokeinterface #127,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     346: pop
     347: goto          245
     350: aload         4
     352: checkcast     #48                 // class java/util/List
     355: nop
     356: checkcast     #62                 // class java/lang/Iterable
     359: astore_1
     360: iconst_0
     361: istore_2
     362: aload_1
     363: invokeinterface #95,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     368: astore_3
     369: aload_3
     370: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     375: ifeq          418
     378: aload_3
     379: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     384: astore        4
     386: iload_2
     387: aload         4
     389: checkcast     #70                 // class java/lang/Character
     392: invokevirtual #147                // Method java/lang/Character.charValue:()C
     395: istore        5
     397: istore        20
     399: iconst_0
     400: istore        6
     402: iload         5
     404: invokestatic  #149                // Method main$getPriority:(C)I
     407: istore        21
     409: iload         20
     411: iload         21
     413: iadd
     414: istore_2
     415: goto          369
     418: iload_2
     419: ireturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #62                 // class java/lang/Iterable
       4: iconst_3
       5: invokestatic  #172                // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;
       8: checkcast     #62                 // class java/lang/Iterable
      11: astore_1
      12: nop
      13: iconst_0
      14: istore_2
      15: aload_1
      16: astore_3
      17: new           #83                 // class java/util/ArrayList
      20: dup
      21: aload_1
      22: bipush        10
      24: invokestatic  #87                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      27: invokespecial #89                 // Method java/util/ArrayList."<init>":(I)V
      30: checkcast     #91                 // class java/util/Collection
      33: astore        4
      35: iconst_0
      36: istore        5
      38: aload_3
      39: invokeinterface #95,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      44: astore        6
      46: aload         6
      48: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      53: ifeq          187
      56: aload         6
      58: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: astore        7
      65: aload         4
      67: aload         7
      69: checkcast     #48                 // class java/util/List
      72: astore        8
      74: astore        13
      76: iconst_0
      77: istore        9
      79: aload         8
      81: iconst_0
      82: invokeinterface #131,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      87: checkcast     #107                // class java/lang/String
      90: astore        10
      92: aload         8
      94: iconst_1
      95: invokeinterface #131,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     100: checkcast     #107                // class java/lang/String
     103: astore        11
     105: aload         8
     107: iconst_2
     108: invokeinterface #131,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     113: checkcast     #107                // class java/lang/String
     116: astore        12
     118: aload         10
     120: checkcast     #109                // class java/lang/CharSequence
     123: invokestatic  #175                // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;
     126: checkcast     #62                 // class java/lang/Iterable
     129: aload         11
     131: checkcast     #109                // class java/lang/CharSequence
     134: invokestatic  #175                // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;
     137: checkcast     #62                 // class java/lang/Iterable
     140: invokestatic  #139                // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
     143: checkcast     #62                 // class java/lang/Iterable
     146: aload         12
     148: checkcast     #109                // class java/lang/CharSequence
     151: invokestatic  #175                // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;
     154: checkcast     #62                 // class java/lang/Iterable
     157: invokestatic  #139                // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
     160: checkcast     #62                 // class java/lang/Iterable
     163: invokestatic  #143                // Method kotlin/collections/CollectionsKt.single:(Ljava/lang/Iterable;)Ljava/lang/Object;
     166: checkcast     #70                 // class java/lang/Character
     169: invokevirtual #147                // Method java/lang/Character.charValue:()C
     172: invokestatic  #74                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     175: aload         13
     177: swap
     178: invokeinterface #127,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     183: pop
     184: goto          46
     187: aload         4
     189: checkcast     #48                 // class java/util/List
     192: nop
     193: checkcast     #62                 // class java/lang/Iterable
     196: astore_1
     197: iconst_0
     198: istore_2
     199: aload_1
     200: invokeinterface #95,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     205: astore_3
     206: aload_3
     207: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     212: ifeq          255
     215: aload_3
     216: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     221: astore        4
     223: iload_2
     224: aload         4
     226: checkcast     #70                 // class java/lang/Character
     229: invokevirtual #147                // Method java/lang/Character.charValue:()C
     232: istore        5
     234: istore        13
     236: iconst_0
     237: istore        6
     239: iload         5
     241: invokestatic  #149                // Method main$getPriority:(C)I
     244: istore        14
     246: iload         13
     248: iload         14
     250: iadd
     251: istore_2
     252: goto          206
     255: iload_2
     256: ireturn
}