import java.io.File
import java.nio.charset.Charset.defaultCharset
import kotlin.streams.toList

typealias ChitonGrid = Map<Pair<Int, Int>, Day15.Square>

object Day15 {
    private fun toCoordinates(row: Int, line: String) = line.chars()
        .map(Character::getNumericValue)
        .toList()
        .mapIndexed { col, value -> (col to row) to Square((col to row), value) }

    private fun draw(coordinates: Collection<Square>) {
        println("\n")
        val maxCols = coordinates.maxOf { it.coord.first }
        val maxRows = coordinates.maxOf { it.coord.second }

        (0..maxRows).forEach { row ->
            (0..maxCols).forEach { col ->
                print(coordinates.find { it.coord == Pair(col, row) }?.let { it.risk } ?: ".")
            }
            println()
        }
    }

    data class Square(
        var coord: Pair<Int, Int>,
        var risk: Int,
        var distance: Int = Int.MAX_VALUE,
        var parent: Square? = null
    ): Comparable<Square> {
        fun getNeighbours(
            validCells: ChitonGrid,
            remaining: Collection<Square>,
            deltas: List<Pair<Int, Int>> = listOf(
                -1 to 0, 0 to -1,
                1 to 0, 0 to 1,
            )
        ) = deltas.asSequence()
            .map { (x2, y2) -> coord.first + x2 to coord.second + y2 }
            .mapNotNull { validCells[it] }
            .filter { remaining.contains(it) }

        override fun compareTo(other: Square): Int {
            return this.distance.compareTo(other.distance)
        }
    }

    object Part1 {
        val chitonGrid = {
            File("day15/input-real.txt")
                .readLines(defaultCharset())
                .mapIndexed(::toCoordinates)
                .flatten()
                .associate { it }
        }

        fun run() {
            val grid = chitonGrid()
            grid.values.first().distance = 0

            val queue = grid.values.toMutableList()

            while (queue.isNotEmpty()) {
                val next = queue.minOrNull()!!
                queue.remove(next)

                val neighbours = next.getNeighbours(grid, queue)
                neighbours.forEach {
                    if (next.distance + next.risk < it.distance) {
                        it.distance = next.distance + next.risk
                        it.parent = next
                    }
                }
            }

            var end = grid.values.last()
            val parents = mutableListOf(end)
            while(end.parent != null) {
                end = end.parent!!
                parents.add(end)
            }
            draw(parents)
            parents.reversed().forEach { println("${it.coord} ${it.risk}   ${it.distance}")  }
            parents.sumOf { it.risk }.also { println(it - grid.values.first().risk) }
        }
    }

    object Part2 {
        private fun toCoordinates(row: Int, line: List<Int>) = line
            .mapIndexed { col, value -> (col to row) to Square((col to row), value) }

        fun run() {
            val grid = File("day15/input-real.txt")
                .readLines(defaultCharset())
                .map { it.map (Character::getNumericValue) }
                .map { vals -> (0..4).flatMap{ i -> vals.map { round(it, i) }}}.let{
                    grid -> (0..4).flatMap{ i -> grid.map { row -> row.map { round(it, i) } }}
                }.mapIndexed { i, it -> toCoordinates(i, it) }
                .flatten()
                .associate { it }

            grid.values.first().distance = 0

            val queue = grid.values.toMutableList()
            val total = queue.size
            var count = 0

            while (queue.isNotEmpty()) {
                if (count++ % 500 == 0) {
                    println("$count/$total (${queue.size})")
                }
                val next = queue.minOrNull()!!
                queue.remove(next)

                val neighbours = next.getNeighbours(grid, queue)
                neighbours.forEach {
                    if (next.distance + next.risk < it.distance) {
                        it.distance = next.distance + next.risk
                        it.parent = next
                    }
                }
            }

            var end = grid.values.last()
            val parents = mutableListOf(end)
            while(end.parent != null) {
                end = end.parent!!
                parents.add(end)
            }
            draw(parents)
            parents.reversed().forEach { println("${it.coord} ${it.risk}   ${it.distance}")  }
            parents.sumOf { it.risk }.also { println(it - grid.values.first().risk) }
        }
    }

    private fun round(it: Int, i: Int): Int {
        val x = it + i
        val y = x - 9
        return if (y > 0) y else x
    }
}

fun main() {
    Day15.Part1.run()
    Day15.Part2.run() // 21 mins!
}

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

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

  private final java.util.List<kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, Day15$Square>> toCoordinates(int, java.lang.String);
    Code:
       0: aload_2
       1: invokevirtual #19                 // Method java/lang/String.chars:()Ljava/util/stream/IntStream;
       4: invokedynamic #38,  0             // InvokeDynamic #0:applyAsInt:()Ljava/util/function/IntUnaryOperator;
       9: invokeinterface #44,  2           // InterfaceMethod java/util/stream/IntStream.map:(Ljava/util/function/IntUnaryOperator;)Ljava/util/stream/IntStream;
      14: dup
      15: ldc           #46                 // String map(...)
      17: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      20: invokestatic  #58                 // Method kotlin/streams/jdk8/StreamsKt.toList:(Ljava/util/stream/IntStream;)Ljava/util/List;
      23: checkcast     #60                 // class java/lang/Iterable
      26: astore_3
      27: nop
      28: iconst_0
      29: istore        4
      31: aload_3
      32: astore        5
      34: new           #62                 // class java/util/ArrayList
      37: dup
      38: aload_3
      39: bipush        10
      41: invokestatic  #68                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      44: invokespecial #71                 // Method java/util/ArrayList."<init>":(I)V
      47: checkcast     #73                 // class java/util/Collection
      50: astore        6
      52: iconst_0
      53: istore        7
      55: iconst_0
      56: istore        8
      58: aload         5
      60: invokeinterface #77,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      65: astore        9
      67: aload         9
      69: invokeinterface #83,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      74: ifeq          175
      77: aload         9
      79: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      84: astore        10
      86: aload         6
      88: iload         8
      90: iinc          8, 1
      93: istore        11
      95: iload         11
      97: ifge          103
     100: invokestatic  #90                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     103: iload         11
     105: aload         10
     107: checkcast     #92                 // class java/lang/Number
     110: invokevirtual #96                 // Method java/lang/Number.intValue:()I
     113: istore        12
     115: istore        13
     117: astore        15
     119: iconst_0
     120: istore        14
     122: iload         13
     124: invokestatic  #102                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     127: iload_1
     128: invokestatic  #102                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     131: invokestatic  #108                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     134: new           #110                // class Day15$Square
     137: dup
     138: iload         13
     140: invokestatic  #102                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     143: iload_1
     144: invokestatic  #102                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     147: invokestatic  #108                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     150: iload         12
     152: iconst_0
     153: aconst_null
     154: bipush        12
     156: aconst_null
     157: invokespecial #113                // Method Day15$Square."<init>":(Lkotlin/Pair;IILDay15$Square;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
     160: invokestatic  #108                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     163: aload         15
     165: swap
     166: invokeinterface #117,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     171: pop
     172: goto          67
     175: aload         6
     177: checkcast     #119                // class java/util/List
     180: nop
     181: areturn

  private final void draw(java.util.Collection<Day15$Square>);
    Code:
       0: ldc           #141                // String \n
       2: getstatic     #147                // Field java/lang/System.out:Ljava/io/PrintStream;
       5: swap
       6: invokevirtual #153                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
       9: aload_1
      10: checkcast     #60                 // class java/lang/Iterable
      13: invokeinterface #77,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      18: astore        4
      20: aload         4
      22: invokeinterface #83,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      27: ifne          38
      30: new           #155                // class java/util/NoSuchElementException
      33: dup
      34: invokespecial #156                // Method java/util/NoSuchElementException."<init>":()V
      37: athrow
      38: aload         4
      40: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      45: checkcast     #110                // class Day15$Square
      48: astore        5
      50: iconst_0
      51: istore        6
      53: aload         5
      55: invokevirtual #160                // Method Day15$Square.getCoord:()Lkotlin/Pair;
      58: invokevirtual #165                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      61: checkcast     #92                 // class java/lang/Number
      64: invokevirtual #96                 // Method java/lang/Number.intValue:()I
      67: istore        5
      69: aload         4
      71: invokeinterface #83,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      76: ifeq          124
      79: aload         4
      81: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      86: checkcast     #110                // class Day15$Square
      89: astore        6
      91: iconst_0
      92: istore        7
      94: aload         6
      96: invokevirtual #160                // Method Day15$Square.getCoord:()Lkotlin/Pair;
      99: invokevirtual #165                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     102: checkcast     #92                 // class java/lang/Number
     105: invokevirtual #96                 // Method java/lang/Number.intValue:()I
     108: istore        6
     110: iload         5
     112: iload         6
     114: if_icmpge     69
     117: iload         6
     119: istore        5
     121: goto          69
     124: iload         5
     126: istore_2
     127: aload_1
     128: checkcast     #60                 // class java/lang/Iterable
     131: invokeinterface #77,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     136: astore        5
     138: aload         5
     140: invokeinterface #83,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     145: ifne          156
     148: new           #155                // class java/util/NoSuchElementException
     151: dup
     152: invokespecial #156                // Method java/util/NoSuchElementException."<init>":()V
     155: athrow
     156: aload         5
     158: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     163: checkcast     #110                // class Day15$Square
     166: astore        6
     168: iconst_0
     169: istore        7
     171: aload         6
     173: invokevirtual #160                // Method Day15$Square.getCoord:()Lkotlin/Pair;
     176: invokevirtual #168                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     179: checkcast     #92                 // class java/lang/Number
     182: invokevirtual #96                 // Method java/lang/Number.intValue:()I
     185: istore        6
     187: aload         5
     189: invokeinterface #83,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     194: ifeq          242
     197: aload         5
     199: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     204: checkcast     #110                // class Day15$Square
     207: astore        7
     209: iconst_0
     210: istore        8
     212: aload         7
     214: invokevirtual #160                // Method Day15$Square.getCoord:()Lkotlin/Pair;
     217: invokevirtual #168                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     220: checkcast     #92                 // class java/lang/Number
     223: invokevirtual #96                 // Method java/lang/Number.intValue:()I
     226: istore        7
     228: iload         6
     230: iload         7
     232: if_icmpge     187
     235: iload         7
     237: istore        6
     239: goto          187
     242: iload         6
     244: istore_3
     245: new           #170                // class kotlin/ranges/IntRange
     248: dup
     249: iconst_0
     250: iload_3
     251: invokespecial #173                // Method kotlin/ranges/IntRange."<init>":(II)V
     254: checkcast     #60                 // class java/lang/Iterable
     257: astore        4
     259: iconst_0
     260: istore        5
     262: aload         4
     264: invokeinterface #77,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     269: astore        6
     271: aload         6
     273: invokeinterface #83,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     278: ifeq          480
     281: aload         6
     283: checkcast     #175                // class kotlin/collections/IntIterator
     286: invokevirtual #178                // Method kotlin/collections/IntIterator.nextInt:()I
     289: istore        7
     291: iload         7
     293: istore        8
     295: iconst_0
     296: istore        9
     298: new           #170                // class kotlin/ranges/IntRange
     301: dup
     302: iconst_0
     303: iload_2
     304: invokespecial #173                // Method kotlin/ranges/IntRange."<init>":(II)V
     307: checkcast     #60                 // class java/lang/Iterable
     310: astore        10
     312: iconst_0
     313: istore        11
     315: aload         10
     317: invokeinterface #77,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     322: astore        12
     324: aload         12
     326: invokeinterface #83,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     331: ifeq          468
     334: aload         12
     336: checkcast     #175                // class kotlin/collections/IntIterator
     339: invokevirtual #178                // Method kotlin/collections/IntIterator.nextInt:()I
     342: istore        13
     344: iload         13
     346: istore        14
     348: iconst_0
     349: istore        15
     351: aload_1
     352: checkcast     #60                 // class java/lang/Iterable
     355: astore        16
     357: aload         16
     359: invokeinterface #77,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     364: astore        17
     366: aload         17
     368: invokeinterface #83,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     373: ifeq          428
     376: aload         17
     378: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     383: astore        18
     385: aload         18
     387: checkcast     #110                // class Day15$Square
     390: astore        19
     392: iconst_0
     393: istore        20
     395: aload         19
     397: invokevirtual #160                // Method Day15$Square.getCoord:()Lkotlin/Pair;
     400: new           #162                // class kotlin/Pair
     403: dup
     404: iload         14
     406: invokestatic  #102                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     409: iload         8
     411: invokestatic  #102                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     414: invokespecial #181                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     417: invokestatic  #185                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     420: ifeq          366
     423: aload         18
     425: goto          429
     428: aconst_null
     429: checkcast     #110                // class Day15$Square
     432: dup
     433: ifnull        453
     436: astore        17
     438: iconst_0
     439: istore        18
     441: aload         17
     443: invokevirtual #188                // Method Day15$Square.getRisk:()I
     446: nop
     447: invokestatic  #102                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     450: goto          456
     453: pop
     454: ldc           #190                // String .
     456: getstatic     #147                // Field java/lang/System.out:Ljava/io/PrintStream;
     459: swap
     460: invokevirtual #193                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     463: nop
     464: nop
     465: goto          324
     468: nop
     469: getstatic     #147                // Field java/lang/System.out:Ljava/io/PrintStream;
     472: invokevirtual #195                // Method java/io/PrintStream.println:()V
     475: nop
     476: nop
     477: goto          271
     480: nop
     481: return

  private final int round(int, int);
    Code:
       0: iload_1
       1: iload_2
       2: iadd
       3: istore_3
       4: iload_3
       5: bipush        9
       7: isub
       8: istore        4
      10: iload         4
      12: ifle          20
      15: iload         4
      17: goto          21
      20: iload_3
      21: ireturn

  public static final void access$draw(Day15, java.util.Collection);
    Code:
       0: aload_0
       1: aload_1
       2: invokespecial #218                // Method draw:(Ljava/util/Collection;)V
       5: return

  public static final java.util.List access$toCoordinates(Day15, int, java.lang.String);
    Code:
       0: aload_0
       1: iload_1
       2: aload_2
       3: invokespecial #223                // Method toCoordinates:(ILjava/lang/String;)Ljava/util/List;
       6: areturn

  public static final int access$round(Day15, int, int);
    Code:
       0: aload_0
       1: iload_1
       2: iload_2
       3: invokespecial #227                // Method round:(II)I
       6: ireturn

  static {};
    Code:
       0: new           #2                  // class Day15
       3: dup
       4: invokespecial #229                // Method "<init>":()V
       7: putstatic     #232                // Field INSTANCE:LDay15;
      10: return
}

Compiled from "Day15.kt"
public final class Day15Kt {
  public static final void main();
    Code:
       0: getstatic     #12                 // Field Day15$Part1.INSTANCE:LDay15$Part1;
       3: invokevirtual #15                 // Method Day15$Part1.run:()V
       6: getstatic     #20                 // Field Day15$Part2.INSTANCE:LDay15$Part2;
       9: invokevirtual #21                 // Method Day15$Part2.run:()V
      12: return

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

Compiled from "Day15.kt"
public final class Day15$Square implements java.lang.Comparable<Day15$Square> {
  private kotlin.Pair<java.lang.Integer, java.lang.Integer> coord;

  private int risk;

  private int distance;

  private Day15$Square parent;

  public Day15$Square(kotlin.Pair<java.lang.Integer, java.lang.Integer>, int, int, Day15$Square);
    Code:
       0: aload_1
       1: ldc           #14                 // String coord
       3: invokestatic  #20                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #23                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_1
      12: putfield      #26                 // Field coord:Lkotlin/Pair;
      15: aload_0
      16: iload_2
      17: putfield      #30                 // Field risk:I
      20: aload_0
      21: iload_3
      22: putfield      #33                 // Field distance:I
      25: aload_0
      26: aload         4
      28: putfield      #37                 // Field parent:LDay15$Square;
      31: return

  public Day15$Square(kotlin.Pair, int, int, Day15$Square, int, kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: iload         5
       2: iconst_4
       3: iand
       4: ifeq          10
       7: ldc           #40                 // int 2147483647
       9: istore_3
      10: iload         5
      12: bipush        8
      14: iand
      15: ifeq          21
      18: aconst_null
      19: astore        4
      21: aload_0
      22: aload_1
      23: iload_2
      24: iload_3
      25: aload         4
      27: invokespecial #42                 // Method "<init>":(Lkotlin/Pair;IILDay15$Square;)V
      30: return

  public final kotlin.Pair<java.lang.Integer, java.lang.Integer> getCoord();
    Code:
       0: aload_0
       1: getfield      #26                 // Field coord:Lkotlin/Pair;
       4: areturn

  public final void setCoord(kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_1
       1: ldc           #50                 // String <set-?>
       3: invokestatic  #20                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: putfield      #26                 // Field coord:Lkotlin/Pair;
      11: return

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

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

  public final int getDistance();
    Code:
       0: aload_0
       1: getfield      #33                 // Field distance:I
       4: ireturn

  public final void setDistance(int);
    Code:
       0: aload_0
       1: iload_1
       2: putfield      #33                 // Field distance:I
       5: return

  public final Day15$Square getParent();
    Code:
       0: aload_0
       1: getfield      #37                 // Field parent:LDay15$Square;
       4: areturn

  public final void setParent(Day15$Square);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #37                 // Field parent:LDay15$Square;
       5: return

  public final kotlin.sequences.Sequence<Day15$Square> getNeighbours(java.util.Map<kotlin.Pair<java.lang.Integer, java.lang.Integer>, Day15$Square>, java.util.Collection<Day15$Square>, java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>>);
    Code:
       0: aload_1
       1: ldc           #65                 // String validCells
       3: invokestatic  #20                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #67                 // String remaining
       9: invokestatic  #20                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_3
      13: ldc           #69                 // String deltas
      15: invokestatic  #20                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: aload_3
      19: checkcast     #71                 // class java/lang/Iterable
      22: invokestatic  #77                 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;
      25: aload_0
      26: invokedynamic #97,  0             // InvokeDynamic #0:invoke:(LDay15$Square;)Lkotlin/jvm/functions/Function1;
      31: invokestatic  #103                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      34: aload_1
      35: invokedynamic #113,  0            // InvokeDynamic #1:invoke:(Ljava/util/Map;)Lkotlin/jvm/functions/Function1;
      40: invokestatic  #116                // Method kotlin/sequences/SequencesKt.mapNotNull:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      43: aload_2
      44: invokedynamic #126,  0            // InvokeDynamic #2:invoke:(Ljava/util/Collection;)Lkotlin/jvm/functions/Function1;
      49: invokestatic  #129                // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      52: areturn

  public static kotlin.sequences.Sequence getNeighbours$default(Day15$Square, java.util.Map, java.util.Collection, java.util.List, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_4
       3: iand
       4: ifeq          79
       7: iconst_4
       8: anewarray     #136                // class kotlin/Pair
      11: astore        6
      13: aload         6
      15: iconst_0
      16: iconst_m1
      17: invokestatic  #142                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      20: iconst_0
      21: invokestatic  #142                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      24: invokestatic  #148                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      27: aastore
      28: aload         6
      30: iconst_1
      31: iconst_0
      32: invokestatic  #142                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      35: iconst_m1
      36: invokestatic  #142                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      39: invokestatic  #148                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      42: aastore
      43: aload         6
      45: iconst_2
      46: iconst_1
      47: invokestatic  #142                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      50: iconst_0
      51: invokestatic  #142                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      54: invokestatic  #148                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      57: aastore
      58: aload         6
      60: iconst_3
      61: iconst_0
      62: invokestatic  #142                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      65: iconst_1
      66: invokestatic  #142                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      69: invokestatic  #148                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      72: aastore
      73: aload         6
      75: invokestatic  #152                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      78: astore_3
      79: aload_0
      80: aload_1
      81: aload_2
      82: aload_3
      83: invokevirtual #154                // Method getNeighbours:(Ljava/util/Map;Ljava/util/Collection;Ljava/util/List;)Lkotlin/sequences/Sequence;
      86: areturn

  public int compareTo(Day15$Square);
    Code:
       0: aload_1
       1: ldc           #158                // String other
       3: invokestatic  #20                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: getfield      #33                 // Field distance:I
      10: aload_1
      11: getfield      #33                 // Field distance:I
      14: invokestatic  #162                // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
      17: ireturn

  public final kotlin.Pair<java.lang.Integer, java.lang.Integer> component1();
    Code:
       0: aload_0
       1: getfield      #26                 // Field coord:Lkotlin/Pair;
       4: areturn

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

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

  public final Day15$Square component4();
    Code:
       0: aload_0
       1: getfield      #37                 // Field parent:LDay15$Square;
       4: areturn

  public final Day15$Square copy(kotlin.Pair<java.lang.Integer, java.lang.Integer>, int, int, Day15$Square);
    Code:
       0: aload_1
       1: ldc           #14                 // String coord
       3: invokestatic  #20                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #2                  // class Day15$Square
       9: dup
      10: aload_1
      11: iload_2
      12: iload_3
      13: aload         4
      15: invokespecial #42                 // Method "<init>":(Lkotlin/Pair;IILDay15$Square;)V
      18: areturn

  public static Day15$Square copy$default(Day15$Square, kotlin.Pair, int, int, Day15$Square, int, java.lang.Object);
    Code:
       0: iload         5
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #26                 // Field coord:Lkotlin/Pair;
      11: astore_1
      12: iload         5
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #30                 // Field risk:I
      23: istore_2
      24: iload         5
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #33                 // Field distance:I
      35: istore_3
      36: iload         5
      38: bipush        8
      40: iand
      41: ifeq          50
      44: aload_0
      45: getfield      #37                 // Field parent:LDay15$Square;
      48: astore        4
      50: aload_0
      51: aload_1
      52: iload_2
      53: iload_3
      54: aload         4
      56: invokevirtual #173                // Method copy:(Lkotlin/Pair;IILDay15$Square;)LDay15$Square;
      59: areturn

  public java.lang.String toString();
    Code:
       0: new           #177                // class java/lang/StringBuilder
       3: dup
       4: invokespecial #178                // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #180                // String Square(coord=
       9: invokevirtual #184                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #26                 // Field coord:Lkotlin/Pair;
      16: invokevirtual #187                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      19: ldc           #189                // String , risk=
      21: invokevirtual #184                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #30                 // Field risk:I
      28: invokevirtual #192                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: ldc           #194                // String , distance=
      33: invokevirtual #184                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: aload_0
      37: getfield      #33                 // Field distance:I
      40: invokevirtual #192                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      43: ldc           #196                // String , parent=
      45: invokevirtual #184                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      48: aload_0
      49: getfield      #37                 // Field parent:LDay15$Square;
      52: invokevirtual #187                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      55: bipush        41
      57: invokevirtual #199                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      60: invokevirtual #201                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      63: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #26                 // Field coord:Lkotlin/Pair;
       4: invokevirtual #204                // Method kotlin/Pair.hashCode:()I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #30                 // Field risk:I
      16: invokestatic  #207                // Method java/lang/Integer.hashCode:(I)I
      19: iadd
      20: istore_1
      21: iload_1
      22: bipush        31
      24: imul
      25: aload_0
      26: getfield      #33                 // Field distance:I
      29: invokestatic  #207                // Method java/lang/Integer.hashCode:(I)I
      32: iadd
      33: istore_1
      34: iload_1
      35: bipush        31
      37: imul
      38: aload_0
      39: getfield      #37                 // Field parent:LDay15$Square;
      42: ifnonnull     49
      45: iconst_0
      46: goto          56
      49: aload_0
      50: getfield      #37                 // Field parent:LDay15$Square;
      53: invokevirtual #208                // Method hashCode:()I
      56: iadd
      57: istore_1
      58: iload_1
      59: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class Day15$Square
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class Day15$Square
      20: astore_2
      21: aload_0
      22: getfield      #26                 // Field coord:Lkotlin/Pair;
      25: aload_2
      26: getfield      #26                 // Field coord:Lkotlin/Pair;
      29: invokestatic  #215                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      32: ifne          37
      35: iconst_0
      36: ireturn
      37: aload_0
      38: getfield      #30                 // Field risk:I
      41: aload_2
      42: getfield      #30                 // Field risk:I
      45: if_icmpeq     50
      48: iconst_0
      49: ireturn
      50: aload_0
      51: getfield      #33                 // Field distance:I
      54: aload_2
      55: getfield      #33                 // Field distance:I
      58: if_icmpeq     63
      61: iconst_0
      62: ireturn
      63: aload_0
      64: getfield      #37                 // Field parent:LDay15$Square;
      67: aload_2
      68: getfield      #37                 // Field parent:LDay15$Square;
      71: invokestatic  #215                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      74: ifne          79
      77: iconst_0
      78: ireturn
      79: iconst_1
      80: ireturn

  private static final kotlin.Pair getNeighbours$lambda$0(Day15$Square, kotlin.Pair);
    Code:
       0: aload_1
       1: ldc           #218                // String <destruct>
       3: invokestatic  #20                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokevirtual #221                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      10: checkcast     #223                // class java/lang/Number
      13: invokevirtual #226                // Method java/lang/Number.intValue:()I
      16: istore_2
      17: aload_1
      18: invokevirtual #228                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      21: checkcast     #223                // class java/lang/Number
      24: invokevirtual #226                // Method java/lang/Number.intValue:()I
      27: istore_3
      28: aload_0
      29: getfield      #26                 // Field coord:Lkotlin/Pair;
      32: invokevirtual #231                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      35: checkcast     #223                // class java/lang/Number
      38: invokevirtual #226                // Method java/lang/Number.intValue:()I
      41: iload_2
      42: iadd
      43: invokestatic  #142                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      46: aload_0
      47: getfield      #26                 // Field coord:Lkotlin/Pair;
      50: invokevirtual #234                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      53: checkcast     #223                // class java/lang/Number
      56: invokevirtual #226                // Method java/lang/Number.intValue:()I
      59: iload_3
      60: iadd
      61: invokestatic  #142                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      64: invokestatic  #148                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      67: areturn

  private static final Day15$Square getNeighbours$lambda$1(java.util.Map, kotlin.Pair);
    Code:
       0: aload_1
       1: ldc           #239                // String it
       3: invokestatic  #20                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: invokeinterface #244,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      13: checkcast     #2                  // class Day15$Square
      16: areturn

  private static final boolean getNeighbours$lambda$2(java.util.Collection, Day15$Square);
    Code:
       0: aload_1
       1: ldc           #239                // String it
       3: invokestatic  #20                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: invokeinterface #250,  2          // InterfaceMethod java/util/Collection.contains:(Ljava/lang/Object;)Z
      13: ireturn

  public int compareTo(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #2                  // class Day15$Square
       5: invokevirtual #254                // Method compareTo:(LDay15$Square;)I
       8: ireturn
}

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

  private static final kotlin.jvm.functions.Function0<java.util.Map<kotlin.Pair<java.lang.Integer, java.lang.Integer>, Day15$Square>> chitonGrid;

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

  public final kotlin.jvm.functions.Function0<java.util.Map<kotlin.Pair<java.lang.Integer, java.lang.Integer>, Day15$Square>> getChitonGrid();
    Code:
       0: getstatic     #18                 // Field chitonGrid:Lkotlin/jvm/functions/Function0;
       3: areturn

  public final void run();
    Code:
       0: getstatic     #18                 // Field chitonGrid:Lkotlin/jvm/functions/Function0;
       3: invokeinterface #25,  1           // InterfaceMethod kotlin/jvm/functions/Function0.invoke:()Ljava/lang/Object;
       8: checkcast     #27                 // class java/util/Map
      11: astore_1
      12: aload_1
      13: invokeinterface #31,  1           // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
      18: checkcast     #33                 // class java/lang/Iterable
      21: invokestatic  #39                 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;
      24: checkcast     #41                 // class Day15$Square
      27: iconst_0
      28: invokevirtual #45                 // Method Day15$Square.setDistance:(I)V
      31: aload_1
      32: invokeinterface #31,  1           // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
      37: invokestatic  #49                 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
      40: astore_2
      41: aload_2
      42: checkcast     #51                 // class java/util/Collection
      45: invokeinterface #55,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
      50: ifne          57
      53: iconst_1
      54: goto          58
      57: iconst_0
      58: ifeq          189
      61: aload_2
      62: checkcast     #33                 // class java/lang/Iterable
      65: invokestatic  #59                 // Method kotlin/collections/CollectionsKt.minOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
      68: dup
      69: invokestatic  #65                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      72: checkcast     #41                 // class Day15$Square
      75: astore_3
      76: aload_2
      77: aload_3
      78: invokeinterface #71,  2           // InterfaceMethod java/util/List.remove:(Ljava/lang/Object;)Z
      83: pop
      84: aload_3
      85: aload_1
      86: aload_2
      87: checkcast     #51                 // class java/util/Collection
      90: aconst_null
      91: iconst_4
      92: aconst_null
      93: invokestatic  #75                 // Method Day15$Square.getNeighbours$default:(LDay15$Square;Ljava/util/Map;Ljava/util/Collection;Ljava/util/List;ILjava/lang/Object;)Lkotlin/sequences/Sequence;
      96: astore        4
      98: aload         4
     100: astore        5
     102: iconst_0
     103: istore        6
     105: aload         5
     107: invokeinterface #81,  1           // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
     112: astore        7
     114: aload         7
     116: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     121: ifeq          185
     124: aload         7
     126: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     131: astore        8
     133: aload         8
     135: checkcast     #41                 // class Day15$Square
     138: astore        9
     140: iconst_0
     141: istore        10
     143: aload_3
     144: invokevirtual #93                 // Method Day15$Square.getDistance:()I
     147: aload_3
     148: invokevirtual #96                 // Method Day15$Square.getRisk:()I
     151: iadd
     152: aload         9
     154: invokevirtual #93                 // Method Day15$Square.getDistance:()I
     157: if_icmpge     180
     160: aload         9
     162: aload_3
     163: invokevirtual #93                 // Method Day15$Square.getDistance:()I
     166: aload_3
     167: invokevirtual #96                 // Method Day15$Square.getRisk:()I
     170: iadd
     171: invokevirtual #45                 // Method Day15$Square.setDistance:(I)V
     174: aload         9
     176: aload_3
     177: invokevirtual #100                // Method Day15$Square.setParent:(LDay15$Square;)V
     180: nop
     181: nop
     182: goto          114
     185: nop
     186: goto          41
     189: aload_1
     190: invokeinterface #31,  1           // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
     195: checkcast     #33                 // class java/lang/Iterable
     198: invokestatic  #103                // Method kotlin/collections/CollectionsKt.last:(Ljava/lang/Iterable;)Ljava/lang/Object;
     201: checkcast     #41                 // class Day15$Square
     204: astore_3
     205: iconst_1
     206: anewarray     #41                 // class Day15$Square
     209: astore        5
     211: aload         5
     213: iconst_0
     214: aload_3
     215: aastore
     216: aload         5
     218: invokestatic  #107                // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
     221: astore        4
     223: aload_3
     224: invokevirtual #111                // Method Day15$Square.getParent:()LDay15$Square;
     227: ifnull        251
     230: aload_3
     231: invokevirtual #111                // Method Day15$Square.getParent:()LDay15$Square;
     234: dup
     235: invokestatic  #65                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     238: astore_3
     239: aload         4
     241: aload_3
     242: invokeinterface #114,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     247: pop
     248: goto          223
     251: getstatic     #120                // Field Day15.INSTANCE:LDay15;
     254: aload         4
     256: checkcast     #51                 // class java/util/Collection
     259: invokestatic  #124                // Method Day15.access$draw:(LDay15;Ljava/util/Collection;)V
     262: aload         4
     264: checkcast     #33                 // class java/lang/Iterable
     267: invokestatic  #128                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
     270: checkcast     #33                 // class java/lang/Iterable
     273: astore        5
     275: iconst_0
     276: istore        6
     278: aload         5
     280: invokeinterface #129,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     285: astore        7
     287: aload         7
     289: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     294: ifeq          372
     297: aload         7
     299: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     304: astore        8
     306: aload         8
     308: checkcast     #41                 // class Day15$Square
     311: astore        9
     313: iconst_0
     314: istore        10
     316: new           #131                // class java/lang/StringBuilder
     319: dup
     320: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
     323: aload         9
     325: invokevirtual #136                // Method Day15$Square.getCoord:()Lkotlin/Pair;
     328: invokevirtual #140                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     331: bipush        32
     333: invokevirtual #143                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     336: aload         9
     338: invokevirtual #96                 // Method Day15$Square.getRisk:()I
     341: invokevirtual #146                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     344: ldc           #148                // String
     346: invokevirtual #151                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     349: aload         9
     351: invokevirtual #93                 // Method Day15$Square.getDistance:()I
     354: invokevirtual #146                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     357: invokevirtual #155                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     360: getstatic     #161                // Field java/lang/System.out:Ljava/io/PrintStream;
     363: swap
     364: invokevirtual #166                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     367: nop
     368: nop
     369: goto          287
     372: nop
     373: aload         4
     375: checkcast     #33                 // class java/lang/Iterable
     378: astore        5
     380: iconst_0
     381: istore        6
     383: aload         5
     385: invokeinterface #129,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     390: astore        7
     392: aload         7
     394: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     399: ifeq          442
     402: aload         7
     404: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     409: astore        8
     411: iload         6
     413: aload         8
     415: checkcast     #41                 // class Day15$Square
     418: astore        9
     420: istore        11
     422: iconst_0
     423: istore        10
     425: aload         9
     427: invokevirtual #96                 // Method Day15$Square.getRisk:()I
     430: istore        12
     432: iload         11
     434: iload         12
     436: iadd
     437: istore        6
     439: goto          392
     442: iload         6
     444: istore        5
     446: iload         5
     448: istore        6
     450: iconst_0
     451: istore        7
     453: iload         6
     455: aload_1
     456: invokeinterface #31,  1           // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
     461: checkcast     #33                 // class java/lang/Iterable
     464: invokestatic  #39                 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;
     467: checkcast     #41                 // class Day15$Square
     470: invokevirtual #96                 // Method Day15$Square.getRisk:()I
     473: isub
     474: istore        8
     476: getstatic     #161                // Field java/lang/System.out:Ljava/io/PrintStream;
     479: iload         8
     481: invokevirtual #168                // Method java/io/PrintStream.println:(I)V
     484: nop
     485: nop
     486: return

  private static final java.util.Map chitonGrid$lambda$1();
    Code:
       0: new           #194                // class java/io/File
       3: dup
       4: ldc           #196                // String day15/input-real.txt
       6: invokespecial #199                // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: invokestatic  #205                // Method java/nio/charset/Charset.defaultCharset:()Ljava/nio/charset/Charset;
      12: dup
      13: ldc           #207                // String defaultCharset(...)
      15: invokestatic  #211                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      18: invokestatic  #217                // Method kotlin/io/FilesKt.readLines:(Ljava/io/File;Ljava/nio/charset/Charset;)Ljava/util/List;
      21: checkcast     #33                 // class java/lang/Iterable
      24: astore_0
      25: getstatic     #120                // Field Day15.INSTANCE:LDay15;
      28: astore_1
      29: iconst_0
      30: istore_2
      31: aload_0
      32: astore_3
      33: new           #219                // class java/util/ArrayList
      36: dup
      37: aload_0
      38: bipush        10
      40: invokestatic  #223                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      43: invokespecial #225                // Method java/util/ArrayList."<init>":(I)V
      46: checkcast     #51                 // class java/util/Collection
      49: astore        4
      51: iconst_0
      52: istore        5
      54: iconst_0
      55: istore        6
      57: aload_3
      58: invokeinterface #129,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      63: astore        7
      65: aload         7
      67: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      72: ifeq          137
      75: aload         7
      77: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      82: astore        8
      84: aload         4
      86: iload         6
      88: iinc          6, 1
      91: istore        9
      93: iload         9
      95: ifge          101
      98: invokestatic  #228                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     101: iload         9
     103: aload         8
     105: checkcast     #230                // class java/lang/String
     108: astore        10
     110: istore        11
     112: astore        13
     114: iconst_0
     115: istore        12
     117: aload_1
     118: iload         11
     120: aload         10
     122: invokestatic  #234                // Method Day15.access$toCoordinates:(LDay15;ILjava/lang/String;)Ljava/util/List;
     125: aload         13
     127: swap
     128: invokeinterface #235,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     133: pop
     134: goto          65
     137: aload         4
     139: checkcast     #67                 // class java/util/List
     142: nop
     143: checkcast     #33                 // class java/lang/Iterable
     146: invokestatic  #238                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     149: checkcast     #33                 // class java/lang/Iterable
     152: astore_0
     153: nop
     154: iconst_0
     155: istore_1
     156: aload_0
     157: bipush        10
     159: invokestatic  #223                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     162: invokestatic  #244                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
     165: bipush        16
     167: invokestatic  #250                // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I
     170: istore_2
     171: aload_0
     172: astore_3
     173: new           #252                // class java/util/LinkedHashMap
     176: dup
     177: iload_2
     178: invokespecial #253                // Method java/util/LinkedHashMap."<init>":(I)V
     181: checkcast     #27                 // class java/util/Map
     184: astore        4
     186: iconst_0
     187: istore        5
     189: aload_3
     190: invokeinterface #129,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     195: astore        6
     197: aload         6
     199: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     204: ifeq          255
     207: aload         6
     209: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     214: astore        7
     216: aload         4
     218: astore        8
     220: aload         7
     222: checkcast     #255                // class kotlin/Pair
     225: astore        9
     227: iconst_0
     228: istore        10
     230: aload         9
     232: astore        9
     234: aload         8
     236: aload         9
     238: invokevirtual #258                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     241: aload         9
     243: invokevirtual #261                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     246: invokeinterface #265,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     251: pop
     252: goto          197
     255: aload         4
     257: nop
     258: areturn

  static {};
    Code:
       0: new           #2                  // class Day15$Part1
       3: dup
       4: invokespecial #287                // Method "<init>":()V
       7: putstatic     #289                // Field INSTANCE:LDay15$Part1;
      10: invokedynamic #303,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function0;
      15: putstatic     #18                 // Field chitonGrid:Lkotlin/jvm/functions/Function0;
      18: return
}

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

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

  private final java.util.List<kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, Day15$Square>> toCoordinates(int, java.util.List<java.lang.Integer>);
    Code:
       0: aload_2
       1: checkcast     #15                 // class java/lang/Iterable
       4: astore_3
       5: nop
       6: iconst_0
       7: istore        4
       9: aload_3
      10: astore        5
      12: new           #17                 // class java/util/ArrayList
      15: dup
      16: aload_3
      17: bipush        10
      19: invokestatic  #23                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      22: invokespecial #26                 // Method java/util/ArrayList."<init>":(I)V
      25: checkcast     #28                 // class java/util/Collection
      28: astore        6
      30: iconst_0
      31: istore        7
      33: iconst_0
      34: istore        8
      36: aload         5
      38: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      43: astore        9
      45: aload         9
      47: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      52: ifeq          153
      55: aload         9
      57: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      62: astore        10
      64: aload         6
      66: iload         8
      68: iinc          8, 1
      71: istore        11
      73: iload         11
      75: ifge          81
      78: invokestatic  #45                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      81: iload         11
      83: aload         10
      85: checkcast     #47                 // class java/lang/Number
      88: invokevirtual #51                 // Method java/lang/Number.intValue:()I
      91: istore        12
      93: istore        13
      95: astore        15
      97: iconst_0
      98: istore        14
     100: iload         13
     102: invokestatic  #57                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     105: iload_1
     106: invokestatic  #57                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     109: invokestatic  #63                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     112: new           #65                 // class Day15$Square
     115: dup
     116: iload         13
     118: invokestatic  #57                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     121: iload_1
     122: invokestatic  #57                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     125: invokestatic  #63                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     128: iload         12
     130: iconst_0
     131: aconst_null
     132: bipush        12
     134: aconst_null
     135: invokespecial #68                 // Method Day15$Square."<init>":(Lkotlin/Pair;IILDay15$Square;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
     138: invokestatic  #63                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     141: aload         15
     143: swap
     144: invokeinterface #72,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     149: pop
     150: goto          45
     153: aload         6
     155: checkcast     #74                 // class java/util/List
     158: nop
     159: areturn

  public final void run();
    Code:
       0: new           #94                 // class java/io/File
       3: dup
       4: ldc           #96                 // String day15/input-real.txt
       6: invokespecial #99                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: invokestatic  #105                // Method java/nio/charset/Charset.defaultCharset:()Ljava/nio/charset/Charset;
      12: dup
      13: ldc           #107                // String defaultCharset(...)
      15: invokestatic  #113                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      18: invokestatic  #119                // Method kotlin/io/FilesKt.readLines:(Ljava/io/File;Ljava/nio/charset/Charset;)Ljava/util/List;
      21: checkcast     #15                 // class java/lang/Iterable
      24: astore_2
      25: nop
      26: iconst_0
      27: istore_3
      28: aload_2
      29: astore        4
      31: new           #17                 // class java/util/ArrayList
      34: dup
      35: aload_2
      36: bipush        10
      38: invokestatic  #23                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      41: invokespecial #26                 // Method java/util/ArrayList."<init>":(I)V
      44: checkcast     #28                 // class java/util/Collection
      47: astore        5
      49: iconst_0
      50: istore        6
      52: aload         4
      54: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      59: astore        7
      61: aload         7
      63: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      68: ifeq          209
      71: aload         7
      73: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      78: astore        8
      80: aload         5
      82: aload         8
      84: checkcast     #121                // class java/lang/String
      87: astore        9
      89: astore        34
      91: iconst_0
      92: istore        10
      94: aload         9
      96: checkcast     #123                // class java/lang/CharSequence
      99: astore        11
     101: iconst_0
     102: istore        12
     104: aload         11
     106: astore        13
     108: new           #17                 // class java/util/ArrayList
     111: dup
     112: aload         11
     114: invokeinterface #126,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     119: invokespecial #26                 // Method java/util/ArrayList."<init>":(I)V
     122: checkcast     #28                 // class java/util/Collection
     125: astore        14
     127: iconst_0
     128: istore        15
     130: iconst_0
     131: istore        16
     133: iload         16
     135: aload         13
     137: invokeinterface #126,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     142: if_icmpge     190
     145: aload         13
     147: iload         16
     149: invokeinterface #130,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     154: istore        17
     156: aload         14
     158: iload         17
     160: istore        18
     162: astore        19
     164: iconst_0
     165: istore        20
     167: iload         18
     169: invokestatic  #136                // Method java/lang/Character.getNumericValue:(C)I
     172: invokestatic  #57                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     175: aload         19
     177: swap
     178: invokeinterface #72,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     183: pop
     184: iinc          16, 1
     187: goto          133
     190: aload         14
     192: checkcast     #74                 // class java/util/List
     195: nop
     196: nop
     197: aload         34
     199: swap
     200: invokeinterface #72,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     205: pop
     206: goto          61
     209: aload         5
     211: checkcast     #74                 // class java/util/List
     214: nop
     215: checkcast     #15                 // class java/lang/Iterable
     218: astore_2
     219: nop
     220: iconst_0
     221: istore_3
     222: aload_2
     223: astore        4
     225: new           #17                 // class java/util/ArrayList
     228: dup
     229: aload_2
     230: bipush        10
     232: invokestatic  #23                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     235: invokespecial #26                 // Method java/util/ArrayList."<init>":(I)V
     238: checkcast     #28                 // class java/util/Collection
     241: astore        5
     243: iconst_0
     244: istore        6
     246: aload         4
     248: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     253: astore        7
     255: aload         7
     257: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     262: ifeq          508
     265: aload         7
     267: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     272: astore        8
     274: aload         5
     276: aload         8
     278: checkcast     #74                 // class java/util/List
     281: astore        9
     283: astore        34
     285: iconst_0
     286: istore        10
     288: new           #138                // class kotlin/ranges/IntRange
     291: dup
     292: iconst_0
     293: iconst_4
     294: invokespecial #141                // Method kotlin/ranges/IntRange."<init>":(II)V
     297: checkcast     #15                 // class java/lang/Iterable
     300: astore        11
     302: iconst_0
     303: istore        12
     305: aload         11
     307: astore        13
     309: new           #17                 // class java/util/ArrayList
     312: dup
     313: invokespecial #142                // Method java/util/ArrayList."<init>":()V
     316: checkcast     #28                 // class java/util/Collection
     319: astore        14
     321: iconst_0
     322: istore        15
     324: aload         13
     326: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     331: astore        16
     333: aload         16
     335: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     340: ifeq          489
     343: aload         16
     345: checkcast     #144                // class kotlin/collections/IntIterator
     348: invokevirtual #147                // Method kotlin/collections/IntIterator.nextInt:()I
     351: istore        17
     353: iload         17
     355: istore        18
     357: iconst_0
     358: istore        19
     360: aload         9
     362: checkcast     #15                 // class java/lang/Iterable
     365: astore        20
     367: iconst_0
     368: istore        21
     370: aload         20
     372: astore        22
     374: new           #17                 // class java/util/ArrayList
     377: dup
     378: aload         20
     380: bipush        10
     382: invokestatic  #23                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     385: invokespecial #26                 // Method java/util/ArrayList."<init>":(I)V
     388: checkcast     #28                 // class java/util/Collection
     391: astore        23
     393: iconst_0
     394: istore        24
     396: aload         22
     398: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     403: astore        25
     405: aload         25
     407: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     412: ifeq          466
     415: aload         25
     417: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     422: astore        26
     424: aload         23
     426: aload         26
     428: checkcast     #47                 // class java/lang/Number
     431: invokevirtual #51                 // Method java/lang/Number.intValue:()I
     434: istore        27
     436: astore        28
     438: iconst_0
     439: istore        29
     441: getstatic     #153                // Field Day15.INSTANCE:LDay15;
     444: iload         27
     446: iload         18
     448: invokestatic  #157                // Method Day15.access$round:(LDay15;II)I
     451: invokestatic  #57                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     454: aload         28
     456: swap
     457: invokeinterface #72,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     462: pop
     463: goto          405
     466: aload         23
     468: checkcast     #74                 // class java/util/List
     471: nop
     472: checkcast     #15                 // class java/lang/Iterable
     475: nop
     476: astore        18
     478: aload         14
     480: aload         18
     482: invokestatic  #161                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     485: pop
     486: goto          333
     489: aload         14
     491: checkcast     #74                 // class java/util/List
     494: nop
     495: nop
     496: aload         34
     498: swap
     499: invokeinterface #72,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     504: pop
     505: goto          255
     508: aload         5
     510: checkcast     #74                 // class java/util/List
     513: nop
     514: astore_3
     515: iconst_0
     516: istore        4
     518: new           #138                // class kotlin/ranges/IntRange
     521: dup
     522: iconst_0
     523: iconst_4
     524: invokespecial #141                // Method kotlin/ranges/IntRange."<init>":(II)V
     527: checkcast     #15                 // class java/lang/Iterable
     530: astore        5
     532: iconst_0
     533: istore        6
     535: aload         5
     537: astore        7
     539: new           #17                 // class java/util/ArrayList
     542: dup
     543: invokespecial #142                // Method java/util/ArrayList."<init>":()V
     546: checkcast     #28                 // class java/util/Collection
     549: astore        8
     551: iconst_0
     552: istore        9
     554: aload         7
     556: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     561: astore        10
     563: aload         10
     565: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     570: ifeq          815
     573: aload         10
     575: checkcast     #144                // class kotlin/collections/IntIterator
     578: invokevirtual #147                // Method kotlin/collections/IntIterator.nextInt:()I
     581: istore        11
     583: iload         11
     585: istore        12
     587: iconst_0
     588: istore        13
     590: aload_3
     591: checkcast     #15                 // class java/lang/Iterable
     594: astore        14
     596: iconst_0
     597: istore        15
     599: aload         14
     601: astore        16
     603: new           #17                 // class java/util/ArrayList
     606: dup
     607: aload         14
     609: bipush        10
     611: invokestatic  #23                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     614: invokespecial #26                 // Method java/util/ArrayList."<init>":(I)V
     617: checkcast     #28                 // class java/util/Collection
     620: astore        17
     622: iconst_0
     623: istore        18
     625: aload         16
     627: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     632: astore        19
     634: aload         19
     636: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     641: ifeq          792
     644: aload         19
     646: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     651: astore        20
     653: aload         17
     655: aload         20
     657: checkcast     #74                 // class java/util/List
     660: astore        21
     662: astore        22
     664: iconst_0
     665: istore        23
     667: aload         21
     669: checkcast     #15                 // class java/lang/Iterable
     672: astore        24
     674: iconst_0
     675: istore        25
     677: aload         24
     679: astore        26
     681: new           #17                 // class java/util/ArrayList
     684: dup
     685: aload         24
     687: bipush        10
     689: invokestatic  #23                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     692: invokespecial #26                 // Method java/util/ArrayList."<init>":(I)V
     695: checkcast     #28                 // class java/util/Collection
     698: astore        27
     700: iconst_0
     701: istore        28
     703: aload         26
     705: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     710: astore        29
     712: aload         29
     714: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     719: ifeq          773
     722: aload         29
     724: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     729: astore        30
     731: aload         27
     733: aload         30
     735: checkcast     #47                 // class java/lang/Number
     738: invokevirtual #51                 // Method java/lang/Number.intValue:()I
     741: istore        31
     743: astore        32
     745: iconst_0
     746: istore        33
     748: getstatic     #153                // Field Day15.INSTANCE:LDay15;
     751: iload         31
     753: iload         12
     755: invokestatic  #157                // Method Day15.access$round:(LDay15;II)I
     758: invokestatic  #57                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     761: aload         32
     763: swap
     764: invokeinterface #72,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     769: pop
     770: goto          712
     773: aload         27
     775: checkcast     #74                 // class java/util/List
     778: nop
     779: nop
     780: aload         22
     782: swap
     783: invokeinterface #72,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     788: pop
     789: goto          634
     792: aload         17
     794: checkcast     #74                 // class java/util/List
     797: nop
     798: checkcast     #15                 // class java/lang/Iterable
     801: nop
     802: astore        12
     804: aload         8
     806: aload         12
     808: invokestatic  #161                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     811: pop
     812: goto          563
     815: aload         8
     817: checkcast     #74                 // class java/util/List
     820: nop
     821: nop
     822: checkcast     #15                 // class java/lang/Iterable
     825: astore_2
     826: nop
     827: iconst_0
     828: istore_3
     829: aload_2
     830: astore        4
     832: new           #17                 // class java/util/ArrayList
     835: dup
     836: aload_2
     837: bipush        10
     839: invokestatic  #23                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     842: invokespecial #26                 // Method java/util/ArrayList."<init>":(I)V
     845: checkcast     #28                 // class java/util/Collection
     848: astore        5
     850: iconst_0
     851: istore        6
     853: iconst_0
     854: istore        7
     856: aload         4
     858: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     863: astore        8
     865: aload         8
     867: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     872: ifeq          939
     875: aload         8
     877: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     882: astore        9
     884: aload         5
     886: iload         7
     888: iinc          7, 1
     891: istore        10
     893: iload         10
     895: ifge          901
     898: invokestatic  #45                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     901: iload         10
     903: aload         9
     905: checkcast     #74                 // class java/util/List
     908: astore        11
     910: istore        12
     912: astore        34
     914: iconst_0
     915: istore        13
     917: getstatic     #163                // Field INSTANCE:LDay15$Part2;
     920: iload         12
     922: aload         11
     924: invokespecial #165                // Method toCoordinates:(ILjava/util/List;)Ljava/util/List;
     927: aload         34
     929: swap
     930: invokeinterface #72,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     935: pop
     936: goto          865
     939: aload         5
     941: checkcast     #74                 // class java/util/List
     944: nop
     945: checkcast     #15                 // class java/lang/Iterable
     948: invokestatic  #169                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     951: checkcast     #15                 // class java/lang/Iterable
     954: astore_2
     955: nop
     956: iconst_0
     957: istore_3
     958: aload_2
     959: bipush        10
     961: invokestatic  #23                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     964: invokestatic  #175                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
     967: bipush        16
     969: invokestatic  #181                // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I
     972: istore        4
     974: aload_2
     975: astore        5
     977: new           #183                // class java/util/LinkedHashMap
     980: dup
     981: iload         4
     983: invokespecial #184                // Method java/util/LinkedHashMap."<init>":(I)V
     986: checkcast     #186                // class java/util/Map
     989: astore        6
     991: iconst_0
     992: istore        7
     994: aload         5
     996: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
    1001: astore        8
    1003: aload         8
    1005: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1010: ifeq          1061
    1013: aload         8
    1015: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1020: astore        9
    1022: aload         6
    1024: astore        10
    1026: aload         9
    1028: checkcast     #188                // class kotlin/Pair
    1031: astore        11
    1033: iconst_0
    1034: istore        12
    1036: aload         11
    1038: astore        11
    1040: aload         10
    1042: aload         11
    1044: invokevirtual #191                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
    1047: aload         11
    1049: invokevirtual #194                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
    1052: invokeinterface #198,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    1057: pop
    1058: goto          1003
    1061: aload         6
    1063: nop
    1064: astore_1
    1065: aload_1
    1066: invokeinterface #202,  1          // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
    1071: checkcast     #15                 // class java/lang/Iterable
    1074: invokestatic  #206                // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;
    1077: checkcast     #65                 // class Day15$Square
    1080: iconst_0
    1081: invokevirtual #209                // Method Day15$Square.setDistance:(I)V
    1084: aload_1
    1085: invokeinterface #202,  1          // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
    1090: invokestatic  #213                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
    1093: astore_2
    1094: aload_2
    1095: invokeinterface #216,  1          // InterfaceMethod java/util/List.size:()I
    1100: istore_3
    1101: iconst_0
    1102: istore        4
    1104: aload_2
    1105: checkcast     #28                 // class java/util/Collection
    1108: invokeinterface #219,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
    1113: ifne          1120
    1116: iconst_1
    1117: goto          1121
    1120: iconst_0
    1121: ifeq          1322
    1124: iload         4
    1126: iinc          4, 1
    1129: sipush        500
    1132: irem
    1133: ifne          1186
    1136: new           #221                // class java/lang/StringBuilder
    1139: dup
    1140: invokespecial #222                // Method java/lang/StringBuilder."<init>":()V
    1143: iload         4
    1145: invokevirtual #226                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
    1148: bipush        47
    1150: invokevirtual #229                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
    1153: iload_3
    1154: invokevirtual #226                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
    1157: ldc           #231                // String  (
    1159: invokevirtual #234                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
    1162: aload_2
    1163: invokeinterface #216,  1          // InterfaceMethod java/util/List.size:()I
    1168: invokevirtual #226                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
    1171: bipush        41
    1173: invokevirtual #229                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
    1176: invokevirtual #238                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
    1179: getstatic     #244                // Field java/lang/System.out:Ljava/io/PrintStream;
    1182: swap
    1183: invokevirtual #250                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
    1186: aload_2
    1187: checkcast     #15                 // class java/lang/Iterable
    1190: invokestatic  #254                // Method kotlin/collections/CollectionsKt.minOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
    1193: dup
    1194: invokestatic  #257                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
    1197: checkcast     #65                 // class Day15$Square
    1200: astore        5
    1202: aload_2
    1203: aload         5
    1205: invokeinterface #260,  2          // InterfaceMethod java/util/List.remove:(Ljava/lang/Object;)Z
    1210: pop
    1211: aload         5
    1213: aload_1
    1214: aload_2
    1215: checkcast     #28                 // class java/util/Collection
    1218: aconst_null
    1219: iconst_4
    1220: aconst_null
    1221: invokestatic  #264                // Method Day15$Square.getNeighbours$default:(LDay15$Square;Ljava/util/Map;Ljava/util/Collection;Ljava/util/List;ILjava/lang/Object;)Lkotlin/sequences/Sequence;
    1224: astore        6
    1226: aload         6
    1228: astore        7
    1230: iconst_0
    1231: istore        8
    1233: aload         7
    1235: invokeinterface #267,  1          // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
    1240: astore        9
    1242: aload         9
    1244: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1249: ifeq          1318
    1252: aload         9
    1254: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1259: astore        10
    1261: aload         10
    1263: checkcast     #65                 // class Day15$Square
    1266: astore        11
    1268: iconst_0
    1269: istore        12
    1271: aload         5
    1273: invokevirtual #270                // Method Day15$Square.getDistance:()I
    1276: aload         5
    1278: invokevirtual #273                // Method Day15$Square.getRisk:()I
    1281: iadd
    1282: aload         11
    1284: invokevirtual #270                // Method Day15$Square.getDistance:()I
    1287: if_icmpge     1313
    1290: aload         11
    1292: aload         5
    1294: invokevirtual #270                // Method Day15$Square.getDistance:()I
    1297: aload         5
    1299: invokevirtual #273                // Method Day15$Square.getRisk:()I
    1302: iadd
    1303: invokevirtual #209                // Method Day15$Square.setDistance:(I)V
    1306: aload         11
    1308: aload         5
    1310: invokevirtual #277                // Method Day15$Square.setParent:(LDay15$Square;)V
    1313: nop
    1314: nop
    1315: goto          1242
    1318: nop
    1319: goto          1104
    1322: aload_1
    1323: invokeinterface #202,  1          // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
    1328: checkcast     #15                 // class java/lang/Iterable
    1331: invokestatic  #280                // Method kotlin/collections/CollectionsKt.last:(Ljava/lang/Iterable;)Ljava/lang/Object;
    1334: checkcast     #65                 // class Day15$Square
    1337: astore        5
    1339: iconst_1
    1340: anewarray     #65                 // class Day15$Square
    1343: astore        7
    1345: aload         7
    1347: iconst_0
    1348: aload         5
    1350: aastore
    1351: aload         7
    1353: invokestatic  #284                // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
    1356: astore        6
    1358: aload         5
    1360: invokevirtual #288                // Method Day15$Square.getParent:()LDay15$Square;
    1363: ifnull        1390
    1366: aload         5
    1368: invokevirtual #288                // Method Day15$Square.getParent:()LDay15$Square;
    1371: dup
    1372: invokestatic  #257                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
    1375: astore        5
    1377: aload         6
    1379: aload         5
    1381: invokeinterface #289,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
    1386: pop
    1387: goto          1358
    1390: getstatic     #153                // Field Day15.INSTANCE:LDay15;
    1393: aload         6
    1395: checkcast     #28                 // class java/util/Collection
    1398: invokestatic  #293                // Method Day15.access$draw:(LDay15;Ljava/util/Collection;)V
    1401: aload         6
    1403: checkcast     #15                 // class java/lang/Iterable
    1406: invokestatic  #296                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
    1409: checkcast     #15                 // class java/lang/Iterable
    1412: astore        7
    1414: iconst_0
    1415: istore        8
    1417: aload         7
    1419: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
    1424: astore        9
    1426: aload         9
    1428: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1433: ifeq          1512
    1436: aload         9
    1438: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1443: astore        10
    1445: aload         10
    1447: checkcast     #65                 // class Day15$Square
    1450: astore        11
    1452: iconst_0
    1453: istore        12
    1455: new           #221                // class java/lang/StringBuilder
    1458: dup
    1459: invokespecial #222                // Method java/lang/StringBuilder."<init>":()V
    1462: aload         11
    1464: invokevirtual #300                // Method Day15$Square.getCoord:()Lkotlin/Pair;
    1467: invokevirtual #303                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
    1470: bipush        32
    1472: invokevirtual #229                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
    1475: aload         11
    1477: invokevirtual #273                // Method Day15$Square.getRisk:()I
    1480: invokevirtual #226                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
    1483: ldc_w         #305                // String
    1486: invokevirtual #234                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
    1489: aload         11
    1491: invokevirtual #270                // Method Day15$Square.getDistance:()I
    1494: invokevirtual #226                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
    1497: invokevirtual #238                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
    1500: getstatic     #244                // Field java/lang/System.out:Ljava/io/PrintStream;
    1503: swap
    1504: invokevirtual #250                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
    1507: nop
    1508: nop
    1509: goto          1426
    1512: nop
    1513: aload         6
    1515: checkcast     #15                 // class java/lang/Iterable
    1518: astore        7
    1520: iconst_0
    1521: istore        8
    1523: aload         7
    1525: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
    1530: astore        9
    1532: aload         9
    1534: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1539: ifeq          1582
    1542: aload         9
    1544: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1549: astore        10
    1551: iload         8
    1553: aload         10
    1555: checkcast     #65                 // class Day15$Square
    1558: astore        11
    1560: istore        34
    1562: iconst_0
    1563: istore        12
    1565: aload         11
    1567: invokevirtual #273                // Method Day15$Square.getRisk:()I
    1570: istore        35
    1572: iload         34
    1574: iload         35
    1576: iadd
    1577: istore        8
    1579: goto          1532
    1582: iload         8
    1584: istore        7
    1586: iload         7
    1588: istore        8
    1590: iconst_0
    1591: istore        9
    1593: iload         8
    1595: aload_1
    1596: invokeinterface #202,  1          // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
    1601: checkcast     #15                 // class java/lang/Iterable
    1604: invokestatic  #206                // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;
    1607: checkcast     #65                 // class Day15$Square
    1610: invokevirtual #273                // Method Day15$Square.getRisk:()I
    1613: isub
    1614: istore        10
    1616: getstatic     #244                // Field java/lang/System.out:Ljava/io/PrintStream;
    1619: iload         10
    1621: invokevirtual #307                // Method java/io/PrintStream.println:(I)V
    1624: nop
    1625: nop
    1626: return

  static {};
    Code:
       0: new           #2                  // class Day15$Part2
       3: dup
       4: invokespecial #362                // Method "<init>":()V
       7: putstatic     #163                // Field INSTANCE:LDay15$Part2;
      10: return
}