import java.io.InputStream
import kotlin.math.absoluteValue

data class Sensor(val pos: Vec2, val range: Int)

class Day15 {
    companion object {
        private fun readSensors(input: InputStream?): Pair<List<Sensor>, Set<Vec2>> {
            if (input == null) {
                throw Exception("Input missing")
            }

            val numRegex = "[\\d\\-]+".toRegex()

            val coords = input.bufferedReader().useLines { lines ->
                lines.flatMap {
                    numRegex.findAll(it).map { res -> res.value.toInt() }
                }.toList()
            }

            val filled = coords.chunked(2).map { Vec2(it[0], it[1]) }.toSet()
            val sensors = coords.chunked(4)
                .map { Sensor(Vec2(it[0], it[1]), (it[0] - it[2]).absoluteValue + (it[1] - it[3]).absoluteValue) }

            return Pair(sensors, filled)
        }

        fun process(input: InputStream?, rowNum: Int): Long {
            val (sensors, filled) = readSensors(input)

            //sensors.forEach { println(it) }
            //filled.forEach { println(it) }

            val leftSensor = sensors.minBy { it.pos.x - it.range }
            val rightSensor = sensors.maxBy { it.pos.x + it.range }

            val minX = leftSensor.pos.x - leftSensor.range
            val maxX = rightSensor.pos.x + rightSensor.range

            println("$minX-$maxX: ${(minX - maxX).absoluteValue}")

            // val map = mutableListOf<Char>()

            val sum = (minX..maxX)
                .toList()
                .parallelStream()
                .map { x ->
                    val inRange = sensors.any { sensor ->
                        (sensor.pos.x - x).absoluteValue + (sensor.pos.y - rowNum).absoluteValue <= sensor.range
                    }
                    if (!inRange) {
                        // map.add('.')
                        0
                    } else {
                        if (filled.contains(Vec2(x, rowNum))) {
                            // map.add('.')
                            0
                        } else {
                            // map.add('#')
                            1
                        }
                    }
                }.filter { it != 0 }.count()

            // map.add('.')

            //println(map.joinToString("").trim('.').count { it == '.' })

            //File("C:\\Temp\\map_15.txt").writeText(map.joinToString(""))

            return sum
        }

        fun process2(input: InputStream?): Long {
            val (sensors, filled) = readSensors(input)

            var maxX = sensors.maxOf { it.pos.x }

            var current = Vec2(0, 0)

            var covering: Sensor? = null

            while (true) {
                covering = sensors.firstOrNull { sensor ->
                    sensor != covering &&
                            (sensor.pos.x - current.x).absoluteValue + (sensor.pos.y - current.y).absoluteValue <= sensor.range
                }

                if (covering == null) {
                    break
                }

                val newPos = ((covering.pos.x + covering.range) - (covering.pos.y - current.y).absoluteValue) + 1

                if (newPos < maxX) {
                    current.x = newPos
                } else {
                    current.x = 0
                    current.y++
                }
            }

            // println(current)

            return 4_000_000L * current.x.toLong() + current.y.toLong()
        }
    }

}

Compiled from "Day15.kt"
public final class Day15 {
  public static final Day15$Companion Companion;

  public Day15();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  static {};
    Code:
       0: new           #13                 // class Day15$Companion
       3: dup
       4: aconst_null
       5: invokespecial #16                 // Method Day15$Companion."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: putstatic     #20                 // Field Companion:LDay15$Companion;
      11: return
}

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

  private final kotlin.Pair<java.util.List<Sensor>, java.util.Set<Vec2>> readSensors(java.io.InputStream);
    Code:
       0: aload_1
       1: ifnonnull     14
       4: new           #17                 // class java/lang/Exception
       7: dup
       8: ldc           #19                 // String Input missing
      10: invokespecial #22                 // Method java/lang/Exception."<init>":(Ljava/lang/String;)V
      13: athrow
      14: new           #24                 // class kotlin/text/Regex
      17: dup
      18: ldc           #26                 // String [\\d\\-]+
      20: invokespecial #27                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      23: astore_2
      24: aload_1
      25: astore        4
      27: getstatic     #33                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      30: astore        5
      32: new           #35                 // class java/io/InputStreamReader
      35: dup
      36: aload         4
      38: aload         5
      40: invokespecial #38                 // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
      43: checkcast     #40                 // class java/io/Reader
      46: astore        6
      48: sipush        8192
      51: istore        7
      53: aload         6
      55: instanceof    #42                 // class java/io/BufferedReader
      58: ifeq          69
      61: aload         6
      63: checkcast     #42                 // class java/io/BufferedReader
      66: goto          80
      69: new           #42                 // class java/io/BufferedReader
      72: dup
      73: aload         6
      75: iload         7
      77: invokespecial #45                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
      80: checkcast     #40                 // class java/io/Reader
      83: astore        4
      85: nop
      86: iconst_0
      87: istore        5
      89: aload         4
      91: astore        6
      93: sipush        8192
      96: istore        7
      98: aload         6
     100: instanceof    #42                 // class java/io/BufferedReader
     103: ifeq          114
     106: aload         6
     108: checkcast     #42                 // class java/io/BufferedReader
     111: goto          125
     114: new           #42                 // class java/io/BufferedReader
     117: dup
     118: aload         6
     120: iload         7
     122: invokespecial #45                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
     125: checkcast     #47                 // class java/io/Closeable
     128: astore        6
     130: aconst_null
     131: astore        7
     133: nop
     134: aload         6
     136: checkcast     #42                 // class java/io/BufferedReader
     139: astore        8
     141: iconst_0
     142: istore        9
     144: aload         8
     146: invokestatic  #53                 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;
     149: astore        10
     151: iconst_0
     152: istore        11
     154: aload         10
     156: aload_2
     157: invokedynamic #73,  0             // InvokeDynamic #0:invoke:(Lkotlin/text/Regex;)Lkotlin/jvm/functions/Function1;
     162: invokestatic  #79                 // Method kotlin/sequences/SequencesKt.flatMap:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     165: invokestatic  #83                 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
     168: astore        8
     170: aload         6
     172: aload         7
     174: invokestatic  #89                 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     177: aload         8
     179: goto          203
     182: astore        9
     184: aload         9
     186: astore        7
     188: aload         9
     190: athrow
     191: astore        9
     193: aload         6
     195: aload         7
     197: invokestatic  #89                 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     200: aload         9
     202: athrow
     203: nop
     204: astore_3
     205: aload_3
     206: checkcast     #91                 // class java/lang/Iterable
     209: iconst_2
     210: invokestatic  #97                 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;
     213: checkcast     #91                 // class java/lang/Iterable
     216: astore        5
     218: iconst_0
     219: istore        6
     221: aload         5
     223: astore        7
     225: new           #99                 // class java/util/ArrayList
     228: dup
     229: aload         5
     231: bipush        10
     233: invokestatic  #103                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     236: invokespecial #106                // Method java/util/ArrayList."<init>":(I)V
     239: checkcast     #108                // class java/util/Collection
     242: astore        8
     244: iconst_0
     245: istore        9
     247: aload         7
     249: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     254: astore        10
     256: aload         10
     258: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     263: ifeq          336
     266: aload         10
     268: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     273: astore        11
     275: aload         8
     277: aload         11
     279: checkcast     #124                // class java/util/List
     282: astore        12
     284: astore        15
     286: iconst_0
     287: istore        13
     289: new           #126                // class Vec2
     292: dup
     293: aload         12
     295: iconst_0
     296: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     301: checkcast     #132                // class java/lang/Number
     304: invokevirtual #136                // Method java/lang/Number.intValue:()I
     307: aload         12
     309: iconst_1
     310: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     315: checkcast     #132                // class java/lang/Number
     318: invokevirtual #136                // Method java/lang/Number.intValue:()I
     321: invokespecial #139                // Method Vec2."<init>":(II)V
     324: aload         15
     326: swap
     327: invokeinterface #143,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     332: pop
     333: goto          256
     336: aload         8
     338: checkcast     #124                // class java/util/List
     341: nop
     342: checkcast     #91                 // class java/lang/Iterable
     345: invokestatic  #147                // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     348: astore        4
     350: aload_3
     351: checkcast     #91                 // class java/lang/Iterable
     354: iconst_4
     355: invokestatic  #97                 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;
     358: checkcast     #91                 // class java/lang/Iterable
     361: astore        6
     363: nop
     364: iconst_0
     365: istore        7
     367: aload         6
     369: astore        8
     371: new           #99                 // class java/util/ArrayList
     374: dup
     375: aload         6
     377: bipush        10
     379: invokestatic  #103                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     382: invokespecial #106                // Method java/util/ArrayList."<init>":(I)V
     385: checkcast     #108                // class java/util/Collection
     388: astore        9
     390: iconst_0
     391: istore        10
     393: aload         8
     395: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     400: astore        11
     402: aload         11
     404: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     409: ifeq          554
     412: aload         11
     414: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     419: astore        12
     421: aload         9
     423: aload         12
     425: checkcast     #124                // class java/util/List
     428: astore        13
     430: astore        15
     432: iconst_0
     433: istore        14
     435: new           #149                // class Sensor
     438: dup
     439: new           #126                // class Vec2
     442: dup
     443: aload         13
     445: iconst_0
     446: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     451: checkcast     #132                // class java/lang/Number
     454: invokevirtual #136                // Method java/lang/Number.intValue:()I
     457: aload         13
     459: iconst_1
     460: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     465: checkcast     #132                // class java/lang/Number
     468: invokevirtual #136                // Method java/lang/Number.intValue:()I
     471: invokespecial #139                // Method Vec2."<init>":(II)V
     474: aload         13
     476: iconst_0
     477: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     482: checkcast     #132                // class java/lang/Number
     485: invokevirtual #136                // Method java/lang/Number.intValue:()I
     488: aload         13
     490: iconst_2
     491: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     496: checkcast     #132                // class java/lang/Number
     499: invokevirtual #136                // Method java/lang/Number.intValue:()I
     502: isub
     503: invokestatic  #155                // Method java/lang/Math.abs:(I)I
     506: aload         13
     508: iconst_1
     509: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     514: checkcast     #132                // class java/lang/Number
     517: invokevirtual #136                // Method java/lang/Number.intValue:()I
     520: aload         13
     522: iconst_3
     523: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     528: checkcast     #132                // class java/lang/Number
     531: invokevirtual #136                // Method java/lang/Number.intValue:()I
     534: isub
     535: invokestatic  #155                // Method java/lang/Math.abs:(I)I
     538: iadd
     539: invokespecial #158                // Method Sensor."<init>":(LVec2;I)V
     542: aload         15
     544: swap
     545: invokeinterface #143,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     550: pop
     551: goto          402
     554: aload         9
     556: checkcast     #124                // class java/util/List
     559: nop
     560: astore        5
     562: new           #160                // class kotlin/Pair
     565: dup
     566: aload         5
     568: aload         4
     570: invokespecial #163                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     573: areturn
    Exception table:
       from    to  target type
         133   170   182   Class java/lang/Throwable
         133   170   191   any
         182   191   191   any
         191   193   191   any

  public final long process(java.io.InputStream, int);
    Code:
       0: aload_0
       1: aload_1
       2: invokespecial #207                // Method readSensors:(Ljava/io/InputStream;)Lkotlin/Pair;
       5: astore_3
       6: aload_3
       7: invokevirtual #210                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      10: checkcast     #124                // class java/util/List
      13: astore        4
      15: aload_3
      16: invokevirtual #213                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      19: checkcast     #202                // class java/util/Set
      22: astore        5
      24: aload         4
      26: checkcast     #91                 // class java/lang/Iterable
      29: astore        7
      31: iconst_0
      32: istore        8
      34: aload         7
      36: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      41: astore        9
      43: aload         9
      45: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifne          61
      53: new           #215                // class java/util/NoSuchElementException
      56: dup
      57: invokespecial #216                // Method java/util/NoSuchElementException."<init>":()V
      60: athrow
      61: aload         9
      63: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      68: astore        10
      70: aload         9
      72: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      77: ifne          85
      80: aload         10
      82: goto          173
      85: aload         10
      87: checkcast     #149                // class Sensor
      90: astore        11
      92: iconst_0
      93: istore        12
      95: aload         11
      97: invokevirtual #220                // Method Sensor.getPos:()LVec2;
     100: invokevirtual #223                // Method Vec2.getX:()I
     103: aload         11
     105: invokevirtual #226                // Method Sensor.getRange:()I
     108: isub
     109: istore        11
     111: aload         9
     113: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     118: astore        12
     120: aload         12
     122: checkcast     #149                // class Sensor
     125: astore        13
     127: iconst_0
     128: istore        14
     130: aload         13
     132: invokevirtual #220                // Method Sensor.getPos:()LVec2;
     135: invokevirtual #223                // Method Vec2.getX:()I
     138: aload         13
     140: invokevirtual #226                // Method Sensor.getRange:()I
     143: isub
     144: istore        13
     146: iload         11
     148: iload         13
     150: if_icmple     161
     153: aload         12
     155: astore        10
     157: iload         13
     159: istore        11
     161: aload         9
     163: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     168: ifne          111
     171: aload         10
     173: checkcast     #149                // class Sensor
     176: astore        6
     178: aload         4
     180: checkcast     #91                 // class java/lang/Iterable
     183: astore        8
     185: iconst_0
     186: istore        9
     188: aload         8
     190: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     195: astore        10
     197: aload         10
     199: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     204: ifne          215
     207: new           #215                // class java/util/NoSuchElementException
     210: dup
     211: invokespecial #216                // Method java/util/NoSuchElementException."<init>":()V
     214: athrow
     215: aload         10
     217: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     222: astore        11
     224: aload         10
     226: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     231: ifne          239
     234: aload         11
     236: goto          327
     239: aload         11
     241: checkcast     #149                // class Sensor
     244: astore        12
     246: iconst_0
     247: istore        13
     249: aload         12
     251: invokevirtual #220                // Method Sensor.getPos:()LVec2;
     254: invokevirtual #223                // Method Vec2.getX:()I
     257: aload         12
     259: invokevirtual #226                // Method Sensor.getRange:()I
     262: iadd
     263: istore        12
     265: aload         10
     267: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     272: astore        13
     274: aload         13
     276: checkcast     #149                // class Sensor
     279: astore        14
     281: iconst_0
     282: istore        15
     284: aload         14
     286: invokevirtual #220                // Method Sensor.getPos:()LVec2;
     289: invokevirtual #223                // Method Vec2.getX:()I
     292: aload         14
     294: invokevirtual #226                // Method Sensor.getRange:()I
     297: iadd
     298: istore        14
     300: iload         12
     302: iload         14
     304: if_icmpge     315
     307: aload         13
     309: astore        11
     311: iload         14
     313: istore        12
     315: aload         10
     317: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     322: ifne          265
     325: aload         11
     327: checkcast     #149                // class Sensor
     330: astore        7
     332: aload         6
     334: invokevirtual #220                // Method Sensor.getPos:()LVec2;
     337: invokevirtual #223                // Method Vec2.getX:()I
     340: aload         6
     342: invokevirtual #226                // Method Sensor.getRange:()I
     345: isub
     346: istore        8
     348: aload         7
     350: invokevirtual #220                // Method Sensor.getPos:()LVec2;
     353: invokevirtual #223                // Method Vec2.getX:()I
     356: aload         7
     358: invokevirtual #226                // Method Sensor.getRange:()I
     361: iadd
     362: istore        9
     364: new           #228                // class java/lang/StringBuilder
     367: dup
     368: invokespecial #229                // Method java/lang/StringBuilder."<init>":()V
     371: iload         8
     373: invokevirtual #233                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     376: bipush        45
     378: invokevirtual #236                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     381: iload         9
     383: invokevirtual #233                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     386: ldc           #238                // String :
     388: invokevirtual #241                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     391: iload         8
     393: iload         9
     395: isub
     396: invokestatic  #155                // Method java/lang/Math.abs:(I)I
     399: invokevirtual #233                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     402: invokevirtual #245                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     405: getstatic     #251                // Field java/lang/System.out:Ljava/io/PrintStream;
     408: swap
     409: invokevirtual #257                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     412: new           #259                // class kotlin/ranges/IntRange
     415: dup
     416: iload         8
     418: iload         9
     420: invokespecial #260                // Method kotlin/ranges/IntRange."<init>":(II)V
     423: checkcast     #91                 // class java/lang/Iterable
     426: invokestatic  #263                // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     429: invokeinterface #267,  1          // InterfaceMethod java/util/List.parallelStream:()Ljava/util/stream/Stream;
     434: aload         4
     436: aload         5
     438: iload_2
     439: invokedynamic #277,  0            // InvokeDynamic #1:invoke:(Ljava/util/List;Ljava/util/Set;I)Lkotlin/jvm/functions/Function1;
     444: invokedynamic #288,  0            // InvokeDynamic #2:apply:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Function;
     449: invokeinterface #294,  2          // InterfaceMethod java/util/stream/Stream.map:(Ljava/util/function/Function;)Ljava/util/stream/Stream;
     454: invokedynamic #304,  0            // InvokeDynamic #3:invoke:()Lkotlin/jvm/functions/Function1;
     459: invokedynamic #314,  0            // InvokeDynamic #4:test:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Predicate;
     464: invokeinterface #318,  2          // InterfaceMethod java/util/stream/Stream.filter:(Ljava/util/function/Predicate;)Ljava/util/stream/Stream;
     469: invokeinterface #322,  1          // InterfaceMethod java/util/stream/Stream.count:()J
     474: lstore        10
     476: lload         10
     478: lreturn

  public final long process2(java.io.InputStream);
    Code:
       0: aload_0
       1: aload_1
       2: invokespecial #207                // Method readSensors:(Ljava/io/InputStream;)Lkotlin/Pair;
       5: astore_2
       6: aload_2
       7: invokevirtual #210                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      10: checkcast     #124                // class java/util/List
      13: astore_3
      14: aload_2
      15: invokevirtual #213                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      18: checkcast     #202                // class java/util/Set
      21: astore        4
      23: aload_3
      24: checkcast     #91                 // class java/lang/Iterable
      27: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      32: astore        7
      34: aload         7
      36: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      41: ifne          52
      44: new           #215                // class java/util/NoSuchElementException
      47: dup
      48: invokespecial #216                // Method java/util/NoSuchElementException."<init>":()V
      51: athrow
      52: aload         7
      54: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      59: checkcast     #149                // class Sensor
      62: astore        8
      64: iconst_0
      65: istore        9
      67: aload         8
      69: invokevirtual #220                // Method Sensor.getPos:()LVec2;
      72: invokevirtual #223                // Method Vec2.getX:()I
      75: istore        8
      77: aload         7
      79: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      84: ifeq          126
      87: aload         7
      89: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      94: checkcast     #149                // class Sensor
      97: astore        9
      99: iconst_0
     100: istore        10
     102: aload         9
     104: invokevirtual #220                // Method Sensor.getPos:()LVec2;
     107: invokevirtual #223                // Method Vec2.getX:()I
     110: istore        9
     112: iload         8
     114: iload         9
     116: if_icmpge     77
     119: iload         9
     121: istore        8
     123: goto          77
     126: iload         8
     128: istore        5
     130: aconst_null
     131: astore        6
     133: new           #126                // class Vec2
     136: dup
     137: iconst_0
     138: iconst_0
     139: invokespecial #139                // Method Vec2."<init>":(II)V
     142: astore        6
     144: aconst_null
     145: astore        7
     147: nop
     148: aload_3
     149: checkcast     #91                 // class java/lang/Iterable
     152: astore        8
     154: iconst_0
     155: istore        9
     157: aload         8
     159: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     164: astore        10
     166: aload         10
     168: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     173: ifeq          261
     176: aload         10
     178: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     183: astore        11
     185: aload         11
     187: checkcast     #149                // class Sensor
     190: astore        12
     192: iconst_0
     193: istore        13
     195: aload         12
     197: aload         7
     199: invokestatic  #352                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     202: ifne          252
     205: aload         12
     207: invokevirtual #220                // Method Sensor.getPos:()LVec2;
     210: invokevirtual #223                // Method Vec2.getX:()I
     213: aload         6
     215: invokevirtual #223                // Method Vec2.getX:()I
     218: isub
     219: invokestatic  #155                // Method java/lang/Math.abs:(I)I
     222: aload         12
     224: invokevirtual #220                // Method Sensor.getPos:()LVec2;
     227: invokevirtual #355                // Method Vec2.getY:()I
     230: aload         6
     232: invokevirtual #355                // Method Vec2.getY:()I
     235: isub
     236: invokestatic  #155                // Method java/lang/Math.abs:(I)I
     239: iadd
     240: aload         12
     242: invokevirtual #226                // Method Sensor.getRange:()I
     245: if_icmpgt     252
     248: iconst_1
     249: goto          253
     252: iconst_0
     253: ifeq          166
     256: aload         11
     258: goto          262
     261: aconst_null
     262: astore        7
     264: aload         7
     266: ifnonnull     272
     269: goto          366
     272: aload         7
     274: checkcast     #149                // class Sensor
     277: invokevirtual #220                // Method Sensor.getPos:()LVec2;
     280: invokevirtual #223                // Method Vec2.getX:()I
     283: aload         7
     285: checkcast     #149                // class Sensor
     288: invokevirtual #226                // Method Sensor.getRange:()I
     291: iadd
     292: aload         7
     294: checkcast     #149                // class Sensor
     297: invokevirtual #220                // Method Sensor.getPos:()LVec2;
     300: invokevirtual #355                // Method Vec2.getY:()I
     303: aload         6
     305: invokevirtual #355                // Method Vec2.getY:()I
     308: isub
     309: invokestatic  #155                // Method java/lang/Math.abs:(I)I
     312: isub
     313: iconst_1
     314: iadd
     315: istore        8
     317: iload         8
     319: iload         5
     321: if_icmpge     334
     324: aload         6
     326: iload         8
     328: invokevirtual #358                // Method Vec2.setX:(I)V
     331: goto          147
     334: aload         6
     336: iconst_0
     337: invokevirtual #358                // Method Vec2.setX:(I)V
     340: aload         6
     342: astore        9
     344: aload         9
     346: invokevirtual #355                // Method Vec2.getY:()I
     349: istore        10
     351: aload         9
     353: iload         10
     355: iconst_1
     356: iadd
     357: invokevirtual #361                // Method Vec2.setY:(I)V
     360: iload         10
     362: pop
     363: goto          147
     366: ldc2_w        #362                // long 4000000l
     369: aload         6
     371: invokevirtual #223                // Method Vec2.getX:()I
     374: i2l
     375: lmul
     376: aload         6
     378: invokevirtual #355                // Method Vec2.getY:()I
     381: i2l
     382: ladd
     383: lreturn

  private static final int readSensors$lambda$2$lambda$1$lambda$0(kotlin.text.MatchResult);
    Code:
       0: aload_0
       1: ldc_w         #376                // String res
       4: invokestatic  #380                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokeinterface #385,  1          // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;
      13: invokestatic  #391                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      16: ireturn

  private static final kotlin.sequences.Sequence readSensors$lambda$2$lambda$1(kotlin.text.Regex, java.lang.String);
    Code:
       0: aload_1
       1: ldc_w         #393                // String it
       4: invokestatic  #380                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: aload_1
       9: checkcast     #395                // class java/lang/CharSequence
      12: iconst_0
      13: iconst_2
      14: aconst_null
      15: invokestatic  #399                // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;
      18: invokedynamic #405,  0            // InvokeDynamic #5:invoke:()Lkotlin/jvm/functions/Function1;
      23: invokestatic  #407                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      26: areturn

  private static final java.lang.Integer process$lambda$8(java.util.List, java.util.Set, int, java.lang.Integer);
    Code:
       0: aload_0
       1: checkcast     #91                 // class java/lang/Iterable
       4: astore        5
       6: iconst_0
       7: istore        6
       9: aload         5
      11: instanceof    #108                // class java/util/Collection
      14: ifeq          34
      17: aload         5
      19: checkcast     #108                // class java/util/Collection
      22: invokeinterface #412,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      27: ifeq          34
      30: iconst_0
      31: goto          127
      34: aload         5
      36: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      41: astore        7
      43: aload         7
      45: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifeq          126
      53: aload         7
      55: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      60: astore        8
      62: aload         8
      64: checkcast     #149                // class Sensor
      67: astore        9
      69: iconst_0
      70: istore        10
      72: aload         9
      74: invokevirtual #220                // Method Sensor.getPos:()LVec2;
      77: invokevirtual #223                // Method Vec2.getX:()I
      80: aload_3
      81: invokestatic  #415                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      84: aload_3
      85: invokevirtual #416                // Method java/lang/Integer.intValue:()I
      88: isub
      89: invokestatic  #155                // Method java/lang/Math.abs:(I)I
      92: aload         9
      94: invokevirtual #220                // Method Sensor.getPos:()LVec2;
      97: invokevirtual #355                // Method Vec2.getY:()I
     100: iload_2
     101: isub
     102: invokestatic  #155                // Method java/lang/Math.abs:(I)I
     105: iadd
     106: aload         9
     108: invokevirtual #226                // Method Sensor.getRange:()I
     111: if_icmpgt     118
     114: iconst_1
     115: goto          119
     118: iconst_0
     119: ifeq          43
     122: iconst_1
     123: goto          127
     126: iconst_0
     127: istore        4
     129: iload         4
     131: ifne          138
     134: iconst_0
     135: goto          168
     138: aload_1
     139: new           #126                // class Vec2
     142: dup
     143: aload_3
     144: invokestatic  #415                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     147: aload_3
     148: invokevirtual #416                // Method java/lang/Integer.intValue:()I
     151: iload_2
     152: invokespecial #139                // Method Vec2."<init>":(II)V
     155: invokeinterface #419,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     160: ifeq          167
     163: iconst_0
     164: goto          168
     167: iconst_1
     168: invokestatic  #423                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     171: areturn

  private static final java.lang.Integer process$lambda$9(kotlin.jvm.functions.Function1, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: invokeinterface #437,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
       7: checkcast     #387                // class java/lang/Integer
      10: areturn

  private static final boolean process$lambda$10(java.lang.Integer);
    Code:
       0: aload_0
       1: dup
       2: ifnonnull     9
       5: pop
       6: goto          15
       9: invokevirtual #416                // Method java/lang/Integer.intValue:()I
      12: ifeq          19
      15: iconst_1
      16: goto          20
      19: iconst_0
      20: ireturn

  private static final boolean process$lambda$11(kotlin.jvm.functions.Function1, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: invokeinterface #437,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
       7: checkcast     #442                // class java/lang/Boolean
      10: invokevirtual #445                // Method java/lang/Boolean.booleanValue:()Z
      13: ireturn

  public Day15$Companion(kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: aload_0
       1: invokespecial #447                // Method "<init>":()V
       4: return
}


import java.io.InputStream

data class HeightMap(val start: List<Int>, val end: Int, val width: Int, val graph: List<List<Boolean>>)

class Day12 {
    companion object {
        private fun readMap(input: InputStream?, startTile: Char, endTile: Char): HeightMap {
            if (input == null) {
                throw Exception("Input missing")
            }

            var start = mutableListOf<Int>()
            var end = 0
            var width = 0

            val map = input.bufferedReader().readLines().flatMapIndexed { i, row ->
                width = row.length
                row.mapIndexed { j, tile ->
                    if (tile == startTile) {
                        start.add(i * width + j)
                    }
                    if (tile == endTile) {
                        end = i * width + j
                    }
                    when (tile) {
                        'S' -> {
                            'a'
                        }

                        'E' -> {
                            'z'
                        }

                        else -> {
                            tile
                        }
                    }
                }
            }

            val graph = MutableList(map.size) { MutableList(map.size) { false } }

            map.forEachIndexed { i, tile ->
                if (i % width + 1 < width) {
                    if (tile.code >= map[i + 1].code - 1) {
                        graph[i][i + 1] = true
                    }
                    if (tile.code <= map[i + 1].code + 1) {
                        graph[i + 1][i] = true
                    }
                }
                if (i + width < map.size) {
                    if (tile.code >= map[i + width].code - 1) {
                        graph[i][i + width] = true
                    }
                    if (tile.code <= map[i + width].code + 1) {
                        graph[i + width][i] = true
                    }
                }
            }

            return HeightMap(start, end, width, graph)
        }

        private fun findPath(graph: List<List<Boolean>>, width: Int, start: Int, end: Int): Int {
            val numOfVertices = graph.size

            val visitedAndDistance = List(numOfVertices) { mutableListOf(0, Int.MAX_VALUE) }

            visitedAndDistance[start][1] = 0

            fun nextToVisit(): Int {
                var v = -1
                for (i in 0 until numOfVertices) {
                    if (visitedAndDistance[i][0] == 0 && (v < 0 || visitedAndDistance[i][1] <= visitedAndDistance[v][1])) {
                        v = i
                    }
                }

                return v
            }

            repeat(numOfVertices) {
                val toVisit = nextToVisit()
                for (i in listOf(toVisit - 1, toVisit + 1, toVisit + width, toVisit - width)) {
                    if (i in 0 until numOfVertices && graph[toVisit][i] && visitedAndDistance[i][0] == 0) {
                        val newDistance = visitedAndDistance[toVisit][1] + 1
                        if (visitedAndDistance[i][1] > newDistance) {
                            visitedAndDistance[i][1] = newDistance
                            if (i == end) {
                                return newDistance
                            }
                        }
                    }
                    visitedAndDistance[toVisit][0] = 1
                }
            }

            return -1
        }

        fun process(input: InputStream?): Int {
            val heightMap = readMap(input, 'S', 'E')

            //heightMap.graph.forEach { println(it) }

            return findPath(heightMap.graph, heightMap.width, heightMap.start[0], heightMap.end)
        }

        fun process2(input: InputStream?): Int {
            val heightMap = readMap(input, 'a', 'E')

            var i = 0

            val lengths = heightMap.start.parallelStream().map {
                findPath(heightMap.graph, heightMap.width, it, heightMap.end)
            }.map {
                i++
                println("$i of ${heightMap.start.size} Done: $it")
                it
            }
                .filter { it > 0 }

            return lengths.min(Integer::compare).get()
        }
    }

}

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

  private final HeightMap readMap(java.io.InputStream, char, char);
    Code:
       0: aload_1
       1: ifnonnull     14
       4: new           #14                 // class java/lang/Exception
       7: dup
       8: ldc           #16                 // String Input missing
      10: invokespecial #19                 // Method java/lang/Exception."<init>":(Ljava/lang/String;)V
      13: athrow
      14: aconst_null
      15: astore        4
      17: new           #21                 // class java/util/ArrayList
      20: dup
      21: invokespecial #22                 // Method java/util/ArrayList."<init>":()V
      24: checkcast     #24                 // class java/util/List
      27: astore        4
      29: iconst_0
      30: istore        5
      32: iconst_0
      33: istore        6
      35: aload_1
      36: astore        8
      38: getstatic     #30                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      41: astore        9
      43: new           #32                 // class java/io/InputStreamReader
      46: dup
      47: aload         8
      49: aload         9
      51: invokespecial #35                 // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
      54: checkcast     #37                 // class java/io/Reader
      57: astore        10
      59: sipush        8192
      62: istore        11
      64: aload         10
      66: instanceof    #39                 // class java/io/BufferedReader
      69: ifeq          80
      72: aload         10
      74: checkcast     #39                 // class java/io/BufferedReader
      77: goto          91
      80: new           #39                 // class java/io/BufferedReader
      83: dup
      84: aload         10
      86: iload         11
      88: invokespecial #42                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
      91: checkcast     #37                 // class java/io/Reader
      94: invokestatic  #48                 // Method kotlin/io/TextStreamsKt.readLines:(Ljava/io/Reader;)Ljava/util/List;
      97: checkcast     #50                 // class java/lang/Iterable
     100: astore        9
     102: new           #21                 // class java/util/ArrayList
     105: dup
     106: invokespecial #22                 // Method java/util/ArrayList."<init>":()V
     109: checkcast     #52                 // class java/util/Collection
     112: astore        10
     114: iconst_0
     115: istore        11
     117: aload         9
     119: invokeinterface #56,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     124: astore        12
     126: aload         12
     128: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     133: ifeq          383
     136: aload         12
     138: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     143: astore        13
     145: iload         11
     147: iinc          11, 1
     150: istore        14
     152: iload         14
     154: ifge          160
     157: invokestatic  #71                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     160: iload         14
     162: aload         13
     164: checkcast     #73                 // class java/lang/String
     167: astore        15
     169: istore        16
     171: iconst_0
     172: istore        17
     174: aload         15
     176: invokevirtual #77                 // Method java/lang/String.length:()I
     179: istore        6
     181: aload         15
     183: checkcast     #79                 // class java/lang/CharSequence
     186: astore        18
     188: iconst_0
     189: istore        19
     191: aload         18
     193: astore        20
     195: new           #21                 // class java/util/ArrayList
     198: dup
     199: aload         18
     201: invokeinterface #80,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     206: invokespecial #83                 // Method java/util/ArrayList."<init>":(I)V
     209: checkcast     #52                 // class java/util/Collection
     212: astore        21
     214: iconst_0
     215: istore        22
     217: iconst_0
     218: istore        23
     220: iconst_0
     221: istore        24
     223: iload         24
     225: aload         20
     227: invokeinterface #80,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     232: if_icmpge     363
     235: aload         20
     237: iload         24
     239: invokeinterface #87,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     244: istore        25
     246: aload         21
     248: iload         23
     250: iinc          23, 1
     253: iload         25
     255: istore        26
     257: istore        27
     259: astore        28
     261: iconst_0
     262: istore        29
     264: iload         26
     266: iload_2
     267: if_icmpne     289
     270: aload         4
     272: iload         16
     274: iload         6
     276: imul
     277: iload         27
     279: iadd
     280: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     283: invokeinterface #97,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     288: pop
     289: iload         26
     291: iload_3
     292: if_icmpne     305
     295: iload         16
     297: iload         6
     299: imul
     300: iload         27
     302: iadd
     303: istore        5
     305: iload         26
     307: lookupswitch  { // 2
                    69: 337
                    83: 332
               default: 342
          }
     332: bipush        97
     334: goto          344
     337: bipush        122
     339: goto          344
     342: iload         26
     344: nop
     345: invokestatic  #102                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     348: aload         28
     350: swap
     351: invokeinterface #103,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     356: pop
     357: iinc          24, 1
     360: goto          223
     363: aload         21
     365: checkcast     #24                 // class java/util/List
     368: nop
     369: checkcast     #50                 // class java/lang/Iterable
     372: nop
     373: aload         10
     375: swap
     376: invokestatic  #107                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     379: pop
     380: goto          126
     383: aload         10
     385: checkcast     #24                 // class java/util/List
     388: astore        7
     390: aload         7
     392: invokeinterface #110,  1          // InterfaceMethod java/util/List.size:()I
     397: istore        9
     399: new           #21                 // class java/util/ArrayList
     402: dup
     403: iload         9
     405: invokespecial #83                 // Method java/util/ArrayList."<init>":(I)V
     408: astore        10
     410: iconst_0
     411: istore        11
     413: iload         11
     415: iload         9
     417: if_icmpge     516
     420: iload         11
     422: istore        12
     424: aload         10
     426: iload         12
     428: istore        13
     430: astore        30
     432: iconst_0
     433: istore        14
     435: aload         7
     437: invokeinterface #110,  1          // InterfaceMethod java/util/List.size:()I
     442: istore        15
     444: new           #21                 // class java/util/ArrayList
     447: dup
     448: iload         15
     450: invokespecial #83                 // Method java/util/ArrayList."<init>":(I)V
     453: astore        16
     455: iconst_0
     456: istore        17
     458: iload         17
     460: iload         15
     462: if_icmpge     497
     465: iload         17
     467: istore        18
     469: aload         16
     471: iload         18
     473: istore        19
     475: astore        20
     477: iconst_0
     478: istore        21
     480: iconst_0
     481: invokestatic  #115                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     484: aload         20
     486: swap
     487: invokevirtual #116                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     490: pop
     491: iinc          17, 1
     494: goto          458
     497: aload         16
     499: checkcast     #24                 // class java/util/List
     502: nop
     503: aload         30
     505: swap
     506: invokevirtual #116                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     509: pop
     510: iinc          11, 1
     513: goto          413
     516: aload         10
     518: checkcast     #24                 // class java/util/List
     521: astore        8
     523: aload         7
     525: checkcast     #50                 // class java/lang/Iterable
     528: astore        9
     530: iconst_0
     531: istore        10
     533: iconst_0
     534: istore        11
     536: aload         9
     538: invokeinterface #56,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     543: astore        12
     545: aload         12
     547: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     552: ifeq          832
     555: aload         12
     557: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     562: astore        13
     564: iload         11
     566: iinc          11, 1
     569: istore        14
     571: iload         14
     573: ifge          579
     576: invokestatic  #71                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     579: iload         14
     581: aload         13
     583: checkcast     #99                 // class java/lang/Character
     586: invokevirtual #120                // Method java/lang/Character.charValue:()C
     589: istore        15
     591: istore        16
     593: iconst_0
     594: istore        17
     596: iload         16
     598: iload         6
     600: irem
     601: iconst_1
     602: iadd
     603: iload         6
     605: if_icmpge     708
     608: iload         15
     610: aload         7
     612: iload         16
     614: iconst_1
     615: iadd
     616: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     621: checkcast     #99                 // class java/lang/Character
     624: invokevirtual #120                // Method java/lang/Character.charValue:()C
     627: iconst_1
     628: isub
     629: if_icmplt     658
     632: aload         8
     634: iload         16
     636: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     641: checkcast     #24                 // class java/util/List
     644: iload         16
     646: iconst_1
     647: iadd
     648: iconst_1
     649: invokestatic  #115                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     652: invokeinterface #128,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     657: pop
     658: iload         15
     660: aload         7
     662: iload         16
     664: iconst_1
     665: iadd
     666: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     671: checkcast     #99                 // class java/lang/Character
     674: invokevirtual #120                // Method java/lang/Character.charValue:()C
     677: iconst_1
     678: iadd
     679: if_icmpgt     708
     682: aload         8
     684: iload         16
     686: iconst_1
     687: iadd
     688: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     693: checkcast     #24                 // class java/util/List
     696: iload         16
     698: iconst_1
     699: invokestatic  #115                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     702: invokeinterface #128,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     707: pop
     708: iload         16
     710: iload         6
     712: iadd
     713: aload         7
     715: invokeinterface #110,  1          // InterfaceMethod java/util/List.size:()I
     720: if_icmpge     827
     723: iload         15
     725: aload         7
     727: iload         16
     729: iload         6
     731: iadd
     732: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     737: checkcast     #99                 // class java/lang/Character
     740: invokevirtual #120                // Method java/lang/Character.charValue:()C
     743: iconst_1
     744: isub
     745: if_icmplt     775
     748: aload         8
     750: iload         16
     752: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     757: checkcast     #24                 // class java/util/List
     760: iload         16
     762: iload         6
     764: iadd
     765: iconst_1
     766: invokestatic  #115                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     769: invokeinterface #128,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     774: pop
     775: iload         15
     777: aload         7
     779: iload         16
     781: iload         6
     783: iadd
     784: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     789: checkcast     #99                 // class java/lang/Character
     792: invokevirtual #120                // Method java/lang/Character.charValue:()C
     795: iconst_1
     796: iadd
     797: if_icmpgt     827
     800: aload         8
     802: iload         16
     804: iload         6
     806: iadd
     807: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     812: checkcast     #24                 // class java/util/List
     815: iload         16
     817: iconst_1
     818: invokestatic  #115                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     821: invokeinterface #128,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     826: pop
     827: nop
     828: nop
     829: goto          545
     832: nop
     833: new           #130                // class HeightMap
     836: dup
     837: aload         4
     839: iload         5
     841: iload         6
     843: aload         8
     845: invokespecial #133                // Method HeightMap."<init>":(Ljava/util/List;IILjava/util/List;)V
     848: areturn

  private final int findPath(java.util.List<? extends java.util.List<java.lang.Boolean>>, int, int, int);
    Code:
       0: aload_1
       1: invokeinterface #110,  1          // InterfaceMethod java/util/List.size:()I
       6: istore        5
       8: new           #21                 // class java/util/ArrayList
      11: dup
      12: iload         5
      14: invokespecial #83                 // Method java/util/ArrayList."<init>":(I)V
      17: astore        7
      19: iconst_0
      20: istore        8
      22: iload         8
      24: iload         5
      26: if_icmpge     85
      29: iload         8
      31: istore        9
      33: aload         7
      35: iload         9
      37: istore        10
      39: astore        14
      41: iconst_0
      42: istore        11
      44: iconst_2
      45: anewarray     #89                 // class java/lang/Integer
      48: astore        12
      50: aload         12
      52: iconst_0
      53: iconst_0
      54: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      57: aastore
      58: aload         12
      60: iconst_1
      61: ldc           #179                // int 2147483647
      63: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      66: aastore
      67: aload         12
      69: invokestatic  #183                // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
      72: aload         14
      74: swap
      75: invokevirtual #116                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      78: pop
      79: iinc          8, 1
      82: goto          22
      85: aload         7
      87: checkcast     #24                 // class java/util/List
      90: astore        6
      92: aload         6
      94: iload_3
      95: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     100: checkcast     #24                 // class java/util/List
     103: iconst_1
     104: iconst_0
     105: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     108: invokeinterface #128,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     113: pop
     114: iconst_0
     115: istore        7
     117: iload         7
     119: iload         5
     121: if_icmpge     430
     124: iload         7
     126: istore        8
     128: iconst_0
     129: istore        9
     131: iload         5
     133: aload         6
     135: invokestatic  #187                // Method findPath$nextToVisit:(ILjava/util/List;)I
     138: istore        10
     140: iconst_4
     141: anewarray     #89                 // class java/lang/Integer
     144: astore        11
     146: aload         11
     148: iconst_0
     149: iload         10
     151: iconst_1
     152: isub
     153: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     156: aastore
     157: aload         11
     159: iconst_1
     160: iload         10
     162: iconst_1
     163: iadd
     164: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     167: aastore
     168: aload         11
     170: iconst_2
     171: iload         10
     173: iload_2
     174: iadd
     175: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     178: aastore
     179: aload         11
     181: iconst_3
     182: iload         10
     184: iload_2
     185: isub
     186: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     189: aastore
     190: aload         11
     192: invokestatic  #190                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     195: invokeinterface #191,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     200: astore        12
     202: aload         12
     204: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     209: ifeq          423
     212: aload         12
     214: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     219: checkcast     #193                // class java/lang/Number
     222: invokevirtual #196                // Method java/lang/Number.intValue:()I
     225: istore        11
     227: iconst_0
     228: iload         11
     230: if_icmpgt     248
     233: iload         11
     235: iload         5
     237: if_icmpge     244
     240: iconst_1
     241: goto          249
     244: iconst_0
     245: goto          249
     248: iconst_0
     249: ifeq          397
     252: aload_1
     253: iload         10
     255: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     260: checkcast     #24                 // class java/util/List
     263: iload         11
     265: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     270: checkcast     #112                // class java/lang/Boolean
     273: invokevirtual #199                // Method java/lang/Boolean.booleanValue:()Z
     276: ifeq          397
     279: aload         6
     281: iload         11
     283: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     288: checkcast     #24                 // class java/util/List
     291: iconst_0
     292: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     297: checkcast     #193                // class java/lang/Number
     300: invokevirtual #196                // Method java/lang/Number.intValue:()I
     303: ifne          397
     306: aload         6
     308: iload         10
     310: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     315: checkcast     #24                 // class java/util/List
     318: iconst_1
     319: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     324: checkcast     #193                // class java/lang/Number
     327: invokevirtual #196                // Method java/lang/Number.intValue:()I
     330: iconst_1
     331: iadd
     332: istore        13
     334: aload         6
     336: iload         11
     338: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     343: checkcast     #24                 // class java/util/List
     346: iconst_1
     347: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     352: checkcast     #193                // class java/lang/Number
     355: invokevirtual #196                // Method java/lang/Number.intValue:()I
     358: iload         13
     360: if_icmple     397
     363: aload         6
     365: iload         11
     367: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     372: checkcast     #24                 // class java/util/List
     375: iconst_1
     376: iload         13
     378: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     381: invokeinterface #128,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     386: pop
     387: iload         11
     389: iload         4
     391: if_icmpne     397
     394: iload         13
     396: ireturn
     397: aload         6
     399: iload         10
     401: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     406: checkcast     #24                 // class java/util/List
     409: iconst_0
     410: iconst_1
     411: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     414: invokeinterface #128,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     419: pop
     420: goto          202
     423: nop
     424: iinc          7, 1
     427: goto          117
     430: iconst_m1
     431: ireturn

  public final int process(java.io.InputStream);
    Code:
       0: aload_0
       1: aload_1
       2: bipush        83
       4: bipush        69
       6: invokespecial #210                // Method readMap:(Ljava/io/InputStream;CC)LHeightMap;
       9: astore_2
      10: aload_0
      11: aload_2
      12: invokevirtual #214                // Method HeightMap.getGraph:()Ljava/util/List;
      15: aload_2
      16: invokevirtual #217                // Method HeightMap.getWidth:()I
      19: aload_2
      20: invokevirtual #220                // Method HeightMap.getStart:()Ljava/util/List;
      23: iconst_0
      24: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      29: checkcast     #193                // class java/lang/Number
      32: invokevirtual #196                // Method java/lang/Number.intValue:()I
      35: aload_2
      36: invokevirtual #223                // Method HeightMap.getEnd:()I
      39: invokespecial #225                // Method findPath:(Ljava/util/List;III)I
      42: ireturn

  public final int process2(java.io.InputStream);
    Code:
       0: aload_0
       1: aload_1
       2: bipush        97
       4: bipush        69
       6: invokespecial #210                // Method readMap:(Ljava/io/InputStream;CC)LHeightMap;
       9: astore_2
      10: new           #230                // class kotlin/jvm/internal/Ref$IntRef
      13: dup
      14: invokespecial #231                // Method kotlin/jvm/internal/Ref$IntRef."<init>":()V
      17: astore_3
      18: aload_2
      19: invokevirtual #220                // Method HeightMap.getStart:()Ljava/util/List;
      22: invokeinterface #235,  1          // InterfaceMethod java/util/List.parallelStream:()Ljava/util/stream/Stream;
      27: aload_2
      28: invokedynamic #255,  0            // InvokeDynamic #0:invoke:(LHeightMap;)Lkotlin/jvm/functions/Function1;
      33: invokedynamic #266,  0            // InvokeDynamic #1:apply:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Function;
      38: invokeinterface #271,  2          // InterfaceMethod java/util/stream/Stream.map:(Ljava/util/function/Function;)Ljava/util/stream/Stream;
      43: aload_3
      44: aload_2
      45: invokedynamic #279,  0            // InvokeDynamic #2:invoke:(Lkotlin/jvm/internal/Ref$IntRef;LHeightMap;)Lkotlin/jvm/functions/Function1;
      50: invokedynamic #284,  0            // InvokeDynamic #3:apply:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Function;
      55: invokeinterface #271,  2          // InterfaceMethod java/util/stream/Stream.map:(Ljava/util/function/Function;)Ljava/util/stream/Stream;
      60: invokedynamic #294,  0            // InvokeDynamic #4:invoke:()Lkotlin/jvm/functions/Function1;
      65: invokedynamic #304,  0            // InvokeDynamic #5:test:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Predicate;
      70: invokeinterface #308,  2          // InterfaceMethod java/util/stream/Stream.filter:(Ljava/util/function/Predicate;)Ljava/util/stream/Stream;
      75: astore        4
      77: aload         4
      79: getstatic     #314                // Field Day12$Companion$process2$1.INSTANCE:LDay12$Companion$process2$1;
      82: checkcast     #316                // class kotlin/jvm/functions/Function2
      85: invokedynamic #327,  0            // InvokeDynamic #6:compare:(Lkotlin/jvm/functions/Function2;)Ljava/util/Comparator;
      90: invokeinterface #331,  2          // InterfaceMethod java/util/stream/Stream.min:(Ljava/util/Comparator;)Ljava/util/Optional;
      95: invokevirtual #335                // Method java/util/Optional.get:()Ljava/lang/Object;
      98: dup
      99: ldc_w         #337                // String get(...)
     102: invokestatic  #343                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     105: checkcast     #193                // class java/lang/Number
     108: invokevirtual #196                // Method java/lang/Number.intValue:()I
     111: ireturn

  private static final int findPath$nextToVisit(int, java.util.List<? extends java.util.List<java.lang.Integer>>);
    Code:
       0: iconst_m1
       1: istore_2
       2: iconst_0
       3: istore_3
       4: iload_3
       5: iload_0
       6: if_icmpge     93
       9: aload_1
      10: iload_3
      11: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      16: checkcast     #24                 // class java/util/List
      19: iconst_0
      20: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      25: checkcast     #193                // class java/lang/Number
      28: invokevirtual #196                // Method java/lang/Number.intValue:()I
      31: ifne          87
      34: iload_2
      35: iflt          85
      38: aload_1
      39: iload_3
      40: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      45: checkcast     #24                 // class java/util/List
      48: iconst_1
      49: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      54: checkcast     #193                // class java/lang/Number
      57: invokevirtual #196                // Method java/lang/Number.intValue:()I
      60: aload_1
      61: iload_2
      62: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      67: checkcast     #24                 // class java/util/List
      70: iconst_1
      71: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      76: checkcast     #193                // class java/lang/Number
      79: invokevirtual #196                // Method java/lang/Number.intValue:()I
      82: if_icmpgt     87
      85: iload_3
      86: istore_2
      87: iinc          3, 1
      90: goto          4
      93: iload_2
      94: ireturn

  private static final java.lang.Integer process2$lambda$7(HeightMap, java.lang.Integer);
    Code:
       0: getstatic     #353                // Field Day12.Companion:LDay12$Companion;
       3: aload_0
       4: invokevirtual #214                // Method HeightMap.getGraph:()Ljava/util/List;
       7: aload_0
       8: invokevirtual #217                // Method HeightMap.getWidth:()I
      11: aload_1
      12: invokestatic  #357                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      15: aload_1
      16: invokevirtual #358                // Method java/lang/Integer.intValue:()I
      19: aload_0
      20: invokevirtual #223                // Method HeightMap.getEnd:()I
      23: invokespecial #225                // Method findPath:(Ljava/util/List;III)I
      26: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      29: areturn

  private static final java.lang.Integer process2$lambda$8(kotlin.jvm.functions.Function1, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: invokeinterface #364,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
       7: checkcast     #89                 // class java/lang/Integer
      10: areturn

  private static final java.lang.Integer process2$lambda$9(kotlin.jvm.internal.Ref$IntRef, HeightMap, java.lang.Integer);
    Code:
       0: aload_0
       1: getfield      #370                // Field kotlin/jvm/internal/Ref$IntRef.element:I
       4: istore_3
       5: aload_0
       6: iload_3
       7: iconst_1
       8: iadd
       9: putfield      #370                // Field kotlin/jvm/internal/Ref$IntRef.element:I
      12: new           #372                // class java/lang/StringBuilder
      15: dup
      16: invokespecial #373                // Method java/lang/StringBuilder."<init>":()V
      19: aload_0
      20: getfield      #370                // Field kotlin/jvm/internal/Ref$IntRef.element:I
      23: invokevirtual #377                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      26: ldc_w         #379                // String  of
      29: invokevirtual #382                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      32: aload_1
      33: invokevirtual #220                // Method HeightMap.getStart:()Ljava/util/List;
      36: invokeinterface #110,  1          // InterfaceMethod java/util/List.size:()I
      41: invokevirtual #377                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      44: ldc_w         #384                // String  Done:
      47: invokevirtual #382                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      50: aload_2
      51: invokevirtual #387                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      54: invokevirtual #391                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      57: getstatic     #397                // Field java/lang/System.out:Ljava/io/PrintStream;
      60: swap
      61: invokevirtual #402                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      64: aload_2
      65: areturn

  private static final java.lang.Integer process2$lambda$10(kotlin.jvm.functions.Function1, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: invokeinterface #364,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
       7: checkcast     #89                 // class java/lang/Integer
      10: areturn

  private static final boolean process2$lambda$11(java.lang.Integer);
    Code:
       0: aload_0
       1: invokevirtual #358                // Method java/lang/Integer.intValue:()I
       4: ifle          11
       7: iconst_1
       8: goto          12
      11: iconst_0
      12: ireturn

  private static final boolean process2$lambda$12(kotlin.jvm.functions.Function1, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: invokeinterface #364,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
       7: checkcast     #112                // class java/lang/Boolean
      10: invokevirtual #199                // Method java/lang/Boolean.booleanValue:()Z
      13: ireturn

  private static final int process2$lambda$13(kotlin.jvm.functions.Function2, java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokeinterface #406,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
       8: checkcast     #193                // class java/lang/Number
      11: invokevirtual #196                // Method java/lang/Number.intValue:()I
      14: ireturn

  public Day12$Companion(kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: aload_0
       1: invokespecial #410                // Method "<init>":()V
       4: return
}

Compiled from "Day12.kt"
final class Day12$Companion$process2$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<java.lang.Integer, java.lang.Integer, java.lang.Integer> {
  public static final Day12$Companion$process2$1 INSTANCE;

  Day12$Companion$process2$1();
    Code:
       0: aload_0
       1: iconst_2
       2: ldc           #11                 // class java/lang/Integer
       4: ldc           #13                 // String compare
       6: ldc           #15                 // String compare(II)I
       8: iconst_0
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final java.lang.Integer invoke(int, int);
    Code:
       0: iload_1
       1: iload_2
       2: invokestatic  #25                 // Method java/lang/Integer.compare:(II)I
       5: invokestatic  #29                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
       8: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #35                 // class java/lang/Number
       5: invokevirtual #39                 // Method java/lang/Number.intValue:()I
       8: aload_2
       9: checkcast     #35                 // class java/lang/Number
      12: invokevirtual #39                 // Method java/lang/Number.intValue:()I
      15: invokevirtual #41                 // Method invoke:(II)Ljava/lang/Integer;
      18: areturn

  static {};
    Code:
       0: new           #2                  // class Day12$Companion$process2$1
       3: dup
       4: invokespecial #46                 // Method "<init>":()V
       7: putstatic     #49                 // Field INSTANCE:LDay12$Companion$process2$1;
      10: return
}

Compiled from "Day12.kt"
public final class Day12 {
  public static final Day12$Companion Companion;

  public Day12();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  static {};
    Code:
       0: new           #13                 // class Day12$Companion
       3: dup
       4: aconst_null
       5: invokespecial #16                 // Method Day12$Companion."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: putstatic     #20                 // Field Companion:LDay12$Companion;
      11: return
}