package day11

import java.io.File

fun main() {
    val data = parse("src/main/kotlin/day11/Day11.txt")

    val answer1 = part1(data)
    val answer2 = part2(data)

    println("🎄 Day 11 🎄")

    println()

    println("[Part 1]")
    println("Answer: $answer1")

    println()

    println("[Part 2]")
    println("Answer: $answer2")
}

private data class Monkey(
    val initialItems: List<Long>,
    val operation: (Long) -> Long,
    val condition: Long,
    val consequent: Int,
    val alternate: Int,
)

private fun List<String>.toMonkey(): Monkey {
    val lines = filter { it.startsWith("  ") }

    val initialItems = lines[0]
        .substringAfterLast(": ")
        .split(", ")
        .map(String::toLong)

    val (op, rhs) = lines[1]
        .split(" ")
        .takeLast(2)

    val operator = when (op) {
        "*" -> { a: Long, b: Long -> a * b }
        "+" -> { a: Long, b: Long -> a + b }
        else -> error("Invalid operator: '$op'")
    }

    val operation = if (rhs == "old") { n: Long ->
        operator(n, n)
    } else { n: Long ->
        operator(n, rhs.toLong())
    }

    val condition = lines[2]
        .substringAfterLast(" ")
        .toLong()

    val consequent = lines[3]
        .substringAfterLast(" ")
        .toInt()

    val alternate = lines[4]
        .substringAfterLast(" ")
        .toInt()

    return Monkey(
        initialItems, operation, condition, consequent, alternate
    )
}

@Suppress("SameParameterValue")
private fun parse(path: String): List<Monkey> =
    File(path)
        .readLines()
        .chunked(7)
        .map { it.toMonkey() }

private fun List<Monkey>.solve(rounds: Int, transform: (Long) -> Long): Long {
    val items = map { it.initialItems.toMutableList() }

    val interactions = Array(size) { 0L }
    repeat(rounds) {
        for ((i, monkey) in withIndex()) {
            for (item in items[i]) {
                val worry = transform(monkey.operation(item))
                val target = if (worry % monkey.condition == 0L) {
                    monkey.consequent
                } else {
                    monkey.alternate
                }

                items[target].add(worry)
            }

            interactions[i] += items[i].size.toLong()
            items[i].clear()
        }
    }

    return interactions
        .sortedArrayDescending()
        .take(2)
        .reduce(Long::times)
}

private fun part1(monkeys: List<Monkey>): Long {
    return monkeys.solve(rounds = 20) { it / 3L }
}

private fun part2(monkeys: List<Monkey>): Long {
    val test = monkeys
        .map(Monkey::condition)
        .reduce(Long::times)

    return monkeys.solve(rounds = 10_000) { it % test }
}

Compiled from "Day11.kt"
public final class day11.Day11Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String src/main/kotlin/day11/Day11.txt
       2: invokestatic  #12                 // Method parse:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #16                 // Method part1:(Ljava/util/List;)J
      10: lstore_1
      11: aload_0
      12: invokestatic  #19                 // Method part2:(Ljava/util/List;)J
      15: lstore_3
      16: ldc           #21                 // String 🎄 Day 11 🎄
      18: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      21: swap
      22: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      25: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      28: invokevirtual #35                 // Method java/io/PrintStream.println:()V
      31: ldc           #37                 // String [Part 1]
      33: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      36: swap
      37: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      40: new           #39                 // class java/lang/StringBuilder
      43: dup
      44: invokespecial #42                 // Method java/lang/StringBuilder."<init>":()V
      47: ldc           #44                 // String Answer:
      49: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      52: lload_1
      53: invokevirtual #51                 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
      56: invokevirtual #55                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      59: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      62: swap
      63: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      66: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      69: invokevirtual #35                 // Method java/io/PrintStream.println:()V
      72: ldc           #57                 // String [Part 2]
      74: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      77: swap
      78: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      81: new           #39                 // class java/lang/StringBuilder
      84: dup
      85: invokespecial #42                 // Method java/lang/StringBuilder."<init>":()V
      88: ldc           #44                 // String Answer:
      90: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      93: lload_3
      94: invokevirtual #51                 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
      97: invokevirtual #55                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     100: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
     103: swap
     104: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     107: return

  private static final day11.Monkey toMonkey(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #67                 // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: astore        4
      10: new           #69                 // class java/util/ArrayList
      13: dup
      14: invokespecial #70                 // Method java/util/ArrayList."<init>":()V
      17: checkcast     #72                 // class java/util/Collection
      20: astore        5
      22: iconst_0
      23: istore        6
      25: aload         4
      27: invokeinterface #76,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      32: astore        7
      34: aload         7
      36: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      41: ifeq          89
      44: aload         7
      46: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      51: astore        8
      53: aload         8
      55: checkcast     #88                 // class java/lang/String
      58: astore        9
      60: iconst_0
      61: istore        10
      63: aload         9
      65: ldc           #90                 // String
      67: iconst_0
      68: iconst_2
      69: aconst_null
      70: invokestatic  #96                 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
      73: ifeq          34
      76: aload         5
      78: aload         8
      80: invokeinterface #100,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      85: pop
      86: goto          34
      89: aload         5
      91: checkcast     #102                // class java/util/List
      94: nop
      95: astore_1
      96: aload_1
      97: iconst_0
      98: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     103: checkcast     #88                 // class java/lang/String
     106: ldc           #108                // String :
     108: aconst_null
     109: iconst_2
     110: aconst_null
     111: invokestatic  #112                // Method kotlin/text/StringsKt.substringAfterLast$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     114: checkcast     #114                // class java/lang/CharSequence
     117: iconst_1
     118: anewarray     #88                 // class java/lang/String
     121: astore_3
     122: aload_3
     123: iconst_0
     124: ldc           #116                // String ,
     126: aastore
     127: aload_3
     128: iconst_0
     129: iconst_0
     130: bipush        6
     132: aconst_null
     133: invokestatic  #120                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     136: checkcast     #67                 // class java/lang/Iterable
     139: astore_3
     140: nop
     141: iconst_0
     142: istore        4
     144: aload_3
     145: astore        5
     147: new           #69                 // class java/util/ArrayList
     150: dup
     151: aload_3
     152: bipush        10
     154: invokestatic  #126                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     157: invokespecial #129                // Method java/util/ArrayList."<init>":(I)V
     160: checkcast     #72                 // class java/util/Collection
     163: astore        6
     165: iconst_0
     166: istore        7
     168: aload         5
     170: invokeinterface #76,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     175: astore        8
     177: aload         8
     179: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     184: ifeq          231
     187: aload         8
     189: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     194: astore        9
     196: aload         6
     198: aload         9
     200: checkcast     #88                 // class java/lang/String
     203: astore        10
     205: astore        12
     207: iconst_0
     208: istore        11
     210: aload         10
     212: invokestatic  #135                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     215: nop
     216: invokestatic  #139                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     219: aload         12
     221: swap
     222: invokeinterface #100,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     227: pop
     228: goto          177
     231: aload         6
     233: checkcast     #102                // class java/util/List
     236: nop
     237: astore_2
     238: aload_1
     239: iconst_1
     240: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     245: checkcast     #114                // class java/lang/CharSequence
     248: iconst_1
     249: anewarray     #88                 // class java/lang/String
     252: astore        4
     254: aload         4
     256: iconst_0
     257: ldc           #141                // String
     259: aastore
     260: aload         4
     262: iconst_0
     263: iconst_0
     264: bipush        6
     266: aconst_null
     267: invokestatic  #120                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     270: iconst_2
     271: invokestatic  #145                // Method kotlin/collections/CollectionsKt.takeLast:(Ljava/util/List;I)Ljava/util/List;
     274: astore_3
     275: aload_3
     276: iconst_0
     277: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     282: checkcast     #88                 // class java/lang/String
     285: astore        4
     287: aload_3
     288: iconst_1
     289: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     294: checkcast     #88                 // class java/lang/String
     297: astore        5
     299: aload         4
     301: astore        7
     303: aload         7
     305: ldc           #147                // String *
     307: invokestatic  #153                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     310: ifeq          321
     313: invokedynamic #173,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;
     318: goto          375
     321: aload         7
     323: ldc           #175                // String +
     325: invokestatic  #153                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     328: ifeq          339
     331: invokedynamic #180,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function2;
     336: goto          375
     339: new           #182                // class java/lang/IllegalStateException
     342: dup
     343: new           #39                 // class java/lang/StringBuilder
     346: dup
     347: invokespecial #42                 // Method java/lang/StringBuilder."<init>":()V
     350: ldc           #184                // String Invalid operator: \'
     352: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     355: aload         4
     357: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     360: bipush        39
     362: invokevirtual #187                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     365: invokevirtual #55                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     368: invokevirtual #188                // Method java/lang/Object.toString:()Ljava/lang/String;
     371: invokespecial #191                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     374: athrow
     375: astore        6
     377: aload         5
     379: ldc           #193                // String old
     381: invokestatic  #153                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     384: ifeq          397
     387: aload         6
     389: invokedynamic #205,  0            // InvokeDynamic #2:invoke:(Lkotlin/jvm/functions/Function2;)Lkotlin/jvm/functions/Function1;
     394: goto          406
     397: aload         6
     399: aload         5
     401: invokedynamic #213,  0            // InvokeDynamic #3:invoke:(Lkotlin/jvm/functions/Function2;Ljava/lang/String;)Lkotlin/jvm/functions/Function1;
     406: astore        7
     408: nop
     409: aload_1
     410: iconst_2
     411: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     416: checkcast     #88                 // class java/lang/String
     419: ldc           #141                // String
     421: aconst_null
     422: iconst_2
     423: aconst_null
     424: invokestatic  #112                // Method kotlin/text/StringsKt.substringAfterLast$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     427: invokestatic  #135                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     430: lstore        8
     432: nop
     433: aload_1
     434: iconst_3
     435: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     440: checkcast     #88                 // class java/lang/String
     443: ldc           #141                // String
     445: aconst_null
     446: iconst_2
     447: aconst_null
     448: invokestatic  #112                // Method kotlin/text/StringsKt.substringAfterLast$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     451: invokestatic  #219                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     454: istore        10
     456: nop
     457: aload_1
     458: iconst_4
     459: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     464: checkcast     #88                 // class java/lang/String
     467: ldc           #141                // String
     469: aconst_null
     470: iconst_2
     471: aconst_null
     472: invokestatic  #112                // Method kotlin/text/StringsKt.substringAfterLast$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     475: invokestatic  #219                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     478: istore        11
     480: new           #221                // class day11/Monkey
     483: dup
     484: aload_2
     485: aload         7
     487: lload         8
     489: iload         10
     491: iload         11
     493: invokespecial #224                // Method day11/Monkey."<init>":(Ljava/util/List;Lkotlin/jvm/functions/Function1;JII)V
     496: areturn

  private static final java.util.List<day11.Monkey> parse(java.lang.String);
    Code:
       0: new           #263                // class java/io/File
       3: dup
       4: aload_0
       5: invokespecial #264                // Method java/io/File."<init>":(Ljava/lang/String;)V
       8: aconst_null
       9: iconst_1
      10: aconst_null
      11: invokestatic  #270                // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      14: checkcast     #67                 // class java/lang/Iterable
      17: bipush        7
      19: invokestatic  #274                // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;
      22: checkcast     #67                 // class java/lang/Iterable
      25: astore_1
      26: nop
      27: iconst_0
      28: istore_2
      29: aload_1
      30: astore_3
      31: new           #69                 // class java/util/ArrayList
      34: dup
      35: aload_1
      36: bipush        10
      38: invokestatic  #126                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      41: invokespecial #129                // Method java/util/ArrayList."<init>":(I)V
      44: checkcast     #72                 // class java/util/Collection
      47: astore        4
      49: iconst_0
      50: istore        5
      52: aload_3
      53: invokeinterface #76,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      58: astore        6
      60: aload         6
      62: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      67: ifeq          110
      70: aload         6
      72: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      77: astore        7
      79: aload         4
      81: aload         7
      83: checkcast     #102                // class java/util/List
      86: astore        8
      88: astore        10
      90: iconst_0
      91: istore        9
      93: aload         8
      95: invokestatic  #276                // Method toMonkey:(Ljava/util/List;)Lday11/Monkey;
      98: aload         10
     100: swap
     101: invokeinterface #100,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     106: pop
     107: goto          60
     110: aload         4
     112: checkcast     #102                // class java/util/List
     115: nop
     116: areturn

  private static final long solve(java.util.List<day11.Monkey>, int, kotlin.jvm.functions.Function1<? super java.lang.Long, java.lang.Long>);
    Code:
       0: aload_0
       1: checkcast     #67                 // class java/lang/Iterable
       4: astore        4
       6: iconst_0
       7: istore        5
       9: aload         4
      11: astore        6
      13: new           #69                 // class java/util/ArrayList
      16: dup
      17: aload         4
      19: bipush        10
      21: invokestatic  #126                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      24: invokespecial #129                // Method java/util/ArrayList."<init>":(I)V
      27: checkcast     #72                 // class java/util/Collection
      30: astore        7
      32: iconst_0
      33: istore        8
      35: aload         6
      37: invokeinterface #76,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        9
      44: aload         9
      46: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          100
      54: aload         9
      56: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        10
      63: aload         7
      65: aload         10
      67: checkcast     #221                // class day11/Monkey
      70: astore        11
      72: astore        18
      74: iconst_0
      75: istore        12
      77: aload         11
      79: invokevirtual #285                // Method day11/Monkey.getInitialItems:()Ljava/util/List;
      82: checkcast     #72                 // class java/util/Collection
      85: invokestatic  #289                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
      88: aload         18
      90: swap
      91: invokeinterface #100,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      96: pop
      97: goto          44
     100: aload         7
     102: checkcast     #102                // class java/util/List
     105: nop
     106: astore_3
     107: iconst_0
     108: istore        5
     110: aload_0
     111: invokeinterface #293,  1          // InterfaceMethod java/util/List.size:()I
     116: istore        6
     118: iload         6
     120: anewarray     #131                // class java/lang/Long
     123: astore        7
     125: iload         5
     127: iload         6
     129: if_icmpge     151
     132: iload         5
     134: istore        8
     136: aload         7
     138: iload         8
     140: lconst_0
     141: invokestatic  #139                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     144: aastore
     145: iinc          5, 1
     148: goto          125
     151: aload         7
     153: astore        4
     155: iconst_0
     156: istore        5
     158: iload         5
     160: iload_1
     161: if_icmpge     402
     164: iload         5
     166: istore        6
     168: iconst_0
     169: istore        7
     171: aload_0
     172: checkcast     #67                 // class java/lang/Iterable
     175: invokeinterface #76,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     180: astore        8
     182: iconst_0
     183: istore        9
     185: aload         8
     187: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     192: ifeq          395
     195: iload         9
     197: istore        10
     199: iload         9
     201: iconst_1
     202: iadd
     203: istore        9
     205: aload         8
     207: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     212: checkcast     #221                // class day11/Monkey
     215: astore        11
     217: aload_3
     218: iload         10
     220: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     225: checkcast     #102                // class java/util/List
     228: invokeinterface #294,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     233: astore        12
     235: aload         12
     237: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     242: ifeq          342
     245: aload         12
     247: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     252: checkcast     #296                // class java/lang/Number
     255: invokevirtual #300                // Method java/lang/Number.longValue:()J
     258: lstore        13
     260: aload_2
     261: aload         11
     263: invokevirtual #304                // Method day11/Monkey.getOperation:()Lkotlin/jvm/functions/Function1;
     266: lload         13
     268: invokestatic  #139                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     271: invokeinterface #306,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     276: invokeinterface #306,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     281: checkcast     #296                // class java/lang/Number
     284: invokevirtual #300                // Method java/lang/Number.longValue:()J
     287: lstore        15
     289: lload         15
     291: aload         11
     293: invokevirtual #309                // Method day11/Monkey.getCondition:()J
     296: lrem
     297: lconst_0
     298: lcmp
     299: ifne          310
     302: aload         11
     304: invokevirtual #312                // Method day11/Monkey.getConsequent:()I
     307: goto          315
     310: aload         11
     312: invokevirtual #315                // Method day11/Monkey.getAlternate:()I
     315: istore        17
     317: aload_3
     318: iload         17
     320: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     325: checkcast     #102                // class java/util/List
     328: lload         15
     330: invokestatic  #139                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     333: invokeinterface #316,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     338: pop
     339: goto          235
     342: aload         4
     344: iload         10
     346: aload         4
     348: iload         10
     350: aaload
     351: invokevirtual #317                // Method java/lang/Long.longValue:()J
     354: aload_3
     355: iload         10
     357: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     362: checkcast     #102                // class java/util/List
     365: invokeinterface #293,  1          // InterfaceMethod java/util/List.size:()I
     370: i2l
     371: ladd
     372: invokestatic  #139                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     375: aastore
     376: aload_3
     377: iload         10
     379: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     384: checkcast     #102                // class java/util/List
     387: invokeinterface #320,  1          // InterfaceMethod java/util/List.clear:()V
     392: goto          185
     395: nop
     396: iinc          5, 1
     399: goto          158
     402: aload         4
     404: checkcast     #322                // class "[Ljava/lang/Comparable;"
     407: invokestatic  #328                // Method kotlin/collections/ArraysKt.sortedArrayDescending:([Ljava/lang/Comparable;)[Ljava/lang/Comparable;
     410: iconst_2
     411: invokestatic  #332                // Method kotlin/collections/ArraysKt.take:([Ljava/lang/Object;I)Ljava/util/List;
     414: checkcast     #67                 // class java/lang/Iterable
     417: astore        5
     419: nop
     420: iconst_0
     421: istore        6
     423: aload         5
     425: invokeinterface #76,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     430: astore        7
     432: aload         7
     434: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     439: ifne          453
     442: new           #334                // class java/lang/UnsupportedOperationException
     445: dup
     446: ldc_w         #336                // String Empty collection can\'t be reduced.
     449: invokespecial #337                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     452: athrow
     453: aload         7
     455: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     460: astore        8
     462: aload         7
     464: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     469: ifeq          513
     472: aload         8
     474: aload         7
     476: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     481: checkcast     #296                // class java/lang/Number
     484: invokevirtual #300                // Method java/lang/Number.longValue:()J
     487: lstore        9
     489: checkcast     #296                // class java/lang/Number
     492: invokevirtual #300                // Method java/lang/Number.longValue:()J
     495: lstore        11
     497: iconst_0
     498: istore        13
     500: lload         11
     502: lload         9
     504: lmul
     505: invokestatic  #139                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     508: astore        8
     510: goto          462
     513: aload         8
     515: checkcast     #296                // class java/lang/Number
     518: invokevirtual #300                // Method java/lang/Number.longValue:()J
     521: lreturn

  private static final long part1(java.util.List<day11.Monkey>);
    Code:
       0: aload_0
       1: bipush        20
       3: invokedynamic #367,  0            // InvokeDynamic #4:invoke:()Lkotlin/jvm/functions/Function1;
       8: invokestatic  #369                // Method solve:(Ljava/util/List;ILkotlin/jvm/functions/Function1;)J
      11: lreturn

  private static final long part2(java.util.List<day11.Monkey>);
    Code:
       0: aload_0
       1: checkcast     #67                 // class java/lang/Iterable
       4: astore_3
       5: nop
       6: iconst_0
       7: istore        4
       9: aload_3
      10: astore        5
      12: new           #69                 // class java/util/ArrayList
      15: dup
      16: aload_3
      17: bipush        10
      19: invokestatic  #126                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      22: invokespecial #129                // Method java/util/ArrayList."<init>":(I)V
      25: checkcast     #72                 // class java/util/Collection
      28: astore        6
      30: iconst_0
      31: istore        7
      33: aload         5
      35: invokeinterface #76,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      40: astore        8
      42: aload         8
      44: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      49: ifeq          95
      52: aload         8
      54: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      59: astore        9
      61: aload         6
      63: aload         9
      65: checkcast     #221                // class day11/Monkey
      68: astore        10
      70: astore        12
      72: iconst_0
      73: istore        11
      75: aload         10
      77: invokevirtual #309                // Method day11/Monkey.getCondition:()J
      80: invokestatic  #139                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      83: aload         12
      85: swap
      86: invokeinterface #100,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      91: pop
      92: goto          42
      95: aload         6
      97: checkcast     #102                // class java/util/List
     100: nop
     101: checkcast     #67                 // class java/lang/Iterable
     104: astore_3
     105: nop
     106: iconst_0
     107: istore        4
     109: aload_3
     110: invokeinterface #76,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     115: astore        5
     117: aload         5
     119: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     124: ifne          138
     127: new           #334                // class java/lang/UnsupportedOperationException
     130: dup
     131: ldc_w         #336                // String Empty collection can\'t be reduced.
     134: invokespecial #337                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     137: athrow
     138: aload         5
     140: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     145: astore        6
     147: aload         5
     149: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     154: ifeq          198
     157: aload         6
     159: aload         5
     161: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     166: checkcast     #296                // class java/lang/Number
     169: invokevirtual #300                // Method java/lang/Number.longValue:()J
     172: lstore        7
     174: checkcast     #296                // class java/lang/Number
     177: invokevirtual #300                // Method java/lang/Number.longValue:()J
     180: lstore        9
     182: iconst_0
     183: istore        11
     185: lload         9
     187: lload         7
     189: lmul
     190: invokestatic  #139                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     193: astore        6
     195: goto          147
     198: aload         6
     200: checkcast     #296                // class java/lang/Number
     203: invokevirtual #300                // Method java/lang/Number.longValue:()J
     206: lstore_1
     207: aload_0
     208: sipush        10000
     211: lload_1
     212: invokedynamic #377,  0            // InvokeDynamic #5:invoke:(J)Lkotlin/jvm/functions/Function1;
     217: invokestatic  #369                // Method solve:(Ljava/util/List;ILkotlin/jvm/functions/Function1;)J
     220: lreturn

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

  private static final long toMonkey$lambda$1(long, long);
    Code:
       0: lload_0
       1: lload_2
       2: lmul
       3: lreturn

  private static final long toMonkey$lambda$2(long, long);
    Code:
       0: lload_0
       1: lload_2
       2: ladd
       3: lreturn

  private static final long toMonkey$lambda$3(kotlin.jvm.functions.Function2, long);
    Code:
       0: aload_0
       1: lload_1
       2: invokestatic  #139                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
       5: lload_1
       6: invokestatic  #139                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
       9: invokeinterface #389,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      14: checkcast     #296                // class java/lang/Number
      17: invokevirtual #300                // Method java/lang/Number.longValue:()J
      20: lreturn

  private static final long toMonkey$lambda$4(kotlin.jvm.functions.Function2, java.lang.String, long);
    Code:
       0: aload_0
       1: lload_2
       2: invokestatic  #139                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
       5: aload_1
       6: invokestatic  #135                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
       9: invokestatic  #139                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      12: invokeinterface #389,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      17: checkcast     #296                // class java/lang/Number
      20: invokevirtual #300                // Method java/lang/Number.longValue:()J
      23: lreturn

  private static final long part1$lambda$9(long);
    Code:
       0: lload_0
       1: ldc2_w        #393                // long 3l
       4: ldiv
       5: lreturn

  private static final long part2$lambda$12(long, long);
    Code:
       0: lload_2
       1: lload_0
       2: lrem
       3: lreturn
}


package day10

import java.io.File

fun main() {
    val data = parse("src/main/kotlin/day10/Day10.txt")

    val answer1 = part1(data)
    val answer2 = part2(data)

    println("🎄 Day 10 🎄")

    println()

    println("[Part 1]")
    println("Answer: $answer1")

    println()

    println("[Part 2]")
    println("Answer:\n$answer2")
}

@Suppress("SameParameterValue")
private fun parse(path: String): List<String> =
    File(path).readLines()

private fun List<String>.execute(onCycle: (x: Int, cycle: Int) -> Unit) {
    var x = 1
    var cycle = 0
    for (instruction in this) {
        val tokens = instruction.split(" ")
        when (tokens[0]) {
            "noop" -> onCycle(x, ++cycle)
            "addx" -> {
                onCycle(x, ++cycle)
                onCycle(x, ++cycle)
                x += tokens[1].toInt()
            }
        }
    }
}

private fun part1(program: List<String>): Int {
    var result = 0
    program.execute { x, cycle ->
        if ((cycle - 20) % 40 == 0) {
            result += x * cycle;
        }
    }
    return result
}

private fun part2(program: List<String>): String {
    val (w, h) = 40 to 6
    val crt = Array(h) { Array(w) { '.' } }

    program.execute { x, cycle ->
        val col = (cycle - 1) % w
        if (x - 1 <= col && col <= x + 1) {
            val row = (cycle - 1) / w
            crt[row][col] = '#'
        }
    }

    return crt.asIterable()
        .joinToString(separator = "\n") { line ->
            line.joinToString(separator = "")
        }
}

Compiled from "Day10.kt"
public final class day10.Day10Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String src/main/kotlin/day10/Day10.txt
       2: invokestatic  #12                 // Method parse:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #16                 // Method part1:(Ljava/util/List;)I
      10: istore_1
      11: aload_0
      12: invokestatic  #20                 // Method part2:(Ljava/util/List;)Ljava/lang/String;
      15: astore_2
      16: ldc           #22                 // String 🎄 Day 10 🎄
      18: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
      21: swap
      22: invokevirtual #34                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      25: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
      28: invokevirtual #36                 // Method java/io/PrintStream.println:()V
      31: ldc           #38                 // String [Part 1]
      33: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
      36: swap
      37: invokevirtual #34                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      40: new           #40                 // class java/lang/StringBuilder
      43: dup
      44: invokespecial #43                 // Method java/lang/StringBuilder."<init>":()V
      47: ldc           #45                 // String Answer:
      49: invokevirtual #49                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      52: iload_1
      53: invokevirtual #52                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      56: invokevirtual #56                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      59: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
      62: swap
      63: invokevirtual #34                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      66: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
      69: invokevirtual #36                 // Method java/io/PrintStream.println:()V
      72: ldc           #58                 // String [Part 2]
      74: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
      77: swap
      78: invokevirtual #34                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      81: new           #40                 // class java/lang/StringBuilder
      84: dup
      85: invokespecial #43                 // Method java/lang/StringBuilder."<init>":()V
      88: ldc           #60                 // String Answer:\n
      90: invokevirtual #49                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      93: aload_2
      94: invokevirtual #49                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      97: invokevirtual #56                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     100: getstatic     #28                 // Field java/lang/System.out:Ljava/io/PrintStream;
     103: swap
     104: invokevirtual #34                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     107: return

  private static final java.util.List<java.lang.String> parse(java.lang.String);
    Code:
       0: new           #69                 // class java/io/File
       3: dup
       4: aload_0
       5: invokespecial #72                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       8: aconst_null
       9: iconst_1
      10: aconst_null
      11: invokestatic  #78                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      14: areturn

  private static final void execute(java.util.List<java.lang.String>, kotlin.jvm.functions.Function2<? super java.lang.Integer, ? super java.lang.Integer, kotlin.Unit>);
    Code:
       0: iconst_1
       1: istore_2
       2: iconst_0
       3: istore_3
       4: aload_0
       5: invokeinterface #88,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      10: astore        4
      12: aload         4
      14: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      19: ifeq          173
      22: aload         4
      24: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      29: checkcast     #100                // class java/lang/String
      32: astore        5
      34: aload         5
      36: checkcast     #102                // class java/lang/CharSequence
      39: iconst_1
      40: anewarray     #100                // class java/lang/String
      43: astore        7
      45: aload         7
      47: iconst_0
      48: ldc           #104                // String
      50: aastore
      51: aload         7
      53: iconst_0
      54: iconst_0
      55: bipush        6
      57: aconst_null
      58: invokestatic  #110                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      61: astore        6
      63: aload         6
      65: iconst_0
      66: invokeinterface #114,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      71: checkcast     #100                // class java/lang/String
      74: astore        7
      76: aload         7
      78: ldc           #116                // String noop
      80: invokestatic  #122                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      83: ifeq          107
      86: aload_1
      87: iload_2
      88: invokestatic  #128                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      91: iinc          3, 1
      94: iload_3
      95: invokestatic  #128                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      98: invokeinterface #134,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     103: pop
     104: goto          12
     107: aload         7
     109: ldc           #136                // String addx
     111: invokestatic  #122                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     114: ifeq          12
     117: aload_1
     118: iload_2
     119: invokestatic  #128                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     122: iinc          3, 1
     125: iload_3
     126: invokestatic  #128                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     129: invokeinterface #134,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     134: pop
     135: aload_1
     136: iload_2
     137: invokestatic  #128                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     140: iinc          3, 1
     143: iload_3
     144: invokestatic  #128                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     147: invokeinterface #134,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     152: pop
     153: iload_2
     154: aload         6
     156: iconst_1
     157: invokeinterface #114,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     162: checkcast     #100                // class java/lang/String
     165: invokestatic  #140                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     168: iadd
     169: istore_2
     170: goto          12
     173: return

  private static final int part1(java.util.List<java.lang.String>);
    Code:
       0: new           #150                // class kotlin/jvm/internal/Ref$IntRef
       3: dup
       4: invokespecial #151                // Method kotlin/jvm/internal/Ref$IntRef."<init>":()V
       7: astore_1
       8: aload_0
       9: aload_1
      10: invokedynamic #169,  0            // InvokeDynamic #0:invoke:(Lkotlin/jvm/internal/Ref$IntRef;)Lkotlin/jvm/functions/Function2;
      15: invokestatic  #171                // Method execute:(Ljava/util/List;Lkotlin/jvm/functions/Function2;)V
      18: aload_1
      19: getfield      #174                // Field kotlin/jvm/internal/Ref$IntRef.element:I
      22: ireturn

  private static final java.lang.String part2(java.util.List<java.lang.String>);
    Code:
       0: bipush        40
       2: invokestatic  #128                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
       5: bipush        6
       7: invokestatic  #128                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      10: invokestatic  #184                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      13: astore_1
      14: aload_1
      15: invokevirtual #189                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      18: checkcast     #191                // class java/lang/Number
      21: invokevirtual #195                // Method java/lang/Number.intValue:()I
      24: istore_2
      25: aload_1
      26: invokevirtual #198                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      29: checkcast     #191                // class java/lang/Number
      32: invokevirtual #195                // Method java/lang/Number.intValue:()I
      35: istore_3
      36: iconst_0
      37: istore        5
      39: iload_3
      40: anewarray     #200                // class "[Ljava/lang/Character;"
      43: astore        6
      45: iload         5
      47: iload_3
      48: if_icmpge     111
      51: iload         5
      53: istore        7
      55: aload         6
      57: iload         7
      59: iconst_0
      60: istore        8
      62: iload_2
      63: anewarray     #202                // class java/lang/Character
      66: astore        9
      68: istore        12
      70: astore        11
      72: iload         8
      74: iload_2
      75: if_icmpge     98
      78: iload         8
      80: istore        10
      82: aload         9
      84: iload         10
      86: bipush        46
      88: invokestatic  #205                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      91: aastore
      92: iinc          8, 1
      95: goto          72
      98: aload         11
     100: iload         12
     102: aload         9
     104: aastore
     105: iinc          5, 1
     108: goto          45
     111: aload         6
     113: astore        4
     115: aload_0
     116: iload_2
     117: aload         4
     119: invokedynamic #213,  0            // InvokeDynamic #1:invoke:(I[[Ljava/lang/Character;)Lkotlin/jvm/functions/Function2;
     124: invokestatic  #171                // Method execute:(Ljava/util/List;Lkotlin/jvm/functions/Function2;)V
     127: aload         4
     129: checkcast     #215                // class "[Ljava/lang/Object;"
     132: invokestatic  #221                // Method kotlin/collections/ArraysKt.asIterable:([Ljava/lang/Object;)Ljava/lang/Iterable;
     135: ldc           #223                // String \n
     137: checkcast     #102                // class java/lang/CharSequence
     140: aconst_null
     141: aconst_null
     142: iconst_0
     143: aconst_null
     144: invokedynamic #234,  0            // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;
     149: bipush        30
     151: aconst_null
     152: invokestatic  #240                // 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;
     155: areturn

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

  private static final kotlin.Unit part1$lambda$0(kotlin.jvm.internal.Ref$IntRef, int, int);
    Code:
       0: iload_2
       1: bipush        20
       3: isub
       4: bipush        40
       6: irem
       7: ifne          22
      10: aload_0
      11: aload_0
      12: getfield      #174                // Field kotlin/jvm/internal/Ref$IntRef.element:I
      15: iload_1
      16: iload_2
      17: imul
      18: iadd
      19: putfield      #174                // Field kotlin/jvm/internal/Ref$IntRef.element:I
      22: getstatic     #256                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      25: areturn

  private static final kotlin.Unit part2$lambda$1(int, java.lang.Character[][], int, int);
    Code:
       0: iload_3
       1: iconst_1
       2: isub
       3: iload_0
       4: irem
       5: istore        4
       7: iload_2
       8: iconst_1
       9: isub
      10: iload         4
      12: if_icmpgt     42
      15: iload         4
      17: iload_2
      18: iconst_1
      19: iadd
      20: if_icmpgt     42
      23: iload_3
      24: iconst_1
      25: isub
      26: iload_0
      27: idiv
      28: istore        5
      30: aload_1
      31: iload         5
      33: aaload
      34: iload         4
      36: bipush        35
      38: invokestatic  #205                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      41: aastore
      42: getstatic     #256                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      45: areturn

  private static final java.lang.CharSequence part2$lambda$2(java.lang.Character[]);
    Code:
       0: aload_0
       1: ldc_w         #263                // String line
       4: invokestatic  #267                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: ldc_w         #269                // String
      11: checkcast     #102                // class java/lang/CharSequence
      14: aconst_null
      15: aconst_null
      16: iconst_0
      17: aconst_null
      18: aconst_null
      19: bipush        62
      21: aconst_null
      22: invokestatic  #272                // Method kotlin/collections/ArraysKt.joinToString$default:([Ljava/lang/Object;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
      25: checkcast     #102                // class java/lang/CharSequence
      28: areturn
}