fun main(args: Array<String>) {
    val TOTAL_DISK_SPACE = 70000000
    val UNUSED_SPACE_NEEDED = 30000000

    abstract class Node(val name: String, var size: Int) {
        abstract fun calcSize(): Int
        abstract fun sumMatchingSizes(): Int
    }

    class File(name: String, size: Int): Node(name, size) {
        override fun calcSize(): Int {
            return size
        }

        override fun sumMatchingSizes(): Int {
            return 0
        }
    }

    class Dir(name: String, val parent: Dir?): Node(name, 0) {
        val children = mutableMapOf<String, Node>()

        override fun calcSize(): Int {
            size = children.values.sumOf { it.calcSize() }
            return size
        }

        override fun sumMatchingSizes(): Int {
            return (if (size <= 100000) size else 0) + children.values.sumOf { it.sumMatchingSizes() }
        }

        fun findSmallestDirWithMinSize(minSize: Int): Dir? {
            val me = if (size >= minSize) this else null
            val descendantCandidates = children.values.mapNotNull {
                if (it !is Dir) null else it.findSmallestDirWithMinSize(minSize)
            }
            return (listOfNotNull(me) + descendantCandidates).minWithOrNull(compareBy { it.size })
        }
    }

    fun executeLine(cwd: Dir, lines: List<String>, startLineNum: Int): Pair<Dir, Int> {
        var lineNum = startLineNum
        val tokens = lines[lineNum++].split(" ")
        if (tokens[0] != "$") {
            throw Exception("Expected prompt, got ${tokens[0]}")
        }
        when (tokens[1]) {
            "cd" -> {
                val targetDir = tokens[2]
                when (targetDir) {
                    "/" -> {
                        if (cwd.parent != null) {
                            throw Exception("unexpected cd to root after start")
                        }
                        // else ignore
                    }
                    ".." -> {
                        return Pair(cwd.parent!!, lineNum)
                    }
                    else -> {
                        // assume "cd X" never precedes the ls output for its parent
                        return Pair(cwd.children.getValue(targetDir) as Dir, lineNum)
                    }
                }
            }
            "ls" -> {
                if (cwd.children.isNotEmpty()) {
                    throw Exception("already listed ${cwd.name}")
                } else {
                    while (lineNum < lines.size
                        && lines[lineNum].isNotEmpty()
                        && !lines[lineNum].startsWith("$")
                    ) {
                        val (dirOrSize, name) = lines[lineNum++].split(" ")
                        val child = if (dirOrSize == "dir") {
                            Dir(name, cwd)
                        } else {
                            File(name, dirOrSize.toInt())
                        }
                        if (cwd.children.containsKey(name))
                            throw Exception("$name already exists")
                        cwd.children[name] = child
                    }
                }
                return Pair(cwd, lineNum)
            }
            else -> {
                throw Exception("bad token ${tokens[1]}")
            }
        }
        return Pair(cwd, lineNum)
    }

    fun loadFileSystem(input: String): Dir {
        val lines = input.split("\n")
        val root = Dir("/", null)
        var cwd = root
        var lineNum = 0
        while (lineNum < lines.size && lines[lineNum].isNotEmpty()) {
            val res = executeLine(cwd, lines, lineNum)
            cwd = res.first
            lineNum = res.second
        }

        root.calcSize()
        return root
    }

    fun part1(root: Dir) {
        println("Part 1 sum of matching sizes: " + root.sumMatchingSizes())
    }

    fun part2(root: Dir) {
        val freeSpace = TOTAL_DISK_SPACE - root.size
        val spaceNeeded = UNUSED_SPACE_NEEDED - freeSpace
        if (spaceNeeded <= 0) {
            throw Exception("There's already enough free space")
        }
        println("Needed space: $spaceNeeded")
        val toDelete = root.findSmallestDirWithMinSize(spaceNeeded)
        println("Dir to delete: ${toDelete!!.name} ${toDelete!!.size}")
    }

    val input = object {}.javaClass.getResource("Day07.txt").readText()

    val root = loadFileSystem(input)
    part1(root)
    part2(root)
}

Compiled from "Day07.kt"
public final class Day07Kt$main$Dir extends Day07Kt$main$Node {
  private final Day07Kt$main$Dir parent;

  private final java.util.Map<java.lang.String, Day07Kt$main$Node> children;

  public Day07Kt$main$Dir(java.lang.String, Day07Kt$main$Dir);
    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: aload_1
       8: iconst_0
       9: invokespecial #17                 // Method Day07Kt$main$Node."<init>":(Ljava/lang/String;I)V
      12: aload_0
      13: aload_2
      14: putfield      #21                 // Field parent:LDay07Kt$main$Dir;
      17: aload_0
      18: new           #23                 // class java/util/LinkedHashMap
      21: dup
      22: invokespecial #26                 // Method java/util/LinkedHashMap."<init>":()V
      25: checkcast     #28                 // class java/util/Map
      28: putfield      #32                 // Field children:Ljava/util/Map;
      31: return

  public final Day07Kt$main$Dir getParent();
    Code:
       0: aload_0
       1: getfield      #21                 // Field parent:LDay07Kt$main$Dir;
       4: areturn

  public final java.util.Map<java.lang.String, Day07Kt$main$Node> getChildren();
    Code:
       0: aload_0
       1: getfield      #32                 // Field children:Ljava/util/Map;
       4: areturn

  public int calcSize();
    Code:
       0: aload_0
       1: aload_0
       2: getfield      #32                 // Field children:Ljava/util/Map;
       5: invokeinterface #45,  1           // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
      10: checkcast     #47                 // class java/lang/Iterable
      13: astore_1
      14: astore        7
      16: iconst_0
      17: istore_2
      18: aload_1
      19: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      24: astore_3
      25: aload_3
      26: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      31: ifeq          71
      34: aload_3
      35: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      40: astore        4
      42: iload_2
      43: aload         4
      45: checkcast     #4                  // class Day07Kt$main$Node
      48: astore        5
      50: istore        8
      52: iconst_0
      53: istore        6
      55: aload         5
      57: invokevirtual #63                 // Method Day07Kt$main$Node.calcSize:()I
      60: istore        9
      62: iload         8
      64: iload         9
      66: iadd
      67: istore_2
      68: goto          25
      71: iload_2
      72: istore        8
      74: aload         7
      76: iload         8
      78: invokevirtual #67                 // Method setSize:(I)V
      81: aload_0
      82: invokevirtual #70                 // Method getSize:()I
      85: ireturn

  public int sumMatchingSizes();
    Code:
       0: aload_0
       1: invokevirtual #70                 // Method getSize:()I
       4: ldc           #76                 // int 100000
       6: if_icmpgt     16
       9: aload_0
      10: invokevirtual #70                 // Method getSize:()I
      13: goto          17
      16: iconst_0
      17: aload_0
      18: getfield      #32                 // Field children:Ljava/util/Map;
      21: invokeinterface #45,  1           // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
      26: checkcast     #47                 // class java/lang/Iterable
      29: astore_1
      30: istore        7
      32: iconst_0
      33: istore_2
      34: aload_1
      35: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      40: astore_3
      41: aload_3
      42: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      47: ifeq          87
      50: aload_3
      51: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        4
      58: iload_2
      59: aload         4
      61: checkcast     #4                  // class Day07Kt$main$Node
      64: astore        5
      66: istore        8
      68: iconst_0
      69: istore        6
      71: aload         5
      73: invokevirtual #78                 // Method Day07Kt$main$Node.sumMatchingSizes:()I
      76: istore        9
      78: iload         8
      80: iload         9
      82: iadd
      83: istore_2
      84: goto          41
      87: iload_2
      88: istore        8
      90: iload         7
      92: iload         8
      94: iadd
      95: ireturn

  public final Day07Kt$main$Dir findSmallestDirWithMinSize(int);
    Code:
       0: aload_0
       1: invokevirtual #70                 // Method getSize:()I
       4: iload_1
       5: if_icmplt     12
       8: aload_0
       9: goto          13
      12: aconst_null
      13: astore_2
      14: aload_0
      15: getfield      #32                 // Field children:Ljava/util/Map;
      18: invokeinterface #45,  1           // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
      23: checkcast     #47                 // class java/lang/Iterable
      26: astore        4
      28: iconst_0
      29: istore        5
      31: aload         4
      33: astore        6
      35: new           #83                 // class java/util/ArrayList
      38: dup
      39: invokespecial #84                 // Method java/util/ArrayList."<init>":()V
      42: checkcast     #86                 // class java/util/Collection
      45: astore        7
      47: iconst_0
      48: istore        8
      50: aload         6
      52: astore        9
      54: iconst_0
      55: istore        10
      57: aload         9
      59: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      64: astore        11
      66: aload         11
      68: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      73: ifeq          150
      76: aload         11
      78: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      83: astore        12
      85: aload         12
      87: astore        13
      89: iconst_0
      90: istore        14
      92: aload         13
      94: checkcast     #4                  // class Day07Kt$main$Node
      97: astore        15
      99: iconst_0
     100: istore        16
     102: aload         15
     104: instanceof    #2                  // class Day07Kt$main$Dir
     107: ifne          114
     110: aconst_null
     111: goto          123
     114: aload         15
     116: checkcast     #2                  // class Day07Kt$main$Dir
     119: iload_1
     120: invokevirtual #88                 // Method findSmallestDirWithMinSize:(I)LDay07Kt$main$Dir;
     123: dup
     124: ifnull        145
     127: astore        17
     129: iconst_0
     130: istore        18
     132: aload         7
     134: aload         17
     136: invokeinterface #92,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     141: pop
     142: goto          146
     145: pop
     146: nop
     147: goto          66
     150: nop
     151: aload         7
     153: checkcast     #94                 // class java/util/List
     156: nop
     157: astore_3
     158: aload_2
     159: invokestatic  #100                // Method kotlin/collections/CollectionsKt.listOfNotNull:(Ljava/lang/Object;)Ljava/util/List;
     162: checkcast     #86                 // class java/util/Collection
     165: aload_3
     166: checkcast     #47                 // class java/lang/Iterable
     169: invokestatic  #104                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     172: checkcast     #47                 // class java/lang/Iterable
     175: new           #106                // class Day07Kt$main$Dir$findSmallestDirWithMinSize$$inlined$compareBy$1
     178: dup
     179: invokespecial #107                // Method Day07Kt$main$Dir$findSmallestDirWithMinSize$$inlined$compareBy$1."<init>":()V
     182: checkcast     #109                // class java/util/Comparator
     185: invokestatic  #113                // Method kotlin/collections/CollectionsKt.minWithOrNull:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/lang/Object;
     188: checkcast     #2                  // class Day07Kt$main$Dir
     191: areturn
}

Compiled from "Day07.kt"
public final class Day07Kt {
  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String args
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: ldc           #16                 // int 70000000
       8: istore_1
       9: ldc           #17                 // int 30000000
      11: istore_2
      12: new           #19                 // class Day07Kt$main$input$1
      15: dup
      16: invokespecial #23                 // Method Day07Kt$main$input$1."<init>":()V
      19: invokevirtual #27                 // Method java/lang/Object.getClass:()Ljava/lang/Class;
      22: ldc           #29                 // String Day07.txt
      24: invokevirtual #35                 // Method java/lang/Class.getResource:(Ljava/lang/String;)Ljava/net/URL;
      27: dup
      28: ldc           #37                 // String getResource(...)
      30: invokestatic  #40                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      33: astore        4
      35: getstatic     #46                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      38: astore        5
      40: aload         4
      42: invokestatic  #52                 // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B
      45: astore        6
      47: new           #54                 // class java/lang/String
      50: dup
      51: aload         6
      53: aload         5
      55: invokespecial #57                 // Method java/lang/String."<init>":([BLjava/nio/charset/Charset;)V
      58: astore_3
      59: aload_3
      60: invokestatic  #61                 // Method main$loadFileSystem:(Ljava/lang/String;)LDay07Kt$main$Dir;
      63: astore        4
      65: aload         4
      67: invokestatic  #65                 // Method main$part1:(LDay07Kt$main$Dir;)V
      70: iload_1
      71: iload_2
      72: aload         4
      74: invokestatic  #69                 // Method main$part2:(IILDay07Kt$main$Dir;)V
      77: return

  private static final kotlin.Pair<Day07Kt$main$Dir, java.lang.Integer> main$executeLine(Day07Kt$main$Dir, java.util.List<java.lang.String>, int);
    Code:
       0: iload_2
       1: istore_3
       2: aload_1
       3: iload_3
       4: iinc          3, 1
       7: invokeinterface #86,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      12: checkcast     #88                 // class java/lang/CharSequence
      15: iconst_1
      16: anewarray     #54                 // class java/lang/String
      19: astore        5
      21: aload         5
      23: iconst_0
      24: ldc           #90                 // String
      26: aastore
      27: aload         5
      29: iconst_0
      30: iconst_0
      31: bipush        6
      33: aconst_null
      34: invokestatic  #96                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      37: astore        4
      39: aload         4
      41: iconst_0
      42: invokeinterface #86,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      47: ldc           #98                 // String $
      49: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      52: ifne          92
      55: new           #104                // class java/lang/Exception
      58: dup
      59: new           #106                // class java/lang/StringBuilder
      62: dup
      63: invokespecial #107                // Method java/lang/StringBuilder."<init>":()V
      66: ldc           #109                // String Expected prompt, got
      68: invokevirtual #113                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      71: aload         4
      73: iconst_0
      74: invokeinterface #86,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      79: checkcast     #54                 // class java/lang/String
      82: invokevirtual #113                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      85: invokevirtual #117                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      88: invokespecial #120                // Method java/lang/Exception."<init>":(Ljava/lang/String;)V
      91: athrow
      92: aload         4
      94: iconst_1
      95: invokeinterface #86,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     100: checkcast     #54                 // class java/lang/String
     103: astore        5
     105: aload         5
     107: ldc           #122                // String cd
     109: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     112: ifeq          219
     115: aload         4
     117: iconst_2
     118: invokeinterface #86,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     123: checkcast     #54                 // class java/lang/String
     126: astore        6
     128: aload         6
     130: astore        7
     132: aload         7
     134: ldc           #124                // String /
     136: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     139: ifeq          159
     142: aload_0
     143: invokevirtual #130                // Method Day07Kt$main$Dir.getParent:()LDay07Kt$main$Dir;
     146: ifnull        553
     149: new           #104                // class java/lang/Exception
     152: dup
     153: ldc           #132                // String unexpected cd to root after start
     155: invokespecial #120                // Method java/lang/Exception."<init>":(Ljava/lang/String;)V
     158: athrow
     159: aload         7
     161: ldc           #134                // String ..
     163: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     166: ifeq          189
     169: new           #136                // class kotlin/Pair
     172: dup
     173: aload_0
     174: invokevirtual #130                // Method Day07Kt$main$Dir.getParent:()LDay07Kt$main$Dir;
     177: dup
     178: invokestatic  #140                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     181: iload_3
     182: invokestatic  #146                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     185: invokespecial #149                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     188: areturn
     189: new           #136                // class kotlin/Pair
     192: dup
     193: aload_0
     194: invokevirtual #153                // Method Day07Kt$main$Dir.getChildren:()Ljava/util/Map;
     197: aload         6
     199: invokestatic  #159                // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;
     202: dup
     203: ldc           #161                // String null cannot be cast to non-null type <root>.Day07Kt.main.Dir
     205: invokestatic  #163                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V
     208: checkcast     #126                // class Day07Kt$main$Dir
     211: iload_3
     212: invokestatic  #146                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     215: invokespecial #149                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     218: areturn
     219: aload         5
     221: ldc           #165                // String ls
     223: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     226: ifeq          516
     229: aload_0
     230: invokevirtual #153                // Method Day07Kt$main$Dir.getChildren:()Ljava/util/Map;
     233: invokeinterface #171,  1          // InterfaceMethod java/util/Map.isEmpty:()Z
     238: ifne          245
     241: iconst_1
     242: goto          246
     245: iconst_0
     246: ifeq          279
     249: new           #104                // class java/lang/Exception
     252: dup
     253: new           #106                // class java/lang/StringBuilder
     256: dup
     257: invokespecial #107                // Method java/lang/StringBuilder."<init>":()V
     260: ldc           #173                // String already listed
     262: invokevirtual #113                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     265: aload_0
     266: invokevirtual #176                // Method Day07Kt$main$Dir.getName:()Ljava/lang/String;
     269: invokevirtual #113                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     272: invokevirtual #117                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     275: invokespecial #120                // Method java/lang/Exception."<init>":(Ljava/lang/String;)V
     278: athrow
     279: iload_3
     280: aload_1
     281: invokeinterface #180,  1          // InterfaceMethod java/util/List.size:()I
     286: if_icmpge     503
     289: aload_1
     290: iload_3
     291: invokeinterface #86,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     296: checkcast     #88                 // class java/lang/CharSequence
     299: invokeinterface #183,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     304: ifle          311
     307: iconst_1
     308: goto          312
     311: iconst_0
     312: ifeq          503
     315: aload_1
     316: iload_3
     317: invokeinterface #86,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     322: checkcast     #54                 // class java/lang/String
     325: ldc           #98                 // String $
     327: iconst_0
     328: iconst_2
     329: aconst_null
     330: invokestatic  #187                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
     333: ifne          503
     336: aload_1
     337: iload_3
     338: iinc          3, 1
     341: invokeinterface #86,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     346: checkcast     #88                 // class java/lang/CharSequence
     349: iconst_1
     350: anewarray     #54                 // class java/lang/String
     353: astore        7
     355: aload         7
     357: iconst_0
     358: ldc           #90                 // String
     360: aastore
     361: aload         7
     363: iconst_0
     364: iconst_0
     365: bipush        6
     367: aconst_null
     368: invokestatic  #96                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     371: astore        6
     373: aload         6
     375: iconst_0
     376: invokeinterface #86,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     381: checkcast     #54                 // class java/lang/String
     384: astore        7
     386: aload         6
     388: iconst_1
     389: invokeinterface #86,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     394: checkcast     #54                 // class java/lang/String
     397: astore        8
     399: aload         7
     401: ldc           #189                // String dir
     403: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     406: ifeq          425
     409: new           #126                // class Day07Kt$main$Dir
     412: dup
     413: aload         8
     415: aload_0
     416: invokespecial #192                // Method Day07Kt$main$Dir."<init>":(Ljava/lang/String;LDay07Kt$main$Dir;)V
     419: checkcast     #194                // class Day07Kt$main$Node
     422: goto          442
     425: new           #196                // class Day07Kt$main$File
     428: dup
     429: aload         8
     431: aload         7
     433: invokestatic  #200                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     436: invokespecial #203                // Method Day07Kt$main$File."<init>":(Ljava/lang/String;I)V
     439: checkcast     #194                // class Day07Kt$main$Node
     442: astore        9
     444: aload_0
     445: invokevirtual #153                // Method Day07Kt$main$Dir.getChildren:()Ljava/util/Map;
     448: aload         8
     450: invokeinterface #207,  2          // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
     455: ifeq          486
     458: new           #104                // class java/lang/Exception
     461: dup
     462: new           #106                // class java/lang/StringBuilder
     465: dup
     466: invokespecial #107                // Method java/lang/StringBuilder."<init>":()V
     469: aload         8
     471: invokevirtual #113                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     474: ldc           #209                // String  already exists
     476: invokevirtual #113                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     479: invokevirtual #117                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     482: invokespecial #120                // Method java/lang/Exception."<init>":(Ljava/lang/String;)V
     485: athrow
     486: aload_0
     487: invokevirtual #153                // Method Day07Kt$main$Dir.getChildren:()Ljava/util/Map;
     490: aload         8
     492: aload         9
     494: invokeinterface #213,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     499: pop
     500: goto          279
     503: new           #136                // class kotlin/Pair
     506: dup
     507: aload_0
     508: iload_3
     509: invokestatic  #146                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     512: invokespecial #149                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     515: areturn
     516: new           #104                // class java/lang/Exception
     519: dup
     520: new           #106                // class java/lang/StringBuilder
     523: dup
     524: invokespecial #107                // Method java/lang/StringBuilder."<init>":()V
     527: ldc           #215                // String bad token
     529: invokevirtual #113                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     532: aload         4
     534: iconst_1
     535: invokeinterface #86,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     540: checkcast     #54                 // class java/lang/String
     543: invokevirtual #113                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     546: invokevirtual #117                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     549: invokespecial #120                // Method java/lang/Exception."<init>":(Ljava/lang/String;)V
     552: athrow
     553: new           #136                // class kotlin/Pair
     556: dup
     557: aload_0
     558: iload_3
     559: invokestatic  #146                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     562: invokespecial #149                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     565: areturn

  private static final Day07Kt$main$Dir main$loadFileSystem(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #88                 // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #54                 // class java/lang/String
       8: astore_2
       9: aload_2
      10: iconst_0
      11: ldc           #229                // String \n
      13: aastore
      14: aload_2
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #96                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: astore_1
      24: new           #126                // class Day07Kt$main$Dir
      27: dup
      28: ldc           #124                // String /
      30: aconst_null
      31: invokespecial #192                // Method Day07Kt$main$Dir."<init>":(Ljava/lang/String;LDay07Kt$main$Dir;)V
      34: astore_2
      35: aload_2
      36: astore_3
      37: iconst_0
      38: istore        4
      40: iload         4
      42: aload_1
      43: invokeinterface #180,  1          // InterfaceMethod java/util/List.size:()I
      48: if_icmpge     112
      51: aload_1
      52: iload         4
      54: invokeinterface #86,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      59: checkcast     #88                 // class java/lang/CharSequence
      62: invokeinterface #183,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      67: ifle          74
      70: iconst_1
      71: goto          75
      74: iconst_0
      75: ifeq          112
      78: aload_3
      79: aload_1
      80: iload         4
      82: invokestatic  #231                // Method main$executeLine:(LDay07Kt$main$Dir;Ljava/util/List;I)Lkotlin/Pair;
      85: astore        5
      87: aload         5
      89: invokevirtual #235                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      92: checkcast     #126                // class Day07Kt$main$Dir
      95: astore_3
      96: aload         5
      98: invokevirtual #238                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     101: checkcast     #240                // class java/lang/Number
     104: invokevirtual #243                // Method java/lang/Number.intValue:()I
     107: istore        4
     109: goto          40
     112: aload_2
     113: invokevirtual #246                // Method Day07Kt$main$Dir.calcSize:()I
     116: pop
     117: aload_2
     118: areturn

  private static final void main$part1(Day07Kt$main$Dir);
    Code:
       0: new           #106                // class java/lang/StringBuilder
       3: dup
       4: invokespecial #107                // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #250                // String Part 1 sum of matching sizes:
       9: invokevirtual #113                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: invokevirtual #253                // Method Day07Kt$main$Dir.sumMatchingSizes:()I
      16: invokevirtual #256                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: invokevirtual #117                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      22: getstatic     #262                // Field java/lang/System.out:Ljava/io/PrintStream;
      25: swap
      26: invokevirtual #267                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      29: return

  private static final void main$part2(int, int, Day07Kt$main$Dir);
    Code:
       0: iload_0
       1: aload_2
       2: invokevirtual #270                // Method Day07Kt$main$Dir.getSize:()I
       5: isub
       6: istore_3
       7: iload_1
       8: iload_3
       9: isub
      10: istore        4
      12: iload         4
      14: ifgt          28
      17: new           #104                // class java/lang/Exception
      20: dup
      21: ldc_w         #272                // String There\'s already enough free space
      24: invokespecial #120                // Method java/lang/Exception."<init>":(Ljava/lang/String;)V
      27: athrow
      28: new           #106                // class java/lang/StringBuilder
      31: dup
      32: invokespecial #107                // Method java/lang/StringBuilder."<init>":()V
      35: ldc_w         #274                // String Needed space:
      38: invokevirtual #113                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      41: iload         4
      43: invokevirtual #256                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      46: invokevirtual #117                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      49: getstatic     #262                // Field java/lang/System.out:Ljava/io/PrintStream;
      52: swap
      53: invokevirtual #267                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      56: aload_2
      57: iload         4
      59: invokevirtual #278                // Method Day07Kt$main$Dir.findSmallestDirWithMinSize:(I)LDay07Kt$main$Dir;
      62: astore        5
      64: new           #106                // class java/lang/StringBuilder
      67: dup
      68: invokespecial #107                // Method java/lang/StringBuilder."<init>":()V
      71: ldc_w         #280                // String Dir to delete:
      74: invokevirtual #113                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      77: aload         5
      79: dup
      80: invokestatic  #140                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      83: invokevirtual #176                // Method Day07Kt$main$Dir.getName:()Ljava/lang/String;
      86: invokevirtual #113                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      89: bipush        32
      91: invokevirtual #283                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      94: aload         5
      96: invokevirtual #270                // Method Day07Kt$main$Dir.getSize:()I
      99: invokevirtual #256                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     102: invokevirtual #117                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     105: getstatic     #262                // Field java/lang/System.out:Ljava/io/PrintStream;
     108: swap
     109: invokevirtual #267                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     112: return
}

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

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

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

  private int size;

  public Day07Kt$main$Node(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 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 abstract int calcSize();

  public abstract int sumMatchingSizes();
}

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

Compiled from "Day07.kt"
public final class Day07Kt$main$File extends Day07Kt$main$Node {
  public Day07Kt$main$File(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: aload_1
       8: iload_2
       9: invokespecial #16                 // Method Day07Kt$main$Node."<init>":(Ljava/lang/String;I)V
      12: return

  public int calcSize();
    Code:
       0: aload_0
       1: invokevirtual #26                 // Method getSize:()I
       4: ireturn

  public int sumMatchingSizes();
    Code:
       0: iconst_0
       1: ireturn
}


fun main(args: Array<String>) {
    fun findCommonElement(strings: List<String>): Char {
        val sets = strings.map { it.toSet() }
        val intersection = sets.reduce { acc, set -> acc.intersect(set) }
        if (intersection.size != 1) {
            throw RuntimeException("expected exactly one match, found ${intersection.size}")
        }
        return intersection.elementAt(0)
    }

    fun findMispackedTypeInRow(row: String): Char? {
        if (row.isEmpty()) return null

        val left = row.substring(0, row.length / 2)
        val right = row.substring(row.length / 2, row.length)
        return findCommonElement(listOf(left, right))
    }

    fun scoreType(type: Char?): Int {
        return if (type == null) {
            0
        } else if (type.isLowerCase()) {
            type - 'a' + 1
        } else {
            type - 'A' + 27
        }
    }

    fun findBadge(rows: List<String>): Char {
        return findCommonElement(rows)
    }

    fun part1(input: String) {
        var sum = 0
        input.split("\n").forEach {
            val type = findMispackedTypeInRow(it)
            sum += scoreType(type)
        }
        println(sum)
    }

    fun part2(input: String) {
        val lines = input.split("\n")
        var i = 0
        var sum = 0
        while (i < lines.size && lines[i].isNotEmpty()) {
            val badge = findBadge(lines.subList(i, i + 3))
            sum += scoreType(badge)
            i += 3
        }
        println(sum)
    }

    val input = object {}.javaClass.getResource("Day03.txt").readText()
    part1(input)
    part2(input)
}

Compiled from "Day03.kt"
public final class Day03Kt {
  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String args
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #17                 // class Day03Kt$main$input$1
       9: dup
      10: invokespecial #21                 // Method Day03Kt$main$input$1."<init>":()V
      13: invokevirtual #25                 // Method java/lang/Object.getClass:()Ljava/lang/Class;
      16: ldc           #27                 // String Day03.txt
      18: invokevirtual #33                 // Method java/lang/Class.getResource:(Ljava/lang/String;)Ljava/net/URL;
      21: dup
      22: ldc           #35                 // String getResource(...)
      24: invokestatic  #38                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      27: astore_2
      28: getstatic     #44                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      31: astore_3
      32: aload_2
      33: invokestatic  #50                 // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B
      36: astore        4
      38: new           #52                 // class java/lang/String
      41: dup
      42: aload         4
      44: aload_3
      45: invokespecial #55                 // Method java/lang/String."<init>":([BLjava/nio/charset/Charset;)V
      48: astore_1
      49: aload_1
      50: invokestatic  #59                 // Method main$part1:(Ljava/lang/String;)V
      53: aload_1
      54: invokestatic  #62                 // Method main$part2:(Ljava/lang/String;)V
      57: return

  private static final char main$findCommonElement(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #70                 // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: astore        4
      10: new           #72                 // class java/util/ArrayList
      13: dup
      14: aload_2
      15: bipush        10
      17: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      20: invokespecial #81                 // Method java/util/ArrayList."<init>":(I)V
      23: checkcast     #83                 // class java/util/Collection
      26: astore        5
      28: iconst_0
      29: istore        6
      31: aload         4
      33: invokeinterface #87,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      38: astore        7
      40: aload         7
      42: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      47: ifeq          93
      50: aload         7
      52: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      57: astore        8
      59: aload         5
      61: aload         8
      63: checkcast     #52                 // class java/lang/String
      66: astore        9
      68: astore        11
      70: iconst_0
      71: istore        10
      73: aload         9
      75: checkcast     #99                 // class java/lang/CharSequence
      78: invokestatic  #105                // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;
      81: aload         11
      83: swap
      84: invokeinterface #109,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      89: pop
      90: goto          40
      93: aload         5
      95: checkcast     #111                // class java/util/List
      98: nop
      99: astore_1
     100: aload_1
     101: checkcast     #70                 // class java/lang/Iterable
     104: astore_3
     105: iconst_0
     106: istore        4
     108: aload_3
     109: invokeinterface #87,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     114: astore        5
     116: aload         5
     118: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     123: ifne          136
     126: new           #113                // class java/lang/UnsupportedOperationException
     129: dup
     130: ldc           #115                // String Empty collection can\'t be reduced.
     132: invokespecial #117                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     135: athrow
     136: aload         5
     138: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     143: astore        6
     145: aload         5
     147: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     152: ifeq          195
     155: aload         6
     157: aload         5
     159: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     164: checkcast     #119                // class java/util/Set
     167: astore        7
     169: checkcast     #119                // class java/util/Set
     172: astore        8
     174: iconst_0
     175: istore        9
     177: aload         8
     179: checkcast     #70                 // class java/lang/Iterable
     182: aload         7
     184: checkcast     #70                 // class java/lang/Iterable
     187: invokestatic  #123                // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
     190: astore        6
     192: goto          145
     195: aload         6
     197: checkcast     #119                // class java/util/Set
     200: astore_2
     201: aload_2
     202: invokeinterface #127,  1          // InterfaceMethod java/util/Set.size:()I
     207: iconst_1
     208: if_icmpeq     243
     211: new           #129                // class java/lang/RuntimeException
     214: dup
     215: new           #131                // class java/lang/StringBuilder
     218: dup
     219: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
     222: ldc           #134                // String expected exactly one match, found
     224: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     227: aload_2
     228: invokeinterface #127,  1          // InterfaceMethod java/util/Set.size:()I
     233: invokevirtual #141                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     236: invokevirtual #145                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     239: invokespecial #146                // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V
     242: athrow
     243: aload_2
     244: checkcast     #70                 // class java/lang/Iterable
     247: iconst_0
     248: invokestatic  #150                // Method kotlin/collections/CollectionsKt.elementAt:(Ljava/lang/Iterable;I)Ljava/lang/Object;
     251: checkcast     #152                // class java/lang/Character
     254: invokevirtual #156                // Method java/lang/Character.charValue:()C
     257: ireturn

  private static final java.lang.Character main$findMispackedTypeInRow(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #99                 // class java/lang/CharSequence
       4: invokeinterface #186,  1          // InterfaceMethod java/lang/CharSequence.length:()I
       9: ifne          16
      12: iconst_1
      13: goto          17
      16: iconst_0
      17: ifeq          22
      20: aconst_null
      21: areturn
      22: aload_0
      23: iconst_0
      24: aload_0
      25: invokevirtual #187                // Method java/lang/String.length:()I
      28: iconst_2
      29: idiv
      30: invokevirtual #191                // Method java/lang/String.substring:(II)Ljava/lang/String;
      33: dup
      34: ldc           #193                // String substring(...)
      36: invokestatic  #38                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      39: astore_1
      40: aload_0
      41: aload_0
      42: invokevirtual #187                // Method java/lang/String.length:()I
      45: iconst_2
      46: idiv
      47: aload_0
      48: invokevirtual #187                // Method java/lang/String.length:()I
      51: invokevirtual #191                // Method java/lang/String.substring:(II)Ljava/lang/String;
      54: dup
      55: ldc           #193                // String substring(...)
      57: invokestatic  #38                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      60: astore_2
      61: iconst_2
      62: anewarray     #52                 // class java/lang/String
      65: astore_3
      66: aload_3
      67: iconst_0
      68: aload_1
      69: aastore
      70: aload_3
      71: iconst_1
      72: aload_2
      73: aastore
      74: aload_3
      75: invokestatic  #197                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      78: invokestatic  #199                // Method main$findCommonElement:(Ljava/util/List;)C
      81: invokestatic  #203                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      84: areturn

  private static final int main$scoreType(java.lang.Character);
    Code:
       0: aload_0
       1: ifnonnull     8
       4: iconst_0
       5: goto          40
       8: aload_0
       9: invokevirtual #156                // Method java/lang/Character.charValue:()C
      12: invokestatic  #212                // Method java/lang/Character.isLowerCase:(C)Z
      15: ifeq          30
      18: aload_0
      19: invokevirtual #156                // Method java/lang/Character.charValue:()C
      22: bipush        97
      24: isub
      25: iconst_1
      26: iadd
      27: goto          40
      30: aload_0
      31: invokevirtual #156                // Method java/lang/Character.charValue:()C
      34: bipush        65
      36: isub
      37: bipush        27
      39: iadd
      40: ireturn

  private static final char main$findBadge(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #199                // Method main$findCommonElement:(Ljava/util/List;)C
       4: ireturn

  private static final void main$part1(java.lang.String);
    Code:
       0: iconst_0
       1: istore_1
       2: aload_0
       3: checkcast     #99                 // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #52                 // class java/lang/String
      10: astore_2
      11: aload_2
      12: iconst_0
      13: ldc           #218                // String \n
      15: aastore
      16: aload_2
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #222                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      25: checkcast     #70                 // class java/lang/Iterable
      28: astore_2
      29: iconst_0
      30: istore_3
      31: aload_2
      32: invokeinterface #87,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        4
      39: aload         4
      41: invokeinterface #93,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          88
      49: aload         4
      51: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        5
      58: aload         5
      60: checkcast     #52                 // class java/lang/String
      63: astore        6
      65: iconst_0
      66: istore        7
      68: aload         6
      70: invokestatic  #224                // Method main$findMispackedTypeInRow:(Ljava/lang/String;)Ljava/lang/Character;
      73: astore        8
      75: iload_1
      76: aload         8
      78: invokestatic  #226                // Method main$scoreType:(Ljava/lang/Character;)I
      81: iadd
      82: istore_1
      83: nop
      84: nop
      85: goto          39
      88: nop
      89: iload_1
      90: istore_2
      91: getstatic     #232                // Field java/lang/System.out:Ljava/io/PrintStream;
      94: iload_2
      95: invokevirtual #237                // Method java/io/PrintStream.println:(I)V
      98: return

  private static final void main$part2(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #99                 // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #52                 // class java/lang/String
       8: astore_2
       9: aload_2
      10: iconst_0
      11: ldc           #218                // String \n
      13: aastore
      14: aload_2
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #222                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: astore_1
      24: iconst_0
      25: istore_2
      26: iconst_0
      27: istore_3
      28: iload_2
      29: aload_1
      30: invokeinterface #243,  1          // InterfaceMethod java/util/List.size:()I
      35: if_icmpge     96
      38: aload_1
      39: iload_2
      40: invokeinterface #247,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      45: checkcast     #99                 // class java/lang/CharSequence
      48: invokeinterface #186,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      53: ifle          60
      56: iconst_1
      57: goto          61
      60: iconst_0
      61: ifeq          96
      64: aload_1
      65: iload_2
      66: iload_2
      67: iconst_3
      68: iadd
      69: invokeinterface #251,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
      74: invokestatic  #253                // Method main$findBadge:(Ljava/util/List;)C
      77: istore        4
      79: iload_3
      80: iload         4
      82: invokestatic  #203                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      85: invokestatic  #226                // Method main$scoreType:(Ljava/lang/Character;)I
      88: iadd
      89: istore_3
      90: iinc          2, 3
      93: goto          28
      96: getstatic     #232                // Field java/lang/System.out:Ljava/io/PrintStream;
      99: iload_3
     100: invokevirtual #237                // Method java/io/PrintStream.println:(I)V
     103: return
}

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


fun main(args: Array<String>) {
    class Shape(
        val draw: Char,
        val defeats: Char,
        val score: Int
    )

    val shapes = buildMap<Char, Shape> {
        put('X', Shape('A', 'C', 1)) // Rock smashes Scissors
        put('Y', Shape('B', 'A', 2)) // Paper covers Rock
        put('Z', Shape('C', 'B', 3)) // Scissors cuts Paper
    }

    class OpponentShape(win: Char, lose: Char, draw: Char) {
        val win = shapes[win]!!
        val lose = shapes[lose]!!
        val draw = shapes[draw]!!
    }

    val opponentShapes = buildMap<Char, OpponentShape> {
        put('A', OpponentShape('Y', 'Z', 'X'))
        put('B', OpponentShape('Z', 'X', 'Y'))
        put('C', OpponentShape('X', 'Y', 'Z'))
    }

    fun scoreRow(row: String, secondColumIsWLD: Boolean): Int {
        if (row.isEmpty())
            return 0

        val opponent = row[0]
        val shape = if (secondColumIsWLD) {
            val opponentShape = opponentShapes[opponent]!!
            when (row[2]) {
                'X' -> opponentShape.lose
                'Y' -> opponentShape.draw
                'Z' -> opponentShape.win
                else -> throw RuntimeException("unhandled input")
            }
        } else {
            shapes[row[2]]!!
        }

        return shape.score + when (opponent) {
            shape.defeats -> 6
            shape.draw -> 3
            else -> 0
        }
    }

    fun partN(input: String, secondColumIsWLD: Boolean) {
        var score = 0
        input.split("\n").forEach {
            score += scoreRow(it, secondColumIsWLD)
        }
        println(score)
    }

    fun part1(input: String) {
        partN(input, false)
    }

    fun part2(input: String) {
        partN(input, true)
    }

    val input = object {}.javaClass.getResource("Day02.txt").readText()
    part1(input)
    part2(input)
}

Compiled from "Day02.kt"
public final class Day02Kt {
  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String args
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: invokestatic  #21                 // Method kotlin/collections/MapsKt.createMapBuilder:()Ljava/util/Map;
       9: astore_2
      10: aload_2
      11: astore_3
      12: iconst_0
      13: istore        4
      15: aload_3
      16: bipush        88
      18: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      21: new           #29                 // class Day02Kt$main$Shape
      24: dup
      25: bipush        65
      27: bipush        67
      29: iconst_1
      30: invokespecial #33                 // Method Day02Kt$main$Shape."<init>":(CCI)V
      33: invokeinterface #39,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      38: pop
      39: aload_3
      40: bipush        89
      42: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      45: new           #29                 // class Day02Kt$main$Shape
      48: dup
      49: bipush        66
      51: bipush        65
      53: iconst_2
      54: invokespecial #33                 // Method Day02Kt$main$Shape."<init>":(CCI)V
      57: invokeinterface #39,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      62: pop
      63: aload_3
      64: bipush        90
      66: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      69: new           #29                 // class Day02Kt$main$Shape
      72: dup
      73: bipush        67
      75: bipush        66
      77: iconst_3
      78: invokespecial #33                 // Method Day02Kt$main$Shape."<init>":(CCI)V
      81: invokeinterface #39,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      86: pop
      87: nop
      88: aload_2
      89: invokestatic  #43                 // Method kotlin/collections/MapsKt.build:(Ljava/util/Map;)Ljava/util/Map;
      92: astore_1
      93: invokestatic  #21                 // Method kotlin/collections/MapsKt.createMapBuilder:()Ljava/util/Map;
      96: astore_3
      97: aload_3
      98: astore        4
     100: iconst_0
     101: istore        5
     103: aload         4
     105: bipush        65
     107: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     110: new           #45                 // class Day02Kt$main$OpponentShape
     113: dup
     114: aload_1
     115: bipush        89
     117: bipush        90
     119: bipush        88
     121: invokespecial #48                 // Method Day02Kt$main$OpponentShape."<init>":(Ljava/util/Map;CCC)V
     124: invokeinterface #39,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     129: pop
     130: aload         4
     132: bipush        66
     134: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     137: new           #45                 // class Day02Kt$main$OpponentShape
     140: dup
     141: aload_1
     142: bipush        90
     144: bipush        88
     146: bipush        89
     148: invokespecial #48                 // Method Day02Kt$main$OpponentShape."<init>":(Ljava/util/Map;CCC)V
     151: invokeinterface #39,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     156: pop
     157: aload         4
     159: bipush        67
     161: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     164: new           #45                 // class Day02Kt$main$OpponentShape
     167: dup
     168: aload_1
     169: bipush        88
     171: bipush        89
     173: bipush        90
     175: invokespecial #48                 // Method Day02Kt$main$OpponentShape."<init>":(Ljava/util/Map;CCC)V
     178: invokeinterface #39,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     183: pop
     184: nop
     185: aload_3
     186: invokestatic  #43                 // Method kotlin/collections/MapsKt.build:(Ljava/util/Map;)Ljava/util/Map;
     189: astore_2
     190: new           #50                 // class Day02Kt$main$input$1
     193: dup
     194: invokespecial #53                 // Method Day02Kt$main$input$1."<init>":()V
     197: invokevirtual #57                 // Method java/lang/Object.getClass:()Ljava/lang/Class;
     200: ldc           #59                 // String Day02.txt
     202: invokevirtual #65                 // Method java/lang/Class.getResource:(Ljava/lang/String;)Ljava/net/URL;
     205: dup
     206: ldc           #67                 // String getResource(...)
     208: invokestatic  #70                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     211: astore        4
     213: getstatic     #76                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
     216: astore        5
     218: aload         4
     220: invokestatic  #82                 // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B
     223: astore        6
     225: new           #84                 // class java/lang/String
     228: dup
     229: aload         6
     231: aload         5
     233: invokespecial #87                 // Method java/lang/String."<init>":([BLjava/nio/charset/Charset;)V
     236: astore_3
     237: aload_2
     238: aload_1
     239: aload_3
     240: invokestatic  #91                 // Method main$part1:(Ljava/util/Map;Ljava/util/Map;Ljava/lang/String;)V
     243: aload_2
     244: aload_1
     245: aload_3
     246: invokestatic  #94                 // Method main$part2:(Ljava/util/Map;Ljava/util/Map;Ljava/lang/String;)V
     249: return

  private static final int main$scoreRow(java.util.Map<java.lang.Character, Day02Kt$main$OpponentShape>, java.util.Map<java.lang.Character, Day02Kt$main$Shape>, java.lang.String, boolean);
    Code:
       0: aload_2
       1: checkcast     #110                // class java/lang/CharSequence
       4: invokeinterface #114,  1          // InterfaceMethod java/lang/CharSequence.length:()I
       9: ifne          16
      12: iconst_1
      13: goto          17
      16: iconst_0
      17: ifeq          22
      20: iconst_0
      21: ireturn
      22: aload_2
      23: iconst_0
      24: invokevirtual #118                // Method java/lang/String.charAt:(I)C
      27: istore        4
      29: iload_3
      30: ifeq          118
      33: aload_0
      34: iload         4
      36: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      39: invokeinterface #122,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      44: dup
      45: invokestatic  #126                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      48: checkcast     #45                 // class Day02Kt$main$OpponentShape
      51: astore        6
      53: aload_2
      54: iconst_2
      55: invokevirtual #118                // Method java/lang/String.charAt:(I)C
      58: tableswitch   { // 88 to 90
                    88: 84
                    89: 92
                    90: 100
               default: 108
          }
      84: aload         6
      86: invokevirtual #130                // Method Day02Kt$main$OpponentShape.getLose:()LDay02Kt$main$Shape;
      89: goto          139
      92: aload         6
      94: invokevirtual #133                // Method Day02Kt$main$OpponentShape.getDraw:()LDay02Kt$main$Shape;
      97: goto          139
     100: aload         6
     102: invokevirtual #136                // Method Day02Kt$main$OpponentShape.getWin:()LDay02Kt$main$Shape;
     105: goto          139
     108: new           #138                // class java/lang/RuntimeException
     111: dup
     112: ldc           #140                // String unhandled input
     114: invokespecial #143                // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V
     117: athrow
     118: aload_1
     119: aload_2
     120: iconst_2
     121: invokevirtual #118                // Method java/lang/String.charAt:(I)C
     124: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     127: invokeinterface #122,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     132: dup
     133: invokestatic  #126                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     136: checkcast     #29                 // class Day02Kt$main$Shape
     139: astore        5
     141: aload         5
     143: invokevirtual #146                // Method Day02Kt$main$Shape.getScore:()I
     146: iload         4
     148: istore        6
     150: iload         6
     152: aload         5
     154: invokevirtual #150                // Method Day02Kt$main$Shape.getDefeats:()C
     157: if_icmpne     165
     160: bipush        6
     162: goto          180
     165: iload         6
     167: aload         5
     169: invokevirtual #152                // Method Day02Kt$main$Shape.getDraw:()C
     172: if_icmpne     179
     175: iconst_3
     176: goto          180
     179: iconst_0
     180: iadd
     181: ireturn

  private static final void main$partN(java.util.Map<java.lang.Character, Day02Kt$main$OpponentShape>, java.util.Map<java.lang.Character, Day02Kt$main$Shape>, java.lang.String, boolean);
    Code:
       0: iconst_0
       1: istore        4
       3: aload_2
       4: checkcast     #110                // class java/lang/CharSequence
       7: iconst_1
       8: anewarray     #84                 // class java/lang/String
      11: astore        5
      13: aload         5
      15: iconst_0
      16: ldc           #166                // String \n
      18: aastore
      19: aload         5
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #172                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: checkcast     #174                // class java/lang/Iterable
      32: astore        5
      34: iconst_0
      35: istore        6
      37: aload         5
      39: invokeinterface #178,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      44: astore        7
      46: aload         7
      48: invokeinterface #184,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      53: ifeq          93
      56: aload         7
      58: invokeinterface #188,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: astore        8
      65: aload         8
      67: checkcast     #84                 // class java/lang/String
      70: astore        9
      72: iconst_0
      73: istore        10
      75: iload         4
      77: aload_0
      78: aload_1
      79: aload         9
      81: iload_3
      82: invokestatic  #190                // Method main$scoreRow:(Ljava/util/Map;Ljava/util/Map;Ljava/lang/String;Z)I
      85: iadd
      86: istore        4
      88: nop
      89: nop
      90: goto          46
      93: nop
      94: iload         4
      96: istore        5
      98: getstatic     #196                // Field java/lang/System.out:Ljava/io/PrintStream;
     101: iload         5
     103: invokevirtual #202                // Method java/io/PrintStream.println:(I)V
     106: return

  private static final void main$part1(java.util.Map<java.lang.Character, Day02Kt$main$OpponentShape>, java.util.Map<java.lang.Character, Day02Kt$main$Shape>, java.lang.String);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: iconst_0
       4: invokestatic  #213                // Method main$partN:(Ljava/util/Map;Ljava/util/Map;Ljava/lang/String;Z)V
       7: return

  private static final void main$part2(java.util.Map<java.lang.Character, Day02Kt$main$OpponentShape>, java.util.Map<java.lang.Character, Day02Kt$main$Shape>, java.lang.String);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: iconst_1
       4: invokestatic  #213                // Method main$partN:(Ljava/util/Map;Ljava/util/Map;Ljava/lang/String;Z)V
       7: return
}

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

Compiled from "Day02.kt"
public final class Day02Kt$main$Shape {
  private final char draw;

  private final char defeats;

  private final int score;

  public Day02Kt$main$Shape(char, char, int);
    Code:
       0: aload_0
       1: invokespecial #9                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: iload_1
       6: putfield      #13                 // Field draw:C
       9: aload_0
      10: iload_2
      11: putfield      #16                 // Field defeats:C
      14: aload_0
      15: iload_3
      16: putfield      #20                 // Field score:I
      19: return

  public final char getDraw();
    Code:
       0: aload_0
       1: getfield      #13                 // Field draw:C
       4: ireturn

  public final char getDefeats();
    Code:
       0: aload_0
       1: getfield      #16                 // Field defeats:C
       4: ireturn

  public final int getScore();
    Code:
       0: aload_0
       1: getfield      #20                 // Field score:I
       4: ireturn
}

Compiled from "Day02.kt"
public final class Day02Kt$main$OpponentShape {
  private final Day02Kt$main$Shape win;

  private final Day02Kt$main$Shape lose;

  private final Day02Kt$main$Shape draw;

  public Day02Kt$main$OpponentShape(java.util.Map<java.lang.Character, Day02Kt$main$Shape>, char, char, char);
    Code:
       0: aload_0
       1: invokespecial #10                 // Method java/lang/Object."<init>":()V
       4: aload_0
       5: aload_1
       6: iload_2
       7: invokestatic  #16                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      10: invokeinterface #22,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      15: dup
      16: invokestatic  #28                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      19: checkcast     #30                 // class Day02Kt$main$Shape
      22: putfield      #34                 // Field win:LDay02Kt$main$Shape;
      25: aload_0
      26: aload_1
      27: iload_3
      28: invokestatic  #16                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      31: invokeinterface #22,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      36: dup
      37: invokestatic  #28                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      40: checkcast     #30                 // class Day02Kt$main$Shape
      43: putfield      #37                 // Field lose:LDay02Kt$main$Shape;
      46: aload_0
      47: aload_1
      48: iload         4
      50: invokestatic  #16                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      53: invokeinterface #22,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      58: dup
      59: invokestatic  #28                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      62: checkcast     #30                 // class Day02Kt$main$Shape
      65: putfield      #40                 // Field draw:LDay02Kt$main$Shape;
      68: return

  public final Day02Kt$main$Shape getWin();
    Code:
       0: aload_0
       1: getfield      #34                 // Field win:LDay02Kt$main$Shape;
       4: areturn

  public final Day02Kt$main$Shape getLose();
    Code:
       0: aload_0
       1: getfield      #37                 // Field lose:LDay02Kt$main$Shape;
       4: areturn

  public final Day02Kt$main$Shape getDraw();
    Code:
       0: aload_0
       1: getfield      #40                 // Field draw:LDay02Kt$main$Shape;
       4: areturn
}


/**
 * Advent of Code 2021 Day 1 solution.
 * This is currently a fairly minimalistic code.
 */

import java.io.File

val testin = """
199
200
208
210
200
207
240
269
260
263
  """.trimIndent()

/**
 * Get diff of List "as series", first element will be null.
 */
private fun diff(ints: List<Int>): List<Int?> {
  val diffs = ints.mapIndexed { idx, elem -> if (idx == 0) null else elem - ints[idx - 1] }
  return diffs
}

private fun getIncsCount(inp: String): Int {
  //val ints = listOf(1, 2, 3, 2, 1)
  val ints = inp.split("\n").map { it.toInt() };
  val diffs = diff(ints)
  val incs = diffs.filterNotNull().filter { it > 0 }.size
  //println(ints)
  //println(diffs)
  return incs
}

private fun getIncs3Count(inp: String): Int {
  //val ints = listOf(1, 2, 3, 2, 1)
  var ints = inp.split("\n").map{ it.toInt() };
  //println(ints.windowed(3))
  //println(ints.windowed(3).map{it.sum()})
  ints = ints.windowed(3).map{it.sum()}
  val diffs = diff(ints)
  val incs = diffs.filterNotNull().filter{ it > 0 }.size
  //println(ints)
  //println(diffs)
  return incs
}

fun main(args: Array<String>){
  var incs = getIncsCount(testin)
  println("rc=$incs")
  val inp = File("./in/day01.in").readText().trim()
  incs = getIncsCount(inp)
  println("rc=$incs")

  incs = getIncs3Count(testin)
  println("rc=$incs")
  incs = getIncs3Count(inp)
  println("rc=$incs")
}

Compiled from "day01.kt"
public final class Day01Kt {
  private static final java.lang.String testin;

  public static final java.lang.String getTestin();
    Code:
       0: getstatic     #11                 // Field testin:Ljava/lang/String;
       3: areturn

  private static final java.util.List<java.lang.Integer> diff(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: checkcast     #16                 // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: astore        4
      10: new           #18                 // class java/util/ArrayList
      13: dup
      14: aload_2
      15: bipush        10
      17: invokestatic  #24                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      20: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
      23: checkcast     #30                 // class java/util/Collection
      26: astore        5
      28: iconst_0
      29: istore        6
      31: iconst_0
      32: istore        7
      34: aload         4
      36: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      41: astore        8
      43: aload         8
      45: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifeq          141
      53: aload         8
      55: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      60: astore        9
      62: aload         5
      64: iload         7
      66: iinc          7, 1
      69: istore        10
      71: iload         10
      73: ifge          79
      76: invokestatic  #48                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      79: iload         10
      81: aload         9
      83: checkcast     #50                 // class java/lang/Number
      86: invokevirtual #54                 // Method java/lang/Number.intValue:()I
      89: istore        11
      91: istore        12
      93: astore        14
      95: iconst_0
      96: istore        13
      98: iload         12
     100: ifne          107
     103: aconst_null
     104: goto          129
     107: iload         11
     109: aload_0
     110: iload         12
     112: iconst_1
     113: isub
     114: invokeinterface #60,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     119: checkcast     #50                 // class java/lang/Number
     122: invokevirtual #54                 // Method java/lang/Number.intValue:()I
     125: isub
     126: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     129: aload         14
     131: swap
     132: invokeinterface #70,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     137: pop
     138: goto          43
     141: aload         5
     143: checkcast     #56                 // class java/util/List
     146: nop
     147: astore_1
     148: aload_1
     149: areturn

  private static final int getIncsCount(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #91                 // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #93                 // class java/lang/String
       8: astore_2
       9: aload_2
      10: iconst_0
      11: ldc           #95                 // String \n
      13: aastore
      14: aload_2
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #101                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: checkcast     #16                 // class java/lang/Iterable
      26: astore_2
      27: iconst_0
      28: istore_3
      29: aload_2
      30: astore        4
      32: new           #18                 // class java/util/ArrayList
      35: dup
      36: aload_2
      37: bipush        10
      39: invokestatic  #24                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      42: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
      45: checkcast     #30                 // class java/util/Collection
      48: astore        5
      50: iconst_0
      51: istore        6
      53: aload         4
      55: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      60: astore        7
      62: aload         7
      64: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      69: ifeq          116
      72: aload         7
      74: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      79: astore        8
      81: aload         5
      83: aload         8
      85: checkcast     #93                 // class java/lang/String
      88: astore        9
      90: astore        13
      92: iconst_0
      93: istore        10
      95: aload         9
      97: invokestatic  #104                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     100: nop
     101: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     104: aload         13
     106: swap
     107: invokeinterface #70,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     112: pop
     113: goto          62
     116: aload         5
     118: checkcast     #56                 // class java/util/List
     121: nop
     122: astore_1
     123: aload_1
     124: invokestatic  #106                // Method diff:(Ljava/util/List;)Ljava/util/List;
     127: astore_2
     128: aload_2
     129: checkcast     #16                 // class java/lang/Iterable
     132: invokestatic  #110                // Method kotlin/collections/CollectionsKt.filterNotNull:(Ljava/lang/Iterable;)Ljava/util/List;
     135: checkcast     #16                 // class java/lang/Iterable
     138: astore        4
     140: iconst_0
     141: istore        5
     143: aload         4
     145: astore        6
     147: new           #18                 // class java/util/ArrayList
     150: dup
     151: invokespecial #112                // Method java/util/ArrayList."<init>":()V
     154: checkcast     #30                 // class java/util/Collection
     157: astore        7
     159: iconst_0
     160: istore        8
     162: aload         6
     164: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     169: astore        9
     171: aload         9
     173: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     178: ifeq          229
     181: aload         9
     183: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     188: astore        10
     190: aload         10
     192: checkcast     #50                 // class java/lang/Number
     195: invokevirtual #54                 // Method java/lang/Number.intValue:()I
     198: istore        11
     200: iconst_0
     201: istore        12
     203: iload         11
     205: ifle          212
     208: iconst_1
     209: goto          213
     212: iconst_0
     213: ifeq          171
     216: aload         7
     218: aload         10
     220: invokeinterface #70,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     225: pop
     226: goto          171
     229: aload         7
     231: checkcast     #56                 // class java/util/List
     234: nop
     235: invokeinterface #115,  1          // InterfaceMethod java/util/List.size:()I
     240: istore_3
     241: iload_3
     242: ireturn

  private static final int getIncs3Count(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #91                 // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #93                 // class java/lang/String
       8: astore_2
       9: aload_2
      10: iconst_0
      11: ldc           #95                 // String \n
      13: aastore
      14: aload_2
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #101                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: checkcast     #16                 // class java/lang/Iterable
      26: astore_2
      27: iconst_0
      28: istore_3
      29: aload_2
      30: astore        4
      32: new           #18                 // class java/util/ArrayList
      35: dup
      36: aload_2
      37: bipush        10
      39: invokestatic  #24                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      42: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
      45: checkcast     #30                 // class java/util/Collection
      48: astore        5
      50: iconst_0
      51: istore        6
      53: aload         4
      55: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      60: astore        7
      62: aload         7
      64: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      69: ifeq          116
      72: aload         7
      74: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      79: astore        8
      81: aload         5
      83: aload         8
      85: checkcast     #93                 // class java/lang/String
      88: astore        9
      90: astore        13
      92: iconst_0
      93: istore        10
      95: aload         9
      97: invokestatic  #104                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     100: nop
     101: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     104: aload         13
     106: swap
     107: invokeinterface #70,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     112: pop
     113: goto          62
     116: aload         5
     118: checkcast     #56                 // class java/util/List
     121: nop
     122: astore_1
     123: aload_1
     124: checkcast     #16                 // class java/lang/Iterable
     127: iconst_3
     128: iconst_0
     129: iconst_0
     130: bipush        6
     132: aconst_null
     133: invokestatic  #134                // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;
     136: checkcast     #16                 // class java/lang/Iterable
     139: astore_2
     140: iconst_0
     141: istore_3
     142: aload_2
     143: astore        4
     145: new           #18                 // class java/util/ArrayList
     148: dup
     149: aload_2
     150: bipush        10
     152: invokestatic  #24                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     155: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
     158: checkcast     #30                 // class java/util/Collection
     161: astore        5
     163: iconst_0
     164: istore        6
     166: aload         4
     168: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     173: astore        7
     175: aload         7
     177: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     182: ifeq          231
     185: aload         7
     187: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     192: astore        8
     194: aload         5
     196: aload         8
     198: checkcast     #56                 // class java/util/List
     201: astore        9
     203: astore        13
     205: iconst_0
     206: istore        10
     208: aload         9
     210: checkcast     #16                 // class java/lang/Iterable
     213: invokestatic  #138                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     216: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     219: aload         13
     221: swap
     222: invokeinterface #70,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     227: pop
     228: goto          175
     231: aload         5
     233: checkcast     #56                 // class java/util/List
     236: nop
     237: astore_1
     238: aload_1
     239: invokestatic  #106                // Method diff:(Ljava/util/List;)Ljava/util/List;
     242: astore_2
     243: aload_2
     244: checkcast     #16                 // class java/lang/Iterable
     247: invokestatic  #110                // Method kotlin/collections/CollectionsKt.filterNotNull:(Ljava/lang/Iterable;)Ljava/util/List;
     250: checkcast     #16                 // class java/lang/Iterable
     253: astore        4
     255: iconst_0
     256: istore        5
     258: aload         4
     260: astore        6
     262: new           #18                 // class java/util/ArrayList
     265: dup
     266: invokespecial #112                // Method java/util/ArrayList."<init>":()V
     269: checkcast     #30                 // class java/util/Collection
     272: astore        7
     274: iconst_0
     275: istore        8
     277: aload         6
     279: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     284: astore        9
     286: aload         9
     288: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     293: ifeq          344
     296: aload         9
     298: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     303: astore        10
     305: aload         10
     307: checkcast     #50                 // class java/lang/Number
     310: invokevirtual #54                 // Method java/lang/Number.intValue:()I
     313: istore        11
     315: iconst_0
     316: istore        12
     318: iload         11
     320: ifle          327
     323: iconst_1
     324: goto          328
     327: iconst_0
     328: ifeq          286
     331: aload         7
     333: aload         10
     335: invokeinterface #70,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     340: pop
     341: goto          286
     344: aload         7
     346: checkcast     #56                 // class java/util/List
     349: nop
     350: invokeinterface #115,  1          // InterfaceMethod java/util/List.size:()I
     355: istore_3
     356: iload_3
     357: ireturn

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #145                // String args
       3: invokestatic  #151                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: getstatic     #11                 // Field testin:Ljava/lang/String;
       9: invokestatic  #153                // Method getIncsCount:(Ljava/lang/String;)I
      12: istore_1
      13: new           #155                // class java/lang/StringBuilder
      16: dup
      17: invokespecial #156                // Method java/lang/StringBuilder."<init>":()V
      20: ldc           #158                // String rc=
      22: invokevirtual #162                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      25: iload_1
      26: invokevirtual #165                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      29: invokevirtual #168                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      32: getstatic     #174                // Field java/lang/System.out:Ljava/io/PrintStream;
      35: swap
      36: invokevirtual #180                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      39: new           #182                // class java/io/File
      42: dup
      43: ldc           #184                // String ./in/day01.in
      45: invokespecial #187                // Method java/io/File."<init>":(Ljava/lang/String;)V
      48: aconst_null
      49: iconst_1
      50: aconst_null
      51: invokestatic  #193                // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
      54: checkcast     #91                 // class java/lang/CharSequence
      57: invokestatic  #197                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      60: invokevirtual #198                // Method java/lang/Object.toString:()Ljava/lang/String;
      63: astore_2
      64: aload_2
      65: invokestatic  #153                // Method getIncsCount:(Ljava/lang/String;)I
      68: istore_1
      69: new           #155                // class java/lang/StringBuilder
      72: dup
      73: invokespecial #156                // Method java/lang/StringBuilder."<init>":()V
      76: ldc           #158                // String rc=
      78: invokevirtual #162                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      81: iload_1
      82: invokevirtual #165                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      85: invokevirtual #168                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      88: getstatic     #174                // Field java/lang/System.out:Ljava/io/PrintStream;
      91: swap
      92: invokevirtual #180                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      95: getstatic     #11                 // Field testin:Ljava/lang/String;
      98: invokestatic  #200                // Method getIncs3Count:(Ljava/lang/String;)I
     101: istore_1
     102: new           #155                // class java/lang/StringBuilder
     105: dup
     106: invokespecial #156                // Method java/lang/StringBuilder."<init>":()V
     109: ldc           #158                // String rc=
     111: invokevirtual #162                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     114: iload_1
     115: invokevirtual #165                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     118: invokevirtual #168                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     121: getstatic     #174                // Field java/lang/System.out:Ljava/io/PrintStream;
     124: swap
     125: invokevirtual #180                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     128: aload_2
     129: invokestatic  #200                // Method getIncs3Count:(Ljava/lang/String;)I
     132: istore_1
     133: new           #155                // class java/lang/StringBuilder
     136: dup
     137: invokespecial #156                // Method java/lang/StringBuilder."<init>":()V
     140: ldc           #158                // String rc=
     142: invokevirtual #162                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     145: iload_1
     146: invokevirtual #165                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     149: invokevirtual #168                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     152: getstatic     #174                // Field java/lang/System.out:Ljava/io/PrintStream;
     155: swap
     156: invokevirtual #180                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     159: return

  static {};
    Code:
       0: ldc           #204                // String 199\n200\n208\n210\n200\n207\n240\n269\n260\n263
       2: putstatic     #11                 // Field testin:Ljava/lang/String;
       5: return
}