class Day08 {

    fun part1(input: List<String>): Int {
        return TreeArea(input).getVisibleTrees()
    }

    fun part2(input: List<String>): Int {
        return TreeArea(input).getBestScore()
    }

    class TreeArea(input: List<String>) {

        private val trees: Array<Array<Tree>>

        private val size: Int

        init {
            val arr: Array<Array<Tree>> = parseTreeArea(input)
            this.trees = arr
            this.size = trees.size - 1
        }

        private fun parseTreeArea(input: List<String>): Array<Array<Tree>> {
            return input.mapIndexed { rowId, row ->
                row.mapIndexed { columnId, height ->
                    Tree(columnId, rowId, height.digitToInt())
                }.toTypedArray()
            }.toTypedArray()
        }

        fun getVisibleTrees(): Int {
            return trees.flatMap { row -> row.map { isTreeVisible(it) } }.count { it }
        }

        fun getBestScore(): Int {
            return trees.flatMap { row -> row.map { getTreeScore(it) } }.max()
        }

        private fun isTreeVisible(tree: Tree): Boolean = isVisibleVertically(tree) || isVisibleHorizontally(tree)

        private fun isVisibleVertically(tree: Tree): Boolean {
            return if (tree.rowId == 0 || tree.rowId == size) {
                true
            } else {
                val visibleTop = (tree.rowId - 1 downTo 0).all { tree.height > trees[it][tree.columnId].height }
                val visibleBottom = (tree.rowId + 1..size).all { tree.height > trees[it][tree.columnId].height }
                visibleTop || visibleBottom
            }
        }

        private fun isVisibleHorizontally(tree: Tree): Boolean {
            return if (tree.columnId == 0 || tree.columnId == size) {
                true
            } else {
                val visibleLeft = (tree.columnId - 1 downTo 0).all { tree.height > trees[tree.rowId][it].height }
                val visibleRight = (tree.columnId + 1..size).all { tree.height > trees[tree.rowId][it].height }
                visibleLeft || visibleRight
            }
        }

        private fun getTreeScore(tree: Tree): Int = getScoreVertically(tree) * getScoreHorizontally(tree)

        private fun getScoreVertically(tree: Tree): Int {
            return if (tree.rowId == 0 || tree.rowId == size) {
                1
            } else {
                val scoreTop = (tree.rowId - 1 downTo 0)
                    .map { trees[it][tree.columnId] }
                    .takeUntil { it.height >= tree.height }.count()
                val scoreBottom = (tree.rowId + 1..size)
                    .map { trees[it][tree.columnId] }
                    .takeUntil { it.height >= tree.height }.count()
                scoreTop * scoreBottom
            }
        }

        private fun getScoreHorizontally(tree: Tree): Int {
            return if (tree.columnId == 0 || tree.columnId == size) {
                1
            } else {
                val scoreLeft = (tree.columnId - 1 downTo 0)
                    .map { trees[tree.rowId][it] }
                    .takeUntil { it.height >= tree.height }.count()
                val scoreRight = (tree.columnId + 1..size)
                    .map { trees[tree.rowId][it] }
                    .takeUntil { it.height >= tree.height }.count()
                scoreLeft * scoreRight
            }
        }
    }

    data class Tree(val columnId: Int, val rowId: Int, val height: Int)

}

private fun <T> Iterable<T>.takeUntil(predicate: (T) -> Boolean): List<T> {
    val list = ArrayList<T>()
    for (item in this) {
        list.add(item)
        if (predicate(item))
            break
    }
    return list
}

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

  public final int part1(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #24                 // class Day08$TreeArea
       9: dup
      10: aload_1
      11: invokespecial #27                 // Method Day08$TreeArea."<init>":(Ljava/util/List;)V
      14: invokevirtual #31                 // Method Day08$TreeArea.getVisibleTrees:()I
      17: ireturn

  public final int part2(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #24                 // class Day08$TreeArea
       9: dup
      10: aload_1
      11: invokespecial #27                 // Method Day08$TreeArea."<init>":(Ljava/util/List;)V
      14: invokevirtual #36                 // Method Day08$TreeArea.getBestScore:()I
      17: ireturn
}

Compiled from "Day08.kt"
public final class Day08$Tree {
  private final int columnId;

  private final int rowId;

  private final int height;

  public Day08$Tree(int, int, int);
    Code:
       0: aload_0
       1: invokespecial #9                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: iload_1
       6: putfield      #13                 // Field columnId:I
       9: aload_0
      10: iload_2
      11: putfield      #16                 // Field rowId:I
      14: aload_0
      15: iload_3
      16: putfield      #19                 // Field height:I
      19: return

  public final int getColumnId();
    Code:
       0: aload_0
       1: getfield      #13                 // Field columnId:I
       4: ireturn

  public final int getRowId();
    Code:
       0: aload_0
       1: getfield      #16                 // Field rowId:I
       4: ireturn

  public final int getHeight();
    Code:
       0: aload_0
       1: getfield      #19                 // Field height:I
       4: ireturn

  public final int component1();
    Code:
       0: aload_0
       1: getfield      #13                 // Field columnId:I
       4: ireturn

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

  public final int component3();
    Code:
       0: aload_0
       1: getfield      #19                 // Field height:I
       4: ireturn

  public final Day08$Tree copy(int, int, int);
    Code:
       0: new           #2                  // class Day08$Tree
       3: dup
       4: iload_1
       5: iload_2
       6: iload_3
       7: invokespecial #33                 // Method "<init>":(III)V
      10: areturn

  public static Day08$Tree copy$default(Day08$Tree, int, int, int, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #13                 // Field columnId:I
      11: istore_1
      12: iload         4
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #16                 // Field rowId:I
      23: istore_2
      24: iload         4
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #19                 // Field height:I
      35: istore_3
      36: aload_0
      37: iload_1
      38: iload_2
      39: iload_3
      40: invokevirtual #37                 // Method copy:(III)LDay08$Tree;
      43: areturn

  public java.lang.String toString();
    Code:
       0: new           #41                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #42                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #44                 // String Tree(columnId=
       9: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #13                 // Field columnId:I
      16: invokevirtual #51                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #53                 // String , rowId=
      21: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #16                 // Field rowId:I
      28: invokevirtual #51                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: ldc           #55                 // String , height=
      33: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: aload_0
      37: getfield      #19                 // Field height:I
      40: invokevirtual #51                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      43: bipush        41
      45: invokevirtual #58                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      48: invokevirtual #60                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      51: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #13                 // Field columnId:I
       4: invokestatic  #66                 // Method java/lang/Integer.hashCode:(I)I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #16                 // Field rowId:I
      16: invokestatic  #66                 // Method java/lang/Integer.hashCode:(I)I
      19: iadd
      20: istore_1
      21: iload_1
      22: bipush        31
      24: imul
      25: aload_0
      26: getfield      #19                 // Field height:I
      29: invokestatic  #66                 // Method java/lang/Integer.hashCode:(I)I
      32: iadd
      33: istore_1
      34: iload_1
      35: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class Day08$Tree
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class Day08$Tree
      20: astore_2
      21: aload_0
      22: getfield      #13                 // Field columnId:I
      25: aload_2
      26: getfield      #13                 // Field columnId:I
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #16                 // Field rowId:I
      38: aload_2
      39: getfield      #16                 // Field rowId:I
      42: if_icmpeq     47
      45: iconst_0
      46: ireturn
      47: aload_0
      48: getfield      #19                 // Field height:I
      51: aload_2
      52: getfield      #19                 // Field height:I
      55: if_icmpeq     60
      58: iconst_0
      59: ireturn
      60: iconst_1
      61: ireturn
}

Compiled from "Day08.kt"
public final class Day08Kt {
  private static final <T> java.util.List<T> takeUntil(java.lang.Iterable<? extends T>, kotlin.jvm.functions.Function1<? super T, java.lang.Boolean>);
    Code:
       0: new           #9                  // class java/util/ArrayList
       3: dup
       4: invokespecial #13                 // Method java/util/ArrayList."<init>":()V
       7: astore_2
       8: aload_0
       9: invokeinterface #19,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      14: astore_3
      15: aload_3
      16: invokeinterface #25,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      21: ifeq          59
      24: aload_3
      25: invokeinterface #29,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      30: astore        4
      32: aload_2
      33: aload         4
      35: invokevirtual #33                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      38: pop
      39: aload_1
      40: aload         4
      42: invokeinterface #39,  2           // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      47: checkcast     #41                 // class java/lang/Boolean
      50: invokevirtual #44                 // Method java/lang/Boolean.booleanValue:()Z
      53: ifeq          15
      56: goto          59
      59: aload_2
      60: checkcast     #46                 // class java/util/List
      63: areturn

  public static final java.util.List access$takeUntil(java.lang.Iterable, kotlin.jvm.functions.Function1);
    Code:
       0: aload_0
       1: aload_1
       2: invokestatic  #57                 // Method takeUntil:(Ljava/lang/Iterable;Lkotlin/jvm/functions/Function1;)Ljava/util/List;
       5: areturn
}

Compiled from "Day08.kt"
public final class Day08$TreeArea {
  private final Day08$Tree[][] trees;

  private final int size;

  public Day08$TreeArea(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #10                 // String input
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #19                 // Method java/lang/Object."<init>":()V
      10: nop
      11: aload_0
      12: aload_1
      13: invokespecial #23                 // Method parseTreeArea:(Ljava/util/List;)[[LDay08$Tree;
      16: astore_2
      17: aload_0
      18: aload_2
      19: putfield      #27                 // Field trees:[[LDay08$Tree;
      22: aload_0
      23: aload_0
      24: getfield      #27                 // Field trees:[[LDay08$Tree;
      27: checkcast     #29                 // class "[Ljava/lang/Object;"
      30: arraylength
      31: iconst_1
      32: isub
      33: putfield      #33                 // Field size:I
      36: nop
      37: return

  private final Day08$Tree[][] parseTreeArea(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: checkcast     #40                 // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: astore        4
      10: new           #42                 // class java/util/ArrayList
      13: dup
      14: aload_2
      15: bipush        10
      17: invokestatic  #48                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      20: invokespecial #51                 // Method java/util/ArrayList."<init>":(I)V
      23: checkcast     #53                 // class java/util/Collection
      26: astore        5
      28: iconst_0
      29: istore        6
      31: iconst_0
      32: istore        7
      34: aload         4
      36: invokeinterface #57,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      41: astore        8
      43: aload         8
      45: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifeq          255
      53: aload         8
      55: invokeinterface #67,  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  #70                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      79: iload         10
      81: aload         9
      83: checkcast     #72                 // class java/lang/String
      86: astore        11
      88: istore        12
      90: astore        26
      92: iconst_0
      93: istore        13
      95: aload         11
      97: checkcast     #74                 // class java/lang/CharSequence
     100: astore        14
     102: iconst_0
     103: istore        15
     105: aload         14
     107: astore        16
     109: new           #42                 // class java/util/ArrayList
     112: dup
     113: aload         14
     115: invokeinterface #78,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     120: invokespecial #51                 // Method java/util/ArrayList."<init>":(I)V
     123: checkcast     #53                 // class java/util/Collection
     126: astore        17
     128: iconst_0
     129: istore        18
     131: iconst_0
     132: istore        19
     134: iconst_0
     135: istore        20
     137: iload         20
     139: aload         16
     141: invokeinterface #78,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     146: if_icmpge     209
     149: aload         16
     151: iload         20
     153: invokeinterface #82,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     158: istore        21
     160: aload         17
     162: iload         19
     164: iinc          19, 1
     167: iload         21
     169: istore        22
     171: istore        23
     173: astore        24
     175: iconst_0
     176: istore        25
     178: new           #84                 // class Day08$Tree
     181: dup
     182: iload         23
     184: iload         12
     186: iload         22
     188: invokestatic  #90                 // Method kotlin/text/CharsKt.digitToInt:(C)I
     191: invokespecial #93                 // Method Day08$Tree."<init>":(III)V
     194: aload         24
     196: swap
     197: invokeinterface #97,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     202: pop
     203: iinc          20, 1
     206: goto          137
     209: aload         17
     211: checkcast     #99                 // class java/util/List
     214: nop
     215: checkcast     #53                 // class java/util/Collection
     218: astore        14
     220: nop
     221: iconst_0
     222: istore        15
     224: aload         14
     226: astore        16
     228: aload         16
     230: iconst_0
     231: anewarray     #84                 // class Day08$Tree
     234: invokeinterface #103,  2          // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;
     239: checkcast     #105                // class "[LDay08$Tree;"
     242: nop
     243: aload         26
     245: swap
     246: invokeinterface #97,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     251: pop
     252: goto          43
     255: aload         5
     257: checkcast     #99                 // class java/util/List
     260: nop
     261: checkcast     #53                 // class java/util/Collection
     264: astore_2
     265: nop
     266: iconst_0
     267: istore_3
     268: aload_2
     269: astore        4
     271: aload         4
     273: iconst_0
     274: anewarray     #105                // class "[LDay08$Tree;"
     277: invokeinterface #103,  2          // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;
     282: checkcast     #106                // class "[[LDay08$Tree;"
     285: areturn

  public final int getVisibleTrees();
    Code:
       0: aload_0
       1: getfield      #27                 // Field trees:[[LDay08$Tree;
       4: checkcast     #29                 // class "[Ljava/lang/Object;"
       7: astore_1
       8: iconst_0
       9: istore_2
      10: aload_1
      11: astore_3
      12: new           #42                 // class java/util/ArrayList
      15: dup
      16: invokespecial #130                // Method java/util/ArrayList."<init>":()V
      19: checkcast     #53                 // class java/util/Collection
      22: astore        4
      24: iconst_0
      25: istore        5
      27: iconst_0
      28: istore        6
      30: aload_3
      31: arraylength
      32: istore        7
      34: iload         6
      36: iload         7
      38: if_icmpge     169
      41: aload_3
      42: iload         6
      44: aaload
      45: astore        8
      47: aload         8
      49: checkcast     #105                // class "[LDay08$Tree;"
      52: astore        9
      54: iconst_0
      55: istore        10
      57: aload         9
      59: astore        11
      61: iconst_0
      62: istore        12
      64: aload         11
      66: astore        13
      68: new           #42                 // class java/util/ArrayList
      71: dup
      72: aload         11
      74: arraylength
      75: invokespecial #51                 // Method java/util/ArrayList."<init>":(I)V
      78: checkcast     #53                 // class java/util/Collection
      81: astore        14
      83: iconst_0
      84: istore        15
      86: iconst_0
      87: istore        16
      89: aload         13
      91: arraylength
      92: istore        17
      94: iload         16
      96: iload         17
      98: if_icmpge     143
     101: aload         13
     103: iload         16
     105: aaload
     106: astore        18
     108: aload         14
     110: aload         18
     112: astore        19
     114: astore        20
     116: iconst_0
     117: istore        21
     119: aload_0
     120: aload         19
     122: invokespecial #134                // Method isTreeVisible:(LDay08$Tree;)Z
     125: invokestatic  #140                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     128: aload         20
     130: swap
     131: invokeinterface #97,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     136: pop
     137: iinc          16, 1
     140: goto          94
     143: aload         14
     145: checkcast     #99                 // class java/util/List
     148: nop
     149: checkcast     #40                 // class java/lang/Iterable
     152: nop
     153: astore        9
     155: aload         4
     157: aload         9
     159: invokestatic  #144                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     162: pop
     163: iinc          6, 1
     166: goto          34
     169: aload         4
     171: checkcast     #99                 // class java/util/List
     174: nop
     175: checkcast     #40                 // class java/lang/Iterable
     178: astore_1
     179: nop
     180: iconst_0
     181: istore_2
     182: aload_1
     183: instanceof    #53                 // class java/util/Collection
     186: ifeq          205
     189: aload_1
     190: checkcast     #53                 // class java/util/Collection
     193: invokeinterface #147,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     198: ifeq          205
     201: iconst_0
     202: goto          266
     205: iconst_0
     206: istore_3
     207: aload_1
     208: invokeinterface #57,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     213: astore        4
     215: aload         4
     217: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     222: ifeq          265
     225: aload         4
     227: invokeinterface #67,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     232: astore        5
     234: aload         5
     236: checkcast     #136                // class java/lang/Boolean
     239: invokevirtual #150                // Method java/lang/Boolean.booleanValue:()Z
     242: istore        6
     244: iconst_0
     245: istore        7
     247: iload         6
     249: ifeq          215
     252: iinc          3, 1
     255: iload_3
     256: ifge          215
     259: invokestatic  #153                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     262: goto          215
     265: iload_3
     266: ireturn

  public final int getBestScore();
    Code:
       0: aload_0
       1: getfield      #27                 // Field trees:[[LDay08$Tree;
       4: checkcast     #29                 // class "[Ljava/lang/Object;"
       7: astore_1
       8: iconst_0
       9: istore_2
      10: aload_1
      11: astore_3
      12: new           #42                 // class java/util/ArrayList
      15: dup
      16: invokespecial #130                // Method java/util/ArrayList."<init>":()V
      19: checkcast     #53                 // class java/util/Collection
      22: astore        4
      24: iconst_0
      25: istore        5
      27: iconst_0
      28: istore        6
      30: aload_3
      31: arraylength
      32: istore        7
      34: iload         6
      36: iload         7
      38: if_icmpge     169
      41: aload_3
      42: iload         6
      44: aaload
      45: astore        8
      47: aload         8
      49: checkcast     #105                // class "[LDay08$Tree;"
      52: astore        9
      54: iconst_0
      55: istore        10
      57: aload         9
      59: astore        11
      61: iconst_0
      62: istore        12
      64: aload         11
      66: astore        13
      68: new           #42                 // class java/util/ArrayList
      71: dup
      72: aload         11
      74: arraylength
      75: invokespecial #51                 // Method java/util/ArrayList."<init>":(I)V
      78: checkcast     #53                 // class java/util/Collection
      81: astore        14
      83: iconst_0
      84: istore        15
      86: iconst_0
      87: istore        16
      89: aload         13
      91: arraylength
      92: istore        17
      94: iload         16
      96: iload         17
      98: if_icmpge     143
     101: aload         13
     103: iload         16
     105: aaload
     106: astore        18
     108: aload         14
     110: aload         18
     112: astore        19
     114: astore        20
     116: iconst_0
     117: istore        21
     119: aload_0
     120: aload         19
     122: invokespecial #178                // Method getTreeScore:(LDay08$Tree;)I
     125: invokestatic  #183                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     128: aload         20
     130: swap
     131: invokeinterface #97,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     136: pop
     137: iinc          16, 1
     140: goto          94
     143: aload         14
     145: checkcast     #99                 // class java/util/List
     148: nop
     149: checkcast     #40                 // class java/lang/Iterable
     152: nop
     153: astore        9
     155: aload         4
     157: aload         9
     159: invokestatic  #144                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     162: pop
     163: iinc          6, 1
     166: goto          34
     169: aload         4
     171: checkcast     #99                 // class java/util/List
     174: nop
     175: checkcast     #40                 // class java/lang/Iterable
     178: invokestatic  #187                // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     181: checkcast     #189                // class java/lang/Number
     184: invokevirtual #192                // Method java/lang/Number.intValue:()I
     187: ireturn

  private final boolean isTreeVisible(Day08$Tree);
    Code:
       0: aload_0
       1: aload_1
       2: invokespecial #197                // Method isVisibleVertically:(LDay08$Tree;)Z
       5: ifne          16
       8: aload_0
       9: aload_1
      10: invokespecial #200                // Method isVisibleHorizontally:(LDay08$Tree;)Z
      13: ifeq          20
      16: iconst_1
      17: goto          21
      20: iconst_0
      21: ireturn

  private final boolean isVisibleVertically(Day08$Tree);
    Code:
       0: aload_1
       1: invokevirtual #204                // Method Day08$Tree.getRowId:()I
       4: ifeq          18
       7: aload_1
       8: invokevirtual #204                // Method Day08$Tree.getRowId:()I
      11: aload_0
      12: getfield      #33                 // Field size:I
      15: if_icmpne     22
      18: iconst_1
      19: goto          268
      22: aload_1
      23: invokevirtual #204                // Method Day08$Tree.getRowId:()I
      26: iconst_1
      27: isub
      28: iconst_0
      29: invokestatic  #210                // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;
      32: checkcast     #40                 // class java/lang/Iterable
      35: astore_3
      36: iconst_0
      37: istore        4
      39: aload_3
      40: instanceof    #53                 // class java/util/Collection
      43: ifeq          62
      46: aload_3
      47: checkcast     #53                 // class java/util/Collection
      50: invokeinterface #147,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      55: ifeq          62
      58: iconst_1
      59: goto          132
      62: aload_3
      63: invokeinterface #57,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      68: astore        5
      70: aload         5
      72: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      77: ifeq          131
      80: aload         5
      82: checkcast     #212                // class kotlin/collections/IntIterator
      85: invokevirtual #215                // Method kotlin/collections/IntIterator.nextInt:()I
      88: istore        6
      90: iload         6
      92: istore        7
      94: iconst_0
      95: istore        8
      97: aload_1
      98: invokevirtual #218                // Method Day08$Tree.getHeight:()I
     101: aload_0
     102: getfield      #27                 // Field trees:[[LDay08$Tree;
     105: iload         7
     107: aaload
     108: aload_1
     109: invokevirtual #221                // Method Day08$Tree.getColumnId:()I
     112: aaload
     113: invokevirtual #218                // Method Day08$Tree.getHeight:()I
     116: if_icmple     123
     119: iconst_1
     120: goto          124
     123: iconst_0
     124: ifne          70
     127: iconst_0
     128: goto          132
     131: iconst_1
     132: istore_2
     133: new           #223                // class kotlin/ranges/IntRange
     136: dup
     137: aload_1
     138: invokevirtual #204                // Method Day08$Tree.getRowId:()I
     141: iconst_1
     142: iadd
     143: aload_0
     144: getfield      #33                 // Field size:I
     147: invokespecial #226                // Method kotlin/ranges/IntRange."<init>":(II)V
     150: checkcast     #40                 // class java/lang/Iterable
     153: astore        4
     155: iconst_0
     156: istore        5
     158: aload         4
     160: instanceof    #53                 // class java/util/Collection
     163: ifeq          183
     166: aload         4
     168: checkcast     #53                 // class java/util/Collection
     171: invokeinterface #147,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     176: ifeq          183
     179: iconst_1
     180: goto          254
     183: aload         4
     185: invokeinterface #57,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     190: astore        6
     192: aload         6
     194: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     199: ifeq          253
     202: aload         6
     204: checkcast     #212                // class kotlin/collections/IntIterator
     207: invokevirtual #215                // Method kotlin/collections/IntIterator.nextInt:()I
     210: istore        7
     212: iload         7
     214: istore        8
     216: iconst_0
     217: istore        9
     219: aload_1
     220: invokevirtual #218                // Method Day08$Tree.getHeight:()I
     223: aload_0
     224: getfield      #27                 // Field trees:[[LDay08$Tree;
     227: iload         8
     229: aaload
     230: aload_1
     231: invokevirtual #221                // Method Day08$Tree.getColumnId:()I
     234: aaload
     235: invokevirtual #218                // Method Day08$Tree.getHeight:()I
     238: if_icmple     245
     241: iconst_1
     242: goto          246
     245: iconst_0
     246: ifne          192
     249: iconst_0
     250: goto          254
     253: iconst_1
     254: istore_3
     255: iload_2
     256: ifne          263
     259: iload_3
     260: ifeq          267
     263: iconst_1
     264: goto          268
     267: iconst_0
     268: ireturn

  private final boolean isVisibleHorizontally(Day08$Tree);
    Code:
       0: aload_1
       1: invokevirtual #221                // Method Day08$Tree.getColumnId:()I
       4: ifeq          18
       7: aload_1
       8: invokevirtual #221                // Method Day08$Tree.getColumnId:()I
      11: aload_0
      12: getfield      #33                 // Field size:I
      15: if_icmpne     22
      18: iconst_1
      19: goto          268
      22: aload_1
      23: invokevirtual #221                // Method Day08$Tree.getColumnId:()I
      26: iconst_1
      27: isub
      28: iconst_0
      29: invokestatic  #210                // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;
      32: checkcast     #40                 // class java/lang/Iterable
      35: astore_3
      36: iconst_0
      37: istore        4
      39: aload_3
      40: instanceof    #53                 // class java/util/Collection
      43: ifeq          62
      46: aload_3
      47: checkcast     #53                 // class java/util/Collection
      50: invokeinterface #147,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      55: ifeq          62
      58: iconst_1
      59: goto          132
      62: aload_3
      63: invokeinterface #57,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      68: astore        5
      70: aload         5
      72: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      77: ifeq          131
      80: aload         5
      82: checkcast     #212                // class kotlin/collections/IntIterator
      85: invokevirtual #215                // Method kotlin/collections/IntIterator.nextInt:()I
      88: istore        6
      90: iload         6
      92: istore        7
      94: iconst_0
      95: istore        8
      97: aload_1
      98: invokevirtual #218                // Method Day08$Tree.getHeight:()I
     101: aload_0
     102: getfield      #27                 // Field trees:[[LDay08$Tree;
     105: aload_1
     106: invokevirtual #204                // Method Day08$Tree.getRowId:()I
     109: aaload
     110: iload         7
     112: aaload
     113: invokevirtual #218                // Method Day08$Tree.getHeight:()I
     116: if_icmple     123
     119: iconst_1
     120: goto          124
     123: iconst_0
     124: ifne          70
     127: iconst_0
     128: goto          132
     131: iconst_1
     132: istore_2
     133: new           #223                // class kotlin/ranges/IntRange
     136: dup
     137: aload_1
     138: invokevirtual #221                // Method Day08$Tree.getColumnId:()I
     141: iconst_1
     142: iadd
     143: aload_0
     144: getfield      #33                 // Field size:I
     147: invokespecial #226                // Method kotlin/ranges/IntRange."<init>":(II)V
     150: checkcast     #40                 // class java/lang/Iterable
     153: astore        4
     155: iconst_0
     156: istore        5
     158: aload         4
     160: instanceof    #53                 // class java/util/Collection
     163: ifeq          183
     166: aload         4
     168: checkcast     #53                 // class java/util/Collection
     171: invokeinterface #147,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     176: ifeq          183
     179: iconst_1
     180: goto          254
     183: aload         4
     185: invokeinterface #57,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     190: astore        6
     192: aload         6
     194: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     199: ifeq          253
     202: aload         6
     204: checkcast     #212                // class kotlin/collections/IntIterator
     207: invokevirtual #215                // Method kotlin/collections/IntIterator.nextInt:()I
     210: istore        7
     212: iload         7
     214: istore        8
     216: iconst_0
     217: istore        9
     219: aload_1
     220: invokevirtual #218                // Method Day08$Tree.getHeight:()I
     223: aload_0
     224: getfield      #27                 // Field trees:[[LDay08$Tree;
     227: aload_1
     228: invokevirtual #204                // Method Day08$Tree.getRowId:()I
     231: aaload
     232: iload         8
     234: aaload
     235: invokevirtual #218                // Method Day08$Tree.getHeight:()I
     238: if_icmple     245
     241: iconst_1
     242: goto          246
     245: iconst_0
     246: ifne          192
     249: iconst_0
     250: goto          254
     253: iconst_1
     254: istore_3
     255: iload_2
     256: ifne          263
     259: iload_3
     260: ifeq          267
     263: iconst_1
     264: goto          268
     267: iconst_0
     268: ireturn

  private final int getTreeScore(Day08$Tree);
    Code:
       0: aload_0
       1: aload_1
       2: invokespecial #239                // Method getScoreVertically:(LDay08$Tree;)I
       5: aload_0
       6: aload_1
       7: invokespecial #242                // Method getScoreHorizontally:(LDay08$Tree;)I
      10: imul
      11: ireturn

  private final int getScoreVertically(Day08$Tree);
    Code:
       0: aload_1
       1: invokevirtual #204                // Method Day08$Tree.getRowId:()I
       4: ifeq          18
       7: aload_1
       8: invokevirtual #204                // Method Day08$Tree.getRowId:()I
      11: aload_0
      12: getfield      #33                 // Field size:I
      15: if_icmpne     22
      18: iconst_1
      19: goto          301
      22: aload_1
      23: invokevirtual #204                // Method Day08$Tree.getRowId:()I
      26: iconst_1
      27: isub
      28: iconst_0
      29: invokestatic  #210                // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;
      32: checkcast     #40                 // class java/lang/Iterable
      35: astore_3
      36: nop
      37: iconst_0
      38: istore        4
      40: aload_3
      41: astore        5
      43: new           #42                 // class java/util/ArrayList
      46: dup
      47: aload_3
      48: bipush        10
      50: invokestatic  #48                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      53: invokespecial #51                 // Method java/util/ArrayList."<init>":(I)V
      56: checkcast     #53                 // class java/util/Collection
      59: astore        6
      61: iconst_0
      62: istore        7
      64: aload         5
      66: invokeinterface #57,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      71: astore        8
      73: aload         8
      75: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      80: ifeq          128
      83: aload         8
      85: checkcast     #212                // class kotlin/collections/IntIterator
      88: invokevirtual #215                // Method kotlin/collections/IntIterator.nextInt:()I
      91: istore        9
      93: aload         6
      95: iload         9
      97: istore        10
      99: astore        13
     101: iconst_0
     102: istore        11
     104: aload_0
     105: getfield      #27                 // Field trees:[[LDay08$Tree;
     108: iload         10
     110: aaload
     111: aload_1
     112: invokevirtual #221                // Method Day08$Tree.getColumnId:()I
     115: aaload
     116: aload         13
     118: swap
     119: invokeinterface #97,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     124: pop
     125: goto          73
     128: aload         6
     130: checkcast     #99                 // class java/util/List
     133: nop
     134: checkcast     #40                 // class java/lang/Iterable
     137: aload_1
     138: invokedynamic #262,  0            // InvokeDynamic #0:invoke:(LDay08$Tree;)Lkotlin/jvm/functions/Function1;
     143: invokestatic  #268                // Method Day08Kt.access$takeUntil:(Ljava/lang/Iterable;Lkotlin/jvm/functions/Function1;)Ljava/util/List;
     146: checkcast     #53                 // class java/util/Collection
     149: invokeinterface #270,  1          // InterfaceMethod java/util/Collection.size:()I
     154: istore_2
     155: new           #223                // class kotlin/ranges/IntRange
     158: dup
     159: aload_1
     160: invokevirtual #204                // Method Day08$Tree.getRowId:()I
     163: iconst_1
     164: iadd
     165: aload_0
     166: getfield      #33                 // Field size:I
     169: invokespecial #226                // Method kotlin/ranges/IntRange."<init>":(II)V
     172: checkcast     #40                 // class java/lang/Iterable
     175: astore        4
     177: nop
     178: iconst_0
     179: istore        5
     181: aload         4
     183: astore        6
     185: new           #42                 // class java/util/ArrayList
     188: dup
     189: aload         4
     191: bipush        10
     193: invokestatic  #48                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     196: invokespecial #51                 // Method java/util/ArrayList."<init>":(I)V
     199: checkcast     #53                 // class java/util/Collection
     202: astore        7
     204: iconst_0
     205: istore        8
     207: aload         6
     209: invokeinterface #57,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     214: astore        9
     216: aload         9
     218: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     223: ifeq          271
     226: aload         9
     228: checkcast     #212                // class kotlin/collections/IntIterator
     231: invokevirtual #215                // Method kotlin/collections/IntIterator.nextInt:()I
     234: istore        10
     236: aload         7
     238: iload         10
     240: istore        11
     242: astore        13
     244: iconst_0
     245: istore        12
     247: aload_0
     248: getfield      #27                 // Field trees:[[LDay08$Tree;
     251: iload         11
     253: aaload
     254: aload_1
     255: invokevirtual #221                // Method Day08$Tree.getColumnId:()I
     258: aaload
     259: aload         13
     261: swap
     262: invokeinterface #97,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     267: pop
     268: goto          216
     271: aload         7
     273: checkcast     #99                 // class java/util/List
     276: nop
     277: checkcast     #40                 // class java/lang/Iterable
     280: aload_1
     281: invokedynamic #275,  0            // InvokeDynamic #1:invoke:(LDay08$Tree;)Lkotlin/jvm/functions/Function1;
     286: invokestatic  #268                // Method Day08Kt.access$takeUntil:(Ljava/lang/Iterable;Lkotlin/jvm/functions/Function1;)Ljava/util/List;
     289: checkcast     #53                 // class java/util/Collection
     292: invokeinterface #270,  1          // InterfaceMethod java/util/Collection.size:()I
     297: istore_3
     298: iload_2
     299: iload_3
     300: imul
     301: ireturn

  private final int getScoreHorizontally(Day08$Tree);
    Code:
       0: aload_1
       1: invokevirtual #221                // Method Day08$Tree.getColumnId:()I
       4: ifeq          18
       7: aload_1
       8: invokevirtual #221                // Method Day08$Tree.getColumnId:()I
      11: aload_0
      12: getfield      #33                 // Field size:I
      15: if_icmpne     22
      18: iconst_1
      19: goto          301
      22: aload_1
      23: invokevirtual #221                // Method Day08$Tree.getColumnId:()I
      26: iconst_1
      27: isub
      28: iconst_0
      29: invokestatic  #210                // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;
      32: checkcast     #40                 // class java/lang/Iterable
      35: astore_3
      36: nop
      37: iconst_0
      38: istore        4
      40: aload_3
      41: astore        5
      43: new           #42                 // class java/util/ArrayList
      46: dup
      47: aload_3
      48: bipush        10
      50: invokestatic  #48                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      53: invokespecial #51                 // Method java/util/ArrayList."<init>":(I)V
      56: checkcast     #53                 // class java/util/Collection
      59: astore        6
      61: iconst_0
      62: istore        7
      64: aload         5
      66: invokeinterface #57,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      71: astore        8
      73: aload         8
      75: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      80: ifeq          128
      83: aload         8
      85: checkcast     #212                // class kotlin/collections/IntIterator
      88: invokevirtual #215                // Method kotlin/collections/IntIterator.nextInt:()I
      91: istore        9
      93: aload         6
      95: iload         9
      97: istore        10
      99: astore        13
     101: iconst_0
     102: istore        11
     104: aload_0
     105: getfield      #27                 // Field trees:[[LDay08$Tree;
     108: aload_1
     109: invokevirtual #204                // Method Day08$Tree.getRowId:()I
     112: aaload
     113: iload         10
     115: aaload
     116: aload         13
     118: swap
     119: invokeinterface #97,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     124: pop
     125: goto          73
     128: aload         6
     130: checkcast     #99                 // class java/util/List
     133: nop
     134: checkcast     #40                 // class java/lang/Iterable
     137: aload_1
     138: invokedynamic #284,  0            // InvokeDynamic #2:invoke:(LDay08$Tree;)Lkotlin/jvm/functions/Function1;
     143: invokestatic  #268                // Method Day08Kt.access$takeUntil:(Ljava/lang/Iterable;Lkotlin/jvm/functions/Function1;)Ljava/util/List;
     146: checkcast     #53                 // class java/util/Collection
     149: invokeinterface #270,  1          // InterfaceMethod java/util/Collection.size:()I
     154: istore_2
     155: new           #223                // class kotlin/ranges/IntRange
     158: dup
     159: aload_1
     160: invokevirtual #221                // Method Day08$Tree.getColumnId:()I
     163: iconst_1
     164: iadd
     165: aload_0
     166: getfield      #33                 // Field size:I
     169: invokespecial #226                // Method kotlin/ranges/IntRange."<init>":(II)V
     172: checkcast     #40                 // class java/lang/Iterable
     175: astore        4
     177: nop
     178: iconst_0
     179: istore        5
     181: aload         4
     183: astore        6
     185: new           #42                 // class java/util/ArrayList
     188: dup
     189: aload         4
     191: bipush        10
     193: invokestatic  #48                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     196: invokespecial #51                 // Method java/util/ArrayList."<init>":(I)V
     199: checkcast     #53                 // class java/util/Collection
     202: astore        7
     204: iconst_0
     205: istore        8
     207: aload         6
     209: invokeinterface #57,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     214: astore        9
     216: aload         9
     218: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     223: ifeq          271
     226: aload         9
     228: checkcast     #212                // class kotlin/collections/IntIterator
     231: invokevirtual #215                // Method kotlin/collections/IntIterator.nextInt:()I
     234: istore        10
     236: aload         7
     238: iload         10
     240: istore        11
     242: astore        13
     244: iconst_0
     245: istore        12
     247: aload_0
     248: getfield      #27                 // Field trees:[[LDay08$Tree;
     251: aload_1
     252: invokevirtual #204                // Method Day08$Tree.getRowId:()I
     255: aaload
     256: iload         11
     258: aaload
     259: aload         13
     261: swap
     262: invokeinterface #97,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     267: pop
     268: goto          216
     271: aload         7
     273: checkcast     #99                 // class java/util/List
     276: nop
     277: checkcast     #40                 // class java/lang/Iterable
     280: aload_1
     281: invokedynamic #289,  0            // InvokeDynamic #3:invoke:(LDay08$Tree;)Lkotlin/jvm/functions/Function1;
     286: invokestatic  #268                // Method Day08Kt.access$takeUntil:(Ljava/lang/Iterable;Lkotlin/jvm/functions/Function1;)Ljava/util/List;
     289: checkcast     #53                 // class java/util/Collection
     292: invokeinterface #270,  1          // InterfaceMethod java/util/Collection.size:()I
     297: istore_3
     298: iload_2
     299: iload_3
     300: imul
     301: ireturn

  private static final boolean getScoreVertically$lambda$12(Day08$Tree, Day08$Tree);
    Code:
       0: aload_1
       1: ldc_w         #294                // String it
       4: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: invokevirtual #218                // Method Day08$Tree.getHeight:()I
      11: aload_0
      12: invokevirtual #218                // Method Day08$Tree.getHeight:()I
      15: if_icmplt     22
      18: iconst_1
      19: goto          23
      22: iconst_0
      23: ireturn

  private static final boolean getScoreVertically$lambda$14(Day08$Tree, Day08$Tree);
    Code:
       0: aload_1
       1: ldc_w         #294                // String it
       4: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: invokevirtual #218                // Method Day08$Tree.getHeight:()I
      11: aload_0
      12: invokevirtual #218                // Method Day08$Tree.getHeight:()I
      15: if_icmplt     22
      18: iconst_1
      19: goto          23
      22: iconst_0
      23: ireturn

  private static final boolean getScoreHorizontally$lambda$16(Day08$Tree, Day08$Tree);
    Code:
       0: aload_1
       1: ldc_w         #294                // String it
       4: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: invokevirtual #218                // Method Day08$Tree.getHeight:()I
      11: aload_0
      12: invokevirtual #218                // Method Day08$Tree.getHeight:()I
      15: if_icmplt     22
      18: iconst_1
      19: goto          23
      22: iconst_0
      23: ireturn

  private static final boolean getScoreHorizontally$lambda$18(Day08$Tree, Day08$Tree);
    Code:
       0: aload_1
       1: ldc_w         #294                // String it
       4: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: invokevirtual #218                // Method Day08$Tree.getHeight:()I
      11: aload_0
      12: invokevirtual #218                // Method Day08$Tree.getHeight:()I
      15: if_icmplt     22
      18: iconst_1
      19: goto          23
      22: iconst_0
      23: ireturn
}


class Day07 {

    fun part1(input: List<String>): Long {
        val hashMapOf = directoriesMap(input)
        return hashMapOf.values.filter { it <= 100_000 }.sum()
    }

    private fun directoriesMap(input: List<String>): MutableMap<String, Long> {
        val hashMapOf = mutableMapOf<String, Long>()
        var path = ""

        for (line in input) {
            when (line.getTyp()) {
                CommandType.COMMAND_CD_ROOT -> path = ""
                CommandType.COMMAND_CD_UP -> {
                    path = path.substringBeforeLast("/")
                }
                CommandType.COMMAND_CD -> {
                    val tempPath = line.substringAfter("$ cd ")
                    path = "$path/$tempPath"
                }
                CommandType.COMMAND_DIR -> ""
                CommandType.DIR -> ""
                CommandType.SIZE -> {
                    val tempSize = line.substringBefore(" ").toInt()
                    var tempDir = path
                    while (true) {
                        val previous = hashMapOf.getOrDefault(tempDir, 0)
                        hashMapOf[tempDir] = previous + tempSize
                        if (tempDir.isEmpty()) break
                        tempDir = tempDir.substringBeforeLast("/", "")
                    }
                }
            }

        }
        return hashMapOf
    }

    private enum class CommandType { COMMAND_CD_ROOT, COMMAND_CD, COMMAND_CD_UP, COMMAND_DIR, DIR, SIZE }

    private fun String.getTyp(): CommandType {
        return when {
            this.startsWith("$ cd /") -> CommandType.COMMAND_CD_ROOT
            this.startsWith("$ cd ..") -> CommandType.COMMAND_CD_UP
            this.startsWith("$ cd ") -> CommandType.COMMAND_CD
            this.startsWith("$ ls") -> CommandType.COMMAND_DIR
            this.startsWith("dir ") -> CommandType.DIR
            else -> CommandType.SIZE
        }

    }

    fun part2(input: List<String>): Long {
        val total = 70_000_000
        val required = 30_000_000
        val directoriesMap = directoriesMap(input)
        val used = directoriesMap.getOrDefault("", 0)
        val unusedSpace = total - used
        val deficit = required - unusedSpace

        return directoriesMap.values.filter { it >= deficit }.min()
    }

}

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

  static {};
    Code:
       0: invokestatic  #14                 // Method Day07$CommandType.values:()[LDay07$CommandType;
       3: arraylength
       4: newarray       int
       6: astore_0
       7: nop
       8: aload_0
       9: getstatic     #18                 // Field Day07$CommandType.COMMAND_CD_ROOT:LDay07$CommandType;
      12: invokevirtual #22                 // Method Day07$CommandType.ordinal:()I
      15: iconst_1
      16: iastore
      17: goto          21
      20: astore_1
      21: nop
      22: aload_0
      23: getstatic     #25                 // Field Day07$CommandType.COMMAND_CD_UP:LDay07$CommandType;
      26: invokevirtual #22                 // Method Day07$CommandType.ordinal:()I
      29: iconst_2
      30: iastore
      31: goto          35
      34: astore_1
      35: nop
      36: aload_0
      37: getstatic     #28                 // Field Day07$CommandType.COMMAND_CD:LDay07$CommandType;
      40: invokevirtual #22                 // Method Day07$CommandType.ordinal:()I
      43: iconst_3
      44: iastore
      45: goto          49
      48: astore_1
      49: nop
      50: aload_0
      51: getstatic     #31                 // Field Day07$CommandType.COMMAND_DIR:LDay07$CommandType;
      54: invokevirtual #22                 // Method Day07$CommandType.ordinal:()I
      57: iconst_4
      58: iastore
      59: goto          63
      62: astore_1
      63: nop
      64: aload_0
      65: getstatic     #34                 // Field Day07$CommandType.DIR:LDay07$CommandType;
      68: invokevirtual #22                 // Method Day07$CommandType.ordinal:()I
      71: iconst_5
      72: iastore
      73: goto          77
      76: astore_1
      77: nop
      78: aload_0
      79: getstatic     #37                 // Field Day07$CommandType.SIZE:LDay07$CommandType;
      82: invokevirtual #22                 // Method Day07$CommandType.ordinal:()I
      85: bipush        6
      87: iastore
      88: goto          92
      91: astore_1
      92: aload_0
      93: putstatic     #41                 // Field $EnumSwitchMapping$0:[I
      96: return
    Exception table:
       from    to  target type
           7    17    20   Class java/lang/NoSuchFieldError
          21    31    34   Class java/lang/NoSuchFieldError
          35    45    48   Class java/lang/NoSuchFieldError
          49    59    62   Class java/lang/NoSuchFieldError
          63    73    76   Class java/lang/NoSuchFieldError
          77    88    91   Class java/lang/NoSuchFieldError
}

Compiled from "Day07.kt"
final class Day07$CommandType extends java.lang.Enum<Day07$CommandType> {
  public static final Day07$CommandType COMMAND_CD_ROOT;

  public static final Day07$CommandType COMMAND_CD;

  public static final Day07$CommandType COMMAND_CD_UP;

  public static final Day07$CommandType COMMAND_DIR;

  public static final Day07$CommandType DIR;

  public static final Day07$CommandType SIZE;

  private static final Day07$CommandType[] $VALUES;

  private static final kotlin.enums.EnumEntries $ENTRIES;

  private Day07$CommandType();
    Code:
       0: aload_0
       1: aload_1
       2: iload_2
       3: invokespecial #10                 // Method java/lang/Enum."<init>":(Ljava/lang/String;I)V
       6: return

  public static Day07$CommandType[] values();
    Code:
       0: getstatic     #22                 // Field $VALUES:[LDay07$CommandType;
       3: invokevirtual #28                 // Method java/lang/Object.clone:()Ljava/lang/Object;
       6: checkcast     #29                 // class "[LDay07$CommandType;"
       9: areturn

  public static Day07$CommandType valueOf(java.lang.String);
    Code:
       0: ldc           #2                  // class Day07$CommandType
       2: aload_0
       3: invokestatic  #34                 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;
       6: checkcast     #2                  // class Day07$CommandType
       9: areturn

  public static kotlin.enums.EnumEntries<Day07$CommandType> getEntries();
    Code:
       0: getstatic     #43                 // Field $ENTRIES:Lkotlin/enums/EnumEntries;
       3: areturn

  private static final Day07$CommandType[] $values();
    Code:
       0: bipush        6
       2: anewarray     #2                  // class Day07$CommandType
       5: astore_0
       6: aload_0
       7: iconst_0
       8: getstatic     #47                 // Field COMMAND_CD_ROOT:LDay07$CommandType;
      11: aastore
      12: aload_0
      13: iconst_1
      14: getstatic     #50                 // Field COMMAND_CD:LDay07$CommandType;
      17: aastore
      18: aload_0
      19: iconst_2
      20: getstatic     #53                 // Field COMMAND_CD_UP:LDay07$CommandType;
      23: aastore
      24: aload_0
      25: iconst_3
      26: getstatic     #56                 // Field COMMAND_DIR:LDay07$CommandType;
      29: aastore
      30: aload_0
      31: iconst_4
      32: getstatic     #59                 // Field DIR:LDay07$CommandType;
      35: aastore
      36: aload_0
      37: iconst_5
      38: getstatic     #62                 // Field SIZE:LDay07$CommandType;
      41: aastore
      42: aload_0
      43: areturn

  static {};
    Code:
       0: new           #2                  // class Day07$CommandType
       3: dup
       4: ldc           #64                 // String COMMAND_CD_ROOT
       6: iconst_0
       7: invokespecial #65                 // Method "<init>":(Ljava/lang/String;I)V
      10: putstatic     #47                 // Field COMMAND_CD_ROOT:LDay07$CommandType;
      13: new           #2                  // class Day07$CommandType
      16: dup
      17: ldc           #66                 // String COMMAND_CD
      19: iconst_1
      20: invokespecial #65                 // Method "<init>":(Ljava/lang/String;I)V
      23: putstatic     #50                 // Field COMMAND_CD:LDay07$CommandType;
      26: new           #2                  // class Day07$CommandType
      29: dup
      30: ldc           #67                 // String COMMAND_CD_UP
      32: iconst_2
      33: invokespecial #65                 // Method "<init>":(Ljava/lang/String;I)V
      36: putstatic     #53                 // Field COMMAND_CD_UP:LDay07$CommandType;
      39: new           #2                  // class Day07$CommandType
      42: dup
      43: ldc           #68                 // String COMMAND_DIR
      45: iconst_3
      46: invokespecial #65                 // Method "<init>":(Ljava/lang/String;I)V
      49: putstatic     #56                 // Field COMMAND_DIR:LDay07$CommandType;
      52: new           #2                  // class Day07$CommandType
      55: dup
      56: ldc           #69                 // String DIR
      58: iconst_4
      59: invokespecial #65                 // Method "<init>":(Ljava/lang/String;I)V
      62: putstatic     #59                 // Field DIR:LDay07$CommandType;
      65: new           #2                  // class Day07$CommandType
      68: dup
      69: ldc           #70                 // String SIZE
      71: iconst_5
      72: invokespecial #65                 // Method "<init>":(Ljava/lang/String;I)V
      75: putstatic     #62                 // Field SIZE:LDay07$CommandType;
      78: invokestatic  #72                 // Method $values:()[LDay07$CommandType;
      81: putstatic     #22                 // Field $VALUES:[LDay07$CommandType;
      84: getstatic     #22                 // Field $VALUES:[LDay07$CommandType;
      87: checkcast     #74                 // class "[Ljava/lang/Enum;"
      90: invokestatic  #80                 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;
      93: putstatic     #43                 // Field $ENTRIES:Lkotlin/enums/EnumEntries;
      96: return
}

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

  public final long part1(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: invokespecial #26                 // Method directoriesMap:(Ljava/util/List;)Ljava/util/Map;
      11: astore_2
      12: aload_2
      13: invokeinterface #32,  1           // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
      18: checkcast     #34                 // class java/lang/Iterable
      21: astore_3
      22: iconst_0
      23: istore        4
      25: aload_3
      26: astore        5
      28: new           #36                 // class java/util/ArrayList
      31: dup
      32: invokespecial #37                 // Method java/util/ArrayList."<init>":()V
      35: checkcast     #39                 // class java/util/Collection
      38: astore        6
      40: iconst_0
      41: istore        7
      43: aload         5
      45: invokeinterface #43,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      50: astore        8
      52: aload         8
      54: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      59: ifeq          114
      62: aload         8
      64: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      69: astore        9
      71: aload         9
      73: checkcast     #55                 // class java/lang/Number
      76: invokevirtual #59                 // Method java/lang/Number.longValue:()J
      79: lstore        10
      81: iconst_0
      82: istore        12
      84: lload         10
      86: ldc2_w        #60                 // long 100000l
      89: lcmp
      90: ifgt          97
      93: iconst_1
      94: goto          98
      97: iconst_0
      98: ifeq          52
     101: aload         6
     103: aload         9
     105: invokeinterface #65,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     110: pop
     111: goto          52
     114: aload         6
     116: checkcast     #67                 // class java/util/List
     119: nop
     120: checkcast     #34                 // class java/lang/Iterable
     123: invokestatic  #73                 // Method kotlin/collections/CollectionsKt.sumOfLong:(Ljava/lang/Iterable;)J
     126: lreturn

  private final java.util.Map<java.lang.String, java.lang.Long> directoriesMap(java.util.List<java.lang.String>);
    Code:
       0: new           #92                 // class java/util/LinkedHashMap
       3: dup
       4: invokespecial #93                 // Method java/util/LinkedHashMap."<init>":()V
       7: checkcast     #28                 // class java/util/Map
      10: astore_2
      11: ldc           #95                 // String
      13: astore_3
      14: aload_1
      15: invokeinterface #96,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      20: astore        4
      22: aload         4
      24: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      29: ifeq          261
      32: aload         4
      34: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      39: checkcast     #98                 // class java/lang/String
      42: astore        5
      44: aload_0
      45: aload         5
      47: invokespecial #102                // Method getTyp:(Ljava/lang/String;)LDay07$CommandType;
      50: getstatic     #108                // Field Day07$WhenMappings.$EnumSwitchMapping$0:[I
      53: swap
      54: invokevirtual #114                // Method Day07$CommandType.ordinal:()I
      57: iaload
      58: tableswitch   { // 1 to 6
                     1: 96
                     2: 102
                     3: 115
                     4: 155
                     5: 158
                     6: 161
               default: 253
          }
      96: ldc           #95                 // String
      98: astore_3
      99: goto          22
     102: aload_3
     103: ldc           #116                // String /
     105: aconst_null
     106: iconst_2
     107: aconst_null
     108: invokestatic  #122                // Method kotlin/text/StringsKt.substringBeforeLast$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     111: astore_3
     112: goto          22
     115: aload         5
     117: ldc           #124                // String $ cd
     119: aconst_null
     120: iconst_2
     121: aconst_null
     122: invokestatic  #127                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     125: astore        6
     127: new           #129                // class java/lang/StringBuilder
     130: dup
     131: invokespecial #130                // Method java/lang/StringBuilder."<init>":()V
     134: aload_3
     135: invokevirtual #134                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     138: bipush        47
     140: invokevirtual #137                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     143: aload         6
     145: invokevirtual #134                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     148: invokevirtual #141                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     151: astore_3
     152: goto          22
     155: goto          22
     158: goto          22
     161: aload         5
     163: ldc           #143                // String
     165: aconst_null
     166: iconst_2
     167: aconst_null
     168: invokestatic  #146                // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     171: invokestatic  #152                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     174: istore        6
     176: aload_3
     177: astore        7
     179: nop
     180: aload_2
     181: aload         7
     183: lconst_0
     184: invokestatic  #158                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     187: invokeinterface #162,  3          // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     192: checkcast     #55                 // class java/lang/Number
     195: invokevirtual #59                 // Method java/lang/Number.longValue:()J
     198: lstore        8
     200: aload_2
     201: aload         7
     203: lload         8
     205: iload         6
     207: i2l
     208: ladd
     209: invokestatic  #158                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     212: invokeinterface #165,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     217: pop
     218: aload         7
     220: checkcast     #167                // class java/lang/CharSequence
     223: invokeinterface #170,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     228: ifne          235
     231: iconst_1
     232: goto          236
     235: iconst_0
     236: ifne          22
     239: aload         7
     241: ldc           #116                // String /
     243: ldc           #95                 // String
     245: invokestatic  #174                // Method kotlin/text/StringsKt.substringBeforeLast:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
     248: astore        7
     250: goto          179
     253: new           #176                // class kotlin/NoWhenBranchMatchedException
     256: dup
     257: invokespecial #177                // Method kotlin/NoWhenBranchMatchedException."<init>":()V
     260: athrow
     261: aload_2
     262: areturn

  private final Day07$CommandType getTyp(java.lang.String);
    Code:
       0: nop
       1: aload_1
       2: ldc           #186                // String $ cd /
       4: iconst_0
       5: iconst_2
       6: aconst_null
       7: invokestatic  #190                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
      10: ifeq          19
      13: getstatic     #194                // Field Day07$CommandType.COMMAND_CD_ROOT:LDay07$CommandType;
      16: goto          94
      19: aload_1
      20: ldc           #196                // String $ cd ..
      22: iconst_0
      23: iconst_2
      24: aconst_null
      25: invokestatic  #190                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
      28: ifeq          37
      31: getstatic     #199                // Field Day07$CommandType.COMMAND_CD_UP:LDay07$CommandType;
      34: goto          94
      37: aload_1
      38: ldc           #124                // String $ cd
      40: iconst_0
      41: iconst_2
      42: aconst_null
      43: invokestatic  #190                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
      46: ifeq          55
      49: getstatic     #202                // Field Day07$CommandType.COMMAND_CD:LDay07$CommandType;
      52: goto          94
      55: aload_1
      56: ldc           #204                // String $ ls
      58: iconst_0
      59: iconst_2
      60: aconst_null
      61: invokestatic  #190                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
      64: ifeq          73
      67: getstatic     #207                // Field Day07$CommandType.COMMAND_DIR:LDay07$CommandType;
      70: goto          94
      73: aload_1
      74: ldc           #209                // String dir
      76: iconst_0
      77: iconst_2
      78: aconst_null
      79: invokestatic  #190                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
      82: ifeq          91
      85: getstatic     #212                // Field Day07$CommandType.DIR:LDay07$CommandType;
      88: goto          94
      91: getstatic     #215                // Field Day07$CommandType.SIZE:LDay07$CommandType;
      94: areturn

  public final long part2(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: ldc           #218                // int 70000000
       8: istore_2
       9: ldc           #219                // int 30000000
      11: istore_3
      12: aload_0
      13: aload_1
      14: invokespecial #26                 // Method directoriesMap:(Ljava/util/List;)Ljava/util/Map;
      17: astore        4
      19: aload         4
      21: ldc           #95                 // String
      23: lconst_0
      24: invokestatic  #158                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      27: invokeinterface #162,  3          // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      32: checkcast     #55                 // class java/lang/Number
      35: invokevirtual #59                 // Method java/lang/Number.longValue:()J
      38: lstore        5
      40: iload_2
      41: i2l
      42: lload         5
      44: lsub
      45: lstore        7
      47: iload_3
      48: i2l
      49: lload         7
      51: lsub
      52: lstore        9
      54: aload         4
      56: invokeinterface #32,  1           // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
      61: checkcast     #34                 // class java/lang/Iterable
      64: astore        11
      66: iconst_0
      67: istore        12
      69: aload         11
      71: astore        13
      73: new           #36                 // class java/util/ArrayList
      76: dup
      77: invokespecial #37                 // Method java/util/ArrayList."<init>":()V
      80: checkcast     #39                 // class java/util/Collection
      83: astore        14
      85: iconst_0
      86: istore        15
      88: aload         13
      90: invokeinterface #43,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      95: astore        16
      97: aload         16
      99: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     104: ifeq          158
     107: aload         16
     109: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     114: astore        17
     116: aload         17
     118: checkcast     #55                 // class java/lang/Number
     121: invokevirtual #59                 // Method java/lang/Number.longValue:()J
     124: lstore        18
     126: iconst_0
     127: istore        20
     129: lload         18
     131: lload         9
     133: lcmp
     134: iflt          141
     137: iconst_1
     138: goto          142
     141: iconst_0
     142: ifeq          97
     145: aload         14
     147: aload         17
     149: invokeinterface #65,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     154: pop
     155: goto          97
     158: aload         14
     160: checkcast     #67                 // class java/util/List
     163: nop
     164: checkcast     #34                 // class java/lang/Iterable
     167: invokestatic  #223                // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     170: checkcast     #55                 // class java/lang/Number
     173: invokevirtual #59                 // Method java/lang/Number.longValue:()J
     176: lreturn
}