object Day08 {
    const val EXPECTED_PART1_CHECK_ANSWER = 21
    const val EXPECTED_PART2_CHECK_ANSWER = 8
}

fun main() {

    fun List<String>.parseTreeGrid(): List<List<Int>> =
        this.map { it.toList() }.map { it.map { chr -> chr.digitToInt() } }

    fun List<List<Int>>.isVisible(x: Int, y: Int): Boolean {
        if (x == 0 || y == 0 || x == this[0].size - 1 || y == this.size - 1) return true
        val heightOfTree = this[y][x]
        if (this[y].subList(0, x).all { it < heightOfTree }) return true
        if (this[y].subList(x + 1, this[y].size).all { it < heightOfTree }) return true
        val treesInSameVerticalRow = this.fold(emptyList<Int>()) { acc, row -> acc + row[x] }
        if (treesInSameVerticalRow.subList(0, y).all { it < heightOfTree }) return true
        if (treesInSameVerticalRow.subList(y + 1, treesInSameVerticalRow.size).all { it < heightOfTree }) return true

        return false
    }

    fun List<List<Int>>.scenicScore(x: Int, y: Int): Int {
        val heightOfTree = this[y][x]

        val treesToTheLeft = this[y].subList(0, x)
        val leftTreesVisible = treesToTheLeft
            .takeLastWhile { it < heightOfTree }.size
            .let { if (it == treesToTheLeft.size) it else it + 1 } // accommodate for edges
        val treesToTheRight = this[y].subList(x + 1, this[y].size)
        val rightTreesVisible = treesToTheRight
            .takeWhile { it < heightOfTree }.size
            .let { if (it == treesToTheRight.size) it else it + 1 } // accommodate for edges

        val treesInSameVerticalRow = this.fold(emptyList<Int>()) { acc, row -> acc + row[x] }
        val treesToTheTop = treesInSameVerticalRow.subList(0, y)
        val upTreesVisible = treesToTheTop
            .takeLastWhile { it < heightOfTree }.size
            .let { if (it == treesToTheTop.size) it else it + 1 } // accommodate for edge
        val treesToTheBottom = treesInSameVerticalRow.subList(y + 1, treesInSameVerticalRow.size)
        val downTreesVisible = treesToTheBottom
                .takeWhile { it < heightOfTree }.size
                .let { if (it == treesToTheBottom.size) it else it + 1 } // accommodate for edge

        return leftTreesVisible * rightTreesVisible * upTreesVisible * downTreesVisible
    }

    fun part1(input: List<String>): Int {
        val treeGrid = input.parseTreeGrid()
        var treesVisible = 0
        for (xIndex in treeGrid[0].indices) {
            for (yIndex in treeGrid.indices) {
                if (treeGrid.isVisible(xIndex, yIndex)) {
                    treesVisible++
                }
            }
        }
        return treesVisible
    }

    fun part2(input: List<String>): Int {
        val treeGrid = input.parseTreeGrid()
        var highestScenicScore = 0
        for (xIndex in treeGrid[0].indices) {
            for (yIndex in treeGrid.indices) {
                val scenicScore = treeGrid.scenicScore(xIndex, yIndex)
                highestScenicScore = maxOf(scenicScore, highestScenicScore)
            }
        }
        return highestScenicScore
    }

    // test if implementation meets criteria from the description, like:
    val testInput = readInput("Day08_test")
    check(part1(testInput) == Day08.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
    check(part2(testInput) == Day08.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }

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

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

  public static final int EXPECTED_PART1_CHECK_ANSWER;

  public static final int EXPECTED_PART2_CHECK_ANSWER;

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

  static {};
    Code:
       0: new           #2                  // class Day08
       3: dup
       4: invokespecial #12                 // Method "<init>":()V
       7: putstatic     #15                 // Field INSTANCE:LDay08;
      10: return
}

Compiled from "Day08.kt"
public final class Day08Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day08_test
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)I
      10: bipush        21
      12: if_icmpne     19
      15: iconst_1
      16: goto          20
      19: iconst_0
      20: ifne          40
      23: iconst_0
      24: istore_2
      25: ldc           #20                 // String Part 1 failed
      27: astore_2
      28: new           #22                 // class java/lang/IllegalStateException
      31: dup
      32: aload_2
      33: invokevirtual #26                 // Method java/lang/Object.toString:()Ljava/lang/String;
      36: invokespecial #30                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      39: athrow
      40: aload_0
      41: invokestatic  #33                 // Method main$part2:(Ljava/util/List;)I
      44: bipush        8
      46: if_icmpne     53
      49: iconst_1
      50: goto          54
      53: iconst_0
      54: ifne          74
      57: iconst_0
      58: istore_2
      59: ldc           #35                 // String Part 2 failed
      61: astore_2
      62: new           #22                 // class java/lang/IllegalStateException
      65: dup
      66: aload_2
      67: invokevirtual #26                 // Method java/lang/Object.toString:()Ljava/lang/String;
      70: invokespecial #30                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      73: athrow
      74: ldc           #37                 // String Day08
      76: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      79: astore_1
      80: aload_1
      81: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)I
      84: istore_2
      85: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      88: iload_2
      89: invokevirtual #49                 // Method java/io/PrintStream.println:(I)V
      92: aload_1
      93: invokestatic  #33                 // Method main$part2:(Ljava/util/List;)I
      96: istore_2
      97: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
     100: iload_2
     101: invokevirtual #49                 // Method java/io/PrintStream.println:(I)V
     104: return

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

  private static final java.util.List<java.util.List<java.lang.Integer>> main$parseTreeGrid(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #67                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: astore_3
       9: new           #69                 // class java/util/ArrayList
      12: dup
      13: aload_1
      14: bipush        10
      16: invokestatic  #75                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      19: invokespecial #77                 // Method java/util/ArrayList."<init>":(I)V
      22: checkcast     #79                 // class java/util/Collection
      25: astore        4
      27: iconst_0
      28: istore        5
      30: aload_3
      31: invokeinterface #83,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      36: astore        6
      38: aload         6
      40: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      45: ifeq          91
      48: aload         6
      50: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      55: astore        7
      57: aload         4
      59: aload         7
      61: checkcast     #95                 // class java/lang/String
      64: astore        8
      66: astore        20
      68: iconst_0
      69: istore        9
      71: aload         8
      73: checkcast     #97                 // class java/lang/CharSequence
      76: invokestatic  #103                // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;
      79: aload         20
      81: swap
      82: invokeinterface #107,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      87: pop
      88: goto          38
      91: aload         4
      93: checkcast     #57                 // class java/util/List
      96: nop
      97: checkcast     #67                 // class java/lang/Iterable
     100: astore_1
     101: nop
     102: iconst_0
     103: istore_2
     104: aload_1
     105: astore_3
     106: new           #69                 // class java/util/ArrayList
     109: dup
     110: aload_1
     111: bipush        10
     113: invokestatic  #75                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     116: invokespecial #77                 // Method java/util/ArrayList."<init>":(I)V
     119: checkcast     #79                 // class java/util/Collection
     122: astore        4
     124: iconst_0
     125: istore        5
     127: aload_3
     128: invokeinterface #83,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     133: astore        6
     135: aload         6
     137: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     142: ifeq          288
     145: aload         6
     147: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     152: astore        7
     154: aload         4
     156: aload         7
     158: checkcast     #57                 // class java/util/List
     161: astore        8
     163: astore        20
     165: iconst_0
     166: istore        9
     168: aload         8
     170: checkcast     #67                 // class java/lang/Iterable
     173: astore        10
     175: iconst_0
     176: istore        11
     178: aload         10
     180: astore        12
     182: new           #69                 // class java/util/ArrayList
     185: dup
     186: aload         10
     188: bipush        10
     190: invokestatic  #75                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     193: invokespecial #77                 // Method java/util/ArrayList."<init>":(I)V
     196: checkcast     #79                 // class java/util/Collection
     199: astore        13
     201: iconst_0
     202: istore        14
     204: aload         12
     206: invokeinterface #83,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     211: astore        15
     213: aload         15
     215: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     220: ifeq          269
     223: aload         15
     225: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     230: astore        16
     232: aload         13
     234: aload         16
     236: checkcast     #109                // class java/lang/Character
     239: invokevirtual #113                // Method java/lang/Character.charValue:()C
     242: istore        17
     244: astore        18
     246: iconst_0
     247: istore        19
     249: iload         17
     251: invokestatic  #119                // Method kotlin/text/CharsKt.digitToInt:(C)I
     254: invokestatic  #125                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     257: aload         18
     259: swap
     260: invokeinterface #107,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     265: pop
     266: goto          213
     269: aload         13
     271: checkcast     #57                 // class java/util/List
     274: nop
     275: nop
     276: aload         20
     278: swap
     279: invokeinterface #107,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     284: pop
     285: goto          135
     288: aload         4
     290: checkcast     #57                 // class java/util/List
     293: nop
     294: areturn

  private static final boolean main$isVisible(java.util.List<? extends java.util.List<java.lang.Integer>>, int, int);
    Code:
       0: iload_1
       1: ifeq          41
       4: iload_2
       5: ifeq          41
       8: iload_1
       9: aload_0
      10: iconst_0
      11: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      16: checkcast     #57                 // class java/util/List
      19: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
      24: iconst_1
      25: isub
      26: if_icmpeq     41
      29: iload_2
      30: aload_0
      31: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
      36: iconst_1
      37: isub
      38: if_icmpne     43
      41: iconst_1
      42: ireturn
      43: aload_0
      44: iload_2
      45: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      50: checkcast     #57                 // class java/util/List
      53: iload_1
      54: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      59: checkcast     #155                // class java/lang/Number
      62: invokevirtual #158                // Method java/lang/Number.intValue:()I
      65: istore_3
      66: aload_0
      67: iload_2
      68: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      73: checkcast     #57                 // class java/util/List
      76: iconst_0
      77: iload_1
      78: invokeinterface #162,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
      83: checkcast     #67                 // class java/lang/Iterable
      86: astore        4
      88: iconst_0
      89: istore        5
      91: aload         4
      93: instanceof    #79                 // class java/util/Collection
      96: ifeq          116
      99: aload         4
     101: checkcast     #79                 // class java/util/Collection
     104: invokeinterface #165,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     109: ifeq          116
     112: iconst_1
     113: goto          176
     116: aload         4
     118: invokeinterface #83,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     123: astore        6
     125: aload         6
     127: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     132: ifeq          175
     135: aload         6
     137: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     142: astore        7
     144: aload         7
     146: checkcast     #155                // class java/lang/Number
     149: invokevirtual #158                // Method java/lang/Number.intValue:()I
     152: istore        8
     154: iconst_0
     155: istore        9
     157: iload         8
     159: iload_3
     160: if_icmpge     167
     163: iconst_1
     164: goto          168
     167: iconst_0
     168: ifne          125
     171: iconst_0
     172: goto          176
     175: iconst_1
     176: ifeq          181
     179: iconst_1
     180: ireturn
     181: aload_0
     182: iload_2
     183: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     188: checkcast     #57                 // class java/util/List
     191: iload_1
     192: iconst_1
     193: iadd
     194: aload_0
     195: iload_2
     196: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     201: checkcast     #57                 // class java/util/List
     204: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
     209: invokeinterface #162,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     214: checkcast     #67                 // class java/lang/Iterable
     217: astore        4
     219: iconst_0
     220: istore        5
     222: aload         4
     224: instanceof    #79                 // class java/util/Collection
     227: ifeq          247
     230: aload         4
     232: checkcast     #79                 // class java/util/Collection
     235: invokeinterface #165,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     240: ifeq          247
     243: iconst_1
     244: goto          307
     247: aload         4
     249: invokeinterface #83,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     254: astore        6
     256: aload         6
     258: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     263: ifeq          306
     266: aload         6
     268: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     273: astore        7
     275: aload         7
     277: checkcast     #155                // class java/lang/Number
     280: invokevirtual #158                // Method java/lang/Number.intValue:()I
     283: istore        8
     285: iconst_0
     286: istore        9
     288: iload         8
     290: iload_3
     291: if_icmpge     298
     294: iconst_1
     295: goto          299
     298: iconst_0
     299: ifne          256
     302: iconst_0
     303: goto          307
     306: iconst_1
     307: ifeq          312
     310: iconst_1
     311: ireturn
     312: aload_0
     313: checkcast     #67                 // class java/lang/Iterable
     316: astore        5
     318: invokestatic  #169                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     321: astore        6
     323: iconst_0
     324: istore        7
     326: aload         6
     328: astore        8
     330: aload         5
     332: invokeinterface #83,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     337: astore        9
     339: aload         9
     341: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     346: ifeq          393
     349: aload         9
     351: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     356: astore        10
     358: aload         8
     360: aload         10
     362: checkcast     #57                 // class java/util/List
     365: astore        11
     367: astore        12
     369: iconst_0
     370: istore        13
     372: aload         12
     374: checkcast     #79                 // class java/util/Collection
     377: aload         11
     379: iload_1
     380: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     385: invokestatic  #173                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     388: astore        8
     390: goto          339
     393: aload         8
     395: astore        4
     397: aload         4
     399: iconst_0
     400: iload_2
     401: invokeinterface #162,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     406: checkcast     #67                 // class java/lang/Iterable
     409: astore        5
     411: iconst_0
     412: istore        6
     414: aload         5
     416: instanceof    #79                 // class java/util/Collection
     419: ifeq          439
     422: aload         5
     424: checkcast     #79                 // class java/util/Collection
     427: invokeinterface #165,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     432: ifeq          439
     435: iconst_1
     436: goto          499
     439: aload         5
     441: invokeinterface #83,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     446: astore        7
     448: aload         7
     450: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     455: ifeq          498
     458: aload         7
     460: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     465: astore        8
     467: aload         8
     469: checkcast     #155                // class java/lang/Number
     472: invokevirtual #158                // Method java/lang/Number.intValue:()I
     475: istore        9
     477: iconst_0
     478: istore        10
     480: iload         9
     482: iload_3
     483: if_icmpge     490
     486: iconst_1
     487: goto          491
     490: iconst_0
     491: ifne          448
     494: iconst_0
     495: goto          499
     498: iconst_1
     499: ifeq          504
     502: iconst_1
     503: ireturn
     504: aload         4
     506: iload_2
     507: iconst_1
     508: iadd
     509: aload         4
     511: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
     516: invokeinterface #162,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     521: checkcast     #67                 // class java/lang/Iterable
     524: astore        5
     526: iconst_0
     527: istore        6
     529: aload         5
     531: instanceof    #79                 // class java/util/Collection
     534: ifeq          554
     537: aload         5
     539: checkcast     #79                 // class java/util/Collection
     542: invokeinterface #165,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     547: ifeq          554
     550: iconst_1
     551: goto          614
     554: aload         5
     556: invokeinterface #83,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     561: astore        7
     563: aload         7
     565: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     570: ifeq          613
     573: aload         7
     575: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     580: astore        8
     582: aload         8
     584: checkcast     #155                // class java/lang/Number
     587: invokevirtual #158                // Method java/lang/Number.intValue:()I
     590: istore        9
     592: iconst_0
     593: istore        10
     595: iload         9
     597: iload_3
     598: if_icmpge     605
     601: iconst_1
     602: goto          606
     605: iconst_0
     606: ifne          563
     609: iconst_0
     610: goto          614
     613: iconst_1
     614: ifeq          619
     617: iconst_1
     618: ireturn
     619: iconst_0
     620: ireturn

  private static final int main$scenicScore(java.util.List<? extends java.util.List<java.lang.Integer>>, int, int);
    Code:
       0: aload_0
       1: iload_2
       2: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
       7: checkcast     #57                 // class java/util/List
      10: iload_1
      11: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      16: checkcast     #155                // class java/lang/Number
      19: invokevirtual #158                // Method java/lang/Number.intValue:()I
      22: istore_3
      23: aload_0
      24: iload_2
      25: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      30: checkcast     #57                 // class java/util/List
      33: iconst_0
      34: iload_1
      35: invokeinterface #162,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
      40: astore        4
      42: aload         4
      44: astore        6
      46: nop
      47: iconst_0
      48: istore        7
      50: aload         6
      52: invokeinterface #196,  1          // InterfaceMethod java/util/List.isEmpty:()Z
      57: ifeq          66
      60: invokestatic  #169                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      63: goto          221
      66: aload         6
      68: aload         6
      70: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
      75: invokeinterface #200,  2          // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;
      80: astore        8
      82: aload         8
      84: invokeinterface #205,  1          // InterfaceMethod java/util/ListIterator.hasPrevious:()Z
      89: ifeq          213
      92: aload         8
      94: invokeinterface #208,  1          // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;
      99: checkcast     #155                // class java/lang/Number
     102: invokevirtual #158                // Method java/lang/Number.intValue:()I
     105: istore        9
     107: iconst_0
     108: istore        10
     110: iload         9
     112: iload_3
     113: if_icmpge     120
     116: iconst_1
     117: goto          121
     120: iconst_0
     121: ifne          82
     124: aload         8
     126: invokeinterface #209,  1          // InterfaceMethod java/util/ListIterator.next:()Ljava/lang/Object;
     131: pop
     132: aload         6
     134: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
     139: aload         8
     141: invokeinterface #212,  1          // InterfaceMethod java/util/ListIterator.nextIndex:()I
     146: isub
     147: istore        11
     149: iload         11
     151: ifne          160
     154: invokestatic  #169                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     157: goto          221
     160: new           #69                 // class java/util/ArrayList
     163: dup
     164: iload         11
     166: invokespecial #77                 // Method java/util/ArrayList."<init>":(I)V
     169: astore        12
     171: aload         12
     173: astore        13
     175: iconst_0
     176: istore        14
     178: aload         8
     180: invokeinterface #213,  1          // InterfaceMethod java/util/ListIterator.hasNext:()Z
     185: ifeq          204
     188: aload         13
     190: aload         8
     192: invokeinterface #209,  1          // InterfaceMethod java/util/ListIterator.next:()Ljava/lang/Object;
     197: invokevirtual #214                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     200: pop
     201: goto          178
     204: nop
     205: aload         12
     207: checkcast     #57                 // class java/util/List
     210: goto          221
     213: aload         6
     215: checkcast     #67                 // class java/lang/Iterable
     218: invokestatic  #217                // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     221: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
     226: istore        7
     228: iconst_0
     229: istore        8
     231: iload         7
     233: aload         4
     235: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
     240: if_icmpne     248
     243: iload         7
     245: goto          252
     248: iload         7
     250: iconst_1
     251: iadd
     252: nop
     253: istore        5
     255: aload_0
     256: iload_2
     257: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     262: checkcast     #57                 // class java/util/List
     265: iload_1
     266: iconst_1
     267: iadd
     268: aload_0
     269: iload_2
     270: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     275: checkcast     #57                 // class java/util/List
     278: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
     283: invokeinterface #162,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     288: astore        6
     290: aload         6
     292: checkcast     #67                 // class java/lang/Iterable
     295: astore        8
     297: nop
     298: iconst_0
     299: istore        9
     301: new           #69                 // class java/util/ArrayList
     304: dup
     305: invokespecial #219                // Method java/util/ArrayList."<init>":()V
     308: astore        10
     310: aload         8
     312: invokeinterface #83,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     317: astore        11
     319: aload         11
     321: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     326: ifeq          379
     329: aload         11
     331: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     336: astore        12
     338: aload         12
     340: checkcast     #155                // class java/lang/Number
     343: invokevirtual #158                // Method java/lang/Number.intValue:()I
     346: istore        13
     348: iconst_0
     349: istore        14
     351: iload         13
     353: iload_3
     354: if_icmpge     361
     357: iconst_1
     358: goto          362
     361: iconst_0
     362: ifne          368
     365: goto          379
     368: aload         10
     370: aload         12
     372: invokevirtual #214                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     375: pop
     376: goto          319
     379: aload         10
     381: checkcast     #57                 // class java/util/List
     384: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
     389: istore        9
     391: iconst_0
     392: istore        10
     394: iload         9
     396: aload         6
     398: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
     403: if_icmpne     411
     406: iload         9
     408: goto          415
     411: iload         9
     413: iconst_1
     414: iadd
     415: nop
     416: istore        7
     418: aload_0
     419: checkcast     #67                 // class java/lang/Iterable
     422: astore        9
     424: invokestatic  #169                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     427: astore        10
     429: iconst_0
     430: istore        11
     432: aload         10
     434: astore        12
     436: aload         9
     438: invokeinterface #83,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     443: astore        13
     445: aload         13
     447: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     452: ifeq          499
     455: aload         13
     457: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     462: astore        14
     464: aload         12
     466: aload         14
     468: checkcast     #57                 // class java/util/List
     471: astore        15
     473: astore        16
     475: iconst_0
     476: istore        17
     478: aload         16
     480: checkcast     #79                 // class java/util/Collection
     483: aload         15
     485: iload_1
     486: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     491: invokestatic  #173                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     494: astore        12
     496: goto          445
     499: aload         12
     501: astore        8
     503: aload         8
     505: iconst_0
     506: iload_2
     507: invokeinterface #162,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     512: astore        9
     514: aload         9
     516: astore        11
     518: nop
     519: iconst_0
     520: istore        12
     522: aload         11
     524: invokeinterface #196,  1          // InterfaceMethod java/util/List.isEmpty:()Z
     529: ifeq          538
     532: invokestatic  #169                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     535: goto          693
     538: aload         11
     540: aload         11
     542: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
     547: invokeinterface #200,  2          // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;
     552: astore        13
     554: aload         13
     556: invokeinterface #205,  1          // InterfaceMethod java/util/ListIterator.hasPrevious:()Z
     561: ifeq          685
     564: aload         13
     566: invokeinterface #208,  1          // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;
     571: checkcast     #155                // class java/lang/Number
     574: invokevirtual #158                // Method java/lang/Number.intValue:()I
     577: istore        14
     579: iconst_0
     580: istore        15
     582: iload         14
     584: iload_3
     585: if_icmpge     592
     588: iconst_1
     589: goto          593
     592: iconst_0
     593: ifne          554
     596: aload         13
     598: invokeinterface #209,  1          // InterfaceMethod java/util/ListIterator.next:()Ljava/lang/Object;
     603: pop
     604: aload         11
     606: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
     611: aload         13
     613: invokeinterface #212,  1          // InterfaceMethod java/util/ListIterator.nextIndex:()I
     618: isub
     619: istore        16
     621: iload         16
     623: ifne          632
     626: invokestatic  #169                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     629: goto          693
     632: new           #69                 // class java/util/ArrayList
     635: dup
     636: iload         16
     638: invokespecial #77                 // Method java/util/ArrayList."<init>":(I)V
     641: astore        17
     643: aload         17
     645: astore        18
     647: iconst_0
     648: istore        19
     650: aload         13
     652: invokeinterface #213,  1          // InterfaceMethod java/util/ListIterator.hasNext:()Z
     657: ifeq          676
     660: aload         18
     662: aload         13
     664: invokeinterface #209,  1          // InterfaceMethod java/util/ListIterator.next:()Ljava/lang/Object;
     669: invokevirtual #214                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     672: pop
     673: goto          650
     676: nop
     677: aload         17
     679: checkcast     #57                 // class java/util/List
     682: goto          693
     685: aload         11
     687: checkcast     #67                 // class java/lang/Iterable
     690: invokestatic  #217                // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     693: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
     698: istore        12
     700: iconst_0
     701: istore        13
     703: iload         12
     705: aload         9
     707: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
     712: if_icmpne     720
     715: iload         12
     717: goto          724
     720: iload         12
     722: iconst_1
     723: iadd
     724: nop
     725: istore        10
     727: aload         8
     729: iload_2
     730: iconst_1
     731: iadd
     732: aload         8
     734: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
     739: invokeinterface #162,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     744: astore        11
     746: aload         11
     748: checkcast     #67                 // class java/lang/Iterable
     751: astore        13
     753: nop
     754: iconst_0
     755: istore        14
     757: new           #69                 // class java/util/ArrayList
     760: dup
     761: invokespecial #219                // Method java/util/ArrayList."<init>":()V
     764: astore        15
     766: aload         13
     768: invokeinterface #83,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     773: astore        16
     775: aload         16
     777: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     782: ifeq          835
     785: aload         16
     787: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     792: astore        17
     794: aload         17
     796: checkcast     #155                // class java/lang/Number
     799: invokevirtual #158                // Method java/lang/Number.intValue:()I
     802: istore        18
     804: iconst_0
     805: istore        19
     807: iload         18
     809: iload_3
     810: if_icmpge     817
     813: iconst_1
     814: goto          818
     817: iconst_0
     818: ifne          824
     821: goto          835
     824: aload         15
     826: aload         17
     828: invokevirtual #214                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     831: pop
     832: goto          775
     835: aload         15
     837: checkcast     #57                 // class java/util/List
     840: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
     845: istore        14
     847: iconst_0
     848: istore        15
     850: iload         14
     852: aload         11
     854: invokeinterface #153,  1          // InterfaceMethod java/util/List.size:()I
     859: if_icmpne     867
     862: iload         14
     864: goto          871
     867: iload         14
     869: iconst_1
     870: iadd
     871: nop
     872: istore        12
     874: iload         5
     876: iload         7
     878: imul
     879: iload         10
     881: imul
     882: iload         12
     884: imul
     885: ireturn

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #252                // Method main$parseTreeGrid:(Ljava/util/List;)Ljava/util/List;
       4: astore_1
       5: iconst_0
       6: istore_2
       7: iconst_0
       8: istore_3
       9: aload_1
      10: iconst_0
      11: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      16: checkcast     #79                 // class java/util/Collection
      19: invokeinterface #253,  1          // InterfaceMethod java/util/Collection.size:()I
      24: istore        4
      26: iload_3
      27: iload         4
      29: if_icmpge     78
      32: iconst_0
      33: istore        5
      35: aload_1
      36: checkcast     #79                 // class java/util/Collection
      39: invokeinterface #253,  1          // InterfaceMethod java/util/Collection.size:()I
      44: istore        6
      46: iload         5
      48: iload         6
      50: if_icmpge     72
      53: aload_1
      54: iload_3
      55: iload         5
      57: invokestatic  #255                // Method main$isVisible:(Ljava/util/List;II)Z
      60: ifeq          66
      63: iinc          2, 1
      66: iinc          5, 1
      69: goto          46
      72: iinc          3, 1
      75: goto          26
      78: iload_2
      79: ireturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #252                // Method main$parseTreeGrid:(Ljava/util/List;)Ljava/util/List;
       4: astore_1
       5: iconst_0
       6: istore_2
       7: iconst_0
       8: istore_3
       9: aload_1
      10: iconst_0
      11: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      16: checkcast     #79                 // class java/util/Collection
      19: invokeinterface #253,  1          // InterfaceMethod java/util/Collection.size:()I
      24: istore        4
      26: iload_3
      27: iload         4
      29: if_icmpge     81
      32: iconst_0
      33: istore        5
      35: aload_1
      36: checkcast     #79                 // class java/util/Collection
      39: invokeinterface #253,  1          // InterfaceMethod java/util/Collection.size:()I
      44: istore        6
      46: iload         5
      48: iload         6
      50: if_icmpge     75
      53: aload_1
      54: iload_3
      55: iload         5
      57: invokestatic  #261                // Method main$scenicScore:(Ljava/util/List;II)I
      60: istore        7
      62: iload         7
      64: iload_2
      65: invokestatic  #267                // Method java/lang/Math.max:(II)I
      68: istore_2
      69: iinc          5, 1
      72: goto          46
      75: iinc          3, 1
      78: goto          26
      81: iload_2
      82: ireturn
}


object Day05 {
    const val dayNumber = "05"

    const val EXPECTED_PART1_CHECK_ANSWER = "CMZ"
    const val EXPECTED_PART2_CHECK_ANSWER = "MCD"

    const val STACK_SETUP_ENTRY_WITH_SPACE_SIZE = 4
    const val STACK_SETUP_ENTRY_SIZE = 3
}

fun main() {

    fun List<String>.parseStackSetup(): List<MutableList<Char>> {
        val stacks = mutableListOf<MutableList<Char>>()
        for (lineIdx in this.size - 2 downTo 0) {
            val line = this[lineIdx]
            var stackIndex = 0
            var stackEntryStartPosition = 0
            while (stackEntryStartPosition < line.length) {
                if (stacks.size < stackIndex + 1) {
                    stacks += mutableListOf<Char>()
                }
                val stackEntry = line.substring(
                    stackEntryStartPosition until (stackEntryStartPosition + Day05.STACK_SETUP_ENTRY_SIZE)
                )
                if (stackEntry.isNotBlank()) {
                    stacks[stackIndex].add(stackEntry[1])
                }
                stackIndex++
                stackEntryStartPosition = stackIndex * Day05.STACK_SETUP_ENTRY_WITH_SPACE_SIZE
            }
        }
        return stacks
    }

    fun parseAndApplyMoves(
        input: List<String>,
        applyMove: (stacks: List<MutableList<Char>>, move: Triple<Int, Int, Int>) -> Unit
    ): String {
        val indexOfEmptyLine = input.indexOf("")
        val stackSetup = input.subList(0, indexOfEmptyLine).parseStackSetup()
        val moves = input.subList(indexOfEmptyLine + 1, input.size)
        val moveTemplate = Regex("move (\\d+) from (\\d+) to (\\d+)")
        moves.forEach { move ->
            moveTemplate.matchEntire(move)?.apply {
                val (amount, from, to) = this.destructured
                applyMove(stackSetup, Triple(amount.toInt(), from.toInt(), to.toInt()))
            }
        }
        return stackSetup.map { stack -> stack.last() }.joinToString(separator = "")
    }

    fun part1(input: List<String>): String {
        return parseAndApplyMoves(input) { stacks, (amount, from, to) ->
            repeat(amount) { _ ->
                val toMove = stacks[from - 1].removeLast()
                stacks[to - 1].add(toMove)
            }
        }
    }

    fun part2(input: List<String>): String {
        return parseAndApplyMoves(input) { stacks, (amount, from, to) ->
            val removedChars = (1..amount).map { _ -> stacks[from - 1].removeLast() }
            stacks[to - 1].addAll(removedChars.reversed())
        }
    }

    // test if implementation meets criteria from the description, like:
    val testInput = readInput("Day${Day05.dayNumber}_test")
    check(part1(testInput) == Day05.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
    check(part2(testInput) == Day05.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }

    val input = readInput("Day${Day05.dayNumber}")
    println(part1(input))
    println(part2(input))
}

Compiled from "Day05.kt"
public final class Day05Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day05_test
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)Ljava/lang/String;
      10: ldc           #20                 // String CMZ
      12: invokestatic  #26                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      15: ifne          35
      18: iconst_0
      19: istore_2
      20: ldc           #28                 // String Part 1 failed
      22: astore_2
      23: new           #30                 // class java/lang/IllegalStateException
      26: dup
      27: aload_2
      28: invokevirtual #34                 // Method java/lang/Object.toString:()Ljava/lang/String;
      31: invokespecial #38                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      34: athrow
      35: aload_0
      36: invokestatic  #41                 // Method main$part2:(Ljava/util/List;)Ljava/lang/String;
      39: ldc           #43                 // String MCD
      41: invokestatic  #26                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      44: ifne          64
      47: iconst_0
      48: istore_2
      49: ldc           #45                 // String Part 2 failed
      51: astore_2
      52: new           #30                 // class java/lang/IllegalStateException
      55: dup
      56: aload_2
      57: invokevirtual #34                 // Method java/lang/Object.toString:()Ljava/lang/String;
      60: invokespecial #38                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      63: athrow
      64: ldc           #47                 // String Day05
      66: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      69: astore_1
      70: aload_1
      71: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)Ljava/lang/String;
      74: getstatic     #53                 // Field java/lang/System.out:Ljava/io/PrintStream;
      77: swap
      78: invokevirtual #59                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      81: aload_1
      82: invokestatic  #41                 // Method main$part2:(Ljava/util/List;)Ljava/lang/String;
      85: getstatic     #53                 // Field java/lang/System.out:Ljava/io/PrintStream;
      88: swap
      89: invokevirtual #59                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      92: return

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

  private static final java.util.List<java.util.List<java.lang.Character>> main$parseStackSetup(java.util.List<java.lang.String>);
    Code:
       0: new           #77                 // class java/util/ArrayList
       3: dup
       4: invokespecial #79                 // Method java/util/ArrayList."<init>":()V
       7: checkcast     #67                 // class java/util/List
      10: astore_1
      11: aload_0
      12: invokeinterface #83,  1           // InterfaceMethod java/util/List.size:()I
      17: iconst_2
      18: isub
      19: istore_2
      20: iconst_m1
      21: iload_2
      22: if_icmpge     163
      25: aload_0
      26: iload_2
      27: invokeinterface #87,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      32: checkcast     #89                 // class java/lang/String
      35: astore_3
      36: iconst_0
      37: istore        4
      39: iconst_0
      40: istore        5
      42: iload         5
      44: aload_3
      45: invokevirtual #92                 // Method java/lang/String.length:()I
      48: if_icmpge     157
      51: aload_1
      52: invokeinterface #83,  1           // InterfaceMethod java/util/List.size:()I
      57: iload         4
      59: iconst_1
      60: iadd
      61: if_icmpge     85
      64: nop
      65: aload_1
      66: checkcast     #94                 // class java/util/Collection
      69: new           #77                 // class java/util/ArrayList
      72: dup
      73: invokespecial #79                 // Method java/util/ArrayList."<init>":()V
      76: checkcast     #67                 // class java/util/List
      79: invokeinterface #98,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      84: pop
      85: aload_3
      86: iload         5
      88: iload         5
      90: iconst_3
      91: iadd
      92: invokestatic  #104                // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      95: invokestatic  #110                // Method kotlin/text/StringsKt.substring:(Ljava/lang/String;Lkotlin/ranges/IntRange;)Ljava/lang/String;
      98: astore        6
     100: aload         6
     102: checkcast     #112                // class java/lang/CharSequence
     105: invokestatic  #116                // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z
     108: ifne          115
     111: iconst_1
     112: goto          116
     115: iconst_0
     116: ifeq          145
     119: aload_1
     120: iload         4
     122: invokeinterface #87,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     127: checkcast     #67                 // class java/util/List
     130: aload         6
     132: iconst_1
     133: invokevirtual #120                // Method java/lang/String.charAt:(I)C
     136: invokestatic  #126                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     139: invokeinterface #127,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     144: pop
     145: iinc          4, 1
     148: iload         4
     150: iconst_4
     151: imul
     152: istore        5
     154: goto          42
     157: iinc          2, -1
     160: goto          20
     163: aload_1
     164: areturn

  private static final java.lang.String main$parseAndApplyMoves(java.util.List<java.lang.String>, kotlin.jvm.functions.Function2<? super java.util.List<? extends java.util.List<java.lang.Character>>, ? super kotlin.Triple<java.lang.Integer, java.lang.Integer, java.lang.Integer>, kotlin.Unit>);
    Code:
       0: aload_0
       1: ldc           #140                // String
       3: invokeinterface #144,  2          // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I
       8: istore_2
       9: aload_0
      10: iconst_0
      11: iload_2
      12: invokeinterface #148,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
      17: invokestatic  #150                // Method main$parseStackSetup:(Ljava/util/List;)Ljava/util/List;
      20: astore_3
      21: aload_0
      22: iload_2
      23: iconst_1
      24: iadd
      25: aload_0
      26: invokeinterface #83,  1           // InterfaceMethod java/util/List.size:()I
      31: invokeinterface #148,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
      36: astore        4
      38: new           #152                // class kotlin/text/Regex
      41: dup
      42: ldc           #154                // String move (\\d+) from (\\d+) to (\\d+)
      44: invokespecial #155                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      47: astore        5
      49: aload         4
      51: checkcast     #157                // class java/lang/Iterable
      54: astore        6
      56: iconst_0
      57: istore        7
      59: aload         6
      61: invokeinterface #161,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      66: astore        8
      68: aload         8
      70: invokeinterface #167,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      75: ifeq          242
      78: aload         8
      80: invokeinterface #171,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      85: astore        9
      87: aload         9
      89: checkcast     #89                 // class java/lang/String
      92: astore        10
      94: iconst_0
      95: istore        11
      97: aload         5
      99: aload         10
     101: checkcast     #112                // class java/lang/CharSequence
     104: invokevirtual #175                // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;
     107: dup
     108: ifnull        235
     111: astore        12
     113: aload         12
     115: astore        13
     117: iconst_0
     118: istore        14
     120: aload         13
     122: invokeinterface #181,  1          // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;
     127: astore        15
     129: aload         15
     131: invokevirtual #187                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     134: invokeinterface #191,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     139: iconst_1
     140: invokeinterface #87,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     145: checkcast     #89                 // class java/lang/String
     148: astore        16
     150: aload         15
     152: invokevirtual #187                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     155: invokeinterface #191,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     160: iconst_2
     161: invokeinterface #87,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     166: checkcast     #89                 // class java/lang/String
     169: astore        17
     171: aload         15
     173: invokevirtual #187                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     176: invokeinterface #191,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     181: iconst_3
     182: invokeinterface #87,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     187: checkcast     #89                 // class java/lang/String
     190: astore        18
     192: aload_1
     193: aload_3
     194: new           #193                // class kotlin/Triple
     197: dup
     198: aload         16
     200: invokestatic  #199                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     203: invokestatic  #202                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     206: aload         17
     208: invokestatic  #199                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     211: invokestatic  #202                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     214: aload         18
     216: invokestatic  #199                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     219: invokestatic  #202                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     222: invokespecial #205                // Method kotlin/Triple."<init>":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
     225: invokeinterface #211,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     230: pop
     231: nop
     232: goto          237
     235: pop
     236: nop
     237: nop
     238: nop
     239: goto          68
     242: nop
     243: aload_3
     244: checkcast     #157                // class java/lang/Iterable
     247: astore        6
     249: iconst_0
     250: istore        7
     252: aload         6
     254: astore        8
     256: new           #77                 // class java/util/ArrayList
     259: dup
     260: aload         6
     262: bipush        10
     264: invokestatic  #217                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     267: invokespecial #220                // Method java/util/ArrayList."<init>":(I)V
     270: checkcast     #94                 // class java/util/Collection
     273: astore        9
     275: iconst_0
     276: istore        10
     278: aload         8
     280: invokeinterface #161,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     285: astore        11
     287: aload         11
     289: invokeinterface #167,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     294: ifeq          346
     297: aload         11
     299: invokeinterface #171,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     304: astore        12
     306: aload         9
     308: aload         12
     310: checkcast     #67                 // class java/util/List
     313: astore        13
     315: astore        19
     317: iconst_0
     318: istore        14
     320: aload         13
     322: invokestatic  #224                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     325: checkcast     #122                // class java/lang/Character
     328: invokevirtual #228                // Method java/lang/Character.charValue:()C
     331: invokestatic  #126                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     334: aload         19
     336: swap
     337: invokeinterface #98,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     342: pop
     343: goto          287
     346: aload         9
     348: checkcast     #67                 // class java/util/List
     351: nop
     352: checkcast     #157                // class java/lang/Iterable
     355: ldc           #140                // String
     357: checkcast     #112                // class java/lang/CharSequence
     360: aconst_null
     361: aconst_null
     362: iconst_0
     363: aconst_null
     364: aconst_null
     365: bipush        62
     367: aconst_null
     368: invokestatic  #232                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
     371: areturn

  private static final kotlin.Unit main$part1$lambda$4(java.util.List, kotlin.Triple);
    Code:
       0: aload_0
       1: ldc_w         #264                // String stacks
       4: invokestatic  #268                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: ldc_w         #270                // String <destruct>
      11: invokestatic  #268                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      14: aload_1
      15: invokevirtual #273                // Method kotlin/Triple.component1:()Ljava/lang/Object;
      18: checkcast     #275                // class java/lang/Number
      21: invokevirtual #278                // Method java/lang/Number.intValue:()I
      24: istore_2
      25: aload_1
      26: invokevirtual #281                // Method kotlin/Triple.component2:()Ljava/lang/Object;
      29: checkcast     #275                // class java/lang/Number
      32: invokevirtual #278                // Method java/lang/Number.intValue:()I
      35: istore_3
      36: aload_1
      37: invokevirtual #284                // Method kotlin/Triple.component3:()Ljava/lang/Object;
      40: checkcast     #275                // class java/lang/Number
      43: invokevirtual #278                // Method java/lang/Number.intValue:()I
      46: istore        4
      48: iconst_0
      49: istore        5
      51: iload         5
      53: iload_2
      54: if_icmpge     123
      57: iconst_0
      58: istore        6
      60: aload_0
      61: iload_3
      62: iconst_1
      63: isub
      64: invokeinterface #87,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      69: checkcast     #67                 // class java/util/List
      72: invokeinterface #287,  1          // InterfaceMethod java/util/List.removeLast:()Ljava/lang/Object;
      77: dup
      78: ldc_w         #289                // String removeLast(...)
      81: invokestatic  #292                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      84: checkcast     #122                // class java/lang/Character
      87: invokevirtual #228                // Method java/lang/Character.charValue:()C
      90: istore        7
      92: aload_0
      93: iload         4
      95: iconst_1
      96: isub
      97: invokeinterface #87,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     102: checkcast     #67                 // class java/util/List
     105: iload         7
     107: invokestatic  #126                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     110: invokeinterface #127,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     115: pop
     116: nop
     117: iinc          5, 1
     120: goto          51
     123: getstatic     #298                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     126: areturn

  private static final java.lang.String main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokedynamic #317,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;
       6: invokestatic  #319                // Method main$parseAndApplyMoves:(Ljava/util/List;Lkotlin/jvm/functions/Function2;)Ljava/lang/String;
       9: areturn

  private static final kotlin.Unit main$part2$lambda$6(java.util.List, kotlin.Triple);
    Code:
       0: aload_0
       1: ldc_w         #264                // String stacks
       4: invokestatic  #268                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: ldc_w         #270                // String <destruct>
      11: invokestatic  #268                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      14: aload_1
      15: invokevirtual #273                // Method kotlin/Triple.component1:()Ljava/lang/Object;
      18: checkcast     #275                // class java/lang/Number
      21: invokevirtual #278                // Method java/lang/Number.intValue:()I
      24: istore_2
      25: aload_1
      26: invokevirtual #281                // Method kotlin/Triple.component2:()Ljava/lang/Object;
      29: checkcast     #275                // class java/lang/Number
      32: invokevirtual #278                // Method java/lang/Number.intValue:()I
      35: istore_3
      36: aload_1
      37: invokevirtual #284                // Method kotlin/Triple.component3:()Ljava/lang/Object;
      40: checkcast     #275                // class java/lang/Number
      43: invokevirtual #278                // Method java/lang/Number.intValue:()I
      46: istore        4
      48: new           #322                // class kotlin/ranges/IntRange
      51: dup
      52: iconst_1
      53: iload_2
      54: invokespecial #325                // Method kotlin/ranges/IntRange."<init>":(II)V
      57: checkcast     #157                // class java/lang/Iterable
      60: astore        6
      62: iconst_0
      63: istore        7
      65: aload         6
      67: astore        8
      69: new           #77                 // class java/util/ArrayList
      72: dup
      73: aload         6
      75: bipush        10
      77: invokestatic  #217                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      80: invokespecial #220                // Method java/util/ArrayList."<init>":(I)V
      83: checkcast     #94                 // class java/util/Collection
      86: astore        9
      88: iconst_0
      89: istore        10
      91: aload         8
      93: invokeinterface #161,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      98: astore        11
     100: aload         11
     102: invokeinterface #167,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     107: ifeq          159
     110: aload         11
     112: checkcast     #327                // class kotlin/collections/IntIterator
     115: invokevirtual #330                // Method kotlin/collections/IntIterator.nextInt:()I
     118: istore        12
     120: aload         9
     122: astore        14
     124: iconst_0
     125: istore        13
     127: aload_0
     128: iload_3
     129: iconst_1
     130: isub
     131: invokeinterface #87,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     136: checkcast     #67                 // class java/util/List
     139: invokeinterface #287,  1          // InterfaceMethod java/util/List.removeLast:()Ljava/lang/Object;
     144: checkcast     #122                // class java/lang/Character
     147: aload         14
     149: swap
     150: invokeinterface #98,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     155: pop
     156: goto          100
     159: aload         9
     161: checkcast     #67                 // class java/util/List
     164: nop
     165: astore        5
     167: aload_0
     168: iload         4
     170: iconst_1
     171: isub
     172: invokeinterface #87,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     177: checkcast     #67                 // class java/util/List
     180: aload         5
     182: checkcast     #157                // class java/lang/Iterable
     185: invokestatic  #334                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
     188: checkcast     #94                 // class java/util/Collection
     191: invokeinterface #338,  2          // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z
     196: pop
     197: getstatic     #298                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     200: areturn

  private static final java.lang.String main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokedynamic #344,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function2;
       6: invokestatic  #319                // Method main$parseAndApplyMoves:(Ljava/util/List;Lkotlin/jvm/functions/Function2;)Ljava/lang/String;
       9: areturn
}

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

  public static final java.lang.String dayNumber;

  public static final java.lang.String EXPECTED_PART1_CHECK_ANSWER;

  public static final java.lang.String EXPECTED_PART2_CHECK_ANSWER;

  public static final int STACK_SETUP_ENTRY_WITH_SPACE_SIZE;

  public static final int STACK_SETUP_ENTRY_SIZE;

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

  static {};
    Code:
       0: new           #2                  // class Day05
       3: dup
       4: invokespecial #12                 // Method "<init>":()V
       7: putstatic     #15                 // Field INSTANCE:LDay05;
      10: return
}


object Day11 {
    const val EXPECTED_PART1_CHECK_ANSWER = 10605L
    const val EXPECTED_PART2_CHECK_ANSWER = 2713310158

    const val PART1_RUNS = 20
    const val PART2_RUNS = 10_000

    const val WORRY_LEVEL_DIVISION_AMOUNT = 3

    val MONKEY_LINE_ITEMS = Regex("\\s+Starting items: ([, \\d]+)")
    val MONKEY_LINE_OPERATION = Regex("\\s+Operation: new = old ([+*]) (\\w+)")
    val MONKEY_LINE_TEST = Regex("\\s+Test: divisible by (\\d+)")
    val MONKEY_LINE_THROW = Regex("\\s+If (true|false): throw to monkey (\\d+)")
}

data class Item(var worryLevel: Long)

class Monkey(
    startingItems: List<Item>,
    val operation: (Long) -> Long,
    val testDivisibleBy: Int,
    private val testTrueDestinationMonkey: Int,
    private val testFalseDestinationMonkey: Int,
    private val relieve: Boolean = true,
) {
    private val items: MutableList<Item> = startingItems.toMutableList()
    var itemsInspected = 0
        private set

    fun addItems(items: List<Item>) {
        this.items.addAll(items)
    }

    fun turn(worryReduceVale: Int): Map<Int, List<Item>> {
        val itemsToThrow = mutableMapOf<Int, List<Item>>()
        for (item in items) {
            item.worryLevel = operation(item.worryLevel)
            if (relieve) {
                item.worryLevel /= Day11.WORRY_LEVEL_DIVISION_AMOUNT
            }
            item.worryLevel %= worryReduceVale
            itemsToThrow.compute(
                if (item.worryLevel % testDivisibleBy == 0L) testTrueDestinationMonkey else testFalseDestinationMonkey
            ) { _, currentItems ->
                (currentItems ?: emptyList()) + item
            }
            itemsInspected++
        }
        items.clear()
        return itemsToThrow
    }
}

class MonkeyBusiness(private val monkeys: List<Monkey>) {
    private val worryReduceVale = monkeys.map { it.testDivisibleBy }.reduce(Int::times)
    private fun round() {
        monkeys.forEach { monkey ->
            val itemsToPass = monkey.turn(worryReduceVale)
            itemsToPass.forEach { (toMonkey, items) ->
                monkeys[toMonkey].addItems(items)
            }
        }
    }

    fun process(numberOfRounds: Int): Long {
        repeat(numberOfRounds) {
            round()
        }
        return monkeys.map { it.itemsInspected }.sortedDescending().take(2).let { it[0].toLong() * it[1].toLong() }
    }
}

fun main() {

    fun List<String>.parseMonkeyBusiness(doRelieve: Boolean = true): MonkeyBusiness {
        val monkeys = mutableListOf<Monkey>()
        var inputIdx = 1
        while (inputIdx < size) {
            val (itemsWorryLevels) = Day11.MONKEY_LINE_ITEMS.matchEntire(this[inputIdx++])!!.destructured
            val items = itemsWorryLevels.split(",").map(String::trim).map { Item(it.toLong()) }
            val (operation, operationValue) = Day11.MONKEY_LINE_OPERATION.matchEntire(this[inputIdx++])!!.destructured
            val (testDivisibleValue) = Day11.MONKEY_LINE_TEST.matchEntire(this[inputIdx++])!!.destructured
            val (_, throwToWhenTrue) = Day11.MONKEY_LINE_THROW.matchEntire(this[inputIdx++])!!.destructured
            val (_, throwToWhenFalse) = Day11.MONKEY_LINE_THROW.matchEntire(this[inputIdx++])!!.destructured

            monkeys.add(
                Monkey(
                    items,
                    {
                        val operand = when (operationValue) {
                            "old" -> it
                            else -> operationValue.toLong()
                        }
                        when (operation) {
                            "*" -> it * operand
                            "+" -> it + operand
                            else -> error("Unknown operation $operation")
                        }
                    },
                    testDivisibleValue.toInt(),
                    throwToWhenTrue.toInt(),
                    throwToWhenFalse.toInt(),
                    doRelieve,
                )
            )
            inputIdx += 2
        }
        return MonkeyBusiness(monkeys)
    }

    fun part1(input: List<String>): Long {
        val monkeyBusiness = input.parseMonkeyBusiness()
        return monkeyBusiness.process(Day11.PART1_RUNS)
    }

    fun part2(input: List<String>): Long {
        val monkeyBusiness = input.parseMonkeyBusiness(false)
        return monkeyBusiness.process(Day11.PART2_RUNS)
    }

    // test if implementation meets criteria from the description, like:
    val testInput = readInput("Day11_test")
    check(part1(testInput) == Day11.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
    check(part2(testInput) == Day11.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }

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

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

  public static final long EXPECTED_PART1_CHECK_ANSWER;

  public static final long EXPECTED_PART2_CHECK_ANSWER;

  public static final int PART1_RUNS;

  public static final int PART2_RUNS;

  public static final int WORRY_LEVEL_DIVISION_AMOUNT;

  private static final kotlin.text.Regex MONKEY_LINE_ITEMS;

  private static final kotlin.text.Regex MONKEY_LINE_OPERATION;

  private static final kotlin.text.Regex MONKEY_LINE_TEST;

  private static final kotlin.text.Regex MONKEY_LINE_THROW;

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

  public final kotlin.text.Regex getMONKEY_LINE_ITEMS();
    Code:
       0: getstatic     #17                 // Field MONKEY_LINE_ITEMS:Lkotlin/text/Regex;
       3: areturn

  public final kotlin.text.Regex getMONKEY_LINE_OPERATION();
    Code:
       0: getstatic     #21                 // Field MONKEY_LINE_OPERATION:Lkotlin/text/Regex;
       3: areturn

  public final kotlin.text.Regex getMONKEY_LINE_TEST();
    Code:
       0: getstatic     #25                 // Field MONKEY_LINE_TEST:Lkotlin/text/Regex;
       3: areturn

  public final kotlin.text.Regex getMONKEY_LINE_THROW();
    Code:
       0: getstatic     #29                 // Field MONKEY_LINE_THROW:Lkotlin/text/Regex;
       3: areturn

  static {};
    Code:
       0: new           #2                  // class Day11
       3: dup
       4: invokespecial #31                 // Method "<init>":()V
       7: putstatic     #34                 // Field INSTANCE:LDay11;
      10: new           #36                 // class kotlin/text/Regex
      13: dup
      14: ldc           #38                 // String \\s+Starting items: ([, \\d]+)
      16: invokespecial #41                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      19: putstatic     #17                 // Field MONKEY_LINE_ITEMS:Lkotlin/text/Regex;
      22: new           #36                 // class kotlin/text/Regex
      25: dup
      26: ldc           #43                 // String \\s+Operation: new = old ([+*]) (\\w+)
      28: invokespecial #41                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      31: putstatic     #21                 // Field MONKEY_LINE_OPERATION:Lkotlin/text/Regex;
      34: new           #36                 // class kotlin/text/Regex
      37: dup
      38: ldc           #45                 // String \\s+Test: divisible by (\\d+)
      40: invokespecial #41                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      43: putstatic     #25                 // Field MONKEY_LINE_TEST:Lkotlin/text/Regex;
      46: new           #36                 // class kotlin/text/Regex
      49: dup
      50: ldc           #47                 // String \\s+If (true|false): throw to monkey (\\d+)
      52: invokespecial #41                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      55: putstatic     #29                 // Field MONKEY_LINE_THROW:Lkotlin/text/Regex;
      58: return
}

Compiled from "Day11.kt"
public final class Day11Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day11_test
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)J
      10: ldc2_w        #19                 // long 10605l
      13: lcmp
      14: ifne          21
      17: iconst_1
      18: goto          22
      21: iconst_0
      22: ifne          42
      25: iconst_0
      26: istore_2
      27: ldc           #22                 // String Part 1 failed
      29: astore_2
      30: new           #24                 // class java/lang/IllegalStateException
      33: dup
      34: aload_2
      35: invokevirtual #28                 // Method java/lang/Object.toString:()Ljava/lang/String;
      38: invokespecial #32                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      41: athrow
      42: aload_0
      43: invokestatic  #35                 // Method main$part2:(Ljava/util/List;)J
      46: ldc2_w        #36                 // long 2713310158l
      49: lcmp
      50: ifne          57
      53: iconst_1
      54: goto          58
      57: iconst_0
      58: ifne          78
      61: iconst_0
      62: istore_2
      63: ldc           #39                 // String Part 2 failed
      65: astore_2
      66: new           #24                 // class java/lang/IllegalStateException
      69: dup
      70: aload_2
      71: invokevirtual #28                 // Method java/lang/Object.toString:()Ljava/lang/String;
      74: invokespecial #32                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      77: athrow
      78: ldc           #41                 // String Day11
      80: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      83: astore_1
      84: aload_1
      85: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)J
      88: lstore_2
      89: getstatic     #47                 // Field java/lang/System.out:Ljava/io/PrintStream;
      92: lload_2
      93: invokevirtual #53                 // Method java/io/PrintStream.println:(J)V
      96: aload_1
      97: invokestatic  #35                 // Method main$part2:(Ljava/util/List;)J
     100: lstore_2
     101: getstatic     #47                 // Field java/lang/System.out:Ljava/io/PrintStream;
     104: lload_2
     105: invokevirtual #53                 // Method java/io/PrintStream.println:(J)V
     108: return

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

  private static final long main$parseMonkeyBusiness$lambda$1(java.lang.String, java.lang.String, long);
    Code:
       0: aload_0
       1: ldc           #70                 // String old
       3: invokestatic  #76                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
       6: ifeq          13
       9: lload_2
      10: goto          17
      13: aload_0
      14: invokestatic  #82                 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
      17: lstore        4
      19: aload_1
      20: astore        6
      22: aload         6
      24: ldc           #84                 // String *
      26: invokestatic  #76                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      29: ifeq          39
      32: lload_2
      33: lload         4
      35: lmul
      36: goto          86
      39: aload         6
      41: ldc           #86                 // String +
      43: invokestatic  #76                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      46: ifeq          56
      49: lload_2
      50: lload         4
      52: ladd
      53: goto          86
      56: new           #24                 // class java/lang/IllegalStateException
      59: dup
      60: new           #88                 // class java/lang/StringBuilder
      63: dup
      64: invokespecial #90                 // Method java/lang/StringBuilder."<init>":()V
      67: ldc           #92                 // String Unknown operation
      69: invokevirtual #96                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      72: aload_1
      73: invokevirtual #96                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      76: invokevirtual #97                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      79: invokevirtual #28                 // Method java/lang/Object.toString:()Ljava/lang/String;
      82: invokespecial #32                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      85: athrow
      86: lreturn

  private static final MonkeyBusiness main$parseMonkeyBusiness(java.util.List<java.lang.String>, boolean);
    Code:
       0: new           #110                // class java/util/ArrayList
       3: dup
       4: invokespecial #111                // Method java/util/ArrayList."<init>":()V
       7: checkcast     #61                 // class java/util/List
      10: astore_2
      11: iconst_1
      12: istore_3
      13: iload_3
      14: aload_0
      15: invokeinterface #115,  1          // InterfaceMethod java/util/List.size:()I
      20: if_icmpge     587
      23: getstatic     #120                // Field Day11.INSTANCE:LDay11;
      26: invokevirtual #124                // Method Day11.getMONKEY_LINE_ITEMS:()Lkotlin/text/Regex;
      29: aload_0
      30: iload_3
      31: iinc          3, 1
      34: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      39: checkcast     #130                // class java/lang/CharSequence
      42: invokevirtual #136                // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;
      45: dup
      46: invokestatic  #140                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      49: invokeinterface #146,  1          // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;
      54: invokevirtual #152                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
      57: invokeinterface #156,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
      62: iconst_1
      63: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      68: checkcast     #105                // class java/lang/String
      71: astore        4
      73: aload         4
      75: checkcast     #130                // class java/lang/CharSequence
      78: iconst_1
      79: anewarray     #105                // class java/lang/String
      82: astore        6
      84: aload         6
      86: iconst_0
      87: ldc           #158                // String ,
      89: aastore
      90: aload         6
      92: iconst_0
      93: iconst_0
      94: bipush        6
      96: aconst_null
      97: invokestatic  #164                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     100: checkcast     #166                // class java/lang/Iterable
     103: astore        6
     105: iconst_0
     106: istore        7
     108: aload         6
     110: astore        8
     112: new           #110                // class java/util/ArrayList
     115: dup
     116: aload         6
     118: bipush        10
     120: invokestatic  #172                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     123: invokespecial #175                // Method java/util/ArrayList."<init>":(I)V
     126: checkcast     #177                // class java/util/Collection
     129: astore        9
     131: iconst_0
     132: istore        10
     134: aload         8
     136: invokeinterface #181,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     141: astore        11
     143: aload         11
     145: invokeinterface #187,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     150: ifeq          200
     153: aload         11
     155: invokeinterface #191,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     160: astore        12
     162: aload         9
     164: aload         12
     166: checkcast     #105                // class java/lang/String
     169: astore        13
     171: astore        15
     173: iconst_0
     174: istore        14
     176: aload         13
     178: checkcast     #130                // class java/lang/CharSequence
     181: invokestatic  #195                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     184: invokevirtual #28                 // Method java/lang/Object.toString:()Ljava/lang/String;
     187: nop
     188: aload         15
     190: swap
     191: invokeinterface #199,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     196: pop
     197: goto          143
     200: aload         9
     202: checkcast     #61                 // class java/util/List
     205: nop
     206: checkcast     #166                // class java/lang/Iterable
     209: astore        6
     211: nop
     212: iconst_0
     213: istore        7
     215: aload         6
     217: astore        8
     219: new           #110                // class java/util/ArrayList
     222: dup
     223: aload         6
     225: bipush        10
     227: invokestatic  #172                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     230: invokespecial #175                // Method java/util/ArrayList."<init>":(I)V
     233: checkcast     #177                // class java/util/Collection
     236: astore        9
     238: iconst_0
     239: istore        10
     241: aload         8
     243: invokeinterface #181,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     248: astore        11
     250: aload         11
     252: invokeinterface #187,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     257: ifeq          307
     260: aload         11
     262: invokeinterface #191,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     267: astore        12
     269: aload         9
     271: aload         12
     273: checkcast     #105                // class java/lang/String
     276: astore        13
     278: astore        15
     280: iconst_0
     281: istore        14
     283: new           #201                // class Item
     286: dup
     287: aload         13
     289: invokestatic  #82                 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     292: invokespecial #203                // Method Item."<init>":(J)V
     295: aload         15
     297: swap
     298: invokeinterface #199,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     303: pop
     304: goto          250
     307: aload         9
     309: checkcast     #61                 // class java/util/List
     312: nop
     313: astore        5
     315: getstatic     #120                // Field Day11.INSTANCE:LDay11;
     318: invokevirtual #206                // Method Day11.getMONKEY_LINE_OPERATION:()Lkotlin/text/Regex;
     321: aload_0
     322: iload_3
     323: iinc          3, 1
     326: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     331: checkcast     #130                // class java/lang/CharSequence
     334: invokevirtual #136                // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;
     337: dup
     338: invokestatic  #140                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     341: invokeinterface #146,  1          // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;
     346: astore        6
     348: aload         6
     350: invokevirtual #152                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     353: invokeinterface #156,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     358: iconst_1
     359: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     364: checkcast     #105                // class java/lang/String
     367: astore        7
     369: aload         6
     371: invokevirtual #152                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     374: invokeinterface #156,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     379: iconst_2
     380: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     385: checkcast     #105                // class java/lang/String
     388: astore        8
     390: getstatic     #120                // Field Day11.INSTANCE:LDay11;
     393: invokevirtual #209                // Method Day11.getMONKEY_LINE_TEST:()Lkotlin/text/Regex;
     396: aload_0
     397: iload_3
     398: iinc          3, 1
     401: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     406: checkcast     #130                // class java/lang/CharSequence
     409: invokevirtual #136                // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;
     412: dup
     413: invokestatic  #140                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     416: invokeinterface #146,  1          // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;
     421: invokevirtual #152                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     424: invokeinterface #156,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     429: iconst_1
     430: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     435: checkcast     #105                // class java/lang/String
     438: astore        10
     440: getstatic     #120                // Field Day11.INSTANCE:LDay11;
     443: invokevirtual #212                // Method Day11.getMONKEY_LINE_THROW:()Lkotlin/text/Regex;
     446: aload_0
     447: iload_3
     448: iinc          3, 1
     451: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     456: checkcast     #130                // class java/lang/CharSequence
     459: invokevirtual #136                // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;
     462: dup
     463: invokestatic  #140                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     466: invokeinterface #146,  1          // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;
     471: invokevirtual #152                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     474: invokeinterface #156,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     479: iconst_2
     480: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     485: checkcast     #105                // class java/lang/String
     488: astore        12
     490: getstatic     #120                // Field Day11.INSTANCE:LDay11;
     493: invokevirtual #212                // Method Day11.getMONKEY_LINE_THROW:()Lkotlin/text/Regex;
     496: aload_0
     497: iload_3
     498: iinc          3, 1
     501: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     506: checkcast     #130                // class java/lang/CharSequence
     509: invokevirtual #136                // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;
     512: dup
     513: invokestatic  #140                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     516: invokeinterface #146,  1          // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;
     521: invokevirtual #152                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     524: invokeinterface #156,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     529: iconst_2
     530: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     535: checkcast     #105                // class java/lang/String
     538: astore        14
     540: aload_2
     541: new           #214                // class Monkey
     544: dup
     545: aload         5
     547: aload         8
     549: aload         7
     551: invokedynamic #232,  0            // InvokeDynamic #0:invoke:(Ljava/lang/String;Ljava/lang/String;)Lkotlin/jvm/functions/Function1;
     556: aload         10
     558: invokestatic  #238                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     561: aload         12
     563: invokestatic  #238                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     566: aload         14
     568: invokestatic  #238                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     571: iload_1
     572: invokespecial #241                // Method Monkey."<init>":(Ljava/util/List;Lkotlin/jvm/functions/Function1;IIIZ)V
     575: invokeinterface #242,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     580: pop
     581: iinc          3, 2
     584: goto          13
     587: new           #244                // class MonkeyBusiness
     590: dup
     591: aload_2
     592: invokespecial #247                // Method MonkeyBusiness."<init>":(Ljava/util/List;)V
     595: areturn

  static MonkeyBusiness main$parseMonkeyBusiness$default(java.util.List, boolean, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_1
       2: iand
       3: ifeq          8
       6: iconst_1
       7: istore_1
       8: aload_0
       9: iload_1
      10: invokestatic  #275                // Method main$parseMonkeyBusiness:(Ljava/util/List;Z)LMonkeyBusiness;
      13: areturn

  private static final long main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: iconst_0
       2: iconst_1
       3: aconst_null
       4: invokestatic  #278                // Method main$parseMonkeyBusiness$default:(Ljava/util/List;ZILjava/lang/Object;)LMonkeyBusiness;
       7: astore_1
       8: aload_1
       9: bipush        20
      11: invokevirtual #282                // Method MonkeyBusiness.process:(I)J
      14: lreturn

  private static final long main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: iconst_0
       2: invokestatic  #275                // Method main$parseMonkeyBusiness:(Ljava/util/List;Z)LMonkeyBusiness;
       5: astore_1
       6: aload_1
       7: sipush        10000
      10: invokevirtual #282                // Method MonkeyBusiness.process:(I)J
      13: lreturn
}