import kotlin.math.floor

fun main() {

    data class Monkey(
        val items: MutableList<Long>,
        val operation: String,
        val divisor: Long,
        val trueMonkey: Int,
        val falseMonkey: Int,
        var inspections: Long = 0
    )

    fun parse(input: List<String>) =
        input
            .joinToString("\n")
            .split("\n\n")
            .map {
                val (itemsInput, operationInput, testInput, trueInput, falseInput) = it.split("\n").drop(1)
                val items = itemsInput.substringAfter("items: ")
                    .split(",")
                    .map { s -> s.trim().toLong() }
                    .toMutableList()

                val operation = operationInput.substringAfter("new =").trim()
                val divisibleBy = testInput.substringAfter("by ").toLong()
                val trueMonkey = trueInput.substringAfter("monkey ").toInt()
                val falseMonkey = falseInput.substringAfter("monkey ").toInt()

                Monkey(items, operation, divisibleBy, trueMonkey, falseMonkey)
            }

    fun operation(operation: String, item: Long): Long {
        val expression = operation.replace("old", item.toString())
        val (n1, op, n2) = expression.split(" ")

        return when (op) {
            "+" -> n1.toLong() + n2.toLong()
            "*" -> n1.toLong() * n2.toLong()
            else -> error("wrong operation $op")
        }
    }

    fun common(input: List<String>, maxIterations: Int, nextWorryLevel: (operationResult: Long, magicNumber: Long) -> Long): Long {
        val monkeys = parse(input)
        val magicNumber = monkeys.map { it.divisor }.reduce { acc, i ->
            acc * i
        }

        repeat(maxIterations) {
            monkeys.forEach {
                it.items.forEach { item ->
                    it.inspections++

                    val operationResult = operation(it.operation, item)
                    val worryLevel = nextWorryLevel(operationResult, magicNumber)

                    if (worryLevel divisibleBy it.divisor) {
                        monkeys[it.trueMonkey].items += worryLevel
                    } else {
                        monkeys[it.falseMonkey].items += worryLevel
                    }
                }

                it.items.clear()
            }
        }

        return monkeys
            .map { it.inspections }
            .sorted()
            .takeLast(2)
            .reduce { acc, i ->
                acc * i
            }
    }

    fun part1(input: List<String>): Long {
        return common(input, 20) { operationResult, _ ->
            floor(operationResult / 3.0).toLong()
        }
    }

    fun part2(input: List<String>): Long {
        return common(input, 10000) { operationResult, magicNumber ->
            operationResult % magicNumber
        }
    }

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

infix fun Long.divisibleBy(divisor: Long) = this % divisor == 0L

Compiled from "Day11.kt"
public final class Day11Kt$main$Monkey {
  private final java.util.List<java.lang.Long> items;

  private final java.lang.String operation;

  private final long divisor;

  private final int trueMonkey;

  private final int falseMonkey;

  private long inspections;

  public Day11Kt$main$Monkey(java.util.List<java.lang.Long>, java.lang.String, long, int, int, long);
    Code:
       0: aload_1
       1: ldc           #9                  // String items
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #17                 // String operation
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: invokespecial #20                 // Method java/lang/Object."<init>":()V
      16: aload_0
      17: aload_1
      18: putfield      #23                 // Field items:Ljava/util/List;
      21: aload_0
      22: aload_2
      23: putfield      #26                 // Field operation:Ljava/lang/String;
      26: aload_0
      27: lload_3
      28: putfield      #30                 // Field divisor:J
      31: aload_0
      32: iload         5
      34: putfield      #34                 // Field trueMonkey:I
      37: aload_0
      38: iload         6
      40: putfield      #37                 // Field falseMonkey:I
      43: aload_0
      44: lload         7
      46: putfield      #40                 // Field inspections:J
      49: return

  public Day11Kt$main$Monkey(java.util.List, java.lang.String, long, int, int, long, int, kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: iload         9
       2: bipush        32
       4: iand
       5: ifeq          11
       8: lconst_0
       9: lstore        7
      11: aload_0
      12: aload_1
      13: aload_2
      14: lload_3
      15: iload         5
      17: iload         6
      19: lload         7
      21: invokespecial #45                 // Method "<init>":(Ljava/util/List;Ljava/lang/String;JIIJ)V
      24: return

  public final java.util.List<java.lang.Long> getItems();
    Code:
       0: aload_0
       1: getfield      #23                 // Field items:Ljava/util/List;
       4: areturn

  public final java.lang.String getOperation();
    Code:
       0: aload_0
       1: getfield      #26                 // Field operation:Ljava/lang/String;
       4: areturn

  public final long getDivisor();
    Code:
       0: aload_0
       1: getfield      #30                 // Field divisor:J
       4: lreturn

  public final int getTrueMonkey();
    Code:
       0: aload_0
       1: getfield      #34                 // Field trueMonkey:I
       4: ireturn

  public final int getFalseMonkey();
    Code:
       0: aload_0
       1: getfield      #37                 // Field falseMonkey:I
       4: ireturn

  public final long getInspections();
    Code:
       0: aload_0
       1: getfield      #40                 // Field inspections:J
       4: lreturn

  public final void setInspections(long);
    Code:
       0: aload_0
       1: lload_1
       2: putfield      #40                 // Field inspections:J
       5: return

  public final java.util.List<java.lang.Long> component1();
    Code:
       0: aload_0
       1: getfield      #23                 // Field items:Ljava/util/List;
       4: areturn

  public final java.lang.String component2();
    Code:
       0: aload_0
       1: getfield      #26                 // Field operation:Ljava/lang/String;
       4: areturn

  public final long component3();
    Code:
       0: aload_0
       1: getfield      #30                 // Field divisor:J
       4: lreturn

  public final int component4();
    Code:
       0: aload_0
       1: getfield      #34                 // Field trueMonkey:I
       4: ireturn

  public final int component5();
    Code:
       0: aload_0
       1: getfield      #37                 // Field falseMonkey:I
       4: ireturn

  public final long component6();
    Code:
       0: aload_0
       1: getfield      #40                 // Field inspections:J
       4: lreturn

  public final Day11Kt$main$Monkey copy(java.util.List<java.lang.Long>, java.lang.String, long, int, int, long);
    Code:
       0: aload_1
       1: ldc           #9                  // String items
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #17                 // String operation
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: new           #2                  // class Day11Kt$main$Monkey
      15: dup
      16: aload_1
      17: aload_2
      18: lload_3
      19: iload         5
      21: iload         6
      23: lload         7
      25: invokespecial #45                 // Method "<init>":(Ljava/util/List;Ljava/lang/String;JIIJ)V
      28: areturn

  public static Day11Kt$main$Monkey copy$default(Day11Kt$main$Monkey, java.util.List, java.lang.String, long, int, int, long, int, java.lang.Object);
    Code:
       0: iload         9
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #23                 // Field items:Ljava/util/List;
      11: astore_1
      12: iload         9
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #26                 // Field operation:Ljava/lang/String;
      23: astore_2
      24: iload         9
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #30                 // Field divisor:J
      35: lstore_3
      36: iload         9
      38: bipush        8
      40: iand
      41: ifeq          50
      44: aload_0
      45: getfield      #34                 // Field trueMonkey:I
      48: istore        5
      50: iload         9
      52: bipush        16
      54: iand
      55: ifeq          64
      58: aload_0
      59: getfield      #37                 // Field falseMonkey:I
      62: istore        6
      64: iload         9
      66: bipush        32
      68: iand
      69: ifeq          78
      72: aload_0
      73: getfield      #40                 // Field inspections:J
      76: lstore        7
      78: aload_0
      79: aload_1
      80: aload_2
      81: lload_3
      82: iload         5
      84: iload         6
      86: lload         7
      88: invokevirtual #72                 // Method copy:(Ljava/util/List;Ljava/lang/String;JIIJ)LDay11Kt$main$Monkey;
      91: areturn

  public java.lang.String toString();
    Code:
       0: new           #75                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #76                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #78                 // String Monkey(items=
       9: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #23                 // Field items:Ljava/util/List;
      16: invokevirtual #85                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      19: ldc           #87                 // String , operation=
      21: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #26                 // Field operation:Ljava/lang/String;
      28: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      31: ldc           #89                 // String , divisor=
      33: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: aload_0
      37: getfield      #30                 // Field divisor:J
      40: invokevirtual #92                 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
      43: ldc           #94                 // String , trueMonkey=
      45: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      48: aload_0
      49: getfield      #34                 // Field trueMonkey:I
      52: invokevirtual #97                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      55: ldc           #99                 // String , falseMonkey=
      57: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      60: aload_0
      61: getfield      #37                 // Field falseMonkey:I
      64: invokevirtual #97                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      67: ldc           #101                // String , inspections=
      69: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      72: aload_0
      73: getfield      #40                 // Field inspections:J
      76: invokevirtual #92                 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
      79: bipush        41
      81: invokevirtual #104                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      84: invokevirtual #106                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      87: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #23                 // Field items:Ljava/util/List;
       4: invokevirtual #109                // Method java/lang/Object.hashCode:()I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #26                 // Field operation:Ljava/lang/String;
      16: invokevirtual #112                // Method java/lang/String.hashCode:()I
      19: iadd
      20: istore_1
      21: iload_1
      22: bipush        31
      24: imul
      25: aload_0
      26: getfield      #30                 // Field divisor:J
      29: invokestatic  #117                // Method java/lang/Long.hashCode:(J)I
      32: iadd
      33: istore_1
      34: iload_1
      35: bipush        31
      37: imul
      38: aload_0
      39: getfield      #34                 // Field trueMonkey:I
      42: invokestatic  #122                // Method java/lang/Integer.hashCode:(I)I
      45: iadd
      46: istore_1
      47: iload_1
      48: bipush        31
      50: imul
      51: aload_0
      52: getfield      #37                 // Field falseMonkey:I
      55: invokestatic  #122                // Method java/lang/Integer.hashCode:(I)I
      58: iadd
      59: istore_1
      60: iload_1
      61: bipush        31
      63: imul
      64: aload_0
      65: getfield      #40                 // Field inspections:J
      68: invokestatic  #117                // Method java/lang/Long.hashCode:(J)I
      71: iadd
      72: istore_1
      73: iload_1
      74: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class Day11Kt$main$Monkey
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class Day11Kt$main$Monkey
      20: astore_2
      21: aload_0
      22: getfield      #23                 // Field items:Ljava/util/List;
      25: aload_2
      26: getfield      #23                 // Field items:Ljava/util/List;
      29: invokestatic  #129                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      32: ifne          37
      35: iconst_0
      36: ireturn
      37: aload_0
      38: getfield      #26                 // Field operation:Ljava/lang/String;
      41: aload_2
      42: getfield      #26                 // Field operation:Ljava/lang/String;
      45: invokestatic  #129                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      48: ifne          53
      51: iconst_0
      52: ireturn
      53: aload_0
      54: getfield      #30                 // Field divisor:J
      57: aload_2
      58: getfield      #30                 // Field divisor:J
      61: lcmp
      62: ifeq          67
      65: iconst_0
      66: ireturn
      67: aload_0
      68: getfield      #34                 // Field trueMonkey:I
      71: aload_2
      72: getfield      #34                 // Field trueMonkey:I
      75: if_icmpeq     80
      78: iconst_0
      79: ireturn
      80: aload_0
      81: getfield      #37                 // Field falseMonkey:I
      84: aload_2
      85: getfield      #37                 // Field falseMonkey:I
      88: if_icmpeq     93
      91: iconst_0
      92: ireturn
      93: aload_0
      94: getfield      #40                 // Field inspections:J
      97: aload_2
      98: getfield      #40                 // Field inspections:J
     101: lcmp
     102: ifeq          107
     105: iconst_0
     106: ireturn
     107: iconst_1
     108: ireturn
}

Compiled from "Day11.kt"
public final class Day11Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String inputs/Day11
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)J
      10: lstore_1
      11: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      14: lload_1
      15: invokevirtual #30                 // Method java/io/PrintStream.println:(J)V
      18: aload_0
      19: invokestatic  #33                 // Method main$part2:(Ljava/util/List;)J
      22: lstore_1
      23: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      26: lload_1
      27: invokevirtual #30                 // Method java/io/PrintStream.println:(J)V
      30: return

  public static final boolean divisibleBy(long, long);
    Code:
       0: lload_0
       1: lload_2
       2: lrem
       3: lconst_0
       4: lcmp
       5: ifne          12
       8: iconst_1
       9: goto          13
      12: iconst_0
      13: ireturn

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

  private static final java.util.List<Day11Kt$main$Monkey> main$parse(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #50                 // class java/lang/Iterable
       4: ldc           #52                 // String \n
       6: checkcast     #54                 // class java/lang/CharSequence
       9: aconst_null
      10: aconst_null
      11: iconst_0
      12: aconst_null
      13: aconst_null
      14: bipush        62
      16: aconst_null
      17: invokestatic  #60                 // 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;
      20: checkcast     #54                 // class java/lang/CharSequence
      23: iconst_1
      24: anewarray     #62                 // class java/lang/String
      27: astore_1
      28: aload_1
      29: iconst_0
      30: ldc           #64                 // String \n\n
      32: aastore
      33: aload_1
      34: iconst_0
      35: iconst_0
      36: bipush        6
      38: aconst_null
      39: invokestatic  #70                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      42: checkcast     #50                 // class java/lang/Iterable
      45: astore_1
      46: nop
      47: iconst_0
      48: istore_2
      49: aload_1
      50: astore_3
      51: new           #72                 // class java/util/ArrayList
      54: dup
      55: aload_1
      56: bipush        10
      58: invokestatic  #76                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      61: invokespecial #80                 // Method java/util/ArrayList."<init>":(I)V
      64: checkcast     #82                 // class java/util/Collection
      67: astore        4
      69: iconst_0
      70: istore        5
      72: aload_3
      73: invokeinterface #86,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      78: astore        6
      80: aload         6
      82: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      87: ifeq          470
      90: aload         6
      92: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      97: astore        7
      99: aload         4
     101: aload         7
     103: checkcast     #62                 // class java/lang/String
     106: astore        8
     108: astore        29
     110: iconst_0
     111: istore        9
     113: aload         8
     115: checkcast     #54                 // class java/lang/CharSequence
     118: iconst_1
     119: anewarray     #62                 // class java/lang/String
     122: astore        10
     124: aload         10
     126: iconst_0
     127: ldc           #52                 // String \n
     129: aastore
     130: aload         10
     132: iconst_0
     133: iconst_0
     134: bipush        6
     136: aconst_null
     137: invokestatic  #70                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     140: checkcast     #50                 // class java/lang/Iterable
     143: iconst_1
     144: invokestatic  #100                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     147: astore        11
     149: aload         11
     151: iconst_0
     152: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     157: checkcast     #62                 // class java/lang/String
     160: astore        10
     162: aload         11
     164: iconst_1
     165: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     170: checkcast     #62                 // class java/lang/String
     173: astore        12
     175: aload         11
     177: iconst_2
     178: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     183: checkcast     #62                 // class java/lang/String
     186: astore        13
     188: aload         11
     190: iconst_3
     191: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     196: checkcast     #62                 // class java/lang/String
     199: astore        14
     201: aload         11
     203: iconst_4
     204: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     209: checkcast     #62                 // class java/lang/String
     212: astore        15
     214: aload         10
     216: ldc           #108                // String items:
     218: aconst_null
     219: iconst_2
     220: aconst_null
     221: invokestatic  #112                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     224: checkcast     #54                 // class java/lang/CharSequence
     227: iconst_1
     228: anewarray     #62                 // class java/lang/String
     231: astore        16
     233: aload         16
     235: iconst_0
     236: ldc           #114                // String ,
     238: aastore
     239: aload         16
     241: iconst_0
     242: iconst_0
     243: bipush        6
     245: aconst_null
     246: invokestatic  #70                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     249: checkcast     #50                 // class java/lang/Iterable
     252: astore        16
     254: nop
     255: iconst_0
     256: istore        17
     258: aload         16
     260: astore        18
     262: new           #72                 // class java/util/ArrayList
     265: dup
     266: aload         16
     268: bipush        10
     270: invokestatic  #76                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     273: invokespecial #80                 // Method java/util/ArrayList."<init>":(I)V
     276: checkcast     #82                 // class java/util/Collection
     279: astore        19
     281: iconst_0
     282: istore        20
     284: aload         18
     286: invokeinterface #86,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     291: astore        21
     293: aload         21
     295: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     300: ifeq          357
     303: aload         21
     305: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     310: astore        22
     312: aload         19
     314: aload         22
     316: checkcast     #62                 // class java/lang/String
     319: astore        23
     321: astore        24
     323: iconst_0
     324: istore        25
     326: nop
     327: aload         23
     329: checkcast     #54                 // class java/lang/CharSequence
     332: invokestatic  #118                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     335: invokevirtual #122                // Method java/lang/Object.toString:()Ljava/lang/String;
     338: invokestatic  #128                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     341: nop
     342: invokestatic  #132                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     345: aload         24
     347: swap
     348: invokeinterface #136,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     353: pop
     354: goto          293
     357: aload         19
     359: checkcast     #102                // class java/util/List
     362: nop
     363: checkcast     #82                 // class java/util/Collection
     366: invokestatic  #140                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     369: astore        26
     371: aload         12
     373: ldc           #142                // String new =
     375: aconst_null
     376: iconst_2
     377: aconst_null
     378: invokestatic  #112                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     381: checkcast     #54                 // class java/lang/CharSequence
     384: invokestatic  #118                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     387: invokevirtual #122                // Method java/lang/Object.toString:()Ljava/lang/String;
     390: astore        16
     392: aload         13
     394: ldc           #144                // String by
     396: aconst_null
     397: iconst_2
     398: aconst_null
     399: invokestatic  #112                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     402: invokestatic  #128                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     405: lstore        27
     407: aload         14
     409: ldc           #146                // String monkey
     411: aconst_null
     412: iconst_2
     413: aconst_null
     414: invokestatic  #112                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     417: invokestatic  #152                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     420: istore        19
     422: aload         15
     424: ldc           #146                // String monkey
     426: aconst_null
     427: iconst_2
     428: aconst_null
     429: invokestatic  #112                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     432: invokestatic  #152                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     435: istore        20
     437: new           #154                // class Day11Kt$main$Monkey
     440: dup
     441: aload         26
     443: aload         16
     445: lload         27
     447: iload         19
     449: iload         20
     451: lconst_0
     452: bipush        32
     454: aconst_null
     455: invokespecial #157                // Method Day11Kt$main$Monkey."<init>":(Ljava/util/List;Ljava/lang/String;JIIJILkotlin/jvm/internal/DefaultConstructorMarker;)V
     458: aload         29
     460: swap
     461: invokeinterface #136,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     466: pop
     467: goto          80
     470: aload         4
     472: checkcast     #102                // class java/util/List
     475: nop
     476: areturn

  private static final long main$operation(java.lang.String, long);
    Code:
       0: aload_0
       1: ldc           #185                // String old
       3: lload_1
       4: invokestatic  #188                // Method java/lang/String.valueOf:(J)Ljava/lang/String;
       7: iconst_0
       8: iconst_4
       9: aconst_null
      10: invokestatic  #192                // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
      13: astore_3
      14: aload_3
      15: checkcast     #54                 // class java/lang/CharSequence
      18: iconst_1
      19: anewarray     #62                 // class java/lang/String
      22: astore        5
      24: aload         5
      26: iconst_0
      27: ldc           #194                // String
      29: aastore
      30: aload         5
      32: iconst_0
      33: iconst_0
      34: bipush        6
      36: aconst_null
      37: invokestatic  #70                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      40: astore        4
      42: aload         4
      44: iconst_0
      45: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      50: checkcast     #62                 // class java/lang/String
      53: astore        5
      55: aload         4
      57: iconst_1
      58: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      63: checkcast     #62                 // class java/lang/String
      66: astore        6
      68: aload         4
      70: iconst_2
      71: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      76: checkcast     #62                 // class java/lang/String
      79: astore        7
      81: aload         6
      83: astore        8
      85: aload         8
      87: ldc           #196                // String +
      89: invokestatic  #202                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      92: ifeq          109
      95: aload         5
      97: invokestatic  #128                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     100: aload         7
     102: invokestatic  #128                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     105: ladd
     106: goto          164
     109: aload         8
     111: ldc           #204                // String *
     113: invokestatic  #202                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     116: ifeq          133
     119: aload         5
     121: invokestatic  #128                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     124: aload         7
     126: invokestatic  #128                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     129: lmul
     130: goto          164
     133: new           #206                // class java/lang/IllegalStateException
     136: dup
     137: new           #208                // class java/lang/StringBuilder
     140: dup
     141: invokespecial #210                // Method java/lang/StringBuilder."<init>":()V
     144: ldc           #212                // String wrong operation
     146: invokevirtual #216                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     149: aload         6
     151: invokevirtual #216                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     154: invokevirtual #217                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     157: invokevirtual #122                // Method java/lang/Object.toString:()Ljava/lang/String;
     160: invokespecial #220                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     163: athrow
     164: lreturn

  private static final long main$common(java.util.List<java.lang.String>, int, kotlin.jvm.functions.Function2<? super java.lang.Long, ? super java.lang.Long, java.lang.Long>);
    Code:
       0: aload_0
       1: invokestatic  #230                // Method main$parse:(Ljava/util/List;)Ljava/util/List;
       4: astore_3
       5: aload_3
       6: checkcast     #50                 // class java/lang/Iterable
       9: astore        6
      11: iconst_0
      12: istore        7
      14: aload         6
      16: astore        8
      18: new           #72                 // class java/util/ArrayList
      21: dup
      22: aload         6
      24: bipush        10
      26: invokestatic  #76                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      29: invokespecial #80                 // Method java/util/ArrayList."<init>":(I)V
      32: checkcast     #82                 // class java/util/Collection
      35: astore        9
      37: iconst_0
      38: istore        10
      40: aload         8
      42: invokeinterface #86,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      47: astore        11
      49: aload         11
      51: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      56: ifeq          102
      59: aload         11
      61: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      66: astore        12
      68: aload         9
      70: aload         12
      72: checkcast     #154                // class Day11Kt$main$Monkey
      75: astore        13
      77: astore        27
      79: iconst_0
      80: istore        14
      82: aload         13
      84: invokevirtual #234                // Method Day11Kt$main$Monkey.getDivisor:()J
      87: invokestatic  #132                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      90: aload         27
      92: swap
      93: invokeinterface #136,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      98: pop
      99: goto          49
     102: aload         9
     104: checkcast     #102                // class java/util/List
     107: nop
     108: checkcast     #50                 // class java/lang/Iterable
     111: astore        6
     113: nop
     114: iconst_0
     115: istore        7
     117: aload         6
     119: invokeinterface #86,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     124: astore        8
     126: aload         8
     128: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     133: ifne          146
     136: new           #236                // class java/lang/UnsupportedOperationException
     139: dup
     140: ldc           #238                // String Empty collection can\'t be reduced.
     142: invokespecial #239                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     145: athrow
     146: aload         8
     148: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     153: astore        9
     155: aload         8
     157: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     162: ifeq          206
     165: aload         9
     167: aload         8
     169: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     174: checkcast     #241                // class java/lang/Number
     177: invokevirtual #244                // Method java/lang/Number.longValue:()J
     180: lstore        10
     182: checkcast     #241                // class java/lang/Number
     185: invokevirtual #244                // Method java/lang/Number.longValue:()J
     188: lstore        12
     190: iconst_0
     191: istore        14
     193: lload         12
     195: lload         10
     197: lmul
     198: invokestatic  #132                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     201: astore        9
     203: goto          155
     206: aload         9
     208: checkcast     #241                // class java/lang/Number
     211: invokevirtual #244                // Method java/lang/Number.longValue:()J
     214: lstore        4
     216: iconst_0
     217: istore        6
     219: iload         6
     221: iload_1
     222: if_icmpge     500
     225: iload         6
     227: istore        7
     229: iconst_0
     230: istore        8
     232: aload_3
     233: checkcast     #50                 // class java/lang/Iterable
     236: astore        9
     238: iconst_0
     239: istore        10
     241: aload         9
     243: invokeinterface #86,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     248: astore        11
     250: aload         11
     252: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     257: ifeq          492
     260: aload         11
     262: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     267: astore        12
     269: aload         12
     271: checkcast     #154                // class Day11Kt$main$Monkey
     274: astore        13
     276: iconst_0
     277: istore        14
     279: aload         13
     281: invokevirtual #248                // Method Day11Kt$main$Monkey.getItems:()Ljava/util/List;
     284: checkcast     #50                 // class java/lang/Iterable
     287: astore        15
     289: iconst_0
     290: istore        16
     292: aload         15
     294: invokeinterface #86,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     299: astore        17
     301: aload         17
     303: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     308: ifeq          476
     311: aload         17
     313: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     318: astore        18
     320: aload         18
     322: checkcast     #241                // class java/lang/Number
     325: invokevirtual #244                // Method java/lang/Number.longValue:()J
     328: lstore        19
     330: iconst_0
     331: istore        21
     333: aload         13
     335: invokevirtual #251                // Method Day11Kt$main$Monkey.getInspections:()J
     338: lstore        22
     340: aload         13
     342: lload         22
     344: lconst_1
     345: ladd
     346: invokevirtual #254                // Method Day11Kt$main$Monkey.setInspections:(J)V
     349: aload         13
     351: invokevirtual #257                // Method Day11Kt$main$Monkey.getOperation:()Ljava/lang/String;
     354: lload         19
     356: invokestatic  #259                // Method main$operation:(Ljava/lang/String;J)J
     359: lstore        22
     361: aload_2
     362: lload         22
     364: invokestatic  #132                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     367: lload         4
     369: invokestatic  #132                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     372: invokeinterface #265,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     377: checkcast     #241                // class java/lang/Number
     380: invokevirtual #244                // Method java/lang/Number.longValue:()J
     383: lstore        24
     385: lload         24
     387: aload         13
     389: invokevirtual #234                // Method Day11Kt$main$Monkey.getDivisor:()J
     392: invokestatic  #267                // Method divisibleBy:(JJ)Z
     395: ifeq          436
     398: lload         24
     400: invokestatic  #132                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     403: astore        26
     405: aload_3
     406: aload         13
     408: invokevirtual #271                // Method Day11Kt$main$Monkey.getTrueMonkey:()I
     411: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     416: checkcast     #154                // class Day11Kt$main$Monkey
     419: invokevirtual #248                // Method Day11Kt$main$Monkey.getItems:()Ljava/util/List;
     422: checkcast     #82                 // class java/util/Collection
     425: aload         26
     427: invokeinterface #136,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     432: pop
     433: goto          471
     436: lload         24
     438: invokestatic  #132                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     441: astore        26
     443: aload_3
     444: aload         13
     446: invokevirtual #274                // Method Day11Kt$main$Monkey.getFalseMonkey:()I
     449: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     454: checkcast     #154                // class Day11Kt$main$Monkey
     457: invokevirtual #248                // Method Day11Kt$main$Monkey.getItems:()Ljava/util/List;
     460: checkcast     #82                 // class java/util/Collection
     463: aload         26
     465: invokeinterface #136,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     470: pop
     471: nop
     472: nop
     473: goto          301
     476: nop
     477: aload         13
     479: invokevirtual #248                // Method Day11Kt$main$Monkey.getItems:()Ljava/util/List;
     482: invokeinterface #277,  1          // InterfaceMethod java/util/List.clear:()V
     487: nop
     488: nop
     489: goto          250
     492: nop
     493: nop
     494: iinc          6, 1
     497: goto          219
     500: aload_3
     501: checkcast     #50                 // class java/lang/Iterable
     504: astore        6
     506: nop
     507: iconst_0
     508: istore        7
     510: aload         6
     512: astore        8
     514: new           #72                 // class java/util/ArrayList
     517: dup
     518: aload         6
     520: bipush        10
     522: invokestatic  #76                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     525: invokespecial #80                 // Method java/util/ArrayList."<init>":(I)V
     528: checkcast     #82                 // class java/util/Collection
     531: astore        9
     533: iconst_0
     534: istore        10
     536: aload         8
     538: invokeinterface #86,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     543: astore        11
     545: aload         11
     547: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     552: ifeq          598
     555: aload         11
     557: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     562: astore        12
     564: aload         9
     566: aload         12
     568: checkcast     #154                // class Day11Kt$main$Monkey
     571: astore        13
     573: astore        27
     575: iconst_0
     576: istore        14
     578: aload         13
     580: invokevirtual #251                // Method Day11Kt$main$Monkey.getInspections:()J
     583: invokestatic  #132                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     586: aload         27
     588: swap
     589: invokeinterface #136,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     594: pop
     595: goto          545
     598: aload         9
     600: checkcast     #102                // class java/util/List
     603: nop
     604: checkcast     #50                 // class java/lang/Iterable
     607: invokestatic  #281                // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
     610: iconst_2
     611: invokestatic  #285                // Method kotlin/collections/CollectionsKt.takeLast:(Ljava/util/List;I)Ljava/util/List;
     614: checkcast     #50                 // class java/lang/Iterable
     617: astore        6
     619: nop
     620: iconst_0
     621: istore        7
     623: aload         6
     625: invokeinterface #86,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     630: astore        8
     632: aload         8
     634: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     639: ifne          652
     642: new           #236                // class java/lang/UnsupportedOperationException
     645: dup
     646: ldc           #238                // String Empty collection can\'t be reduced.
     648: invokespecial #239                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     651: athrow
     652: aload         8
     654: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     659: astore        9
     661: aload         8
     663: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     668: ifeq          712
     671: aload         9
     673: aload         8
     675: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     680: checkcast     #241                // class java/lang/Number
     683: invokevirtual #244                // Method java/lang/Number.longValue:()J
     686: lstore        10
     688: checkcast     #241                // class java/lang/Number
     691: invokevirtual #244                // Method java/lang/Number.longValue:()J
     694: lstore        12
     696: iconst_0
     697: istore        14
     699: lload         12
     701: lload         10
     703: lmul
     704: invokestatic  #132                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     707: astore        9
     709: goto          661
     712: aload         9
     714: checkcast     #241                // class java/lang/Number
     717: invokevirtual #244                // Method java/lang/Number.longValue:()J
     720: lreturn

  private static final long main$part1$lambda$9(long, long);
    Code:
       0: lload_0
       1: l2d
       2: ldc2_w        #313                // double 3.0d
       5: ddiv
       6: invokestatic  #320                // Method java/lang/Math.floor:(D)D
       9: d2l
      10: lreturn

  private static final long main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: bipush        20
       3: invokedynamic #337,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;
       8: invokestatic  #339                // Method main$common:(Ljava/util/List;ILkotlin/jvm/functions/Function2;)J
      11: lreturn

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

  private static final long main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: sipush        10000
       4: invokedynamic #344,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function2;
       9: invokestatic  #339                // Method main$common:(Ljava/util/List;ILkotlin/jvm/functions/Function2;)J
      12: lreturn
}


private sealed class Packet : Comparable<Packet> {
    companion object {
        fun of(input: String): Packet =
            of(input.split("""((?<=[\[\],])|(?=[\[\],]))""".toRegex())
                    .filter { it.isNotBlank() }
                    .filter { it != "," }
                    .iterator()
            )

        private fun of(input: Iterator<String>): Packet {
            val packets = mutableListOf<Packet>()
            while (input.hasNext()) {
                when (val symbol = input.next()) {
                    "]" -> return ListPacket(packets)
                    "[" -> packets.add(of(input))
                    else -> packets.add(IntPacket(symbol.toInt()))
                }
            }
            return ListPacket(packets)
        }
    }
}

private class IntPacket(val amount: Int) : Packet() {
    fun asList(): Packet = ListPacket(listOf(this))

    override fun compareTo(other: Packet): Int =
        when (other) {
            is IntPacket -> amount.compareTo(other.amount)
            is ListPacket -> asList().compareTo(other)
        }
}

private class ListPacket(val subPackets: List<Packet>) : Packet() {
    override fun compareTo(other: Packet): Int =
        when (other) {
            is IntPacket -> compareTo(other.asList())
            is ListPacket -> subPackets.zip(other.subPackets)
                .map { it.first.compareTo(it.second) }
                .firstOrNull { it != 0 } ?: subPackets.size.compareTo(other.subPackets.size)
        }
}

fun main() {

    fun parse(input: List<String>): Sequence<Packet> {
        return input.asSequence().filter { it.isNotBlank() }.map { Packet.of(it) }
    }

    fun part1(input: List<String>): Int {
        return parse(input)
                .chunked(2)
                .mapIndexed { index, (first, second) ->
                    if (first < second) index + 1 else 0
                }.sum()
    }

    fun part2(input: List<String>): Int {
        val packets = parse(input)
        val divider1 = Packet.of("[[2]]")
        val divider2 = Packet.of("[[6]]")
        val ordered = (packets + divider1 + divider2).sorted()
        return (ordered.indexOf(divider1) + 1) * (ordered.indexOf(divider2) + 1)
    }

    val input = readInput("inputs/Day13")
    println(part1(input))
    println(part2(input))
}

Compiled from "Day13.kt"
public final class Day13Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String inputs/Day13
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)I
      10: istore_1
      11: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      14: iload_1
      15: invokevirtual #30                 // Method java/io/PrintStream.println:(I)V
      18: aload_0
      19: invokestatic  #33                 // Method main$part2:(Ljava/util/List;)I
      22: istore_1
      23: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      26: iload_1
      27: invokevirtual #30                 // Method java/io/PrintStream.println:(I)V
      30: return

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

  private static final boolean main$parse$lambda$0(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #44                 // String it
       3: invokestatic  #50                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #52                 // class java/lang/CharSequence
      10: invokestatic  #58                 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z
      13: ifne          20
      16: iconst_1
      17: goto          21
      20: iconst_0
      21: ireturn

  private static final Packet main$parse$lambda$1(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #44                 // String it
       3: invokestatic  #50                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: getstatic     #67                 // Field Packet.Companion:LPacket$Companion;
       9: aload_0
      10: invokevirtual #72                 // Method Packet$Companion.of:(Ljava/lang/String;)LPacket;
      13: areturn

  private static final kotlin.sequences.Sequence<Packet> main$parse(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #77                 // class java/lang/Iterable
       4: invokestatic  #83                 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;
       7: invokedynamic #101,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      12: invokestatic  #107                // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      15: invokedynamic #112,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
      20: invokestatic  #115                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      23: areturn

  private static final int main$part1$lambda$2(int, java.util.List);
    Code:
       0: aload_1
       1: ldc           #119                // String <destruct>
       3: invokestatic  #50                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: iconst_0
       8: invokeinterface #125,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      13: checkcast     #63                 // class Packet
      16: astore_2
      17: aload_1
      18: iconst_1
      19: invokeinterface #125,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      24: checkcast     #63                 // class Packet
      27: astore_3
      28: aload_2
      29: aload_3
      30: invokevirtual #129                // Method Packet.compareTo:(Ljava/lang/Object;)I
      33: ifge          42
      36: iload_0
      37: iconst_1
      38: iadd
      39: goto          43
      42: iconst_0
      43: ireturn

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #137                // Method main$parse:(Ljava/util/List;)Lkotlin/sequences/Sequence;
       4: iconst_2
       5: invokestatic  #141                // Method kotlin/sequences/SequencesKt.chunked:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;
       8: invokedynamic #151,  0            // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function2;
      13: invokestatic  #155                // Method kotlin/sequences/SequencesKt.mapIndexed:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;
      16: invokestatic  #159                // Method kotlin/sequences/SequencesKt.sumOfInt:(Lkotlin/sequences/Sequence;)I
      19: ireturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #137                // Method main$parse:(Ljava/util/List;)Lkotlin/sequences/Sequence;
       4: astore_1
       5: getstatic     #67                 // Field Packet.Companion:LPacket$Companion;
       8: ldc           #161                // String [[2]]
      10: invokevirtual #72                 // Method Packet$Companion.of:(Ljava/lang/String;)LPacket;
      13: astore_2
      14: getstatic     #67                 // Field Packet.Companion:LPacket$Companion;
      17: ldc           #163                // String [[6]]
      19: invokevirtual #72                 // Method Packet$Companion.of:(Ljava/lang/String;)LPacket;
      22: astore_3
      23: aload_1
      24: aload_2
      25: invokestatic  #167                // Method kotlin/sequences/SequencesKt.plus:(Lkotlin/sequences/Sequence;Ljava/lang/Object;)Lkotlin/sequences/Sequence;
      28: aload_3
      29: invokestatic  #167                // Method kotlin/sequences/SequencesKt.plus:(Lkotlin/sequences/Sequence;Ljava/lang/Object;)Lkotlin/sequences/Sequence;
      32: invokestatic  #171                // Method kotlin/sequences/SequencesKt.sorted:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
      35: astore        4
      37: aload         4
      39: aload_2
      40: invokestatic  #175                // Method kotlin/sequences/SequencesKt.indexOf:(Lkotlin/sequences/Sequence;Ljava/lang/Object;)I
      43: iconst_1
      44: iadd
      45: aload         4
      47: aload_3
      48: invokestatic  #175                // Method kotlin/sequences/SequencesKt.indexOf:(Lkotlin/sequences/Sequence;Ljava/lang/Object;)I
      51: iconst_1
      52: iadd
      53: imul
      54: ireturn
}


fun main() {

    fun Set<Char>.score(): Int {
        val c = single()
        return if (c.isLowerCase()) {
            1 + (c - 'a')
        } else {
            27 + (c - 'A')
        }
    }

    fun String.halve(): List<String> {
        val half = length / 2
        return listOf(substring(0, half), substring(half))
    }

    fun part1(input: List<String>) =
        input.sumOf { item ->
            val (first, second) = item.halve()
            (first intersect second).score()
        }

    fun part2(input: List<String>) =
        input
            .chunked(3)
            .sumOf {
                it.fold(it[0].toSet()) {
                    acc, s -> acc intersect s
                }
                .score()
            }

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

infix fun String.intersect(o: String) = toSet() intersect o.toSet()
infix fun Set<Char>.intersect(o: String) = this intersect o.toSet()

Compiled from "Day03.kt"
public final class Day03Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String inputs/Day03
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)I
      10: istore_1
      11: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      14: iload_1
      15: invokevirtual #30                 // Method java/io/PrintStream.println:(I)V
      18: aload_0
      19: invokestatic  #33                 // Method main$part2:(Ljava/util/List;)I
      22: istore_1
      23: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      26: iload_1
      27: invokevirtual #30                 // Method java/io/PrintStream.println:(I)V
      30: return

  public static final java.util.Set<java.lang.Character> intersect(java.lang.String, java.lang.String);
    Code:
       0: aload_0
       1: ldc           #41                 // String <this>
       3: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #49                 // String o
       9: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: checkcast     #51                 // class java/lang/CharSequence
      16: invokestatic  #57                 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;
      19: checkcast     #59                 // class java/lang/Iterable
      22: aload_1
      23: checkcast     #51                 // class java/lang/CharSequence
      26: invokestatic  #57                 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;
      29: checkcast     #59                 // class java/lang/Iterable
      32: invokestatic  #64                 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
      35: areturn

  public static final java.util.Set<java.lang.Character> intersect(java.util.Set<java.lang.Character>, java.lang.String);
    Code:
       0: aload_0
       1: ldc           #41                 // String <this>
       3: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #49                 // String o
       9: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: checkcast     #59                 // class java/lang/Iterable
      16: aload_1
      17: checkcast     #51                 // class java/lang/CharSequence
      20: invokestatic  #57                 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;
      23: checkcast     #59                 // class java/lang/Iterable
      26: invokestatic  #64                 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
      29: areturn

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

  private static final int main$score(java.util.Set<java.lang.Character>);
    Code:
       0: aload_0
       1: checkcast     #59                 // class java/lang/Iterable
       4: invokestatic  #81                 // Method kotlin/collections/CollectionsKt.single:(Ljava/lang/Iterable;)Ljava/lang/Object;
       7: checkcast     #83                 // class java/lang/Character
      10: invokevirtual #87                 // Method java/lang/Character.charValue:()C
      13: istore_1
      14: iload_1
      15: invokestatic  #91                 // Method java/lang/Character.isLowerCase:(C)Z
      18: ifeq          30
      21: iconst_1
      22: iload_1
      23: bipush        97
      25: isub
      26: iadd
      27: goto          37
      30: bipush        27
      32: iload_1
      33: bipush        65
      35: isub
      36: iadd
      37: ireturn

  private static final java.util.List<java.lang.String> main$halve(java.lang.String);
    Code:
       0: aload_0
       1: invokevirtual #102                // Method java/lang/String.length:()I
       4: iconst_2
       5: idiv
       6: istore_1
       7: iconst_2
       8: anewarray     #98                 // class java/lang/String
      11: astore_2
      12: aload_2
      13: iconst_0
      14: aload_0
      15: iconst_0
      16: iload_1
      17: invokevirtual #106                // Method java/lang/String.substring:(II)Ljava/lang/String;
      20: dup
      21: ldc           #108                // String substring(...)
      23: invokestatic  #111                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      26: aastore
      27: aload_2
      28: iconst_1
      29: aload_0
      30: iload_1
      31: invokevirtual #114                // Method java/lang/String.substring:(I)Ljava/lang/String;
      34: dup
      35: ldc           #108                // String substring(...)
      37: invokestatic  #111                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      40: aastore
      41: aload_2
      42: invokestatic  #118                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      45: areturn

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #59                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: invokeinterface #126,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      13: astore_3
      14: aload_3
      15: invokeinterface #132,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      20: ifeq          98
      23: aload_3
      24: invokeinterface #136,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      29: astore        4
      31: iload_2
      32: aload         4
      34: checkcast     #98                 // class java/lang/String
      37: astore        5
      39: istore        10
      41: iconst_0
      42: istore        6
      44: aload         5
      46: invokestatic  #138                // Method main$halve:(Ljava/lang/String;)Ljava/util/List;
      49: astore        7
      51: aload         7
      53: iconst_0
      54: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      59: checkcast     #98                 // class java/lang/String
      62: astore        8
      64: aload         7
      66: iconst_1
      67: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      72: checkcast     #98                 // class java/lang/String
      75: astore        9
      77: aload         8
      79: aload         9
      81: invokestatic  #146                // Method intersect:(Ljava/lang/String;Ljava/lang/String;)Ljava/util/Set;
      84: invokestatic  #148                // Method main$score:(Ljava/util/Set;)I
      87: istore        11
      89: iload         10
      91: iload         11
      93: iadd
      94: istore_2
      95: goto          14
      98: iload_2
      99: ireturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #59                 // class java/lang/Iterable
       4: iconst_3
       5: invokestatic  #156                // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;
       8: checkcast     #59                 // class java/lang/Iterable
      11: astore_1
      12: iconst_0
      13: istore_2
      14: aload_1
      15: invokeinterface #126,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      20: astore_3
      21: aload_3
      22: invokeinterface #132,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      27: ifeq          151
      30: aload_3
      31: invokeinterface #136,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      36: astore        4
      38: iload_2
      39: aload         4
      41: checkcast     #140                // class java/util/List
      44: astore        5
      46: istore        16
      48: iconst_0
      49: istore        6
      51: aload         5
      53: checkcast     #59                 // class java/lang/Iterable
      56: astore        7
      58: aload         5
      60: iconst_0
      61: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      66: checkcast     #51                 // class java/lang/CharSequence
      69: invokestatic  #57                 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;
      72: astore        8
      74: iconst_0
      75: istore        9
      77: aload         8
      79: astore        10
      81: aload         7
      83: invokeinterface #126,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      88: astore        11
      90: aload         11
      92: invokeinterface #132,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      97: ifeq          135
     100: aload         11
     102: invokeinterface #136,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     107: astore        12
     109: aload         10
     111: aload         12
     113: checkcast     #98                 // class java/lang/String
     116: astore        13
     118: astore        14
     120: iconst_0
     121: istore        15
     123: aload         14
     125: aload         13
     127: invokestatic  #158                // Method intersect:(Ljava/util/Set;Ljava/lang/String;)Ljava/util/Set;
     130: astore        10
     132: goto          90
     135: aload         10
     137: invokestatic  #148                // Method main$score:(Ljava/util/Set;)I
     140: istore        17
     142: iload         16
     144: iload         17
     146: iadd
     147: istore_2
     148: goto          21
     151: iload_2
     152: ireturn
}


import Sign.*
import java.lang.RuntimeException

enum class Sign { ROCK, PAPER, SCISSORS }
data class Round(val opponent: Sign, val mine: Sign) {

    private fun signPoints() =
        when (mine) {
            ROCK -> 1
            PAPER -> 2
            SCISSORS -> 3
        }

    private fun matchPoints() =
        when (mine) {
            ROCK -> when (opponent) {
                ROCK -> 3
                PAPER -> 0
                SCISSORS -> 6
            }

            PAPER -> when (opponent) {
                ROCK -> 6
                PAPER -> 3
                SCISSORS -> 0
            }

            SCISSORS -> when (opponent) {
                ROCK -> 0
                PAPER -> 6
                SCISSORS -> 3
            }
        }

    fun totalPoints() = signPoints() + matchPoints()
}

fun main() {

    fun part1(input: List<String>): Int {
        return input
            .map { it.split(" ") }
            .map {
                it.map { sign ->
                    when (sign) {
                        "A", "X" -> ROCK
                        "B", "Y" -> PAPER
                        "C", "Z" -> SCISSORS
                        else -> throw RuntimeException()
                    }
                }
            }
            .map { (opponent, mine) -> Round(opponent, mine) }
            .sumOf { it.totalPoints() }
    }

    fun part2(input: List<String>): Int {
        val signs = listOf(ROCK, SCISSORS, PAPER)

        return input
            .map { it.split(" ") }
            .map { (opponentSign, mySign) ->
                val opponent = when (opponentSign) {
                    "A" -> ROCK
                    "B" -> PAPER
                    "C" -> SCISSORS
                    else -> throw RuntimeException()
                }

                val mine = when (mySign) {
                    "X" -> signs[(signs.indexOf(opponent) + 1) % signs.size]
                    "Y" -> opponent
                    "Z" -> signs[(signs.indexOf(opponent) + 2) % signs.size]
                    else -> throw RuntimeException()
                }
                Round(opponent, mine)
            }
            .sumOf { it.totalPoints() }
    }

    val input = readInput("inputs/Day02")
    println(part1(input))
    println(part2(input))
}

Compiled from "Day02.kt"
public final class Day02Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String inputs/Day02
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)I
      10: istore_1
      11: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      14: iload_1
      15: invokevirtual #30                 // Method java/io/PrintStream.println:(I)V
      18: aload_0
      19: invokestatic  #33                 // Method main$part2:(Ljava/util/List;)I
      22: istore_1
      23: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      26: iload_1
      27: invokevirtual #30                 // Method java/io/PrintStream.println:(I)V
      30: return

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

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #43                 // class java/lang/Iterable
       4: astore_1
       5: nop
       6: iconst_0
       7: istore_2
       8: aload_1
       9: astore_3
      10: new           #45                 // class java/util/ArrayList
      13: dup
      14: aload_1
      15: bipush        10
      17: invokestatic  #51                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      20: invokespecial #54                 // Method java/util/ArrayList."<init>":(I)V
      23: checkcast     #56                 // class java/util/Collection
      26: astore        4
      28: iconst_0
      29: istore        5
      31: aload_3
      32: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        6
      39: aload         6
      41: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          111
      49: aload         6
      51: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        7
      58: aload         4
      60: aload         7
      62: checkcast     #72                 // class java/lang/String
      65: astore        8
      67: astore        21
      69: iconst_0
      70: istore        9
      72: aload         8
      74: checkcast     #74                 // class java/lang/CharSequence
      77: iconst_1
      78: anewarray     #72                 // class java/lang/String
      81: astore        10
      83: aload         10
      85: iconst_0
      86: ldc           #76                 // String
      88: aastore
      89: aload         10
      91: iconst_0
      92: iconst_0
      93: bipush        6
      95: aconst_null
      96: invokestatic  #82                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      99: aload         21
     101: swap
     102: invokeinterface #86,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     107: pop
     108: goto          39
     111: aload         4
     113: checkcast     #88                 // class java/util/List
     116: nop
     117: checkcast     #43                 // class java/lang/Iterable
     120: astore_1
     121: nop
     122: iconst_0
     123: istore_2
     124: aload_1
     125: astore_3
     126: new           #45                 // class java/util/ArrayList
     129: dup
     130: aload_1
     131: bipush        10
     133: invokestatic  #51                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     136: invokespecial #54                 // Method java/util/ArrayList."<init>":(I)V
     139: checkcast     #56                 // class java/util/Collection
     142: astore        4
     144: iconst_0
     145: istore        5
     147: aload_3
     148: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     153: astore        6
     155: aload         6
     157: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     162: ifeq          468
     165: aload         6
     167: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     172: astore        7
     174: aload         4
     176: aload         7
     178: checkcast     #88                 // class java/util/List
     181: astore        8
     183: astore        21
     185: iconst_0
     186: istore        9
     188: aload         8
     190: checkcast     #43                 // class java/lang/Iterable
     193: astore        10
     195: iconst_0
     196: istore        11
     198: aload         10
     200: astore        12
     202: new           #45                 // class java/util/ArrayList
     205: dup
     206: aload         10
     208: bipush        10
     210: invokestatic  #51                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     213: invokespecial #54                 // Method java/util/ArrayList."<init>":(I)V
     216: checkcast     #56                 // class java/util/Collection
     219: astore        13
     221: iconst_0
     222: istore        14
     224: aload         12
     226: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     231: astore        15
     233: aload         15
     235: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     240: ifeq          449
     243: aload         15
     245: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     250: astore        16
     252: aload         13
     254: aload         16
     256: checkcast     #72                 // class java/lang/String
     259: astore        17
     261: astore        18
     263: iconst_0
     264: istore        19
     266: aload         17
     268: astore        20
     270: aload         20
     272: invokevirtual #92                 // Method java/lang/String.hashCode:()I
     275: lookupswitch  { // 6
                    65: 332
                    66: 345
                    67: 358
                    88: 371
                    89: 384
                    90: 397
               default: 428
          }
     332: aload         20
     334: ldc           #94                 // String A
     336: invokevirtual #97                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     339: ifne          410
     342: goto          428
     345: aload         20
     347: ldc           #99                 // String B
     349: invokevirtual #97                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     352: ifne          416
     355: goto          428
     358: aload         20
     360: ldc           #101                // String C
     362: invokevirtual #97                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     365: ifne          422
     368: goto          428
     371: aload         20
     373: ldc           #103                // String X
     375: invokevirtual #97                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     378: ifne          410
     381: goto          428
     384: aload         20
     386: ldc           #105                // String Y
     388: invokevirtual #97                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     391: ifne          416
     394: goto          428
     397: aload         20
     399: ldc           #107                // String Z
     401: invokevirtual #97                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     404: ifne          422
     407: goto          428
     410: getstatic     #113                // Field Sign.ROCK:LSign;
     413: goto          436
     416: getstatic     #116                // Field Sign.PAPER:LSign;
     419: goto          436
     422: getstatic     #119                // Field Sign.SCISSORS:LSign;
     425: goto          436
     428: new           #121                // class java/lang/RuntimeException
     431: dup
     432: invokespecial #123                // Method java/lang/RuntimeException."<init>":()V
     435: athrow
     436: nop
     437: aload         18
     439: swap
     440: invokeinterface #86,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     445: pop
     446: goto          233
     449: aload         13
     451: checkcast     #88                 // class java/util/List
     454: nop
     455: nop
     456: aload         21
     458: swap
     459: invokeinterface #86,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     464: pop
     465: goto          155
     468: aload         4
     470: checkcast     #88                 // class java/util/List
     473: nop
     474: checkcast     #43                 // class java/lang/Iterable
     477: astore_1
     478: nop
     479: iconst_0
     480: istore_2
     481: aload_1
     482: astore_3
     483: new           #45                 // class java/util/ArrayList
     486: dup
     487: aload_1
     488: bipush        10
     490: invokestatic  #51                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     493: invokespecial #54                 // Method java/util/ArrayList."<init>":(I)V
     496: checkcast     #56                 // class java/util/Collection
     499: astore        4
     501: iconst_0
     502: istore        5
     504: aload_3
     505: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     510: astore        6
     512: aload         6
     514: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     519: ifeq          594
     522: aload         6
     524: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     529: astore        7
     531: aload         4
     533: aload         7
     535: checkcast     #88                 // class java/util/List
     538: astore        8
     540: astore        21
     542: iconst_0
     543: istore        9
     545: aload         8
     547: iconst_0
     548: invokeinterface #127,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     553: checkcast     #109                // class Sign
     556: astore        10
     558: aload         8
     560: iconst_1
     561: invokeinterface #127,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     566: checkcast     #109                // class Sign
     569: astore        11
     571: new           #129                // class Round
     574: dup
     575: aload         10
     577: aload         11
     579: invokespecial #132                // Method Round."<init>":(LSign;LSign;)V
     582: aload         21
     584: swap
     585: invokeinterface #86,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     590: pop
     591: goto          512
     594: aload         4
     596: checkcast     #88                 // class java/util/List
     599: nop
     600: checkcast     #43                 // class java/lang/Iterable
     603: astore_1
     604: iconst_0
     605: istore_2
     606: aload_1
     607: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     612: astore_3
     613: aload_3
     614: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     619: ifeq          659
     622: aload_3
     623: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     628: astore        4
     630: iload_2
     631: aload         4
     633: checkcast     #129                // class Round
     636: astore        5
     638: istore        21
     640: iconst_0
     641: istore        6
     643: aload         5
     645: invokevirtual #135                // Method Round.totalPoints:()I
     648: istore        22
     650: iload         21
     652: iload         22
     654: iadd
     655: istore_2
     656: goto          613
     659: iload_2
     660: ireturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: iconst_3
       1: anewarray     #109                // class Sign
       4: astore_2
       5: aload_2
       6: iconst_0
       7: getstatic     #113                // Field Sign.ROCK:LSign;
      10: aastore
      11: aload_2
      12: iconst_1
      13: getstatic     #119                // Field Sign.SCISSORS:LSign;
      16: aastore
      17: aload_2
      18: iconst_2
      19: getstatic     #116                // Field Sign.PAPER:LSign;
      22: aastore
      23: aload_2
      24: invokestatic  #160                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      27: astore_1
      28: aload_0
      29: checkcast     #43                 // class java/lang/Iterable
      32: astore_2
      33: nop
      34: iconst_0
      35: istore_3
      36: aload_2
      37: astore        4
      39: new           #45                 // class java/util/ArrayList
      42: dup
      43: aload_2
      44: bipush        10
      46: invokestatic  #51                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      49: invokespecial #54                 // Method java/util/ArrayList."<init>":(I)V
      52: checkcast     #56                 // class java/util/Collection
      55: astore        5
      57: iconst_0
      58: istore        6
      60: aload         4
      62: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      67: astore        7
      69: aload         7
      71: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      76: ifeq          141
      79: aload         7
      81: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      86: astore        8
      88: aload         5
      90: aload         8
      92: checkcast     #72                 // class java/lang/String
      95: astore        9
      97: astore        16
      99: iconst_0
     100: istore        10
     102: aload         9
     104: checkcast     #74                 // class java/lang/CharSequence
     107: iconst_1
     108: anewarray     #72                 // class java/lang/String
     111: astore        11
     113: aload         11
     115: iconst_0
     116: ldc           #76                 // String
     118: aastore
     119: aload         11
     121: iconst_0
     122: iconst_0
     123: bipush        6
     125: aconst_null
     126: invokestatic  #82                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     129: aload         16
     131: swap
     132: invokeinterface #86,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     137: pop
     138: goto          69
     141: aload         5
     143: checkcast     #88                 // class java/util/List
     146: nop
     147: checkcast     #43                 // class java/lang/Iterable
     150: astore_2
     151: nop
     152: iconst_0
     153: istore_3
     154: aload_2
     155: astore        4
     157: new           #45                 // class java/util/ArrayList
     160: dup
     161: aload_2
     162: bipush        10
     164: invokestatic  #51                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     167: invokespecial #54                 // Method java/util/ArrayList."<init>":(I)V
     170: checkcast     #56                 // class java/util/Collection
     173: astore        5
     175: iconst_0
     176: istore        6
     178: aload         4
     180: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     185: astore        7
     187: aload         7
     189: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     194: ifeq          519
     197: aload         7
     199: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     204: astore        8
     206: aload         5
     208: aload         8
     210: checkcast     #88                 // class java/util/List
     213: astore        9
     215: astore        16
     217: iconst_0
     218: istore        10
     220: aload         9
     222: iconst_0
     223: invokeinterface #127,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     228: checkcast     #72                 // class java/lang/String
     231: astore        11
     233: aload         9
     235: iconst_1
     236: invokeinterface #127,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     241: checkcast     #72                 // class java/lang/String
     244: astore        12
     246: aload         11
     248: astore        13
     250: aload         13
     252: invokevirtual #92                 // Method java/lang/String.hashCode:()I
     255: tableswitch   { // 65 to 67
                    65: 280
                    66: 293
                    67: 306
               default: 337
          }
     280: aload         13
     282: ldc           #94                 // String A
     284: invokevirtual #97                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     287: ifne          319
     290: goto          337
     293: aload         13
     295: ldc           #99                 // String B
     297: invokevirtual #97                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     300: ifne          325
     303: goto          337
     306: aload         13
     308: ldc           #101                // String C
     310: invokevirtual #97                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     313: ifne          331
     316: goto          337
     319: getstatic     #113                // Field Sign.ROCK:LSign;
     322: goto          345
     325: getstatic     #116                // Field Sign.PAPER:LSign;
     328: goto          345
     331: getstatic     #119                // Field Sign.SCISSORS:LSign;
     334: goto          345
     337: new           #121                // class java/lang/RuntimeException
     340: dup
     341: invokespecial #123                // Method java/lang/RuntimeException."<init>":()V
     344: athrow
     345: astore        14
     347: aload         12
     349: astore        15
     351: aload         15
     353: invokevirtual #92                 // Method java/lang/String.hashCode:()I
     356: tableswitch   { // 88 to 90
                    88: 384
                    89: 397
                    90: 410
               default: 486
          }
     384: aload         15
     386: ldc           #103                // String X
     388: invokevirtual #97                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     391: ifne          423
     394: goto          486
     397: aload         15
     399: ldc           #105                // String Y
     401: invokevirtual #97                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     404: ifne          452
     407: goto          486
     410: aload         15
     412: ldc           #107                // String Z
     414: invokevirtual #97                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     417: ifne          457
     420: goto          486
     423: aload_1
     424: aload_1
     425: aload         14
     427: invokeinterface #164,  2          // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I
     432: iconst_1
     433: iadd
     434: aload_1
     435: invokeinterface #167,  1          // InterfaceMethod java/util/List.size:()I
     440: irem
     441: invokeinterface #127,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     446: checkcast     #109                // class Sign
     449: goto          494
     452: aload         14
     454: goto          494
     457: aload_1
     458: aload_1
     459: aload         14
     461: invokeinterface #164,  2          // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I
     466: iconst_2
     467: iadd
     468: aload_1
     469: invokeinterface #167,  1          // InterfaceMethod java/util/List.size:()I
     474: irem
     475: invokeinterface #127,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     480: checkcast     #109                // class Sign
     483: goto          494
     486: new           #121                // class java/lang/RuntimeException
     489: dup
     490: invokespecial #123                // Method java/lang/RuntimeException."<init>":()V
     493: athrow
     494: astore        13
     496: new           #129                // class Round
     499: dup
     500: aload         14
     502: aload         13
     504: invokespecial #132                // Method Round."<init>":(LSign;LSign;)V
     507: aload         16
     509: swap
     510: invokeinterface #86,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     515: pop
     516: goto          187
     519: aload         5
     521: checkcast     #88                 // class java/util/List
     524: nop
     525: checkcast     #43                 // class java/lang/Iterable
     528: astore_2
     529: iconst_0
     530: istore_3
     531: aload_2
     532: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     537: astore        4
     539: aload         4
     541: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     546: ifeq          587
     549: aload         4
     551: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     556: astore        5
     558: iload_3
     559: aload         5
     561: checkcast     #129                // class Round
     564: astore        6
     566: istore        16
     568: iconst_0
     569: istore        7
     571: aload         6
     573: invokevirtual #135                // Method Round.totalPoints:()I
     576: istore        17
     578: iload         16
     580: iload         17
     582: iadd
     583: istore_3
     584: goto          539
     587: iload_3
     588: ireturn
}