package day23

import Point
import readInput

private typealias Grove = Set<Point>

var directionsToCheck = mutableListOf(
    Point::northernNeighbours,
    Point::southernNeighbours,
    Point::westernNeighbours,
    Point::easternNeighbours
)

fun main() {
    val input = readInput("main/day23/Day23")

    println(year_2017.day23.part1(input))
    println(year_2017.day23.part2(input))
}

fun part1(input: List<String>): Int {
    return generateSequence(input.toGrove()) { step(it).second }.drop(10).first().let { tenth ->
        (1 + tenth.maxOf { it.x } - tenth.minOf { it.x }) *
                (1 + tenth.maxOf { it.y } - tenth.minOf { it.y }) - tenth.size
    }
}

fun part2(input: List<String>): Int {
    directionsToCheck = mutableListOf(
        Point::northernNeighbours,
        Point::southernNeighbours,
        Point::westernNeighbours,
        Point::easternNeighbours
    )
    return generateSequence(emptySet<Point>() to input.toGrove()) { result ->
        step(result.second)
    }.takeWhile {
        it.first != it.second
    }.count()
}

private fun step(grove: Set<Point>): Pair<Grove, Grove> {

    val proposedSteps = grove.proposedSteps()
    directionsToCheck.add(directionsToCheck.removeFirst())

    val stepsByElf = proposedSteps.associateBy { it.first }
    val possiblePositions = proposedSteps.associateTo(mutableMapOf()) { (_, next) ->
        next to proposedSteps.count { it.second == next }
    }.filter {
        it.value == 1
    }.keys

    return grove to grove.map { elf ->
        if (possiblePositions.contains(stepsByElf[elf]?.second))
            stepsByElf[elf]!!.second
        else
            elf
    }.toSet()
}

fun Grove.proposedSteps(): List<Pair<Point, Point>> {
    val proposedSteps = mutableListOf<Pair<Point, Point>>()
    forEach { elf ->
        if (elf.allNeighbours().any { this.contains(it) }) {

            val direction = directionsToCheck.firstOrNull { findNeighbours ->
                findNeighbours.invoke(elf).dropLast(1).none { this.contains(it) }
            }
            if (direction != null) {
                proposedSteps.add(elf to (elf + direction.invoke(elf).last()))
            }
        }
    }
    return proposedSteps
}

fun List<String>.toGrove() =
    flatMapIndexed { y, line ->
        line.mapIndexedNotNull { x, s ->
            if (s == '#') Point(x, y) else null
        }
    }.toSet()

fun Point.northernNeighbours(): List<Point> {
    return listOf(
        Point(x - 1, y - 1),
        Point(x, y - 1),
        Point(x + 1, y - 1),
        Point(0, -1),
    )
}

fun Point.southernNeighbours(): List<Point> {
    return listOf(
        Point(x - 1, y + 1),
        Point(x, y + 1),
        Point(x + 1, y + 1),
        Point(0, 1),
    )
}

fun Point.easternNeighbours(): List<Point> {
    return listOf(
        Point(x + 1, y - 1),
        Point(x + 1, y),
        Point(x + 1, y + 1),
        Point(1, 0),
    )
}

fun Point.westernNeighbours(): List<Point> {
    return listOf(
        Point(x - 1, y - 1),
        Point(x - 1, y),
        Point(x - 1, y + 1),
        Point(-1, 0),
    )
}

Compiled from "day23.kt"
final class day23.Day23Kt$directionsToCheck$3 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<Point, java.util.List<? extends Point>> {
  public static final day23.Day23Kt$directionsToCheck$3 INSTANCE;

  day23.Day23Kt$directionsToCheck$3();
    Code:
       0: aload_0
       1: iconst_1
       2: ldc           #11                 // class day23/Day23Kt
       4: ldc           #13                 // String westernNeighbours
       6: ldc           #15                 // String westernNeighbours(LPoint;)Ljava/util/List;
       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 java.util.List<Point> invoke(Point);
    Code:
       0: aload_1
       1: ldc           #25                 // String p0
       3: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokestatic  #33                 // Method day23/Day23Kt.westernNeighbours:(LPoint;)Ljava/util/List;
      10: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #37                 // class Point
       5: invokevirtual #39                 // Method invoke:(LPoint;)Ljava/util/List;
       8: areturn

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

Compiled from "day23.kt"
final class day23.Day23Kt$directionsToCheck$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<Point, java.util.List<? extends Point>> {
  public static final day23.Day23Kt$directionsToCheck$1 INSTANCE;

  day23.Day23Kt$directionsToCheck$1();
    Code:
       0: aload_0
       1: iconst_1
       2: ldc           #11                 // class day23/Day23Kt
       4: ldc           #13                 // String northernNeighbours
       6: ldc           #15                 // String northernNeighbours(LPoint;)Ljava/util/List;
       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 java.util.List<Point> invoke(Point);
    Code:
       0: aload_1
       1: ldc           #25                 // String p0
       3: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokestatic  #33                 // Method day23/Day23Kt.northernNeighbours:(LPoint;)Ljava/util/List;
      10: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #37                 // class Point
       5: invokevirtual #39                 // Method invoke:(LPoint;)Ljava/util/List;
       8: areturn

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

Compiled from "day23.kt"
final class day23.Day23Kt$part2$4 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<Point, java.util.List<? extends Point>> {
  public static final day23.Day23Kt$part2$4 INSTANCE;

  day23.Day23Kt$part2$4();
    Code:
       0: aload_0
       1: iconst_1
       2: ldc           #11                 // class day23/Day23Kt
       4: ldc           #13                 // String easternNeighbours
       6: ldc           #15                 // String easternNeighbours(LPoint;)Ljava/util/List;
       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 java.util.List<Point> invoke(Point);
    Code:
       0: aload_1
       1: ldc           #25                 // String p0
       3: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokestatic  #33                 // Method day23/Day23Kt.easternNeighbours:(LPoint;)Ljava/util/List;
      10: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #37                 // class Point
       5: invokevirtual #39                 // Method invoke:(LPoint;)Ljava/util/List;
       8: areturn

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

Compiled from "day23.kt"
public final class day23.Day23Kt {
  private static java.util.List<kotlin.reflect.KFunction<java.util.List<Point>>> directionsToCheck;

  public static final java.util.List<kotlin.reflect.KFunction<java.util.List<Point>>> getDirectionsToCheck();
    Code:
       0: getstatic     #12                 // Field directionsToCheck:Ljava/util/List;
       3: areturn

  public static final void setDirectionsToCheck(java.util.List<kotlin.reflect.KFunction<java.util.List<Point>>>);
    Code:
       0: aload_0
       1: ldc           #17                 // String <set-?>
       3: invokestatic  #23                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: putstatic     #12                 // Field directionsToCheck:Ljava/util/List;
      10: return

  public static final void main();
    Code:
       0: ldc           #27                 // String main/day23/Day23
       2: invokestatic  #33                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #39                 // Method year_2017/day23/Day23Kt.part1:(Ljava/util/List;)I
      10: istore_1
      11: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
      14: iload_1
      15: invokevirtual #51                 // Method java/io/PrintStream.println:(I)V
      18: aload_0
      19: invokestatic  #54                 // Method year_2017/day23/Day23Kt.part2:(Ljava/util/List;)I
      22: istore_1
      23: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
      26: iload_1
      27: invokevirtual #51                 // Method java/io/PrintStream.println:(I)V
      30: return

  public static final int part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #57                 // String input
       3: invokestatic  #23                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #61                 // Method toGrove:(Ljava/util/List;)Ljava/util/Set;
      10: invokedynamic #80,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      15: invokestatic  #86                 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      18: bipush        10
      20: invokestatic  #90                 // Method kotlin/sequences/SequencesKt.drop:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;
      23: invokestatic  #94                 // Method kotlin/sequences/SequencesKt.first:(Lkotlin/sequences/Sequence;)Ljava/lang/Object;
      26: checkcast     #96                 // class java/util/Set
      29: astore_1
      30: iconst_0
      31: istore_2
      32: iconst_1
      33: aload_1
      34: checkcast     #98                 // class java/lang/Iterable
      37: astore_3
      38: istore        4
      40: aload_3
      41: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      46: astore        5
      48: aload         5
      50: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      55: ifne          66
      58: new           #110                // class java/util/NoSuchElementException
      61: dup
      62: invokespecial #113                // Method java/util/NoSuchElementException."<init>":()V
      65: athrow
      66: aload         5
      68: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      73: checkcast     #119                // class Point
      76: astore        6
      78: iconst_0
      79: istore        7
      81: aload         6
      83: invokevirtual #123                // Method Point.getX:()I
      86: istore        6
      88: aload         5
      90: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      95: ifeq          134
      98: aload         5
     100: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     105: checkcast     #119                // class Point
     108: astore        7
     110: iconst_0
     111: istore        8
     113: aload         7
     115: invokevirtual #123                // Method Point.getX:()I
     118: istore        7
     120: iload         6
     122: iload         7
     124: if_icmpge     88
     127: iload         7
     129: istore        6
     131: goto          88
     134: iload         6
     136: istore        9
     138: iload         4
     140: iload         9
     142: iadd
     143: aload_1
     144: checkcast     #98                 // class java/lang/Iterable
     147: astore_3
     148: istore        4
     150: aload_3
     151: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     156: astore        5
     158: aload         5
     160: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     165: ifne          176
     168: new           #110                // class java/util/NoSuchElementException
     171: dup
     172: invokespecial #113                // Method java/util/NoSuchElementException."<init>":()V
     175: athrow
     176: aload         5
     178: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     183: checkcast     #119                // class Point
     186: astore        6
     188: iconst_0
     189: istore        7
     191: aload         6
     193: invokevirtual #123                // Method Point.getX:()I
     196: istore        6
     198: aload         5
     200: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     205: ifeq          244
     208: aload         5
     210: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     215: checkcast     #119                // class Point
     218: astore        7
     220: iconst_0
     221: istore        8
     223: aload         7
     225: invokevirtual #123                // Method Point.getX:()I
     228: istore        7
     230: iload         6
     232: iload         7
     234: if_icmple     198
     237: iload         7
     239: istore        6
     241: goto          198
     244: iload         6
     246: istore        9
     248: iload         4
     250: iload         9
     252: isub
     253: iconst_1
     254: aload_1
     255: checkcast     #98                 // class java/lang/Iterable
     258: astore_3
     259: istore        9
     261: istore        4
     263: aload_3
     264: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     269: astore        5
     271: aload         5
     273: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     278: ifne          289
     281: new           #110                // class java/util/NoSuchElementException
     284: dup
     285: invokespecial #113                // Method java/util/NoSuchElementException."<init>":()V
     288: athrow
     289: aload         5
     291: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     296: checkcast     #119                // class Point
     299: astore        6
     301: iconst_0
     302: istore        7
     304: aload         6
     306: invokevirtual #126                // Method Point.getY:()I
     309: istore        6
     311: aload         5
     313: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     318: ifeq          357
     321: aload         5
     323: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     328: checkcast     #119                // class Point
     331: astore        7
     333: iconst_0
     334: istore        8
     336: aload         7
     338: invokevirtual #126                // Method Point.getY:()I
     341: istore        7
     343: iload         6
     345: iload         7
     347: if_icmpge     311
     350: iload         7
     352: istore        6
     354: goto          311
     357: iload         6
     359: istore        10
     361: iload         4
     363: iload         9
     365: iload         10
     367: iadd
     368: aload_1
     369: checkcast     #98                 // class java/lang/Iterable
     372: astore_3
     373: istore        9
     375: istore        4
     377: aload_3
     378: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     383: astore        5
     385: aload         5
     387: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     392: ifne          403
     395: new           #110                // class java/util/NoSuchElementException
     398: dup
     399: invokespecial #113                // Method java/util/NoSuchElementException."<init>":()V
     402: athrow
     403: aload         5
     405: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     410: checkcast     #119                // class Point
     413: astore        6
     415: iconst_0
     416: istore        7
     418: aload         6
     420: invokevirtual #126                // Method Point.getY:()I
     423: istore        6
     425: aload         5
     427: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     432: ifeq          471
     435: aload         5
     437: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     442: checkcast     #119                // class Point
     445: astore        7
     447: iconst_0
     448: istore        8
     450: aload         7
     452: invokevirtual #126                // Method Point.getY:()I
     455: istore        7
     457: iload         6
     459: iload         7
     461: if_icmple     425
     464: iload         7
     466: istore        6
     468: goto          425
     471: iload         6
     473: istore        10
     475: iload         4
     477: iload         9
     479: iload         10
     481: isub
     482: imul
     483: aload_1
     484: invokeinterface #129,  1          // InterfaceMethod java/util/Set.size:()I
     489: isub
     490: nop
     491: nop
     492: ireturn

  public static final int part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #57                 // String input
       3: invokestatic  #23                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_4
       7: anewarray     #143                // class kotlin/reflect/KFunction
      10: astore_1
      11: aload_1
      12: iconst_0
      13: getstatic     #149                // Field day23/Day23Kt$part2$1.INSTANCE:Lday23/Day23Kt$part2$1;
      16: aastore
      17: aload_1
      18: iconst_1
      19: getstatic     #154                // Field day23/Day23Kt$part2$2.INSTANCE:Lday23/Day23Kt$part2$2;
      22: aastore
      23: aload_1
      24: iconst_2
      25: getstatic     #159                // Field day23/Day23Kt$part2$3.INSTANCE:Lday23/Day23Kt$part2$3;
      28: aastore
      29: aload_1
      30: iconst_3
      31: getstatic     #164                // Field day23/Day23Kt$part2$4.INSTANCE:Lday23/Day23Kt$part2$4;
      34: aastore
      35: aload_1
      36: invokestatic  #170                // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
      39: putstatic     #12                 // Field directionsToCheck:Ljava/util/List;
      42: invokestatic  #176                // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;
      45: aload_0
      46: invokestatic  #61                 // Method toGrove:(Ljava/util/List;)Ljava/util/Set;
      49: invokestatic  #182                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      52: invokedynamic #189,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
      57: invokestatic  #86                 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      60: invokedynamic #197,  0            // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;
      65: invokestatic  #201                // Method kotlin/sequences/SequencesKt.takeWhile:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      68: invokestatic  #205                // Method kotlin/sequences/SequencesKt.count:(Lkotlin/sequences/Sequence;)I
      71: ireturn

  private static final kotlin.Pair<java.util.Set<Point>, java.util.Set<Point>> step(java.util.Set<Point>);
    Code:
       0: aload_0
       1: invokestatic  #212                // Method proposedSteps:(Ljava/util/Set;)Ljava/util/List;
       4: astore_1
       5: getstatic     #12                 // Field directionsToCheck:Ljava/util/List;
       8: getstatic     #12                 // Field directionsToCheck:Ljava/util/List;
      11: invokeinterface #215,  1          // InterfaceMethod java/util/List.removeFirst:()Ljava/lang/Object;
      16: dup
      17: ldc           #217                // String removeFirst(...)
      19: invokestatic  #220                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      22: invokeinterface #224,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      27: pop
      28: aload_1
      29: checkcast     #98                 // class java/lang/Iterable
      32: astore_3
      33: iconst_0
      34: istore        4
      36: aload_3
      37: bipush        10
      39: invokestatic  #228                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      42: invokestatic  #234                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
      45: bipush        16
      47: invokestatic  #240                // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I
      50: istore        5
      52: aload_3
      53: astore        6
      55: new           #242                // class java/util/LinkedHashMap
      58: dup
      59: iload         5
      61: invokespecial #244                // Method java/util/LinkedHashMap."<init>":(I)V
      64: checkcast     #246                // class java/util/Map
      67: astore        7
      69: iconst_0
      70: istore        8
      72: aload         6
      74: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      79: astore        9
      81: aload         9
      83: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      88: ifeq          136
      91: aload         9
      93: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      98: astore        10
     100: aload         7
     102: aload         10
     104: checkcast     #248                // class kotlin/Pair
     107: astore        11
     109: astore        22
     111: iconst_0
     112: istore        12
     114: aload         11
     116: invokevirtual #251                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     119: checkcast     #119                // class Point
     122: aload         22
     124: swap
     125: aload         10
     127: invokeinterface #255,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     132: pop
     133: goto          81
     136: aload         7
     138: nop
     139: astore_2
     140: aload_1
     141: checkcast     #98                 // class java/lang/Iterable
     144: astore        4
     146: new           #242                // class java/util/LinkedHashMap
     149: dup
     150: invokespecial #256                // Method java/util/LinkedHashMap."<init>":()V
     153: checkcast     #246                // class java/util/Map
     156: astore        5
     158: nop
     159: iconst_0
     160: istore        6
     162: aload         4
     164: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     169: astore        7
     171: aload         7
     173: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     178: ifeq          357
     181: aload         7
     183: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     188: astore        8
     190: aload         5
     192: astore        9
     194: aload         8
     196: checkcast     #248                // class kotlin/Pair
     199: astore        10
     201: iconst_0
     202: istore        11
     204: aload         10
     206: invokevirtual #259                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     209: checkcast     #119                // class Point
     212: astore        12
     214: aload         12
     216: aload_1
     217: checkcast     #98                 // class java/lang/Iterable
     220: astore        13
     222: astore        14
     224: iconst_0
     225: istore        15
     227: aload         13
     229: instanceof    #261                // class java/util/Collection
     232: ifeq          252
     235: aload         13
     237: checkcast     #261                // class java/util/Collection
     240: invokeinterface #264,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     245: ifeq          252
     248: iconst_0
     249: goto          322
     252: iconst_0
     253: istore        16
     255: aload         13
     257: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     262: astore        17
     264: aload         17
     266: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     271: ifeq          320
     274: aload         17
     276: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     281: astore        18
     283: aload         18
     285: checkcast     #248                // class kotlin/Pair
     288: astore        19
     290: iconst_0
     291: istore        20
     293: aload         19
     295: invokevirtual #267                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     298: aload         12
     300: invokestatic  #271                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     303: ifeq          264
     306: iinc          16, 1
     309: iload         16
     311: ifge          264
     314: invokestatic  #274                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     317: goto          264
     320: iload         16
     322: istore        21
     324: aload         14
     326: iload         21
     328: invokestatic  #280                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     331: invokestatic  #182                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     334: astore        10
     336: aload         9
     338: aload         10
     340: invokevirtual #251                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     343: aload         10
     345: invokevirtual #267                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     348: invokeinterface #255,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     353: pop
     354: goto          171
     357: aload         5
     359: astore        4
     361: nop
     362: iconst_0
     363: istore        5
     365: aload         4
     367: astore        6
     369: new           #242                // class java/util/LinkedHashMap
     372: dup
     373: invokespecial #256                // Method java/util/LinkedHashMap."<init>":()V
     376: checkcast     #246                // class java/util/Map
     379: astore        7
     381: iconst_0
     382: istore        8
     384: aload         6
     386: invokeinterface #283,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     391: invokeinterface #284,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     396: astore        9
     398: aload         9
     400: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     405: ifeq          477
     408: aload         9
     410: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     415: checkcast     #286                // class java/util/Map$Entry
     418: astore        10
     420: aload         10
     422: astore        11
     424: iconst_0
     425: istore        12
     427: aload         11
     429: invokeinterface #289,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     434: checkcast     #291                // class java/lang/Number
     437: invokevirtual #294                // Method java/lang/Number.intValue:()I
     440: iconst_1
     441: if_icmpne     448
     444: iconst_1
     445: goto          449
     448: iconst_0
     449: ifeq          398
     452: aload         7
     454: aload         10
     456: invokeinterface #297,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     461: aload         10
     463: invokeinterface #289,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     468: invokeinterface #255,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     473: pop
     474: goto          398
     477: aload         7
     479: nop
     480: invokeinterface #300,  1          // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;
     485: astore_3
     486: aload_0
     487: aload_0
     488: checkcast     #98                 // class java/lang/Iterable
     491: astore        4
     493: astore        22
     495: iconst_0
     496: istore        5
     498: aload         4
     500: astore        6
     502: new           #302                // class java/util/ArrayList
     505: dup
     506: aload         4
     508: bipush        10
     510: invokestatic  #228                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     513: invokespecial #303                // Method java/util/ArrayList."<init>":(I)V
     516: checkcast     #261                // class java/util/Collection
     519: astore        7
     521: iconst_0
     522: istore        8
     524: aload         6
     526: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     531: astore        9
     533: aload         9
     535: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     540: ifeq          640
     543: aload         9
     545: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     550: astore        10
     552: aload         7
     554: aload         10
     556: checkcast     #119                // class Point
     559: astore        11
     561: astore        23
     563: iconst_0
     564: istore        12
     566: aload_3
     567: checkcast     #98                 // class java/lang/Iterable
     570: aload_2
     571: aload         11
     573: invokeinterface #306,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     578: checkcast     #248                // class kotlin/Pair
     581: dup
     582: ifnull        594
     585: invokevirtual #267                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     588: checkcast     #119                // class Point
     591: goto          596
     594: pop
     595: aconst_null
     596: invokestatic  #310                // Method kotlin/collections/CollectionsKt.contains:(Ljava/lang/Iterable;Ljava/lang/Object;)Z
     599: ifeq          626
     602: aload_2
     603: aload         11
     605: invokeinterface #306,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     610: dup
     611: invokestatic  #314                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     614: checkcast     #248                // class kotlin/Pair
     617: invokevirtual #267                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     620: checkcast     #119                // class Point
     623: goto          628
     626: aload         11
     628: aload         23
     630: swap
     631: invokeinterface #315,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     636: pop
     637: goto          533
     640: aload         7
     642: checkcast     #141                // class java/util/List
     645: nop
     646: aload         22
     648: swap
     649: checkcast     #98                 // class java/lang/Iterable
     652: invokestatic  #319                // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     655: invokestatic  #182                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     658: areturn

  public static final java.util.List<kotlin.Pair<Point, Point>> proposedSteps(java.util.Set<Point>);
    Code:
       0: aload_0
       1: ldc_w         #360                // String <this>
       4: invokestatic  #23                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: new           #302                // class java/util/ArrayList
      10: dup
      11: invokespecial #361                // Method java/util/ArrayList."<init>":()V
      14: checkcast     #141                // class java/util/List
      17: astore_1
      18: aload_0
      19: checkcast     #98                 // class java/lang/Iterable
      22: astore_2
      23: iconst_0
      24: istore_3
      25: aload_2
      26: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      31: astore        4
      33: aload         4
      35: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      40: ifeq          375
      43: aload         4
      45: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      50: astore        5
      52: aload         5
      54: checkcast     #119                // class Point
      57: astore        6
      59: iconst_0
      60: istore        7
      62: aload         6
      64: invokevirtual #364                // Method Point.allNeighbours:()Ljava/util/Set;
      67: checkcast     #98                 // class java/lang/Iterable
      70: astore        8
      72: iconst_0
      73: istore        9
      75: aload         8
      77: instanceof    #261                // class java/util/Collection
      80: ifeq          100
      83: aload         8
      85: checkcast     #261                // class java/util/Collection
      88: invokeinterface #264,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      93: ifeq          100
      96: iconst_0
      97: goto          154
     100: aload         8
     102: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     107: astore        10
     109: aload         10
     111: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     116: ifeq          153
     119: aload         10
     121: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     126: astore        11
     128: aload         11
     130: checkcast     #119                // class Point
     133: astore        12
     135: iconst_0
     136: istore        13
     138: aload_0
     139: aload         12
     141: invokeinterface #366,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     146: ifeq          109
     149: iconst_1
     150: goto          154
     153: iconst_0
     154: ifeq          370
     157: getstatic     #12                 // Field directionsToCheck:Ljava/util/List;
     160: checkcast     #98                 // class java/lang/Iterable
     163: astore        9
     165: iconst_0
     166: istore        10
     168: aload         9
     170: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     175: astore        11
     177: aload         11
     179: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     184: ifeq          321
     187: aload         11
     189: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     194: astore        12
     196: aload         12
     198: checkcast     #143                // class kotlin/reflect/KFunction
     201: astore        13
     203: iconst_0
     204: istore        14
     206: aload         13
     208: checkcast     #368                // class kotlin/jvm/functions/Function1
     211: aload         6
     213: invokeinterface #370,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     218: checkcast     #141                // class java/util/List
     221: iconst_1
     222: invokestatic  #374                // Method kotlin/collections/CollectionsKt.dropLast:(Ljava/util/List;I)Ljava/util/List;
     225: checkcast     #98                 // class java/lang/Iterable
     228: astore        15
     230: iconst_0
     231: istore        16
     233: aload         15
     235: instanceof    #261                // class java/util/Collection
     238: ifeq          258
     241: aload         15
     243: checkcast     #261                // class java/util/Collection
     246: invokeinterface #264,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     251: ifeq          258
     254: iconst_1
     255: goto          312
     258: aload         15
     260: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     265: astore        17
     267: aload         17
     269: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     274: ifeq          311
     277: aload         17
     279: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     284: astore        18
     286: aload         18
     288: checkcast     #119                // class Point
     291: astore        19
     293: iconst_0
     294: istore        20
     296: aload_0
     297: aload         19
     299: invokeinterface #366,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     304: ifeq          267
     307: iconst_0
     308: goto          312
     311: iconst_1
     312: nop
     313: ifeq          177
     316: aload         12
     318: goto          322
     321: aconst_null
     322: checkcast     #143                // class kotlin/reflect/KFunction
     325: astore        8
     327: aload         8
     329: ifnull        370
     332: aload_1
     333: aload         6
     335: aload         6
     337: aload         8
     339: checkcast     #368                // class kotlin/jvm/functions/Function1
     342: aload         6
     344: invokeinterface #370,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     349: checkcast     #141                // class java/util/List
     352: invokestatic  #378                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     355: checkcast     #119                // class Point
     358: invokevirtual #382                // Method Point.plus:(LPoint;)LPoint;
     361: invokestatic  #182                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     364: invokeinterface #224,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     369: pop
     370: nop
     371: nop
     372: goto          33
     375: nop
     376: aload_1
     377: areturn

  public static final java.util.Set<Point> toGrove(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc_w         #360                // String <this>
       4: invokestatic  #23                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: checkcast     #98                 // class java/lang/Iterable
      11: astore_1
      12: new           #302                // class java/util/ArrayList
      15: dup
      16: invokespecial #361                // Method java/util/ArrayList."<init>":()V
      19: checkcast     #261                // class java/util/Collection
      22: astore_2
      23: iconst_0
      24: istore_3
      25: aload_1
      26: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      31: astore        4
      33: aload         4
      35: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      40: ifeq          242
      43: aload         4
      45: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      50: astore        5
      52: iload_3
      53: iinc          3, 1
      56: istore        6
      58: iload         6
      60: ifge          66
      63: invokestatic  #402                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      66: iload         6
      68: aload         5
      70: checkcast     #404                // class java/lang/String
      73: astore        7
      75: istore        8
      77: iconst_0
      78: istore        9
      80: aload         7
      82: checkcast     #406                // class java/lang/CharSequence
      85: astore        10
      87: iconst_0
      88: istore        11
      90: aload         10
      92: astore        12
      94: new           #302                // class java/util/ArrayList
      97: dup
      98: invokespecial #361                // Method java/util/ArrayList."<init>":()V
     101: checkcast     #261                // class java/util/Collection
     104: astore        13
     106: iconst_0
     107: istore        14
     109: aload         12
     111: astore        15
     113: iconst_0
     114: istore        16
     116: iconst_0
     117: istore        17
     119: iconst_0
     120: istore        18
     122: iload         18
     124: aload         15
     126: invokeinterface #409,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     131: if_icmpge     222
     134: aload         15
     136: iload         18
     138: invokeinterface #413,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     143: istore        19
     145: iload         17
     147: iinc          17, 1
     150: iload         19
     152: istore        20
     154: istore        21
     156: iconst_0
     157: istore        22
     159: iload         21
     161: iload         20
     163: istore        23
     165: istore        24
     167: iconst_0
     168: istore        25
     170: iload         23
     172: bipush        35
     174: if_icmpne     191
     177: new           #119                // class Point
     180: dup
     181: iload         24
     183: iload         8
     185: invokespecial #416                // Method Point."<init>":(II)V
     188: goto          192
     191: aconst_null
     192: dup
     193: ifnull        214
     196: astore        26
     198: iconst_0
     199: istore        27
     201: aload         13
     203: aload         26
     205: invokeinterface #315,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     210: pop
     211: goto          215
     214: pop
     215: nop
     216: iinc          18, 1
     219: goto          122
     222: nop
     223: aload         13
     225: checkcast     #141                // class java/util/List
     228: nop
     229: checkcast     #98                 // class java/lang/Iterable
     232: nop
     233: aload_2
     234: swap
     235: invokestatic  #420                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     238: pop
     239: goto          33
     242: aload_2
     243: checkcast     #141                // class java/util/List
     246: checkcast     #98                 // class java/lang/Iterable
     249: invokestatic  #319                // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     252: areturn

  public static final java.util.List<Point> northernNeighbours(Point);
    Code:
       0: aload_0
       1: ldc_w         #360                // String <this>
       4: invokestatic  #23                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: iconst_4
       8: anewarray     #119                // class Point
      11: astore_1
      12: aload_1
      13: iconst_0
      14: new           #119                // class Point
      17: dup
      18: aload_0
      19: invokevirtual #123                // Method Point.getX:()I
      22: iconst_1
      23: isub
      24: aload_0
      25: invokevirtual #126                // Method Point.getY:()I
      28: iconst_1
      29: isub
      30: invokespecial #416                // Method Point."<init>":(II)V
      33: aastore
      34: aload_1
      35: iconst_1
      36: new           #119                // class Point
      39: dup
      40: aload_0
      41: invokevirtual #123                // Method Point.getX:()I
      44: aload_0
      45: invokevirtual #126                // Method Point.getY:()I
      48: iconst_1
      49: isub
      50: invokespecial #416                // Method Point."<init>":(II)V
      53: aastore
      54: aload_1
      55: iconst_2
      56: new           #119                // class Point
      59: dup
      60: aload_0
      61: invokevirtual #123                // Method Point.getX:()I
      64: iconst_1
      65: iadd
      66: aload_0
      67: invokevirtual #126                // Method Point.getY:()I
      70: iconst_1
      71: isub
      72: invokespecial #416                // Method Point."<init>":(II)V
      75: aastore
      76: aload_1
      77: iconst_3
      78: new           #119                // class Point
      81: dup
      82: iconst_0
      83: iconst_m1
      84: invokespecial #416                // Method Point."<init>":(II)V
      87: aastore
      88: aload_1
      89: invokestatic  #448                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      92: areturn

  public static final java.util.List<Point> southernNeighbours(Point);
    Code:
       0: aload_0
       1: ldc_w         #360                // String <this>
       4: invokestatic  #23                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: iconst_4
       8: anewarray     #119                // class Point
      11: astore_1
      12: aload_1
      13: iconst_0
      14: new           #119                // class Point
      17: dup
      18: aload_0
      19: invokevirtual #123                // Method Point.getX:()I
      22: iconst_1
      23: isub
      24: aload_0
      25: invokevirtual #126                // Method Point.getY:()I
      28: iconst_1
      29: iadd
      30: invokespecial #416                // Method Point."<init>":(II)V
      33: aastore
      34: aload_1
      35: iconst_1
      36: new           #119                // class Point
      39: dup
      40: aload_0
      41: invokevirtual #123                // Method Point.getX:()I
      44: aload_0
      45: invokevirtual #126                // Method Point.getY:()I
      48: iconst_1
      49: iadd
      50: invokespecial #416                // Method Point."<init>":(II)V
      53: aastore
      54: aload_1
      55: iconst_2
      56: new           #119                // class Point
      59: dup
      60: aload_0
      61: invokevirtual #123                // Method Point.getX:()I
      64: iconst_1
      65: iadd
      66: aload_0
      67: invokevirtual #126                // Method Point.getY:()I
      70: iconst_1
      71: iadd
      72: invokespecial #416                // Method Point."<init>":(II)V
      75: aastore
      76: aload_1
      77: iconst_3
      78: new           #119                // class Point
      81: dup
      82: iconst_0
      83: iconst_1
      84: invokespecial #416                // Method Point."<init>":(II)V
      87: aastore
      88: aload_1
      89: invokestatic  #448                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      92: areturn

  public static final java.util.List<Point> easternNeighbours(Point);
    Code:
       0: aload_0
       1: ldc_w         #360                // String <this>
       4: invokestatic  #23                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: iconst_4
       8: anewarray     #119                // class Point
      11: astore_1
      12: aload_1
      13: iconst_0
      14: new           #119                // class Point
      17: dup
      18: aload_0
      19: invokevirtual #123                // Method Point.getX:()I
      22: iconst_1
      23: iadd
      24: aload_0
      25: invokevirtual #126                // Method Point.getY:()I
      28: iconst_1
      29: isub
      30: invokespecial #416                // Method Point."<init>":(II)V
      33: aastore
      34: aload_1
      35: iconst_1
      36: new           #119                // class Point
      39: dup
      40: aload_0
      41: invokevirtual #123                // Method Point.getX:()I
      44: iconst_1
      45: iadd
      46: aload_0
      47: invokevirtual #126                // Method Point.getY:()I
      50: invokespecial #416                // Method Point."<init>":(II)V
      53: aastore
      54: aload_1
      55: iconst_2
      56: new           #119                // class Point
      59: dup
      60: aload_0
      61: invokevirtual #123                // Method Point.getX:()I
      64: iconst_1
      65: iadd
      66: aload_0
      67: invokevirtual #126                // Method Point.getY:()I
      70: iconst_1
      71: iadd
      72: invokespecial #416                // Method Point."<init>":(II)V
      75: aastore
      76: aload_1
      77: iconst_3
      78: new           #119                // class Point
      81: dup
      82: iconst_1
      83: iconst_0
      84: invokespecial #416                // Method Point."<init>":(II)V
      87: aastore
      88: aload_1
      89: invokestatic  #448                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      92: areturn

  public static final java.util.List<Point> westernNeighbours(Point);
    Code:
       0: aload_0
       1: ldc_w         #360                // String <this>
       4: invokestatic  #23                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: iconst_4
       8: anewarray     #119                // class Point
      11: astore_1
      12: aload_1
      13: iconst_0
      14: new           #119                // class Point
      17: dup
      18: aload_0
      19: invokevirtual #123                // Method Point.getX:()I
      22: iconst_1
      23: isub
      24: aload_0
      25: invokevirtual #126                // Method Point.getY:()I
      28: iconst_1
      29: isub
      30: invokespecial #416                // Method Point."<init>":(II)V
      33: aastore
      34: aload_1
      35: iconst_1
      36: new           #119                // class Point
      39: dup
      40: aload_0
      41: invokevirtual #123                // Method Point.getX:()I
      44: iconst_1
      45: isub
      46: aload_0
      47: invokevirtual #126                // Method Point.getY:()I
      50: invokespecial #416                // Method Point."<init>":(II)V
      53: aastore
      54: aload_1
      55: iconst_2
      56: new           #119                // class Point
      59: dup
      60: aload_0
      61: invokevirtual #123                // Method Point.getX:()I
      64: iconst_1
      65: isub
      66: aload_0
      67: invokevirtual #126                // Method Point.getY:()I
      70: iconst_1
      71: iadd
      72: invokespecial #416                // Method Point."<init>":(II)V
      75: aastore
      76: aload_1
      77: iconst_3
      78: new           #119                // class Point
      81: dup
      82: iconst_m1
      83: iconst_0
      84: invokespecial #416                // Method Point."<init>":(II)V
      87: aastore
      88: aload_1
      89: invokestatic  #448                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      92: areturn

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

  private static final java.util.Set part1$lambda$0(java.util.Set);
    Code:
       0: aload_0
       1: ldc_w         #461                // String it
       4: invokestatic  #23                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokestatic  #463                // Method step:(Ljava/util/Set;)Lkotlin/Pair;
      11: invokevirtual #267                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      14: checkcast     #96                 // class java/util/Set
      17: areturn

  private static final kotlin.Pair part2$lambda$6(kotlin.Pair);
    Code:
       0: aload_0
       1: ldc_w         #465                // String result
       4: invokestatic  #23                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokevirtual #267                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      11: checkcast     #96                 // class java/util/Set
      14: invokestatic  #463                // Method step:(Ljava/util/Set;)Lkotlin/Pair;
      17: areturn

  private static final boolean part2$lambda$7(kotlin.Pair);
    Code:
       0: aload_0
       1: ldc_w         #461                // String it
       4: invokestatic  #23                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokevirtual #251                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      11: aload_0
      12: invokevirtual #267                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      15: invokestatic  #271                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      18: ifne          25
      21: iconst_1
      22: goto          26
      25: iconst_0
      26: ireturn

  static {};
    Code:
       0: iconst_4
       1: anewarray     #143                // class kotlin/reflect/KFunction
       4: astore_0
       5: aload_0
       6: iconst_0
       7: getstatic     #471                // Field day23/Day23Kt$directionsToCheck$1.INSTANCE:Lday23/Day23Kt$directionsToCheck$1;
      10: aastore
      11: aload_0
      12: iconst_1
      13: getstatic     #476                // Field day23/Day23Kt$directionsToCheck$2.INSTANCE:Lday23/Day23Kt$directionsToCheck$2;
      16: aastore
      17: aload_0
      18: iconst_2
      19: getstatic     #481                // Field day23/Day23Kt$directionsToCheck$3.INSTANCE:Lday23/Day23Kt$directionsToCheck$3;
      22: aastore
      23: aload_0
      24: iconst_3
      25: getstatic     #486                // Field day23/Day23Kt$directionsToCheck$4.INSTANCE:Lday23/Day23Kt$directionsToCheck$4;
      28: aastore
      29: aload_0
      30: invokestatic  #170                // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
      33: putstatic     #12                 // Field directionsToCheck:Ljava/util/List;
      36: return
}

Compiled from "day23.kt"
final class day23.Day23Kt$part2$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<Point, java.util.List<? extends Point>> {
  public static final day23.Day23Kt$part2$2 INSTANCE;

  day23.Day23Kt$part2$2();
    Code:
       0: aload_0
       1: iconst_1
       2: ldc           #11                 // class day23/Day23Kt
       4: ldc           #13                 // String southernNeighbours
       6: ldc           #15                 // String southernNeighbours(LPoint;)Ljava/util/List;
       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 java.util.List<Point> invoke(Point);
    Code:
       0: aload_1
       1: ldc           #25                 // String p0
       3: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokestatic  #33                 // Method day23/Day23Kt.southernNeighbours:(LPoint;)Ljava/util/List;
      10: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #37                 // class Point
       5: invokevirtual #39                 // Method invoke:(LPoint;)Ljava/util/List;
       8: areturn

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

Compiled from "day23.kt"
final class day23.Day23Kt$directionsToCheck$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<Point, java.util.List<? extends Point>> {
  public static final day23.Day23Kt$directionsToCheck$2 INSTANCE;

  day23.Day23Kt$directionsToCheck$2();
    Code:
       0: aload_0
       1: iconst_1
       2: ldc           #11                 // class day23/Day23Kt
       4: ldc           #13                 // String southernNeighbours
       6: ldc           #15                 // String southernNeighbours(LPoint;)Ljava/util/List;
       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 java.util.List<Point> invoke(Point);
    Code:
       0: aload_1
       1: ldc           #25                 // String p0
       3: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokestatic  #33                 // Method day23/Day23Kt.southernNeighbours:(LPoint;)Ljava/util/List;
      10: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #37                 // class Point
       5: invokevirtual #39                 // Method invoke:(LPoint;)Ljava/util/List;
       8: areturn

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

Compiled from "day23.kt"
final class day23.Day23Kt$part2$3 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<Point, java.util.List<? extends Point>> {
  public static final day23.Day23Kt$part2$3 INSTANCE;

  day23.Day23Kt$part2$3();
    Code:
       0: aload_0
       1: iconst_1
       2: ldc           #11                 // class day23/Day23Kt
       4: ldc           #13                 // String westernNeighbours
       6: ldc           #15                 // String westernNeighbours(LPoint;)Ljava/util/List;
       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 java.util.List<Point> invoke(Point);
    Code:
       0: aload_1
       1: ldc           #25                 // String p0
       3: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokestatic  #33                 // Method day23/Day23Kt.westernNeighbours:(LPoint;)Ljava/util/List;
      10: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #37                 // class Point
       5: invokevirtual #39                 // Method invoke:(LPoint;)Ljava/util/List;
       8: areturn

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

Compiled from "day23.kt"
final class day23.Day23Kt$part2$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<Point, java.util.List<? extends Point>> {
  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 northernNeighbours
       6: ldc           #15                 // String northernNeighbours(LPoint;)Ljava/util/List;
       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 java.util.List<Point> invoke(Point);
    Code:
       0: aload_1
       1: ldc           #25                 // String p0
       3: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokestatic  #33                 // Method day23/Day23Kt.northernNeighbours:(LPoint;)Ljava/util/List;
      10: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #37                 // class Point
       5: invokevirtual #39                 // Method invoke:(LPoint;)Ljava/util/List;
       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
}

Compiled from "day23.kt"
final class day23.Day23Kt$directionsToCheck$4 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<Point, java.util.List<? extends Point>> {
  public static final day23.Day23Kt$directionsToCheck$4 INSTANCE;

  day23.Day23Kt$directionsToCheck$4();
    Code:
       0: aload_0
       1: iconst_1
       2: ldc           #11                 // class day23/Day23Kt
       4: ldc           #13                 // String easternNeighbours
       6: ldc           #15                 // String easternNeighbours(LPoint;)Ljava/util/List;
       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 java.util.List<Point> invoke(Point);
    Code:
       0: aload_1
       1: ldc           #25                 // String p0
       3: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokestatic  #33                 // Method day23/Day23Kt.easternNeighbours:(LPoint;)Ljava/util/List;
      10: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #37                 // class Point
       5: invokevirtual #39                 // Method invoke:(LPoint;)Ljava/util/List;
       8: areturn

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