fun main(args: Array<String>) {
    fun parseStacks(input: List<String>): Pair<List<MutableList<Char>>, List<String>> {
        val stackLabels = input.find { s -> s.startsWith(" 1") }!!
        val numStacks = stackLabels.split(" ").last { s -> !s.isEmpty() }.toInt()

        val stacks = mutableListOf<MutableList<Char>>()
        for (i in 1..numStacks) {
            stacks.add(mutableListOf())
        }

        var i = 0
        while (!input[i].startsWith(" 1")) {
            val line = input[i]
            var j = 0
            while (j < numStacks) {
                val c = line[j * 4 + 1]
                if (c != ' ') {
                    stacks[j].add(c)
                }
                j += 1
            }
            i++
        }
        return Pair(stacks, input.subList(i + 2, input.size))
    }

    fun executeMoves(stacks: List<MutableList<Char>>, moves: List<String>, reverseOrder: Boolean) {
        moves.filter{ it.isNotEmpty() }.forEach {
            val (num, src, dst) = it.split(" ").mapNotNull { s -> s.toIntOrNull() }
            if (reverseOrder) {
                for (i in num - 1 downTo 0) {
                    stacks[dst - 1].add(0, stacks[src - 1].removeAt(i))
                }
            } else {
                for (i in 1..num) {
                    stacks[dst - 1].add(0, stacks[src - 1].removeAt(0))
                }
            }
        }
    }

    fun resultString(stacks: List<List<Char>>): String {
        return stacks.map { it.first() }.joinToString("")
    }

    fun part1(input: String) {
        val (stacks, moves) = parseStacks(input.split("\n"))
        executeMoves(stacks, moves, false)
        println(resultString(stacks))
    }

    fun part2(input: String) {
        val (stacks, moves) = parseStacks(input.split("\n"))
        executeMoves(stacks, moves, true)
        println(resultString(stacks))
    }

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

    part1(input)
    part2(input)
}

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

Compiled from "Day05.kt"
public final class Day05Kt {
  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 Day05Kt$main$input$1
       9: dup
      10: invokespecial #21                 // Method Day05Kt$main$input$1."<init>":()V
      13: invokevirtual #25                 // Method java/lang/Object.getClass:()Ljava/lang/Class;
      16: ldc           #27                 // String Day05.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 kotlin.Pair<java.util.List<java.util.List<java.lang.Character>>, java.util.List<java.lang.String>> main$parseStacks(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #70                 // class java/lang/Iterable
       4: astore_3
       5: aload_3
       6: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      11: astore        4
      13: aload         4
      15: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      20: ifeq          60
      23: aload         4
      25: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      30: astore        5
      32: aload         5
      34: checkcast     #52                 // class java/lang/String
      37: astore        6
      39: iconst_0
      40: istore        7
      42: aload         6
      44: ldc           #86                 // String  1
      46: iconst_0
      47: iconst_2
      48: aconst_null
      49: invokestatic  #92                 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
      52: ifeq          13
      55: aload         5
      57: goto          61
      60: aconst_null
      61: dup
      62: invokestatic  #96                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      65: checkcast     #52                 // class java/lang/String
      68: astore_1
      69: aload_1
      70: checkcast     #98                 // class java/lang/CharSequence
      73: iconst_1
      74: anewarray     #52                 // class java/lang/String
      77: astore_3
      78: aload_3
      79: iconst_0
      80: ldc           #100                // String
      82: aastore
      83: aload_3
      84: iconst_0
      85: iconst_0
      86: bipush        6
      88: aconst_null
      89: invokestatic  #104                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      92: astore_3
      93: iconst_0
      94: istore        4
      96: aload_3
      97: aload_3
      98: invokeinterface #110,  1          // InterfaceMethod java/util/List.size:()I
     103: invokeinterface #114,  2          // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;
     108: astore        5
     110: aload         5
     112: invokeinterface #119,  1          // InterfaceMethod java/util/ListIterator.hasPrevious:()Z
     117: ifeq          173
     120: aload         5
     122: invokeinterface #122,  1          // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;
     127: astore        6
     129: aload         6
     131: checkcast     #52                 // class java/lang/String
     134: astore        7
     136: iconst_0
     137: istore        8
     139: aload         7
     141: checkcast     #98                 // class java/lang/CharSequence
     144: invokeinterface #125,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     149: ifne          156
     152: iconst_1
     153: goto          157
     156: iconst_0
     157: ifne          164
     160: iconst_1
     161: goto          165
     164: iconst_0
     165: ifeq          110
     168: aload         6
     170: goto          183
     173: new           #127                // class java/util/NoSuchElementException
     176: dup
     177: ldc           #129                // String List contains no element matching the predicate.
     179: invokespecial #131                // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
     182: athrow
     183: checkcast     #52                 // class java/lang/String
     186: invokestatic  #137                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     189: istore_2
     190: new           #139                // class java/util/ArrayList
     193: dup
     194: invokespecial #140                // Method java/util/ArrayList."<init>":()V
     197: checkcast     #106                // class java/util/List
     200: astore_3
     201: iconst_1
     202: istore        4
     204: iload         4
     206: iload_2
     207: if_icmpgt     239
     210: aload_3
     211: new           #139                // class java/util/ArrayList
     214: dup
     215: invokespecial #140                // Method java/util/ArrayList."<init>":()V
     218: checkcast     #106                // class java/util/List
     221: invokeinterface #144,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     226: pop
     227: iload         4
     229: iload_2
     230: if_icmpeq     239
     233: iinc          4, 1
     236: goto          210
     239: iconst_0
     240: istore        4
     242: aload_0
     243: iload         4
     245: invokeinterface #148,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     250: checkcast     #52                 // class java/lang/String
     253: ldc           #86                 // String  1
     255: iconst_0
     256: iconst_2
     257: aconst_null
     258: invokestatic  #92                 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
     261: ifne          340
     264: aload_0
     265: iload         4
     267: invokeinterface #148,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     272: checkcast     #52                 // class java/lang/String
     275: astore        5
     277: iconst_0
     278: istore        6
     280: iload         6
     282: iload_2
     283: if_icmpge     334
     286: aload         5
     288: iload         6
     290: iconst_4
     291: imul
     292: iconst_1
     293: iadd
     294: invokevirtual #152                // Method java/lang/String.charAt:(I)C
     297: istore        7
     299: iload         7
     301: bipush        32
     303: if_icmpeq     328
     306: aload_3
     307: iload         6
     309: invokeinterface #148,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     314: checkcast     #106                // class java/util/List
     317: iload         7
     319: invokestatic  #158                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     322: invokeinterface #144,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     327: pop
     328: iinc          6, 1
     331: goto          280
     334: iinc          4, 1
     337: goto          242
     340: new           #160                // class kotlin/Pair
     343: dup
     344: aload_3
     345: aload_0
     346: iload         4
     348: iconst_2
     349: iadd
     350: aload_0
     351: invokeinterface #110,  1          // InterfaceMethod java/util/List.size:()I
     356: invokeinterface #164,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     361: invokespecial #167                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     364: areturn

  private static final void main$executeMoves(java.util.List<? extends java.util.List<java.lang.Character>>, java.util.List<java.lang.String>, boolean);
    Code:
       0: aload_1
       1: checkcast     #70                 // class java/lang/Iterable
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: astore        5
      11: new           #139                // class java/util/ArrayList
      14: dup
      15: invokespecial #140                // Method java/util/ArrayList."<init>":()V
      18: checkcast     #191                // class java/util/Collection
      21: astore        6
      23: iconst_0
      24: istore        7
      26: aload         5
      28: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      33: astore        8
      35: aload         8
      37: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      42: ifeq          99
      45: aload         8
      47: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      52: astore        9
      54: aload         9
      56: checkcast     #52                 // class java/lang/String
      59: astore        10
      61: iconst_0
      62: istore        11
      64: aload         10
      66: checkcast     #98                 // class java/lang/CharSequence
      69: invokeinterface #125,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      74: ifle          81
      77: iconst_1
      78: goto          82
      81: iconst_0
      82: nop
      83: ifeq          35
      86: aload         6
      88: aload         9
      90: invokeinterface #192,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      95: pop
      96: goto          35
      99: aload         6
     101: checkcast     #106                // class java/util/List
     104: nop
     105: checkcast     #70                 // class java/lang/Iterable
     108: astore_3
     109: nop
     110: iconst_0
     111: istore        4
     113: aload_3
     114: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     119: astore        5
     121: aload         5
     123: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     128: ifeq          472
     131: aload         5
     133: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     138: astore        6
     140: aload         6
     142: checkcast     #52                 // class java/lang/String
     145: astore        7
     147: iconst_0
     148: istore        8
     150: aload         7
     152: checkcast     #98                 // class java/lang/CharSequence
     155: iconst_1
     156: anewarray     #52                 // class java/lang/String
     159: astore        9
     161: aload         9
     163: iconst_0
     164: ldc           #100                // String
     166: aastore
     167: aload         9
     169: iconst_0
     170: iconst_0
     171: bipush        6
     173: aconst_null
     174: invokestatic  #104                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     177: checkcast     #70                 // class java/lang/Iterable
     180: astore        9
     182: iconst_0
     183: istore        10
     185: aload         9
     187: astore        11
     189: new           #139                // class java/util/ArrayList
     192: dup
     193: invokespecial #140                // Method java/util/ArrayList."<init>":()V
     196: checkcast     #191                // class java/util/Collection
     199: astore        12
     201: iconst_0
     202: istore        13
     204: aload         11
     206: astore        14
     208: iconst_0
     209: istore        15
     211: aload         14
     213: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     218: astore        16
     220: aload         16
     222: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     227: ifeq          288
     230: aload         16
     232: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     237: astore        17
     239: aload         17
     241: astore        18
     243: iconst_0
     244: istore        19
     246: aload         18
     248: checkcast     #52                 // class java/lang/String
     251: astore        20
     253: iconst_0
     254: istore        21
     256: aload         20
     258: invokestatic  #196                // Method kotlin/text/StringsKt.toIntOrNull:(Ljava/lang/String;)Ljava/lang/Integer;
     261: dup
     262: ifnull        283
     265: astore        22
     267: iconst_0
     268: istore        23
     270: aload         12
     272: aload         22
     274: invokeinterface #192,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     279: pop
     280: goto          284
     283: pop
     284: nop
     285: goto          220
     288: nop
     289: aload         12
     291: checkcast     #106                // class java/util/List
     294: nop
     295: astore        24
     297: aload         24
     299: iconst_0
     300: invokeinterface #148,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     305: checkcast     #198                // class java/lang/Number
     308: invokevirtual #201                // Method java/lang/Number.intValue:()I
     311: istore        9
     313: aload         24
     315: iconst_1
     316: invokeinterface #148,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     321: checkcast     #198                // class java/lang/Number
     324: invokevirtual #201                // Method java/lang/Number.intValue:()I
     327: istore        10
     329: aload         24
     331: iconst_2
     332: invokeinterface #148,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     337: checkcast     #198                // class java/lang/Number
     340: invokevirtual #201                // Method java/lang/Number.intValue:()I
     343: istore        11
     345: iload_2
     346: ifeq          406
     349: iload         9
     351: iconst_1
     352: isub
     353: istore        12
     355: iconst_m1
     356: iload         12
     358: if_icmpge     467
     361: aload_0
     362: iload         11
     364: iconst_1
     365: isub
     366: invokeinterface #148,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     371: checkcast     #106                // class java/util/List
     374: iconst_0
     375: aload_0
     376: iload         10
     378: iconst_1
     379: isub
     380: invokeinterface #148,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     385: checkcast     #106                // class java/util/List
     388: iload         12
     390: invokeinterface #204,  2          // InterfaceMethod java/util/List.remove:(I)Ljava/lang/Object;
     395: invokeinterface #207,  3          // InterfaceMethod java/util/List.add:(ILjava/lang/Object;)V
     400: iinc          12, -1
     403: goto          355
     406: iconst_1
     407: istore        12
     409: iload         12
     411: iload         9
     413: if_icmpgt     467
     416: aload_0
     417: iload         11
     419: iconst_1
     420: isub
     421: invokeinterface #148,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     426: checkcast     #106                // class java/util/List
     429: iconst_0
     430: aload_0
     431: iload         10
     433: iconst_1
     434: isub
     435: invokeinterface #148,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     440: checkcast     #106                // class java/util/List
     443: iconst_0
     444: invokeinterface #204,  2          // InterfaceMethod java/util/List.remove:(I)Ljava/lang/Object;
     449: invokeinterface #207,  3          // InterfaceMethod java/util/List.add:(ILjava/lang/Object;)V
     454: iload         12
     456: iload         9
     458: if_icmpeq     467
     461: iinc          12, 1
     464: goto          416
     467: nop
     468: nop
     469: goto          121
     472: nop
     473: return

  private static final java.lang.String main$resultString(java.util.List<? extends java.util.List<java.lang.Character>>);
    Code:
       0: aload_0
       1: checkcast     #70                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: astore_3
       9: new           #139                // class java/util/ArrayList
      12: dup
      13: aload_1
      14: bipush        10
      16: invokestatic  #245                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      19: invokespecial #248                // Method java/util/ArrayList."<init>":(I)V
      22: checkcast     #191                // class java/util/Collection
      25: astore        4
      27: iconst_0
      28: istore        5
      30: aload_3
      31: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      36: astore        6
      38: aload         6
      40: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      45: ifeq          97
      48: aload         6
      50: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      55: astore        7
      57: aload         4
      59: aload         7
      61: checkcast     #106                // class java/util/List
      64: astore        8
      66: astore        10
      68: iconst_0
      69: istore        9
      71: aload         8
      73: invokestatic  #252                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      76: checkcast     #154                // class java/lang/Character
      79: invokevirtual #256                // Method java/lang/Character.charValue:()C
      82: invokestatic  #158                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      85: aload         10
      87: swap
      88: invokeinterface #192,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      93: pop
      94: goto          38
      97: aload         4
      99: checkcast     #106                // class java/util/List
     102: nop
     103: checkcast     #70                 // class java/lang/Iterable
     106: ldc_w         #258                // String
     109: checkcast     #98                 // class java/lang/CharSequence
     112: aconst_null
     113: aconst_null
     114: iconst_0
     115: aconst_null
     116: aconst_null
     117: bipush        62
     119: aconst_null
     120: invokestatic  #262                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
     123: areturn

  private static final void main$part1(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #98                 // 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_w         #270                // String \n
      14: aastore
      15: aload_2
      16: iconst_0
      17: iconst_0
      18: bipush        6
      20: aconst_null
      21: invokestatic  #104                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      24: invokestatic  #272                // Method main$parseStacks:(Ljava/util/List;)Lkotlin/Pair;
      27: astore_1
      28: aload_1
      29: invokevirtual #275                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      32: checkcast     #106                // class java/util/List
      35: astore_2
      36: aload_1
      37: invokevirtual #278                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      40: checkcast     #106                // class java/util/List
      43: astore_3
      44: aload_2
      45: aload_3
      46: iconst_0
      47: invokestatic  #280                // Method main$executeMoves:(Ljava/util/List;Ljava/util/List;Z)V
      50: aload_2
      51: invokestatic  #282                // Method main$resultString:(Ljava/util/List;)Ljava/lang/String;
      54: getstatic     #288                // Field java/lang/System.out:Ljava/io/PrintStream;
      57: swap
      58: invokevirtual #293                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      61: return

  private static final void main$part2(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #98                 // 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_w         #270                // String \n
      14: aastore
      15: aload_2
      16: iconst_0
      17: iconst_0
      18: bipush        6
      20: aconst_null
      21: invokestatic  #104                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      24: invokestatic  #272                // Method main$parseStacks:(Ljava/util/List;)Lkotlin/Pair;
      27: astore_1
      28: aload_1
      29: invokevirtual #275                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      32: checkcast     #106                // class java/util/List
      35: astore_2
      36: aload_1
      37: invokevirtual #278                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      40: checkcast     #106                // class java/util/List
      43: astore_3
      44: aload_2
      45: aload_3
      46: iconst_1
      47: invokestatic  #280                // Method main$executeMoves:(Ljava/util/List;Ljava/util/List;Z)V
      50: aload_2
      51: invokestatic  #282                // Method main$resultString:(Ljava/util/List;)Ljava/lang/String;
      54: getstatic     #288                // Field java/lang/System.out:Ljava/io/PrintStream;
      57: swap
      58: invokevirtual #293                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      61: return
}


fun main(args: Array<String>) {
    class Tree(val height: Int) {
        var visited = false
        var viewScore = 0

        override fun toString(): String {
            return "$height${if (visited) '*' else ' '} "
        }
    }

    fun countRows(input: List<String>): Int {
        return input.size
    }

    fun countCols(input: List<String>): Int {
        return input[0].length
    }

    fun visit(tree: Tree, maxHeight: Int): Int {
        return if (tree.height > maxHeight) {
            tree.visited = true
            tree.height
        } else {
            maxHeight
        }
    }

    fun countFromTop(grid: Array<Array<Tree>>) {
        for (col in 0 until grid[0].size) {
            var maxHeight = -1
            for (row in 0 until grid.size) {
                maxHeight = visit(grid[row][col], maxHeight)
            }
        }
    }

    fun countFromRight(grid: Array<Array<Tree>>) {
        for (row in 0 until grid.size) {
            var maxHeight = -1
            for (col in grid.size - 1 downTo 0) {
                maxHeight = visit(grid[row][col], maxHeight)
            }
        }
    }

    fun countFromBottom(grid: Array<Array<Tree>>) {
        for (col in 0 until grid[0].size) {
            var maxHeight = -1
            for (row in grid.size - 1 downTo 0) {
                maxHeight = visit(grid[row][col], maxHeight)
            }
        }
    }

    fun countFromLeft(grid: Array<Array<Tree>>) {
        for (row in 0 until grid.size) {
            var maxHeight = -1
            for (col in 0 until grid.size) {
                maxHeight = visit(grid[row][col], maxHeight)
            }
        }
    }

    fun part1(grid: Array<Array<Tree>>) {
        countFromTop(grid)
        countFromRight(grid)
        countFromBottom(grid)
        countFromLeft(grid)

        grid.forEach{
            it.forEach { it2 -> print(it2)}
            println()
        }

        val visibleCount = grid.sumOf { it.filter { tree -> tree.visited }.size }
        println("Visible: $visibleCount")
    }

    fun viewScoreUp(grid: Array<Array<Tree>>, treeRow: Int, treeCol: Int): Int {
        val height = grid[treeRow][treeCol].height
        var score = 0
        for (row in treeRow - 1 downTo 0) {
            score++
            if (grid[row][treeCol].height >= height) {
                break
            }
        }
        return score
    }

    fun viewScoreRight(grid: Array<Array<Tree>>, treeRow: Int, treeCol: Int): Int {
        val height = grid[treeRow][treeCol].height
        var score = 0
        for (col in treeCol + 1 until grid[treeRow].size) {
            score++
            if (grid[treeRow][col].height >= height) {
                break
            }
        }
        return score
    }

    fun viewScoreDown(grid: Array<Array<Tree>>, treeRow: Int, treeCol: Int): Int {
        val height = grid[treeRow][treeCol].height
        var score = 0
        for (row in treeRow + 1 until grid.size) {
            score++
            if (grid[row][treeCol].height >= height) {
                break
            }
        }
        return score
    }

    fun viewScoreLeft(grid: Array<Array<Tree>>, treeRow: Int, treeCol: Int): Int {
        val height = grid[treeRow][treeCol].height
        var score = 0
        for (col in treeCol - 1 downTo 0) {
            score++
            if (grid[treeRow][col].height >= height) {
                break
            }
        }
        return score
    }

    fun calcViewScore(grid: Array<Array<Tree>>, row: Int, col: Int) {
        grid[row][col].viewScore = viewScoreUp(grid, row, col)
        if (grid[row][col].viewScore == 0) return

        grid[row][col].viewScore *= viewScoreRight(grid, row, col)
        if (grid[row][col].viewScore == 0) return

        grid[row][col].viewScore *= viewScoreDown(grid, row, col)
        if (grid[row][col].viewScore == 0) return

        grid[row][col].viewScore *= viewScoreLeft(grid, row, col)
    }

    fun part2(grid: Array<Array<Tree>>) {
        for (row in 0 until grid.size) {
            for (col in 0 until grid[row].size) {
                calcViewScore(grid, row, col)
            }
        }

        grid.forEach{
            it.forEach { it2 -> print("${it2.viewScore} ") }
            println()
        }

        val bestViewScore = grid.maxOf { it -> it.maxOf { tree -> tree.viewScore }}
        println("Best view score: $bestViewScore")
    }

    val input = object {}.javaClass.getResource("Day08.txt").readText().trim().split("\n")

    val rows = countRows(input)
    val cols = countCols(input)
    val protoGrid: Array<Array<Tree?>> = Array(rows) {
        arrayOfNulls(cols)
    }
    input.forEachIndexed { rowIdx, row -> row.forEachIndexed {
            colIdx, height -> protoGrid[rowIdx][colIdx] = Tree(height.digitToInt()) } }
    val grid = protoGrid as Array<Array<Tree>>

    part1(grid)
    part2(grid)
}

Compiled from "Day08.kt"
public final class Day08Kt$main$Tree {
  private final int height;

  private boolean visited;

  private int viewScore;

  public Day08Kt$main$Tree(int);
    Code:
       0: aload_0
       1: invokespecial #9                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: iload_1
       6: putfield      #13                 // Field height:I
       9: return

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

  public final boolean getVisited();
    Code:
       0: aload_0
       1: getfield      #23                 // Field visited:Z
       4: ireturn

  public final void setVisited(boolean);
    Code:
       0: aload_0
       1: iload_1
       2: putfield      #23                 // Field visited:Z
       5: return

  public final int getViewScore();
    Code:
       0: aload_0
       1: getfield      #30                 // Field viewScore:I
       4: ireturn

  public final void setViewScore(int);
    Code:
       0: aload_0
       1: iload_1
       2: putfield      #30                 // Field viewScore:I
       5: return

  public java.lang.String toString();
    Code:
       0: new           #35                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #36                 // Method java/lang/StringBuilder."<init>":()V
       7: aload_0
       8: getfield      #13                 // Field height:I
      11: invokevirtual #40                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      14: aload_0
      15: getfield      #23                 // Field visited:Z
      18: ifeq          26
      21: bipush        42
      23: goto          28
      26: bipush        32
      28: invokevirtual #43                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      31: bipush        32
      33: invokevirtual #43                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      36: invokevirtual #45                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      39: areturn
}

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

Compiled from "Day08.kt"
public final class Day08Kt {
  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 Day08Kt$main$input$1
       9: dup
      10: invokespecial #21                 // Method Day08Kt$main$input$1."<init>":()V
      13: invokevirtual #25                 // Method java/lang/Object.getClass:()Ljava/lang/Class;
      16: ldc           #27                 // String Day08.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: checkcast     #57                 // class java/lang/CharSequence
      51: invokestatic  #63                 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      54: invokevirtual #67                 // Method java/lang/Object.toString:()Ljava/lang/String;
      57: checkcast     #57                 // class java/lang/CharSequence
      60: iconst_1
      61: anewarray     #52                 // class java/lang/String
      64: astore_2
      65: aload_2
      66: iconst_0
      67: ldc           #69                 // String \n
      69: aastore
      70: aload_2
      71: iconst_0
      72: iconst_0
      73: bipush        6
      75: aconst_null
      76: invokestatic  #73                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      79: astore_1
      80: aload_1
      81: invokestatic  #77                 // Method main$countRows:(Ljava/util/List;)I
      84: istore_2
      85: aload_1
      86: invokestatic  #80                 // Method main$countCols:(Ljava/util/List;)I
      89: istore_3
      90: iconst_0
      91: istore        5
      93: iload_2
      94: anewarray     #82                 // class "[LDay08Kt$main$Tree;"
      97: astore        6
      99: iload         5
     101: iload_2
     102: if_icmpge     124
     105: iload         5
     107: istore        7
     109: aload         6
     111: iload         7
     113: iload_3
     114: anewarray     #84                 // class Day08Kt$main$Tree
     117: aastore
     118: iinc          5, 1
     121: goto          99
     124: aload         6
     126: astore        4
     128: aload_1
     129: checkcast     #86                 // class java/lang/Iterable
     132: astore        5
     134: iconst_0
     135: istore        6
     137: iconst_0
     138: istore        7
     140: aload         5
     142: invokeinterface #90,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     147: astore        8
     149: aload         8
     151: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     156: ifeq          283
     159: aload         8
     161: invokeinterface #100,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     166: astore        9
     168: iload         7
     170: iinc          7, 1
     173: istore        10
     175: iload         10
     177: ifge          183
     180: invokestatic  #105                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     183: iload         10
     185: aload         9
     187: checkcast     #52                 // class java/lang/String
     190: astore        11
     192: istore        12
     194: iconst_0
     195: istore        13
     197: aload         11
     199: checkcast     #57                 // class java/lang/CharSequence
     202: astore        14
     204: iconst_0
     205: istore        15
     207: iconst_0
     208: istore        16
     210: iconst_0
     211: istore        17
     213: iload         17
     215: aload         14
     217: invokeinterface #109,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     222: if_icmpge     277
     225: aload         14
     227: iload         17
     229: invokeinterface #113,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     234: istore        18
     236: iload         16
     238: iinc          16, 1
     241: iload         18
     243: istore        19
     245: istore        20
     247: iconst_0
     248: istore        21
     250: aload         4
     252: iload         12
     254: aaload
     255: iload         20
     257: new           #84                 // class Day08Kt$main$Tree
     260: dup
     261: iload         19
     263: invokestatic  #119                // Method kotlin/text/CharsKt.digitToInt:(C)I
     266: invokespecial #122                // Method Day08Kt$main$Tree."<init>":(I)V
     269: aastore
     270: nop
     271: iinc          17, 1
     274: goto          213
     277: nop
     278: nop
     279: nop
     280: goto          149
     283: nop
     284: aload         4
     286: astore        5
     288: aload         5
     290: invokestatic  #126                // Method main$part1:([[LDay08Kt$main$Tree;)V
     293: aload         5
     295: invokestatic  #129                // Method main$part2:([[LDay08Kt$main$Tree;)V
     298: return

  private static final int main$countRows(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokeinterface #163,  1          // InterfaceMethod java/util/List.size:()I
       6: ireturn

  private static final int main$countCols(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: iconst_0
       2: invokeinterface #167,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
       7: checkcast     #52                 // class java/lang/String
      10: invokevirtual #168                // Method java/lang/String.length:()I
      13: ireturn

  private static final int main$visit(Day08Kt$main$Tree, int);
    Code:
       0: aload_0
       1: invokevirtual #173                // Method Day08Kt$main$Tree.getHeight:()I
       4: iload_1
       5: if_icmple     20
       8: aload_0
       9: iconst_1
      10: invokevirtual #177                // Method Day08Kt$main$Tree.setVisited:(Z)V
      13: aload_0
      14: invokevirtual #173                // Method Day08Kt$main$Tree.getHeight:()I
      17: goto          21
      20: iload_1
      21: ireturn

  private static final void main$countFromTop(Day08Kt$main$Tree[][]);
    Code:
       0: iconst_0
       1: istore_1
       2: aload_0
       3: iconst_0
       4: aaload
       5: arraylength
       6: istore_2
       7: iload_1
       8: iload_2
       9: if_icmpge     54
      12: iconst_m1
      13: istore_3
      14: iconst_0
      15: istore        4
      17: aload_0
      18: checkcast     #183                // class "[Ljava/lang/Object;"
      21: arraylength
      22: istore        5
      24: iload         4
      26: iload         5
      28: if_icmpge     48
      31: aload_0
      32: iload         4
      34: aaload
      35: iload_1
      36: aaload
      37: iload_3
      38: invokestatic  #185                // Method main$visit:(LDay08Kt$main$Tree;I)I
      41: istore_3
      42: iinc          4, 1
      45: goto          24
      48: iinc          1, 1
      51: goto          7
      54: return

  private static final void main$countFromRight(Day08Kt$main$Tree[][]);
    Code:
       0: iconst_0
       1: istore_1
       2: aload_0
       3: checkcast     #183                // class "[Ljava/lang/Object;"
       6: arraylength
       7: istore_2
       8: iload_1
       9: iload_2
      10: if_icmpge     53
      13: iconst_m1
      14: istore_3
      15: aload_0
      16: checkcast     #183                // class "[Ljava/lang/Object;"
      19: arraylength
      20: iconst_1
      21: isub
      22: istore        4
      24: iconst_m1
      25: iload         4
      27: if_icmpge     47
      30: aload_0
      31: iload_1
      32: aaload
      33: iload         4
      35: aaload
      36: iload_3
      37: invokestatic  #185                // Method main$visit:(LDay08Kt$main$Tree;I)I
      40: istore_3
      41: iinc          4, -1
      44: goto          24
      47: iinc          1, 1
      50: goto          8
      53: return

  private static final void main$countFromBottom(Day08Kt$main$Tree[][]);
    Code:
       0: iconst_0
       1: istore_1
       2: aload_0
       3: iconst_0
       4: aaload
       5: arraylength
       6: istore_2
       7: iload_1
       8: iload_2
       9: if_icmpge     52
      12: iconst_m1
      13: istore_3
      14: aload_0
      15: checkcast     #183                // class "[Ljava/lang/Object;"
      18: arraylength
      19: iconst_1
      20: isub
      21: istore        4
      23: iconst_m1
      24: iload         4
      26: if_icmpge     46
      29: aload_0
      30: iload         4
      32: aaload
      33: iload_1
      34: aaload
      35: iload_3
      36: invokestatic  #185                // Method main$visit:(LDay08Kt$main$Tree;I)I
      39: istore_3
      40: iinc          4, -1
      43: goto          23
      46: iinc          1, 1
      49: goto          7
      52: return

  private static final void main$countFromLeft(Day08Kt$main$Tree[][]);
    Code:
       0: iconst_0
       1: istore_1
       2: aload_0
       3: checkcast     #183                // class "[Ljava/lang/Object;"
       6: arraylength
       7: istore_2
       8: iload_1
       9: iload_2
      10: if_icmpge     55
      13: iconst_m1
      14: istore_3
      15: iconst_0
      16: istore        4
      18: aload_0
      19: checkcast     #183                // class "[Ljava/lang/Object;"
      22: arraylength
      23: istore        5
      25: iload         4
      27: iload         5
      29: if_icmpge     49
      32: aload_0
      33: iload_1
      34: aaload
      35: iload         4
      37: aaload
      38: iload_3
      39: invokestatic  #185                // Method main$visit:(LDay08Kt$main$Tree;I)I
      42: istore_3
      43: iinc          4, 1
      46: goto          25
      49: iinc          1, 1
      52: goto          8
      55: return

  private static final void main$part1(Day08Kt$main$Tree[][]);
    Code:
       0: aload_0
       1: invokestatic  #191                // Method main$countFromTop:([[LDay08Kt$main$Tree;)V
       4: aload_0
       5: invokestatic  #193                // Method main$countFromRight:([[LDay08Kt$main$Tree;)V
       8: aload_0
       9: invokestatic  #195                // Method main$countFromBottom:([[LDay08Kt$main$Tree;)V
      12: aload_0
      13: invokestatic  #197                // Method main$countFromLeft:([[LDay08Kt$main$Tree;)V
      16: aload_0
      17: checkcast     #183                // class "[Ljava/lang/Object;"
      20: astore_1
      21: iconst_0
      22: istore_2
      23: iconst_0
      24: istore_3
      25: aload_1
      26: arraylength
      27: istore        4
      29: iload_3
      30: iload         4
      32: if_icmpge     117
      35: aload_1
      36: iload_3
      37: aaload
      38: astore        5
      40: aload         5
      42: checkcast     #82                 // class "[LDay08Kt$main$Tree;"
      45: astore        6
      47: iconst_0
      48: istore        7
      50: aload         6
      52: astore        8
      54: iconst_0
      55: istore        9
      57: iconst_0
      58: istore        10
      60: aload         8
      62: arraylength
      63: istore        11
      65: iload         10
      67: iload         11
      69: if_icmpge     102
      72: aload         8
      74: iload         10
      76: aaload
      77: astore        12
      79: aload         12
      81: astore        13
      83: iconst_0
      84: istore        14
      86: getstatic     #203                // Field java/lang/System.out:Ljava/io/PrintStream;
      89: aload         13
      91: invokevirtual #209                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
      94: nop
      95: nop
      96: iinc          10, 1
      99: goto          65
     102: nop
     103: getstatic     #203                // Field java/lang/System.out:Ljava/io/PrintStream;
     106: invokevirtual #212                // Method java/io/PrintStream.println:()V
     109: nop
     110: nop
     111: iinc          3, 1
     114: goto          29
     117: nop
     118: aload_0
     119: checkcast     #183                // class "[Ljava/lang/Object;"
     122: astore_2
     123: iconst_0
     124: istore_3
     125: iconst_0
     126: istore        4
     128: aload_2
     129: arraylength
     130: istore        5
     132: iload         4
     134: iload         5
     136: if_icmpge     262
     139: aload_2
     140: iload         4
     142: aaload
     143: astore        6
     145: iload_3
     146: aload         6
     148: checkcast     #82                 // class "[LDay08Kt$main$Tree;"
     151: astore        7
     153: istore        19
     155: iconst_0
     156: istore        8
     158: aload         7
     160: astore        9
     162: iconst_0
     163: istore        10
     165: aload         9
     167: astore        11
     169: new           #214                // class java/util/ArrayList
     172: dup
     173: invokespecial #215                // Method java/util/ArrayList."<init>":()V
     176: checkcast     #217                // class java/util/Collection
     179: astore        12
     181: iconst_0
     182: istore        13
     184: iconst_0
     185: istore        14
     187: aload         11
     189: arraylength
     190: istore        15
     192: iload         14
     194: iload         15
     196: if_icmpge     237
     199: aload         11
     201: iload         14
     203: aaload
     204: astore        16
     206: aload         16
     208: astore        17
     210: iconst_0
     211: istore        18
     213: aload         17
     215: invokevirtual #220                // Method Day08Kt$main$Tree.getVisited:()Z
     218: ifeq          231
     221: aload         12
     223: aload         16
     225: invokeinterface #224,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     230: pop
     231: iinc          14, 1
     234: goto          192
     237: aload         12
     239: checkcast     #156                // class java/util/List
     242: nop
     243: invokeinterface #163,  1          // InterfaceMethod java/util/List.size:()I
     248: istore        20
     250: iload         19
     252: iload         20
     254: iadd
     255: istore_3
     256: iinc          4, 1
     259: goto          132
     262: iload_3
     263: istore_1
     264: new           #226                // class java/lang/StringBuilder
     267: dup
     268: invokespecial #227                // Method java/lang/StringBuilder."<init>":()V
     271: ldc           #229                // String Visible:
     273: invokevirtual #233                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     276: iload_1
     277: invokevirtual #236                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     280: invokevirtual #237                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     283: getstatic     #203                // Field java/lang/System.out:Ljava/io/PrintStream;
     286: swap
     287: invokevirtual #239                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     290: return

  private static final int main$viewScoreUp(Day08Kt$main$Tree[][], int, int);
    Code:
       0: aload_0
       1: iload_1
       2: aaload
       3: iload_2
       4: aaload
       5: invokevirtual #173                // Method Day08Kt$main$Tree.getHeight:()I
       8: istore_3
       9: iconst_0
      10: istore        4
      12: iload_1
      13: iconst_1
      14: isub
      15: istore        5
      17: iconst_m1
      18: iload         5
      20: if_icmpge     48
      23: iinc          4, 1
      26: aload_0
      27: iload         5
      29: aaload
      30: iload_2
      31: aaload
      32: invokevirtual #173                // Method Day08Kt$main$Tree.getHeight:()I
      35: iload_3
      36: if_icmplt     42
      39: goto          48
      42: iinc          5, -1
      45: goto          17
      48: iload         4
      50: ireturn

  private static final int main$viewScoreRight(Day08Kt$main$Tree[][], int, int);
    Code:
       0: aload_0
       1: iload_1
       2: aaload
       3: iload_2
       4: aaload
       5: invokevirtual #173                // Method Day08Kt$main$Tree.getHeight:()I
       8: istore_3
       9: iconst_0
      10: istore        4
      12: iload_2
      13: iconst_1
      14: iadd
      15: istore        5
      17: aload_0
      18: iload_1
      19: aaload
      20: arraylength
      21: istore        6
      23: iload         5
      25: iload         6
      27: if_icmpge     55
      30: iinc          4, 1
      33: aload_0
      34: iload_1
      35: aaload
      36: iload         5
      38: aaload
      39: invokevirtual #173                // Method Day08Kt$main$Tree.getHeight:()I
      42: iload_3
      43: if_icmplt     49
      46: goto          55
      49: iinc          5, 1
      52: goto          23
      55: iload         4
      57: ireturn

  private static final int main$viewScoreDown(Day08Kt$main$Tree[][], int, int);
    Code:
       0: aload_0
       1: iload_1
       2: aaload
       3: iload_2
       4: aaload
       5: invokevirtual #173                // Method Day08Kt$main$Tree.getHeight:()I
       8: istore_3
       9: iconst_0
      10: istore        4
      12: iload_1
      13: iconst_1
      14: iadd
      15: istore        5
      17: aload_0
      18: checkcast     #183                // class "[Ljava/lang/Object;"
      21: arraylength
      22: istore        6
      24: iload         5
      26: iload         6
      28: if_icmpge     56
      31: iinc          4, 1
      34: aload_0
      35: iload         5
      37: aaload
      38: iload_2
      39: aaload
      40: invokevirtual #173                // Method Day08Kt$main$Tree.getHeight:()I
      43: iload_3
      44: if_icmplt     50
      47: goto          56
      50: iinc          5, 1
      53: goto          24
      56: iload         4
      58: ireturn

  private static final int main$viewScoreLeft(Day08Kt$main$Tree[][], int, int);
    Code:
       0: aload_0
       1: iload_1
       2: aaload
       3: iload_2
       4: aaload
       5: invokevirtual #173                // Method Day08Kt$main$Tree.getHeight:()I
       8: istore_3
       9: iconst_0
      10: istore        4
      12: iload_2
      13: iconst_1
      14: isub
      15: istore        5
      17: iconst_m1
      18: iload         5
      20: if_icmpge     48
      23: iinc          4, 1
      26: aload_0
      27: iload_1
      28: aaload
      29: iload         5
      31: aaload
      32: invokevirtual #173                // Method Day08Kt$main$Tree.getHeight:()I
      35: iload_3
      36: if_icmplt     42
      39: goto          48
      42: iinc          5, -1
      45: goto          17
      48: iload         4
      50: ireturn

  private static final void main$calcViewScore(Day08Kt$main$Tree[][], int, int);
    Code:
       0: aload_0
       1: iload_1
       2: aaload
       3: iload_2
       4: aaload
       5: aload_0
       6: iload_1
       7: iload_2
       8: invokestatic  #268                // Method main$viewScoreUp:([[LDay08Kt$main$Tree;II)I
      11: invokevirtual #271                // Method Day08Kt$main$Tree.setViewScore:(I)V
      14: aload_0
      15: iload_1
      16: aaload
      17: iload_2
      18: aaload
      19: invokevirtual #274                // Method Day08Kt$main$Tree.getViewScore:()I
      22: ifne          26
      25: return
      26: aload_0
      27: iload_1
      28: aaload
      29: iload_2
      30: aaload
      31: astore_3
      32: aload_3
      33: aload_3
      34: invokevirtual #274                // Method Day08Kt$main$Tree.getViewScore:()I
      37: aload_0
      38: iload_1
      39: iload_2
      40: invokestatic  #276                // Method main$viewScoreRight:([[LDay08Kt$main$Tree;II)I
      43: imul
      44: invokevirtual #271                // Method Day08Kt$main$Tree.setViewScore:(I)V
      47: aload_0
      48: iload_1
      49: aaload
      50: iload_2
      51: aaload
      52: invokevirtual #274                // Method Day08Kt$main$Tree.getViewScore:()I
      55: ifne          59
      58: return
      59: aload_0
      60: iload_1
      61: aaload
      62: iload_2
      63: aaload
      64: astore_3
      65: aload_3
      66: aload_3
      67: invokevirtual #274                // Method Day08Kt$main$Tree.getViewScore:()I
      70: aload_0
      71: iload_1
      72: iload_2
      73: invokestatic  #278                // Method main$viewScoreDown:([[LDay08Kt$main$Tree;II)I
      76: imul
      77: invokevirtual #271                // Method Day08Kt$main$Tree.setViewScore:(I)V
      80: aload_0
      81: iload_1
      82: aaload
      83: iload_2
      84: aaload
      85: invokevirtual #274                // Method Day08Kt$main$Tree.getViewScore:()I
      88: ifne          92
      91: return
      92: aload_0
      93: iload_1
      94: aaload
      95: iload_2
      96: aaload
      97: astore_3
      98: aload_3
      99: aload_3
     100: invokevirtual #274                // Method Day08Kt$main$Tree.getViewScore:()I
     103: aload_0
     104: iload_1
     105: iload_2
     106: invokestatic  #280                // Method main$viewScoreLeft:([[LDay08Kt$main$Tree;II)I
     109: imul
     110: invokevirtual #271                // Method Day08Kt$main$Tree.setViewScore:(I)V
     113: return

  private static final void main$part2(Day08Kt$main$Tree[][]);
    Code:
       0: iconst_0
       1: istore_1
       2: aload_0
       3: checkcast     #183                // class "[Ljava/lang/Object;"
       6: arraylength
       7: istore_2
       8: iload_1
       9: iload_2
      10: if_icmpge     45
      13: iconst_0
      14: istore_3
      15: aload_0
      16: iload_1
      17: aaload
      18: arraylength
      19: istore        4
      21: iload_3
      22: iload         4
      24: if_icmpge     39
      27: aload_0
      28: iload_1
      29: iload_3
      30: invokestatic  #282                // Method main$calcViewScore:([[LDay08Kt$main$Tree;II)V
      33: iinc          3, 1
      36: goto          21
      39: iinc          1, 1
      42: goto          8
      45: aload_0
      46: checkcast     #183                // class "[Ljava/lang/Object;"
      49: astore_1
      50: iconst_0
      51: istore_2
      52: iconst_0
      53: istore_3
      54: aload_1
      55: arraylength
      56: istore        4
      58: iload_3
      59: iload         4
      61: if_icmpge     168
      64: aload_1
      65: iload_3
      66: aaload
      67: astore        5
      69: aload         5
      71: checkcast     #82                 // class "[LDay08Kt$main$Tree;"
      74: astore        6
      76: iconst_0
      77: istore        7
      79: aload         6
      81: astore        8
      83: iconst_0
      84: istore        9
      86: iconst_0
      87: istore        10
      89: aload         8
      91: arraylength
      92: istore        11
      94: iload         10
      96: iload         11
      98: if_icmpge     153
     101: aload         8
     103: iload         10
     105: aaload
     106: astore        12
     108: aload         12
     110: astore        13
     112: iconst_0
     113: istore        14
     115: new           #226                // class java/lang/StringBuilder
     118: dup
     119: invokespecial #227                // Method java/lang/StringBuilder."<init>":()V
     122: aload         13
     124: invokevirtual #274                // Method Day08Kt$main$Tree.getViewScore:()I
     127: invokevirtual #236                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     130: bipush        32
     132: invokevirtual #285                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     135: invokevirtual #237                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     138: getstatic     #203                // Field java/lang/System.out:Ljava/io/PrintStream;
     141: swap
     142: invokevirtual #209                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     145: nop
     146: nop
     147: iinc          10, 1
     150: goto          94
     153: nop
     154: getstatic     #203                // Field java/lang/System.out:Ljava/io/PrintStream;
     157: invokevirtual #212                // Method java/io/PrintStream.println:()V
     160: nop
     161: nop
     162: iinc          3, 1
     165: goto          58
     168: nop
     169: aload_0
     170: checkcast     #183                // class "[Ljava/lang/Object;"
     173: astore_2
     174: aload_2
     175: arraylength
     176: ifne          183
     179: iconst_1
     180: goto          184
     183: iconst_0
     184: ifeq          195
     187: new           #287                // class java/util/NoSuchElementException
     190: dup
     191: invokespecial #288                // Method java/util/NoSuchElementException."<init>":()V
     194: athrow
     195: aload_2
     196: iconst_0
     197: aaload
     198: checkcast     #82                 // class "[LDay08Kt$main$Tree;"
     201: astore_3
     202: iconst_0
     203: istore        4
     205: aload_3
     206: astore        5
     208: aload         5
     210: arraylength
     211: ifne          218
     214: iconst_1
     215: goto          219
     218: iconst_0
     219: ifeq          230
     222: new           #287                // class java/util/NoSuchElementException
     225: dup
     226: invokespecial #288                // Method java/util/NoSuchElementException."<init>":()V
     229: athrow
     230: aload         5
     232: iconst_0
     233: aaload
     234: astore        6
     236: iconst_0
     237: istore        7
     239: aload         6
     241: invokevirtual #274                // Method Day08Kt$main$Tree.getViewScore:()I
     244: istore        6
     246: iconst_1
     247: istore        7
     249: aload         5
     251: invokestatic  #294                // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I
     254: istore        8
     256: iload         7
     258: iload         8
     260: if_icmpgt     304
     263: aload         5
     265: iload         7
     267: aaload
     268: astore        9
     270: iconst_0
     271: istore        10
     273: aload         9
     275: invokevirtual #274                // Method Day08Kt$main$Tree.getViewScore:()I
     278: istore        9
     280: iload         6
     282: iload         9
     284: if_icmpge     291
     287: iload         9
     289: istore        6
     291: iload         7
     293: iload         8
     295: if_icmpeq     304
     298: iinc          7, 1
     301: goto          263
     304: iload         6
     306: nop
     307: istore_3
     308: iconst_1
     309: istore        4
     311: aload_2
     312: invokestatic  #294                // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I
     315: istore        5
     317: iload         4
     319: iload         5
     321: if_icmpgt     463
     324: aload_2
     325: iload         4
     327: aaload
     328: checkcast     #82                 // class "[LDay08Kt$main$Tree;"
     331: astore        6
     333: iconst_0
     334: istore        7
     336: aload         6
     338: astore        8
     340: aload         8
     342: arraylength
     343: ifne          350
     346: iconst_1
     347: goto          351
     350: iconst_0
     351: ifeq          362
     354: new           #287                // class java/util/NoSuchElementException
     357: dup
     358: invokespecial #288                // Method java/util/NoSuchElementException."<init>":()V
     361: athrow
     362: aload         8
     364: iconst_0
     365: aaload
     366: astore        9
     368: iconst_0
     369: istore        10
     371: aload         9
     373: invokevirtual #274                // Method Day08Kt$main$Tree.getViewScore:()I
     376: istore        9
     378: iconst_1
     379: istore        10
     381: aload         8
     383: invokestatic  #294                // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I
     386: istore        11
     388: iload         10
     390: iload         11
     392: if_icmpgt     436
     395: aload         8
     397: iload         10
     399: aaload
     400: astore        12
     402: iconst_0
     403: istore        13
     405: aload         12
     407: invokevirtual #274                // Method Day08Kt$main$Tree.getViewScore:()I
     410: istore        12
     412: iload         9
     414: iload         12
     416: if_icmpge     423
     419: iload         12
     421: istore        9
     423: iload         10
     425: iload         11
     427: if_icmpeq     436
     430: iinc          10, 1
     433: goto          395
     436: iload         9
     438: nop
     439: istore        6
     441: iload_3
     442: iload         6
     444: if_icmpge     450
     447: iload         6
     449: istore_3
     450: iload         4
     452: iload         5
     454: if_icmpeq     463
     457: iinc          4, 1
     460: goto          324
     463: iload_3
     464: istore_1
     465: new           #226                // class java/lang/StringBuilder
     468: dup
     469: invokespecial #227                // Method java/lang/StringBuilder."<init>":()V
     472: ldc_w         #296                // String Best view score:
     475: invokevirtual #233                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     478: iload_1
     479: invokevirtual #236                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     482: invokevirtual #237                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     485: getstatic     #203                // Field java/lang/System.out:Ljava/io/PrintStream;
     488: swap
     489: invokevirtual #239                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     492: return
}