import java.io.InputStream

data class Monkey(
    val items: MutableList<Long>,
    val operation: (Long) -> Long,
    val test: Long,
    val trueReceiver: Int,
    val falseReceiver: Int,
    var inspectionCount: Long = 0
)

class Day11 {
    companion object {
        private fun createOperation(operator: String, other: Long?): (Long) -> Long {
            return when (operator) {
                "+" -> { old: Long -> old + (other ?: old) }
                else -> { old: Long -> old * (other ?: old) }
            }
        }

        private fun privateProcess(input: InputStream?, rounds: Int, worryDivider: Long): Long {
            if (input == null) {
                throw Exception("Input missing")
            }

            val numRegex = "\\d+".toRegex()
            val operatorRegex = "[+*]".toRegex()

            val monkeys = input.bufferedReader().useLines { lines ->
                lines.chunked(7)
                    .map { monkeyDesc ->
                        val items = numRegex.findAll(monkeyDesc[1]).map { it.value.toLong() }.toMutableList()

                        //println(monkeyDesc)

                        Monkey(
                            items,
                            createOperation(
                                operatorRegex.find(monkeyDesc[2])!!.value,
                                numRegex.find(monkeyDesc[2])?.value?.toLong()
                            ),
                            numRegex.find(monkeyDesc[3])!!.value.toLong(),
                            numRegex.find(monkeyDesc[4])!!.value.toInt(),
                            numRegex.find(monkeyDesc[5])!!.value.toInt(),
                        )
                    }.toList()
            }

            val mod = monkeys.map { it.test }.fold(1L) { acc, it -> acc * it }

            for (i in 1..rounds) {
                for (monkey in monkeys) {
                    monkey.items.map {
                        monkey.operation(it) / worryDivider
                    }.forEach {
                        monkey.inspectionCount++
                        val reveiver =
                            if ((it) % monkey.test == 0L) monkey.trueReceiver else monkey.falseReceiver
                        val converted = it % mod
                        monkeys[reveiver].items.add(converted)
                    }
                    monkey.items.clear()
                }

//                if (i == 1 || i % 1000 == 0) {
//                    monkeys.forEachIndexed { index, it -> println("$index: ${it.items}, ${it.inspectionCount}") }
//                    println()
//                }
            }

            return monkeys.sortedByDescending { it.inspectionCount }.take(2).map { it.inspectionCount }
                .fold(1L) { acc, count -> acc * count }
        }

        fun process(input: InputStream?): Long {
            return privateProcess(input, 20, 3L)
        }

        fun process2(input: InputStream?): Long {
            return privateProcess(input, 10_000, 1L)
        }
    }

}

Compiled from "Comparisons.kt"
public final class Day11$Companion$privateProcess$$inlined$sortedByDescending$1<T> implements java.util.Comparator {
  public Day11$Companion$privateProcess$$inlined$sortedByDescending$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

  public final int compare(T, T);
    Code:
       0: aload_2
       1: checkcast     #23                 // class Monkey
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method Monkey.getInspectionCount:()J
      12: invokestatic  #33                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      15: checkcast     #35                 // class java/lang/Comparable
      18: aload_1
      19: checkcast     #23                 // class Monkey
      22: astore_3
      23: astore        5
      25: iconst_0
      26: istore        4
      28: aload_3
      29: invokevirtual #27                 // Method Monkey.getInspectionCount:()J
      32: invokestatic  #33                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      35: aload         5
      37: swap
      38: checkcast     #35                 // class java/lang/Comparable
      41: invokestatic  #41                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      44: ireturn
}

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

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

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

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

  private final kotlin.jvm.functions.Function1<java.lang.Long, java.lang.Long> createOperation(java.lang.String, java.lang.Long);
    Code:
       0: aload_1
       1: ldc           #15                 // String +
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
       6: ifeq          18
       9: aload_2
      10: invokedynamic #41,  0             // InvokeDynamic #0:invoke:(Ljava/lang/Long;)Lkotlin/jvm/functions/Function1;
      15: goto          24
      18: aload_2
      19: invokedynamic #46,  0             // InvokeDynamic #1:invoke:(Ljava/lang/Long;)Lkotlin/jvm/functions/Function1;
      24: areturn

  private final long privateProcess(java.io.InputStream, int, long);
    Code:
       0: aload_1
       1: ifnonnull     14
       4: new           #58                 // class java/lang/Exception
       7: dup
       8: ldc           #60                 // String Input missing
      10: invokespecial #63                 // Method java/lang/Exception."<init>":(Ljava/lang/String;)V
      13: athrow
      14: new           #65                 // class kotlin/text/Regex
      17: dup
      18: ldc           #67                 // String \\d+
      20: invokespecial #68                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      23: astore        5
      25: new           #65                 // class kotlin/text/Regex
      28: dup
      29: ldc           #70                 // String [+*]
      31: invokespecial #68                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      34: astore        6
      36: aload_1
      37: astore        8
      39: getstatic     #76                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      42: astore        9
      44: new           #78                 // class java/io/InputStreamReader
      47: dup
      48: aload         8
      50: aload         9
      52: invokespecial #81                 // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
      55: checkcast     #83                 // class java/io/Reader
      58: astore        10
      60: sipush        8192
      63: istore        11
      65: aload         10
      67: instanceof    #85                 // class java/io/BufferedReader
      70: ifeq          81
      73: aload         10
      75: checkcast     #85                 // class java/io/BufferedReader
      78: goto          92
      81: new           #85                 // class java/io/BufferedReader
      84: dup
      85: aload         10
      87: iload         11
      89: invokespecial #88                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
      92: checkcast     #83                 // class java/io/Reader
      95: astore        8
      97: nop
      98: iconst_0
      99: istore        9
     101: aload         8
     103: astore        10
     105: sipush        8192
     108: istore        11
     110: aload         10
     112: instanceof    #85                 // class java/io/BufferedReader
     115: ifeq          126
     118: aload         10
     120: checkcast     #85                 // class java/io/BufferedReader
     123: goto          137
     126: new           #85                 // class java/io/BufferedReader
     129: dup
     130: aload         10
     132: iload         11
     134: invokespecial #88                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
     137: checkcast     #90                 // class java/io/Closeable
     140: astore        10
     142: aconst_null
     143: astore        11
     145: nop
     146: aload         10
     148: checkcast     #85                 // class java/io/BufferedReader
     151: astore        13
     153: iconst_0
     154: istore        14
     156: aload         13
     158: invokestatic  #96                 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;
     161: astore        16
     163: iconst_0
     164: istore        17
     166: aload         16
     168: bipush        7
     170: invokestatic  #102                // Method kotlin/sequences/SequencesKt.chunked:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;
     173: aload         5
     175: aload         6
     177: invokedynamic #112,  0            // InvokeDynamic #2:invoke:(Lkotlin/text/Regex;Lkotlin/text/Regex;)Lkotlin/jvm/functions/Function1;
     182: invokestatic  #116                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     185: invokestatic  #120                // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
     188: astore        13
     190: aload         10
     192: aload         11
     194: invokestatic  #126                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     197: aload         13
     199: goto          223
     202: astore        14
     204: aload         14
     206: astore        11
     208: aload         14
     210: athrow
     211: astore        14
     213: aload         10
     215: aload         11
     217: invokestatic  #126                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     220: aload         14
     222: athrow
     223: nop
     224: astore        7
     226: aload         7
     228: checkcast     #128                // class java/lang/Iterable
     231: astore        10
     233: iconst_0
     234: istore        11
     236: aload         10
     238: astore        13
     240: new           #130                // class java/util/ArrayList
     243: dup
     244: aload         10
     246: bipush        10
     248: invokestatic  #136                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     251: invokespecial #139                // Method java/util/ArrayList."<init>":(I)V
     254: checkcast     #141                // class java/util/Collection
     257: astore        14
     259: iconst_0
     260: istore        16
     262: aload         13
     264: invokeinterface #145,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     269: astore        17
     271: aload         17
     273: invokeinterface #151,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     278: ifeq          324
     281: aload         17
     283: invokeinterface #155,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     288: astore        18
     290: aload         14
     292: aload         18
     294: checkcast     #157                // class Monkey
     297: astore        19
     299: astore        27
     301: iconst_0
     302: istore        20
     304: aload         19
     306: invokevirtual #161                // Method Monkey.getTest:()J
     309: invokestatic  #167                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     312: aload         27
     314: swap
     315: invokeinterface #171,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     320: pop
     321: goto          271
     324: aload         14
     326: checkcast     #173                // class java/util/List
     329: nop
     330: checkcast     #128                // class java/lang/Iterable
     333: astore        10
     335: lconst_1
     336: lstore        11
     338: iconst_0
     339: istore        13
     341: lload         11
     343: lstore        14
     345: aload         10
     347: invokeinterface #145,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     352: astore        16
     354: aload         16
     356: invokeinterface #151,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     361: ifeq          400
     364: aload         16
     366: invokeinterface #155,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     371: astore        17
     373: lload         14
     375: aload         17
     377: checkcast     #175                // class java/lang/Number
     380: invokevirtual #178                // Method java/lang/Number.longValue:()J
     383: lstore        18
     385: lstore        20
     387: iconst_0
     388: istore        22
     390: lload         20
     392: lload         18
     394: lmul
     395: lstore        14
     397: goto          354
     400: lload         14
     402: lstore        8
     404: iconst_1
     405: istore        10
     407: iload         10
     409: iload_2
     410: if_icmpgt     730
     413: aload         7
     415: invokeinterface #179,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     420: astore        11
     422: aload         11
     424: invokeinterface #151,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     429: ifeq          718
     432: aload         11
     434: invokeinterface #155,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     439: checkcast     #157                // class Monkey
     442: astore        13
     444: aload         13
     446: invokevirtual #183                // Method Monkey.getItems:()Ljava/util/List;
     449: checkcast     #128                // class java/lang/Iterable
     452: astore        14
     454: iconst_0
     455: istore        16
     457: aload         14
     459: astore        17
     461: new           #130                // class java/util/ArrayList
     464: dup
     465: aload         14
     467: bipush        10
     469: invokestatic  #136                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     472: invokespecial #139                // Method java/util/ArrayList."<init>":(I)V
     475: checkcast     #141                // class java/util/Collection
     478: astore        18
     480: iconst_0
     481: istore        19
     483: aload         17
     485: invokeinterface #145,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     490: astore        20
     492: aload         20
     494: invokeinterface #151,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     499: ifeq          566
     502: aload         20
     504: invokeinterface #155,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     509: astore        21
     511: aload         18
     513: aload         21
     515: checkcast     #175                // class java/lang/Number
     518: invokevirtual #178                // Method java/lang/Number.longValue:()J
     521: lstore        22
     523: astore        27
     525: iconst_0
     526: istore        24
     528: aload         13
     530: invokevirtual #187                // Method Monkey.getOperation:()Lkotlin/jvm/functions/Function1;
     533: lload         22
     535: invokestatic  #167                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     538: invokeinterface #189,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     543: checkcast     #175                // class java/lang/Number
     546: invokevirtual #178                // Method java/lang/Number.longValue:()J
     549: lload_3
     550: ldiv
     551: invokestatic  #167                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     554: aload         27
     556: swap
     557: invokeinterface #171,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     562: pop
     563: goto          492
     566: aload         18
     568: checkcast     #173                // class java/util/List
     571: nop
     572: checkcast     #128                // class java/lang/Iterable
     575: astore        14
     577: nop
     578: iconst_0
     579: istore        16
     581: aload         14
     583: invokeinterface #145,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     588: astore        17
     590: aload         17
     592: invokeinterface #151,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     597: ifeq          704
     600: aload         17
     602: invokeinterface #155,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     607: astore        18
     609: aload         18
     611: checkcast     #175                // class java/lang/Number
     614: invokevirtual #178                // Method java/lang/Number.longValue:()J
     617: lstore        19
     619: iconst_0
     620: istore        21
     622: aload         13
     624: invokevirtual #192                // Method Monkey.getInspectionCount:()J
     627: lstore        22
     629: aload         13
     631: lload         22
     633: lconst_1
     634: ladd
     635: invokevirtual #196                // Method Monkey.setInspectionCount:(J)V
     638: lload         19
     640: aload         13
     642: invokevirtual #161                // Method Monkey.getTest:()J
     645: lrem
     646: lconst_0
     647: lcmp
     648: ifne          659
     651: aload         13
     653: invokevirtual #200                // Method Monkey.getTrueReceiver:()I
     656: goto          664
     659: aload         13
     661: invokevirtual #203                // Method Monkey.getFalseReceiver:()I
     664: istore        24
     666: lload         19
     668: lload         8
     670: lrem
     671: lstore        25
     673: aload         7
     675: iload         24
     677: invokeinterface #207,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     682: checkcast     #157                // class Monkey
     685: invokevirtual #183                // Method Monkey.getItems:()Ljava/util/List;
     688: lload         25
     690: invokestatic  #167                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     693: invokeinterface #208,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     698: pop
     699: nop
     700: nop
     701: goto          590
     704: nop
     705: aload         13
     707: invokevirtual #183                // Method Monkey.getItems:()Ljava/util/List;
     710: invokeinterface #211,  1          // InterfaceMethod java/util/List.clear:()V
     715: goto          422
     718: iload         10
     720: iload_2
     721: if_icmpeq     730
     724: iinc          10, 1
     727: goto          413
     730: aload         7
     732: checkcast     #128                // class java/lang/Iterable
     735: astore        10
     737: iconst_0
     738: istore        11
     740: aload         10
     742: new           #213                // class Day11$Companion$privateProcess$$inlined$sortedByDescending$1
     745: dup
     746: invokespecial #214                // Method Day11$Companion$privateProcess$$inlined$sortedByDescending$1."<init>":()V
     749: checkcast     #216                // class java/util/Comparator
     752: invokestatic  #220                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
     755: checkcast     #128                // class java/lang/Iterable
     758: iconst_2
     759: invokestatic  #224                // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
     762: checkcast     #128                // class java/lang/Iterable
     765: astore        10
     767: iconst_0
     768: istore        11
     770: aload         10
     772: astore        13
     774: new           #130                // class java/util/ArrayList
     777: dup
     778: aload         10
     780: bipush        10
     782: invokestatic  #136                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     785: invokespecial #139                // Method java/util/ArrayList."<init>":(I)V
     788: checkcast     #141                // class java/util/Collection
     791: astore        14
     793: iconst_0
     794: istore        16
     796: aload         13
     798: invokeinterface #145,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     803: astore        17
     805: aload         17
     807: invokeinterface #151,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     812: ifeq          858
     815: aload         17
     817: invokeinterface #155,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     822: astore        18
     824: aload         14
     826: aload         18
     828: checkcast     #157                // class Monkey
     831: astore        19
     833: astore        27
     835: iconst_0
     836: istore        20
     838: aload         19
     840: invokevirtual #192                // Method Monkey.getInspectionCount:()J
     843: invokestatic  #167                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     846: aload         27
     848: swap
     849: invokeinterface #171,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     854: pop
     855: goto          805
     858: aload         14
     860: checkcast     #173                // class java/util/List
     863: nop
     864: checkcast     #128                // class java/lang/Iterable
     867: astore        10
     869: lconst_1
     870: lstore        11
     872: iconst_0
     873: istore        13
     875: lload         11
     877: lstore        14
     879: aload         10
     881: invokeinterface #145,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     886: astore        16
     888: aload         16
     890: invokeinterface #151,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     895: ifeq          934
     898: aload         16
     900: invokeinterface #155,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     905: astore        17
     907: lload         14
     909: aload         17
     911: checkcast     #175                // class java/lang/Number
     914: invokevirtual #178                // Method java/lang/Number.longValue:()J
     917: lstore        18
     919: lstore        20
     921: iconst_0
     922: istore        22
     924: lload         20
     926: lload         18
     928: lmul
     929: lstore        14
     931: goto          888
     934: lload         14
     936: lreturn
    Exception table:
       from    to  target type
         145   190   202   Class java/lang/Throwable
         145   190   211   any
         202   211   211   any
         211   213   211   any

  public final long process(java.io.InputStream);
    Code:
       0: aload_0
       1: aload_1
       2: bipush        20
       4: ldc2_w        #287                // long 3l
       7: invokespecial #290                // Method privateProcess:(Ljava/io/InputStream;IJ)J
      10: lreturn

  public final long process2(java.io.InputStream);
    Code:
       0: aload_0
       1: aload_1
       2: sipush        10000
       5: lconst_1
       6: invokespecial #290                // Method privateProcess:(Ljava/io/InputStream;IJ)J
       9: lreturn

  private static final long createOperation$lambda$0(java.lang.Long, long);
    Code:
       0: lload_1
       1: aload_0
       2: dup
       3: ifnull        12
       6: invokevirtual #292                // Method java/lang/Long.longValue:()J
       9: goto          14
      12: pop
      13: lload_1
      14: ladd
      15: lreturn

  private static final long createOperation$lambda$1(java.lang.Long, long);
    Code:
       0: lload_1
       1: aload_0
       2: dup
       3: ifnull        12
       6: invokevirtual #292                // Method java/lang/Long.longValue:()J
       9: goto          14
      12: pop
      13: lload_1
      14: lmul
      15: lreturn

  private static final long privateProcess$lambda$4$lambda$3$lambda$2(kotlin.text.MatchResult);
    Code:
       0: aload_0
       1: ldc_w         #297                // String it
       4: invokestatic  #301                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokeinterface #307,  1          // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;
      13: invokestatic  #311                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
      16: lreturn

  private static final Monkey privateProcess$lambda$4$lambda$3(kotlin.text.Regex, kotlin.text.Regex, java.util.List);
    Code:
       0: aload_2
       1: ldc_w         #314                // String monkeyDesc
       4: invokestatic  #301                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: aload_2
       9: iconst_1
      10: invokeinterface #207,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      15: checkcast     #316                // class java/lang/CharSequence
      18: iconst_0
      19: iconst_2
      20: aconst_null
      21: invokestatic  #320                // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;
      24: invokedynamic #327,  0            // InvokeDynamic #3:invoke:()Lkotlin/jvm/functions/Function1;
      29: invokestatic  #116                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      32: invokestatic  #330                // Method kotlin/sequences/SequencesKt.toMutableList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
      35: astore_3
      36: new           #157                // class Monkey
      39: dup
      40: aload_3
      41: getstatic     #335                // Field Day11.Companion:LDay11$Companion;
      44: aload_1
      45: aload_2
      46: iconst_2
      47: invokeinterface #207,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      52: checkcast     #316                // class java/lang/CharSequence
      55: iconst_0
      56: iconst_2
      57: aconst_null
      58: invokestatic  #339                // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;
      61: dup
      62: invokestatic  #343                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      65: invokeinterface #307,  1          // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;
      70: aload_0
      71: aload_2
      72: iconst_2
      73: invokeinterface #207,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      78: checkcast     #316                // class java/lang/CharSequence
      81: iconst_0
      82: iconst_2
      83: aconst_null
      84: invokestatic  #339                // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;
      87: dup
      88: ifnull        109
      91: invokeinterface #307,  1          // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;
      96: dup
      97: ifnull        109
     100: invokestatic  #311                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     103: invokestatic  #167                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     106: goto          111
     109: pop
     110: aconst_null
     111: invokespecial #345                // Method createOperation:(Ljava/lang/String;Ljava/lang/Long;)Lkotlin/jvm/functions/Function1;
     114: aload_0
     115: aload_2
     116: iconst_3
     117: invokeinterface #207,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     122: checkcast     #316                // class java/lang/CharSequence
     125: iconst_0
     126: iconst_2
     127: aconst_null
     128: invokestatic  #339                // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;
     131: dup
     132: invokestatic  #343                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     135: invokeinterface #307,  1          // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;
     140: invokestatic  #311                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     143: aload_0
     144: aload_2
     145: iconst_4
     146: invokeinterface #207,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     151: checkcast     #316                // class java/lang/CharSequence
     154: iconst_0
     155: iconst_2
     156: aconst_null
     157: invokestatic  #339                // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;
     160: dup
     161: invokestatic  #343                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     164: invokeinterface #307,  1          // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;
     169: invokestatic  #351                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     172: aload_0
     173: aload_2
     174: iconst_5
     175: invokeinterface #207,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     180: checkcast     #316                // class java/lang/CharSequence
     183: iconst_0
     184: iconst_2
     185: aconst_null
     186: invokestatic  #339                // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;
     189: dup
     190: invokestatic  #343                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     193: invokeinterface #307,  1          // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;
     198: invokestatic  #351                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     201: lconst_0
     202: bipush        32
     204: aconst_null
     205: invokespecial #354                // Method Monkey."<init>":(Ljava/util/List;Lkotlin/jvm/functions/Function1;JIIJILkotlin/jvm/internal/DefaultConstructorMarker;)V
     208: areturn

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


import java.io.InputStream
import kotlin.math.abs
import kotlin.math.pow
import kotlin.math.sqrt

data class Vec2(
    var x: Int,
    var y: Int
) {
    operator fun plus(other: Vec2): Vec2 {
        return Vec2(x + other.x, y + other.y)
    }

    operator fun minus(other: Vec2): Vec2 {
        return Vec2(x - other.x, y - other.y)
    }

    fun toUnits(): Vec2 {
        val uX = if (abs(x) > 1) x / 2 else x
        val uY = if (abs(y) > 1) y / 2 else y
        return Vec2(uX, uY)
    }

    fun length(): Float {
        return sqrt(x.toFloat().pow(2) + y.toFloat().pow(2))
    }
}

class Day9 {
    companion object {
        fun process(input: InputStream?): Int {
            if (input == null) {
                throw Exception("Input missing")
            }

            var head = Vec2(0, 0)
            var prevHead = Vec2(0, 0)
            var tail = Vec2(0, 0)
            val visited = mutableSetOf(tail)

            input.bufferedReader()
                .useLines { lines ->
                    lines.map { it.split(" ") }
                        .map { Pair(it[0], it[1].toInt()) }
                        .forEach { c ->
                            //println("${head.x},${head.y}")
                            val dir = when (c.first) {
                                "U" -> Vec2(0, 1)
                                "D" -> Vec2(0, -1)
                                "L" -> Vec2(-1, 0)
                                else -> Vec2(1, 0)
                            }
                            repeat(c.second) {
                                head += dir

                                if ((head - tail).length() > 1.5) {
                                    tail = prevHead
                                    visited.add(tail)
                                }
                                prevHead = head
                            }
                        }
                }

            return visited.size
        }

        fun process2(input: InputStream?): Int {
            if (input == null) {
                throw Exception("Input missing")
            }

            val rope = Array(10) { Vec2(0, 0) }
            val visited = mutableSetOf(rope[9])

            input.bufferedReader()
                .useLines { lines ->
                    lines.map { it.split(" ") }
                        .map { Pair(it[0], it[1].toInt()) }
                        .forEach { c ->
                            val dir = when (c.first) {
                                "U" -> Vec2(0, 1)
                                "D" -> Vec2(0, -1)
                                "L" -> Vec2(-1, 0)
                                else -> Vec2(1, 0)
                            }
                            repeat(c.second) {
                                rope[0] += dir

                                for (i in 1..9) {
                                    val sectionVec = rope[i - 1] - rope[i]
                                    if (sectionVec.length() > 1.5) {
                                        rope[i] += sectionVec.toUnits()
                                    }
                                }

                                visited.add(rope[9])
                            }
                        }
                }

            return visited.size
        }
    }

}

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

  public final int process(java.io.InputStream);
    Code:
       0: aload_1
       1: ifnonnull     14
       4: new           #17                 // class java/lang/Exception
       7: dup
       8: ldc           #19                 // String Input missing
      10: invokespecial #22                 // Method java/lang/Exception."<init>":(Ljava/lang/String;)V
      13: athrow
      14: aconst_null
      15: astore_2
      16: new           #24                 // class Vec2
      19: dup
      20: iconst_0
      21: iconst_0
      22: invokespecial #27                 // Method Vec2."<init>":(II)V
      25: astore_2
      26: aconst_null
      27: astore_3
      28: new           #24                 // class Vec2
      31: dup
      32: iconst_0
      33: iconst_0
      34: invokespecial #27                 // Method Vec2."<init>":(II)V
      37: astore_3
      38: aconst_null
      39: astore        4
      41: new           #24                 // class Vec2
      44: dup
      45: iconst_0
      46: iconst_0
      47: invokespecial #27                 // Method Vec2."<init>":(II)V
      50: astore        4
      52: iconst_1
      53: anewarray     #24                 // class Vec2
      56: astore        6
      58: aload         6
      60: iconst_0
      61: aload         4
      63: aastore
      64: aload         6
      66: invokestatic  #33                 // Method kotlin/collections/SetsKt.mutableSetOf:([Ljava/lang/Object;)Ljava/util/Set;
      69: astore        5
      71: aload_1
      72: astore        6
      74: getstatic     #39                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      77: astore        7
      79: new           #41                 // class java/io/InputStreamReader
      82: dup
      83: aload         6
      85: aload         7
      87: invokespecial #44                 // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
      90: checkcast     #46                 // class java/io/Reader
      93: astore        8
      95: sipush        8192
      98: istore        9
     100: aload         8
     102: instanceof    #48                 // class java/io/BufferedReader
     105: ifeq          116
     108: aload         8
     110: checkcast     #48                 // class java/io/BufferedReader
     113: goto          127
     116: new           #48                 // class java/io/BufferedReader
     119: dup
     120: aload         8
     122: iload         9
     124: invokespecial #51                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
     127: checkcast     #46                 // class java/io/Reader
     130: astore        6
     132: nop
     133: iconst_0
     134: istore        7
     136: aload         6
     138: astore        8
     140: sipush        8192
     143: istore        9
     145: aload         8
     147: instanceof    #48                 // class java/io/BufferedReader
     150: ifeq          161
     153: aload         8
     155: checkcast     #48                 // class java/io/BufferedReader
     158: goto          172
     161: new           #48                 // class java/io/BufferedReader
     164: dup
     165: aload         8
     167: iload         9
     169: invokespecial #51                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
     172: checkcast     #53                 // class java/io/Closeable
     175: astore        8
     177: aconst_null
     178: astore        9
     180: nop
     181: aload         8
     183: checkcast     #48                 // class java/io/BufferedReader
     186: astore        10
     188: iconst_0
     189: istore        11
     191: aload         10
     193: invokestatic  #59                 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;
     196: astore        12
     198: iconst_0
     199: istore        13
     201: aload         12
     203: invokedynamic #78,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     208: invokestatic  #84                 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     211: invokedynamic #91,  0             // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
     216: invokestatic  #84                 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     219: astore        14
     221: nop
     222: iconst_0
     223: istore        15
     225: aload         14
     227: invokeinterface #97,  1           // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
     232: astore        16
     234: aload         16
     236: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     241: ifeq          479
     244: aload         16
     246: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     251: astore        17
     253: aload         17
     255: checkcast     #109                // class kotlin/Pair
     258: astore        18
     260: iconst_0
     261: istore        19
     263: aload         18
     265: invokevirtual #112                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     268: checkcast     #114                // class java/lang/String
     271: astore        20
     273: aload         20
     275: invokevirtual #118                // Method java/lang/String.hashCode:()I
     278: lookupswitch  { // 3
                    68: 312
                    76: 338
                    85: 325
               default: 387
          }
     312: aload         20
     314: ldc           #120                // String D
     316: invokevirtual #124                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     319: ifne          363
     322: goto          387
     325: aload         20
     327: ldc           #126                // String U
     329: invokevirtual #124                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     332: ifne          351
     335: goto          387
     338: aload         20
     340: ldc           #128                // String L
     342: invokevirtual #124                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     345: ifne          375
     348: goto          387
     351: new           #24                 // class Vec2
     354: dup
     355: iconst_0
     356: iconst_1
     357: invokespecial #27                 // Method Vec2."<init>":(II)V
     360: goto          396
     363: new           #24                 // class Vec2
     366: dup
     367: iconst_0
     368: iconst_m1
     369: invokespecial #27                 // Method Vec2."<init>":(II)V
     372: goto          396
     375: new           #24                 // class Vec2
     378: dup
     379: iconst_m1
     380: iconst_0
     381: invokespecial #27                 // Method Vec2."<init>":(II)V
     384: goto          396
     387: new           #24                 // class Vec2
     390: dup
     391: iconst_1
     392: iconst_0
     393: invokespecial #27                 // Method Vec2."<init>":(II)V
     396: astore        21
     398: aload         18
     400: invokevirtual #131                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     403: checkcast     #133                // class java/lang/Number
     406: invokevirtual #136                // Method java/lang/Number.intValue:()I
     409: istore        20
     411: iconst_0
     412: istore        22
     414: iload         22
     416: iload         20
     418: if_icmpge     474
     421: iload         22
     423: istore        23
     425: iconst_0
     426: istore        24
     428: aload_2
     429: aload         21
     431: invokevirtual #140                // Method Vec2.plus:(LVec2;)LVec2;
     434: astore_2
     435: aload_2
     436: aload         4
     438: invokevirtual #143                // Method Vec2.minus:(LVec2;)LVec2;
     441: invokevirtual #147                // Method Vec2.length:()F
     444: f2d
     445: ldc2_w        #148                // double 1.5d
     448: dcmpl
     449: ifle          465
     452: aload_3
     453: astore        4
     455: aload         5
     457: aload         4
     459: invokeinterface #154,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     464: pop
     465: aload_2
     466: astore_3
     467: nop
     468: iinc          22, 1
     471: goto          414
     474: nop
     475: nop
     476: goto          234
     479: nop
     480: nop
     481: getstatic     #160                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     484: astore        10
     486: aload         8
     488: aload         9
     490: invokestatic  #166                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     493: goto          517
     496: astore        11
     498: aload         11
     500: astore        9
     502: aload         11
     504: athrow
     505: astore        11
     507: aload         8
     509: aload         9
     511: invokestatic  #166                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     514: aload         11
     516: athrow
     517: nop
     518: aload         5
     520: invokeinterface #169,  1          // InterfaceMethod java/util/Set.size:()I
     525: ireturn
    Exception table:
       from    to  target type
         180   486   496   Class java/lang/Throwable
         180   486   505   any
         496   505   505   any
         505   507   505   any

  public final int process2(java.io.InputStream);
    Code:
       0: aload_1
       1: ifnonnull     14
       4: new           #17                 // class java/lang/Exception
       7: dup
       8: ldc           #19                 // String Input missing
      10: invokespecial #22                 // Method java/lang/Exception."<init>":(Ljava/lang/String;)V
      13: athrow
      14: iconst_0
      15: istore_3
      16: bipush        10
      18: anewarray     #24                 // class Vec2
      21: astore        4
      23: iload_3
      24: bipush        10
      26: if_icmpge     52
      29: iload_3
      30: istore        5
      32: aload         4
      34: iload         5
      36: new           #24                 // class Vec2
      39: dup
      40: iconst_0
      41: iconst_0
      42: invokespecial #27                 // Method Vec2."<init>":(II)V
      45: aastore
      46: iinc          3, 1
      49: goto          23
      52: aload         4
      54: astore_2
      55: iconst_1
      56: anewarray     #24                 // class Vec2
      59: astore        4
      61: aload         4
      63: iconst_0
      64: aload_2
      65: bipush        9
      67: aaload
      68: aastore
      69: aload         4
      71: invokestatic  #33                 // Method kotlin/collections/SetsKt.mutableSetOf:([Ljava/lang/Object;)Ljava/util/Set;
      74: astore_3
      75: aload_1
      76: astore        4
      78: getstatic     #39                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      81: astore        5
      83: new           #41                 // class java/io/InputStreamReader
      86: dup
      87: aload         4
      89: aload         5
      91: invokespecial #44                 // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
      94: checkcast     #46                 // class java/io/Reader
      97: astore        6
      99: sipush        8192
     102: istore        7
     104: aload         6
     106: instanceof    #48                 // class java/io/BufferedReader
     109: ifeq          120
     112: aload         6
     114: checkcast     #48                 // class java/io/BufferedReader
     117: goto          131
     120: new           #48                 // class java/io/BufferedReader
     123: dup
     124: aload         6
     126: iload         7
     128: invokespecial #51                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
     131: checkcast     #46                 // class java/io/Reader
     134: astore        4
     136: nop
     137: iconst_0
     138: istore        5
     140: aload         4
     142: astore        6
     144: sipush        8192
     147: istore        7
     149: aload         6
     151: instanceof    #48                 // class java/io/BufferedReader
     154: ifeq          165
     157: aload         6
     159: checkcast     #48                 // class java/io/BufferedReader
     162: goto          176
     165: new           #48                 // class java/io/BufferedReader
     168: dup
     169: aload         6
     171: iload         7
     173: invokespecial #51                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
     176: checkcast     #53                 // class java/io/Closeable
     179: astore        6
     181: aconst_null
     182: astore        7
     184: nop
     185: aload         6
     187: checkcast     #48                 // class java/io/BufferedReader
     190: astore        8
     192: iconst_0
     193: istore        9
     195: aload         8
     197: invokestatic  #59                 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;
     200: astore        10
     202: iconst_0
     203: istore        11
     205: aload         10
     207: invokedynamic #207,  0            // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;
     212: invokestatic  #84                 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     215: invokedynamic #212,  0            // InvokeDynamic #3:invoke:()Lkotlin/jvm/functions/Function1;
     220: invokestatic  #84                 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     223: astore        12
     225: nop
     226: iconst_0
     227: istore        13
     229: aload         12
     231: invokeinterface #97,  1           // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
     236: astore        14
     238: aload         14
     240: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     245: ifeq          530
     248: aload         14
     250: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     255: astore        15
     257: aload         15
     259: checkcast     #109                // class kotlin/Pair
     262: astore        16
     264: iconst_0
     265: istore        17
     267: aload         16
     269: invokevirtual #112                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     272: checkcast     #114                // class java/lang/String
     275: astore        18
     277: aload         18
     279: invokevirtual #118                // Method java/lang/String.hashCode:()I
     282: lookupswitch  { // 3
                    68: 316
                    76: 342
                    85: 329
               default: 391
          }
     316: aload         18
     318: ldc           #120                // String D
     320: invokevirtual #124                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     323: ifne          367
     326: goto          391
     329: aload         18
     331: ldc           #126                // String U
     333: invokevirtual #124                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     336: ifne          355
     339: goto          391
     342: aload         18
     344: ldc           #128                // String L
     346: invokevirtual #124                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     349: ifne          379
     352: goto          391
     355: new           #24                 // class Vec2
     358: dup
     359: iconst_0
     360: iconst_1
     361: invokespecial #27                 // Method Vec2."<init>":(II)V
     364: goto          400
     367: new           #24                 // class Vec2
     370: dup
     371: iconst_0
     372: iconst_m1
     373: invokespecial #27                 // Method Vec2."<init>":(II)V
     376: goto          400
     379: new           #24                 // class Vec2
     382: dup
     383: iconst_m1
     384: iconst_0
     385: invokespecial #27                 // Method Vec2."<init>":(II)V
     388: goto          400
     391: new           #24                 // class Vec2
     394: dup
     395: iconst_1
     396: iconst_0
     397: invokespecial #27                 // Method Vec2."<init>":(II)V
     400: astore        19
     402: aload         16
     404: invokevirtual #131                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     407: checkcast     #133                // class java/lang/Number
     410: invokevirtual #136                // Method java/lang/Number.intValue:()I
     413: istore        18
     415: iconst_0
     416: istore        20
     418: iload         20
     420: iload         18
     422: if_icmpge     525
     425: iload         20
     427: istore        21
     429: iconst_0
     430: istore        22
     432: aload_2
     433: iconst_0
     434: aload_2
     435: iconst_0
     436: aaload
     437: aload         19
     439: invokevirtual #140                // Method Vec2.plus:(LVec2;)LVec2;
     442: aastore
     443: iconst_1
     444: istore        23
     446: iload         23
     448: bipush        10
     450: if_icmpge     507
     453: aload_2
     454: iload         23
     456: iconst_1
     457: isub
     458: aaload
     459: aload_2
     460: iload         23
     462: aaload
     463: invokevirtual #143                // Method Vec2.minus:(LVec2;)LVec2;
     466: astore        24
     468: aload         24
     470: invokevirtual #147                // Method Vec2.length:()F
     473: f2d
     474: ldc2_w        #148                // double 1.5d
     477: dcmpl
     478: ifle          501
     481: iload         23
     483: istore        25
     485: aload_2
     486: iload         25
     488: aload_2
     489: iload         25
     491: aaload
     492: aload         24
     494: invokevirtual #216                // Method Vec2.toUnits:()LVec2;
     497: invokevirtual #140                // Method Vec2.plus:(LVec2;)LVec2;
     500: aastore
     501: iinc          23, 1
     504: goto          446
     507: aload_3
     508: aload_2
     509: bipush        9
     511: aaload
     512: invokeinterface #154,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     517: pop
     518: nop
     519: iinc          20, 1
     522: goto          418
     525: nop
     526: nop
     527: goto          238
     530: nop
     531: nop
     532: getstatic     #160                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     535: astore        8
     537: aload         6
     539: aload         7
     541: invokestatic  #166                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     544: goto          568
     547: astore        9
     549: aload         9
     551: astore        7
     553: aload         9
     555: athrow
     556: astore        9
     558: aload         6
     560: aload         7
     562: invokestatic  #166                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     565: aload         9
     567: athrow
     568: nop
     569: aload_3
     570: invokeinterface #169,  1          // InterfaceMethod java/util/Set.size:()I
     575: ireturn
    Exception table:
       from    to  target type
         184   537   547   Class java/lang/Throwable
         184   537   556   any
         547   556   556   any
         556   558   556   any

  private static final java.util.List process$lambda$4$lambda$0(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #225                // String it
       3: invokestatic  #231                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #233                // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #114                // class java/lang/String
      14: astore_1
      15: aload_1
      16: iconst_0
      17: ldc           #235                // String
      19: aastore
      20: aload_1
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #241                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: areturn

  private static final kotlin.Pair process$lambda$4$lambda$1(java.util.List);
    Code:
       0: aload_0
       1: ldc           #225                // String it
       3: invokestatic  #231                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #109                // class kotlin/Pair
       9: dup
      10: aload_0
      11: iconst_0
      12: invokeinterface #248,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      17: aload_0
      18: iconst_1
      19: invokeinterface #248,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      24: checkcast     #114                // class java/lang/String
      27: invokestatic  #254                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      30: invokestatic  #258                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      33: invokespecial #261                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      36: areturn

  private static final java.util.List process2$lambda$9$lambda$5(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #225                // String it
       3: invokestatic  #231                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #233                // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #114                // class java/lang/String
      14: astore_1
      15: aload_1
      16: iconst_0
      17: ldc           #235                // String
      19: aastore
      20: aload_1
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #241                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: areturn

  private static final kotlin.Pair process2$lambda$9$lambda$6(java.util.List);
    Code:
       0: aload_0
       1: ldc           #225                // String it
       3: invokestatic  #231                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #109                // class kotlin/Pair
       9: dup
      10: aload_0
      11: iconst_0
      12: invokeinterface #248,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      17: aload_0
      18: iconst_1
      19: invokeinterface #248,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      24: checkcast     #114                // class java/lang/String
      27: invokestatic  #254                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      30: invokestatic  #258                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      33: invokespecial #261                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      36: areturn

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

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

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

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