package day19

import java.nio.file.Files
import java.nio.file.Paths
import kotlin.math.absoluteValue
import kotlin.system.measureTimeMillis

fun main() {
  val rotations = createRotations()

  fun fullMap(input: Input): MutableList<Pair<Point, List<Point>>> {
    val fixed = mutableListOf(Point(0, 0, 0) to input.first())
    val remaining = input.withIndex().drop(1).toMutableList()
    val tried = Array(input.size) { HashSet<Int>() }
    while (remaining.isNotEmpty()) {
      remaining.removeAll { (index, beacons) ->
        for ((scannerIndex, scannerAndBeacons) in fixed.withIndex()) {
          if (scannerIndex in tried[index]) continue
          tried[index] += scannerIndex
          for (rotation in rotations) {
            val rotated = beacons.map { it.rotate(rotation) }
            val (shift, frequency) = buildMap {
              for (a in rotated) {
                for (b in scannerAndBeacons.second) {
                  this.compute(b - a) { _, prev ->
                    1 + (prev ?: 0)
                  }
                }
              }
            }.maxByOrNull { it.value }!!
            if (frequency >= 12) {
              fixed += shift to rotated.map { it + shift }
              return@removeAll true
            }
          }
        }
        return@removeAll false
      }
    }
    return fixed
  }

  fun part1(input: Input): Int {
    return fullMap(input).map { it.second }.flatten().toSet().size
  }

  fun part2(input: Input): Int {
    val scanners = fullMap(input).map { it.first }
    return scanners.maxOf { a ->
      scanners.maxOf { b ->
        (a - b).magnitude()
      }
    }
  }

  check(part1(readInput("test-input.txt")) == 79)
  check(part2(readInput("test-input.txt")) == 3621)

  val millis = measureTimeMillis {
    println(part1(readInput("input.txt")))
    println(part2(readInput("input.txt")))
  }
  System.err.println("Done in $millis ms.")
}

private fun createRotations(): List<List<List<Int>>> {
  fun createMatrices(sin: Int, cos: Int): List<List<List<Int>>> = listOf(
    listOf( // Rx
      listOf(1,    0,   0),
      listOf(0,  cos, sin),
      listOf(0, -sin, cos),
    ),
    listOf( // Ry
      listOf(cos, 0, -sin),
      listOf(  0, 1,    0),
      listOf(sin, 0,  cos),
    ),
    listOf( // Rz
      listOf( cos, sin, 0),
      listOf(-sin, cos, 0),
      listOf(   0,   0, 1),
    ),
  )

  return listOf(
    1 to 0,
    0 to 1,
    -1 to 0,
    0 to -1,
  ).flatMap { (cos, sin) ->
    createMatrices(sin, cos)
  }.let {
    buildSet {
      for (a in it) for (b in it) add(a * b)
      check(size == 24)
    }.toList()
  }
}

private operator fun List<List<Int>>.times(other: List<List<Int>>): List<List<Int>> {
  require(this.first().size == other.size)
  return List(this.size) { i ->
    List(other.first().size) { j ->
      other.indices.sumOf { k ->
        this[i][k] * other[k][j]
      }
    }
  }
}

private data class Point(val x: Int, val y: Int, val z: Int)

private operator fun Point.plus(other: Point) =
  Point(x + other.x, y + other.y, z + other.z)

private operator fun Point.minus(other: Point) =
  Point(x - other.x, y - other.y, z - other.z)

private fun Point.rotate(rotation: List<List<Int>>): Point {
  val (x, y, z) = (listOf(listOf(x, y, z)) * rotation).first()
  return Point(x, y, z)
}

private fun Point.magnitude(): Int = x.absoluteValue + y.absoluteValue + z.absoluteValue

private fun readInput(s: String): Input {
  return buildList<MutableList<Point>> {
    Files.newBufferedReader(Paths.get("src/day19/$s")).forEachLine { line ->
      if (line == "--- scanner $size ---") {
        add(mutableListOf())
      } else if (line.isNotBlank()) {
        val (x, y, z) = line.split(",").map { it.toInt() }
        last().add(Point(x, y, z))
      }
    }
  }
}

private typealias Input = List<List<Point>>

Compiled from "Solution.kt"
public final class day19.SolutionKt {
  public static final void main();
    Code:
       0: invokestatic  #10                 // Method createRotations:()Ljava/util/List;
       3: astore_0
       4: aload_0
       5: ldc           #12                 // String test-input.txt
       7: invokestatic  #16                 // Method readInput:(Ljava/lang/String;)Ljava/util/List;
      10: invokestatic  #20                 // Method main$part1:(Ljava/util/List;Ljava/util/List;)I
      13: bipush        79
      15: if_icmpne     22
      18: iconst_1
      19: goto          23
      22: iconst_0
      23: ifne          36
      26: new           #22                 // class java/lang/IllegalStateException
      29: dup
      30: ldc           #24                 // String Check failed.
      32: invokespecial #28                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      35: athrow
      36: aload_0
      37: ldc           #12                 // String test-input.txt
      39: invokestatic  #16                 // Method readInput:(Ljava/lang/String;)Ljava/util/List;
      42: invokestatic  #31                 // Method main$part2:(Ljava/util/List;Ljava/util/List;)I
      45: sipush        3621
      48: if_icmpne     55
      51: iconst_1
      52: goto          56
      55: iconst_0
      56: ifne          69
      59: new           #22                 // class java/lang/IllegalStateException
      62: dup
      63: ldc           #24                 // String Check failed.
      65: invokespecial #28                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      68: athrow
      69: iconst_0
      70: istore_3
      71: invokestatic  #37                 // Method java/lang/System.currentTimeMillis:()J
      74: lstore        4
      76: iconst_0
      77: istore        6
      79: aload_0
      80: ldc           #39                 // String input.txt
      82: invokestatic  #16                 // Method readInput:(Ljava/lang/String;)Ljava/util/List;
      85: invokestatic  #20                 // Method main$part1:(Ljava/util/List;Ljava/util/List;)I
      88: istore        7
      90: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      93: iload         7
      95: invokevirtual #49                 // Method java/io/PrintStream.println:(I)V
      98: aload_0
      99: ldc           #39                 // String input.txt
     101: invokestatic  #16                 // Method readInput:(Ljava/lang/String;)Ljava/util/List;
     104: invokestatic  #31                 // Method main$part2:(Ljava/util/List;Ljava/util/List;)I
     107: istore        7
     109: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
     112: iload         7
     114: invokevirtual #49                 // Method java/io/PrintStream.println:(I)V
     117: nop
     118: nop
     119: invokestatic  #37                 // Method java/lang/System.currentTimeMillis:()J
     122: lload         4
     124: lsub
     125: lstore_1
     126: getstatic     #52                 // Field java/lang/System.err:Ljava/io/PrintStream;
     129: new           #54                 // class java/lang/StringBuilder
     132: dup
     133: invokespecial #56                 // Method java/lang/StringBuilder."<init>":()V
     136: ldc           #58                 // String Done in
     138: invokevirtual #62                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     141: lload_1
     142: invokevirtual #65                 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     145: ldc           #67                 // String  ms.
     147: invokevirtual #62                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     150: invokevirtual #71                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     153: invokevirtual #73                 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
     156: return

  private static final java.util.List<java.util.List<java.util.List<java.lang.Integer>>> createRotations();
    Code:
       0: iconst_4
       1: anewarray     #86                 // class kotlin/Pair
       4: astore_0
       5: aload_0
       6: iconst_0
       7: iconst_1
       8: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      11: iconst_0
      12: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      15: invokestatic  #98                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      18: aastore
      19: aload_0
      20: iconst_1
      21: iconst_0
      22: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      25: iconst_1
      26: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      29: invokestatic  #98                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      32: aastore
      33: aload_0
      34: iconst_2
      35: iconst_m1
      36: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      39: iconst_0
      40: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      43: invokestatic  #98                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      46: aastore
      47: aload_0
      48: iconst_3
      49: iconst_0
      50: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      53: iconst_m1
      54: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      57: invokestatic  #98                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      60: aastore
      61: aload_0
      62: invokestatic  #104                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      65: checkcast     #106                // class java/lang/Iterable
      68: astore_0
      69: nop
      70: iconst_0
      71: istore_1
      72: aload_0
      73: astore_2
      74: new           #108                // class java/util/ArrayList
      77: dup
      78: invokespecial #109                // Method java/util/ArrayList."<init>":()V
      81: checkcast     #111                // class java/util/Collection
      84: astore_3
      85: iconst_0
      86: istore        4
      88: aload_2
      89: invokeinterface #115,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      94: astore        5
      96: aload         5
      98: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     103: ifeq          173
     106: aload         5
     108: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     113: astore        6
     115: aload         6
     117: checkcast     #86                 // class kotlin/Pair
     120: astore        7
     122: iconst_0
     123: istore        8
     125: aload         7
     127: invokevirtual #128                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     130: checkcast     #130                // class java/lang/Number
     133: invokevirtual #134                // Method java/lang/Number.intValue:()I
     136: istore        9
     138: aload         7
     140: invokevirtual #137                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     143: checkcast     #130                // class java/lang/Number
     146: invokevirtual #134                // Method java/lang/Number.intValue:()I
     149: istore        10
     151: iload         10
     153: iload         9
     155: invokestatic  #141                // Method createRotations$createMatrices:(II)Ljava/util/List;
     158: checkcast     #106                // class java/lang/Iterable
     161: astore        7
     163: aload_3
     164: aload         7
     166: invokestatic  #145                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     169: pop
     170: goto          96
     173: aload_3
     174: checkcast     #83                 // class java/util/List
     177: nop
     178: astore_1
     179: iconst_0
     180: istore_2
     181: invokestatic  #151                // Method kotlin/collections/SetsKt.createSetBuilder:()Ljava/util/Set;
     184: astore_3
     185: aload_3
     186: astore        4
     188: iconst_0
     189: istore        5
     191: aload_1
     192: invokeinterface #152,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     197: astore        6
     199: aload         6
     201: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     206: ifeq          269
     209: aload         6
     211: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     216: checkcast     #83                 // class java/util/List
     219: astore        7
     221: aload_1
     222: invokeinterface #152,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     227: astore        8
     229: aload         8
     231: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     236: ifeq          199
     239: aload         8
     241: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     246: checkcast     #83                 // class java/util/List
     249: astore        9
     251: aload         4
     253: aload         7
     255: aload         9
     257: invokestatic  #156                // Method times:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;
     260: invokeinterface #162,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     265: pop
     266: goto          229
     269: aload         4
     271: invokeinterface #165,  1          // InterfaceMethod java/util/Set.size:()I
     276: bipush        24
     278: if_icmpne     285
     281: iconst_1
     282: goto          286
     285: iconst_0
     286: ifne          299
     289: new           #22                 // class java/lang/IllegalStateException
     292: dup
     293: ldc           #24                 // String Check failed.
     295: invokespecial #28                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     298: athrow
     299: nop
     300: aload_3
     301: invokestatic  #169                // Method kotlin/collections/SetsKt.build:(Ljava/util/Set;)Ljava/util/Set;
     304: checkcast     #106                // class java/lang/Iterable
     307: invokestatic  #173                // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     310: nop
     311: areturn

  private static final java.util.List<java.util.List<java.lang.Integer>> times(java.util.List<? extends java.util.List<java.lang.Integer>>, java.util.List<? extends java.util.List<java.lang.Integer>>);
    Code:
       0: aload_0
       1: ldc           #196                // String <this>
       3: invokestatic  #202                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #206                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      10: checkcast     #83                 // class java/util/List
      13: invokeinterface #207,  1          // InterfaceMethod java/util/List.size:()I
      18: aload_1
      19: invokeinterface #207,  1          // InterfaceMethod java/util/List.size:()I
      24: if_icmpne     31
      27: iconst_1
      28: goto          32
      31: iconst_0
      32: ifne          50
      35: ldc           #209                // String Failed requirement.
      37: astore_3
      38: new           #211                // class java/lang/IllegalArgumentException
      41: dup
      42: aload_3
      43: invokevirtual #212                // Method java/lang/Object.toString:()Ljava/lang/String;
      46: invokespecial #213                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      49: athrow
      50: aload_0
      51: invokeinterface #207,  1          // InterfaceMethod java/util/List.size:()I
      56: istore_2
      57: new           #108                // class java/util/ArrayList
      60: dup
      61: iload_2
      62: invokespecial #215                // Method java/util/ArrayList."<init>":(I)V
      65: astore_3
      66: iconst_0
      67: istore        4
      69: iload         4
      71: iload_2
      72: if_icmpge     293
      75: iload         4
      77: istore        5
      79: aload_3
      80: iload         5
      82: istore        6
      84: astore        23
      86: iconst_0
      87: istore        7
      89: aload_1
      90: invokestatic  #206                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      93: checkcast     #83                 // class java/util/List
      96: invokeinterface #207,  1          // InterfaceMethod java/util/List.size:()I
     101: istore        8
     103: new           #108                // class java/util/ArrayList
     106: dup
     107: iload         8
     109: invokespecial #215                // Method java/util/ArrayList."<init>":(I)V
     112: astore        9
     114: iconst_0
     115: istore        10
     117: iload         10
     119: iload         8
     121: if_icmpge     274
     124: iload         10
     126: istore        11
     128: aload         9
     130: iload         11
     132: istore        12
     134: astore        13
     136: iconst_0
     137: istore        14
     139: aload_1
     140: checkcast     #111                // class java/util/Collection
     143: invokestatic  #219                // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
     146: checkcast     #106                // class java/lang/Iterable
     149: astore        15
     151: iconst_0
     152: istore        16
     154: aload         15
     156: invokeinterface #115,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     161: astore        17
     163: aload         17
     165: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     170: ifeq          255
     173: aload         17
     175: checkcast     #221                // class kotlin/collections/IntIterator
     178: invokevirtual #224                // Method kotlin/collections/IntIterator.nextInt:()I
     181: istore        18
     183: iload         16
     185: iload         18
     187: istore        19
     189: istore        20
     191: iconst_0
     192: istore        21
     194: aload_0
     195: iload         6
     197: invokeinterface #228,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     202: checkcast     #83                 // class java/util/List
     205: iload         19
     207: invokeinterface #228,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     212: checkcast     #130                // class java/lang/Number
     215: invokevirtual #134                // Method java/lang/Number.intValue:()I
     218: aload_1
     219: iload         19
     221: invokeinterface #228,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     226: checkcast     #83                 // class java/util/List
     229: iload         12
     231: invokeinterface #228,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     236: checkcast     #130                // class java/lang/Number
     239: invokevirtual #134                // Method java/lang/Number.intValue:()I
     242: imul
     243: istore        22
     245: iload         20
     247: iload         22
     249: iadd
     250: istore        16
     252: goto          163
     255: iload         16
     257: nop
     258: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     261: aload         13
     263: swap
     264: invokevirtual #229                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     267: pop
     268: iinc          10, 1
     271: goto          117
     274: aload         9
     276: checkcast     #83                 // class java/util/List
     279: nop
     280: aload         23
     282: swap
     283: invokevirtual #229                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     286: pop
     287: iinc          4, 1
     290: goto          69
     293: aload_3
     294: checkcast     #83                 // class java/util/List
     297: areturn

  private static final day19.Point plus(day19.Point, day19.Point);
    Code:
       0: aload_0
       1: ldc           #196                // String <this>
       3: invokestatic  #202                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #241                // class day19/Point
       9: dup
      10: aload_0
      11: invokevirtual #244                // Method day19/Point.getX:()I
      14: aload_1
      15: invokevirtual #244                // Method day19/Point.getX:()I
      18: iadd
      19: aload_0
      20: invokevirtual #247                // Method day19/Point.getY:()I
      23: aload_1
      24: invokevirtual #247                // Method day19/Point.getY:()I
      27: iadd
      28: aload_0
      29: invokevirtual #250                // Method day19/Point.getZ:()I
      32: aload_1
      33: invokevirtual #250                // Method day19/Point.getZ:()I
      36: iadd
      37: invokespecial #253                // Method day19/Point."<init>":(III)V
      40: areturn

  private static final day19.Point minus(day19.Point, day19.Point);
    Code:
       0: aload_0
       1: ldc           #196                // String <this>
       3: invokestatic  #202                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #241                // class day19/Point
       9: dup
      10: aload_0
      11: invokevirtual #244                // Method day19/Point.getX:()I
      14: aload_1
      15: invokevirtual #244                // Method day19/Point.getX:()I
      18: isub
      19: aload_0
      20: invokevirtual #247                // Method day19/Point.getY:()I
      23: aload_1
      24: invokevirtual #247                // Method day19/Point.getY:()I
      27: isub
      28: aload_0
      29: invokevirtual #250                // Method day19/Point.getZ:()I
      32: aload_1
      33: invokevirtual #250                // Method day19/Point.getZ:()I
      36: isub
      37: invokespecial #253                // Method day19/Point."<init>":(III)V
      40: areturn

  private static final day19.Point rotate(day19.Point, java.util.List<? extends java.util.List<java.lang.Integer>>);
    Code:
       0: iconst_3
       1: anewarray     #88                 // class java/lang/Integer
       4: astore_3
       5: aload_3
       6: iconst_0
       7: aload_0
       8: invokevirtual #244                // Method day19/Point.getX:()I
      11: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      14: aastore
      15: aload_3
      16: iconst_1
      17: aload_0
      18: invokevirtual #247                // Method day19/Point.getY:()I
      21: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      24: aastore
      25: aload_3
      26: iconst_2
      27: aload_0
      28: invokevirtual #250                // Method day19/Point.getZ:()I
      31: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      34: aastore
      35: aload_3
      36: invokestatic  #104                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      39: invokestatic  #263                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      42: aload_1
      43: invokestatic  #156                // Method times:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;
      46: invokestatic  #206                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      49: checkcast     #83                 // class java/util/List
      52: astore_2
      53: aload_2
      54: iconst_0
      55: invokeinterface #228,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      60: checkcast     #130                // class java/lang/Number
      63: invokevirtual #134                // Method java/lang/Number.intValue:()I
      66: istore_3
      67: aload_2
      68: iconst_1
      69: invokeinterface #228,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      74: checkcast     #130                // class java/lang/Number
      77: invokevirtual #134                // Method java/lang/Number.intValue:()I
      80: istore        4
      82: aload_2
      83: iconst_2
      84: invokeinterface #228,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      89: checkcast     #130                // class java/lang/Number
      92: invokevirtual #134                // Method java/lang/Number.intValue:()I
      95: istore        5
      97: new           #241                // class day19/Point
     100: dup
     101: iload_3
     102: iload         4
     104: iload         5
     106: invokespecial #253                // Method day19/Point."<init>":(III)V
     109: areturn

  private static final int magnitude(day19.Point);
    Code:
       0: aload_0
       1: invokevirtual #244                // Method day19/Point.getX:()I
       4: invokestatic  #276                // Method java/lang/Math.abs:(I)I
       7: aload_0
       8: invokevirtual #247                // Method day19/Point.getY:()I
      11: invokestatic  #276                // Method java/lang/Math.abs:(I)I
      14: iadd
      15: aload_0
      16: invokevirtual #250                // Method day19/Point.getZ:()I
      19: invokestatic  #276                // Method java/lang/Math.abs:(I)I
      22: iadd
      23: ireturn

  private static final java.util.List<java.util.List<day19.Point>> readInput(java.lang.String);
    Code:
       0: invokestatic  #281                // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;
       3: astore_1
       4: aload_1
       5: astore_2
       6: iconst_0
       7: istore_3
       8: new           #54                 // class java/lang/StringBuilder
      11: dup
      12: invokespecial #56                 // Method java/lang/StringBuilder."<init>":()V
      15: ldc_w         #283                // String src/day19/
      18: invokevirtual #62                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      21: aload_0
      22: invokevirtual #62                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      25: invokevirtual #71                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      28: iconst_0
      29: anewarray     #285                // class java/lang/String
      32: invokestatic  #290                // Method java/nio/file/Paths.get:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;
      35: invokestatic  #296                // Method java/nio/file/Files.newBufferedReader:(Ljava/nio/file/Path;)Ljava/io/BufferedReader;
      38: dup
      39: ldc_w         #298                // String newBufferedReader(...)
      42: invokestatic  #301                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      45: checkcast     #303                // class java/io/Reader
      48: aload_2
      49: invokedynamic #323,  0            // InvokeDynamic #0:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function1;
      54: invokestatic  #329                // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V
      57: nop
      58: aload_1
      59: invokestatic  #332                // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;
      62: areturn

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

  private static final java.lang.Integer main$fullMap$lambda$6$lambda$3$lambda$1(day19.Point, java.lang.Integer);
    Code:
       0: aload_0
       1: ldc_w         #345                // String <unused var>
       4: invokestatic  #202                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: iconst_1
       8: aload_1
       9: dup
      10: ifnull        19
      13: invokevirtual #346                // Method java/lang/Integer.intValue:()I
      16: goto          21
      19: pop
      20: iconst_0
      21: iadd
      22: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      25: areturn

  private static final java.lang.Integer main$fullMap$lambda$6$lambda$3$lambda$2(kotlin.jvm.functions.Function2, java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokeinterface #355,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
       8: checkcast     #88                 // class java/lang/Integer
      11: areturn

  private static final boolean main$fullMap$lambda$6(java.util.List, java.util.HashSet[], java.util.List, kotlin.collections.IndexedValue);
    Code:
       0: aload_3
       1: ldc_w         #363                // String <destruct>
       4: invokestatic  #202                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_3
       8: invokevirtual #367                // Method kotlin/collections/IndexedValue.component1:()I
      11: istore        4
      13: aload_3
      14: invokevirtual #368                // Method kotlin/collections/IndexedValue.component2:()Ljava/lang/Object;
      17: checkcast     #83                 // class java/util/List
      20: astore        5
      22: aload_0
      23: checkcast     #106                // class java/lang/Iterable
      26: invokeinterface #115,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      31: astore        6
      33: iconst_0
      34: istore        7
      36: aload         6
      38: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      43: ifeq          670
      46: iload         7
      48: istore        8
      50: iload         7
      52: iconst_1
      53: iadd
      54: istore        7
      56: aload         6
      58: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: checkcast     #86                 // class kotlin/Pair
      66: astore        9
      68: aload_1
      69: iload         4
      71: aaload
      72: iload         8
      74: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      77: invokevirtual #373                // Method java/util/HashSet.contains:(Ljava/lang/Object;)Z
      80: ifne          36
      83: iload         8
      85: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      88: astore        11
      90: aload_1
      91: iload         4
      93: aaload
      94: checkcast     #111                // class java/util/Collection
      97: aload         11
      99: invokeinterface #374,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     104: pop
     105: aload_2
     106: invokeinterface #152,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     111: astore        10
     113: aload         10
     115: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     120: ifeq          36
     123: aload         10
     125: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     130: checkcast     #83                 // class java/util/List
     133: astore        11
     135: aload         5
     137: checkcast     #106                // class java/lang/Iterable
     140: astore        13
     142: iconst_0
     143: istore        14
     145: aload         13
     147: astore        15
     149: new           #108                // class java/util/ArrayList
     152: dup
     153: aload         13
     155: bipush        10
     157: invokestatic  #378                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     160: invokespecial #215                // Method java/util/ArrayList."<init>":(I)V
     163: checkcast     #111                // class java/util/Collection
     166: astore        16
     168: iconst_0
     169: istore        17
     171: aload         15
     173: invokeinterface #115,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     178: astore        18
     180: aload         18
     182: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     187: ifeq          232
     190: aload         18
     192: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     197: astore        19
     199: aload         16
     201: aload         19
     203: checkcast     #241                // class day19/Point
     206: astore        20
     208: astore        26
     210: iconst_0
     211: istore        21
     213: aload         20
     215: aload         11
     217: invokestatic  #380                // Method rotate:(Lday19/Point;Ljava/util/List;)Lday19/Point;
     220: aload         26
     222: swap
     223: invokeinterface #374,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     228: pop
     229: goto          180
     232: aload         16
     234: checkcast     #83                 // class java/util/List
     237: nop
     238: astore        12
     240: invokestatic  #386                // Method kotlin/collections/MapsKt.createMapBuilder:()Ljava/util/Map;
     243: astore        14
     245: aload         14
     247: astore        15
     249: iconst_0
     250: istore        16
     252: aload         12
     254: invokeinterface #152,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     259: astore        17
     261: aload         17
     263: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     268: ifeq          348
     271: aload         17
     273: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     278: checkcast     #241                // class day19/Point
     281: astore        18
     283: aload         9
     285: invokevirtual #389                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     288: checkcast     #83                 // class java/util/List
     291: invokeinterface #152,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     296: astore        19
     298: aload         19
     300: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     305: ifeq          261
     308: aload         19
     310: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     315: checkcast     #241                // class day19/Point
     318: astore        20
     320: aload         15
     322: aload         20
     324: aload         18
     326: invokestatic  #391                // Method minus:(Lday19/Point;Lday19/Point;)Lday19/Point;
     329: invokedynamic #399,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function2;
     334: invokedynamic #408,  0            // InvokeDynamic #2:apply:(Lkotlin/jvm/functions/Function2;)Ljava/util/function/BiFunction;
     339: invokeinterface #414,  3          // InterfaceMethod java/util/Map.compute:(Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;
     344: pop
     345: goto          298
     348: nop
     349: aload         14
     351: invokestatic  #417                // Method kotlin/collections/MapsKt.build:(Ljava/util/Map;)Ljava/util/Map;
     354: invokeinterface #420,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     359: checkcast     #106                // class java/lang/Iterable
     362: astore        15
     364: aload         15
     366: invokeinterface #115,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     371: astore        16
     373: aload         16
     375: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     380: ifne          387
     383: aconst_null
     384: goto          497
     387: aload         16
     389: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     394: astore        17
     396: aload         16
     398: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     403: ifne          411
     406: aload         17
     408: goto          497
     411: aload         17
     413: checkcast     #422                // class java/util/Map$Entry
     416: astore        18
     418: iconst_0
     419: istore        19
     421: aload         18
     423: invokeinterface #425,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     428: checkcast     #130                // class java/lang/Number
     431: invokevirtual #134                // Method java/lang/Number.intValue:()I
     434: istore        18
     436: aload         16
     438: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     443: astore        19
     445: aload         19
     447: checkcast     #422                // class java/util/Map$Entry
     450: astore        20
     452: iconst_0
     453: istore        21
     455: aload         20
     457: invokeinterface #425,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     462: checkcast     #130                // class java/lang/Number
     465: invokevirtual #134                // Method java/lang/Number.intValue:()I
     468: istore        20
     470: iload         18
     472: iload         20
     474: if_icmpge     485
     477: aload         19
     479: astore        17
     481: iload         20
     483: istore        18
     485: aload         16
     487: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     492: ifne          436
     495: aload         17
     497: checkcast     #422                // class java/util/Map$Entry
     500: dup
     501: invokestatic  #429                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     504: astore        13
     506: aload         13
     508: invokeinterface #432,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     513: checkcast     #241                // class day19/Point
     516: astore        14
     518: aload         13
     520: invokeinterface #425,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     525: checkcast     #130                // class java/lang/Number
     528: invokevirtual #134                // Method java/lang/Number.intValue:()I
     531: istore        15
     533: iload         15
     535: bipush        12
     537: if_icmplt     113
     540: aload_0
     541: checkcast     #111                // class java/util/Collection
     544: astore        16
     546: aload         14
     548: aload         12
     550: checkcast     #106                // class java/lang/Iterable
     553: astore        17
     555: astore        26
     557: iconst_0
     558: istore        18
     560: aload         17
     562: astore        19
     564: new           #108                // class java/util/ArrayList
     567: dup
     568: aload         17
     570: bipush        10
     572: invokestatic  #378                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     575: invokespecial #215                // Method java/util/ArrayList."<init>":(I)V
     578: checkcast     #111                // class java/util/Collection
     581: astore        20
     583: iconst_0
     584: istore        21
     586: aload         19
     588: invokeinterface #115,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     593: astore        22
     595: aload         22
     597: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     602: ifeq          647
     605: aload         22
     607: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     612: astore        23
     614: aload         20
     616: aload         23
     618: checkcast     #241                // class day19/Point
     621: astore        24
     623: astore        27
     625: iconst_0
     626: istore        25
     628: aload         24
     630: aload         14
     632: invokestatic  #434                // Method plus:(Lday19/Point;Lday19/Point;)Lday19/Point;
     635: aload         27
     637: swap
     638: invokeinterface #374,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     643: pop
     644: goto          595
     647: aload         20
     649: checkcast     #83                 // class java/util/List
     652: nop
     653: aload         26
     655: swap
     656: invokestatic  #98                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     659: aload         16
     661: swap
     662: invokeinterface #374,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     667: pop
     668: iconst_1
     669: ireturn
     670: iconst_0
     671: ireturn

  private static final java.util.List<kotlin.Pair<day19.Point, java.util.List<day19.Point>>> main$fullMap(java.util.List<? extends java.util.List<? extends java.util.List<java.lang.Integer>>>, java.util.List<? extends java.util.List<day19.Point>>);
    Code:
       0: iconst_1
       1: anewarray     #86                 // class kotlin/Pair
       4: astore_3
       5: aload_3
       6: iconst_0
       7: new           #241                // class day19/Point
      10: dup
      11: iconst_0
      12: iconst_0
      13: iconst_0
      14: invokespecial #253                // Method day19/Point."<init>":(III)V
      17: aload_1
      18: invokestatic  #206                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      21: invokestatic  #98                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      24: aastore
      25: aload_3
      26: invokestatic  #464                // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
      29: astore_2
      30: aload_1
      31: checkcast     #106                // class java/lang/Iterable
      34: invokestatic  #468                // Method kotlin/collections/CollectionsKt.withIndex:(Ljava/lang/Iterable;)Ljava/lang/Iterable;
      37: iconst_1
      38: invokestatic  #472                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
      41: checkcast     #111                // class java/util/Collection
      44: invokestatic  #476                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
      47: astore_3
      48: iconst_0
      49: istore        5
      51: aload_1
      52: invokeinterface #207,  1          // InterfaceMethod java/util/List.size:()I
      57: istore        6
      59: iload         6
      61: anewarray     #370                // class java/util/HashSet
      64: astore        7
      66: iload         5
      68: iload         6
      70: if_icmpge     95
      73: iload         5
      75: istore        8
      77: aload         7
      79: iload         8
      81: new           #370                // class java/util/HashSet
      84: dup
      85: invokespecial #477                // Method java/util/HashSet."<init>":()V
      88: aastore
      89: iinc          5, 1
      92: goto          66
      95: aload         7
      97: astore        4
      99: aload_3
     100: checkcast     #111                // class java/util/Collection
     103: invokeinterface #480,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     108: ifne          115
     111: iconst_1
     112: goto          116
     115: iconst_0
     116: ifeq          136
     119: aload_3
     120: aload_2
     121: aload         4
     123: aload_0
     124: invokedynamic #488,  0            // InvokeDynamic #3:invoke:(Ljava/util/List;[Ljava/util/HashSet;Ljava/util/List;)Lkotlin/jvm/functions/Function1;
     129: invokestatic  #492                // Method kotlin/collections/CollectionsKt.removeAll:(Ljava/util/List;Lkotlin/jvm/functions/Function1;)Z
     132: pop
     133: goto          99
     136: aload_2
     137: areturn

  private static final int main$part1(java.util.List<? extends java.util.List<? extends java.util.List<java.lang.Integer>>>, java.util.List<? extends java.util.List<day19.Point>>);
    Code:
       0: aload_0
       1: aload_1
       2: invokestatic  #499                // Method main$fullMap:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;
       5: checkcast     #106                // class java/lang/Iterable
       8: astore_2
       9: iconst_0
      10: istore_3
      11: aload_2
      12: astore        4
      14: new           #108                // class java/util/ArrayList
      17: dup
      18: aload_2
      19: bipush        10
      21: invokestatic  #378                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      24: invokespecial #215                // Method java/util/ArrayList."<init>":(I)V
      27: checkcast     #111                // class java/util/Collection
      30: astore        5
      32: iconst_0
      33: istore        6
      35: aload         4
      37: invokeinterface #115,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        7
      44: aload         7
      46: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          97
      54: aload         7
      56: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        8
      63: aload         5
      65: aload         8
      67: checkcast     #86                 // class kotlin/Pair
      70: astore        9
      72: astore        11
      74: iconst_0
      75: istore        10
      77: aload         9
      79: invokevirtual #389                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      82: checkcast     #83                 // class java/util/List
      85: aload         11
      87: swap
      88: invokeinterface #374,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      93: pop
      94: goto          44
      97: aload         5
      99: checkcast     #83                 // class java/util/List
     102: nop
     103: checkcast     #106                // class java/lang/Iterable
     106: invokestatic  #502                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     109: checkcast     #106                // class java/lang/Iterable
     112: invokestatic  #506                // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     115: invokeinterface #165,  1          // InterfaceMethod java/util/Set.size:()I
     120: ireturn

  private static final int main$part2(java.util.List<? extends java.util.List<? extends java.util.List<java.lang.Integer>>>, java.util.List<? extends java.util.List<day19.Point>>);
    Code:
       0: aload_0
       1: aload_1
       2: invokestatic  #499                // Method main$fullMap:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;
       5: checkcast     #106                // class java/lang/Iterable
       8: astore_3
       9: iconst_0
      10: istore        4
      12: aload_3
      13: astore        5
      15: new           #108                // class java/util/ArrayList
      18: dup
      19: aload_3
      20: bipush        10
      22: invokestatic  #378                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      25: invokespecial #215                // Method java/util/ArrayList."<init>":(I)V
      28: checkcast     #111                // class java/util/Collection
      31: astore        6
      33: iconst_0
      34: istore        7
      36: aload         5
      38: invokeinterface #115,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      43: astore        8
      45: aload         8
      47: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      52: ifeq          98
      55: aload         8
      57: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      62: astore        9
      64: aload         6
      66: aload         9
      68: checkcast     #86                 // class kotlin/Pair
      71: astore        10
      73: astore        12
      75: iconst_0
      76: istore        11
      78: aload         10
      80: invokevirtual #510                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      83: checkcast     #241                // class day19/Point
      86: aload         12
      88: swap
      89: invokeinterface #374,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      94: pop
      95: goto          45
      98: aload         6
     100: checkcast     #83                 // class java/util/List
     103: nop
     104: astore_2
     105: aload_2
     106: checkcast     #106                // class java/lang/Iterable
     109: invokeinterface #115,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     114: astore        4
     116: aload         4
     118: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     123: ifne          134
     126: new           #512                // class java/util/NoSuchElementException
     129: dup
     130: invokespecial #513                // Method java/util/NoSuchElementException."<init>":()V
     133: athrow
     134: aload         4
     136: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     141: checkcast     #241                // class day19/Point
     144: astore        5
     146: iconst_0
     147: istore        6
     149: aload_2
     150: checkcast     #106                // class java/lang/Iterable
     153: invokeinterface #115,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     158: astore        7
     160: aload         7
     162: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     167: ifne          178
     170: new           #512                // class java/util/NoSuchElementException
     173: dup
     174: invokespecial #513                // Method java/util/NoSuchElementException."<init>":()V
     177: athrow
     178: aload         7
     180: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     185: checkcast     #241                // class day19/Point
     188: astore        8
     190: iconst_0
     191: istore        9
     193: aload         5
     195: aload         8
     197: invokestatic  #391                // Method minus:(Lday19/Point;Lday19/Point;)Lday19/Point;
     200: invokestatic  #515                // Method magnitude:(Lday19/Point;)I
     203: istore        8
     205: aload         7
     207: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     212: ifeq          256
     215: aload         7
     217: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     222: checkcast     #241                // class day19/Point
     225: astore        9
     227: iconst_0
     228: istore        10
     230: aload         5
     232: aload         9
     234: invokestatic  #391                // Method minus:(Lday19/Point;Lday19/Point;)Lday19/Point;
     237: invokestatic  #515                // Method magnitude:(Lday19/Point;)I
     240: istore        9
     242: iload         8
     244: iload         9
     246: if_icmpge     205
     249: iload         9
     251: istore        8
     253: goto          205
     256: iload         8
     258: nop
     259: istore        5
     261: aload         4
     263: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     268: ifeq          412
     271: aload         4
     273: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     278: checkcast     #241                // class day19/Point
     281: astore        6
     283: iconst_0
     284: istore        7
     286: aload_2
     287: checkcast     #106                // class java/lang/Iterable
     290: invokeinterface #115,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     295: astore        8
     297: aload         8
     299: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     304: ifne          315
     307: new           #512                // class java/util/NoSuchElementException
     310: dup
     311: invokespecial #513                // Method java/util/NoSuchElementException."<init>":()V
     314: athrow
     315: aload         8
     317: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     322: checkcast     #241                // class day19/Point
     325: astore        9
     327: iconst_0
     328: istore        10
     330: aload         6
     332: aload         9
     334: invokestatic  #391                // Method minus:(Lday19/Point;Lday19/Point;)Lday19/Point;
     337: invokestatic  #515                // Method magnitude:(Lday19/Point;)I
     340: istore        9
     342: aload         8
     344: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     349: ifeq          393
     352: aload         8
     354: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     359: checkcast     #241                // class day19/Point
     362: astore        10
     364: iconst_0
     365: istore        11
     367: aload         6
     369: aload         10
     371: invokestatic  #391                // Method minus:(Lday19/Point;Lday19/Point;)Lday19/Point;
     374: invokestatic  #515                // Method magnitude:(Lday19/Point;)I
     377: istore        10
     379: iload         9
     381: iload         10
     383: if_icmpge     342
     386: iload         10
     388: istore        9
     390: goto          342
     393: iload         9
     395: nop
     396: istore        6
     398: iload         5
     400: iload         6
     402: if_icmpge     261
     405: iload         6
     407: istore        5
     409: goto          261
     412: iload         5
     414: ireturn

  private static final java.util.List<java.util.List<java.util.List<java.lang.Integer>>> createRotations$createMatrices(int, int);
    Code:
       0: iconst_3
       1: anewarray     #83                 // class java/util/List
       4: astore_2
       5: aload_2
       6: iconst_0
       7: iconst_3
       8: anewarray     #83                 // class java/util/List
      11: astore_3
      12: aload_3
      13: iconst_0
      14: iconst_3
      15: anewarray     #88                 // class java/lang/Integer
      18: astore        4
      20: aload         4
      22: iconst_0
      23: iconst_1
      24: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      27: aastore
      28: aload         4
      30: iconst_1
      31: iconst_0
      32: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      35: aastore
      36: aload         4
      38: iconst_2
      39: iconst_0
      40: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      43: aastore
      44: aload         4
      46: invokestatic  #104                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      49: aastore
      50: aload_3
      51: iconst_1
      52: iconst_3
      53: anewarray     #88                 // class java/lang/Integer
      56: astore        4
      58: aload         4
      60: iconst_0
      61: iconst_0
      62: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      65: aastore
      66: aload         4
      68: iconst_1
      69: iload_1
      70: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      73: aastore
      74: aload         4
      76: iconst_2
      77: iload_0
      78: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      81: aastore
      82: aload         4
      84: invokestatic  #104                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      87: aastore
      88: aload_3
      89: iconst_2
      90: iconst_3
      91: anewarray     #88                 // class java/lang/Integer
      94: astore        4
      96: aload         4
      98: iconst_0
      99: iconst_0
     100: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     103: aastore
     104: aload         4
     106: iconst_1
     107: iload_0
     108: ineg
     109: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     112: aastore
     113: aload         4
     115: iconst_2
     116: iload_1
     117: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     120: aastore
     121: aload         4
     123: invokestatic  #104                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     126: aastore
     127: aload_3
     128: invokestatic  #104                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     131: aastore
     132: aload_2
     133: iconst_1
     134: iconst_3
     135: anewarray     #83                 // class java/util/List
     138: astore_3
     139: aload_3
     140: iconst_0
     141: iconst_3
     142: anewarray     #88                 // class java/lang/Integer
     145: astore        4
     147: aload         4
     149: iconst_0
     150: iload_1
     151: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     154: aastore
     155: aload         4
     157: iconst_1
     158: iconst_0
     159: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     162: aastore
     163: aload         4
     165: iconst_2
     166: iload_0
     167: ineg
     168: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     171: aastore
     172: aload         4
     174: invokestatic  #104                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     177: aastore
     178: aload_3
     179: iconst_1
     180: iconst_3
     181: anewarray     #88                 // class java/lang/Integer
     184: astore        4
     186: aload         4
     188: iconst_0
     189: iconst_0
     190: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     193: aastore
     194: aload         4
     196: iconst_1
     197: iconst_1
     198: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     201: aastore
     202: aload         4
     204: iconst_2
     205: iconst_0
     206: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     209: aastore
     210: aload         4
     212: invokestatic  #104                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     215: aastore
     216: aload_3
     217: iconst_2
     218: iconst_3
     219: anewarray     #88                 // class java/lang/Integer
     222: astore        4
     224: aload         4
     226: iconst_0
     227: iload_0
     228: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     231: aastore
     232: aload         4
     234: iconst_1
     235: iconst_0
     236: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     239: aastore
     240: aload         4
     242: iconst_2
     243: iload_1
     244: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     247: aastore
     248: aload         4
     250: invokestatic  #104                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     253: aastore
     254: aload_3
     255: invokestatic  #104                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     258: aastore
     259: aload_2
     260: iconst_2
     261: iconst_3
     262: anewarray     #83                 // class java/util/List
     265: astore_3
     266: aload_3
     267: iconst_0
     268: iconst_3
     269: anewarray     #88                 // class java/lang/Integer
     272: astore        4
     274: aload         4
     276: iconst_0
     277: iload_1
     278: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     281: aastore
     282: aload         4
     284: iconst_1
     285: iload_0
     286: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     289: aastore
     290: aload         4
     292: iconst_2
     293: iconst_0
     294: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     297: aastore
     298: aload         4
     300: invokestatic  #104                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     303: aastore
     304: aload_3
     305: iconst_1
     306: iconst_3
     307: anewarray     #88                 // class java/lang/Integer
     310: astore        4
     312: aload         4
     314: iconst_0
     315: iload_0
     316: ineg
     317: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     320: aastore
     321: aload         4
     323: iconst_1
     324: iload_1
     325: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     328: aastore
     329: aload         4
     331: iconst_2
     332: iconst_0
     333: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     336: aastore
     337: aload         4
     339: invokestatic  #104                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     342: aastore
     343: aload_3
     344: iconst_2
     345: iconst_3
     346: anewarray     #88                 // class java/lang/Integer
     349: astore        4
     351: aload         4
     353: iconst_0
     354: iconst_0
     355: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     358: aastore
     359: aload         4
     361: iconst_1
     362: iconst_0
     363: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     366: aastore
     367: aload         4
     369: iconst_2
     370: iconst_1
     371: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     374: aastore
     375: aload         4
     377: invokestatic  #104                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     380: aastore
     381: aload_3
     382: invokestatic  #104                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     385: aastore
     386: aload_2
     387: invokestatic  #104                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     390: areturn

  private static final kotlin.Unit readInput$lambda$20$lambda$19(java.util.List, java.lang.String);
    Code:
       0: aload_1
       1: ldc_w         #522                // String line
       4: invokestatic  #202                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: new           #54                 // class java/lang/StringBuilder
      11: dup
      12: invokespecial #56                 // Method java/lang/StringBuilder."<init>":()V
      15: ldc_w         #524                // String --- scanner
      18: invokevirtual #62                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      21: aload_0
      22: invokeinterface #207,  1          // InterfaceMethod java/util/List.size:()I
      27: invokevirtual #527                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      30: ldc_w         #529                // String  ---
      33: invokevirtual #62                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: invokevirtual #71                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      39: invokestatic  #533                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      42: ifeq          65
      45: aload_0
      46: new           #108                // class java/util/ArrayList
      49: dup
      50: invokespecial #109                // Method java/util/ArrayList."<init>":()V
      53: checkcast     #83                 // class java/util/List
      56: invokeinterface #534,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      61: pop
      62: goto          277
      65: aload_1
      66: checkcast     #536                // class java/lang/CharSequence
      69: invokestatic  #542                // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z
      72: ifne          79
      75: iconst_1
      76: goto          80
      79: iconst_0
      80: ifeq          277
      83: aload_1
      84: checkcast     #536                // class java/lang/CharSequence
      87: iconst_1
      88: anewarray     #285                // class java/lang/String
      91: astore_3
      92: aload_3
      93: iconst_0
      94: ldc_w         #544                // String ,
      97: aastore
      98: aload_3
      99: iconst_0
     100: iconst_0
     101: bipush        6
     103: aconst_null
     104: invokestatic  #548                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     107: checkcast     #106                // class java/lang/Iterable
     110: astore_3
     111: iconst_0
     112: istore        4
     114: aload_3
     115: astore        5
     117: new           #108                // class java/util/ArrayList
     120: dup
     121: aload_3
     122: bipush        10
     124: invokestatic  #378                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     127: invokespecial #215                // Method java/util/ArrayList."<init>":(I)V
     130: checkcast     #111                // class java/util/Collection
     133: astore        6
     135: iconst_0
     136: istore        7
     138: aload         5
     140: invokeinterface #115,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     145: astore        8
     147: aload         8
     149: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     154: ifeq          201
     157: aload         8
     159: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     164: astore        9
     166: aload         6
     168: aload         9
     170: checkcast     #285                // class java/lang/String
     173: astore        10
     175: astore        12
     177: iconst_0
     178: istore        11
     180: aload         10
     182: invokestatic  #552                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     185: nop
     186: invokestatic  #92                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     189: aload         12
     191: swap
     192: invokeinterface #374,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     197: pop
     198: goto          147
     201: aload         6
     203: checkcast     #83                 // class java/util/List
     206: nop
     207: astore_2
     208: aload_2
     209: iconst_0
     210: invokeinterface #228,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     215: checkcast     #130                // class java/lang/Number
     218: invokevirtual #134                // Method java/lang/Number.intValue:()I
     221: istore_3
     222: aload_2
     223: iconst_1
     224: invokeinterface #228,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     229: checkcast     #130                // class java/lang/Number
     232: invokevirtual #134                // Method java/lang/Number.intValue:()I
     235: istore        4
     237: aload_2
     238: iconst_2
     239: invokeinterface #228,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     244: checkcast     #130                // class java/lang/Number
     247: invokevirtual #134                // Method java/lang/Number.intValue:()I
     250: istore        5
     252: aload_0
     253: invokestatic  #555                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     256: checkcast     #83                 // class java/util/List
     259: new           #241                // class day19/Point
     262: dup
     263: iload_3
     264: iload         4
     266: iload         5
     268: invokespecial #253                // Method day19/Point."<init>":(III)V
     271: invokeinterface #534,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     276: pop
     277: getstatic     #561                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     280: areturn
}


package be.amedee.adventofcode.aoc2015.day01

import java.io.BufferedReader
import java.io.InputStreamReader

/**
 * Single move to the next floor, up or down.
 *
 * @return do we go up or down
 */
fun move(): (String) -> Int =
    {
        when (it) {
            "(" -> 1
            ")" -> -1
            else -> 0
        }
    }

/**
 * The entire list of elevator instructions.
 *
 * @return at which floor Santa ends up
 */
fun followInstructions(): (String) -> Int =
    { instructionList ->
        instructionList
            .toList()
            .sumOf { move()(it.toString()) }
    }

/**
 * Find the position of the first character that causes Santa to enter the
 * basement (floor -1). The first character in the instructions has
 * position 1, the second character has position 2, and so on.
 */
fun findBasementPosition(instructions: String): Int {
    var floor = 0
    return instructions.indexOfFirst {
        when (it) {
            '(' -> floor++
            ')' -> floor--
        }
        floor == -1
    } + 1
}

class Day01 {
    fun readElevatorInstructionsFromFile(fileName: String): String {
        val packageName = javaClass.`package`.name.replace(".", "/")
        val filePath = "/$packageName/$fileName"
        val inputStream = javaClass.getResourceAsStream(filePath)
        return BufferedReader(InputStreamReader(inputStream!!)).use { it.readText().trim() }
    }
}

/**
 * Santa is trying to deliver presents in a large apartment building,
 * but he can't find the right floor - the directions he got are a little confusing.
 */
fun main() {
    val inputFile = "input"
    val puzzleInput = Day01().readElevatorInstructionsFromFile(inputFile)

    val endFloor = followInstructions()(puzzleInput)
    println("Santa ends up on floor $endFloor.")

    val basementPosition = findBasementPosition(puzzleInput)
    when (basementPosition) {
        0 -> println("Santa never enters the basement.")
        else -> println("Santa enters the basement at character position ${"%,d".format(basementPosition)}.")
    }
}

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

  public final java.lang.String readElevatorInstructionsFromFile(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #17                 // String fileName
       3: invokestatic  #23                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #27                 // Method java/lang/Object.getClass:()Ljava/lang/Class;
      10: invokevirtual #33                 // Method java/lang/Class.getPackage:()Ljava/lang/Package;
      13: invokevirtual #39                 // Method java/lang/Package.getName:()Ljava/lang/String;
      16: dup
      17: ldc           #41                 // String getName(...)
      19: invokestatic  #44                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      22: ldc           #46                 // String .
      24: ldc           #48                 // String /
      26: iconst_0
      27: iconst_4
      28: aconst_null
      29: invokestatic  #54                 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
      32: astore_2
      33: new           #56                 // class java/lang/StringBuilder
      36: dup
      37: invokespecial #57                 // Method java/lang/StringBuilder."<init>":()V
      40: bipush        47
      42: invokevirtual #61                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      45: aload_2
      46: invokevirtual #64                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      49: bipush        47
      51: invokevirtual #61                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      54: aload_1
      55: invokevirtual #64                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      58: invokevirtual #67                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      61: astore_3
      62: aload_0
      63: invokevirtual #27                 // Method java/lang/Object.getClass:()Ljava/lang/Class;
      66: aload_3
      67: invokevirtual #71                 // Method java/lang/Class.getResourceAsStream:(Ljava/lang/String;)Ljava/io/InputStream;
      70: astore        4
      72: new           #73                 // class java/io/BufferedReader
      75: dup
      76: new           #75                 // class java/io/InputStreamReader
      79: dup
      80: aload         4
      82: dup
      83: invokestatic  #79                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      86: invokespecial #82                 // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;)V
      89: checkcast     #84                 // class java/io/Reader
      92: invokespecial #87                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;)V
      95: checkcast     #89                 // class java/io/Closeable
      98: astore        5
     100: aconst_null
     101: astore        6
     103: nop
     104: aload         5
     106: checkcast     #73                 // class java/io/BufferedReader
     109: astore        7
     111: iconst_0
     112: istore        8
     114: aload         7
     116: checkcast     #84                 // class java/io/Reader
     119: invokestatic  #95                 // Method kotlin/io/TextStreamsKt.readText:(Ljava/io/Reader;)Ljava/lang/String;
     122: checkcast     #97                 // class java/lang/CharSequence
     125: invokestatic  #101                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     128: invokevirtual #102                // Method java/lang/Object.toString:()Ljava/lang/String;
     131: nop
     132: astore        7
     134: aload         5
     136: aload         6
     138: invokestatic  #108                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     141: aload         7
     143: goto          167
     146: astore        8
     148: aload         8
     150: astore        6
     152: aload         8
     154: athrow
     155: astore        8
     157: aload         5
     159: aload         6
     161: invokestatic  #108                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     164: aload         8
     166: athrow
     167: areturn
    Exception table:
       from    to  target type
         103   134   146   Class java/lang/Throwable
         103   134   155   any
         146   155   155   any
         155   157   155   any
}

Compiled from "Day01.kt"
public final class be.amedee.adventofcode.aoc2015.day01.Day01Kt {
  public static final kotlin.jvm.functions.Function1<java.lang.String, java.lang.Integer> move();
    Code:
       0: invokedynamic #27,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
       5: areturn

  public static final kotlin.jvm.functions.Function1<java.lang.String, java.lang.Integer> followInstructions();
    Code:
       0: invokedynamic #33,  0             // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
       5: areturn

  public static final int findBasementPosition(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #36                 // String instructions
       3: invokestatic  #42                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_1
       8: aload_0
       9: checkcast     #44                 // class java/lang/CharSequence
      12: astore_2
      13: iconst_0
      14: istore_3
      15: iconst_0
      16: istore        4
      18: aload_2
      19: invokeinterface #48,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      24: istore        5
      26: iload         4
      28: iload         5
      30: if_icmpge     107
      33: aload_2
      34: iload         4
      36: invokeinterface #52,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
      41: istore        6
      43: iconst_0
      44: istore        7
      46: iload         6
      48: tableswitch   { // 40 to 41
                    40: 72
                    41: 79
               default: 83
          }
      72: iload_1
      73: iconst_1
      74: iadd
      75: istore_1
      76: goto          83
      79: iload_1
      80: iconst_m1
      81: iadd
      82: istore_1
      83: iload_1
      84: iconst_m1
      85: if_icmpne     92
      88: iconst_1
      89: goto          93
      92: iconst_0
      93: ifeq          101
      96: iload         4
      98: goto          108
     101: iinc          4, 1
     104: goto          26
     107: iconst_m1
     108: iconst_1
     109: iadd
     110: ireturn

  public static final void main();
    Code:
       0: ldc           #68                 // String input
       2: astore_0
       3: new           #70                 // class be/amedee/adventofcode/aoc2015/day01/Day01
       6: dup
       7: invokespecial #73                 // Method be/amedee/adventofcode/aoc2015/day01/Day01."<init>":()V
      10: aload_0
      11: invokevirtual #77                 // Method be/amedee/adventofcode/aoc2015/day01/Day01.readElevatorInstructionsFromFile:(Ljava/lang/String;)Ljava/lang/String;
      14: astore_1
      15: invokestatic  #79                 // Method followInstructions:()Lkotlin/jvm/functions/Function1;
      18: aload_1
      19: invokeinterface #83,  2           // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      24: checkcast     #85                 // class java/lang/Number
      27: invokevirtual #88                 // Method java/lang/Number.intValue:()I
      30: istore_2
      31: new           #90                 // class java/lang/StringBuilder
      34: dup
      35: invokespecial #91                 // Method java/lang/StringBuilder."<init>":()V
      38: ldc           #93                 // String Santa ends up on floor
      40: invokevirtual #97                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      43: iload_2
      44: invokevirtual #100                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      47: bipush        46
      49: invokevirtual #103                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      52: invokevirtual #107                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      55: getstatic     #113                // Field java/lang/System.out:Ljava/io/PrintStream;
      58: swap
      59: invokevirtual #119                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      62: aload_1
      63: invokestatic  #121                // Method findBasementPosition:(Ljava/lang/String;)I
      66: istore_3
      67: iload_3
      68: ifne          83
      71: ldc           #123                // String Santa never enters the basement.
      73: getstatic     #113                // Field java/lang/System.out:Ljava/io/PrintStream;
      76: swap
      77: invokevirtual #119                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      80: goto          154
      83: new           #90                 // class java/lang/StringBuilder
      86: dup
      87: invokespecial #91                 // Method java/lang/StringBuilder."<init>":()V
      90: ldc           #125                // String Santa enters the basement at character position
      92: invokevirtual #97                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      95: ldc           #127                // String %,d
      97: astore        4
      99: iconst_1
     100: anewarray     #4                  // class java/lang/Object
     103: astore        5
     105: aload         5
     107: iconst_0
     108: iload_3
     109: invokestatic  #133                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     112: aastore
     113: aload         5
     115: astore        5
     117: aload         4
     119: aload         5
     121: aload         5
     123: arraylength
     124: invokestatic  #139                // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;
     127: invokestatic  #143                // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
     130: dup
     131: ldc           #145                // String format(...)
     133: invokestatic  #148                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     136: invokevirtual #97                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     139: bipush        46
     141: invokevirtual #103                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     144: invokevirtual #107                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     147: getstatic     #113                // Field java/lang/System.out:Ljava/io/PrintStream;
     150: swap
     151: invokevirtual #119                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     154: return

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

  private static final int move$lambda$0(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #158                // String it
       3: invokestatic  #42                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: astore_1
       8: aload_1
       9: ldc           #160                // String (
      11: invokestatic  #164                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      14: ifeq          21
      17: iconst_1
      18: goto          35
      21: aload_1
      22: ldc           #166                // String )
      24: invokestatic  #164                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      27: ifeq          34
      30: iconst_m1
      31: goto          35
      34: iconst_0
      35: ireturn

  private static final int followInstructions$lambda$2(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #168                // String instructionList
       3: invokestatic  #42                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #44                 // class java/lang/CharSequence
      10: invokestatic  #174                // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;
      13: checkcast     #176                // class java/lang/Iterable
      16: astore_1
      17: iconst_0
      18: istore_2
      19: aload_1
      20: invokeinterface #180,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      25: astore_3
      26: aload_3
      27: invokeinterface #186,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      32: ifeq          89
      35: aload_3
      36: invokeinterface #190,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      41: astore        4
      43: iload_2
      44: aload         4
      46: checkcast     #192                // class java/lang/Character
      49: invokevirtual #196                // Method java/lang/Character.charValue:()C
      52: istore        5
      54: istore        7
      56: iconst_0
      57: istore        6
      59: invokestatic  #198                // Method move:()Lkotlin/jvm/functions/Function1;
      62: iload         5
      64: invokestatic  #201                // Method java/lang/String.valueOf:(C)Ljava/lang/String;
      67: invokeinterface #83,  2           // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      72: checkcast     #85                 // class java/lang/Number
      75: invokevirtual #88                 // Method java/lang/Number.intValue:()I
      78: istore        8
      80: iload         7
      82: iload         8
      84: iadd
      85: istore_2
      86: goto          26
      89: iload_2
      90: ireturn
}