import kotlin.math.abs

typealias Knot = Position2D

private fun Knot.isCloseTo(other: Knot) = (this - other).run { abs(dx) <= 1 && abs(dy) <= 1 }

fun main() {

    val day = "Day09"

    data class Simulation(
        val numberOfExtraKnots: Int = 0,
        val head: Knot = Knot(0, 0),
        val knots: List<Knot> = List(numberOfExtraKnots) { _ -> head },
        val tail: Knot = head,
        val placesVisitedByTail: Set<Knot> = setOf(tail)
    ) {
        fun moveHead(direction: String): Simulation {
            val newHeadPosition = calculateNewHeadPosition(direction)
            val newKnotPositions = calculateKnotPositions(newHeadPosition)
            val newTailPosition =
                tail.calculateNewPosition(if (numberOfExtraKnots > 0) newKnotPositions.last() else newHeadPosition)

            return this.copy(
                head = newHeadPosition,
                knots = newKnotPositions,
                tail = newTailPosition,
                placesVisitedByTail = placesVisitedByTail + newTailPosition
            )
        }

        private fun calculateNewHeadPosition(direction: String) =
            head + when (direction) {
                "U" -> Movement2D(0, 1)
                "L" -> Movement2D(-1, 0)
                "D" -> Movement2D(0, -1)
                "R" -> Movement2D(1, 0)
                else -> {
                    throw IllegalArgumentException("Unknown input: $direction")
                }
            }

        private fun calculateKnotPositions(head: Knot) =
            knots.runningFold(head) { prev, tail -> tail.calculateNewPosition(prev) }.drop(1)

        private fun Knot.calculateNewPosition(head: Knot): Knot {
            val tail = this
            return if (tail.isCloseTo(head)) {
                tail
            } else {
                tail + Movement2D((head.x - tail.x).coerceIn(-1, 1), (head.y - tail.y).coerceIn(-1, 1))
            }
        }
    }

    fun List<String>.simulate(simulation: Simulation) =
        this.flatMap {
            val (direction, steps) = it.split(" ")
            List(steps.toInt()) { _ -> direction }
        }.fold(simulation) { runningSimulation, direction -> runningSimulation.moveHead(direction) }

    fun part1(input: List<String>): Int {
        return input.simulate(Simulation())
            .placesVisitedByTail.size
    }

    fun part2(input: List<String>): Int {
        return input.simulate(Simulation(numberOfExtraKnots = 8))
            .placesVisitedByTail.size
    }

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

    check(part1(testInput) == 13)
    val result1 = part1(input)
    println(result1)
    check(result1 == 6090)

    check(part2(testInput) == 1)
    check(part2(testInput2) == 36)
    val result2 = part2(input)
    println(result2)
    check(result2 == 2566)
}

Compiled from "Day09.kt"
public final class Day09Kt {
  private static final boolean isCloseTo(Position2D, Position2D);
    Code:
       0: aload_0
       1: aload_1
       2: invokevirtual #12                 // Method Position2D.minus:(LPosition2D;)LMovement2D;
       5: astore_2
       6: iconst_0
       7: istore_3
       8: aload_2
       9: invokevirtual #18                 // Method Movement2D.getDx:()I
      12: invokestatic  #24                 // Method java/lang/Math.abs:(I)I
      15: iconst_1
      16: if_icmpgt     34
      19: aload_2
      20: invokevirtual #27                 // Method Movement2D.getDy:()I
      23: invokestatic  #24                 // Method java/lang/Math.abs:(I)I
      26: iconst_1
      27: if_icmpgt     34
      30: iconst_1
      31: goto          35
      34: iconst_0
      35: nop
      36: ireturn

  public static final void main();
    Code:
       0: ldc           #38                 // String Day09
       2: astore_0
       3: new           #40                 // class java/lang/StringBuilder
       6: dup
       7: invokespecial #43                 // Method java/lang/StringBuilder."<init>":()V
      10: aload_0
      11: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      14: ldc           #49                 // String _test
      16: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      19: invokevirtual #53                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      22: invokestatic  #59                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      25: astore_1
      26: new           #40                 // class java/lang/StringBuilder
      29: dup
      30: invokespecial #43                 // Method java/lang/StringBuilder."<init>":()V
      33: aload_0
      34: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      37: ldc           #61                 // String _test2
      39: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      42: invokevirtual #53                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      45: invokestatic  #59                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      48: astore_2
      49: aload_0
      50: invokestatic  #59                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      53: astore_3
      54: aload_1
      55: invokestatic  #65                 // Method main$part1:(Ljava/util/List;)I
      58: bipush        13
      60: if_icmpne     67
      63: iconst_1
      64: goto          68
      67: iconst_0
      68: ifne          81
      71: new           #67                 // class java/lang/IllegalStateException
      74: dup
      75: ldc           #69                 // String Check failed.
      77: invokespecial #72                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      80: athrow
      81: aload_3
      82: invokestatic  #65                 // Method main$part1:(Ljava/util/List;)I
      85: istore        4
      87: getstatic     #78                 // Field java/lang/System.out:Ljava/io/PrintStream;
      90: iload         4
      92: invokevirtual #84                 // Method java/io/PrintStream.println:(I)V
      95: iload         4
      97: sipush        6090
     100: if_icmpne     107
     103: iconst_1
     104: goto          108
     107: iconst_0
     108: ifne          121
     111: new           #67                 // class java/lang/IllegalStateException
     114: dup
     115: ldc           #69                 // String Check failed.
     117: invokespecial #72                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     120: athrow
     121: aload_1
     122: invokestatic  #87                 // Method main$part2:(Ljava/util/List;)I
     125: iconst_1
     126: if_icmpne     133
     129: iconst_1
     130: goto          134
     133: iconst_0
     134: ifne          147
     137: new           #67                 // class java/lang/IllegalStateException
     140: dup
     141: ldc           #69                 // String Check failed.
     143: invokespecial #72                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     146: athrow
     147: aload_2
     148: invokestatic  #87                 // Method main$part2:(Ljava/util/List;)I
     151: bipush        36
     153: if_icmpne     160
     156: iconst_1
     157: goto          161
     160: iconst_0
     161: ifne          174
     164: new           #67                 // class java/lang/IllegalStateException
     167: dup
     168: ldc           #69                 // String Check failed.
     170: invokespecial #72                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     173: athrow
     174: aload_3
     175: invokestatic  #87                 // Method main$part2:(Ljava/util/List;)I
     178: istore        5
     180: getstatic     #78                 // Field java/lang/System.out:Ljava/io/PrintStream;
     183: iload         5
     185: invokevirtual #84                 // Method java/io/PrintStream.println:(I)V
     188: iload         5
     190: sipush        2566
     193: if_icmpne     200
     196: iconst_1
     197: goto          201
     200: iconst_0
     201: ifne          214
     204: new           #67                 // class java/lang/IllegalStateException
     207: dup
     208: ldc           #69                 // String Check failed.
     210: invokespecial #72                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     213: athrow
     214: return

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

  private static final Day09Kt$main$Simulation main$simulate(java.util.List<java.lang.String>, Day09Kt$main$Simulation);
    Code:
       0: aload_0
       1: checkcast     #109                // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: astore        4
      10: new           #111                // class java/util/ArrayList
      13: dup
      14: invokespecial #112                // Method java/util/ArrayList."<init>":()V
      17: checkcast     #114                // class java/util/Collection
      20: astore        5
      22: iconst_0
      23: istore        6
      25: aload         4
      27: invokeinterface #118,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      32: astore        7
      34: aload         7
      36: invokeinterface #124,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      41: ifeq          190
      44: aload         7
      46: invokeinterface #128,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      51: astore        8
      53: aload         8
      55: checkcast     #97                 // class java/lang/String
      58: astore        9
      60: iconst_0
      61: istore        10
      63: aload         9
      65: checkcast     #130                // class java/lang/CharSequence
      68: iconst_1
      69: anewarray     #97                 // class java/lang/String
      72: astore        11
      74: aload         11
      76: iconst_0
      77: ldc           #132                // String
      79: aastore
      80: aload         11
      82: iconst_0
      83: iconst_0
      84: bipush        6
      86: aconst_null
      87: invokestatic  #138                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      90: astore        12
      92: aload         12
      94: iconst_0
      95: invokeinterface #142,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     100: checkcast     #97                 // class java/lang/String
     103: astore        11
     105: aload         12
     107: iconst_1
     108: invokeinterface #142,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     113: checkcast     #97                 // class java/lang/String
     116: astore        13
     118: aload         13
     120: invokestatic  #148                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     123: istore        14
     125: new           #111                // class java/util/ArrayList
     128: dup
     129: iload         14
     131: invokespecial #150                // Method java/util/ArrayList."<init>":(I)V
     134: astore        15
     136: iconst_0
     137: istore        16
     139: iload         16
     141: iload         14
     143: if_icmpge     168
     146: aload         15
     148: astore        17
     150: iconst_0
     151: istore        18
     153: aload         11
     155: aload         17
     157: swap
     158: invokevirtual #154                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     161: pop
     162: iinc          16, 1
     165: goto          139
     168: aload         15
     170: checkcast     #99                 // class java/util/List
     173: checkcast     #109                // class java/lang/Iterable
     176: nop
     177: astore        9
     179: aload         5
     181: aload         9
     183: invokestatic  #160                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     186: pop
     187: goto          34
     190: aload         5
     192: checkcast     #99                 // class java/util/List
     195: nop
     196: checkcast     #109                // class java/lang/Iterable
     199: astore_2
     200: nop
     201: iconst_0
     202: istore_3
     203: aload_1
     204: astore        4
     206: aload_2
     207: invokeinterface #118,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     212: astore        5
     214: aload         5
     216: invokeinterface #124,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     221: ifeq          259
     224: aload         5
     226: invokeinterface #128,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     231: astore        6
     233: aload         4
     235: aload         6
     237: checkcast     #97                 // class java/lang/String
     240: astore        7
     242: astore        8
     244: iconst_0
     245: istore        9
     247: aload         8
     249: aload         7
     251: invokevirtual #166                // Method Day09Kt$main$Simulation.moveHead:(Ljava/lang/String;)LDay09Kt$main$Simulation;
     254: astore        4
     256: goto          214
     259: aload         4
     261: areturn

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: new           #162                // class Day09Kt$main$Simulation
       4: dup
       5: iconst_0
       6: aconst_null
       7: aconst_null
       8: aconst_null
       9: aconst_null
      10: bipush        31
      12: aconst_null
      13: invokespecial #194                // Method Day09Kt$main$Simulation."<init>":(ILPosition2D;Ljava/util/List;LPosition2D;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
      16: invokestatic  #196                // Method main$simulate:(Ljava/util/List;LDay09Kt$main$Simulation;)LDay09Kt$main$Simulation;
      19: invokevirtual #200                // Method Day09Kt$main$Simulation.getPlacesVisitedByTail:()Ljava/util/Set;
      22: invokeinterface #205,  1          // InterfaceMethod java/util/Set.size:()I
      27: ireturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: new           #162                // class Day09Kt$main$Simulation
       4: dup
       5: bipush        8
       7: aconst_null
       8: aconst_null
       9: aconst_null
      10: aconst_null
      11: bipush        30
      13: aconst_null
      14: invokespecial #194                // Method Day09Kt$main$Simulation."<init>":(ILPosition2D;Ljava/util/List;LPosition2D;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
      17: invokestatic  #196                // Method main$simulate:(Ljava/util/List;LDay09Kt$main$Simulation;)LDay09Kt$main$Simulation;
      20: invokevirtual #200                // Method Day09Kt$main$Simulation.getPlacesVisitedByTail:()Ljava/util/Set;
      23: invokeinterface #205,  1          // InterfaceMethod java/util/Set.size:()I
      28: ireturn

  public static final boolean access$isCloseTo(Position2D, Position2D);
    Code:
       0: aload_0
       1: aload_1
       2: invokestatic  #208                // Method isCloseTo:(LPosition2D;LPosition2D;)Z
       5: ireturn
}

Compiled from "Day09.kt"
public final class Day09Kt$main$Simulation {
  private final int numberOfExtraKnots;

  private final Position2D head;

  private final java.util.List<Position2D> knots;

  private final Position2D tail;

  private final java.util.Set<Position2D> placesVisitedByTail;

  public Day09Kt$main$Simulation(int, Position2D, java.util.List<Position2D>, Position2D, java.util.Set<Position2D>);
    Code:
       0: aload_2
       1: ldc           #9                  // String head
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_3
       7: ldc           #17                 // String knots
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload         4
      14: ldc           #19                 // String tail
      16: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      19: aload         5
      21: ldc           #21                 // String placesVisitedByTail
      23: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      26: aload_0
      27: invokespecial #24                 // Method java/lang/Object."<init>":()V
      30: aload_0
      31: iload_1
      32: putfield      #28                 // Field numberOfExtraKnots:I
      35: aload_0
      36: aload_2
      37: putfield      #31                 // Field head:LPosition2D;
      40: aload_0
      41: aload_3
      42: putfield      #34                 // Field knots:Ljava/util/List;
      45: aload_0
      46: aload         4
      48: putfield      #36                 // Field tail:LPosition2D;
      51: aload_0
      52: aload         5
      54: putfield      #39                 // Field placesVisitedByTail:Ljava/util/Set;
      57: return

  public Day09Kt$main$Simulation(int, Position2D, java.util.List, Position2D, java.util.Set, int, kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: iload         6
       2: iconst_1
       3: iand
       4: ifeq          9
       7: iconst_0
       8: istore_1
       9: iload         6
      11: iconst_2
      12: iand
      13: ifeq          26
      16: new           #44                 // class Position2D
      19: dup
      20: iconst_0
      21: iconst_0
      22: invokespecial #47                 // Method Position2D."<init>":(II)V
      25: astore_2
      26: iload         6
      28: iconst_4
      29: iand
      30: ifeq          83
      33: new           #49                 // class java/util/ArrayList
      36: dup
      37: iload_1
      38: invokespecial #52                 // Method java/util/ArrayList."<init>":(I)V
      41: astore        8
      43: iconst_0
      44: istore        9
      46: iload         9
      48: iload_1
      49: if_icmpge     77
      52: iload         9
      54: istore        10
      56: aload         8
      58: astore        12
      60: iconst_0
      61: istore        11
      63: aload_2
      64: aload         12
      66: swap
      67: invokevirtual #56                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      70: pop
      71: iinc          9, 1
      74: goto          46
      77: aload         8
      79: checkcast     #58                 // class java/util/List
      82: astore_3
      83: iload         6
      85: bipush        8
      87: iand
      88: ifeq          94
      91: aload_2
      92: astore        4
      94: iload         6
      96: bipush        16
      98: iand
      99: ifeq          109
     102: aload         4
     104: invokestatic  #64                 // Method kotlin/collections/SetsKt.setOf:(Ljava/lang/Object;)Ljava/util/Set;
     107: astore        5
     109: aload_0
     110: iload_1
     111: aload_2
     112: aload_3
     113: aload         4
     115: aload         5
     117: invokespecial #66                 // Method "<init>":(ILPosition2D;Ljava/util/List;LPosition2D;Ljava/util/Set;)V
     120: return

  public final int getNumberOfExtraKnots();
    Code:
       0: aload_0
       1: getfield      #28                 // Field numberOfExtraKnots:I
       4: ireturn

  public final Position2D getHead();
    Code:
       0: aload_0
       1: getfield      #31                 // Field head:LPosition2D;
       4: areturn

  public final java.util.List<Position2D> getKnots();
    Code:
       0: aload_0
       1: getfield      #34                 // Field knots:Ljava/util/List;
       4: areturn

  public final Position2D getTail();
    Code:
       0: aload_0
       1: getfield      #36                 // Field tail:LPosition2D;
       4: areturn

  public final java.util.Set<Position2D> getPlacesVisitedByTail();
    Code:
       0: aload_0
       1: getfield      #39                 // Field placesVisitedByTail:Ljava/util/Set;
       4: areturn

  public final Day09Kt$main$Simulation moveHead(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #82                 // String direction
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: invokespecial #86                 // Method calculateNewHeadPosition:(Ljava/lang/String;)LPosition2D;
      11: astore_2
      12: aload_0
      13: aload_2
      14: invokespecial #90                 // Method calculateKnotPositions:(LPosition2D;)Ljava/util/List;
      17: astore_3
      18: aload_0
      19: aload_0
      20: getfield      #36                 // Field tail:LPosition2D;
      23: aload_0
      24: getfield      #28                 // Field numberOfExtraKnots:I
      27: ifle          40
      30: aload_3
      31: invokestatic  #96                 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
      34: checkcast     #44                 // class Position2D
      37: goto          41
      40: aload_2
      41: invokespecial #100                // Method calculateNewPosition:(LPosition2D;LPosition2D;)LPosition2D;
      44: astore        4
      46: aload_0
      47: iconst_0
      48: aload_2
      49: aload_3
      50: aload         4
      52: aload_0
      53: getfield      #39                 // Field placesVisitedByTail:Ljava/util/Set;
      56: aload         4
      58: invokestatic  #104                // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Object;)Ljava/util/Set;
      61: iconst_1
      62: aconst_null
      63: invokestatic  #108                // Method copy$default:(LDay09Kt$main$Simulation;ILPosition2D;Ljava/util/List;LPosition2D;Ljava/util/Set;ILjava/lang/Object;)LDay09Kt$main$Simulation;
      66: areturn

  private final Position2D calculateNewHeadPosition(java.lang.String);
    Code:
       0: aload_0
       1: getfield      #31                 // Field head:LPosition2D;
       4: aload_1
       5: astore_2
       6: aload_2
       7: invokevirtual #117                // Method java/lang/String.hashCode:()I
      10: lookupswitch  { // 4
                    68: 64
                    76: 88
                    82: 52
                    85: 76
               default: 148
          }
      52: aload_2
      53: ldc           #119                // String R
      55: invokevirtual #122                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      58: ifne          136
      61: goto          148
      64: aload_2
      65: ldc           #124                // String D
      67: invokevirtual #122                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      70: ifne          124
      73: goto          148
      76: aload_2
      77: ldc           #126                // String U
      79: invokevirtual #122                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      82: ifne          100
      85: goto          148
      88: aload_2
      89: ldc           #128                // String L
      91: invokevirtual #122                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      94: ifne          112
      97: goto          148
     100: new           #130                // class Movement2D
     103: dup
     104: iconst_0
     105: iconst_1
     106: invokespecial #131                // Method Movement2D."<init>":(II)V
     109: goto          175
     112: new           #130                // class Movement2D
     115: dup
     116: iconst_m1
     117: iconst_0
     118: invokespecial #131                // Method Movement2D."<init>":(II)V
     121: goto          175
     124: new           #130                // class Movement2D
     127: dup
     128: iconst_0
     129: iconst_m1
     130: invokespecial #131                // Method Movement2D."<init>":(II)V
     133: goto          175
     136: new           #130                // class Movement2D
     139: dup
     140: iconst_1
     141: iconst_0
     142: invokespecial #131                // Method Movement2D."<init>":(II)V
     145: goto          175
     148: new           #133                // class java/lang/IllegalArgumentException
     151: dup
     152: new           #135                // class java/lang/StringBuilder
     155: dup
     156: invokespecial #136                // Method java/lang/StringBuilder."<init>":()V
     159: ldc           #138                // String Unknown input:
     161: invokevirtual #142                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     164: aload_1
     165: invokevirtual #142                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     168: invokevirtual #146                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     171: invokespecial #149                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     174: athrow
     175: invokevirtual #152                // Method Position2D.plus:(LMovement2D;)LPosition2D;
     178: areturn

  private final java.util.List<Position2D> calculateKnotPositions(Position2D);
    Code:
       0: aload_0
       1: getfield      #34                 // Field knots:Ljava/util/List;
       4: checkcast     #155                // class java/lang/Iterable
       7: astore_2
       8: iconst_0
       9: istore_3
      10: aload_2
      11: bipush        9
      13: invokestatic  #159                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      16: istore        4
      18: iload         4
      20: ifne          30
      23: aload_1
      24: invokestatic  #163                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      27: goto          131
      30: new           #49                 // class java/util/ArrayList
      33: dup
      34: iload         4
      36: iconst_1
      37: iadd
      38: invokespecial #52                 // Method java/util/ArrayList."<init>":(I)V
      41: astore        5
      43: aload         5
      45: astore        6
      47: iconst_0
      48: istore        7
      50: aload         6
      52: aload_1
      53: invokevirtual #56                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      56: pop
      57: aload         5
      59: astore        8
      61: aload_1
      62: astore        5
      64: aload_2
      65: invokeinterface #167,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      70: astore        6
      72: aload         6
      74: invokeinterface #173,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      79: ifeq          126
      82: aload         6
      84: invokeinterface #177,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      89: astore        7
      91: aload         5
      93: aload         7
      95: checkcast     #44                 // class Position2D
      98: astore        9
     100: astore        10
     102: iconst_0
     103: istore        11
     105: aload_0
     106: aload         9
     108: aload         10
     110: invokespecial #100                // Method calculateNewPosition:(LPosition2D;LPosition2D;)LPosition2D;
     113: astore        5
     115: aload         8
     117: aload         5
     119: invokevirtual #56                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     122: pop
     123: goto          72
     126: aload         8
     128: checkcast     #58                 // class java/util/List
     131: checkcast     #155                // class java/lang/Iterable
     134: iconst_1
     135: invokestatic  #181                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     138: areturn

  private final Position2D calculateNewPosition(Position2D, Position2D);
    Code:
       0: aload_1
       1: astore_3
       2: aload_3
       3: aload_2
       4: invokestatic  #200                // Method Day09Kt.access$isCloseTo:(LPosition2D;LPosition2D;)Z
       7: ifeq          14
      10: aload_3
      11: goto          53
      14: aload_3
      15: new           #130                // class Movement2D
      18: dup
      19: aload_2
      20: invokevirtual #203                // Method Position2D.getX:()I
      23: aload_3
      24: invokevirtual #203                // Method Position2D.getX:()I
      27: isub
      28: iconst_m1
      29: iconst_1
      30: invokestatic  #209                // Method kotlin/ranges/RangesKt.coerceIn:(III)I
      33: aload_2
      34: invokevirtual #212                // Method Position2D.getY:()I
      37: aload_3
      38: invokevirtual #212                // Method Position2D.getY:()I
      41: isub
      42: iconst_m1
      43: iconst_1
      44: invokestatic  #209                // Method kotlin/ranges/RangesKt.coerceIn:(III)I
      47: invokespecial #131                // Method Movement2D."<init>":(II)V
      50: invokevirtual #152                // Method Position2D.plus:(LMovement2D;)LPosition2D;
      53: areturn

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

  public final Position2D component2();
    Code:
       0: aload_0
       1: getfield      #31                 // Field head:LPosition2D;
       4: areturn

  public final java.util.List<Position2D> component3();
    Code:
       0: aload_0
       1: getfield      #34                 // Field knots:Ljava/util/List;
       4: areturn

  public final Position2D component4();
    Code:
       0: aload_0
       1: getfield      #36                 // Field tail:LPosition2D;
       4: areturn

  public final java.util.Set<Position2D> component5();
    Code:
       0: aload_0
       1: getfield      #39                 // Field placesVisitedByTail:Ljava/util/Set;
       4: areturn

  public final Day09Kt$main$Simulation copy(int, Position2D, java.util.List<Position2D>, Position2D, java.util.Set<Position2D>);
    Code:
       0: aload_2
       1: ldc           #9                  // String head
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_3
       7: ldc           #17                 // String knots
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload         4
      14: ldc           #19                 // String tail
      16: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      19: aload         5
      21: ldc           #21                 // String placesVisitedByTail
      23: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      26: new           #2                  // class Day09Kt$main$Simulation
      29: dup
      30: iload_1
      31: aload_2
      32: aload_3
      33: aload         4
      35: aload         5
      37: invokespecial #66                 // Method "<init>":(ILPosition2D;Ljava/util/List;LPosition2D;Ljava/util/Set;)V
      40: areturn

  public static Day09Kt$main$Simulation copy$default(Day09Kt$main$Simulation, int, Position2D, java.util.List, Position2D, java.util.Set, int, java.lang.Object);
    Code:
       0: iload         6
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #28                 // Field numberOfExtraKnots:I
      11: istore_1
      12: iload         6
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #31                 // Field head:LPosition2D;
      23: astore_2
      24: iload         6
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #34                 // Field knots:Ljava/util/List;
      35: astore_3
      36: iload         6
      38: bipush        8
      40: iand
      41: ifeq          50
      44: aload_0
      45: getfield      #36                 // Field tail:LPosition2D;
      48: astore        4
      50: iload         6
      52: bipush        16
      54: iand
      55: ifeq          64
      58: aload_0
      59: getfield      #39                 // Field placesVisitedByTail:Ljava/util/Set;
      62: astore        5
      64: aload_0
      65: iload_1
      66: aload_2
      67: aload_3
      68: aload         4
      70: aload         5
      72: invokevirtual #223                // Method copy:(ILPosition2D;Ljava/util/List;LPosition2D;Ljava/util/Set;)LDay09Kt$main$Simulation;
      75: areturn

  public java.lang.String toString();
    Code:
       0: new           #135                // class java/lang/StringBuilder
       3: dup
       4: invokespecial #136                // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #225                // String Simulation(numberOfExtraKnots=
       9: invokevirtual #142                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #28                 // Field numberOfExtraKnots:I
      16: invokevirtual #228                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #230                // String , head=
      21: invokevirtual #142                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #31                 // Field head:LPosition2D;
      28: invokevirtual #233                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      31: ldc           #235                // String , knots=
      33: invokevirtual #142                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: aload_0
      37: getfield      #34                 // Field knots:Ljava/util/List;
      40: invokevirtual #233                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      43: ldc           #237                // String , tail=
      45: invokevirtual #142                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      48: aload_0
      49: getfield      #36                 // Field tail:LPosition2D;
      52: invokevirtual #233                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      55: ldc           #239                // String , placesVisitedByTail=
      57: invokevirtual #142                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      60: aload_0
      61: getfield      #39                 // Field placesVisitedByTail:Ljava/util/Set;
      64: invokevirtual #233                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      67: bipush        41
      69: invokevirtual #242                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      72: invokevirtual #146                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      75: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #28                 // Field numberOfExtraKnots:I
       4: invokestatic  #247                // Method java/lang/Integer.hashCode:(I)I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #31                 // Field head:LPosition2D;
      16: invokevirtual #248                // Method Position2D.hashCode:()I
      19: iadd
      20: istore_1
      21: iload_1
      22: bipush        31
      24: imul
      25: aload_0
      26: getfield      #34                 // Field knots:Ljava/util/List;
      29: invokevirtual #249                // Method java/lang/Object.hashCode:()I
      32: iadd
      33: istore_1
      34: iload_1
      35: bipush        31
      37: imul
      38: aload_0
      39: getfield      #36                 // Field tail:LPosition2D;
      42: invokevirtual #248                // Method Position2D.hashCode:()I
      45: iadd
      46: istore_1
      47: iload_1
      48: bipush        31
      50: imul
      51: aload_0
      52: getfield      #39                 // Field placesVisitedByTail:Ljava/util/Set;
      55: invokevirtual #249                // Method java/lang/Object.hashCode:()I
      58: iadd
      59: istore_1
      60: iload_1
      61: 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 Day09Kt$main$Simulation
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class Day09Kt$main$Simulation
      20: astore_2
      21: aload_0
      22: getfield      #28                 // Field numberOfExtraKnots:I
      25: aload_2
      26: getfield      #28                 // Field numberOfExtraKnots:I
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #31                 // Field head:LPosition2D;
      38: aload_2
      39: getfield      #31                 // Field head:LPosition2D;
      42: invokestatic  #254                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      45: ifne          50
      48: iconst_0
      49: ireturn
      50: aload_0
      51: getfield      #34                 // Field knots:Ljava/util/List;
      54: aload_2
      55: getfield      #34                 // Field knots:Ljava/util/List;
      58: invokestatic  #254                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      61: ifne          66
      64: iconst_0
      65: ireturn
      66: aload_0
      67: getfield      #36                 // Field tail:LPosition2D;
      70: aload_2
      71: getfield      #36                 // Field tail:LPosition2D;
      74: invokestatic  #254                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      77: ifne          82
      80: iconst_0
      81: ireturn
      82: aload_0
      83: getfield      #39                 // Field placesVisitedByTail:Ljava/util/Set;
      86: aload_2
      87: getfield      #39                 // Field placesVisitedByTail:Ljava/util/Set;
      90: invokestatic  #254                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      93: ifne          98
      96: iconst_0
      97: ireturn
      98: iconst_1
      99: ireturn
}


typealias Trees = Grid2D<Char>
typealias TreePosition = Position2D
typealias Direction = (TreePosition, Trees) -> List<TreePosition>

fun main() {

    val day = "Day08"

    val up: Direction =
        { tp: TreePosition, _: Trees -> (0 until tp.y).map { TreePosition(tp.x, it) }.reversed() }
    val down: Direction =
        { tp: TreePosition, trees: Trees -> (tp.y + 1 until trees.height).map { TreePosition(tp.x, it) } }
    val left: Direction =
        { tp: TreePosition, _: Trees -> (0 until tp.x).map { TreePosition(it, tp.y) }.reversed() }
    val right: Direction =
        { tp: TreePosition, trees: Trees -> (tp.x + 1 until trees.width).map { TreePosition(it, tp.y) } }

    val directions = listOf(up, down, left, right)

    fun part1(input: List<String>): Int {
        val trees = Trees.from(input)

        fun TreePosition.canBeSeenFrom(direction: Direction) =
            direction(this, trees).none { (trees[this]) <= trees[it] }

        fun TreePosition.isVisibleFromAnyDirection() =
            directions.any { this.canBeSeenFrom(it) }

        fun TreePosition.isOnOuterEdge() = isOnOuterEdgeIn(trees)

        fun Trees.numberOfTreesOnOuterEdge() = allPositions.filter { it.isOnOuterEdge() }.size

        return (trees.allPositions
            .filter { !it.isOnOuterEdge() }
            .count { it.isVisibleFromAnyDirection() } + trees.numberOfTreesOnOuterEdge())
    }

    fun part2(input: List<String>): Int {
        val trees = Trees.from(input)

        fun List<TreePosition>.thatCanBeSeenFrom(treePosition: TreePosition): Int {

            fun addViewOfTreeThatCantBeSeenPassed(numberOfLowerTreesCounted: Int) =
                if (isNotEmpty() && numberOfLowerTreesCounted < size) 1 else 0

            return takeWhile { (trees[treePosition] > trees[it]) }
                .count().let { it + addViewOfTreeThatCantBeSeenPassed(it) }
        }

        fun TreePosition.numberOfTreesInViewPerDirection() =
            directions.map { direction ->
                val treesInDirection = direction(this, trees)
                treesInDirection.thatCanBeSeenFrom(this)
            }

        fun TreePosition.scenicValue() =
            numberOfTreesInViewPerDirection()
                .reduce(Int::times)

        return trees.allPositions
            .maxOf { it.scenicValue() }
    }

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

    check(part1(testInput) == 21)
    val result1 = part1(input)
    println(result1)
    check(result1 == 1717)

    check(part2(testInput) == 8)
    val result2 = part2(input)
    println(result2)
    check(result2 == 321975)
}

Compiled from "Day08.kt"
public final class Day08Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day08
       2: astore_0
       3: invokedynamic #27,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;
       8: astore_1
       9: invokedynamic #32,  0             // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function2;
      14: astore_2
      15: invokedynamic #37,  0             // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function2;
      20: astore_3
      21: invokedynamic #42,  0             // InvokeDynamic #3:invoke:()Lkotlin/jvm/functions/Function2;
      26: astore        4
      28: iconst_4
      29: anewarray     #44                 // class kotlin/jvm/functions/Function2
      32: astore        6
      34: aload         6
      36: iconst_0
      37: aload_1
      38: aastore
      39: aload         6
      41: iconst_1
      42: aload_2
      43: aastore
      44: aload         6
      46: iconst_2
      47: aload_3
      48: aastore
      49: aload         6
      51: iconst_3
      52: aload         4
      54: aastore
      55: aload         6
      57: invokestatic  #50                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      60: astore        5
      62: new           #52                 // class java/lang/StringBuilder
      65: dup
      66: invokespecial #55                 // Method java/lang/StringBuilder."<init>":()V
      69: aload_0
      70: invokevirtual #59                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      73: ldc           #61                 // String _test
      75: invokevirtual #59                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      78: invokevirtual #65                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      81: invokestatic  #71                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      84: astore        6
      86: aload_0
      87: invokestatic  #71                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      90: astore        7
      92: aload         5
      94: aload         6
      96: invokestatic  #75                 // Method main$part1:(Ljava/util/List;Ljava/util/List;)I
      99: bipush        21
     101: if_icmpne     108
     104: iconst_1
     105: goto          109
     108: iconst_0
     109: ifne          122
     112: new           #77                 // class java/lang/IllegalStateException
     115: dup
     116: ldc           #79                 // String Check failed.
     118: invokespecial #82                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     121: athrow
     122: aload         5
     124: aload         7
     126: invokestatic  #75                 // Method main$part1:(Ljava/util/List;Ljava/util/List;)I
     129: istore        8
     131: getstatic     #88                 // Field java/lang/System.out:Ljava/io/PrintStream;
     134: iload         8
     136: invokevirtual #94                 // Method java/io/PrintStream.println:(I)V
     139: iload         8
     141: sipush        1717
     144: if_icmpne     151
     147: iconst_1
     148: goto          152
     151: iconst_0
     152: ifne          165
     155: new           #77                 // class java/lang/IllegalStateException
     158: dup
     159: ldc           #79                 // String Check failed.
     161: invokespecial #82                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     164: athrow
     165: aload         5
     167: aload         6
     169: invokestatic  #97                 // Method main$part2:(Ljava/util/List;Ljava/util/List;)I
     172: bipush        8
     174: if_icmpne     181
     177: iconst_1
     178: goto          182
     181: iconst_0
     182: ifne          195
     185: new           #77                 // class java/lang/IllegalStateException
     188: dup
     189: ldc           #79                 // String Check failed.
     191: invokespecial #82                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     194: athrow
     195: aload         5
     197: aload         7
     199: invokestatic  #97                 // Method main$part2:(Ljava/util/List;Ljava/util/List;)I
     202: istore        9
     204: getstatic     #88                 // Field java/lang/System.out:Ljava/io/PrintStream;
     207: iload         9
     209: invokevirtual #94                 // Method java/io/PrintStream.println:(I)V
     212: iload         9
     214: ldc           #98                 // int 321975
     216: if_icmpne     223
     219: iconst_1
     220: goto          224
     223: iconst_0
     224: ifne          237
     227: new           #77                 // class java/lang/IllegalStateException
     230: dup
     231: ldc           #79                 // String Check failed.
     233: invokespecial #82                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     236: athrow
     237: return

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

  private static final java.util.List main$lambda$1(Position2D, Grid2D);
    Code:
       0: aload_0
       1: ldc           #123                // String tp
       3: invokestatic  #129                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #131                // String <unused var>
       9: invokestatic  #129                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iconst_0
      13: aload_0
      14: invokevirtual #137                // Method Position2D.getY:()I
      17: invokestatic  #143                // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      20: checkcast     #145                // class java/lang/Iterable
      23: astore_2
      24: iconst_0
      25: istore_3
      26: aload_2
      27: astore        4
      29: new           #147                // class java/util/ArrayList
      32: dup
      33: aload_2
      34: bipush        10
      36: invokestatic  #151                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      39: invokespecial #153                // Method java/util/ArrayList."<init>":(I)V
      42: checkcast     #155                // class java/util/Collection
      45: astore        5
      47: iconst_0
      48: istore        6
      50: aload         4
      52: invokeinterface #159,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      57: astore        7
      59: aload         7
      61: invokeinterface #165,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      66: ifeq          115
      69: aload         7
      71: checkcast     #167                // class kotlin/collections/IntIterator
      74: invokevirtual #170                // Method kotlin/collections/IntIterator.nextInt:()I
      77: istore        8
      79: aload         5
      81: iload         8
      83: istore        9
      85: astore        11
      87: iconst_0
      88: istore        10
      90: new           #133                // class Position2D
      93: dup
      94: aload_0
      95: invokevirtual #173                // Method Position2D.getX:()I
      98: iload         9
     100: invokespecial #176                // Method Position2D."<init>":(II)V
     103: aload         11
     105: swap
     106: invokeinterface #180,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     111: pop
     112: goto          59
     115: aload         5
     117: checkcast     #116                // class java/util/List
     120: nop
     121: checkcast     #145                // class java/lang/Iterable
     124: invokestatic  #184                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
     127: areturn

  private static final java.util.List main$lambda$3(Position2D, Grid2D);
    Code:
       0: aload_0
       1: ldc           #123                // String tp
       3: invokestatic  #129                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #199                // String trees
       9: invokestatic  #129                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: invokevirtual #137                // Method Position2D.getY:()I
      16: iconst_1
      17: iadd
      18: aload_1
      19: invokeinterface #202,  1          // InterfaceMethod Grid2D.getHeight:()I
      24: invokestatic  #143                // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      27: checkcast     #145                // class java/lang/Iterable
      30: astore_2
      31: iconst_0
      32: istore_3
      33: aload_2
      34: astore        4
      36: new           #147                // class java/util/ArrayList
      39: dup
      40: aload_2
      41: bipush        10
      43: invokestatic  #151                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      46: invokespecial #153                // Method java/util/ArrayList."<init>":(I)V
      49: checkcast     #155                // class java/util/Collection
      52: astore        5
      54: iconst_0
      55: istore        6
      57: aload         4
      59: invokeinterface #159,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      64: astore        7
      66: aload         7
      68: invokeinterface #165,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      73: ifeq          122
      76: aload         7
      78: checkcast     #167                // class kotlin/collections/IntIterator
      81: invokevirtual #170                // Method kotlin/collections/IntIterator.nextInt:()I
      84: istore        8
      86: aload         5
      88: iload         8
      90: istore        9
      92: astore        11
      94: iconst_0
      95: istore        10
      97: new           #133                // class Position2D
     100: dup
     101: aload_0
     102: invokevirtual #173                // Method Position2D.getX:()I
     105: iload         9
     107: invokespecial #176                // Method Position2D."<init>":(II)V
     110: aload         11
     112: swap
     113: invokeinterface #180,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     118: pop
     119: goto          66
     122: aload         5
     124: checkcast     #116                // class java/util/List
     127: nop
     128: areturn

  private static final java.util.List main$lambda$5(Position2D, Grid2D);
    Code:
       0: aload_0
       1: ldc           #123                // String tp
       3: invokestatic  #129                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #131                // String <unused var>
       9: invokestatic  #129                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iconst_0
      13: aload_0
      14: invokevirtual #173                // Method Position2D.getX:()I
      17: invokestatic  #143                // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      20: checkcast     #145                // class java/lang/Iterable
      23: astore_2
      24: iconst_0
      25: istore_3
      26: aload_2
      27: astore        4
      29: new           #147                // class java/util/ArrayList
      32: dup
      33: aload_2
      34: bipush        10
      36: invokestatic  #151                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      39: invokespecial #153                // Method java/util/ArrayList."<init>":(I)V
      42: checkcast     #155                // class java/util/Collection
      45: astore        5
      47: iconst_0
      48: istore        6
      50: aload         4
      52: invokeinterface #159,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      57: astore        7
      59: aload         7
      61: invokeinterface #165,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      66: ifeq          115
      69: aload         7
      71: checkcast     #167                // class kotlin/collections/IntIterator
      74: invokevirtual #170                // Method kotlin/collections/IntIterator.nextInt:()I
      77: istore        8
      79: aload         5
      81: iload         8
      83: istore        9
      85: astore        11
      87: iconst_0
      88: istore        10
      90: new           #133                // class Position2D
      93: dup
      94: iload         9
      96: aload_0
      97: invokevirtual #137                // Method Position2D.getY:()I
     100: invokespecial #176                // Method Position2D."<init>":(II)V
     103: aload         11
     105: swap
     106: invokeinterface #180,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     111: pop
     112: goto          59
     115: aload         5
     117: checkcast     #116                // class java/util/List
     120: nop
     121: checkcast     #145                // class java/lang/Iterable
     124: invokestatic  #184                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
     127: areturn

  private static final java.util.List main$lambda$7(Position2D, Grid2D);
    Code:
       0: aload_0
       1: ldc           #123                // String tp
       3: invokestatic  #129                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #199                // String trees
       9: invokestatic  #129                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: invokevirtual #173                // Method Position2D.getX:()I
      16: iconst_1
      17: iadd
      18: aload_1
      19: invokeinterface #208,  1          // InterfaceMethod Grid2D.getWidth:()I
      24: invokestatic  #143                // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      27: checkcast     #145                // class java/lang/Iterable
      30: astore_2
      31: iconst_0
      32: istore_3
      33: aload_2
      34: astore        4
      36: new           #147                // class java/util/ArrayList
      39: dup
      40: aload_2
      41: bipush        10
      43: invokestatic  #151                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      46: invokespecial #153                // Method java/util/ArrayList."<init>":(I)V
      49: checkcast     #155                // class java/util/Collection
      52: astore        5
      54: iconst_0
      55: istore        6
      57: aload         4
      59: invokeinterface #159,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      64: astore        7
      66: aload         7
      68: invokeinterface #165,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      73: ifeq          122
      76: aload         7
      78: checkcast     #167                // class kotlin/collections/IntIterator
      81: invokevirtual #170                // Method kotlin/collections/IntIterator.nextInt:()I
      84: istore        8
      86: aload         5
      88: iload         8
      90: istore        9
      92: astore        11
      94: iconst_0
      95: istore        10
      97: new           #133                // class Position2D
     100: dup
     101: iload         9
     103: aload_0
     104: invokevirtual #137                // Method Position2D.getY:()I
     107: invokespecial #176                // Method Position2D."<init>":(II)V
     110: aload         11
     112: swap
     113: invokeinterface #180,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     118: pop
     119: goto          66
     122: aload         5
     124: checkcast     #116                // class java/util/List
     127: nop
     128: areturn

  private static final boolean main$part1$canBeSeenFrom(Position2D, Grid2D<java.lang.Character>, kotlin.jvm.functions.Function2<? super Position2D, ? super Grid2D<java.lang.Character>, ? extends java.util.List<Position2D>>);
    Code:
       0: aload_2
       1: aload_0
       2: aload_1
       3: invokeinterface #214,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
       8: checkcast     #145                // class java/lang/Iterable
      11: astore_3
      12: iconst_0
      13: istore        4
      15: aload_3
      16: instanceof    #155                // class java/util/Collection
      19: ifeq          38
      22: aload_3
      23: checkcast     #155                // class java/util/Collection
      26: invokeinterface #217,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      31: ifeq          38
      34: iconst_1
      35: goto          121
      38: aload_3
      39: invokeinterface #159,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      44: astore        5
      46: aload         5
      48: invokeinterface #165,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      53: ifeq          120
      56: aload         5
      58: invokeinterface #221,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: astore        6
      65: aload         6
      67: checkcast     #133                // class Position2D
      70: astore        7
      72: iconst_0
      73: istore        8
      75: aload_1
      76: aload_0
      77: invokeinterface #225,  2          // InterfaceMethod Grid2D.get:(LPosition2D;)Ljava/lang/Object;
      82: checkcast     #227                // class java/lang/Character
      85: invokevirtual #231                // Method java/lang/Character.charValue:()C
      88: aload_1
      89: aload         7
      91: invokeinterface #225,  2          // InterfaceMethod Grid2D.get:(LPosition2D;)Ljava/lang/Object;
      96: checkcast     #227                // class java/lang/Character
      99: invokevirtual #231                // Method java/lang/Character.charValue:()C
     102: invokestatic  #235                // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
     105: ifgt          112
     108: iconst_1
     109: goto          113
     112: iconst_0
     113: ifeq          46
     116: iconst_0
     117: goto          121
     120: iconst_1
     121: ireturn

  private static final boolean main$part1$isVisibleFromAnyDirection(Position2D, java.util.List<? extends kotlin.jvm.functions.Function2<? super Position2D, ? super Grid2D<java.lang.Character>, ? extends java.util.List<Position2D>>>, Grid2D<java.lang.Character>);
    Code:
       0: aload_1
       1: checkcast     #145                // class java/lang/Iterable
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: instanceof    #155                // class java/util/Collection
      12: ifeq          31
      15: aload_3
      16: checkcast     #155                // class java/util/Collection
      19: invokeinterface #217,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      24: ifeq          31
      27: iconst_0
      28: goto          83
      31: aload_3
      32: invokeinterface #159,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        5
      39: aload         5
      41: invokeinterface #165,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          82
      49: aload         5
      51: invokeinterface #221,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        6
      58: aload         6
      60: checkcast     #44                 // class kotlin/jvm/functions/Function2
      63: astore        7
      65: iconst_0
      66: istore        8
      68: aload_0
      69: aload_2
      70: aload         7
      72: invokestatic  #247                // Method main$part1$canBeSeenFrom:(LPosition2D;LGrid2D;Lkotlin/jvm/functions/Function2;)Z
      75: ifeq          39
      78: iconst_1
      79: goto          83
      82: iconst_0
      83: ireturn

  private static final boolean main$part1$isOnOuterEdge(Position2D, Grid2D<java.lang.Character>);
    Code:
       0: aload_0
       1: aload_1
       2: invokevirtual #258                // Method Position2D.isOnOuterEdgeIn:(LGrid2D;)Z
       5: ireturn

  private static final int main$part1$numberOfTreesOnOuterEdge(Grid2D<java.lang.Character>, Grid2D<java.lang.Character>);
    Code:
       0: aload_0
       1: invokeinterface #266,  1          // InterfaceMethod Grid2D.getAllPositions:()Ljava/util/List;
       6: checkcast     #145                // class java/lang/Iterable
       9: astore_2
      10: iconst_0
      11: istore_3
      12: aload_2
      13: astore        4
      15: new           #147                // class java/util/ArrayList
      18: dup
      19: invokespecial #267                // Method java/util/ArrayList."<init>":()V
      22: checkcast     #155                // class java/util/Collection
      25: astore        5
      27: iconst_0
      28: istore        6
      30: aload         4
      32: invokeinterface #159,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        7
      39: aload         7
      41: invokeinterface #165,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          90
      49: aload         7
      51: invokeinterface #221,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        8
      58: aload         8
      60: checkcast     #133                // class Position2D
      63: astore        9
      65: iconst_0
      66: istore        10
      68: aload         9
      70: aload_1
      71: invokestatic  #269                // Method main$part1$isOnOuterEdge:(LPosition2D;LGrid2D;)Z
      74: ifeq          39
      77: aload         5
      79: aload         8
      81: invokeinterface #180,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      86: pop
      87: goto          39
      90: aload         5
      92: checkcast     #116                // class java/util/List
      95: nop
      96: invokeinterface #272,  1          // InterfaceMethod java/util/List.size:()I
     101: ireturn

  private static final int main$part1(java.util.List<? extends kotlin.jvm.functions.Function2<? super Position2D, ? super Grid2D<java.lang.Character>, ? extends java.util.List<Position2D>>>, java.util.List<java.lang.String>);
    Code:
       0: getstatic     #284                // Field Grid2D.Companion:LGrid2D$Companion;
       3: aload_1
       4: invokevirtual #290                // Method Grid2D$Companion.from1:(Ljava/util/List;)LGrid2D;
       7: astore_2
       8: aload_2
       9: invokeinterface #266,  1          // InterfaceMethod Grid2D.getAllPositions:()Ljava/util/List;
      14: checkcast     #145                // class java/lang/Iterable
      17: astore_3
      18: nop
      19: iconst_0
      20: istore        4
      22: aload_3
      23: astore        5
      25: new           #147                // class java/util/ArrayList
      28: dup
      29: invokespecial #267                // Method java/util/ArrayList."<init>":()V
      32: checkcast     #155                // class java/util/Collection
      35: astore        6
      37: iconst_0
      38: istore        7
      40: aload         5
      42: invokeinterface #159,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      47: astore        8
      49: aload         8
      51: invokeinterface #165,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      56: ifeq          108
      59: aload         8
      61: invokeinterface #221,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      66: astore        9
      68: aload         9
      70: checkcast     #133                // class Position2D
      73: astore        10
      75: iconst_0
      76: istore        11
      78: aload         10
      80: aload_2
      81: invokestatic  #269                // Method main$part1$isOnOuterEdge:(LPosition2D;LGrid2D;)Z
      84: ifne          91
      87: iconst_1
      88: goto          92
      91: iconst_0
      92: ifeq          49
      95: aload         6
      97: aload         9
      99: invokeinterface #180,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     104: pop
     105: goto          49
     108: aload         6
     110: checkcast     #116                // class java/util/List
     113: nop
     114: checkcast     #145                // class java/lang/Iterable
     117: astore_3
     118: nop
     119: iconst_0
     120: istore        4
     122: aload_3
     123: instanceof    #155                // class java/util/Collection
     126: ifeq          145
     129: aload_3
     130: checkcast     #155                // class java/util/Collection
     133: invokeinterface #217,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     138: ifeq          145
     141: iconst_0
     142: goto          211
     145: iconst_0
     146: istore        5
     148: aload_3
     149: invokeinterface #159,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     154: astore        6
     156: aload         6
     158: invokeinterface #165,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     163: ifeq          209
     166: aload         6
     168: invokeinterface #221,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     173: astore        7
     175: aload         7
     177: checkcast     #133                // class Position2D
     180: astore        8
     182: iconst_0
     183: istore        9
     185: aload         8
     187: aload_0
     188: aload_2
     189: invokestatic  #292                // Method main$part1$isVisibleFromAnyDirection:(LPosition2D;Ljava/util/List;LGrid2D;)Z
     192: ifeq          156
     195: iinc          5, 1
     198: iload         5
     200: ifge          156
     203: invokestatic  #295                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     206: goto          156
     209: iload         5
     211: aload_2
     212: aload_2
     213: invokestatic  #297                // Method main$part1$numberOfTreesOnOuterEdge:(LGrid2D;LGrid2D;)I
     216: iadd
     217: ireturn

  private static final int main$part2$thatCanBeSeenFrom$addViewOfTreeThatCantBeSeenPassed(java.util.List<Position2D>, int);
    Code:
       0: aload_0
       1: checkcast     #155                // class java/util/Collection
       4: invokeinterface #217,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
       9: ifne          16
      12: iconst_1
      13: goto          17
      16: iconst_0
      17: ifeq          34
      20: iload_1
      21: aload_0
      22: invokeinterface #272,  1          // InterfaceMethod java/util/List.size:()I
      27: if_icmpge     34
      30: iconst_1
      31: goto          35
      34: iconst_0
      35: ireturn

  private static final int main$part2$thatCanBeSeenFrom(java.util.List<Position2D>, Grid2D<java.lang.Character>, Position2D);
    Code:
       0: aload_0
       1: checkcast     #145                // class java/lang/Iterable
       4: astore_3
       5: iconst_0
       6: istore        4
       8: new           #147                // class java/util/ArrayList
      11: dup
      12: invokespecial #267                // Method java/util/ArrayList."<init>":()V
      15: astore        5
      17: aload_3
      18: invokeinterface #159,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      23: astore        6
      25: aload         6
      27: invokeinterface #165,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      32: ifeq          109
      35: aload         6
      37: invokeinterface #221,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      42: astore        7
      44: aload         7
      46: checkcast     #133                // class Position2D
      49: astore        8
      51: iconst_0
      52: istore        9
      54: aload_1
      55: aload_2
      56: invokeinterface #225,  2          // InterfaceMethod Grid2D.get:(LPosition2D;)Ljava/lang/Object;
      61: checkcast     #227                // class java/lang/Character
      64: invokevirtual #231                // Method java/lang/Character.charValue:()C
      67: aload_1
      68: aload         8
      70: invokeinterface #225,  2          // InterfaceMethod Grid2D.get:(LPosition2D;)Ljava/lang/Object;
      75: checkcast     #227                // class java/lang/Character
      78: invokevirtual #231                // Method java/lang/Character.charValue:()C
      81: invokestatic  #235                // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
      84: ifle          91
      87: iconst_1
      88: goto          92
      91: iconst_0
      92: ifne          98
      95: goto          109
      98: aload         5
     100: aload         7
     102: invokevirtual #311                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     105: pop
     106: goto          25
     109: aload         5
     111: checkcast     #116                // class java/util/List
     114: checkcast     #155                // class java/util/Collection
     117: invokeinterface #312,  1          // InterfaceMethod java/util/Collection.size:()I
     122: istore        4
     124: iconst_0
     125: istore        5
     127: iload         4
     129: aload_0
     130: iload         4
     132: invokestatic  #314                // Method main$part2$thatCanBeSeenFrom$addViewOfTreeThatCantBeSeenPassed:(Ljava/util/List;I)I
     135: iadd
     136: nop
     137: ireturn

  private static final java.util.List<java.lang.Integer> main$part2$numberOfTreesInViewPerDirection(Position2D, java.util.List<? extends kotlin.jvm.functions.Function2<? super Position2D, ? super Grid2D<java.lang.Character>, ? extends java.util.List<Position2D>>>, Grid2D<java.lang.Character>);
    Code:
       0: aload_1
       1: checkcast     #145                // class java/lang/Iterable
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: astore        5
      11: new           #147                // class java/util/ArrayList
      14: dup
      15: aload_3
      16: bipush        10
      18: invokestatic  #151                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #153                // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #155                // class java/util/Collection
      27: astore        6
      29: iconst_0
      30: istore        7
      32: aload         5
      34: invokeinterface #159,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      39: astore        8
      41: aload         8
      43: invokeinterface #165,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      48: ifeq          110
      51: aload         8
      53: invokeinterface #221,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      58: astore        9
      60: aload         6
      62: aload         9
      64: checkcast     #44                 // class kotlin/jvm/functions/Function2
      67: astore        10
      69: astore        13
      71: iconst_0
      72: istore        11
      74: aload         10
      76: aload_0
      77: aload_2
      78: invokeinterface #214,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      83: checkcast     #116                // class java/util/List
      86: astore        12
      88: aload         12
      90: aload_2
      91: aload_0
      92: invokestatic  #328                // Method main$part2$thatCanBeSeenFrom:(Ljava/util/List;LGrid2D;LPosition2D;)I
      95: invokestatic  #334                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      98: aload         13
     100: swap
     101: invokeinterface #180,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     106: pop
     107: goto          41
     110: aload         6
     112: checkcast     #116                // class java/util/List
     115: nop
     116: areturn

  private static final int main$part2$scenicValue(Position2D, java.util.List<? extends kotlin.jvm.functions.Function2<? super Position2D, ? super Grid2D<java.lang.Character>, ? extends java.util.List<Position2D>>>, Grid2D<java.lang.Character>);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokestatic  #342                // Method main$part2$numberOfTreesInViewPerDirection:(LPosition2D;Ljava/util/List;LGrid2D;)Ljava/util/List;
       6: checkcast     #145                // class java/lang/Iterable
       9: astore_3
      10: nop
      11: iconst_0
      12: istore        4
      14: aload_3
      15: invokeinterface #159,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      20: astore        5
      22: aload         5
      24: invokeinterface #165,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      29: ifne          43
      32: new           #344                // class java/lang/UnsupportedOperationException
      35: dup
      36: ldc_w         #346                // String Empty collection can\'t be reduced.
      39: invokespecial #347                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
      42: athrow
      43: aload         5
      45: invokeinterface #221,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      50: astore        6
      52: aload         5
      54: invokeinterface #165,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      59: ifeq          103
      62: aload         6
      64: aload         5
      66: invokeinterface #221,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      71: checkcast     #349                // class java/lang/Number
      74: invokevirtual #352                // Method java/lang/Number.intValue:()I
      77: istore        7
      79: checkcast     #349                // class java/lang/Number
      82: invokevirtual #352                // Method java/lang/Number.intValue:()I
      85: istore        8
      87: iconst_0
      88: istore        9
      90: iload         8
      92: iload         7
      94: imul
      95: invokestatic  #334                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      98: astore        6
     100: goto          52
     103: aload         6
     105: checkcast     #349                // class java/lang/Number
     108: invokevirtual #352                // Method java/lang/Number.intValue:()I
     111: ireturn

  private static final int main$part2(java.util.List<? extends kotlin.jvm.functions.Function2<? super Position2D, ? super Grid2D<java.lang.Character>, ? extends java.util.List<Position2D>>>, java.util.List<java.lang.String>);
    Code:
       0: getstatic     #284                // Field Grid2D.Companion:LGrid2D$Companion;
       3: aload_1
       4: invokevirtual #290                // Method Grid2D$Companion.from1:(Ljava/util/List;)LGrid2D;
       7: astore_2
       8: aload_2
       9: invokeinterface #266,  1          // InterfaceMethod Grid2D.getAllPositions:()Ljava/util/List;
      14: checkcast     #145                // class java/lang/Iterable
      17: invokeinterface #159,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      22: astore_3
      23: aload_3
      24: invokeinterface #165,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      29: ifne          40
      32: new           #363                // class java/util/NoSuchElementException
      35: dup
      36: invokespecial #364                // Method java/util/NoSuchElementException."<init>":()V
      39: athrow
      40: aload_3
      41: invokeinterface #221,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      46: checkcast     #133                // class Position2D
      49: astore        4
      51: iconst_0
      52: istore        5
      54: aload         4
      56: aload_0
      57: aload_2
      58: invokestatic  #366                // Method main$part2$scenicValue:(LPosition2D;Ljava/util/List;LGrid2D;)I
      61: istore        4
      63: aload_3
      64: invokeinterface #165,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      69: ifeq          109
      72: aload_3
      73: invokeinterface #221,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      78: checkcast     #133                // class Position2D
      81: astore        5
      83: iconst_0
      84: istore        6
      86: aload         5
      88: aload_0
      89: aload_2
      90: invokestatic  #366                // Method main$part2$scenicValue:(LPosition2D;Ljava/util/List;LGrid2D;)I
      93: istore        5
      95: iload         4
      97: iload         5
      99: if_icmpge     63
     102: iload         5
     104: istore        4
     106: goto          63
     109: iload         4
     111: ireturn
}