package day23

import java.io.File

fun main() {
    val data = parse("src/main/kotlin/day23/Day23.txt")

    val answer1 = part1(data)
    val answer2 = part2(data)

    println("🎄 Day 23 🎄")

    println()

    println("[Part 1]")
    println("Answer: $answer1")

    println()

    println("[Part 2]")
    println("Answer: $answer2")
}

typealias Point = Pair<Int, Int>

@Suppress("SameParameterValue")
private fun parse(path: String): Set<Point> {
    val elves = mutableSetOf<Pair<Int, Int>>()
    val lines = File(path).readLines()
    for ((y, row) in lines.withIndex()) {
        for ((x, col) in row.withIndex()) {
            if (col == '#') {
                elves += x to y
            }
        }
    }
    return elves
}

private fun Point.neighbors(): List<Point> {
    val (x, y) = this
    return listOf(
        x - 1 to y - 1,
        x + 0 to y - 1,
        x + 1 to y - 1,
        x - 1 to y + 0,
        x + 1 to y + 0,
        x - 1 to y + 1,
        x + 0 to y + 1,
        x + 1 to y + 1,
    )
}

private val directions = listOf(
    (+0 to -1) to listOf(-1 to -1, +0 to -1, +1 to -1), // North
    (+0 to +1) to listOf(-1 to +1, +0 to +1, +1 to +1), // South
    (-1 to +0) to listOf(-1 to -1, -1 to +0, -1 to +1), // West
    (+1 to +0) to listOf(+1 to -1, +1 to +0, +1 to +1), // East
)

private data class State(
    val elves: Set<Point>,
    val firstDirection: Int = 0,
)

private fun State.next(): State {
    val movements = mutableMapOf<Point, List<Point>>()
    for ((x, y) in elves) {
        if ((x to y).neighbors().all { it !in elves }) {
            continue
        }
        search@for (i in 0..3) {
            val (proposal, offsets) = directions[(firstDirection + i) % 4]
            if (offsets.all { (dx, dy) ->  (x + dx) to (y + dy) !in elves }) {
                val (px, py) = proposal
                val (nx, ny) = (x + px) to (y + py)
                movements.merge(nx to ny, listOf(x to y)) { a, b -> a + b }
                break@search
            }
        }
    }

    val newElves = elves.toMutableSet()
    for ((position, candidates) in movements) {
        if (candidates.size == 1) {
            newElves -= candidates.first()
            newElves += position
        }
    }

    val newFirstDirection = (firstDirection + 1) % 4
    return State(newElves, newFirstDirection)
}

private fun part1(data: Set<Point>): Int =
    generateSequence(State(data), State::next)
        .drop(10)
        .first()
        .let { (elves, _) ->
            val minX = elves.minOf { (x, _) -> x }
            val maxX = elves.maxOf { (x, _) -> x }
            val minY = elves.minOf { (_, y) -> y }
            val maxY = elves.maxOf { (_, y) -> y }

            (minY..maxY).sumOf { y ->
                (minX..maxX).sumOf { x ->
                    (if (x to y !in elves) 1 else 0).toInt()
                }
            }
        }

private fun part2(data: Set<Point>): Int =
    generateSequence(State(data), State::next)
        .zipWithNext()
        .withIndex()
        .dropWhile { (_, states) -> states.let { (s0, s1) -> s0.elves != s1.elves }  }
        .first()
        .let { (idx, _) -> idx + 1 }

Compiled from "Day23.kt"
public final class day23.Day23Kt {
  private static final java.util.List<kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>>>> directions;

  public static final void main();
    Code:
       0: ldc           #8                  // String src/main/kotlin/day23/Day23.txt
       2: invokestatic  #12                 // Method parse:(Ljava/lang/String;)Ljava/util/Set;
       5: astore_0
       6: aload_0
       7: invokestatic  #16                 // Method part1:(Ljava/util/Set;)I
      10: istore_1
      11: aload_0
      12: invokestatic  #19                 // Method part2:(Ljava/util/Set;)I
      15: istore_2
      16: ldc           #21                 // String 🎄 Day 23 🎄
      18: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      21: swap
      22: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      25: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      28: invokevirtual #35                 // Method java/io/PrintStream.println:()V
      31: ldc           #37                 // String [Part 1]
      33: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      36: swap
      37: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      40: new           #39                 // class java/lang/StringBuilder
      43: dup
      44: invokespecial #42                 // Method java/lang/StringBuilder."<init>":()V
      47: ldc           #44                 // String Answer:
      49: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      52: iload_1
      53: invokevirtual #51                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      56: invokevirtual #55                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      59: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      62: swap
      63: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      66: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      69: invokevirtual #35                 // Method java/io/PrintStream.println:()V
      72: ldc           #57                 // String [Part 2]
      74: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      77: swap
      78: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      81: new           #39                 // class java/lang/StringBuilder
      84: dup
      85: invokespecial #42                 // Method java/lang/StringBuilder."<init>":()V
      88: ldc           #44                 // String Answer:
      90: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      93: iload_2
      94: invokevirtual #51                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      97: invokevirtual #55                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     100: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
     103: swap
     104: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     107: return

  private static final java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>> parse(java.lang.String);
    Code:
       0: new           #65                 // class java/util/LinkedHashSet
       3: dup
       4: invokespecial #66                 // Method java/util/LinkedHashSet."<init>":()V
       7: checkcast     #68                 // class java/util/Set
      10: astore_1
      11: new           #70                 // class java/io/File
      14: dup
      15: aload_0
      16: invokespecial #73                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      19: aconst_null
      20: iconst_1
      21: aconst_null
      22: invokestatic  #79                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      25: astore_2
      26: aload_2
      27: checkcast     #81                 // class java/lang/Iterable
      30: invokeinterface #85,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      35: astore_3
      36: iconst_0
      37: istore        4
      39: aload_3
      40: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      45: ifeq          135
      48: iload         4
      50: istore        5
      52: iload         4
      54: iconst_1
      55: iadd
      56: istore        4
      58: aload_3
      59: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      64: checkcast     #97                 // class java/lang/String
      67: astore        6
      69: iconst_0
      70: istore        7
      72: aload         6
      74: invokevirtual #101                // Method java/lang/String.length:()I
      77: istore        8
      79: iload         7
      81: iload         8
      83: if_icmpge     39
      86: iload         7
      88: istore        9
      90: aload         6
      92: iload         7
      94: invokevirtual #105                // Method java/lang/String.charAt:(I)C
      97: istore        10
      99: iload         10
     101: bipush        35
     103: if_icmpne     129
     106: aload_1
     107: checkcast     #107                // class java/util/Collection
     110: iload         9
     112: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     115: iload         5
     117: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     120: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     123: invokeinterface #123,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     128: pop
     129: iinc          7, 1
     132: goto          79
     135: aload_1
     136: areturn

  private static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> neighbors(kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: invokevirtual #143                // Method kotlin/Pair.component1:()Ljava/lang/Object;
       4: checkcast     #145                // class java/lang/Number
       7: invokevirtual #148                // Method java/lang/Number.intValue:()I
      10: istore_1
      11: aload_0
      12: invokevirtual #151                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      15: checkcast     #145                // class java/lang/Number
      18: invokevirtual #148                // Method java/lang/Number.intValue:()I
      21: istore_2
      22: bipush        8
      24: anewarray     #140                // class kotlin/Pair
      27: astore_3
      28: aload_3
      29: iconst_0
      30: iload_1
      31: iconst_1
      32: isub
      33: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      36: iload_2
      37: iconst_1
      38: isub
      39: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      42: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      45: aastore
      46: aload_3
      47: iconst_1
      48: iload_1
      49: iconst_0
      50: iadd
      51: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      54: iload_2
      55: iconst_1
      56: isub
      57: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      60: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      63: aastore
      64: aload_3
      65: iconst_2
      66: iload_1
      67: iconst_1
      68: iadd
      69: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      72: iload_2
      73: iconst_1
      74: isub
      75: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      78: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      81: aastore
      82: aload_3
      83: iconst_3
      84: iload_1
      85: iconst_1
      86: isub
      87: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      90: iload_2
      91: iconst_0
      92: iadd
      93: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      96: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      99: aastore
     100: aload_3
     101: iconst_4
     102: iload_1
     103: iconst_1
     104: iadd
     105: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     108: iload_2
     109: iconst_0
     110: iadd
     111: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     114: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     117: aastore
     118: aload_3
     119: iconst_5
     120: iload_1
     121: iconst_1
     122: isub
     123: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     126: iload_2
     127: iconst_1
     128: iadd
     129: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     132: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     135: aastore
     136: aload_3
     137: bipush        6
     139: iload_1
     140: iconst_0
     141: iadd
     142: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     145: iload_2
     146: iconst_1
     147: iadd
     148: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     151: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     154: aastore
     155: aload_3
     156: bipush        7
     158: iload_1
     159: iconst_1
     160: iadd
     161: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     164: iload_2
     165: iconst_1
     166: iadd
     167: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     170: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     173: aastore
     174: aload_3
     175: invokestatic  #157                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     178: areturn

  private static final day23.State next(day23.State);
    Code:
       0: new           #162                // class java/util/LinkedHashMap
       3: dup
       4: invokespecial #163                // Method java/util/LinkedHashMap."<init>":()V
       7: checkcast     #165                // class java/util/Map
      10: astore_1
      11: aload_0
      12: invokevirtual #171                // Method day23/State.getElves:()Ljava/util/Set;
      15: invokeinterface #172,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
      20: astore_2
      21: aload_2
      22: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      27: ifeq          509
      30: aload_2
      31: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      36: checkcast     #140                // class kotlin/Pair
      39: astore_3
      40: aload_3
      41: invokevirtual #143                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      44: checkcast     #145                // class java/lang/Number
      47: invokevirtual #148                // Method java/lang/Number.intValue:()I
      50: istore        4
      52: aload_3
      53: invokevirtual #151                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      56: checkcast     #145                // class java/lang/Number
      59: invokevirtual #148                // Method java/lang/Number.intValue:()I
      62: istore        5
      64: iload         4
      66: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      69: iload         5
      71: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      74: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      77: invokestatic  #174                // Method neighbors:(Lkotlin/Pair;)Ljava/util/List;
      80: checkcast     #81                 // class java/lang/Iterable
      83: astore        6
      85: iconst_0
      86: istore        7
      88: aload         6
      90: instanceof    #107                // class java/util/Collection
      93: ifeq          113
      96: aload         6
      98: checkcast     #107                // class java/util/Collection
     101: invokeinterface #177,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     106: ifeq          113
     109: iconst_1
     110: goto          178
     113: aload         6
     115: invokeinterface #85,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     120: astore        8
     122: aload         8
     124: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     129: ifeq          177
     132: aload         8
     134: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     139: astore        9
     141: aload         9
     143: checkcast     #140                // class kotlin/Pair
     146: astore        10
     148: iconst_0
     149: istore        11
     151: aload_0
     152: invokevirtual #171                // Method day23/State.getElves:()Ljava/util/Set;
     155: aload         10
     157: invokeinterface #180,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     162: ifne          169
     165: iconst_1
     166: goto          170
     169: iconst_0
     170: ifne          122
     173: iconst_0
     174: goto          178
     177: iconst_1
     178: ifeq          184
     181: goto          21
     184: iconst_0
     185: istore        6
     187: iload         6
     189: iconst_4
     190: if_icmpge     21
     193: getstatic     #183                // Field directions:Ljava/util/List;
     196: aload_0
     197: invokevirtual #186                // Method day23/State.getFirstDirection:()I
     200: iload         6
     202: iadd
     203: iconst_4
     204: irem
     205: invokeinterface #190,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     210: checkcast     #140                // class kotlin/Pair
     213: astore        7
     215: aload         7
     217: invokevirtual #143                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     220: checkcast     #140                // class kotlin/Pair
     223: astore        8
     225: aload         7
     227: invokevirtual #151                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     230: checkcast     #135                // class java/util/List
     233: astore        9
     235: aload         9
     237: checkcast     #81                 // class java/lang/Iterable
     240: astore        10
     242: iconst_0
     243: istore        11
     245: aload         10
     247: instanceof    #107                // class java/util/Collection
     250: ifeq          270
     253: aload         10
     255: checkcast     #107                // class java/util/Collection
     258: invokeinterface #177,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     263: ifeq          270
     266: iconst_1
     267: goto          378
     270: aload         10
     272: invokeinterface #85,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     277: astore        12
     279: aload         12
     281: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     286: ifeq          377
     289: aload         12
     291: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     296: astore        13
     298: aload         13
     300: checkcast     #140                // class kotlin/Pair
     303: astore        14
     305: iconst_0
     306: istore        15
     308: aload         14
     310: invokevirtual #143                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     313: checkcast     #145                // class java/lang/Number
     316: invokevirtual #148                // Method java/lang/Number.intValue:()I
     319: istore        16
     321: aload         14
     323: invokevirtual #151                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     326: checkcast     #145                // class java/lang/Number
     329: invokevirtual #148                // Method java/lang/Number.intValue:()I
     332: istore        17
     334: aload_0
     335: invokevirtual #171                // Method day23/State.getElves:()Ljava/util/Set;
     338: iload         4
     340: iload         16
     342: iadd
     343: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     346: iload         5
     348: iload         17
     350: iadd
     351: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     354: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     357: invokeinterface #180,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     362: ifne          369
     365: iconst_1
     366: goto          370
     369: iconst_0
     370: ifne          279
     373: iconst_0
     374: goto          378
     377: iconst_1
     378: ifeq          503
     381: aload         8
     383: invokevirtual #143                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     386: checkcast     #145                // class java/lang/Number
     389: invokevirtual #148                // Method java/lang/Number.intValue:()I
     392: istore        10
     394: aload         8
     396: invokevirtual #151                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     399: checkcast     #145                // class java/lang/Number
     402: invokevirtual #148                // Method java/lang/Number.intValue:()I
     405: istore        11
     407: iload         4
     409: iload         10
     411: iadd
     412: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     415: iload         5
     417: iload         11
     419: iadd
     420: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     423: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     426: astore        12
     428: aload         12
     430: invokevirtual #143                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     433: checkcast     #145                // class java/lang/Number
     436: invokevirtual #148                // Method java/lang/Number.intValue:()I
     439: istore        13
     441: aload         12
     443: invokevirtual #151                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     446: checkcast     #145                // class java/lang/Number
     449: invokevirtual #148                // Method java/lang/Number.intValue:()I
     452: istore        14
     454: aload_1
     455: iload         13
     457: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     460: iload         14
     462: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     465: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     468: iload         4
     470: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     473: iload         5
     475: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     478: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     481: invokestatic  #193                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     484: invokedynamic #212,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;
     489: invokedynamic #223,  0            // InvokeDynamic #1:apply:(Lkotlin/jvm/functions/Function2;)Ljava/util/function/BiFunction;
     494: invokeinterface #227,  4          // InterfaceMethod java/util/Map.merge:(Ljava/lang/Object;Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;
     499: pop
     500: goto          21
     503: iinc          6, 1
     506: goto          187
     509: aload_0
     510: invokevirtual #171                // Method day23/State.getElves:()Ljava/util/Set;
     513: checkcast     #81                 // class java/lang/Iterable
     516: invokestatic  #231                // Method kotlin/collections/CollectionsKt.toMutableSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     519: astore_2
     520: aload_1
     521: invokeinterface #234,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     526: invokeinterface #172,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     531: astore_3
     532: aload_3
     533: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     538: ifeq          617
     541: aload_3
     542: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     547: checkcast     #236                // class java/util/Map$Entry
     550: astore        4
     552: aload         4
     554: invokeinterface #239,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     559: checkcast     #140                // class kotlin/Pair
     562: astore        5
     564: aload         4
     566: invokeinterface #242,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     571: checkcast     #135                // class java/util/List
     574: astore        6
     576: aload         6
     578: invokeinterface #245,  1          // InterfaceMethod java/util/List.size:()I
     583: iconst_1
     584: if_icmpne     532
     587: aload_2
     588: checkcast     #107                // class java/util/Collection
     591: aload         6
     593: invokestatic  #249                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     596: invokeinterface #252,  2          // InterfaceMethod java/util/Collection.remove:(Ljava/lang/Object;)Z
     601: pop
     602: aload_2
     603: checkcast     #107                // class java/util/Collection
     606: aload         5
     608: invokeinterface #123,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     613: pop
     614: goto          532
     617: aload_0
     618: invokevirtual #186                // Method day23/State.getFirstDirection:()I
     621: iconst_1
     622: iadd
     623: iconst_4
     624: irem
     625: istore_3
     626: new           #167                // class day23/State
     629: dup
     630: aload_2
     631: iload_3
     632: invokespecial #255                // Method day23/State."<init>":(Ljava/util/Set;I)V
     635: areturn

  private static final int part1(java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>>);
    Code:
       0: new           #167                // class day23/State
       3: dup
       4: aload_0
       5: iconst_0
       6: iconst_2
       7: aconst_null
       8: invokespecial #284                // Method day23/State."<init>":(Ljava/util/Set;IILkotlin/jvm/internal/DefaultConstructorMarker;)V
      11: getstatic     #290                // Field day23/Day23Kt$part1$1.INSTANCE:Lday23/Day23Kt$part1$1;
      14: checkcast     #292                // class kotlin/jvm/functions/Function1
      17: invokestatic  #298                // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      20: bipush        10
      22: invokestatic  #302                // Method kotlin/sequences/SequencesKt.drop:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;
      25: invokestatic  #305                // Method kotlin/sequences/SequencesKt.first:(Lkotlin/sequences/Sequence;)Ljava/lang/Object;
      28: checkcast     #167                // class day23/State
      31: astore_1
      32: iconst_0
      33: istore_2
      34: aload_1
      35: invokevirtual #307                // Method day23/State.component1:()Ljava/util/Set;
      38: astore_3
      39: aload_3
      40: checkcast     #81                 // class java/lang/Iterable
      43: invokeinterface #85,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      48: astore        4
      50: aload         4
      52: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      57: ifne          68
      60: new           #309                // class java/util/NoSuchElementException
      63: dup
      64: invokespecial #310                // Method java/util/NoSuchElementException."<init>":()V
      67: athrow
      68: aload         4
      70: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      75: checkcast     #140                // class kotlin/Pair
      78: astore        5
      80: iconst_0
      81: istore        6
      83: aload         5
      85: invokevirtual #143                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      88: checkcast     #145                // class java/lang/Number
      91: invokevirtual #148                // Method java/lang/Number.intValue:()I
      94: istore        7
      96: iload         7
      98: istore        5
     100: aload         4
     102: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     107: ifeq          156
     110: aload         4
     112: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     117: checkcast     #140                // class kotlin/Pair
     120: astore        6
     122: iconst_0
     123: istore        7
     125: aload         6
     127: invokevirtual #143                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     130: checkcast     #145                // class java/lang/Number
     133: invokevirtual #148                // Method java/lang/Number.intValue:()I
     136: istore        8
     138: iload         8
     140: istore        6
     142: iload         5
     144: iload         6
     146: if_icmple     100
     149: iload         6
     151: istore        5
     153: goto          100
     156: iload         5
     158: istore        9
     160: aload_3
     161: checkcast     #81                 // class java/lang/Iterable
     164: invokeinterface #85,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     169: astore        5
     171: aload         5
     173: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     178: ifne          189
     181: new           #309                // class java/util/NoSuchElementException
     184: dup
     185: invokespecial #310                // Method java/util/NoSuchElementException."<init>":()V
     188: athrow
     189: aload         5
     191: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     196: checkcast     #140                // class kotlin/Pair
     199: astore        6
     201: iconst_0
     202: istore        7
     204: aload         6
     206: invokevirtual #143                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     209: checkcast     #145                // class java/lang/Number
     212: invokevirtual #148                // Method java/lang/Number.intValue:()I
     215: istore        8
     217: iload         8
     219: istore        6
     221: aload         5
     223: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     228: ifeq          277
     231: aload         5
     233: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     238: checkcast     #140                // class kotlin/Pair
     241: astore        7
     243: iconst_0
     244: istore        8
     246: aload         7
     248: invokevirtual #143                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     251: checkcast     #145                // class java/lang/Number
     254: invokevirtual #148                // Method java/lang/Number.intValue:()I
     257: istore        10
     259: iload         10
     261: istore        7
     263: iload         6
     265: iload         7
     267: if_icmpge     221
     270: iload         7
     272: istore        6
     274: goto          221
     277: iload         6
     279: istore        11
     281: aload_3
     282: checkcast     #81                 // class java/lang/Iterable
     285: invokeinterface #85,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     290: astore        6
     292: aload         6
     294: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     299: ifne          310
     302: new           #309                // class java/util/NoSuchElementException
     305: dup
     306: invokespecial #310                // Method java/util/NoSuchElementException."<init>":()V
     309: athrow
     310: aload         6
     312: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     317: checkcast     #140                // class kotlin/Pair
     320: astore        7
     322: iconst_0
     323: istore        8
     325: aload         7
     327: invokevirtual #151                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     330: checkcast     #145                // class java/lang/Number
     333: invokevirtual #148                // Method java/lang/Number.intValue:()I
     336: istore        10
     338: iload         10
     340: istore        7
     342: aload         6
     344: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     349: ifeq          398
     352: aload         6
     354: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     359: checkcast     #140                // class kotlin/Pair
     362: astore        8
     364: iconst_0
     365: istore        10
     367: aload         8
     369: invokevirtual #151                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     372: checkcast     #145                // class java/lang/Number
     375: invokevirtual #148                // Method java/lang/Number.intValue:()I
     378: istore        12
     380: iload         12
     382: istore        8
     384: iload         7
     386: iload         8
     388: if_icmple     342
     391: iload         8
     393: istore        7
     395: goto          342
     398: iload         7
     400: istore        4
     402: aload_3
     403: checkcast     #81                 // class java/lang/Iterable
     406: invokeinterface #85,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     411: astore        7
     413: aload         7
     415: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     420: ifne          431
     423: new           #309                // class java/util/NoSuchElementException
     426: dup
     427: invokespecial #310                // Method java/util/NoSuchElementException."<init>":()V
     430: athrow
     431: aload         7
     433: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     438: checkcast     #140                // class kotlin/Pair
     441: astore        8
     443: iconst_0
     444: istore        10
     446: aload         8
     448: invokevirtual #151                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     451: checkcast     #145                // class java/lang/Number
     454: invokevirtual #148                // Method java/lang/Number.intValue:()I
     457: istore        12
     459: iload         12
     461: istore        8
     463: aload         7
     465: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     470: ifeq          519
     473: aload         7
     475: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     480: checkcast     #140                // class kotlin/Pair
     483: astore        10
     485: iconst_0
     486: istore        12
     488: aload         10
     490: invokevirtual #151                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     493: checkcast     #145                // class java/lang/Number
     496: invokevirtual #148                // Method java/lang/Number.intValue:()I
     499: istore        13
     501: iload         13
     503: istore        10
     505: iload         8
     507: iload         10
     509: if_icmpge     463
     512: iload         10
     514: istore        8
     516: goto          463
     519: iload         8
     521: istore        5
     523: new           #312                // class kotlin/ranges/IntRange
     526: dup
     527: iload         4
     529: iload         5
     531: invokespecial #315                // Method kotlin/ranges/IntRange."<init>":(II)V
     534: checkcast     #81                 // class java/lang/Iterable
     537: astore        6
     539: iconst_0
     540: istore        7
     542: aload         6
     544: invokeinterface #85,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     549: astore        8
     551: aload         8
     553: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     558: ifeq          695
     561: aload         8
     563: checkcast     #317                // class kotlin/collections/IntIterator
     566: invokevirtual #320                // Method kotlin/collections/IntIterator.nextInt:()I
     569: istore        10
     571: iload         7
     573: iload         10
     575: istore        12
     577: istore        14
     579: iconst_0
     580: istore        13
     582: new           #312                // class kotlin/ranges/IntRange
     585: dup
     586: iload         9
     588: iload         11
     590: invokespecial #315                // Method kotlin/ranges/IntRange."<init>":(II)V
     593: checkcast     #81                 // class java/lang/Iterable
     596: astore        15
     598: iconst_0
     599: istore        16
     601: aload         15
     603: invokeinterface #85,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     608: astore        17
     610: aload         17
     612: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     617: ifeq          680
     620: aload         17
     622: checkcast     #317                // class kotlin/collections/IntIterator
     625: invokevirtual #320                // Method kotlin/collections/IntIterator.nextInt:()I
     628: istore        18
     630: iload         16
     632: iload         18
     634: istore        19
     636: istore        20
     638: iconst_0
     639: istore        21
     641: aload_3
     642: iload         19
     644: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     647: iload         12
     649: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     652: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     655: invokeinterface #180,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     660: ifne          667
     663: iconst_1
     664: goto          668
     667: iconst_0
     668: istore        22
     670: iload         20
     672: iload         22
     674: iadd
     675: istore        16
     677: goto          610
     680: iload         16
     682: nop
     683: istore        23
     685: iload         14
     687: iload         23
     689: iadd
     690: istore        7
     692: goto          551
     695: iload         7
     697: nop
     698: nop
     699: ireturn

  private static final int part2(java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>>);
    Code:
       0: new           #167                // class day23/State
       3: dup
       4: aload_0
       5: iconst_0
       6: iconst_2
       7: aconst_null
       8: invokespecial #284                // Method day23/State."<init>":(Ljava/util/Set;IILkotlin/jvm/internal/DefaultConstructorMarker;)V
      11: getstatic     #336                // Field day23/Day23Kt$part2$1.INSTANCE:Lday23/Day23Kt$part2$1;
      14: checkcast     #292                // class kotlin/jvm/functions/Function1
      17: invokestatic  #298                // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      20: invokestatic  #340                // Method kotlin/sequences/SequencesKt.zipWithNext:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
      23: invokestatic  #343                // Method kotlin/sequences/SequencesKt.withIndex:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
      26: invokedynamic #355,  0            // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;
      31: invokestatic  #359                // Method kotlin/sequences/SequencesKt.dropWhile:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      34: invokestatic  #305                // Method kotlin/sequences/SequencesKt.first:(Lkotlin/sequences/Sequence;)Ljava/lang/Object;
      37: checkcast     #361                // class kotlin/collections/IndexedValue
      40: astore_1
      41: iconst_0
      42: istore_2
      43: aload_1
      44: invokevirtual #363                // Method kotlin/collections/IndexedValue.component1:()I
      47: istore_3
      48: iload_3
      49: iconst_1
      50: iadd
      51: nop
      52: ireturn

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

  private static final java.util.List next$lambda$2(java.util.List, java.util.List);
    Code:
       0: aload_0
       1: ldc_w         #372                // String a
       4: invokestatic  #378                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: ldc_w         #380                // String b
      11: invokestatic  #378                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      14: aload_0
      15: checkcast     #107                // class java/util/Collection
      18: aload_1
      19: checkcast     #81                 // class java/lang/Iterable
      22: invokestatic  #384                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
      25: areturn

  private static final java.util.List next$lambda$3(kotlin.jvm.functions.Function2, java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokeinterface #388,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
       8: checkcast     #135                // class java/util/List
      11: areturn

  private static final boolean part2$lambda$12(kotlin.collections.IndexedValue);
    Code:
       0: aload_0
       1: ldc_w         #394                // String <destruct>
       4: invokestatic  #378                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokevirtual #395                // Method kotlin/collections/IndexedValue.component2:()Ljava/lang/Object;
      11: checkcast     #140                // class kotlin/Pair
      14: astore_1
      15: aload_1
      16: astore_2
      17: iconst_0
      18: istore_3
      19: aload_2
      20: invokevirtual #143                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      23: checkcast     #167                // class day23/State
      26: astore        4
      28: aload_2
      29: invokevirtual #151                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      32: checkcast     #167                // class day23/State
      35: astore        5
      37: aload         4
      39: invokevirtual #171                // Method day23/State.getElves:()Ljava/util/Set;
      42: aload         5
      44: invokevirtual #171                // Method day23/State.getElves:()Ljava/util/Set;
      47: invokestatic  #399                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      50: ifne          57
      53: iconst_1
      54: goto          58
      57: iconst_0
      58: nop
      59: ireturn

  public static final day23.State access$next(day23.State);
    Code:
       0: aload_0
       1: invokestatic  #406                // Method next:(Lday23/State;)Lday23/State;
       4: areturn

  static {};
    Code:
       0: iconst_4
       1: anewarray     #140                // class kotlin/Pair
       4: astore_0
       5: aload_0
       6: iconst_0
       7: iconst_0
       8: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      11: iconst_m1
      12: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      15: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      18: iconst_3
      19: anewarray     #140                // class kotlin/Pair
      22: astore_1
      23: aload_1
      24: iconst_0
      25: iconst_m1
      26: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      29: iconst_m1
      30: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      33: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      36: aastore
      37: aload_1
      38: iconst_1
      39: iconst_0
      40: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      43: iconst_m1
      44: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      47: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      50: aastore
      51: aload_1
      52: iconst_2
      53: iconst_1
      54: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      57: iconst_m1
      58: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      61: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      64: aastore
      65: aload_1
      66: invokestatic  #157                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      69: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      72: aastore
      73: aload_0
      74: iconst_1
      75: iconst_0
      76: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      79: iconst_1
      80: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      83: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      86: iconst_3
      87: anewarray     #140                // class kotlin/Pair
      90: astore_1
      91: aload_1
      92: iconst_0
      93: iconst_m1
      94: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      97: iconst_1
      98: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     101: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     104: aastore
     105: aload_1
     106: iconst_1
     107: iconst_0
     108: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     111: iconst_1
     112: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     115: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     118: aastore
     119: aload_1
     120: iconst_2
     121: iconst_1
     122: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     125: iconst_1
     126: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     129: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     132: aastore
     133: aload_1
     134: invokestatic  #157                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     137: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     140: aastore
     141: aload_0
     142: iconst_2
     143: iconst_m1
     144: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     147: iconst_0
     148: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     151: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     154: iconst_3
     155: anewarray     #140                // class kotlin/Pair
     158: astore_1
     159: aload_1
     160: iconst_0
     161: iconst_m1
     162: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     165: iconst_m1
     166: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     169: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     172: aastore
     173: aload_1
     174: iconst_1
     175: iconst_m1
     176: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     179: iconst_0
     180: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     183: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     186: aastore
     187: aload_1
     188: iconst_2
     189: iconst_m1
     190: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     193: iconst_1
     194: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     197: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     200: aastore
     201: aload_1
     202: invokestatic  #157                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     205: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     208: aastore
     209: aload_0
     210: iconst_3
     211: iconst_1
     212: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     215: iconst_0
     216: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     219: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     222: iconst_3
     223: anewarray     #140                // class kotlin/Pair
     226: astore_1
     227: aload_1
     228: iconst_0
     229: iconst_1
     230: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     233: iconst_m1
     234: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     237: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     240: aastore
     241: aload_1
     242: iconst_1
     243: iconst_1
     244: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     247: iconst_0
     248: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     251: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     254: aastore
     255: aload_1
     256: iconst_2
     257: iconst_1
     258: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     261: iconst_1
     262: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     265: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     268: aastore
     269: aload_1
     270: invokestatic  #157                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     273: invokestatic  #119                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     276: aastore
     277: aload_0
     278: invokestatic  #157                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     281: putstatic     #183                // Field directions:Ljava/util/List;
     284: return
}

Compiled from "Day23.kt"
final class day23.Day23Kt$part1$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<day23.State, day23.State> {
  public static final day23.Day23Kt$part1$1 INSTANCE;

  day23.Day23Kt$part1$1();
    Code:
       0: aload_0
       1: iconst_1
       2: ldc           #11                 // class day23/Day23Kt
       4: ldc           #13                 // String next
       6: ldc           #15                 // String next(Lday23/State;)Lday23/State;
       8: iconst_1
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final day23.State invoke(day23.State);
    Code:
       0: aload_1
       1: ldc           #24                 // String p0
       3: invokestatic  #30                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokestatic  #33                 // Method day23/Day23Kt.access$next:(Lday23/State;)Lday23/State;
      10: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #37                 // class day23/State
       5: invokevirtual #39                 // Method invoke:(Lday23/State;)Lday23/State;
       8: areturn

  static {};
    Code:
       0: new           #2                  // class day23/Day23Kt$part1$1
       3: dup
       4: invokespecial #44                 // Method "<init>":()V
       7: putstatic     #47                 // Field INSTANCE:Lday23/Day23Kt$part1$1;
      10: return
}

Compiled from "Day23.kt"
final class day23.Day23Kt$part2$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<day23.State, day23.State> {
  public static final day23.Day23Kt$part2$1 INSTANCE;

  day23.Day23Kt$part2$1();
    Code:
       0: aload_0
       1: iconst_1
       2: ldc           #11                 // class day23/Day23Kt
       4: ldc           #13                 // String next
       6: ldc           #15                 // String next(Lday23/State;)Lday23/State;
       8: iconst_1
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final day23.State invoke(day23.State);
    Code:
       0: aload_1
       1: ldc           #24                 // String p0
       3: invokestatic  #30                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokestatic  #33                 // Method day23/Day23Kt.access$next:(Lday23/State;)Lday23/State;
      10: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #37                 // class day23/State
       5: invokevirtual #39                 // Method invoke:(Lday23/State;)Lday23/State;
       8: areturn

  static {};
    Code:
       0: new           #2                  // class day23/Day23Kt$part2$1
       3: dup
       4: invokespecial #44                 // Method "<init>":()V
       7: putstatic     #47                 // Field INSTANCE:Lday23/Day23Kt$part2$1;
      10: return
}


package day24

import java.io.File

fun main() {
    val data = parse("src/main/kotlin/day24/Day24.txt")

    val answer1 = part1(data)
    val answer2 = part2(data)

    println("🎄 Day 24 🎄")

    println()

    println("[Part 1]")
    println("Answer: $answer1")

    println()

    println("[Part 2]")
    println("Answer: $answer2")
}

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

private data class Blizzard(
    val origin: Point,
    val offset: Point,
)

private data class World(
    val source: Point,
    val target: Point,
    val blizzards: Set<Blizzard>,
)

@Suppress("SameParameterValue")
private fun parse(path: String): World {
    val lines = File(path).readLines()
    val source = Point(lines.first().indexOf('.'), 0)
    val target = Point(lines.last().indexOf('.'), lines.lastIndex)
    val blizzards = mutableSetOf<Blizzard>()
    for ((y, row) in lines.withIndex()) {
        for ((x, col) in row.withIndex()) {
            when (col) {
                '>' -> blizzards += Blizzard(Point(x, y), Point(+1, +0))
                '<' -> blizzards += Blizzard(Point(x, y), Point(-1, +0))
                '^' -> blizzards += Blizzard(Point(x, y), Point(+0, -1))
                'v' -> blizzards += Blizzard(Point(x, y), Point(+0, +1))
            }
        }
    }
    return World(source, target, blizzards)
}

private val World.minX
    get() = source.x

private val World.maxX
    get() = target.x

private val World.minY
    get() = source.y + 1

private val World.maxY
    get() = target.y - 1

private fun World.next(): World {
    val newBlizzards = mutableSetOf<Blizzard>()
    for ((origin, offset) in blizzards) {
        var nx = origin.x + offset.x
        var ny = origin.y + offset.y

        if (nx < minX) nx = maxX
        if (nx > maxX) nx = minX
        if (ny < minY) ny = maxY
        if (ny > maxY) ny = minY

        newBlizzards += Blizzard(Point(nx, ny), offset)
    }

    return copy(blizzards = newBlizzards)
}

private fun Point.neighbors(): List<Point> =
    listOf(
        Point(x + 0, y + 1),
        Point(x + 0, y - 1),
        Point(x + 1, y + 0),
        Point(x - 1, y + 0),
    )

private fun World.withinBounds(point: Point): Boolean =
    (point.x in minX..maxX) && (point.y in minY..maxY)

private fun World.safe(point: Point): Boolean =
    blizzards.find { it.origin == point } == null

private fun solve(world: World, source: Point, target: Point, stepCount: Int = 0): Pair<Int, World> {
    val worlds = mutableMapOf(stepCount to world)
    val queue = ArrayDeque<Pair<Int, Point>>().apply { add(stepCount to source) }
    val visited = mutableSetOf<Pair<Int, Point>>()

    while (queue.isNotEmpty()) {
        val attempt = queue.removeFirst()
        if (attempt in visited) {
            continue
        }

        val (steps, position) = attempt
        val nextWorld = worlds.computeIfAbsent(steps + 1) {
            worlds.getValue(steps).next()
        }

        val neighbors = position.neighbors()
        if (target in neighbors) {
            return steps + 1 to nextWorld
        }

        for (neighbor in position.neighbors()) {
            if (nextWorld.withinBounds(neighbor) && nextWorld.safe(neighbor)) {
                queue += steps + 1 to neighbor
            }
        }

        visited += attempt
        if (nextWorld.safe(position)) {
            queue += steps + 1 to position
        }
    }

    error("Could not find the path.")
}

private fun part1(data: World): Int =
    solve(data, data.source, data.target).let { (steps, _) -> steps }

private fun part2(w0: World): Int  {
    val (s1, w1) = solve(w0, w0.source, w0.target)
    val (s2, w2) = solve(w1, w0.target, w0.source, s1)
    val (s3,  _) = solve(w2, w0.source, w0.target, s2)
    return s3
}

Compiled from "Day24.kt"
public final class day24.Day24Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String src/main/kotlin/day24/Day24.txt
       2: invokestatic  #12                 // Method parse:(Ljava/lang/String;)Lday24/World;
       5: astore_0
       6: aload_0
       7: invokestatic  #16                 // Method part1:(Lday24/World;)I
      10: istore_1
      11: aload_0
      12: invokestatic  #19                 // Method part2:(Lday24/World;)I
      15: istore_2
      16: ldc           #21                 // String 🎄 Day 24 🎄
      18: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      21: swap
      22: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      25: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      28: invokevirtual #35                 // Method java/io/PrintStream.println:()V
      31: ldc           #37                 // String [Part 1]
      33: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      36: swap
      37: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      40: new           #39                 // class java/lang/StringBuilder
      43: dup
      44: invokespecial #42                 // Method java/lang/StringBuilder."<init>":()V
      47: ldc           #44                 // String Answer:
      49: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      52: iload_1
      53: invokevirtual #51                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      56: invokevirtual #55                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      59: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      62: swap
      63: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      66: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      69: invokevirtual #35                 // Method java/io/PrintStream.println:()V
      72: ldc           #57                 // String [Part 2]
      74: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      77: swap
      78: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      81: new           #39                 // class java/lang/StringBuilder
      84: dup
      85: invokespecial #42                 // Method java/lang/StringBuilder."<init>":()V
      88: ldc           #44                 // String Answer:
      90: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      93: iload_2
      94: invokevirtual #51                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      97: invokevirtual #55                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     100: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
     103: swap
     104: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     107: return

  private static final day24.World parse(java.lang.String);
    Code:
       0: new           #64                 // class java/io/File
       3: dup
       4: aload_0
       5: invokespecial #67                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       8: aconst_null
       9: iconst_1
      10: aconst_null
      11: invokestatic  #73                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      14: astore_1
      15: new           #75                 // class day24/Point
      18: dup
      19: aload_1
      20: invokestatic  #81                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      23: checkcast     #83                 // class java/lang/CharSequence
      26: bipush        46
      28: iconst_0
      29: iconst_0
      30: bipush        6
      32: aconst_null
      33: invokestatic  #89                 // Method kotlin/text/StringsKt.indexOf$default:(Ljava/lang/CharSequence;CIZILjava/lang/Object;)I
      36: iconst_0
      37: invokespecial #92                 // Method day24/Point."<init>":(II)V
      40: astore_2
      41: new           #75                 // class day24/Point
      44: dup
      45: aload_1
      46: invokestatic  #95                 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
      49: checkcast     #83                 // class java/lang/CharSequence
      52: bipush        46
      54: iconst_0
      55: iconst_0
      56: bipush        6
      58: aconst_null
      59: invokestatic  #89                 // Method kotlin/text/StringsKt.indexOf$default:(Ljava/lang/CharSequence;CIZILjava/lang/Object;)I
      62: aload_1
      63: invokestatic  #99                 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
      66: invokespecial #92                 // Method day24/Point."<init>":(II)V
      69: astore_3
      70: new           #101                // class java/util/LinkedHashSet
      73: dup
      74: invokespecial #102                // Method java/util/LinkedHashSet."<init>":()V
      77: checkcast     #104                // class java/util/Set
      80: astore        4
      82: aload_1
      83: checkcast     #106                // class java/lang/Iterable
      86: invokeinterface #110,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      91: astore        5
      93: iconst_0
      94: istore        6
      96: aload         5
      98: invokeinterface #116,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     103: ifeq          371
     106: iload         6
     108: istore        7
     110: iload         6
     112: iconst_1
     113: iadd
     114: istore        6
     116: aload         5
     118: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     123: checkcast     #122                // class java/lang/String
     126: astore        8
     128: iconst_0
     129: istore        9
     131: aload         8
     133: invokevirtual #126                // Method java/lang/String.length:()I
     136: istore        10
     138: iload         9
     140: iload         10
     142: if_icmpge     96
     145: iload         9
     147: istore        11
     149: aload         8
     151: iload         9
     153: invokevirtual #130                // Method java/lang/String.charAt:(I)C
     156: istore        12
     158: iload         12
     160: lookupswitch  { // 4
                    60: 245
                    62: 204
                    94: 286
                   118: 327
               default: 365
          }
     204: aload         4
     206: checkcast     #132                // class java/util/Collection
     209: new           #134                // class day24/Blizzard
     212: dup
     213: new           #75                 // class day24/Point
     216: dup
     217: iload         11
     219: iload         7
     221: invokespecial #92                 // Method day24/Point."<init>":(II)V
     224: new           #75                 // class day24/Point
     227: dup
     228: iconst_1
     229: iconst_0
     230: invokespecial #92                 // Method day24/Point."<init>":(II)V
     233: invokespecial #137                // Method day24/Blizzard."<init>":(Lday24/Point;Lday24/Point;)V
     236: invokeinterface #141,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     241: pop
     242: goto          365
     245: aload         4
     247: checkcast     #132                // class java/util/Collection
     250: new           #134                // class day24/Blizzard
     253: dup
     254: new           #75                 // class day24/Point
     257: dup
     258: iload         11
     260: iload         7
     262: invokespecial #92                 // Method day24/Point."<init>":(II)V
     265: new           #75                 // class day24/Point
     268: dup
     269: iconst_m1
     270: iconst_0
     271: invokespecial #92                 // Method day24/Point."<init>":(II)V
     274: invokespecial #137                // Method day24/Blizzard."<init>":(Lday24/Point;Lday24/Point;)V
     277: invokeinterface #141,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     282: pop
     283: goto          365
     286: aload         4
     288: checkcast     #132                // class java/util/Collection
     291: new           #134                // class day24/Blizzard
     294: dup
     295: new           #75                 // class day24/Point
     298: dup
     299: iload         11
     301: iload         7
     303: invokespecial #92                 // Method day24/Point."<init>":(II)V
     306: new           #75                 // class day24/Point
     309: dup
     310: iconst_0
     311: iconst_m1
     312: invokespecial #92                 // Method day24/Point."<init>":(II)V
     315: invokespecial #137                // Method day24/Blizzard."<init>":(Lday24/Point;Lday24/Point;)V
     318: invokeinterface #141,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     323: pop
     324: goto          365
     327: aload         4
     329: checkcast     #132                // class java/util/Collection
     332: new           #134                // class day24/Blizzard
     335: dup
     336: new           #75                 // class day24/Point
     339: dup
     340: iload         11
     342: iload         7
     344: invokespecial #92                 // Method day24/Point."<init>":(II)V
     347: new           #75                 // class day24/Point
     350: dup
     351: iconst_0
     352: iconst_1
     353: invokespecial #92                 // Method day24/Point."<init>":(II)V
     356: invokespecial #137                // Method day24/Blizzard."<init>":(Lday24/Point;Lday24/Point;)V
     359: invokeinterface #141,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     364: pop
     365: iinc          9, 1
     368: goto          138
     371: new           #143                // class day24/World
     374: dup
     375: aload_2
     376: aload_3
     377: aload         4
     379: invokespecial #146                // Method day24/World."<init>":(Lday24/Point;Lday24/Point;Ljava/util/Set;)V
     382: areturn

  private static final int getMinX(day24.World);
    Code:
       0: aload_0
       1: invokevirtual #167                // Method day24/World.getSource:()Lday24/Point;
       4: invokevirtual #170                // Method day24/Point.getX:()I
       7: ireturn

  private static final int getMaxX(day24.World);
    Code:
       0: aload_0
       1: invokevirtual #175                // Method day24/World.getTarget:()Lday24/Point;
       4: invokevirtual #170                // Method day24/Point.getX:()I
       7: ireturn

  private static final int getMinY(day24.World);
    Code:
       0: aload_0
       1: invokevirtual #167                // Method day24/World.getSource:()Lday24/Point;
       4: invokevirtual #180                // Method day24/Point.getY:()I
       7: iconst_1
       8: iadd
       9: ireturn

  private static final int getMaxY(day24.World);
    Code:
       0: aload_0
       1: invokevirtual #175                // Method day24/World.getTarget:()Lday24/Point;
       4: invokevirtual #180                // Method day24/Point.getY:()I
       7: iconst_1
       8: isub
       9: ireturn

  private static final day24.World next(day24.World);
    Code:
       0: new           #101                // class java/util/LinkedHashSet
       3: dup
       4: invokespecial #102                // Method java/util/LinkedHashSet."<init>":()V
       7: checkcast     #104                // class java/util/Set
      10: astore_1
      11: aload_0
      12: invokevirtual #188                // Method day24/World.getBlizzards:()Ljava/util/Set;
      15: invokeinterface #189,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
      20: astore_2
      21: aload_2
      22: invokeinterface #116,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      27: ifeq          171
      30: aload_2
      31: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      36: checkcast     #134                // class day24/Blizzard
      39: astore_3
      40: aload_3
      41: invokevirtual #192                // Method day24/Blizzard.component1:()Lday24/Point;
      44: astore        4
      46: aload_3
      47: invokevirtual #195                // Method day24/Blizzard.component2:()Lday24/Point;
      50: astore        5
      52: aload         4
      54: invokevirtual #170                // Method day24/Point.getX:()I
      57: aload         5
      59: invokevirtual #170                // Method day24/Point.getX:()I
      62: iadd
      63: istore        6
      65: aload         4
      67: invokevirtual #180                // Method day24/Point.getY:()I
      70: aload         5
      72: invokevirtual #180                // Method day24/Point.getY:()I
      75: iadd
      76: istore        7
      78: iload         6
      80: aload_0
      81: invokestatic  #197                // Method getMinX:(Lday24/World;)I
      84: if_icmpge     93
      87: aload_0
      88: invokestatic  #199                // Method getMaxX:(Lday24/World;)I
      91: istore        6
      93: iload         6
      95: aload_0
      96: invokestatic  #199                // Method getMaxX:(Lday24/World;)I
      99: if_icmple     108
     102: aload_0
     103: invokestatic  #197                // Method getMinX:(Lday24/World;)I
     106: istore        6
     108: iload         7
     110: aload_0
     111: invokestatic  #201                // Method getMinY:(Lday24/World;)I
     114: if_icmpge     123
     117: aload_0
     118: invokestatic  #203                // Method getMaxY:(Lday24/World;)I
     121: istore        7
     123: iload         7
     125: aload_0
     126: invokestatic  #203                // Method getMaxY:(Lday24/World;)I
     129: if_icmple     138
     132: aload_0
     133: invokestatic  #201                // Method getMinY:(Lday24/World;)I
     136: istore        7
     138: aload_1
     139: checkcast     #132                // class java/util/Collection
     142: new           #134                // class day24/Blizzard
     145: dup
     146: new           #75                 // class day24/Point
     149: dup
     150: iload         6
     152: iload         7
     154: invokespecial #92                 // Method day24/Point."<init>":(II)V
     157: aload         5
     159: invokespecial #137                // Method day24/Blizzard."<init>":(Lday24/Point;Lday24/Point;)V
     162: invokeinterface #141,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     167: pop
     168: goto          21
     171: aload_0
     172: aconst_null
     173: aconst_null
     174: aload_1
     175: iconst_3
     176: aconst_null
     177: invokestatic  #207                // Method day24/World.copy$default:(Lday24/World;Lday24/Point;Lday24/Point;Ljava/util/Set;ILjava/lang/Object;)Lday24/World;
     180: areturn

  private static final java.util.List<day24.Point> neighbors(day24.Point);
    Code:
       0: iconst_4
       1: anewarray     #75                 // class day24/Point
       4: astore_1
       5: aload_1
       6: iconst_0
       7: new           #75                 // class day24/Point
      10: dup
      11: aload_0
      12: invokevirtual #170                // Method day24/Point.getX:()I
      15: iconst_0
      16: iadd
      17: aload_0
      18: invokevirtual #180                // Method day24/Point.getY:()I
      21: iconst_1
      22: iadd
      23: invokespecial #92                 // Method day24/Point."<init>":(II)V
      26: aastore
      27: aload_1
      28: iconst_1
      29: new           #75                 // class day24/Point
      32: dup
      33: aload_0
      34: invokevirtual #170                // Method day24/Point.getX:()I
      37: iconst_0
      38: iadd
      39: aload_0
      40: invokevirtual #180                // Method day24/Point.getY:()I
      43: iconst_1
      44: isub
      45: invokespecial #92                 // Method day24/Point."<init>":(II)V
      48: aastore
      49: aload_1
      50: iconst_2
      51: new           #75                 // class day24/Point
      54: dup
      55: aload_0
      56: invokevirtual #170                // Method day24/Point.getX:()I
      59: iconst_1
      60: iadd
      61: aload_0
      62: invokevirtual #180                // Method day24/Point.getY:()I
      65: iconst_0
      66: iadd
      67: invokespecial #92                 // Method day24/Point."<init>":(II)V
      70: aastore
      71: aload_1
      72: iconst_3
      73: new           #75                 // class day24/Point
      76: dup
      77: aload_0
      78: invokevirtual #170                // Method day24/Point.getX:()I
      81: iconst_1
      82: isub
      83: aload_0
      84: invokevirtual #180                // Method day24/Point.getY:()I
      87: iconst_0
      88: iadd
      89: invokespecial #92                 // Method day24/Point."<init>":(II)V
      92: aastore
      93: aload_1
      94: invokestatic  #220                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      97: areturn

  private static final boolean withinBounds(day24.World, day24.Point);
    Code:
       0: aload_0
       1: invokestatic  #197                // Method getMinX:(Lday24/World;)I
       4: istore_2
       5: aload_0
       6: invokestatic  #199                // Method getMaxX:(Lday24/World;)I
       9: istore_3
      10: aload_1
      11: invokevirtual #170                // Method day24/Point.getX:()I
      14: istore        4
      16: iload_2
      17: iload         4
      19: if_icmpgt     36
      22: iload         4
      24: iload_3
      25: if_icmpgt     32
      28: iconst_1
      29: goto          37
      32: iconst_0
      33: goto          37
      36: iconst_0
      37: ifeq          84
      40: aload_0
      41: invokestatic  #201                // Method getMinY:(Lday24/World;)I
      44: istore_2
      45: aload_0
      46: invokestatic  #203                // Method getMaxY:(Lday24/World;)I
      49: istore_3
      50: aload_1
      51: invokevirtual #180                // Method day24/Point.getY:()I
      54: istore        4
      56: iload_2
      57: iload         4
      59: if_icmpgt     76
      62: iload         4
      64: iload_3
      65: if_icmpgt     72
      68: iconst_1
      69: goto          77
      72: iconst_0
      73: goto          77
      76: iconst_0
      77: ifeq          84
      80: iconst_1
      81: goto          85
      84: iconst_0
      85: ireturn

  private static final boolean safe(day24.World, day24.Point);
    Code:
       0: aload_0
       1: invokevirtual #188                // Method day24/World.getBlizzards:()Ljava/util/Set;
       4: checkcast     #106                // class java/lang/Iterable
       7: astore_2
       8: aload_2
       9: invokeinterface #110,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      14: astore_3
      15: aload_3
      16: invokeinterface #116,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      21: ifeq          59
      24: aload_3
      25: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      30: astore        4
      32: aload         4
      34: checkcast     #134                // class day24/Blizzard
      37: astore        5
      39: iconst_0
      40: istore        6
      42: aload         5
      44: invokevirtual #229                // Method day24/Blizzard.getOrigin:()Lday24/Point;
      47: aload_1
      48: invokestatic  #235                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      51: ifeq          15
      54: aload         4
      56: goto          60
      59: aconst_null
      60: ifnonnull     67
      63: iconst_1
      64: goto          68
      67: iconst_0
      68: ireturn

  private static final kotlin.Pair<java.lang.Integer, day24.World> solve(day24.World, day24.Point, day24.Point, int);
    Code:
       0: iconst_1
       1: anewarray     #244                // class kotlin/Pair
       4: astore        5
       6: aload         5
       8: iconst_0
       9: iload_3
      10: invokestatic  #250                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      13: aload_0
      14: invokestatic  #256                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      17: aastore
      18: aload         5
      20: invokestatic  #262                // Method kotlin/collections/MapsKt.mutableMapOf:([Lkotlin/Pair;)Ljava/util/Map;
      23: astore        4
      25: new           #264                // class kotlin/collections/ArrayDeque
      28: dup
      29: invokespecial #265                // Method kotlin/collections/ArrayDeque."<init>":()V
      32: astore        6
      34: aload         6
      36: astore        7
      38: iconst_0
      39: istore        8
      41: aload         7
      43: iload_3
      44: invokestatic  #250                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      47: aload_1
      48: invokestatic  #256                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      51: invokevirtual #266                // Method kotlin/collections/ArrayDeque.add:(Ljava/lang/Object;)Z
      54: pop
      55: aload         6
      57: astore        5
      59: new           #101                // class java/util/LinkedHashSet
      62: dup
      63: invokespecial #102                // Method java/util/LinkedHashSet."<init>":()V
      66: checkcast     #104                // class java/util/Set
      69: astore        6
      71: aload         5
      73: checkcast     #132                // class java/util/Collection
      76: invokeinterface #269,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      81: ifne          88
      84: iconst_1
      85: goto          89
      88: iconst_0
      89: ifeq          340
      92: aload         5
      94: invokevirtual #272                // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;
      97: checkcast     #244                // class kotlin/Pair
     100: astore        7
     102: aload         6
     104: aload         7
     106: invokeinterface #275,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     111: ifeq          117
     114: goto          71
     117: aload         7
     119: invokevirtual #277                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     122: checkcast     #279                // class java/lang/Number
     125: invokevirtual #282                // Method java/lang/Number.intValue:()I
     128: istore        8
     130: aload         7
     132: invokevirtual #284                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     135: checkcast     #75                 // class day24/Point
     138: astore        9
     140: aload         4
     142: iload         8
     144: iconst_1
     145: iadd
     146: invokestatic  #250                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     149: aload         4
     151: iload         8
     153: invokedynamic #304,  0            // InvokeDynamic #0:invoke:(Ljava/util/Map;I)Lkotlin/jvm/functions/Function1;
     158: invokedynamic #315,  0            // InvokeDynamic #1:apply:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Function;
     163: invokeinterface #321,  3          // InterfaceMethod java/util/Map.computeIfAbsent:(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;
     168: dup
     169: ldc_w         #323                // String computeIfAbsent(...)
     172: invokestatic  #327                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     175: checkcast     #143                // class day24/World
     178: astore        10
     180: aload         9
     182: invokestatic  #329                // Method neighbors:(Lday24/Point;)Ljava/util/List;
     185: astore        11
     187: aload         11
     189: aload_2
     190: invokeinterface #330,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     195: ifeq          211
     198: iload         8
     200: iconst_1
     201: iadd
     202: invokestatic  #250                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     205: aload         10
     207: invokestatic  #256                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     210: areturn
     211: aload         9
     213: invokestatic  #329                // Method neighbors:(Lday24/Point;)Ljava/util/List;
     216: invokeinterface #331,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     221: astore        12
     223: aload         12
     225: invokeinterface #116,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     230: ifeq          291
     233: aload         12
     235: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     240: checkcast     #75                 // class day24/Point
     243: astore        13
     245: aload         10
     247: aload         13
     249: invokestatic  #333                // Method withinBounds:(Lday24/World;Lday24/Point;)Z
     252: ifeq          223
     255: aload         10
     257: aload         13
     259: invokestatic  #335                // Method safe:(Lday24/World;Lday24/Point;)Z
     262: ifeq          223
     265: aload         5
     267: checkcast     #132                // class java/util/Collection
     270: iload         8
     272: iconst_1
     273: iadd
     274: invokestatic  #250                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     277: aload         13
     279: invokestatic  #256                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     282: invokeinterface #141,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     287: pop
     288: goto          223
     291: aload         6
     293: checkcast     #132                // class java/util/Collection
     296: aload         7
     298: invokeinterface #141,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     303: pop
     304: aload         10
     306: aload         9
     308: invokestatic  #335                // Method safe:(Lday24/World;Lday24/Point;)Z
     311: ifeq          71
     314: aload         5
     316: checkcast     #132                // class java/util/Collection
     319: iload         8
     321: iconst_1
     322: iadd
     323: invokestatic  #250                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     326: aload         9
     328: invokestatic  #256                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     331: invokeinterface #141,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     336: pop
     337: goto          71
     340: new           #337                // class java/lang/IllegalStateException
     343: dup
     344: ldc_w         #339                // String Could not find the path.
     347: invokevirtual #340                // Method java/lang/Object.toString:()Ljava/lang/String;
     350: invokespecial #341                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     353: athrow

  static kotlin.Pair solve$default(day24.World, day24.Point, day24.Point, int, int, java.lang.Object);
    Code:
       0: iload         4
       2: bipush        8
       4: iand
       5: ifeq          10
       8: iconst_0
       9: istore_3
      10: aload_0
      11: aload_1
      12: aload_2
      13: iload_3
      14: invokestatic  #360                // Method solve:(Lday24/World;Lday24/Point;Lday24/Point;I)Lkotlin/Pair;
      17: areturn

  private static final int part1(day24.World);
    Code:
       0: aload_0
       1: aload_0
       2: invokevirtual #167                // Method day24/World.getSource:()Lday24/Point;
       5: aload_0
       6: invokevirtual #175                // Method day24/World.getTarget:()Lday24/Point;
       9: iconst_0
      10: bipush        8
      12: aconst_null
      13: invokestatic  #362                // Method solve$default:(Lday24/World;Lday24/Point;Lday24/Point;IILjava/lang/Object;)Lkotlin/Pair;
      16: astore_1
      17: iconst_0
      18: istore_2
      19: aload_1
      20: invokevirtual #277                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      23: checkcast     #279                // class java/lang/Number
      26: invokevirtual #282                // Method java/lang/Number.intValue:()I
      29: istore_3
      30: iload_3
      31: nop
      32: ireturn

  private static final int part2(day24.World);
    Code:
       0: aload_0
       1: aload_0
       2: invokevirtual #167                // Method day24/World.getSource:()Lday24/Point;
       5: aload_0
       6: invokevirtual #175                // Method day24/World.getTarget:()Lday24/Point;
       9: iconst_0
      10: bipush        8
      12: aconst_null
      13: invokestatic  #362                // Method solve$default:(Lday24/World;Lday24/Point;Lday24/Point;IILjava/lang/Object;)Lkotlin/Pair;
      16: astore_1
      17: aload_1
      18: invokevirtual #277                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      21: checkcast     #279                // class java/lang/Number
      24: invokevirtual #282                // Method java/lang/Number.intValue:()I
      27: istore_2
      28: aload_1
      29: invokevirtual #284                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      32: checkcast     #143                // class day24/World
      35: astore_3
      36: aload_3
      37: aload_0
      38: invokevirtual #175                // Method day24/World.getTarget:()Lday24/Point;
      41: aload_0
      42: invokevirtual #167                // Method day24/World.getSource:()Lday24/Point;
      45: iload_2
      46: invokestatic  #360                // Method solve:(Lday24/World;Lday24/Point;Lday24/Point;I)Lkotlin/Pair;
      49: astore        4
      51: aload         4
      53: invokevirtual #277                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      56: checkcast     #279                // class java/lang/Number
      59: invokevirtual #282                // Method java/lang/Number.intValue:()I
      62: istore        5
      64: aload         4
      66: invokevirtual #284                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      69: checkcast     #143                // class day24/World
      72: astore        6
      74: aload         6
      76: aload_0
      77: invokevirtual #167                // Method day24/World.getSource:()Lday24/Point;
      80: aload_0
      81: invokevirtual #175                // Method day24/World.getTarget:()Lday24/Point;
      84: iload         5
      86: invokestatic  #360                // Method solve:(Lday24/World;Lday24/Point;Lday24/Point;I)Lkotlin/Pair;
      89: invokevirtual #277                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      92: checkcast     #279                // class java/lang/Number
      95: invokevirtual #282                // Method java/lang/Number.intValue:()I
      98: istore        7
     100: iload         7
     102: ireturn

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

  private static final day24.World solve$lambda$2(java.util.Map, int, java.lang.Integer);
    Code:
       0: aload_2
       1: ldc_w         #375                // String it
       4: invokestatic  #378                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: iload_1
       9: invokestatic  #250                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      12: invokestatic  #382                // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;
      15: checkcast     #143                // class day24/World
      18: invokestatic  #384                // Method next:(Lday24/World;)Lday24/World;
      21: areturn

  private static final day24.World solve$lambda$3(kotlin.jvm.functions.Function1, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: invokeinterface #391,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
       7: checkcast     #143                // class day24/World
      10: areturn
}