import kotlin.String
import kotlin.collections.List

object Day8 {
    data class Node(var left: Node?, var right: Node?, val key: String)
    data class DesertMap(val directions: CharArray, val root: Node?) {
        companion object {
            fun parse(input: List<String>): DesertMap {
                val directions = input.first().toCharArray()
                val nodes = parseNodes(input.drop(2))
                val root = nodes.find { it.key == "AAA" }
                return DesertMap(directions, root)
            }

            fun parsePart2(input: List<String>): List<DesertMap> {
                val directions = input.first().toCharArray()
                val nodes = parseNodes(input.drop(2))
                val roots = nodes.filter { it.key.endsWith("A") }
                return roots.map { DesertMap(directions, it) }
            }

            private fun parseNodes(input: List<String>): List<Node> {
                val index = mutableMapOf<String, Node>()
                val nodePattern = "(\\w+) = \\((\\w+), (\\w+)\\)".toRegex()
                for (line in input) {
                    val (key, left, right) = nodePattern.matchEntire(line)!!.destructured
                    val leftNode = index.getOrPut(left) { Node(null, null, left) }
                    val rightNode = index.getOrPut(right) { Node(null, null, right) }
                    val keyNode = index.getOrPut(key) { Node(null, null, key) }
                    keyNode.left = leftNode
                    keyNode.right = rightNode
                }
                return index.values.toList()
            }

        }
    }

    fun part1(input: List<String>): String {
        val desertMap = DesertMap.parse(input)
        return followUntilExit(desertMap.directions, desertMap.root, 0).toString()
    }

    private tailrec fun followUntilExit(
        directions: CharArray,
        currentNode: Node?,
        currentSteps: Long,
        exitCondition: (Node) -> Boolean = { it.key == "ZZZ" }
    ): Long {
        if (currentNode == null || exitCondition(currentNode)) {
            return currentSteps
        }
        val nextNode = if (directions.first() == 'L') {
            currentNode.left
        } else {
            currentNode.right
        }
        return followUntilExit(directions.rotate(1), nextNode, currentSteps + 1, exitCondition)
    }

    fun part2(input: List<String>): String {
        val desertMaps = DesertMap.parsePart2(input)
        return followUntilAllExit(desertMaps).toString()
    }

    private fun followUntilAllExit(desertMaps: List<DesertMap>): Long {
        val requiredStepsUntilExit =
            desertMaps.map { followUntilExit(it.directions, it.root, 0) { it.key.endsWith("Z") } }
        return leastCommonMultiple(requiredStepsUntilExit)
    }

    private fun leastCommonMultiple(requiredStepsUntilExit: List<Long>): Long {
        return requiredStepsUntilExit.reduce { a, b -> lcm(a, b) }
    }

    private fun lcm(a: Long, b: Long): Long {
        return a * b / gcd(a, b)
    }

    private fun gcd(a: Long, b: Long): Long {
        return if (b == 0L) a else gcd(b, a % b)
    }

    private fun CharArray.rotate(n: Int) =
        let { sliceArray(n..<size) + sliceArray(0..<n) }

}

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

  public final Day8$DesertMap parse(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokestatic  #28                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      10: checkcast     #30                 // class java/lang/String
      13: invokevirtual #34                 // Method java/lang/String.toCharArray:()[C
      16: dup
      17: ldc           #36                 // String toCharArray(...)
      19: invokestatic  #39                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      22: astore_2
      23: aload_0
      24: aload_1
      25: checkcast     #41                 // class java/lang/Iterable
      28: iconst_2
      29: invokestatic  #45                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
      32: invokespecial #49                 // Method parseNodes:(Ljava/util/List;)Ljava/util/List;
      35: astore_3
      36: aload_3
      37: checkcast     #41                 // class java/lang/Iterable
      40: astore        5
      42: aload         5
      44: invokeinterface #53,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      49: astore        6
      51: aload         6
      53: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      58: ifeq          98
      61: aload         6
      63: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      68: astore        7
      70: aload         7
      72: checkcast     #65                 // class Day8$Node
      75: astore        8
      77: iconst_0
      78: istore        9
      80: aload         8
      82: invokevirtual #69                 // Method Day8$Node.getKey:()Ljava/lang/String;
      85: ldc           #71                 // String AAA
      87: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      90: ifeq          51
      93: aload         7
      95: goto          99
      98: aconst_null
      99: checkcast     #65                 // class Day8$Node
     102: astore        4
     104: new           #77                 // class Day8$DesertMap
     107: dup
     108: aload_2
     109: aload         4
     111: invokespecial #80                 // Method Day8$DesertMap."<init>":([CLDay8$Node;)V
     114: areturn

  public final java.util.List<Day8$DesertMap> parsePart2(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokestatic  #28                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      10: checkcast     #30                 // class java/lang/String
      13: invokevirtual #34                 // Method java/lang/String.toCharArray:()[C
      16: dup
      17: ldc           #36                 // String toCharArray(...)
      19: invokestatic  #39                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      22: astore_2
      23: aload_0
      24: aload_1
      25: checkcast     #41                 // class java/lang/Iterable
      28: iconst_2
      29: invokestatic  #45                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
      32: invokespecial #49                 // Method parseNodes:(Ljava/util/List;)Ljava/util/List;
      35: astore_3
      36: aload_3
      37: checkcast     #41                 // class java/lang/Iterable
      40: astore        5
      42: iconst_0
      43: istore        6
      45: aload         5
      47: astore        7
      49: new           #96                 // class java/util/ArrayList
      52: dup
      53: invokespecial #97                 // Method java/util/ArrayList."<init>":()V
      56: checkcast     #99                 // class java/util/Collection
      59: astore        8
      61: iconst_0
      62: istore        9
      64: aload         7
      66: invokeinterface #53,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      71: astore        10
      73: aload         10
      75: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      80: ifeq          131
      83: aload         10
      85: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      90: astore        11
      92: aload         11
      94: checkcast     #65                 // class Day8$Node
      97: astore        12
      99: iconst_0
     100: istore        13
     102: aload         12
     104: invokevirtual #69                 // Method Day8$Node.getKey:()Ljava/lang/String;
     107: ldc           #101                // String A
     109: iconst_0
     110: iconst_2
     111: aconst_null
     112: invokestatic  #107                // Method kotlin/text/StringsKt.endsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
     115: ifeq          73
     118: aload         8
     120: aload         11
     122: invokeinterface #111,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     127: pop
     128: goto          73
     131: aload         8
     133: checkcast     #91                 // class java/util/List
     136: nop
     137: astore        4
     139: aload         4
     141: checkcast     #41                 // class java/lang/Iterable
     144: astore        5
     146: iconst_0
     147: istore        6
     149: aload         5
     151: astore        7
     153: new           #96                 // class java/util/ArrayList
     156: dup
     157: aload         5
     159: bipush        10
     161: invokestatic  #115                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     164: invokespecial #118                // Method java/util/ArrayList."<init>":(I)V
     167: checkcast     #99                 // class java/util/Collection
     170: astore        8
     172: iconst_0
     173: istore        9
     175: aload         7
     177: invokeinterface #53,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     182: astore        10
     184: aload         10
     186: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     191: ifeq          239
     194: aload         10
     196: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     201: astore        11
     203: aload         8
     205: aload         11
     207: checkcast     #65                 // class Day8$Node
     210: astore        12
     212: astore        14
     214: iconst_0
     215: istore        13
     217: new           #77                 // class Day8$DesertMap
     220: dup
     221: aload_2
     222: aload         12
     224: invokespecial #80                 // Method Day8$DesertMap."<init>":([CLDay8$Node;)V
     227: aload         14
     229: swap
     230: invokeinterface #111,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     235: pop
     236: goto          184
     239: aload         8
     241: checkcast     #91                 // class java/util/List
     244: nop
     245: areturn

  private final java.util.List<Day8$Node> parseNodes(java.util.List<java.lang.String>);
    Code:
       0: new           #138                // class java/util/LinkedHashMap
       3: dup
       4: invokespecial #139                // Method java/util/LinkedHashMap."<init>":()V
       7: checkcast     #141                // class java/util/Map
      10: astore_2
      11: new           #143                // class kotlin/text/Regex
      14: dup
      15: ldc           #145                // String (\\w+) = \\((\\w+), (\\w+)\\)
      17: invokespecial #148                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      20: astore_3
      21: aload_1
      22: invokeinterface #149,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      27: astore        4
      29: aload         4
      31: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      36: ifeq          340
      39: aload         4
      41: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      46: checkcast     #30                 // class java/lang/String
      49: astore        5
      51: aload_3
      52: aload         5
      54: checkcast     #151                // class java/lang/CharSequence
      57: invokevirtual #155                // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;
      60: dup
      61: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      64: invokeinterface #165,  1          // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;
      69: astore        6
      71: aload         6
      73: invokevirtual #171                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
      76: invokeinterface #175,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
      81: iconst_1
      82: invokeinterface #179,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      87: checkcast     #30                 // class java/lang/String
      90: astore        7
      92: aload         6
      94: invokevirtual #171                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
      97: invokeinterface #175,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     102: iconst_2
     103: invokeinterface #179,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     108: checkcast     #30                 // class java/lang/String
     111: astore        8
     113: aload         6
     115: invokevirtual #171                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     118: invokeinterface #175,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     123: iconst_3
     124: invokeinterface #179,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     129: checkcast     #30                 // class java/lang/String
     132: astore        9
     134: aload_2
     135: astore        11
     137: iconst_0
     138: istore        12
     140: aload         11
     142: aload         8
     144: invokeinterface #182,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     149: astore        13
     151: aload         13
     153: ifnonnull     189
     156: iconst_0
     157: istore        14
     159: new           #65                 // class Day8$Node
     162: dup
     163: aconst_null
     164: aconst_null
     165: aload         8
     167: invokespecial #185                // Method Day8$Node."<init>":(LDay8$Node;LDay8$Node;Ljava/lang/String;)V
     170: astore        14
     172: aload         11
     174: aload         8
     176: aload         14
     178: invokeinterface #189,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     183: pop
     184: aload         14
     186: goto          191
     189: aload         13
     191: nop
     192: checkcast     #65                 // class Day8$Node
     195: astore        10
     197: aload_2
     198: astore        12
     200: iconst_0
     201: istore        13
     203: aload         12
     205: aload         9
     207: invokeinterface #182,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     212: astore        14
     214: aload         14
     216: ifnonnull     252
     219: iconst_0
     220: istore        15
     222: new           #65                 // class Day8$Node
     225: dup
     226: aconst_null
     227: aconst_null
     228: aload         9
     230: invokespecial #185                // Method Day8$Node."<init>":(LDay8$Node;LDay8$Node;Ljava/lang/String;)V
     233: astore        15
     235: aload         12
     237: aload         9
     239: aload         15
     241: invokeinterface #189,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     246: pop
     247: aload         15
     249: goto          254
     252: aload         14
     254: nop
     255: checkcast     #65                 // class Day8$Node
     258: astore        11
     260: aload_2
     261: astore        13
     263: iconst_0
     264: istore        14
     266: aload         13
     268: aload         7
     270: invokeinterface #182,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     275: astore        15
     277: aload         15
     279: ifnonnull     315
     282: iconst_0
     283: istore        16
     285: new           #65                 // class Day8$Node
     288: dup
     289: aconst_null
     290: aconst_null
     291: aload         7
     293: invokespecial #185                // Method Day8$Node."<init>":(LDay8$Node;LDay8$Node;Ljava/lang/String;)V
     296: astore        16
     298: aload         13
     300: aload         7
     302: aload         16
     304: invokeinterface #189,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     309: pop
     310: aload         16
     312: goto          317
     315: aload         15
     317: nop
     318: checkcast     #65                 // class Day8$Node
     321: astore        12
     323: aload         12
     325: aload         10
     327: invokevirtual #193                // Method Day8$Node.setLeft:(LDay8$Node;)V
     330: aload         12
     332: aload         11
     334: invokevirtual #196                // Method Day8$Node.setRight:(LDay8$Node;)V
     337: goto          29
     340: aload_2
     341: invokeinterface #200,  1          // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
     346: checkcast     #41                 // class java/lang/Iterable
     349: invokestatic  #204                // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     352: areturn

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

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

  private final char[] directions;

  private final Day8$Node root;

  public Day8$DesertMap(char[], Day8$Node);
    Code:
       0: aload_1
       1: ldc           #10                 // String directions
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #19                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_1
      12: putfield      #22                 // Field directions:[C
      15: aload_0
      16: aload_2
      17: putfield      #26                 // Field root:LDay8$Node;
      20: return

  public final char[] getDirections();
    Code:
       0: aload_0
       1: getfield      #22                 // Field directions:[C
       4: areturn

  public final Day8$Node getRoot();
    Code:
       0: aload_0
       1: getfield      #26                 // Field root:LDay8$Node;
       4: areturn

  public final char[] component1();
    Code:
       0: aload_0
       1: getfield      #22                 // Field directions:[C
       4: areturn

  public final Day8$Node component2();
    Code:
       0: aload_0
       1: getfield      #26                 // Field root:LDay8$Node;
       4: areturn

  public final Day8$DesertMap copy(char[], Day8$Node);
    Code:
       0: aload_1
       1: ldc           #10                 // String directions
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #2                  // class Day8$DesertMap
       9: dup
      10: aload_1
      11: aload_2
      12: invokespecial #38                 // Method "<init>":([CLDay8$Node;)V
      15: areturn

  public static Day8$DesertMap copy$default(Day8$DesertMap, char[], Day8$Node, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          11
       6: aload_0
       7: getfield      #22                 // Field directions:[C
      10: astore_1
      11: iload_3
      12: iconst_2
      13: iand
      14: ifeq          22
      17: aload_0
      18: getfield      #26                 // Field root:LDay8$Node;
      21: astore_2
      22: aload_0
      23: aload_1
      24: aload_2
      25: invokevirtual #42                 // Method copy:([CLDay8$Node;)LDay8$DesertMap;
      28: areturn

  public java.lang.String toString();
    Code:
       0: new           #46                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #47                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #49                 // String DesertMap(directions=
       9: invokevirtual #53                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #22                 // Field directions:[C
      16: invokestatic  #58                 // Method java/util/Arrays.toString:([C)Ljava/lang/String;
      19: invokevirtual #53                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      22: ldc           #60                 // String , root=
      24: invokevirtual #53                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      27: aload_0
      28: getfield      #26                 // Field root:LDay8$Node;
      31: invokevirtual #63                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      34: bipush        41
      36: invokevirtual #66                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      39: invokevirtual #68                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      42: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #22                 // Field directions:[C
       4: invokestatic  #73                 // Method java/util/Arrays.hashCode:([C)I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #26                 // Field root:LDay8$Node;
      16: ifnonnull     23
      19: iconst_0
      20: goto          30
      23: aload_0
      24: getfield      #26                 // Field root:LDay8$Node;
      27: invokevirtual #77                 // Method Day8$Node.hashCode:()I
      30: iadd
      31: istore_1
      32: iload_1
      33: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class Day8$DesertMap
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class Day8$DesertMap
      20: astore_2
      21: aload_0
      22: getfield      #22                 // Field directions:[C
      25: aload_2
      26: getfield      #22                 // Field directions:[C
      29: invokestatic  #85                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      32: ifne          37
      35: iconst_0
      36: ireturn
      37: aload_0
      38: getfield      #26                 // Field root:LDay8$Node;
      41: aload_2
      42: getfield      #26                 // Field root:LDay8$Node;
      45: invokestatic  #85                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      48: ifne          53
      51: iconst_0
      52: ireturn
      53: iconst_1
      54: ireturn

  static {};
    Code:
       0: new           #90                 // class Day8$DesertMap$Companion
       3: dup
       4: aconst_null
       5: invokespecial #93                 // Method Day8$DesertMap$Companion."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: putstatic     #97                 // Field Companion:LDay8$DesertMap$Companion;
      11: return
}

Compiled from "Day8.kt"
public final class Day8 {
  public static final Day8 INSTANCE;

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

  public final java.lang.String part1(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: getstatic     #28                 // Field Day8$DesertMap.Companion:LDay8$DesertMap$Companion;
       9: aload_1
      10: invokevirtual #34                 // Method Day8$DesertMap$Companion.parse:(Ljava/util/List;)LDay8$DesertMap;
      13: astore_2
      14: aload_0
      15: aload_2
      16: invokevirtual #38                 // Method Day8$DesertMap.getDirections:()[C
      19: aload_2
      20: invokevirtual #42                 // Method Day8$DesertMap.getRoot:()LDay8$Node;
      23: lconst_0
      24: aconst_null
      25: bipush        8
      27: aconst_null
      28: invokestatic  #46                 // Method followUntilExit$default:(LDay8;[CLDay8$Node;JLkotlin/jvm/functions/Function1;ILjava/lang/Object;)J
      31: invokestatic  #52                 // Method java/lang/String.valueOf:(J)Ljava/lang/String;
      34: areturn

  private final long followUntilExit(char[], Day8$Node, long, kotlin.jvm.functions.Function1<? super Day8$Node, java.lang.Boolean>);
    Code:
       0: aload_0
       1: astore        6
       3: aload_2
       4: ifnull        24
       7: aload         5
       9: aload_2
      10: invokeinterface #64,  2           // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      15: checkcast     #66                 // class java/lang/Boolean
      18: invokevirtual #70                 // Method java/lang/Boolean.booleanValue:()Z
      21: ifeq          26
      24: lload_3
      25: lreturn
      26: aload_1
      27: invokestatic  #76                 // Method kotlin/collections/ArraysKt.first:([C)C
      30: bipush        76
      32: if_icmpne     42
      35: aload_2
      36: invokevirtual #81                 // Method Day8$Node.getLeft:()LDay8$Node;
      39: goto          46
      42: aload_2
      43: invokevirtual #84                 // Method Day8$Node.getRight:()LDay8$Node;
      46: astore        7
      48: aload         6
      50: astore        8
      52: aload         6
      54: aload_1
      55: iconst_1
      56: invokespecial #88                 // Method rotate:([CI)[C
      59: astore        9
      61: lload_3
      62: lconst_1
      63: ladd
      64: lstore        10
      66: aload         5
      68: astore        12
      70: aload         8
      72: astore        6
      74: aload         9
      76: astore_1
      77: aload         7
      79: astore_2
      80: lload         10
      82: lstore_3
      83: aload         12
      85: astore        5
      87: goto          3

  static long followUntilExit$default(Day8, char[], Day8$Node, long, kotlin.jvm.functions.Function1, int, java.lang.Object);
    Code:
       0: iload         6
       2: bipush        8
       4: iand
       5: ifeq          15
       8: invokedynamic #115,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      13: astore        5
      15: aload_0
      16: aload_1
      17: aload_2
      18: lload_3
      19: aload         5
      21: invokespecial #117                // Method followUntilExit:([CLDay8$Node;JLkotlin/jvm/functions/Function1;)J
      24: lreturn

  public final java.lang.String part2(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: getstatic     #28                 // Field Day8$DesertMap.Companion:LDay8$DesertMap$Companion;
       9: aload_1
      10: invokevirtual #122                // Method Day8$DesertMap$Companion.parsePart2:(Ljava/util/List;)Ljava/util/List;
      13: astore_2
      14: aload_0
      15: aload_2
      16: invokespecial #126                // Method followUntilAllExit:(Ljava/util/List;)J
      19: invokestatic  #52                 // Method java/lang/String.valueOf:(J)Ljava/lang/String;
      22: areturn

  private final long followUntilAllExit(java.util.List<Day8$DesertMap>);
    Code:
       0: aload_1
       1: checkcast     #130                // class java/lang/Iterable
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: astore        5
      11: new           #132                // class java/util/ArrayList
      14: dup
      15: aload_3
      16: bipush        10
      18: invokestatic  #138                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #141                // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #143                // class java/util/Collection
      27: astore        6
      29: iconst_0
      30: istore        7
      32: aload         5
      34: invokeinterface #147,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      39: astore        8
      41: aload         8
      43: invokeinterface #152,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      48: ifeq          111
      51: aload         8
      53: invokeinterface #156,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      58: astore        9
      60: aload         6
      62: aload         9
      64: checkcast     #24                 // class Day8$DesertMap
      67: astore        10
      69: astore        12
      71: iconst_0
      72: istore        11
      74: getstatic     #159                // Field INSTANCE:LDay8;
      77: aload         10
      79: invokevirtual #38                 // Method Day8$DesertMap.getDirections:()[C
      82: aload         10
      84: invokevirtual #42                 // Method Day8$DesertMap.getRoot:()LDay8$Node;
      87: lconst_0
      88: invokedynamic #164,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
      93: invokespecial #117                // Method followUntilExit:([CLDay8$Node;JLkotlin/jvm/functions/Function1;)J
      96: invokestatic  #169                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      99: aload         12
     101: swap
     102: invokeinterface #173,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     107: pop
     108: goto          41
     111: aload         6
     113: checkcast     #175                // class java/util/List
     116: nop
     117: astore_2
     118: aload_0
     119: aload_2
     120: invokespecial #178                // Method leastCommonMultiple:(Ljava/util/List;)J
     123: lreturn

  private final long leastCommonMultiple(java.util.List<java.lang.Long>);
    Code:
       0: aload_1
       1: checkcast     #130                // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: invokeinterface #147,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      13: astore        4
      15: aload         4
      17: invokeinterface #152,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      22: ifne          35
      25: new           #194                // class java/lang/UnsupportedOperationException
      28: dup
      29: ldc           #196                // String Empty collection can\'t be reduced.
      31: invokespecial #199                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
      34: athrow
      35: aload         4
      37: invokeinterface #156,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      42: astore        5
      44: aload         4
      46: invokeinterface #152,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          100
      54: aload         5
      56: aload         4
      58: invokeinterface #156,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: checkcast     #201                // class java/lang/Number
      66: invokevirtual #205                // Method java/lang/Number.longValue:()J
      69: lstore        6
      71: checkcast     #201                // class java/lang/Number
      74: invokevirtual #205                // Method java/lang/Number.longValue:()J
      77: lstore        8
      79: iconst_0
      80: istore        10
      82: getstatic     #159                // Field INSTANCE:LDay8;
      85: lload         8
      87: lload         6
      89: invokespecial #209                // Method lcm:(JJ)J
      92: invokestatic  #169                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      95: astore        5
      97: goto          44
     100: aload         5
     102: checkcast     #201                // class java/lang/Number
     105: invokevirtual #205                // Method java/lang/Number.longValue:()J
     108: lreturn

  private final long lcm(long, long);
    Code:
       0: lload_1
       1: lload_3
       2: lmul
       3: aload_0
       4: lload_1
       5: lload_3
       6: invokespecial #220                // Method gcd:(JJ)J
       9: ldiv
      10: lreturn

  private final long gcd(long, long);
    Code:
       0: lload_3
       1: lconst_0
       2: lcmp
       3: ifne          10
       6: lload_1
       7: goto          18
      10: aload_0
      11: lload_3
      12: lload_1
      13: lload_3
      14: lrem
      15: invokespecial #220                // Method gcd:(JJ)J
      18: lreturn

  private final char[] rotate(char[], int);
    Code:
       0: aload_1
       1: astore_3
       2: iconst_0
       3: istore        4
       5: aload_1
       6: iload_2
       7: aload_1
       8: arraylength
       9: invokestatic  #226                // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      12: invokestatic  #230                // Method kotlin/collections/ArraysKt.sliceArray:([CLkotlin/ranges/IntRange;)[C
      15: aload_1
      16: iconst_0
      17: iload_2
      18: invokestatic  #226                // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      21: invokestatic  #230                // Method kotlin/collections/ArraysKt.sliceArray:([CLkotlin/ranges/IntRange;)[C
      24: invokestatic  #234                // Method kotlin/collections/ArraysKt.plus:([C[C)[C
      27: nop
      28: areturn

  private static final boolean followUntilExit$lambda$0(Day8$Node);
    Code:
       0: aload_0
       1: ldc           #238                // String it
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #242                // Method Day8$Node.getKey:()Ljava/lang/String;
      10: ldc           #244                // String ZZZ
      12: invokestatic  #248                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      15: ireturn

  private static final boolean followUntilAllExit$lambda$2$lambda$1(Day8$Node);
    Code:
       0: aload_0
       1: ldc           #238                // String it
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #242                // Method Day8$Node.getKey:()Ljava/lang/String;
      10: ldc           #250                // String Z
      12: iconst_0
      13: iconst_2
      14: aconst_null
      15: invokestatic  #256                // Method kotlin/text/StringsKt.endsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
      18: ireturn

  static {};
    Code:
       0: new           #2                  // class Day8
       3: dup
       4: invokespecial #258                // Method "<init>":()V
       7: putstatic     #159                // Field INSTANCE:LDay8;
      10: return
}

Compiled from "Day8.kt"
public final class Day8$Node {
  private Day8$Node left;

  private Day8$Node right;

  private final java.lang.String key;

  public Day8$Node(Day8$Node, Day8$Node, java.lang.String);
    Code:
       0: aload_3
       1: ldc           #10                 // String key
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #19                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_1
      12: putfield      #23                 // Field left:LDay8$Node;
      15: aload_0
      16: aload_2
      17: putfield      #26                 // Field right:LDay8$Node;
      20: aload_0
      21: aload_3
      22: putfield      #29                 // Field key:Ljava/lang/String;
      25: return

  public final Day8$Node getLeft();
    Code:
       0: aload_0
       1: getfield      #23                 // Field left:LDay8$Node;
       4: areturn

  public final void setLeft(Day8$Node);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #23                 // Field left:LDay8$Node;
       5: return

  public final Day8$Node getRight();
    Code:
       0: aload_0
       1: getfield      #26                 // Field right:LDay8$Node;
       4: areturn

  public final void setRight(Day8$Node);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #26                 // Field right:LDay8$Node;
       5: return

  public final java.lang.String getKey();
    Code:
       0: aload_0
       1: getfield      #29                 // Field key:Ljava/lang/String;
       4: areturn

  public final Day8$Node component1();
    Code:
       0: aload_0
       1: getfield      #23                 // Field left:LDay8$Node;
       4: areturn

  public final Day8$Node component2();
    Code:
       0: aload_0
       1: getfield      #26                 // Field right:LDay8$Node;
       4: areturn

  public final java.lang.String component3();
    Code:
       0: aload_0
       1: getfield      #29                 // Field key:Ljava/lang/String;
       4: areturn

  public final Day8$Node copy(Day8$Node, Day8$Node, java.lang.String);
    Code:
       0: aload_3
       1: ldc           #10                 // String key
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #2                  // class Day8$Node
       9: dup
      10: aload_1
      11: aload_2
      12: aload_3
      13: invokespecial #46                 // Method "<init>":(LDay8$Node;LDay8$Node;Ljava/lang/String;)V
      16: areturn

  public static Day8$Node copy$default(Day8$Node, Day8$Node, Day8$Node, java.lang.String, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #23                 // Field left:LDay8$Node;
      11: astore_1
      12: iload         4
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #26                 // Field right:LDay8$Node;
      23: astore_2
      24: iload         4
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #29                 // Field key:Ljava/lang/String;
      35: astore_3
      36: aload_0
      37: aload_1
      38: aload_2
      39: aload_3
      40: invokevirtual #50                 // Method copy:(LDay8$Node;LDay8$Node;Ljava/lang/String;)LDay8$Node;
      43: areturn

  public java.lang.String toString();
    Code:
       0: new           #53                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #54                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #56                 // String Node(left=
       9: invokevirtual #60                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #23                 // Field left:LDay8$Node;
      16: invokevirtual #63                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      19: ldc           #65                 // String , right=
      21: invokevirtual #60                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #26                 // Field right:LDay8$Node;
      28: invokevirtual #63                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      31: ldc           #67                 // String , key=
      33: invokevirtual #60                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: aload_0
      37: getfield      #29                 // Field key:Ljava/lang/String;
      40: invokevirtual #60                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      43: bipush        41
      45: invokevirtual #70                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      48: invokevirtual #72                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      51: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #23                 // Field left:LDay8$Node;
       4: ifnonnull     11
       7: iconst_0
       8: goto          18
      11: aload_0
      12: getfield      #23                 // Field left:LDay8$Node;
      15: invokevirtual #76                 // Method hashCode:()I
      18: istore_1
      19: iload_1
      20: bipush        31
      22: imul
      23: aload_0
      24: getfield      #26                 // Field right:LDay8$Node;
      27: ifnonnull     34
      30: iconst_0
      31: goto          41
      34: aload_0
      35: getfield      #26                 // Field right:LDay8$Node;
      38: invokevirtual #76                 // Method hashCode:()I
      41: iadd
      42: istore_1
      43: iload_1
      44: bipush        31
      46: imul
      47: aload_0
      48: getfield      #29                 // Field key:Ljava/lang/String;
      51: invokevirtual #79                 // Method java/lang/String.hashCode:()I
      54: iadd
      55: istore_1
      56: iload_1
      57: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class Day8$Node
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class Day8$Node
      20: astore_2
      21: aload_0
      22: getfield      #23                 // Field left:LDay8$Node;
      25: aload_2
      26: getfield      #23                 // Field left:LDay8$Node;
      29: invokestatic  #87                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      32: ifne          37
      35: iconst_0
      36: ireturn
      37: aload_0
      38: getfield      #26                 // Field right:LDay8$Node;
      41: aload_2
      42: getfield      #26                 // Field right:LDay8$Node;
      45: invokestatic  #87                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      48: ifne          53
      51: iconst_0
      52: ireturn
      53: aload_0
      54: getfield      #29                 // Field key:Ljava/lang/String;
      57: aload_2
      58: getfield      #29                 // Field key:Ljava/lang/String;
      61: invokestatic  #87                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      64: ifne          69
      67: iconst_0
      68: ireturn
      69: iconst_1
      70: ireturn
}


import kotlin.String
import kotlin.collections.List

object Day2 {
    data class Cube(
        val color: String,
        val count: Int
    )

    data class Game(
        val id: Int,
        val cubePulls: List<List<Cube>>
    ) {
        companion object {
            fun parseGame(s: String): Game {
                val (id, pulls) = s.split(":")
                return Game(
                    id.trimStart(*"Game ".toCharArray()).toInt(),
                    pulls.split(";").map { cubeList ->
                        cubeList.split(",").map { cube ->
                            val (count, color) = cube.trimStart(' ').split(" ")
                            Cube(color, count.toInt())
                        }
                    }
                )
            }
        }
    }

    fun part1(input: List<String>): String {
        return sumOfGamesWithTarget(
            input.map(Game::parseGame),
            listOf(
                Cube("red", 12), Cube("green", 13), Cube("blue", 14)
            )
        ).toString()
    }

    private fun sumOfGamesWithTarget(input: List<Game>, targets: List<Cube>): Int {
        val index = targets.associateBy { it.color }
        return input.filter {
            it.cubePulls.all {
                it.all {
                    it.count <= index.getOrDefault(
                        it.color,
                        it
                    ).count
                }
            }
        }.sumOf { it.id }
    }

    fun part2(input: List<String>): String {
        return sumOfPowersWithMinimums(input.map(Game::parseGame)).toString()
    }

    private fun sumOfPowersWithMinimums(games: List<Game>): Int {
        return games.map {
            val minimumCubesNeeded = it.cubePulls.flatten()
                .groupBy { it.color }
                .mapValues { it.value.maxBy { it.count } }
            minimumCubesNeeded.map { it.value.count }.reduce { a, b -> a * b }
        }.sum()
    }
}

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

  private final int id;

  private final java.util.List<java.util.List<Day2$Cube>> cubePulls;

  public Day2$Game(int, java.util.List<? extends java.util.List<Day2$Cube>>);
    Code:
       0: aload_2
       1: ldc           #10                 // String cubePulls
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #19                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: iload_1
      12: putfield      #23                 // Field id:I
      15: aload_0
      16: aload_2
      17: putfield      #26                 // Field cubePulls:Ljava/util/List;
      20: return

  public final int getId();
    Code:
       0: aload_0
       1: getfield      #23                 // Field id:I
       4: ireturn

  public final java.util.List<java.util.List<Day2$Cube>> getCubePulls();
    Code:
       0: aload_0
       1: getfield      #26                 // Field cubePulls:Ljava/util/List;
       4: areturn

  public final int component1();
    Code:
       0: aload_0
       1: getfield      #23                 // Field id:I
       4: ireturn

  public final java.util.List<java.util.List<Day2$Cube>> component2();
    Code:
       0: aload_0
       1: getfield      #26                 // Field cubePulls:Ljava/util/List;
       4: areturn

  public final Day2$Game copy(int, java.util.List<? extends java.util.List<Day2$Cube>>);
    Code:
       0: aload_2
       1: ldc           #10                 // String cubePulls
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #2                  // class Day2$Game
       9: dup
      10: iload_1
      11: aload_2
      12: invokespecial #40                 // Method "<init>":(ILjava/util/List;)V
      15: areturn

  public static Day2$Game copy$default(Day2$Game, int, java.util.List, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          11
       6: aload_0
       7: getfield      #23                 // Field id:I
      10: istore_1
      11: iload_3
      12: iconst_2
      13: iand
      14: ifeq          22
      17: aload_0
      18: getfield      #26                 // Field cubePulls:Ljava/util/List;
      21: astore_2
      22: aload_0
      23: iload_1
      24: aload_2
      25: invokevirtual #44                 // Method copy:(ILjava/util/List;)LDay2$Game;
      28: areturn

  public java.lang.String toString();
    Code:
       0: new           #48                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #49                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #51                 // String Game(id=
       9: invokevirtual #55                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #23                 // Field id:I
      16: invokevirtual #58                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #60                 // String , cubePulls=
      21: invokevirtual #55                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #26                 // Field cubePulls:Ljava/util/List;
      28: invokevirtual #63                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      31: bipush        41
      33: invokevirtual #66                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      36: invokevirtual #68                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      39: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #23                 // Field id:I
       4: invokestatic  #74                 // Method java/lang/Integer.hashCode:(I)I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #26                 // Field cubePulls:Ljava/util/List;
      16: invokevirtual #76                 // Method java/lang/Object.hashCode:()I
      19: iadd
      20: istore_1
      21: iload_1
      22: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class Day2$Game
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class Day2$Game
      20: astore_2
      21: aload_0
      22: getfield      #23                 // Field id:I
      25: aload_2
      26: getfield      #23                 // Field id:I
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #26                 // Field cubePulls:Ljava/util/List;
      38: aload_2
      39: getfield      #26                 // Field cubePulls:Ljava/util/List;
      42: invokestatic  #84                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      45: ifne          50
      48: iconst_0
      49: ireturn
      50: iconst_1
      51: ireturn

  static {};
    Code:
       0: new           #89                 // class Day2$Game$Companion
       3: dup
       4: aconst_null
       5: invokespecial #92                 // Method Day2$Game$Companion."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: putstatic     #96                 // Field Companion:LDay2$Game$Companion;
      11: return
}

Compiled from "Day2.kt"
public final class Day2 {
  public static final Day2 INSTANCE;

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

  public final java.lang.String part1(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: checkcast     #24                 // class java/lang/Iterable
      11: astore_2
      12: getstatic     #30                 // Field Day2$Game.Companion:LDay2$Game$Companion;
      15: astore_3
      16: astore        12
      18: iconst_0
      19: istore        4
      21: aload_2
      22: astore        5
      24: new           #32                 // class java/util/ArrayList
      27: dup
      28: aload_2
      29: bipush        10
      31: invokestatic  #38                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      34: invokespecial #41                 // Method java/util/ArrayList."<init>":(I)V
      37: checkcast     #43                 // class java/util/Collection
      40: astore        6
      42: iconst_0
      43: istore        7
      45: aload         5
      47: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      52: astore        8
      54: aload         8
      56: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      61: ifeq          105
      64: aload         8
      66: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      71: astore        9
      73: aload         6
      75: aload         9
      77: checkcast     #59                 // class java/lang/String
      80: astore        10
      82: astore        13
      84: iconst_0
      85: istore        11
      87: aload_3
      88: aload         10
      90: invokevirtual #65                 // Method Day2$Game$Companion.parseGame:(Ljava/lang/String;)LDay2$Game;
      93: aload         13
      95: swap
      96: invokeinterface #69,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     101: pop
     102: goto          54
     105: aload         6
     107: checkcast     #71                 // class java/util/List
     110: nop
     111: aload         12
     113: swap
     114: iconst_3
     115: anewarray     #73                 // class Day2$Cube
     118: astore_2
     119: aload_2
     120: iconst_0
     121: new           #73                 // class Day2$Cube
     124: dup
     125: ldc           #75                 // String red
     127: bipush        12
     129: invokespecial #78                 // Method Day2$Cube."<init>":(Ljava/lang/String;I)V
     132: aastore
     133: aload_2
     134: iconst_1
     135: new           #73                 // class Day2$Cube
     138: dup
     139: ldc           #80                 // String green
     141: bipush        13
     143: invokespecial #78                 // Method Day2$Cube."<init>":(Ljava/lang/String;I)V
     146: aastore
     147: aload_2
     148: iconst_2
     149: new           #73                 // class Day2$Cube
     152: dup
     153: ldc           #82                 // String blue
     155: bipush        14
     157: invokespecial #78                 // Method Day2$Cube."<init>":(Ljava/lang/String;I)V
     160: aastore
     161: aload_2
     162: invokestatic  #86                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     165: invokespecial #90                 // Method sumOfGamesWithTarget:(Ljava/util/List;Ljava/util/List;)I
     168: invokestatic  #94                 // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     171: areturn

  private final int sumOfGamesWithTarget(java.util.List<Day2$Game>, java.util.List<Day2$Cube>);
    Code:
       0: aload_2
       1: checkcast     #24                 // class java/lang/Iterable
       4: astore        4
       6: iconst_0
       7: istore        5
       9: aload         4
      11: bipush        10
      13: invokestatic  #38                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      16: invokestatic  #115                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
      19: bipush        16
      21: invokestatic  #121                // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I
      24: istore        6
      26: aload         4
      28: astore        7
      30: new           #123                // class java/util/LinkedHashMap
      33: dup
      34: iload         6
      36: invokespecial #124                // Method java/util/LinkedHashMap."<init>":(I)V
      39: checkcast     #126                // class java/util/Map
      42: astore        8
      44: iconst_0
      45: istore        9
      47: aload         7
      49: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      54: astore        10
      56: aload         10
      58: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      63: ifeq          108
      66: aload         10
      68: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      73: astore        11
      75: aload         8
      77: aload         11
      79: checkcast     #73                 // class Day2$Cube
      82: astore        12
      84: astore        25
      86: iconst_0
      87: istore        13
      89: aload         12
      91: invokevirtual #130                // Method Day2$Cube.getColor:()Ljava/lang/String;
      94: aload         25
      96: swap
      97: aload         11
      99: invokeinterface #134,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     104: pop
     105: goto          56
     108: aload         8
     110: nop
     111: astore_3
     112: aload_1
     113: checkcast     #24                 // class java/lang/Iterable
     116: astore        4
     118: iconst_0
     119: istore        5
     121: aload         4
     123: astore        6
     125: new           #32                 // class java/util/ArrayList
     128: dup
     129: invokespecial #135                // Method java/util/ArrayList."<init>":()V
     132: checkcast     #43                 // class java/util/Collection
     135: astore        7
     137: iconst_0
     138: istore        8
     140: aload         6
     142: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     147: astore        9
     149: aload         9
     151: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     156: ifeq          394
     159: aload         9
     161: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     166: astore        10
     168: aload         10
     170: checkcast     #26                 // class Day2$Game
     173: astore        11
     175: iconst_0
     176: istore        12
     178: aload         11
     180: invokevirtual #139                // Method Day2$Game.getCubePulls:()Ljava/util/List;
     183: checkcast     #24                 // class java/lang/Iterable
     186: astore        13
     188: iconst_0
     189: istore        14
     191: aload         13
     193: instanceof    #43                 // class java/util/Collection
     196: ifeq          216
     199: aload         13
     201: checkcast     #43                 // class java/util/Collection
     204: invokeinterface #142,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     209: ifeq          216
     212: iconst_1
     213: goto          377
     216: aload         13
     218: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     223: astore        15
     225: aload         15
     227: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     232: ifeq          376
     235: aload         15
     237: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     242: astore        16
     244: aload         16
     246: checkcast     #71                 // class java/util/List
     249: astore        17
     251: iconst_0
     252: istore        18
     254: aload         17
     256: checkcast     #24                 // class java/lang/Iterable
     259: astore        19
     261: iconst_0
     262: istore        20
     264: aload         19
     266: instanceof    #43                 // class java/util/Collection
     269: ifeq          289
     272: aload         19
     274: checkcast     #43                 // class java/util/Collection
     277: invokeinterface #142,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     282: ifeq          289
     285: iconst_1
     286: goto          368
     289: aload         19
     291: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     296: astore        21
     298: aload         21
     300: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     305: ifeq          367
     308: aload         21
     310: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     315: astore        22
     317: aload         22
     319: checkcast     #73                 // class Day2$Cube
     322: astore        23
     324: iconst_0
     325: istore        24
     327: aload         23
     329: invokevirtual #146                // Method Day2$Cube.getCount:()I
     332: aload_3
     333: aload         23
     335: invokevirtual #130                // Method Day2$Cube.getColor:()Ljava/lang/String;
     338: aload         23
     340: invokeinterface #149,  3          // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     345: checkcast     #73                 // class Day2$Cube
     348: invokevirtual #146                // Method Day2$Cube.getCount:()I
     351: if_icmpgt     358
     354: iconst_1
     355: goto          359
     358: iconst_0
     359: nop
     360: ifne          298
     363: iconst_0
     364: goto          368
     367: iconst_1
     368: nop
     369: ifne          225
     372: iconst_0
     373: goto          377
     376: iconst_1
     377: nop
     378: ifeq          149
     381: aload         7
     383: aload         10
     385: invokeinterface #69,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     390: pop
     391: goto          149
     394: aload         7
     396: checkcast     #71                 // class java/util/List
     399: nop
     400: checkcast     #24                 // class java/lang/Iterable
     403: astore        4
     405: iconst_0
     406: istore        5
     408: aload         4
     410: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     415: astore        6
     417: aload         6
     419: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     424: ifeq          467
     427: aload         6
     429: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     434: astore        7
     436: iload         5
     438: aload         7
     440: checkcast     #26                 // class Day2$Game
     443: astore        8
     445: istore        25
     447: iconst_0
     448: istore        9
     450: aload         8
     452: invokevirtual #152                // Method Day2$Game.getId:()I
     455: istore        26
     457: iload         25
     459: iload         26
     461: iadd
     462: istore        5
     464: goto          417
     467: iload         5
     469: ireturn

  public final java.lang.String part2(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: checkcast     #24                 // class java/lang/Iterable
      11: astore_2
      12: getstatic     #30                 // Field Day2$Game.Companion:LDay2$Game$Companion;
      15: astore_3
      16: astore        12
      18: iconst_0
      19: istore        4
      21: aload_2
      22: astore        5
      24: new           #32                 // class java/util/ArrayList
      27: dup
      28: aload_2
      29: bipush        10
      31: invokestatic  #38                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      34: invokespecial #41                 // Method java/util/ArrayList."<init>":(I)V
      37: checkcast     #43                 // class java/util/Collection
      40: astore        6
      42: iconst_0
      43: istore        7
      45: aload         5
      47: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      52: astore        8
      54: aload         8
      56: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      61: ifeq          105
      64: aload         8
      66: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      71: astore        9
      73: aload         6
      75: aload         9
      77: checkcast     #59                 // class java/lang/String
      80: astore        10
      82: astore        13
      84: iconst_0
      85: istore        11
      87: aload_3
      88: aload         10
      90: invokevirtual #65                 // Method Day2$Game$Companion.parseGame:(Ljava/lang/String;)LDay2$Game;
      93: aload         13
      95: swap
      96: invokeinterface #69,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     101: pop
     102: goto          54
     105: aload         6
     107: checkcast     #71                 // class java/util/List
     110: nop
     111: aload         12
     113: swap
     114: invokespecial #181                // Method sumOfPowersWithMinimums:(Ljava/util/List;)I
     117: invokestatic  #94                 // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     120: areturn

  private final int sumOfPowersWithMinimums(java.util.List<Day2$Game>);
    Code:
       0: aload_1
       1: checkcast     #24                 // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: astore        4
      10: new           #32                 // class java/util/ArrayList
      13: dup
      14: aload_2
      15: bipush        10
      17: invokestatic  #38                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      20: invokespecial #41                 // Method java/util/ArrayList."<init>":(I)V
      23: checkcast     #43                 // class java/util/Collection
      26: astore        5
      28: iconst_0
      29: istore        6
      31: aload         4
      33: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      38: astore        7
      40: aload         7
      42: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      47: ifeq          751
      50: aload         7
      52: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      57: astore        8
      59: aload         5
      61: aload         8
      63: checkcast     #26                 // class Day2$Game
      66: astore        9
      68: astore        37
      70: iconst_0
      71: istore        10
      73: aload         9
      75: invokevirtual #139                // Method Day2$Game.getCubePulls:()Ljava/util/List;
      78: checkcast     #24                 // class java/lang/Iterable
      81: invokestatic  #187                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
      84: checkcast     #24                 // class java/lang/Iterable
      87: astore        11
      89: nop
      90: iconst_0
      91: istore        12
      93: aload         11
      95: astore        13
      97: new           #123                // class java/util/LinkedHashMap
     100: dup
     101: invokespecial #188                // Method java/util/LinkedHashMap."<init>":()V
     104: checkcast     #126                // class java/util/Map
     107: astore        14
     109: iconst_0
     110: istore        15
     112: aload         13
     114: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     119: astore        16
     121: aload         16
     123: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     128: ifeq          233
     131: aload         16
     133: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     138: astore        17
     140: aload         17
     142: checkcast     #73                 // class Day2$Cube
     145: astore        18
     147: iconst_0
     148: istore        19
     150: aload         18
     152: invokevirtual #130                // Method Day2$Cube.getColor:()Ljava/lang/String;
     155: astore        20
     157: aload         14
     159: astore        21
     161: iconst_0
     162: istore        22
     164: aload         21
     166: aload         20
     168: invokeinterface #192,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     173: astore        23
     175: aload         23
     177: ifnonnull     212
     180: iconst_0
     181: istore        24
     183: new           #32                 // class java/util/ArrayList
     186: dup
     187: invokespecial #135                // Method java/util/ArrayList."<init>":()V
     190: checkcast     #71                 // class java/util/List
     193: astore        24
     195: aload         21
     197: aload         20
     199: aload         24
     201: invokeinterface #134,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     206: pop
     207: aload         24
     209: goto          214
     212: aload         23
     214: nop
     215: checkcast     #71                 // class java/util/List
     218: astore        18
     220: aload         18
     222: aload         17
     224: invokeinterface #193,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     229: pop
     230: goto          121
     233: aload         14
     235: nop
     236: astore        11
     238: nop
     239: iconst_0
     240: istore        12
     242: aload         11
     244: astore        13
     246: new           #123                // class java/util/LinkedHashMap
     249: dup
     250: aload         11
     252: invokeinterface #196,  1          // InterfaceMethod java/util/Map.size:()I
     257: invokestatic  #115                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
     260: invokespecial #124                // Method java/util/LinkedHashMap."<init>":(I)V
     263: checkcast     #126                // class java/util/Map
     266: astore        14
     268: iconst_0
     269: istore        15
     271: aload         13
     273: invokeinterface #200,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     278: checkcast     #24                 // class java/lang/Iterable
     281: astore        16
     283: iconst_0
     284: istore        17
     286: aload         16
     288: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     293: astore        18
     295: aload         18
     297: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     302: ifeq          509
     305: aload         18
     307: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     312: astore        19
     314: aload         14
     316: aload         19
     318: checkcast     #202                // class java/util/Map$Entry
     321: astore        20
     323: astore        21
     325: iconst_0
     326: istore        22
     328: aload         20
     330: invokeinterface #205,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     335: aload         21
     337: swap
     338: aload         19
     340: checkcast     #202                // class java/util/Map$Entry
     343: astore        23
     345: astore        25
     347: astore        26
     349: iconst_0
     350: istore        24
     352: aload         23
     354: invokeinterface #208,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     359: checkcast     #24                 // class java/lang/Iterable
     362: astore        27
     364: iconst_0
     365: istore        28
     367: aload         27
     369: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     374: astore        29
     376: aload         29
     378: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     383: ifne          394
     386: new           #210                // class java/util/NoSuchElementException
     389: dup
     390: invokespecial #211                // Method java/util/NoSuchElementException."<init>":()V
     393: athrow
     394: aload         29
     396: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     401: astore        30
     403: aload         29
     405: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     410: ifne          418
     413: aload         30
     415: goto          488
     418: aload         30
     420: checkcast     #73                 // class Day2$Cube
     423: astore        31
     425: iconst_0
     426: istore        32
     428: aload         31
     430: invokevirtual #146                // Method Day2$Cube.getCount:()I
     433: istore        31
     435: aload         29
     437: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     442: astore        32
     444: aload         32
     446: checkcast     #73                 // class Day2$Cube
     449: astore        33
     451: iconst_0
     452: istore        34
     454: aload         33
     456: invokevirtual #146                // Method Day2$Cube.getCount:()I
     459: istore        33
     461: iload         31
     463: iload         33
     465: if_icmpge     476
     468: aload         32
     470: astore        30
     472: iload         33
     474: istore        31
     476: aload         29
     478: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     483: ifne          435
     486: aload         30
     488: checkcast     #73                 // class Day2$Cube
     491: nop
     492: astore        35
     494: aload         26
     496: aload         25
     498: aload         35
     500: invokeinterface #134,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     505: pop
     506: goto          295
     509: aload         14
     511: nop
     512: nop
     513: astore        36
     515: aload         36
     517: astore        11
     519: iconst_0
     520: istore        12
     522: aload         11
     524: astore        13
     526: new           #32                 // class java/util/ArrayList
     529: dup
     530: aload         11
     532: invokeinterface #196,  1          // InterfaceMethod java/util/Map.size:()I
     537: invokespecial #41                 // Method java/util/ArrayList."<init>":(I)V
     540: checkcast     #43                 // class java/util/Collection
     543: astore        14
     545: iconst_0
     546: istore        15
     548: aload         13
     550: invokeinterface #200,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     555: invokeinterface #214,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     560: astore        16
     562: aload         16
     564: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     569: ifeq          623
     572: aload         16
     574: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     579: checkcast     #202                // class java/util/Map$Entry
     582: astore        17
     584: aload         14
     586: aload         17
     588: astore        18
     590: astore        26
     592: iconst_0
     593: istore        19
     595: aload         18
     597: invokeinterface #208,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     602: checkcast     #73                 // class Day2$Cube
     605: invokevirtual #146                // Method Day2$Cube.getCount:()I
     608: invokestatic  #219                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     611: aload         26
     613: swap
     614: invokeinterface #69,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     619: pop
     620: goto          562
     623: aload         14
     625: checkcast     #71                 // class java/util/List
     628: nop
     629: checkcast     #24                 // class java/lang/Iterable
     632: astore        11
     634: nop
     635: iconst_0
     636: istore        12
     638: aload         11
     640: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     645: astore        13
     647: aload         13
     649: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     654: ifne          667
     657: new           #221                // class java/lang/UnsupportedOperationException
     660: dup
     661: ldc           #223                // String Empty collection can\'t be reduced.
     663: invokespecial #226                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     666: athrow
     667: aload         13
     669: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     674: astore        14
     676: aload         13
     678: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     683: ifeq          727
     686: aload         14
     688: aload         13
     690: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     695: checkcast     #228                // class java/lang/Number
     698: invokevirtual #231                // Method java/lang/Number.intValue:()I
     701: istore        15
     703: checkcast     #228                // class java/lang/Number
     706: invokevirtual #231                // Method java/lang/Number.intValue:()I
     709: istore        16
     711: iconst_0
     712: istore        17
     714: iload         16
     716: iload         15
     718: imul
     719: invokestatic  #219                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     722: astore        14
     724: goto          676
     727: aload         14
     729: checkcast     #228                // class java/lang/Number
     732: invokevirtual #231                // Method java/lang/Number.intValue:()I
     735: nop
     736: invokestatic  #219                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     739: aload         37
     741: swap
     742: invokeinterface #69,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     747: pop
     748: goto          40
     751: aload         5
     753: checkcast     #71                 // class java/util/List
     756: nop
     757: checkcast     #24                 // class java/lang/Iterable
     760: invokestatic  #235                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     763: ireturn

  static {};
    Code:
       0: new           #2                  // class Day2
       3: dup
       4: invokespecial #278                // Method "<init>":()V
       7: putstatic     #281                // Field INSTANCE:LDay2;
      10: return
}

Compiled from "Day2.kt"
public final class Day2$Cube {
  private final java.lang.String color;

  private final int count;

  public Day2$Cube(java.lang.String, int);
    Code:
       0: aload_1
       1: ldc           #9                  // String color
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #18                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_1
      12: putfield      #21                 // Field color:Ljava/lang/String;
      15: aload_0
      16: iload_2
      17: putfield      #25                 // Field count:I
      20: return

  public final java.lang.String getColor();
    Code:
       0: aload_0
       1: getfield      #21                 // Field color:Ljava/lang/String;
       4: areturn

  public final int getCount();
    Code:
       0: aload_0
       1: getfield      #25                 // Field count:I
       4: ireturn

  public final java.lang.String component1();
    Code:
       0: aload_0
       1: getfield      #21                 // Field color:Ljava/lang/String;
       4: areturn

  public final int component2();
    Code:
       0: aload_0
       1: getfield      #25                 // Field count:I
       4: ireturn

  public final Day2$Cube copy(java.lang.String, int);
    Code:
       0: aload_1
       1: ldc           #9                  // String color
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #2                  // class Day2$Cube
       9: dup
      10: aload_1
      11: iload_2
      12: invokespecial #37                 // Method "<init>":(Ljava/lang/String;I)V
      15: areturn

  public static Day2$Cube copy$default(Day2$Cube, java.lang.String, int, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          11
       6: aload_0
       7: getfield      #21                 // Field color:Ljava/lang/String;
      10: astore_1
      11: iload_3
      12: iconst_2
      13: iand
      14: ifeq          22
      17: aload_0
      18: getfield      #25                 // Field count:I
      21: istore_2
      22: aload_0
      23: aload_1
      24: iload_2
      25: invokevirtual #41                 // Method copy:(Ljava/lang/String;I)LDay2$Cube;
      28: areturn

  public java.lang.String toString();
    Code:
       0: new           #44                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #45                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #47                 // String Cube(color=
       9: invokevirtual #51                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #21                 // Field color:Ljava/lang/String;
      16: invokevirtual #51                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      19: ldc           #53                 // String , count=
      21: invokevirtual #51                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #25                 // Field count:I
      28: invokevirtual #56                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: bipush        41
      33: invokevirtual #59                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      36: invokevirtual #61                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      39: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #21                 // Field color:Ljava/lang/String;
       4: invokevirtual #66                 // Method java/lang/String.hashCode:()I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #25                 // Field count:I
      16: invokestatic  #71                 // Method java/lang/Integer.hashCode:(I)I
      19: iadd
      20: istore_1
      21: iload_1
      22: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class Day2$Cube
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class Day2$Cube
      20: astore_2
      21: aload_0
      22: getfield      #21                 // Field color:Ljava/lang/String;
      25: aload_2
      26: getfield      #21                 // Field color:Ljava/lang/String;
      29: invokestatic  #79                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      32: ifne          37
      35: iconst_0
      36: ireturn
      37: aload_0
      38: getfield      #25                 // Field count:I
      41: aload_2
      42: getfield      #25                 // Field count:I
      45: if_icmpeq     50
      48: iconst_0
      49: ireturn
      50: iconst_1
      51: ireturn
}

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

  public final Day2$Game parseGame(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #15                 // String s
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #23                 // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #25                 // class java/lang/String
      14: astore_3
      15: aload_3
      16: iconst_0
      17: ldc           #27                 // String :
      19: aastore
      20: aload_3
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #33                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: astore_2
      30: aload_2
      31: iconst_0
      32: invokeinterface #39,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      37: checkcast     #25                 // class java/lang/String
      40: astore_3
      41: aload_2
      42: iconst_1
      43: invokeinterface #39,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      48: checkcast     #25                 // class java/lang/String
      51: astore        4
      53: aload_3
      54: ldc           #41                 // String Game
      56: invokevirtual #45                 // Method java/lang/String.toCharArray:()[C
      59: dup
      60: ldc           #47                 // String toCharArray(...)
      62: invokestatic  #50                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      65: astore        5
      67: aload         5
      69: aload         5
      71: arraylength
      72: invokestatic  #56                 // Method java/util/Arrays.copyOf:([CI)[C
      75: invokestatic  #60                 // Method kotlin/text/StringsKt.trimStart:(Ljava/lang/String;[C)Ljava/lang/String;
      78: invokestatic  #66                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      81: aload         4
      83: checkcast     #23                 // class java/lang/CharSequence
      86: iconst_1
      87: anewarray     #25                 // class java/lang/String
      90: astore        5
      92: aload         5
      94: iconst_0
      95: ldc           #68                 // String ;
      97: aastore
      98: aload         5
     100: iconst_0
     101: iconst_0
     102: bipush        6
     104: aconst_null
     105: invokestatic  #33                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     108: checkcast     #70                 // class java/lang/Iterable
     111: astore        5
     113: istore        27
     115: iconst_0
     116: istore        6
     118: aload         5
     120: astore        7
     122: new           #72                 // class java/util/ArrayList
     125: dup
     126: aload         5
     128: bipush        10
     130: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     133: invokespecial #81                 // Method java/util/ArrayList."<init>":(I)V
     136: checkcast     #83                 // class java/util/Collection
     139: astore        8
     141: iconst_0
     142: istore        9
     144: aload         7
     146: invokeinterface #87,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     151: astore        10
     153: aload         10
     155: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     160: ifeq          405
     163: aload         10
     165: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     170: astore        11
     172: aload         8
     174: aload         11
     176: checkcast     #25                 // class java/lang/String
     179: astore        12
     181: astore        28
     183: iconst_0
     184: istore        13
     186: aload         12
     188: checkcast     #23                 // class java/lang/CharSequence
     191: iconst_1
     192: anewarray     #25                 // class java/lang/String
     195: astore        14
     197: aload         14
     199: iconst_0
     200: ldc           #99                 // String ,
     202: aastore
     203: aload         14
     205: iconst_0
     206: iconst_0
     207: bipush        6
     209: aconst_null
     210: invokestatic  #33                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     213: checkcast     #70                 // class java/lang/Iterable
     216: astore        14
     218: iconst_0
     219: istore        15
     221: aload         14
     223: astore        16
     225: new           #72                 // class java/util/ArrayList
     228: dup
     229: aload         14
     231: bipush        10
     233: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     236: invokespecial #81                 // Method java/util/ArrayList."<init>":(I)V
     239: checkcast     #83                 // class java/util/Collection
     242: astore        17
     244: iconst_0
     245: istore        18
     247: aload         16
     249: invokeinterface #87,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     254: astore        19
     256: aload         19
     258: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     263: ifeq          386
     266: aload         19
     268: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     273: astore        20
     275: aload         17
     277: aload         20
     279: checkcast     #25                 // class java/lang/String
     282: astore        21
     284: astore        22
     286: iconst_0
     287: istore        23
     289: aload         21
     291: iconst_1
     292: newarray       char
     294: astore        24
     296: aload         24
     298: iconst_0
     299: bipush        32
     301: castore
     302: aload         24
     304: invokestatic  #60                 // Method kotlin/text/StringsKt.trimStart:(Ljava/lang/String;[C)Ljava/lang/String;
     307: checkcast     #23                 // class java/lang/CharSequence
     310: iconst_1
     311: anewarray     #25                 // class java/lang/String
     314: astore        24
     316: aload         24
     318: iconst_0
     319: ldc           #101                // String
     321: aastore
     322: aload         24
     324: iconst_0
     325: iconst_0
     326: bipush        6
     328: aconst_null
     329: invokestatic  #33                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     332: astore        25
     334: aload         25
     336: iconst_0
     337: invokeinterface #39,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     342: checkcast     #25                 // class java/lang/String
     345: astore        24
     347: aload         25
     349: iconst_1
     350: invokeinterface #39,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     355: checkcast     #25                 // class java/lang/String
     358: astore        26
     360: new           #103                // class Day2$Cube
     363: dup
     364: aload         26
     366: aload         24
     368: invokestatic  #66                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     371: invokespecial #106                // Method Day2$Cube."<init>":(Ljava/lang/String;I)V
     374: aload         22
     376: swap
     377: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     382: pop
     383: goto          256
     386: aload         17
     388: checkcast     #35                 // class java/util/List
     391: nop
     392: nop
     393: aload         28
     395: swap
     396: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     401: pop
     402: goto          153
     405: aload         8
     407: checkcast     #35                 // class java/util/List
     410: nop
     411: astore        28
     413: iload         27
     415: aload         28
     417: astore        29
     419: istore        30
     421: new           #112                // class Day2$Game
     424: dup
     425: iload         30
     427: aload         29
     429: invokespecial #115                // Method Day2$Game."<init>":(ILjava/util/List;)V
     432: areturn

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