import java.util.*
import kotlin.collections.ArrayList

fun main() {

    val day = "Day07"

    data class Directory(val name: String, var size: Int = 0)

    fun parseDirectorySizes(input: List<String>): List<Directory> {

        fun String.toFileSize() = split(" ")[0].toInt()

        data class State(val path: Stack<Directory>, val total: MutableList<Directory>) {

            fun addFile(fileSize: Int) {
                path.peek().size += fileSize
            }

            fun moveInto(name: String) {
                path.push(
                    Directory(
                        if (path.isEmpty()) {
                            name
                        } else {
                            "${path.peek().name.dropLastWhile { it == '/' }}/$name"
                        }
                    )
                )
            }

            fun moveUp() {
                val currentDir = path.pop()
                total.add(currentDir)
                if (path.isNotEmpty()) {
                    path.peek().size += currentDir.size
                }
            }

            fun moveToRoot() {
                while (path.isNotEmpty()) {
                    moveUp()
                }
            }
        }

        return input
            .filter { !it.startsWith("dir") }
            .filter { !it.startsWith("$ ls") }
            .fold(State(Stack(), ArrayList())) { state, s ->
                if (s == "$ cd ..") {
                    state.apply { moveUp() }
                } else if (s.startsWith("$ cd ")) {
                    state.apply {
                        moveInto(s.removePrefix("$ cd "))
                    }
                } else {
                    state.apply {
                        addFile(s.toFileSize())
                    }
                }
            }.apply { moveToRoot() }.total
    }

    fun part1(input: List<String>): Int {
        return parseDirectorySizes(input)
            .filter { it.size <= 100000 }
            .sumOf(Directory::size)
    }

    fun part2(input: List<String>): Int {
        val directories = parseDirectorySizes(input)
        val usedSpace = directories.first { it.name == "/" }.size
        val freeSpace = 70000000 - usedSpace
        val spaceNeeded = 30000000 - freeSpace

        return directories
            .filter { it.size >= spaceNeeded }
            .minBy { it.size }
            .size
    }

    // test if implementation meets criteria from the description, like:
    val testInput = readInput("${day}_test")
    val input = readInput(day)

    check(part1(testInput) == 95437)
    val result1 = part1(input)
    println(result1)
    check(result1 == 1908462)

    check(part2(testInput) == 24933642)
    val result2 = part2(input)
    println(result2)
    check(result2 == 3979145)
}

Compiled from "Day07.kt"
public final class Day07Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day07
       2: astore_0
       3: new           #10                 // class java/lang/StringBuilder
       6: dup
       7: invokespecial #13                 // Method java/lang/StringBuilder."<init>":()V
      10: aload_0
      11: invokevirtual #17                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      14: ldc           #19                 // String _test
      16: invokevirtual #17                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      19: invokevirtual #23                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      22: invokestatic  #29                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      25: astore_1
      26: aload_0
      27: invokestatic  #29                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      30: astore_2
      31: aload_1
      32: invokestatic  #33                 // Method main$part1:(Ljava/util/List;)I
      35: ldc           #34                 // int 95437
      37: if_icmpne     44
      40: iconst_1
      41: goto          45
      44: iconst_0
      45: ifne          58
      48: new           #36                 // class java/lang/IllegalStateException
      51: dup
      52: ldc           #38                 // String Check failed.
      54: invokespecial #41                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      57: athrow
      58: aload_2
      59: invokestatic  #33                 // Method main$part1:(Ljava/util/List;)I
      62: istore_3
      63: getstatic     #47                 // Field java/lang/System.out:Ljava/io/PrintStream;
      66: iload_3
      67: invokevirtual #53                 // Method java/io/PrintStream.println:(I)V
      70: iload_3
      71: ldc           #54                 // int 1908462
      73: if_icmpne     80
      76: iconst_1
      77: goto          81
      80: iconst_0
      81: ifne          94
      84: new           #36                 // class java/lang/IllegalStateException
      87: dup
      88: ldc           #38                 // String Check failed.
      90: invokespecial #41                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      93: athrow
      94: aload_1
      95: invokestatic  #57                 // Method main$part2:(Ljava/util/List;)I
      98: ldc           #58                 // int 24933642
     100: if_icmpne     107
     103: iconst_1
     104: goto          108
     107: iconst_0
     108: ifne          121
     111: new           #36                 // class java/lang/IllegalStateException
     114: dup
     115: ldc           #38                 // String Check failed.
     117: invokespecial #41                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     120: athrow
     121: aload_2
     122: invokestatic  #57                 // Method main$part2:(Ljava/util/List;)I
     125: istore        4
     127: getstatic     #47                 // Field java/lang/System.out:Ljava/io/PrintStream;
     130: iload         4
     132: invokevirtual #53                 // Method java/io/PrintStream.println:(I)V
     135: iload         4
     137: ldc           #59                 // int 3979145
     139: if_icmpne     146
     142: iconst_1
     143: goto          147
     146: iconst_0
     147: ifne          160
     150: new           #36                 // class java/lang/IllegalStateException
     153: dup
     154: ldc           #38                 // String Check failed.
     156: invokespecial #41                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     159: athrow
     160: return

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

  private static final int main$parseDirectorySizes$toFileSize(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #80                 // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #69                 // class java/lang/String
       8: astore_1
       9: aload_1
      10: iconst_0
      11: ldc           #82                 // String
      13: aastore
      14: aload_1
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #88                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: iconst_0
      24: invokeinterface #92,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      29: checkcast     #69                 // class java/lang/String
      32: invokestatic  #97                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      35: ireturn

  private static final java.util.List<Day07Kt$main$Directory> main$parseDirectorySizes(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #103                // class java/lang/Iterable
       4: astore_1
       5: nop
       6: iconst_0
       7: istore_2
       8: aload_1
       9: astore_3
      10: new           #105                // class java/util/ArrayList
      13: dup
      14: invokespecial #106                // Method java/util/ArrayList."<init>":()V
      17: checkcast     #108                // class java/util/Collection
      20: astore        4
      22: iconst_0
      23: istore        5
      25: aload_3
      26: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      31: astore        6
      33: aload         6
      35: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      40: ifeq          96
      43: aload         6
      45: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      50: astore        7
      52: aload         7
      54: checkcast     #69                 // class java/lang/String
      57: astore        8
      59: iconst_0
      60: istore        9
      62: aload         8
      64: ldc           #124                // String dir
      66: iconst_0
      67: iconst_2
      68: aconst_null
      69: invokestatic  #128                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
      72: ifne          79
      75: iconst_1
      76: goto          80
      79: iconst_0
      80: ifeq          33
      83: aload         4
      85: aload         7
      87: invokeinterface #132,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      92: pop
      93: goto          33
      96: aload         4
      98: checkcast     #71                 // class java/util/List
     101: nop
     102: checkcast     #103                // class java/lang/Iterable
     105: astore_1
     106: nop
     107: iconst_0
     108: istore_2
     109: aload_1
     110: astore_3
     111: new           #105                // class java/util/ArrayList
     114: dup
     115: invokespecial #106                // Method java/util/ArrayList."<init>":()V
     118: checkcast     #108                // class java/util/Collection
     121: astore        4
     123: iconst_0
     124: istore        5
     126: aload_3
     127: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     132: astore        6
     134: aload         6
     136: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     141: ifeq          197
     144: aload         6
     146: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     151: astore        7
     153: aload         7
     155: checkcast     #69                 // class java/lang/String
     158: astore        8
     160: iconst_0
     161: istore        9
     163: aload         8
     165: ldc           #134                // String $ ls
     167: iconst_0
     168: iconst_2
     169: aconst_null
     170: invokestatic  #128                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
     173: ifne          180
     176: iconst_1
     177: goto          181
     180: iconst_0
     181: ifeq          134
     184: aload         4
     186: aload         7
     188: invokeinterface #132,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     193: pop
     194: goto          134
     197: aload         4
     199: checkcast     #71                 // class java/util/List
     202: nop
     203: checkcast     #103                // class java/lang/Iterable
     206: astore_1
     207: new           #136                // class Day07Kt$main$parseDirectorySizes$State
     210: dup
     211: new           #138                // class java/util/Stack
     214: dup
     215: invokespecial #139                // Method java/util/Stack."<init>":()V
     218: new           #105                // class java/util/ArrayList
     221: dup
     222: invokespecial #106                // Method java/util/ArrayList."<init>":()V
     225: checkcast     #71                 // class java/util/List
     228: invokespecial #142                // Method Day07Kt$main$parseDirectorySizes$State."<init>":(Ljava/util/Stack;Ljava/util/List;)V
     231: astore_2
     232: iconst_0
     233: istore_3
     234: aload_2
     235: astore        4
     237: aload_1
     238: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     243: astore        5
     245: aload         5
     247: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     252: ifeq          384
     255: aload         5
     257: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     262: astore        6
     264: aload         4
     266: aload         6
     268: checkcast     #69                 // class java/lang/String
     271: astore        7
     273: astore        8
     275: iconst_0
     276: istore        9
     278: aload         7
     280: ldc           #144                // String $ cd ..
     282: invokestatic  #150                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     285: ifeq          309
     288: aload         8
     290: astore        10
     292: aload         10
     294: astore        11
     296: iconst_0
     297: istore        12
     299: aload         11
     301: invokevirtual #153                // Method Day07Kt$main$parseDirectorySizes$State.moveUp:()V
     304: aload         10
     306: goto          378
     309: aload         7
     311: ldc           #155                // String $ cd
     313: iconst_0
     314: iconst_2
     315: aconst_null
     316: invokestatic  #128                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
     319: ifeq          354
     322: aload         8
     324: astore        10
     326: aload         10
     328: astore        11
     330: iconst_0
     331: istore        12
     333: aload         11
     335: aload         7
     337: ldc           #155                // String $ cd
     339: checkcast     #80                 // class java/lang/CharSequence
     342: invokestatic  #159                // Method kotlin/text/StringsKt.removePrefix:(Ljava/lang/String;Ljava/lang/CharSequence;)Ljava/lang/String;
     345: invokevirtual #162                // Method Day07Kt$main$parseDirectorySizes$State.moveInto:(Ljava/lang/String;)V
     348: nop
     349: aload         10
     351: goto          378
     354: aload         8
     356: astore        10
     358: aload         10
     360: astore        11
     362: iconst_0
     363: istore        12
     365: aload         11
     367: aload         7
     369: invokestatic  #164                // Method main$parseDirectorySizes$toFileSize:(Ljava/lang/String;)I
     372: invokevirtual #167                // Method Day07Kt$main$parseDirectorySizes$State.addFile:(I)V
     375: nop
     376: aload         10
     378: nop
     379: astore        4
     381: goto          245
     384: aload         4
     386: astore_1
     387: aload_1
     388: astore_2
     389: iconst_0
     390: istore_3
     391: aload_2
     392: invokevirtual #170                // Method Day07Kt$main$parseDirectorySizes$State.moveToRoot:()V
     395: aload_1
     396: invokevirtual #174                // Method Day07Kt$main$parseDirectorySizes$State.getTotal:()Ljava/util/List;
     399: areturn

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #206                // Method main$parseDirectorySizes:(Ljava/util/List;)Ljava/util/List;
       4: checkcast     #103                // class java/lang/Iterable
       7: astore_1
       8: nop
       9: iconst_0
      10: istore_2
      11: aload_1
      12: astore_3
      13: new           #105                // class java/util/ArrayList
      16: dup
      17: invokespecial #106                // Method java/util/ArrayList."<init>":()V
      20: checkcast     #108                // class java/util/Collection
      23: astore        4
      25: iconst_0
      26: istore        5
      28: aload_3
      29: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      34: astore        6
      36: aload         6
      38: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      43: ifeq          96
      46: aload         6
      48: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      53: astore        7
      55: aload         7
      57: checkcast     #208                // class Day07Kt$main$Directory
      60: astore        8
      62: iconst_0
      63: istore        9
      65: aload         8
      67: invokevirtual #212                // Method Day07Kt$main$Directory.getSize:()I
      70: ldc           #213                // int 100000
      72: if_icmpgt     79
      75: iconst_1
      76: goto          80
      79: iconst_0
      80: ifeq          36
      83: aload         4
      85: aload         7
      87: invokeinterface #132,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      92: pop
      93: goto          36
      96: aload         4
      98: checkcast     #71                 // class java/util/List
     101: nop
     102: checkcast     #103                // class java/lang/Iterable
     105: astore_1
     106: iconst_0
     107: istore_2
     108: aload_1
     109: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     114: astore_3
     115: aload_3
     116: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     121: ifeq          161
     124: aload_3
     125: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     130: astore        4
     132: iload_2
     133: aload         4
     135: checkcast     #208                // class Day07Kt$main$Directory
     138: astore        5
     140: istore        10
     142: iconst_0
     143: istore        6
     145: aload         5
     147: invokevirtual #212                // Method Day07Kt$main$Directory.getSize:()I
     150: istore        11
     152: iload         10
     154: iload         11
     156: iadd
     157: istore_2
     158: goto          115
     161: iload_2
     162: ireturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #206                // Method main$parseDirectorySizes:(Ljava/util/List;)Ljava/util/List;
       4: astore_1
       5: aload_1
       6: checkcast     #103                // class java/lang/Iterable
       9: astore_3
      10: iconst_0
      11: istore        4
      13: aload_3
      14: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      19: astore        5
      21: aload         5
      23: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      28: ifeq          68
      31: aload         5
      33: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      38: astore        6
      40: aload         6
      42: checkcast     #208                // class Day07Kt$main$Directory
      45: astore        7
      47: iconst_0
      48: istore        8
      50: aload         7
      52: invokevirtual #220                // Method Day07Kt$main$Directory.getName:()Ljava/lang/String;
      55: ldc           #222                // String /
      57: invokestatic  #150                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      60: ifeq          21
      63: aload         6
      65: goto          78
      68: new           #224                // class java/util/NoSuchElementException
      71: dup
      72: ldc           #226                // String Collection contains no element matching the predicate.
      74: invokespecial #227                // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
      77: athrow
      78: checkcast     #208                // class Day07Kt$main$Directory
      81: invokevirtual #212                // Method Day07Kt$main$Directory.getSize:()I
      84: istore_2
      85: ldc           #228                // int 70000000
      87: iload_2
      88: isub
      89: istore_3
      90: ldc           #229                // int 30000000
      92: iload_3
      93: isub
      94: istore        4
      96: aload_1
      97: checkcast     #103                // class java/lang/Iterable
     100: astore        5
     102: nop
     103: iconst_0
     104: istore        6
     106: aload         5
     108: astore        7
     110: new           #105                // class java/util/ArrayList
     113: dup
     114: invokespecial #106                // Method java/util/ArrayList."<init>":()V
     117: checkcast     #108                // class java/util/Collection
     120: astore        8
     122: iconst_0
     123: istore        9
     125: aload         7
     127: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     132: astore        10
     134: aload         10
     136: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     141: ifeq          194
     144: aload         10
     146: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     151: astore        11
     153: aload         11
     155: checkcast     #208                // class Day07Kt$main$Directory
     158: astore        12
     160: iconst_0
     161: istore        13
     163: aload         12
     165: invokevirtual #212                // Method Day07Kt$main$Directory.getSize:()I
     168: iload         4
     170: if_icmplt     177
     173: iconst_1
     174: goto          178
     177: iconst_0
     178: ifeq          134
     181: aload         8
     183: aload         11
     185: invokeinterface #132,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     190: pop
     191: goto          134
     194: aload         8
     196: checkcast     #71                 // class java/util/List
     199: nop
     200: checkcast     #103                // class java/lang/Iterable
     203: astore        5
     205: nop
     206: iconst_0
     207: istore        6
     209: aload         5
     211: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     216: astore        7
     218: aload         7
     220: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     225: ifne          236
     228: new           #224                // class java/util/NoSuchElementException
     231: dup
     232: invokespecial #230                // Method java/util/NoSuchElementException."<init>":()V
     235: athrow
     236: aload         7
     238: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     243: astore        8
     245: aload         7
     247: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     252: ifne          260
     255: aload         8
     257: goto          330
     260: aload         8
     262: checkcast     #208                // class Day07Kt$main$Directory
     265: astore        9
     267: iconst_0
     268: istore        10
     270: aload         9
     272: invokevirtual #212                // Method Day07Kt$main$Directory.getSize:()I
     275: istore        9
     277: aload         7
     279: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     284: astore        10
     286: aload         10
     288: checkcast     #208                // class Day07Kt$main$Directory
     291: astore        11
     293: iconst_0
     294: istore        12
     296: aload         11
     298: invokevirtual #212                // Method Day07Kt$main$Directory.getSize:()I
     301: istore        11
     303: iload         9
     305: iload         11
     307: if_icmple     318
     310: aload         10
     312: astore        8
     314: iload         11
     316: istore        9
     318: aload         7
     320: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     325: ifne          277
     328: aload         8
     330: checkcast     #208                // class Day07Kt$main$Directory
     333: invokevirtual #212                // Method Day07Kt$main$Directory.getSize:()I
     336: ireturn
}

Compiled from "Day07.kt"
public final class Day07Kt$main$Directory {
  private final java.lang.String name;

  private int size;

  public Day07Kt$main$Directory(java.lang.String, int);
    Code:
       0: aload_1
       1: ldc           #8                  // String name
       3: invokestatic  #14                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #17                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_1
      12: putfield      #20                 // Field name:Ljava/lang/String;
      15: aload_0
      16: iload_2
      17: putfield      #24                 // Field size:I
      20: return

  public Day07Kt$main$Directory(java.lang.String, int, int, kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: iload_3
       1: iconst_2
       2: iand
       3: ifeq          8
       6: iconst_0
       7: istore_2
       8: aload_0
       9: aload_1
      10: iload_2
      11: invokespecial #29                 // Method "<init>":(Ljava/lang/String;I)V
      14: return

  public final java.lang.String getName();
    Code:
       0: aload_0
       1: getfield      #20                 // Field name:Ljava/lang/String;
       4: areturn

  public final int getSize();
    Code:
       0: aload_0
       1: getfield      #24                 // Field size:I
       4: ireturn

  public final void setSize(int);
    Code:
       0: aload_0
       1: iload_1
       2: putfield      #24                 // Field size:I
       5: return

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

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

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

  public static Day07Kt$main$Directory copy$default(Day07Kt$main$Directory, java.lang.String, int, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          11
       6: aload_0
       7: getfield      #20                 // Field name:Ljava/lang/String;
      10: astore_1
      11: iload_3
      12: iconst_2
      13: iand
      14: ifeq          22
      17: aload_0
      18: getfield      #24                 // Field size:I
      21: istore_2
      22: aload_0
      23: aload_1
      24: iload_2
      25: invokevirtual #44                 // Method copy:(Ljava/lang/String;I)LDay07Kt$main$Directory;
      28: areturn

  public java.lang.String toString();
    Code:
       0: new           #47                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #48                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #50                 // String Directory(name=
       9: invokevirtual #54                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #20                 // Field name:Ljava/lang/String;
      16: invokevirtual #54                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      19: ldc           #56                 // String , size=
      21: invokevirtual #54                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #24                 // Field size:I
      28: invokevirtual #59                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: bipush        41
      33: invokevirtual #62                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      36: invokevirtual #64                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      39: areturn

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

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class Day07Kt$main$Directory
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class Day07Kt$main$Directory
      20: astore_2
      21: aload_0
      22: getfield      #20                 // Field name:Ljava/lang/String;
      25: aload_2
      26: getfield      #20                 // Field name:Ljava/lang/String;
      29: invokestatic  #81                 // 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      #24                 // Field size:I
      41: aload_2
      42: getfield      #24                 // Field size:I
      45: if_icmpeq     50
      48: iconst_0
      49: ireturn
      50: iconst_1
      51: ireturn
}

Compiled from "Day07.kt"
public final class Day07Kt$main$parseDirectorySizes$State {
  private final java.util.Stack<Day07Kt$main$Directory> path;

  private final java.util.List<Day07Kt$main$Directory> total;

  public Day07Kt$main$parseDirectorySizes$State(java.util.Stack<Day07Kt$main$Directory>, java.util.List<Day07Kt$main$Directory>);
    Code:
       0: aload_1
       1: ldc           #9                  // String path
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #17                 // String total
       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 path:Ljava/util/Stack;
      21: aload_0
      22: aload_2
      23: putfield      #26                 // Field total:Ljava/util/List;
      26: return

  public final java.util.Stack<Day07Kt$main$Directory> getPath();
    Code:
       0: aload_0
       1: getfield      #23                 // Field path:Ljava/util/Stack;
       4: areturn

  public final java.util.List<Day07Kt$main$Directory> getTotal();
    Code:
       0: aload_0
       1: getfield      #26                 // Field total:Ljava/util/List;
       4: areturn

  public final void addFile(int);
    Code:
       0: aload_0
       1: getfield      #23                 // Field path:Ljava/util/Stack;
       4: invokevirtual #42                 // Method java/util/Stack.peek:()Ljava/lang/Object;
       7: checkcast     #44                 // class Day07Kt$main$Directory
      10: astore_2
      11: aload_2
      12: aload_2
      13: invokevirtual #48                 // Method Day07Kt$main$Directory.getSize:()I
      16: iload_1
      17: iadd
      18: invokevirtual #51                 // Method Day07Kt$main$Directory.setSize:(I)V
      21: return

  public final void moveInto(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #57                 // String name
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: getfield      #23                 // Field path:Ljava/util/Stack;
      10: aload_0
      11: getfield      #23                 // Field path:Ljava/util/Stack;
      14: invokevirtual #61                 // Method java/util/Stack.isEmpty:()Z
      17: ifeq          24
      20: aload_1
      21: goto          153
      24: new           #63                 // class java/lang/StringBuilder
      27: dup
      28: invokespecial #64                 // Method java/lang/StringBuilder."<init>":()V
      31: aload_0
      32: getfield      #23                 // Field path:Ljava/util/Stack;
      35: invokevirtual #42                 // Method java/util/Stack.peek:()Ljava/lang/Object;
      38: checkcast     #44                 // class Day07Kt$main$Directory
      41: invokevirtual #68                 // Method Day07Kt$main$Directory.getName:()Ljava/lang/String;
      44: astore_2
      45: astore        9
      47: astore        8
      49: iconst_0
      50: istore_3
      51: aload_2
      52: checkcast     #70                 // class java/lang/CharSequence
      55: invokestatic  #76                 // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I
      58: istore        4
      60: iconst_m1
      61: iload         4
      63: if_icmpge     128
      66: aload_2
      67: iload         4
      69: invokevirtual #82                 // Method java/lang/String.charAt:(I)C
      72: istore        5
      74: iconst_0
      75: istore        6
      77: iload         5
      79: bipush        47
      81: if_icmpne     88
      84: iconst_1
      85: goto          89
      88: iconst_0
      89: ifne          122
      92: aload_2
      93: astore        5
      95: iconst_0
      96: istore        6
      98: iload         4
     100: iconst_1
     101: iadd
     102: istore        7
     104: aload         5
     106: iload         6
     108: iload         7
     110: invokevirtual #86                 // Method java/lang/String.substring:(II)Ljava/lang/String;
     113: dup
     114: ldc           #88                 // String substring(...)
     116: invokestatic  #91                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     119: goto          130
     122: iinc          4, -1
     125: goto          60
     128: ldc           #93                 // String
     130: astore        10
     132: aload         8
     134: aload         9
     136: aload         10
     138: invokevirtual #97                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     141: bipush        47
     143: invokevirtual #100                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     146: aload_1
     147: invokevirtual #97                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     150: invokevirtual #103                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     153: iconst_0
     154: iconst_2
     155: aconst_null
     156: astore        11
     158: istore        12
     160: istore        13
     162: astore        14
     164: new           #44                 // class Day07Kt$main$Directory
     167: dup
     168: aload         14
     170: iload         13
     172: iload         12
     174: aload         11
     176: invokespecial #106                // Method Day07Kt$main$Directory."<init>":(Ljava/lang/String;IILkotlin/jvm/internal/DefaultConstructorMarker;)V
     179: invokevirtual #110                // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;
     182: pop
     183: return

  public final void moveUp();
    Code:
       0: aload_0
       1: getfield      #23                 // Field path:Ljava/util/Stack;
       4: invokevirtual #121                // Method java/util/Stack.pop:()Ljava/lang/Object;
       7: checkcast     #44                 // class Day07Kt$main$Directory
      10: astore_1
      11: aload_0
      12: getfield      #26                 // Field total:Ljava/util/List;
      15: aload_1
      16: invokestatic  #125                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      19: aload_1
      20: invokeinterface #131,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      25: pop
      26: aload_0
      27: getfield      #23                 // Field path:Ljava/util/Stack;
      30: checkcast     #133                // class java/util/Collection
      33: invokeinterface #134,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      38: ifne          45
      41: iconst_1
      42: goto          46
      45: iconst_0
      46: ifeq          73
      49: aload_0
      50: getfield      #23                 // Field path:Ljava/util/Stack;
      53: invokevirtual #42                 // Method java/util/Stack.peek:()Ljava/lang/Object;
      56: checkcast     #44                 // class Day07Kt$main$Directory
      59: astore_2
      60: aload_2
      61: aload_2
      62: invokevirtual #48                 // Method Day07Kt$main$Directory.getSize:()I
      65: aload_1
      66: invokevirtual #48                 // Method Day07Kt$main$Directory.getSize:()I
      69: iadd
      70: invokevirtual #51                 // Method Day07Kt$main$Directory.setSize:(I)V
      73: return

  public final void moveToRoot();
    Code:
       0: aload_0
       1: getfield      #23                 // Field path:Ljava/util/Stack;
       4: checkcast     #133                // class java/util/Collection
       7: invokeinterface #134,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      12: ifne          19
      15: iconst_1
      16: goto          20
      19: iconst_0
      20: ifeq          30
      23: aload_0
      24: invokevirtual #139                // Method moveUp:()V
      27: goto          0
      30: return

  public final java.util.Stack<Day07Kt$main$Directory> component1();
    Code:
       0: aload_0
       1: getfield      #23                 // Field path:Ljava/util/Stack;
       4: areturn

  public final java.util.List<Day07Kt$main$Directory> component2();
    Code:
       0: aload_0
       1: getfield      #26                 // Field total:Ljava/util/List;
       4: areturn

  public final Day07Kt$main$parseDirectorySizes$State copy(java.util.Stack<Day07Kt$main$Directory>, java.util.List<Day07Kt$main$Directory>);
    Code:
       0: aload_1
       1: ldc           #9                  // String path
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #17                 // String total
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: new           #2                  // class Day07Kt$main$parseDirectorySizes$State
      15: dup
      16: aload_1
      17: aload_2
      18: invokespecial #146                // Method "<init>":(Ljava/util/Stack;Ljava/util/List;)V
      21: areturn

  public static Day07Kt$main$parseDirectorySizes$State copy$default(Day07Kt$main$parseDirectorySizes$State, java.util.Stack, java.util.List, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          11
       6: aload_0
       7: getfield      #23                 // Field path:Ljava/util/Stack;
      10: astore_1
      11: iload_3
      12: iconst_2
      13: iand
      14: ifeq          22
      17: aload_0
      18: getfield      #26                 // Field total:Ljava/util/List;
      21: astore_2
      22: aload_0
      23: aload_1
      24: aload_2
      25: invokevirtual #150                // Method copy:(Ljava/util/Stack;Ljava/util/List;)LDay07Kt$main$parseDirectorySizes$State;
      28: areturn

  public java.lang.String toString();
    Code:
       0: new           #63                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #64                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #152                // String State(path=
       9: invokevirtual #97                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #23                 // Field path:Ljava/util/Stack;
      16: invokevirtual #155                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      19: ldc           #157                // String , total=
      21: invokevirtual #97                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #26                 // Field total:Ljava/util/List;
      28: invokevirtual #155                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      31: bipush        41
      33: invokevirtual #100                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      36: invokevirtual #103                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      39: areturn

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

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class Day07Kt$main$parseDirectorySizes$State
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class Day07Kt$main$parseDirectorySizes$State
      20: astore_2
      21: aload_0
      22: getfield      #23                 // Field path:Ljava/util/Stack;
      25: aload_2
      26: getfield      #23                 // Field path:Ljava/util/Stack;
      29: invokestatic  #167                // 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 total:Ljava/util/List;
      41: aload_2
      42: getfield      #26                 // Field total:Ljava/util/List;
      45: invokestatic  #167                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      48: ifne          53
      51: iconst_0
      52: ireturn
      53: iconst_1
      54: ireturn
}


fun main() {

    val day = "Day06"

    fun String.toNumberOfCharsBeforeUniqeSetOfSize(size: Int) = windowed(size)
        .mapIndexed { index, s -> index + size to s }
        .first { (_, s) -> s.toSet().size == size }.first

    fun part1(input: String): Int {
        return input.toNumberOfCharsBeforeUniqeSetOfSize(4)
    }

    fun part2(input: String): Int {
        return input.toNumberOfCharsBeforeUniqeSetOfSize(14)
    }

    // test if implementation meets criteria from the description, like:
    val input = readInput(day)

    check(part1("mjqjpqmgbljsphdztnvjfqwrcgsmlb") == 7)
    check(part1("bvwbjplbgvbhsrlpgdmjqwftvncz") == 5)
    check(part1("nppdvjthqldpwncqszvftbrmjlhg") == 6)
    check(part1("nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg") == 10)
    check(part1("zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw") == 11)
    val result1 = part1(input.first())
    println(result1)
    check(result1 == 1779)

    check(part2("mjqjpqmgbljsphdztnvjfqwrcgsmlb") == 19)
    check(part2("bvwbjplbgvbhsrlpgdmjqwftvncz") == 23)
    check(part2("nppdvjthqldpwncqszvftbrmjlhg") == 23)
    check(part2("nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg") == 29)
    check(part2("zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw") == 26)
    val result2 = part2(input.first())
    println(result2)
    check(result2 == 2635)
}

Compiled from "Day06.kt"
public final class Day06Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day06
       2: astore_0
       3: aload_0
       4: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       7: astore_1
       8: ldc           #16                 // String mjqjpqmgbljsphdztnvjfqwrcgsmlb
      10: invokestatic  #20                 // Method main$part1:(Ljava/lang/String;)I
      13: bipush        7
      15: if_icmpne     22
      18: iconst_1
      19: goto          23
      22: iconst_0
      23: ifne          36
      26: new           #22                 // class java/lang/IllegalStateException
      29: dup
      30: ldc           #24                 // String Check failed.
      32: invokespecial #28                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      35: athrow
      36: ldc           #30                 // String bvwbjplbgvbhsrlpgdmjqwftvncz
      38: invokestatic  #20                 // Method main$part1:(Ljava/lang/String;)I
      41: iconst_5
      42: if_icmpne     49
      45: iconst_1
      46: goto          50
      49: iconst_0
      50: ifne          63
      53: new           #22                 // class java/lang/IllegalStateException
      56: dup
      57: ldc           #24                 // String Check failed.
      59: invokespecial #28                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      62: athrow
      63: ldc           #32                 // String nppdvjthqldpwncqszvftbrmjlhg
      65: invokestatic  #20                 // Method main$part1:(Ljava/lang/String;)I
      68: bipush        6
      70: if_icmpne     77
      73: iconst_1
      74: goto          78
      77: iconst_0
      78: ifne          91
      81: new           #22                 // class java/lang/IllegalStateException
      84: dup
      85: ldc           #24                 // String Check failed.
      87: invokespecial #28                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      90: athrow
      91: ldc           #34                 // String nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg
      93: invokestatic  #20                 // Method main$part1:(Ljava/lang/String;)I
      96: bipush        10
      98: if_icmpne     105
     101: iconst_1
     102: goto          106
     105: iconst_0
     106: ifne          119
     109: new           #22                 // class java/lang/IllegalStateException
     112: dup
     113: ldc           #24                 // String Check failed.
     115: invokespecial #28                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     118: athrow
     119: ldc           #36                 // String zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw
     121: invokestatic  #20                 // Method main$part1:(Ljava/lang/String;)I
     124: bipush        11
     126: if_icmpne     133
     129: iconst_1
     130: goto          134
     133: iconst_0
     134: ifne          147
     137: new           #22                 // class java/lang/IllegalStateException
     140: dup
     141: ldc           #24                 // String Check failed.
     143: invokespecial #28                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     146: athrow
     147: aload_1
     148: invokestatic  #42                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     151: checkcast     #44                 // class java/lang/String
     154: invokestatic  #20                 // Method main$part1:(Ljava/lang/String;)I
     157: istore_2
     158: getstatic     #50                 // Field java/lang/System.out:Ljava/io/PrintStream;
     161: iload_2
     162: invokevirtual #56                 // Method java/io/PrintStream.println:(I)V
     165: iload_2
     166: sipush        1779
     169: if_icmpne     176
     172: iconst_1
     173: goto          177
     176: iconst_0
     177: ifne          190
     180: new           #22                 // class java/lang/IllegalStateException
     183: dup
     184: ldc           #24                 // String Check failed.
     186: invokespecial #28                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     189: athrow
     190: ldc           #16                 // String mjqjpqmgbljsphdztnvjfqwrcgsmlb
     192: invokestatic  #59                 // Method main$part2:(Ljava/lang/String;)I
     195: bipush        19
     197: if_icmpne     204
     200: iconst_1
     201: goto          205
     204: iconst_0
     205: ifne          218
     208: new           #22                 // class java/lang/IllegalStateException
     211: dup
     212: ldc           #24                 // String Check failed.
     214: invokespecial #28                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     217: athrow
     218: ldc           #30                 // String bvwbjplbgvbhsrlpgdmjqwftvncz
     220: invokestatic  #59                 // Method main$part2:(Ljava/lang/String;)I
     223: bipush        23
     225: if_icmpne     232
     228: iconst_1
     229: goto          233
     232: iconst_0
     233: ifne          246
     236: new           #22                 // class java/lang/IllegalStateException
     239: dup
     240: ldc           #24                 // String Check failed.
     242: invokespecial #28                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     245: athrow
     246: ldc           #32                 // String nppdvjthqldpwncqszvftbrmjlhg
     248: invokestatic  #59                 // Method main$part2:(Ljava/lang/String;)I
     251: bipush        23
     253: if_icmpne     260
     256: iconst_1
     257: goto          261
     260: iconst_0
     261: ifne          274
     264: new           #22                 // class java/lang/IllegalStateException
     267: dup
     268: ldc           #24                 // String Check failed.
     270: invokespecial #28                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     273: athrow
     274: ldc           #34                 // String nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg
     276: invokestatic  #59                 // Method main$part2:(Ljava/lang/String;)I
     279: bipush        29
     281: if_icmpne     288
     284: iconst_1
     285: goto          289
     288: iconst_0
     289: ifne          302
     292: new           #22                 // class java/lang/IllegalStateException
     295: dup
     296: ldc           #24                 // String Check failed.
     298: invokespecial #28                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     301: athrow
     302: ldc           #36                 // String zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw
     304: invokestatic  #59                 // Method main$part2:(Ljava/lang/String;)I
     307: bipush        26
     309: if_icmpne     316
     312: iconst_1
     313: goto          317
     316: iconst_0
     317: ifne          330
     320: new           #22                 // class java/lang/IllegalStateException
     323: dup
     324: ldc           #24                 // String Check failed.
     326: invokespecial #28                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     329: athrow
     330: aload_1
     331: invokestatic  #42                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     334: checkcast     #44                 // class java/lang/String
     337: invokestatic  #59                 // Method main$part2:(Ljava/lang/String;)I
     340: istore_3
     341: getstatic     #50                 // Field java/lang/System.out:Ljava/io/PrintStream;
     344: iload_3
     345: invokevirtual #56                 // Method java/io/PrintStream.println:(I)V
     348: iload_3
     349: sipush        2635
     352: if_icmpne     359
     355: iconst_1
     356: goto          360
     359: iconst_0
     360: ifne          373
     363: new           #22                 // class java/lang/IllegalStateException
     366: dup
     367: ldc           #24                 // String Check failed.
     369: invokespecial #28                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     372: athrow
     373: return

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

  private static final int main$toNumberOfCharsBeforeUniqeSetOfSize(java.lang.String, int);
    Code:
       0: aload_0
       1: checkcast     #77                 // class java/lang/CharSequence
       4: iload_1
       5: iconst_0
       6: iconst_0
       7: bipush        6
       9: aconst_null
      10: invokestatic  #83                 // Method kotlin/text/StringsKt.windowed$default:(Ljava/lang/CharSequence;IIZILjava/lang/Object;)Ljava/util/List;
      13: checkcast     #85                 // class java/lang/Iterable
      16: astore_2
      17: nop
      18: iconst_0
      19: istore_3
      20: aload_2
      21: astore        4
      23: new           #87                 // class java/util/ArrayList
      26: dup
      27: aload_2
      28: bipush        10
      30: invokestatic  #91                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      33: invokespecial #93                 // Method java/util/ArrayList."<init>":(I)V
      36: checkcast     #95                 // class java/util/Collection
      39: astore        5
      41: iconst_0
      42: istore        6
      44: iconst_0
      45: istore        7
      47: aload         4
      49: invokeinterface #99,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      54: astore        8
      56: aload         8
      58: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      63: ifeq          132
      66: aload         8
      68: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      73: astore        9
      75: aload         5
      77: iload         7
      79: iinc          7, 1
      82: istore        10
      84: iload         10
      86: ifge          92
      89: invokestatic  #112                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      92: iload         10
      94: aload         9
      96: checkcast     #44                 // class java/lang/String
      99: astore        11
     101: istore        12
     103: astore        14
     105: iconst_0
     106: istore        13
     108: iload         12
     110: iload_1
     111: iadd
     112: invokestatic  #118                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     115: aload         11
     117: invokestatic  #124                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     120: aload         14
     122: swap
     123: invokeinterface #128,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     128: pop
     129: goto          56
     132: aload         5
     134: checkcast     #68                 // class java/util/List
     137: nop
     138: checkcast     #85                 // class java/lang/Iterable
     141: astore_2
     142: nop
     143: iconst_0
     144: istore_3
     145: aload_2
     146: invokeinterface #99,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     151: astore        4
     153: aload         4
     155: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     160: ifeq          222
     163: aload         4
     165: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     170: astore        5
     172: aload         5
     174: checkcast     #130                // class kotlin/Pair
     177: astore        6
     179: iconst_0
     180: istore        7
     182: aload         6
     184: invokevirtual #133                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     187: checkcast     #44                 // class java/lang/String
     190: astore        8
     192: aload         8
     194: checkcast     #77                 // class java/lang/CharSequence
     197: invokestatic  #137                // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;
     200: invokeinterface #143,  1          // InterfaceMethod java/util/Set.size:()I
     205: iload_1
     206: if_icmpne     213
     209: iconst_1
     210: goto          214
     213: iconst_0
     214: ifeq          153
     217: aload         5
     219: goto          232
     222: new           #145                // class java/util/NoSuchElementException
     225: dup
     226: ldc           #147                // String Collection contains no element matching the predicate.
     228: invokespecial #148                // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
     231: athrow
     232: checkcast     #130                // class kotlin/Pair
     235: invokevirtual #151                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     238: checkcast     #153                // class java/lang/Number
     241: invokevirtual #156                // Method java/lang/Number.intValue:()I
     244: ireturn

  private static final int main$part1(java.lang.String);
    Code:
       0: aload_0
       1: iconst_4
       2: invokestatic  #176                // Method main$toNumberOfCharsBeforeUniqeSetOfSize:(Ljava/lang/String;I)I
       5: ireturn

  private static final int main$part2(java.lang.String);
    Code:
       0: aload_0
       1: bipush        14
       3: invokestatic  #176                // Method main$toNumberOfCharsBeforeUniqeSetOfSize:(Ljava/lang/String;I)I
       6: ireturn
}


fun main() {

    val day = "Day03"

    fun List<String>.findCommonChar() =
        this.drop(1).fold(this.first().toSet()) { acc, s -> s.toSet().intersect(acc) }.first()

    fun calculatePriority(badge: Char) =
        if (badge.isLowerCase()) {
            badge - 'a' + 1
        } else {
            badge - 'A' + 27
        }

    fun part1(input: List<String>): Int {
        return input.map { rucksack ->
            rucksack.chunked(rucksack.length / 2)
                .findCommonChar()
        }.map(::calculatePriority).sum()
    }

    fun part2(input: List<String>): Int {
        return input.chunked(3)
            .map(List<String>::findCommonChar)
            .map(::calculatePriority).sum()
    }

    // test if implementation meets criteria from the description, like:
    val testInput = readInput("${day}_test")
    val input = readInput(day)

    check(part1(testInput) == 157)
    val result1 = part1(input)
    println(result1)
    check(result1 == 7997)

    check(part2(testInput) == 70)
    val result2 = part2(input)
    println(result2)
    check(result2 == 2545)
}

Compiled from "Day03.kt"
public final class Day03Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day03
       2: astore_0
       3: new           #10                 // class java/lang/StringBuilder
       6: dup
       7: invokespecial #13                 // Method java/lang/StringBuilder."<init>":()V
      10: aload_0
      11: invokevirtual #17                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      14: ldc           #19                 // String _test
      16: invokevirtual #17                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      19: invokevirtual #23                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      22: invokestatic  #29                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      25: astore_1
      26: aload_0
      27: invokestatic  #29                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      30: astore_2
      31: aload_1
      32: invokestatic  #33                 // Method main$part1:(Ljava/util/List;)I
      35: sipush        157
      38: if_icmpne     45
      41: iconst_1
      42: goto          46
      45: iconst_0
      46: ifne          59
      49: new           #35                 // class java/lang/IllegalStateException
      52: dup
      53: ldc           #37                 // String Check failed.
      55: invokespecial #40                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      58: athrow
      59: aload_2
      60: invokestatic  #33                 // Method main$part1:(Ljava/util/List;)I
      63: istore_3
      64: getstatic     #46                 // Field java/lang/System.out:Ljava/io/PrintStream;
      67: iload_3
      68: invokevirtual #52                 // Method java/io/PrintStream.println:(I)V
      71: iload_3
      72: sipush        7997
      75: if_icmpne     82
      78: iconst_1
      79: goto          83
      82: iconst_0
      83: ifne          96
      86: new           #35                 // class java/lang/IllegalStateException
      89: dup
      90: ldc           #37                 // String Check failed.
      92: invokespecial #40                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      95: athrow
      96: aload_1
      97: invokestatic  #55                 // Method main$part2:(Ljava/util/List;)I
     100: bipush        70
     102: if_icmpne     109
     105: iconst_1
     106: goto          110
     109: iconst_0
     110: ifne          123
     113: new           #35                 // class java/lang/IllegalStateException
     116: dup
     117: ldc           #37                 // String Check failed.
     119: invokespecial #40                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     122: athrow
     123: aload_2
     124: invokestatic  #55                 // Method main$part2:(Ljava/util/List;)I
     127: istore        4
     129: getstatic     #46                 // Field java/lang/System.out:Ljava/io/PrintStream;
     132: iload         4
     134: invokevirtual #52                 // Method java/io/PrintStream.println:(I)V
     137: iload         4
     139: sipush        2545
     142: if_icmpne     149
     145: iconst_1
     146: goto          150
     149: iconst_0
     150: ifne          163
     153: new           #35                 // class java/lang/IllegalStateException
     156: dup
     157: ldc           #37                 // String Check failed.
     159: invokespecial #40                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     162: athrow
     163: return

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

  private static final char main$findCommonChar(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #77                 // class java/lang/Iterable
       4: iconst_1
       5: invokestatic  #83                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
       8: checkcast     #77                 // class java/lang/Iterable
      11: astore_1
      12: aload_0
      13: invokestatic  #87                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      16: checkcast     #89                 // class java/lang/CharSequence
      19: invokestatic  #95                 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;
      22: astore_2
      23: iconst_0
      24: istore_3
      25: aload_2
      26: astore        4
      28: aload_1
      29: invokeinterface #99,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      34: astore        5
      36: aload         5
      38: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      43: ifeq          93
      46: aload         5
      48: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      53: astore        6
      55: aload         4
      57: aload         6
      59: checkcast     #65                 // class java/lang/String
      62: astore        7
      64: astore        8
      66: iconst_0
      67: istore        9
      69: aload         7
      71: checkcast     #89                 // class java/lang/CharSequence
      74: invokestatic  #95                 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;
      77: checkcast     #77                 // class java/lang/Iterable
      80: aload         8
      82: checkcast     #77                 // class java/lang/Iterable
      85: invokestatic  #113                // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
      88: astore        4
      90: goto          36
      93: aload         4
      95: checkcast     #77                 // class java/lang/Iterable
      98: invokestatic  #116                // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;
     101: checkcast     #118                // class java/lang/Character
     104: invokevirtual #122                // Method java/lang/Character.charValue:()C
     107: ireturn

  private static final int main$calculatePriority(char);
    Code:
       0: iload_0
       1: invokestatic  #142                // Method java/lang/Character.isLowerCase:(C)Z
       4: ifeq          16
       7: iload_0
       8: bipush        97
      10: isub
      11: iconst_1
      12: iadd
      13: goto          23
      16: iload_0
      17: bipush        65
      19: isub
      20: bipush        27
      22: iadd
      23: ireturn

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #77                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: astore_3
       9: new           #147                // class java/util/ArrayList
      12: dup
      13: aload_1
      14: bipush        10
      16: invokestatic  #151                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      19: invokespecial #153                // Method java/util/ArrayList."<init>":(I)V
      22: checkcast     #155                // class java/util/Collection
      25: astore        4
      27: iconst_0
      28: istore        5
      30: aload_3
      31: invokeinterface #99,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      36: astore        6
      38: aload         6
      40: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      45: ifeq          104
      48: aload         6
      50: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      55: astore        7
      57: aload         4
      59: aload         7
      61: checkcast     #65                 // class java/lang/String
      64: astore        8
      66: astore        10
      68: iconst_0
      69: istore        9
      71: aload         8
      73: checkcast     #89                 // class java/lang/CharSequence
      76: aload         8
      78: invokevirtual #159                // Method java/lang/String.length:()I
      81: iconst_2
      82: idiv
      83: invokestatic  #163                // Method kotlin/text/StringsKt.chunked:(Ljava/lang/CharSequence;I)Ljava/util/List;
      86: invokestatic  #165                // Method main$findCommonChar:(Ljava/util/List;)C
      89: invokestatic  #169                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      92: aload         10
      94: swap
      95: invokeinterface #173,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     100: pop
     101: goto          38
     104: aload         4
     106: checkcast     #67                 // class java/util/List
     109: nop
     110: checkcast     #77                 // class java/lang/Iterable
     113: astore_1
     114: nop
     115: iconst_0
     116: istore_2
     117: aload_1
     118: astore_3
     119: new           #147                // class java/util/ArrayList
     122: dup
     123: aload_1
     124: bipush        10
     126: invokestatic  #151                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     129: invokespecial #153                // Method java/util/ArrayList."<init>":(I)V
     132: checkcast     #155                // class java/util/Collection
     135: astore        4
     137: iconst_0
     138: istore        5
     140: aload_3
     141: invokeinterface #99,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     146: astore        6
     148: aload         6
     150: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     155: ifeq          204
     158: aload         6
     160: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     165: astore        7
     167: aload         4
     169: aload         7
     171: checkcast     #118                // class java/lang/Character
     174: invokevirtual #122                // Method java/lang/Character.charValue:()C
     177: istore        8
     179: astore        10
     181: iconst_0
     182: istore        9
     184: iload         8
     186: invokestatic  #175                // Method main$calculatePriority:(C)I
     189: invokestatic  #180                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     192: aload         10
     194: swap
     195: invokeinterface #173,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     200: pop
     201: goto          148
     204: aload         4
     206: checkcast     #67                 // class java/util/List
     209: nop
     210: checkcast     #77                 // class java/lang/Iterable
     213: invokestatic  #184                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     216: ireturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #77                 // class java/lang/Iterable
       4: iconst_3
       5: invokestatic  #197                // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;
       8: checkcast     #77                 // class java/lang/Iterable
      11: astore_1
      12: nop
      13: iconst_0
      14: istore_2
      15: aload_1
      16: astore_3
      17: new           #147                // class java/util/ArrayList
      20: dup
      21: aload_1
      22: bipush        10
      24: invokestatic  #151                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      27: invokespecial #153                // Method java/util/ArrayList."<init>":(I)V
      30: checkcast     #155                // class java/util/Collection
      33: astore        4
      35: iconst_0
      36: istore        5
      38: aload_3
      39: invokeinterface #99,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      44: astore        6
      46: aload         6
      48: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      53: ifeq          99
      56: aload         6
      58: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: astore        7
      65: aload         4
      67: aload         7
      69: checkcast     #67                 // class java/util/List
      72: astore        8
      74: astore        10
      76: iconst_0
      77: istore        9
      79: aload         8
      81: invokestatic  #165                // Method main$findCommonChar:(Ljava/util/List;)C
      84: invokestatic  #169                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      87: aload         10
      89: swap
      90: invokeinterface #173,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      95: pop
      96: goto          46
      99: aload         4
     101: checkcast     #67                 // class java/util/List
     104: nop
     105: checkcast     #77                 // class java/lang/Iterable
     108: astore_1
     109: nop
     110: iconst_0
     111: istore_2
     112: aload_1
     113: astore_3
     114: new           #147                // class java/util/ArrayList
     117: dup
     118: aload_1
     119: bipush        10
     121: invokestatic  #151                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     124: invokespecial #153                // Method java/util/ArrayList."<init>":(I)V
     127: checkcast     #155                // class java/util/Collection
     130: astore        4
     132: iconst_0
     133: istore        5
     135: aload_3
     136: invokeinterface #99,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     141: astore        6
     143: aload         6
     145: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     150: ifeq          199
     153: aload         6
     155: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     160: astore        7
     162: aload         4
     164: aload         7
     166: checkcast     #118                // class java/lang/Character
     169: invokevirtual #122                // Method java/lang/Character.charValue:()C
     172: istore        8
     174: astore        10
     176: iconst_0
     177: istore        9
     179: iload         8
     181: invokestatic  #175                // Method main$calculatePriority:(C)I
     184: invokestatic  #180                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     187: aload         10
     189: swap
     190: invokeinterface #173,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     195: pop
     196: goto          143
     199: aload         4
     201: checkcast     #67                 // class java/util/List
     204: nop
     205: checkcast     #77                 // class java/lang/Iterable
     208: invokestatic  #184                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     211: ireturn
}


import Outcome.*
import Outcome.Companion.outcome
import Shape.Companion.myShape
import Shape.Companion.opponentShape

enum class Shape(val opponentCode: String, val myCode: String, val score: Int, val winsOver: Int) {
    ROCK("A", "X", 1, 2),
    PAPER("B", "Y", 2, 0),
    SCISSORS("C", "Z", 3, 1);

    companion object {
        fun opponentShape(opponentCode: String) = values().find { it.opponentCode == opponentCode }!!
        fun myShape(myCode: String) = values().find { it.myCode == myCode }!!
        fun winsOver(shape: Shape) = values().find { it.winsOver == shape.ordinal }!!
        fun loosesTo(shape: Shape) = values().find { it.ordinal == shape.winsOver }!!
    }
}

enum class Outcome(val code: String) {
    WIN("Z"),
    DRAW("Y"),
    LOOSE("X");

    companion object {
        fun outcome(code: String) = values().find { it.code == code }!!
    }
}

fun main() {

    val day = "Day02"

    fun calculateScore(opponentShape: Shape, myShape: Shape) =
        myShape.score + when {
            myShape.winsOver == opponentShape.ordinal -> 6
            myShape == opponentShape -> 3
            else -> 0
        }

    fun part1(input: List<String>): Int {
        return input.map { inputRow ->
            val (opponentCode, myCode) = inputRow.split(" ")
            opponentShape(opponentCode) to myShape(myCode)
        }.sumOf { (opponentShape, myShape) -> calculateScore(opponentShape, myShape) }
    }

    fun part2(input: List<String>): Int {

        fun findMyShape(outcome: Outcome, opponentShape: Shape) = when (outcome) {
            WIN -> Shape.winsOver(opponentShape)
            DRAW -> opponentShape
            LOOSE -> Shape.loosesTo(opponentShape)
        }

        return input.map { inputRow ->
            val (opponentCode, outcomeCode) = inputRow.split(" ")
            opponentShape(opponentCode) to outcome(outcomeCode)
        }
            .map { (opponentShape, outcome) -> opponentShape to findMyShape(outcome, opponentShape) }
            .sumOf { (opponentShape, myShape) -> calculateScore(opponentShape, myShape) }

    }

    // test if implementation meets criteria from the description, like:
    val testInput = readInput("${day}_test")
    val input = readInput(day)

    check(part1(testInput) == 15)
    val result1 = part1(input)
    println(result1)
    check(result1 == 14264)

    check(part2(testInput) == 12)
    val result2 = part2(input)
    println(result2)
    check(result2 == 12382)
}

Compiled from "Day02.kt"
public final class Day02Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day02
       2: astore_0
       3: new           #10                 // class java/lang/StringBuilder
       6: dup
       7: invokespecial #13                 // Method java/lang/StringBuilder."<init>":()V
      10: aload_0
      11: invokevirtual #17                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      14: ldc           #19                 // String _test
      16: invokevirtual #17                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      19: invokevirtual #23                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      22: invokestatic  #29                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      25: astore_1
      26: aload_0
      27: invokestatic  #29                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      30: astore_2
      31: aload_1
      32: invokestatic  #33                 // Method main$part1:(Ljava/util/List;)I
      35: bipush        15
      37: if_icmpne     44
      40: iconst_1
      41: goto          45
      44: iconst_0
      45: ifne          58
      48: new           #35                 // class java/lang/IllegalStateException
      51: dup
      52: ldc           #37                 // String Check failed.
      54: invokespecial #40                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      57: athrow
      58: aload_2
      59: invokestatic  #33                 // Method main$part1:(Ljava/util/List;)I
      62: istore_3
      63: getstatic     #46                 // Field java/lang/System.out:Ljava/io/PrintStream;
      66: iload_3
      67: invokevirtual #52                 // Method java/io/PrintStream.println:(I)V
      70: iload_3
      71: sipush        14264
      74: if_icmpne     81
      77: iconst_1
      78: goto          82
      81: iconst_0
      82: ifne          95
      85: new           #35                 // class java/lang/IllegalStateException
      88: dup
      89: ldc           #37                 // String Check failed.
      91: invokespecial #40                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      94: athrow
      95: aload_1
      96: invokestatic  #55                 // Method main$part2:(Ljava/util/List;)I
      99: bipush        12
     101: if_icmpne     108
     104: iconst_1
     105: goto          109
     108: iconst_0
     109: ifne          122
     112: new           #35                 // class java/lang/IllegalStateException
     115: dup
     116: ldc           #37                 // String Check failed.
     118: invokespecial #40                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     121: athrow
     122: aload_2
     123: invokestatic  #55                 // Method main$part2:(Ljava/util/List;)I
     126: istore        4
     128: getstatic     #46                 // Field java/lang/System.out:Ljava/io/PrintStream;
     131: iload         4
     133: invokevirtual #52                 // Method java/io/PrintStream.println:(I)V
     136: iload         4
     138: sipush        12382
     141: if_icmpne     148
     144: iconst_1
     145: goto          149
     148: iconst_0
     149: ifne          162
     152: new           #35                 // class java/lang/IllegalStateException
     155: dup
     156: ldc           #37                 // String Check failed.
     158: invokespecial #40                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     161: athrow
     162: return

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

  private static final int main$calculateScore(Shape, Shape);
    Code:
       0: aload_1
       1: invokevirtual #80                 // Method Shape.getScore:()I
       4: aload_1
       5: invokevirtual #83                 // Method Shape.getWinsOver:()I
       8: aload_0
       9: invokevirtual #86                 // Method Shape.ordinal:()I
      12: if_icmpne     20
      15: bipush        6
      17: goto          30
      20: aload_1
      21: aload_0
      22: if_acmpne     29
      25: iconst_3
      26: goto          30
      29: iconst_0
      30: iadd
      31: ireturn

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #92                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: astore_3
       9: new           #94                 // class java/util/ArrayList
      12: dup
      13: aload_1
      14: bipush        10
      16: invokestatic  #100                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      19: invokespecial #102                // Method java/util/ArrayList."<init>":(I)V
      22: checkcast     #104                // class java/util/Collection
      25: astore        4
      27: iconst_0
      28: istore        5
      30: aload_3
      31: invokeinterface #108,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      36: astore        6
      38: aload         6
      40: invokeinterface #114,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      45: ifeq          157
      48: aload         6
      50: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      55: astore        7
      57: aload         4
      59: aload         7
      61: checkcast     #65                 // class java/lang/String
      64: astore        8
      66: astore        13
      68: iconst_0
      69: istore        9
      71: aload         8
      73: checkcast     #120                // class java/lang/CharSequence
      76: iconst_1
      77: anewarray     #65                 // class java/lang/String
      80: astore        10
      82: aload         10
      84: iconst_0
      85: ldc           #122                // String
      87: aastore
      88: aload         10
      90: iconst_0
      91: iconst_0
      92: bipush        6
      94: aconst_null
      95: invokestatic  #128                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      98: astore        11
     100: aload         11
     102: iconst_0
     103: invokeinterface #132,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     108: checkcast     #65                 // class java/lang/String
     111: astore        10
     113: aload         11
     115: iconst_1
     116: invokeinterface #132,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     121: checkcast     #65                 // class java/lang/String
     124: astore        12
     126: getstatic     #136                // Field Shape.Companion:LShape$Companion;
     129: aload         10
     131: invokevirtual #141                // Method Shape$Companion.opponentShape:(Ljava/lang/String;)LShape;
     134: getstatic     #136                // Field Shape.Companion:LShape$Companion;
     137: aload         12
     139: invokevirtual #143                // Method Shape$Companion.myShape:(Ljava/lang/String;)LShape;
     142: invokestatic  #149                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     145: aload         13
     147: swap
     148: invokeinterface #153,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     153: pop
     154: goto          38
     157: aload         4
     159: checkcast     #67                 // class java/util/List
     162: nop
     163: checkcast     #92                 // class java/lang/Iterable
     166: astore_1
     167: iconst_0
     168: istore_2
     169: aload_1
     170: invokeinterface #108,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     175: astore_3
     176: aload_3
     177: invokeinterface #114,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     182: ifeq          244
     185: aload_3
     186: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     191: astore        4
     193: iload_2
     194: aload         4
     196: checkcast     #155                // class kotlin/Pair
     199: astore        5
     201: istore        13
     203: iconst_0
     204: istore        6
     206: aload         5
     208: invokevirtual #158                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     211: checkcast     #76                 // class Shape
     214: astore        7
     216: aload         5
     218: invokevirtual #161                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     221: checkcast     #76                 // class Shape
     224: astore        8
     226: aload         7
     228: aload         8
     230: invokestatic  #163                // Method main$calculateScore:(LShape;LShape;)I
     233: istore        14
     235: iload         13
     237: iload         14
     239: iadd
     240: istore_2
     241: goto          176
     244: iload_2
     245: ireturn

  private static final Shape main$part2$findMyShape(Outcome, Shape);
    Code:
       0: aload_0
       1: getstatic     #185                // Field Day02Kt$WhenMappings.$EnumSwitchMapping$0:[I
       4: swap
       5: invokevirtual #188                // Method Outcome.ordinal:()I
       8: iaload
       9: tableswitch   { // 1 to 3
                     1: 36
                     2: 46
                     3: 50
               default: 60
          }
      36: getstatic     #136                // Field Shape.Companion:LShape$Companion;
      39: aload_1
      40: invokevirtual #192                // Method Shape$Companion.winsOver:(LShape;)LShape;
      43: goto          68
      46: aload_1
      47: goto          68
      50: getstatic     #136                // Field Shape.Companion:LShape$Companion;
      53: aload_1
      54: invokevirtual #195                // Method Shape$Companion.loosesTo:(LShape;)LShape;
      57: goto          68
      60: new           #197                // class kotlin/NoWhenBranchMatchedException
      63: dup
      64: invokespecial #198                // Method kotlin/NoWhenBranchMatchedException."<init>":()V
      67: athrow
      68: areturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #92                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: astore_3
       9: new           #94                 // class java/util/ArrayList
      12: dup
      13: aload_1
      14: bipush        10
      16: invokestatic  #100                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      19: invokespecial #102                // Method java/util/ArrayList."<init>":(I)V
      22: checkcast     #104                // class java/util/Collection
      25: astore        4
      27: iconst_0
      28: istore        5
      30: aload_3
      31: invokeinterface #108,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      36: astore        6
      38: aload         6
      40: invokeinterface #114,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      45: ifeq          157
      48: aload         6
      50: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      55: astore        7
      57: aload         4
      59: aload         7
      61: checkcast     #65                 // class java/lang/String
      64: astore        8
      66: astore        13
      68: iconst_0
      69: istore        9
      71: aload         8
      73: checkcast     #120                // class java/lang/CharSequence
      76: iconst_1
      77: anewarray     #65                 // class java/lang/String
      80: astore        10
      82: aload         10
      84: iconst_0
      85: ldc           #122                // String
      87: aastore
      88: aload         10
      90: iconst_0
      91: iconst_0
      92: bipush        6
      94: aconst_null
      95: invokestatic  #128                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      98: astore        11
     100: aload         11
     102: iconst_0
     103: invokeinterface #132,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     108: checkcast     #65                 // class java/lang/String
     111: astore        10
     113: aload         11
     115: iconst_1
     116: invokeinterface #132,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     121: checkcast     #65                 // class java/lang/String
     124: astore        12
     126: getstatic     #136                // Field Shape.Companion:LShape$Companion;
     129: aload         10
     131: invokevirtual #141                // Method Shape$Companion.opponentShape:(Ljava/lang/String;)LShape;
     134: getstatic     #203                // Field Outcome.Companion:LOutcome$Companion;
     137: aload         12
     139: invokevirtual #208                // Method Outcome$Companion.outcome:(Ljava/lang/String;)LOutcome;
     142: invokestatic  #149                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     145: aload         13
     147: swap
     148: invokeinterface #153,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     153: pop
     154: goto          38
     157: aload         4
     159: checkcast     #67                 // class java/util/List
     162: nop
     163: checkcast     #92                 // class java/lang/Iterable
     166: astore_1
     167: nop
     168: iconst_0
     169: istore_2
     170: aload_1
     171: astore_3
     172: new           #94                 // class java/util/ArrayList
     175: dup
     176: aload_1
     177: bipush        10
     179: invokestatic  #100                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     182: invokespecial #102                // Method java/util/ArrayList."<init>":(I)V
     185: checkcast     #104                // class java/util/Collection
     188: astore        4
     190: iconst_0
     191: istore        5
     193: aload_3
     194: invokeinterface #108,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     199: astore        6
     201: aload         6
     203: invokeinterface #114,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     208: ifeq          278
     211: aload         6
     213: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     218: astore        7
     220: aload         4
     222: aload         7
     224: checkcast     #155                // class kotlin/Pair
     227: astore        8
     229: astore        13
     231: iconst_0
     232: istore        9
     234: aload         8
     236: invokevirtual #158                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     239: checkcast     #76                 // class Shape
     242: astore        10
     244: aload         8
     246: invokevirtual #161                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     249: checkcast     #187                // class Outcome
     252: astore        11
     254: aload         10
     256: aload         11
     258: aload         10
     260: invokestatic  #210                // Method main$part2$findMyShape:(LOutcome;LShape;)LShape;
     263: invokestatic  #149                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     266: aload         13
     268: swap
     269: invokeinterface #153,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     274: pop
     275: goto          201
     278: aload         4
     280: checkcast     #67                 // class java/util/List
     283: nop
     284: checkcast     #92                 // class java/lang/Iterable
     287: astore_1
     288: iconst_0
     289: istore_2
     290: aload_1
     291: invokeinterface #108,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     296: astore_3
     297: aload_3
     298: invokeinterface #114,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     303: ifeq          365
     306: aload_3
     307: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     312: astore        4
     314: iload_2
     315: aload         4
     317: checkcast     #155                // class kotlin/Pair
     320: astore        5
     322: istore        13
     324: iconst_0
     325: istore        6
     327: aload         5
     329: invokevirtual #158                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     332: checkcast     #76                 // class Shape
     335: astore        7
     337: aload         5
     339: invokevirtual #161                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     342: checkcast     #76                 // class Shape
     345: astore        8
     347: aload         7
     349: aload         8
     351: invokestatic  #163                // Method main$calculateScore:(LShape;LShape;)I
     354: istore        14
     356: iload         13
     358: iload         14
     360: iadd
     361: istore_2
     362: goto          297
     365: iload_2
     366: ireturn
}

Compiled from "Day02.kt"
public final class Day02Kt$WhenMappings {
  public static final int[] $EnumSwitchMapping$0;

  static {};
    Code:
       0: invokestatic  #14                 // Method Outcome.values:()[LOutcome;
       3: arraylength
       4: newarray       int
       6: astore_0
       7: nop
       8: aload_0
       9: getstatic     #18                 // Field Outcome.WIN:LOutcome;
      12: invokevirtual #22                 // Method Outcome.ordinal:()I
      15: iconst_1
      16: iastore
      17: goto          21
      20: astore_1
      21: nop
      22: aload_0
      23: getstatic     #25                 // Field Outcome.DRAW:LOutcome;
      26: invokevirtual #22                 // Method Outcome.ordinal:()I
      29: iconst_2
      30: iastore
      31: goto          35
      34: astore_1
      35: nop
      36: aload_0
      37: getstatic     #28                 // Field Outcome.LOOSE:LOutcome;
      40: invokevirtual #22                 // Method Outcome.ordinal:()I
      43: iconst_3
      44: iastore
      45: goto          49
      48: astore_1
      49: aload_0
      50: putstatic     #32                 // Field $EnumSwitchMapping$0:[I
      53: return
    Exception table:
       from    to  target type
           7    17    20   Class java/lang/NoSuchFieldError
          21    31    34   Class java/lang/NoSuchFieldError
          35    45    48   Class java/lang/NoSuchFieldError
}