fun main() {
    val directionsToConsider = arrayOf(
        arrayOf(
            Vector2d.UP,
            Vector2d.UP + Vector2d.LEFT,
            Vector2d.UP + Vector2d.RIGHT,
        ),
        arrayOf(
            Vector2d.DOWN,
            Vector2d.DOWN + Vector2d.LEFT,
            Vector2d.DOWN + Vector2d.RIGHT,
        ),
        arrayOf(
            Vector2d.LEFT,
            Vector2d.LEFT + Vector2d.UP,
            Vector2d.LEFT + Vector2d.DOWN,
        ),
        arrayOf(
            Vector2d.RIGHT,
            Vector2d.RIGHT + Vector2d.UP,
            Vector2d.RIGHT + Vector2d.DOWN,
        ),
    )

    fun diffuseElves(elves: MutableSet<Vector2d>, stopAfterRound: Int = -1): Int {
        var rounds = 1
        var directionsToConsiderIndex = 0

        while (true) {
            val moveProposals = mutableMapOf<Vector2d, Vector2d>()
            val moveProposalsDuplicates = mutableSetOf<Vector2d>()
            val moveProposalsElves = mutableSetOf<Vector2d>()

            // first half
            for (elf in elves) {
                val neighbours = elf.neighbours8().intersect(elves)

                if (neighbours.isEmpty())
                    continue

                for (n in directionsToConsider.indices) {
                    val directionToConsiderIndex = (directionsToConsiderIndex + n) % directionsToConsider.size
                    val directionNeighbours = directionsToConsider[directionToConsiderIndex].map { elf + it }.toSet()

                    if (directionNeighbours.intersect(neighbours).isEmpty()) {
                        val moveProposal = directionNeighbours.first()

                        if (moveProposal in moveProposalsDuplicates)
                            break

                        if (moveProposal in moveProposals) {
                            moveProposalsDuplicates += moveProposal
                            moveProposalsElves -= moveProposals[moveProposal]!!
                            moveProposals -= moveProposal

                            break
                        }

                        moveProposals[moveProposal] = elf
                        moveProposalsElves += elf

                        break
                    }
                }
            }

            if (stopAfterRound == -1 && moveProposals.isEmpty())
                break

            // second half
            elves -= moveProposalsElves
//            elves -= moveProposals.values.toSet()
            elves += moveProposals.keys

            directionsToConsiderIndex = (directionsToConsiderIndex + 1) % directionsToConsider.size

            if (rounds++ == stopAfterRound)
                break
        }

        return rounds
    }

    fun part1(input: List<String>): Int {
        val elves = Grid(input.map { line -> line.toCharArray().toList() }).data.flatten().filter { it.value == '#' }.map { it.position }.toMutableSet()

        diffuseElves(elves, stopAfterRound = 10)

        val minX = elves.minOf { it.x }
        val maxX = elves.maxOf { it.x }
        val minY = elves.minOf { it.y }
        val maxY = elves.maxOf { it.y }

        return (maxX - minX + 1) * (maxY - minY + 1) - elves.size
    }

    fun part2(input: List<String>): Int {
        val elves = Grid(input.map { line -> line.toCharArray().toList() }).data.flatten().filter { it.value == '#' }.map { it.position }.toMutableSet()

        return diffuseElves(elves)
    }

    test(
        day = 23,
        testTarget1 = 110,
        testTarget2 = 20,
        part1 = ::part1,
        part2 = ::part2,
    )
}

Compiled from "Day23.kt"
final class Day23Kt$main$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.util.List<? extends java.lang.String>, java.lang.Integer> {
  final Vector2d[][] $directionsToConsider;

  Day23Kt$main$1(Vector2d[][]);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #13                 // Field $directionsToConsider:[[LVector2d;
       5: aload_0
       6: iconst_1
       7: ldc           #15                 // class kotlin/jvm/internal/Intrinsics$Kotlin
       9: ldc           #17                 // String part1
      11: ldc           #19                 // String main$part1([[LVector2d;Ljava/util/List;)I
      13: iconst_0
      14: invokespecial #22                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      17: return

  public final java.lang.Integer invoke(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #29                 // String p0
       3: invokestatic  #35                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: getfield      #13                 // Field $directionsToConsider:[[LVector2d;
      10: aload_1
      11: invokestatic  #41                 // Method Day23Kt.access$main$part1:([[LVector2d;Ljava/util/List;)I
      14: invokestatic  #47                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      17: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #51                 // class java/util/List
       5: invokevirtual #53                 // Method invoke:(Ljava/util/List;)Ljava/lang/Integer;
       8: areturn
}

Compiled from "Day23.kt"
public final class Day23Kt {
  public static final void main();
    Code:
       0: iconst_4
       1: anewarray     #8                  // class "[LVector2d;"
       4: astore_1
       5: aload_1
       6: iconst_0
       7: iconst_3
       8: anewarray     #10                 // class Vector2d
      11: astore_2
      12: aload_2
      13: iconst_0
      14: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
      17: invokevirtual #20                 // Method Vector2d$Companion.getUP:()LVector2d;
      20: aastore
      21: aload_2
      22: iconst_1
      23: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
      26: invokevirtual #20                 // Method Vector2d$Companion.getUP:()LVector2d;
      29: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
      32: invokevirtual #23                 // Method Vector2d$Companion.getLEFT:()LVector2d;
      35: invokevirtual #27                 // Method Vector2d.plus:(LVector2d;)LVector2d;
      38: aastore
      39: aload_2
      40: iconst_2
      41: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
      44: invokevirtual #20                 // Method Vector2d$Companion.getUP:()LVector2d;
      47: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
      50: invokevirtual #30                 // Method Vector2d$Companion.getRIGHT:()LVector2d;
      53: invokevirtual #27                 // Method Vector2d.plus:(LVector2d;)LVector2d;
      56: aastore
      57: aload_2
      58: aastore
      59: aload_1
      60: iconst_1
      61: iconst_3
      62: anewarray     #10                 // class Vector2d
      65: astore_2
      66: aload_2
      67: iconst_0
      68: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
      71: invokevirtual #33                 // Method Vector2d$Companion.getDOWN:()LVector2d;
      74: aastore
      75: aload_2
      76: iconst_1
      77: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
      80: invokevirtual #33                 // Method Vector2d$Companion.getDOWN:()LVector2d;
      83: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
      86: invokevirtual #23                 // Method Vector2d$Companion.getLEFT:()LVector2d;
      89: invokevirtual #27                 // Method Vector2d.plus:(LVector2d;)LVector2d;
      92: aastore
      93: aload_2
      94: iconst_2
      95: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
      98: invokevirtual #33                 // Method Vector2d$Companion.getDOWN:()LVector2d;
     101: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
     104: invokevirtual #30                 // Method Vector2d$Companion.getRIGHT:()LVector2d;
     107: invokevirtual #27                 // Method Vector2d.plus:(LVector2d;)LVector2d;
     110: aastore
     111: aload_2
     112: aastore
     113: aload_1
     114: iconst_2
     115: iconst_3
     116: anewarray     #10                 // class Vector2d
     119: astore_2
     120: aload_2
     121: iconst_0
     122: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
     125: invokevirtual #23                 // Method Vector2d$Companion.getLEFT:()LVector2d;
     128: aastore
     129: aload_2
     130: iconst_1
     131: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
     134: invokevirtual #23                 // Method Vector2d$Companion.getLEFT:()LVector2d;
     137: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
     140: invokevirtual #20                 // Method Vector2d$Companion.getUP:()LVector2d;
     143: invokevirtual #27                 // Method Vector2d.plus:(LVector2d;)LVector2d;
     146: aastore
     147: aload_2
     148: iconst_2
     149: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
     152: invokevirtual #23                 // Method Vector2d$Companion.getLEFT:()LVector2d;
     155: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
     158: invokevirtual #33                 // Method Vector2d$Companion.getDOWN:()LVector2d;
     161: invokevirtual #27                 // Method Vector2d.plus:(LVector2d;)LVector2d;
     164: aastore
     165: aload_2
     166: aastore
     167: aload_1
     168: iconst_3
     169: iconst_3
     170: anewarray     #10                 // class Vector2d
     173: astore_2
     174: aload_2
     175: iconst_0
     176: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
     179: invokevirtual #30                 // Method Vector2d$Companion.getRIGHT:()LVector2d;
     182: aastore
     183: aload_2
     184: iconst_1
     185: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
     188: invokevirtual #30                 // Method Vector2d$Companion.getRIGHT:()LVector2d;
     191: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
     194: invokevirtual #20                 // Method Vector2d$Companion.getUP:()LVector2d;
     197: invokevirtual #27                 // Method Vector2d.plus:(LVector2d;)LVector2d;
     200: aastore
     201: aload_2
     202: iconst_2
     203: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
     206: invokevirtual #30                 // Method Vector2d$Companion.getRIGHT:()LVector2d;
     209: getstatic     #14                 // Field Vector2d.Companion:LVector2d$Companion;
     212: invokevirtual #33                 // Method Vector2d$Companion.getDOWN:()LVector2d;
     215: invokevirtual #27                 // Method Vector2d.plus:(LVector2d;)LVector2d;
     218: aastore
     219: aload_2
     220: aastore
     221: aload_1
     222: astore_0
     223: bipush        23
     225: bipush        110
     227: invokestatic  #39                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     230: bipush        20
     232: invokestatic  #39                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     235: new           #41                 // class Day23Kt$main$1
     238: dup
     239: aload_0
     240: invokespecial #45                 // Method Day23Kt$main$1."<init>":([[LVector2d;)V
     243: checkcast     #47                 // class kotlin/jvm/functions/Function1
     246: new           #49                 // class Day23Kt$main$2
     249: dup
     250: aload_0
     251: invokespecial #50                 // Method Day23Kt$main$2."<init>":([[LVector2d;)V
     254: checkcast     #47                 // class kotlin/jvm/functions/Function1
     257: invokestatic  #56                 // Method UtilsKt.test:(ILjava/lang/Object;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V
     260: return

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

  private static final int main$diffuseElves(Vector2d[][], java.util.Set<Vector2d>, int);
    Code:
       0: iconst_1
       1: istore_3
       2: iconst_0
       3: istore        4
       5: nop
       6: new           #68                 // class java/util/LinkedHashMap
       9: dup
      10: invokespecial #70                 // Method java/util/LinkedHashMap."<init>":()V
      13: checkcast     #72                 // class java/util/Map
      16: astore        5
      18: new           #74                 // class java/util/LinkedHashSet
      21: dup
      22: invokespecial #75                 // Method java/util/LinkedHashSet."<init>":()V
      25: checkcast     #77                 // class java/util/Set
      28: astore        6
      30: new           #74                 // class java/util/LinkedHashSet
      33: dup
      34: invokespecial #75                 // Method java/util/LinkedHashSet."<init>":()V
      37: checkcast     #77                 // class java/util/Set
      40: astore        7
      42: aload_1
      43: invokeinterface #81,  1           // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
      48: astore        8
      50: aload         8
      52: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      57: ifeq          377
      60: aload         8
      62: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      67: checkcast     #10                 // class Vector2d
      70: astore        9
      72: aload         9
      74: invokevirtual #95                 // Method Vector2d.neighbours8:()Ljava/util/Set;
      77: checkcast     #97                 // class java/lang/Iterable
      80: aload_1
      81: checkcast     #97                 // class java/lang/Iterable
      84: invokestatic  #103                // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
      87: astore        10
      89: aload         10
      91: invokeinterface #106,  1          // InterfaceMethod java/util/Set.isEmpty:()Z
      96: ifeq          102
      99: goto          50
     102: iconst_0
     103: istore        11
     105: aload_0
     106: checkcast     #108                // class "[Ljava/lang/Object;"
     109: arraylength
     110: istore        12
     112: iload         11
     114: iload         12
     116: if_icmpge     50
     119: iload         4
     121: iload         11
     123: iadd
     124: aload_0
     125: checkcast     #108                // class "[Ljava/lang/Object;"
     128: arraylength
     129: irem
     130: istore        13
     132: aload_0
     133: iload         13
     135: aaload
     136: astore        15
     138: iconst_0
     139: istore        16
     141: aload         15
     143: astore        17
     145: new           #110                // class java/util/ArrayList
     148: dup
     149: aload         15
     151: arraylength
     152: invokespecial #113                // Method java/util/ArrayList."<init>":(I)V
     155: checkcast     #115                // class java/util/Collection
     158: astore        18
     160: iconst_0
     161: istore        19
     163: iconst_0
     164: istore        20
     166: aload         17
     168: arraylength
     169: istore        21
     171: iload         20
     173: iload         21
     175: if_icmpge     218
     178: aload         17
     180: iload         20
     182: aaload
     183: astore        22
     185: aload         18
     187: aload         22
     189: astore        23
     191: astore        25
     193: iconst_0
     194: istore        24
     196: aload         9
     198: aload         23
     200: invokevirtual #27                 // Method Vector2d.plus:(LVector2d;)LVector2d;
     203: aload         25
     205: swap
     206: invokeinterface #119,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     211: pop
     212: iinc          20, 1
     215: goto          171
     218: aload         18
     220: checkcast     #121                // class java/util/List
     223: nop
     224: checkcast     #97                 // class java/lang/Iterable
     227: invokestatic  #125                // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     230: astore        14
     232: aload         14
     234: checkcast     #97                 // class java/lang/Iterable
     237: aload         10
     239: checkcast     #97                 // class java/lang/Iterable
     242: invokestatic  #103                // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
     245: invokeinterface #106,  1          // InterfaceMethod java/util/Set.isEmpty:()Z
     250: ifeq          371
     253: aload         14
     255: checkcast     #97                 // class java/lang/Iterable
     258: invokestatic  #129                // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;
     261: checkcast     #10                 // class Vector2d
     264: astore        15
     266: aload         6
     268: aload         15
     270: invokeinterface #132,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     275: ifeq          281
     278: goto          50
     281: aload         5
     283: aload         15
     285: invokeinterface #135,  2          // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
     290: ifeq          343
     293: aload         6
     295: checkcast     #115                // class java/util/Collection
     298: aload         15
     300: invokeinterface #119,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     305: pop
     306: aload         7
     308: checkcast     #115                // class java/util/Collection
     311: aload         5
     313: aload         15
     315: invokeinterface #139,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     320: dup
     321: invokestatic  #145                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     324: invokeinterface #148,  2          // InterfaceMethod java/util/Collection.remove:(Ljava/lang/Object;)Z
     329: pop
     330: aload         5
     332: aload         15
     334: invokeinterface #150,  2          // InterfaceMethod java/util/Map.remove:(Ljava/lang/Object;)Ljava/lang/Object;
     339: pop
     340: goto          50
     343: aload         5
     345: aload         15
     347: aload         9
     349: invokeinterface #154,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     354: pop
     355: aload         7
     357: checkcast     #115                // class java/util/Collection
     360: aload         9
     362: invokeinterface #119,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     367: pop
     368: goto          50
     371: iinc          11, 1
     374: goto          112
     377: iload_2
     378: iconst_m1
     379: if_icmpne     395
     382: aload         5
     384: invokeinterface #155,  1          // InterfaceMethod java/util/Map.isEmpty:()Z
     389: ifeq          395
     392: goto          449
     395: aload_1
     396: checkcast     #115                // class java/util/Collection
     399: aload         7
     401: checkcast     #97                 // class java/lang/Iterable
     404: invokestatic  #159                // Method kotlin/collections/CollectionsKt.removeAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     407: pop
     408: aload_1
     409: checkcast     #115                // class java/util/Collection
     412: aload         5
     414: invokeinterface #162,  1          // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;
     419: checkcast     #97                 // class java/lang/Iterable
     422: invokestatic  #165                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     425: pop
     426: iload         4
     428: iconst_1
     429: iadd
     430: aload_0
     431: checkcast     #108                // class "[Ljava/lang/Object;"
     434: arraylength
     435: irem
     436: istore        4
     438: iload_3
     439: iinc          3, 1
     442: iload_2
     443: if_icmpne     5
     446: goto          449
     449: iload_3
     450: ireturn

  static int main$diffuseElves$default(Vector2d[][], java.util.Set, int, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_4
       2: iand
       3: ifeq          8
       6: iconst_m1
       7: istore_2
       8: aload_0
       9: aload_1
      10: iload_2
      11: invokestatic  #197                // Method main$diffuseElves:([[LVector2d;Ljava/util/Set;I)I
      14: ireturn

  private static final int main$part1(Vector2d[][], java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: checkcast     #97                 // class java/lang/Iterable
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: astore        5
      11: new           #110                // class java/util/ArrayList
      14: dup
      15: aload_3
      16: bipush        10
      18: invokestatic  #204                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #113                // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #115                // class java/util/Collection
      27: astore        6
      29: iconst_0
      30: istore        7
      32: aload         5
      34: invokeinterface #205,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      39: astore        8
      41: aload         8
      43: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      48: ifeq          100
      51: aload         8
      53: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      58: astore        9
      60: aload         6
      62: aload         9
      64: checkcast     #207                // class java/lang/String
      67: astore        10
      69: astore        13
      71: iconst_0
      72: istore        11
      74: aload         10
      76: invokevirtual #211                // Method java/lang/String.toCharArray:()[C
      79: dup
      80: ldc           #213                // String toCharArray(...)
      82: invokestatic  #217                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      85: invokestatic  #223                // Method kotlin/collections/ArraysKt.toList:([C)Ljava/util/List;
      88: aload         13
      90: swap
      91: invokeinterface #119,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      96: pop
      97: goto          41
     100: aload         6
     102: checkcast     #121                // class java/util/List
     105: nop
     106: astore        14
     108: new           #225                // class Grid
     111: dup
     112: aload         14
     114: invokespecial #228                // Method Grid."<init>":(Ljava/util/List;)V
     117: invokevirtual #232                // Method Grid.getData:()Ljava/util/List;
     120: checkcast     #97                 // class java/lang/Iterable
     123: invokestatic  #236                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     126: checkcast     #97                 // class java/lang/Iterable
     129: astore_3
     130: iconst_0
     131: istore        4
     133: aload_3
     134: astore        5
     136: new           #110                // class java/util/ArrayList
     139: dup
     140: invokespecial #237                // Method java/util/ArrayList."<init>":()V
     143: checkcast     #115                // class java/util/Collection
     146: astore        6
     148: iconst_0
     149: istore        7
     151: aload         5
     153: invokeinterface #205,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     158: astore        8
     160: aload         8
     162: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     167: ifeq          226
     170: aload         8
     172: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     177: astore        9
     179: aload         9
     181: checkcast     #239                // class GridCell
     184: astore        10
     186: iconst_0
     187: istore        11
     189: aload         10
     191: invokevirtual #242                // Method GridCell.getValue:()Ljava/lang/Object;
     194: checkcast     #244                // class java/lang/Character
     197: invokevirtual #248                // Method java/lang/Character.charValue:()C
     200: bipush        35
     202: if_icmpne     209
     205: iconst_1
     206: goto          210
     209: iconst_0
     210: ifeq          160
     213: aload         6
     215: aload         9
     217: invokeinterface #119,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     222: pop
     223: goto          160
     226: aload         6
     228: checkcast     #121                // class java/util/List
     231: nop
     232: checkcast     #97                 // class java/lang/Iterable
     235: astore_3
     236: nop
     237: iconst_0
     238: istore        4
     240: aload_3
     241: astore        5
     243: new           #110                // class java/util/ArrayList
     246: dup
     247: aload_3
     248: bipush        10
     250: invokestatic  #204                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     253: invokespecial #113                // Method java/util/ArrayList."<init>":(I)V
     256: checkcast     #115                // class java/util/Collection
     259: astore        6
     261: iconst_0
     262: istore        7
     264: aload         5
     266: invokeinterface #205,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     271: astore        8
     273: aload         8
     275: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     280: ifeq          323
     283: aload         8
     285: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     290: astore        9
     292: aload         6
     294: aload         9
     296: checkcast     #239                // class GridCell
     299: astore        10
     301: astore        12
     303: iconst_0
     304: istore        11
     306: aload         10
     308: invokevirtual #251                // Method GridCell.getPosition:()LVector2d;
     311: aload         12
     313: swap
     314: invokeinterface #119,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     319: pop
     320: goto          273
     323: aload         6
     325: checkcast     #121                // class java/util/List
     328: nop
     329: checkcast     #97                 // class java/lang/Iterable
     332: invokestatic  #254                // Method kotlin/collections/CollectionsKt.toMutableSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     335: astore_2
     336: aload_0
     337: aload_2
     338: bipush        10
     340: invokestatic  #197                // Method main$diffuseElves:([[LVector2d;Ljava/util/Set;I)I
     343: pop
     344: aload_2
     345: checkcast     #97                 // class java/lang/Iterable
     348: invokeinterface #205,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     353: astore        5
     355: aload         5
     357: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     362: ifne          373
     365: new           #256                // class java/util/NoSuchElementException
     368: dup
     369: invokespecial #257                // Method java/util/NoSuchElementException."<init>":()V
     372: athrow
     373: aload         5
     375: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     380: checkcast     #10                 // class Vector2d
     383: astore        6
     385: iconst_0
     386: istore        7
     388: aload         6
     390: invokevirtual #261                // Method Vector2d.getX:()I
     393: istore        6
     395: aload         5
     397: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     402: ifeq          441
     405: aload         5
     407: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     412: checkcast     #10                 // class Vector2d
     415: astore        7
     417: iconst_0
     418: istore        8
     420: aload         7
     422: invokevirtual #261                // Method Vector2d.getX:()I
     425: istore        7
     427: iload         6
     429: iload         7
     431: if_icmple     395
     434: iload         7
     436: istore        6
     438: goto          395
     441: iload         6
     443: istore_3
     444: aload_2
     445: checkcast     #97                 // class java/lang/Iterable
     448: invokeinterface #205,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     453: astore        6
     455: aload         6
     457: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     462: ifne          473
     465: new           #256                // class java/util/NoSuchElementException
     468: dup
     469: invokespecial #257                // Method java/util/NoSuchElementException."<init>":()V
     472: athrow
     473: aload         6
     475: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     480: checkcast     #10                 // class Vector2d
     483: astore        7
     485: iconst_0
     486: istore        8
     488: aload         7
     490: invokevirtual #261                // Method Vector2d.getX:()I
     493: istore        7
     495: aload         6
     497: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     502: ifeq          541
     505: aload         6
     507: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     512: checkcast     #10                 // class Vector2d
     515: astore        8
     517: iconst_0
     518: istore        9
     520: aload         8
     522: invokevirtual #261                // Method Vector2d.getX:()I
     525: istore        8
     527: iload         7
     529: iload         8
     531: if_icmpge     495
     534: iload         8
     536: istore        7
     538: goto          495
     541: iload         7
     543: istore        4
     545: aload_2
     546: checkcast     #97                 // class java/lang/Iterable
     549: invokeinterface #205,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     554: astore        7
     556: aload         7
     558: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     563: ifne          574
     566: new           #256                // class java/util/NoSuchElementException
     569: dup
     570: invokespecial #257                // Method java/util/NoSuchElementException."<init>":()V
     573: athrow
     574: aload         7
     576: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     581: checkcast     #10                 // class Vector2d
     584: astore        8
     586: iconst_0
     587: istore        9
     589: aload         8
     591: invokevirtual #264                // Method Vector2d.getY:()I
     594: istore        8
     596: aload         7
     598: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     603: ifeq          642
     606: aload         7
     608: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     613: checkcast     #10                 // class Vector2d
     616: astore        9
     618: iconst_0
     619: istore        10
     621: aload         9
     623: invokevirtual #264                // Method Vector2d.getY:()I
     626: istore        9
     628: iload         8
     630: iload         9
     632: if_icmple     596
     635: iload         9
     637: istore        8
     639: goto          596
     642: iload         8
     644: istore        5
     646: aload_2
     647: checkcast     #97                 // class java/lang/Iterable
     650: invokeinterface #205,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     655: astore        8
     657: aload         8
     659: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     664: ifne          675
     667: new           #256                // class java/util/NoSuchElementException
     670: dup
     671: invokespecial #257                // Method java/util/NoSuchElementException."<init>":()V
     674: athrow
     675: aload         8
     677: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     682: checkcast     #10                 // class Vector2d
     685: astore        9
     687: iconst_0
     688: istore        10
     690: aload         9
     692: invokevirtual #264                // Method Vector2d.getY:()I
     695: istore        9
     697: aload         8
     699: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     704: ifeq          743
     707: aload         8
     709: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     714: checkcast     #10                 // class Vector2d
     717: astore        10
     719: iconst_0
     720: istore        11
     722: aload         10
     724: invokevirtual #264                // Method Vector2d.getY:()I
     727: istore        10
     729: iload         9
     731: iload         10
     733: if_icmpge     697
     736: iload         10
     738: istore        9
     740: goto          697
     743: iload         9
     745: istore        6
     747: iload         4
     749: iload_3
     750: isub
     751: iconst_1
     752: iadd
     753: iload         6
     755: iload         5
     757: isub
     758: iconst_1
     759: iadd
     760: imul
     761: aload_2
     762: invokeinterface #267,  1          // InterfaceMethod java/util/Set.size:()I
     767: isub
     768: ireturn

  private static final int main$part2(Vector2d[][], java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: checkcast     #97                 // class java/lang/Iterable
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: astore        5
      11: new           #110                // class java/util/ArrayList
      14: dup
      15: aload_3
      16: bipush        10
      18: invokestatic  #204                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #113                // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #115                // class java/util/Collection
      27: astore        6
      29: iconst_0
      30: istore        7
      32: aload         5
      34: invokeinterface #205,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      39: astore        8
      41: aload         8
      43: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      48: ifeq          100
      51: aload         8
      53: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      58: astore        9
      60: aload         6
      62: aload         9
      64: checkcast     #207                // class java/lang/String
      67: astore        10
      69: astore        13
      71: iconst_0
      72: istore        11
      74: aload         10
      76: invokevirtual #211                // Method java/lang/String.toCharArray:()[C
      79: dup
      80: ldc           #213                // String toCharArray(...)
      82: invokestatic  #217                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      85: invokestatic  #223                // Method kotlin/collections/ArraysKt.toList:([C)Ljava/util/List;
      88: aload         13
      90: swap
      91: invokeinterface #119,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      96: pop
      97: goto          41
     100: aload         6
     102: checkcast     #121                // class java/util/List
     105: nop
     106: astore        14
     108: new           #225                // class Grid
     111: dup
     112: aload         14
     114: invokespecial #228                // Method Grid."<init>":(Ljava/util/List;)V
     117: invokevirtual #232                // Method Grid.getData:()Ljava/util/List;
     120: checkcast     #97                 // class java/lang/Iterable
     123: invokestatic  #236                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     126: checkcast     #97                 // class java/lang/Iterable
     129: astore_3
     130: iconst_0
     131: istore        4
     133: aload_3
     134: astore        5
     136: new           #110                // class java/util/ArrayList
     139: dup
     140: invokespecial #237                // Method java/util/ArrayList."<init>":()V
     143: checkcast     #115                // class java/util/Collection
     146: astore        6
     148: iconst_0
     149: istore        7
     151: aload         5
     153: invokeinterface #205,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     158: astore        8
     160: aload         8
     162: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     167: ifeq          226
     170: aload         8
     172: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     177: astore        9
     179: aload         9
     181: checkcast     #239                // class GridCell
     184: astore        10
     186: iconst_0
     187: istore        11
     189: aload         10
     191: invokevirtual #242                // Method GridCell.getValue:()Ljava/lang/Object;
     194: checkcast     #244                // class java/lang/Character
     197: invokevirtual #248                // Method java/lang/Character.charValue:()C
     200: bipush        35
     202: if_icmpne     209
     205: iconst_1
     206: goto          210
     209: iconst_0
     210: ifeq          160
     213: aload         6
     215: aload         9
     217: invokeinterface #119,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     222: pop
     223: goto          160
     226: aload         6
     228: checkcast     #121                // class java/util/List
     231: nop
     232: checkcast     #97                 // class java/lang/Iterable
     235: astore_3
     236: nop
     237: iconst_0
     238: istore        4
     240: aload_3
     241: astore        5
     243: new           #110                // class java/util/ArrayList
     246: dup
     247: aload_3
     248: bipush        10
     250: invokestatic  #204                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     253: invokespecial #113                // Method java/util/ArrayList."<init>":(I)V
     256: checkcast     #115                // class java/util/Collection
     259: astore        6
     261: iconst_0
     262: istore        7
     264: aload         5
     266: invokeinterface #205,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     271: astore        8
     273: aload         8
     275: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     280: ifeq          323
     283: aload         8
     285: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     290: astore        9
     292: aload         6
     294: aload         9
     296: checkcast     #239                // class GridCell
     299: astore        10
     301: astore        12
     303: iconst_0
     304: istore        11
     306: aload         10
     308: invokevirtual #251                // Method GridCell.getPosition:()LVector2d;
     311: aload         12
     313: swap
     314: invokeinterface #119,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     319: pop
     320: goto          273
     323: aload         6
     325: checkcast     #121                // class java/util/List
     328: nop
     329: checkcast     #97                 // class java/lang/Iterable
     332: invokestatic  #254                // Method kotlin/collections/CollectionsKt.toMutableSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     335: astore_2
     336: aload_0
     337: aload_2
     338: iconst_0
     339: iconst_4
     340: aconst_null
     341: invokestatic  #292                // Method main$diffuseElves$default:([[LVector2d;Ljava/util/Set;IILjava/lang/Object;)I
     344: ireturn

  public static final int access$main$part1(Vector2d[][], java.util.List);
    Code:
       0: aload_0
       1: aload_1
       2: invokestatic  #298                // Method main$part1:([[LVector2d;Ljava/util/List;)I
       5: ireturn

  public static final int access$main$part2(Vector2d[][], java.util.List);
    Code:
       0: aload_0
       1: aload_1
       2: invokestatic  #301                // Method main$part2:([[LVector2d;Ljava/util/List;)I
       5: ireturn
}

Compiled from "Day23.kt"
final class Day23Kt$main$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.util.List<? extends java.lang.String>, java.lang.Integer> {
  final Vector2d[][] $directionsToConsider;

  Day23Kt$main$2(Vector2d[][]);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #13                 // Field $directionsToConsider:[[LVector2d;
       5: aload_0
       6: iconst_1
       7: ldc           #15                 // class kotlin/jvm/internal/Intrinsics$Kotlin
       9: ldc           #17                 // String part2
      11: ldc           #19                 // String main$part2([[LVector2d;Ljava/util/List;)I
      13: iconst_0
      14: invokespecial #22                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      17: return

  public final java.lang.Integer invoke(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #29                 // String p0
       3: invokestatic  #35                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: getfield      #13                 // Field $directionsToConsider:[[LVector2d;
      10: aload_1
      11: invokestatic  #41                 // Method Day23Kt.access$main$part2:([[LVector2d;Ljava/util/List;)I
      14: invokestatic  #47                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      17: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #51                 // class java/util/List
       5: invokevirtual #53                 // Method invoke:(Ljava/util/List;)Ljava/lang/Integer;
       8: areturn
}


import kotlin.math.absoluteValue

fun main() {
    class Wrapper(val value: Long)

    fun mix(originalOrder:List<Wrapper>, mixed:MutableList<Wrapper>){

//        println(mixed.map { it.value })

        for (entry in originalOrder) {
            val entryPositionInMixed = mixed.indexOf(entry)
            mixed.remove(entry)

            var newEntryPosition = entryPositionInMixed + entry.value

            if(newEntryPosition < 0){
                val n = (newEntryPosition.absoluteValue / mixed.size) + 1

                newEntryPosition += n * mixed.size
            }

            newEntryPosition %= mixed.size

            if(newEntryPosition == 0L)
                newEntryPosition = mixed.size.toLong()

//            println("Moving ${entry.value} between ${mixed[(newEntryPosition + mixed.size + - 1) % mixed.size].value} and ${mixed[(newEntryPosition) % mixed.size].value}")

            mixed.add(newEntryPosition.toInt(), entry)
//            println(mixed.map { it.value })
        }
    }

    fun part1(input: List<String>): Long {
        val originalOrder = input.map { Wrapper(it.toLong()) }
        val mixed = originalOrder.toMutableList()

        mix(originalOrder, mixed)

        val zeroPosition = mixed.indexOfFirst { it.value == 0L }

        return arrayOf(1000, 2000, 3000).map {
            mixed[(zeroPosition + it) % mixed.size].value
        }.sum()
    }

    fun part2(input: List<String>): Long {
        val originalOrder = input.map { Wrapper(it.toLong() * 811589153) }
        val mixed = originalOrder.toMutableList()

        repeat(10){ mix(originalOrder, mixed) }

        val zeroPosition = mixed.indexOfFirst { it.value == 0L }

        return arrayOf(1000, 2000, 3000).map {
            mixed[(zeroPosition + it) % mixed.size].value
        }.sum()
    }

    test(
        day = 20,
        testTarget1 = 3,
        testTarget2 = 1623178306,
        part1 = ::part1,
        part2 = ::part2,
    )
}

Compiled from "Day20.kt"
final class Day20Kt$main$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.util.List<? extends java.lang.String>, java.lang.Long> {
  public static final Day20Kt$main$2 INSTANCE;

  Day20Kt$main$2();
    Code:
       0: aload_0
       1: iconst_1
       2: ldc           #11                 // class kotlin/jvm/internal/Intrinsics$Kotlin
       4: ldc           #13                 // String part2
       6: ldc           #15                 // String main$part2(Ljava/util/List;)J
       8: iconst_0
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final java.lang.Long invoke(java.util.List<java.lang.String>);
    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  #37                 // Method Day20Kt.access$main$part2:(Ljava/util/List;)J
      10: invokestatic  #43                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      13: areturn

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

  static {};
    Code:
       0: new           #2                  // class Day20Kt$main$2
       3: dup
       4: invokespecial #54                 // Method "<init>":()V
       7: putstatic     #57                 // Field INSTANCE:LDay20Kt$main$2;
      10: return
}

Compiled from "Day20.kt"
final class Day20Kt$main$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.util.List<? extends java.lang.String>, java.lang.Long> {
  public static final Day20Kt$main$1 INSTANCE;

  Day20Kt$main$1();
    Code:
       0: aload_0
       1: iconst_1
       2: ldc           #11                 // class kotlin/jvm/internal/Intrinsics$Kotlin
       4: ldc           #13                 // String part1
       6: ldc           #15                 // String main$part1(Ljava/util/List;)J
       8: iconst_0
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final java.lang.Long invoke(java.util.List<java.lang.String>);
    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  #37                 // Method Day20Kt.access$main$part1:(Ljava/util/List;)J
      10: invokestatic  #43                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      13: areturn

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

  static {};
    Code:
       0: new           #2                  // class Day20Kt$main$1
       3: dup
       4: invokespecial #54                 // Method "<init>":()V
       7: putstatic     #57                 // Field INSTANCE:LDay20Kt$main$1;
      10: return
}

Compiled from "Day20.kt"
public final class Day20Kt {
  public static final void main();
    Code:
       0: bipush        20
       2: ldc2_w        #7                  // long 3l
       5: invokestatic  #14                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
       8: ldc2_w        #15                 // long 1623178306l
      11: invokestatic  #14                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      14: getstatic     #22                 // Field Day20Kt$main$1.INSTANCE:LDay20Kt$main$1;
      17: checkcast     #24                 // class kotlin/jvm/functions/Function1
      20: getstatic     #29                 // Field Day20Kt$main$2.INSTANCE:LDay20Kt$main$2;
      23: checkcast     #24                 // class kotlin/jvm/functions/Function1
      26: invokestatic  #35                 // Method UtilsKt.test:(ILjava/lang/Object;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V
      29: return

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

  private static final void main$mix(java.util.List<Day20Kt$main$Wrapper>, java.util.List<Day20Kt$main$Wrapper>);
    Code:
       0: aload_0
       1: invokeinterface #49,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
       6: astore_2
       7: aload_2
       8: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      13: ifeq          133
      16: aload_2
      17: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      22: checkcast     #61                 // class Day20Kt$main$Wrapper
      25: astore_3
      26: aload_1
      27: aload_3
      28: invokeinterface #65,  2           // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I
      33: istore        4
      35: aload_1
      36: aload_3
      37: invokeinterface #69,  2           // InterfaceMethod java/util/List.remove:(Ljava/lang/Object;)Z
      42: pop
      43: iload         4
      45: i2l
      46: aload_3
      47: invokevirtual #73                 // Method Day20Kt$main$Wrapper.getValue:()J
      50: ladd
      51: lstore        5
      53: lload         5
      55: lconst_0
      56: lcmp
      57: ifge          92
      60: lload         5
      62: invokestatic  #79                 // Method java/lang/Math.abs:(J)J
      65: aload_1
      66: invokeinterface #83,  1           // InterfaceMethod java/util/List.size:()I
      71: i2l
      72: ldiv
      73: lconst_1
      74: ladd
      75: lstore        7
      77: lload         5
      79: lload         7
      81: aload_1
      82: invokeinterface #83,  1           // InterfaceMethod java/util/List.size:()I
      87: i2l
      88: lmul
      89: ladd
      90: lstore        5
      92: lload         5
      94: aload_1
      95: invokeinterface #83,  1           // InterfaceMethod java/util/List.size:()I
     100: i2l
     101: lrem
     102: lstore        5
     104: lload         5
     106: lconst_0
     107: lcmp
     108: ifne          120
     111: aload_1
     112: invokeinterface #83,  1           // InterfaceMethod java/util/List.size:()I
     117: i2l
     118: lstore        5
     120: aload_1
     121: lload         5
     123: l2i
     124: aload_3
     125: invokeinterface #87,  3           // InterfaceMethod java/util/List.add:(ILjava/lang/Object;)V
     130: goto          7
     133: return

  private static final long main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #102                // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: astore        4
      10: new           #104                // class java/util/ArrayList
      13: dup
      14: aload_2
      15: bipush        10
      17: invokestatic  #110                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      20: invokespecial #114                // Method java/util/ArrayList."<init>":(I)V
      23: checkcast     #116                // class java/util/Collection
      26: astore        5
      28: iconst_0
      29: istore        6
      31: aload         4
      33: invokeinterface #117,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      38: astore        7
      40: aload         7
      42: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      47: ifeq          97
      50: aload         7
      52: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      57: astore        8
      59: aload         5
      61: aload         8
      63: checkcast     #119                // class java/lang/String
      66: astore        9
      68: astore        14
      70: iconst_0
      71: istore        10
      73: new           #61                 // class Day20Kt$main$Wrapper
      76: dup
      77: aload         9
      79: invokestatic  #123                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
      82: invokespecial #126                // Method Day20Kt$main$Wrapper."<init>":(J)V
      85: aload         14
      87: swap
      88: invokeinterface #128,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      93: pop
      94: goto          40
      97: aload         5
      99: checkcast     #45                 // class java/util/List
     102: nop
     103: astore_1
     104: aload_1
     105: checkcast     #116                // class java/util/Collection
     108: invokestatic  #132                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     111: astore_2
     112: aload_1
     113: aload_2
     114: invokestatic  #134                // Method main$mix:(Ljava/util/List;Ljava/util/List;)V
     117: aload_2
     118: astore        4
     120: iconst_0
     121: istore        5
     123: iconst_0
     124: istore        6
     126: aload         4
     128: invokeinterface #49,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     133: astore        7
     135: aload         7
     137: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     142: ifeq          193
     145: aload         7
     147: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     152: astore        8
     154: aload         8
     156: checkcast     #61                 // class Day20Kt$main$Wrapper
     159: astore        9
     161: iconst_0
     162: istore        10
     164: aload         9
     166: invokevirtual #73                 // Method Day20Kt$main$Wrapper.getValue:()J
     169: lconst_0
     170: lcmp
     171: ifne          178
     174: iconst_1
     175: goto          179
     178: iconst_0
     179: ifeq          187
     182: iload         6
     184: goto          194
     187: iinc          6, 1
     190: goto          135
     193: iconst_m1
     194: istore_3
     195: iconst_3
     196: anewarray     #136                // class java/lang/Integer
     199: astore        4
     201: aload         4
     203: iconst_0
     204: sipush        1000
     207: invokestatic  #139                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     210: aastore
     211: aload         4
     213: iconst_1
     214: sipush        2000
     217: invokestatic  #139                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     220: aastore
     221: aload         4
     223: iconst_2
     224: sipush        3000
     227: invokestatic  #139                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     230: aastore
     231: aload         4
     233: astore        4
     235: iconst_0
     236: istore        5
     238: aload         4
     240: astore        6
     242: new           #104                // class java/util/ArrayList
     245: dup
     246: aload         4
     248: arraylength
     249: invokespecial #114                // Method java/util/ArrayList."<init>":(I)V
     252: checkcast     #116                // class java/util/Collection
     255: astore        7
     257: iconst_0
     258: istore        8
     260: iconst_0
     261: istore        9
     263: aload         6
     265: arraylength
     266: istore        10
     268: iload         9
     270: iload         10
     272: if_icmpge     340
     275: aload         6
     277: iload         9
     279: aaload
     280: astore        11
     282: aload         7
     284: aload         11
     286: checkcast     #141                // class java/lang/Number
     289: invokevirtual #144                // Method java/lang/Number.intValue:()I
     292: istore        12
     294: astore        14
     296: iconst_0
     297: istore        13
     299: aload_2
     300: iload_3
     301: iload         12
     303: iadd
     304: aload_2
     305: invokeinterface #83,  1           // InterfaceMethod java/util/List.size:()I
     310: irem
     311: invokeinterface #148,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     316: checkcast     #61                 // class Day20Kt$main$Wrapper
     319: invokevirtual #73                 // Method Day20Kt$main$Wrapper.getValue:()J
     322: invokestatic  #14                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     325: aload         14
     327: swap
     328: invokeinterface #128,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     333: pop
     334: iinc          9, 1
     337: goto          268
     340: aload         7
     342: checkcast     #45                 // class java/util/List
     345: nop
     346: checkcast     #102                // class java/lang/Iterable
     349: invokestatic  #152                // Method kotlin/collections/CollectionsKt.sumOfLong:(Ljava/lang/Iterable;)J
     352: lreturn

  private static final long main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #102                // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: astore        4
      10: new           #104                // class java/util/ArrayList
      13: dup
      14: aload_2
      15: bipush        10
      17: invokestatic  #110                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      20: invokespecial #114                // Method java/util/ArrayList."<init>":(I)V
      23: checkcast     #116                // class java/util/Collection
      26: astore        5
      28: iconst_0
      29: istore        6
      31: aload         4
      33: invokeinterface #117,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      38: astore        7
      40: aload         7
      42: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      47: ifeq          101
      50: aload         7
      52: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      57: astore        8
      59: aload         5
      61: aload         8
      63: checkcast     #119                // class java/lang/String
      66: astore        9
      68: astore        14
      70: iconst_0
      71: istore        10
      73: new           #61                 // class Day20Kt$main$Wrapper
      76: dup
      77: aload         9
      79: invokestatic  #123                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
      82: ldc           #177                // int 811589153
      84: i2l
      85: lmul
      86: invokespecial #126                // Method Day20Kt$main$Wrapper."<init>":(J)V
      89: aload         14
      91: swap
      92: invokeinterface #128,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      97: pop
      98: goto          40
     101: aload         5
     103: checkcast     #45                 // class java/util/List
     106: nop
     107: astore_1
     108: aload_1
     109: checkcast     #116                // class java/util/Collection
     112: invokestatic  #132                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     115: astore_2
     116: bipush        10
     118: istore_3
     119: iconst_0
     120: istore        4
     122: iload         4
     124: iload_3
     125: if_icmpge     146
     128: iload         4
     130: istore        5
     132: iconst_0
     133: istore        6
     135: aload_1
     136: aload_2
     137: invokestatic  #134                // Method main$mix:(Ljava/util/List;Ljava/util/List;)V
     140: iinc          4, 1
     143: goto          122
     146: aload_2
     147: astore        4
     149: iconst_0
     150: istore        5
     152: iconst_0
     153: istore        6
     155: aload         4
     157: invokeinterface #49,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     162: astore        7
     164: aload         7
     166: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     171: ifeq          222
     174: aload         7
     176: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     181: astore        8
     183: aload         8
     185: checkcast     #61                 // class Day20Kt$main$Wrapper
     188: astore        9
     190: iconst_0
     191: istore        10
     193: aload         9
     195: invokevirtual #73                 // Method Day20Kt$main$Wrapper.getValue:()J
     198: lconst_0
     199: lcmp
     200: ifne          207
     203: iconst_1
     204: goto          208
     207: iconst_0
     208: ifeq          216
     211: iload         6
     213: goto          223
     216: iinc          6, 1
     219: goto          164
     222: iconst_m1
     223: istore_3
     224: iconst_3
     225: anewarray     #136                // class java/lang/Integer
     228: astore        4
     230: aload         4
     232: iconst_0
     233: sipush        1000
     236: invokestatic  #139                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     239: aastore
     240: aload         4
     242: iconst_1
     243: sipush        2000
     246: invokestatic  #139                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     249: aastore
     250: aload         4
     252: iconst_2
     253: sipush        3000
     256: invokestatic  #139                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     259: aastore
     260: aload         4
     262: astore        4
     264: iconst_0
     265: istore        5
     267: aload         4
     269: astore        6
     271: new           #104                // class java/util/ArrayList
     274: dup
     275: aload         4
     277: arraylength
     278: invokespecial #114                // Method java/util/ArrayList."<init>":(I)V
     281: checkcast     #116                // class java/util/Collection
     284: astore        7
     286: iconst_0
     287: istore        8
     289: iconst_0
     290: istore        9
     292: aload         6
     294: arraylength
     295: istore        10
     297: iload         9
     299: iload         10
     301: if_icmpge     369
     304: aload         6
     306: iload         9
     308: aaload
     309: astore        11
     311: aload         7
     313: aload         11
     315: checkcast     #141                // class java/lang/Number
     318: invokevirtual #144                // Method java/lang/Number.intValue:()I
     321: istore        12
     323: astore        14
     325: iconst_0
     326: istore        13
     328: aload_2
     329: iload_3
     330: iload         12
     332: iadd
     333: aload_2
     334: invokeinterface #83,  1           // InterfaceMethod java/util/List.size:()I
     339: irem
     340: invokeinterface #148,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     345: checkcast     #61                 // class Day20Kt$main$Wrapper
     348: invokevirtual #73                 // Method Day20Kt$main$Wrapper.getValue:()J
     351: invokestatic  #14                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     354: aload         14
     356: swap
     357: invokeinterface #128,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     362: pop
     363: iinc          9, 1
     366: goto          297
     369: aload         7
     371: checkcast     #45                 // class java/util/List
     374: nop
     375: checkcast     #102                // class java/lang/Iterable
     378: invokestatic  #152                // Method kotlin/collections/CollectionsKt.sumOfLong:(Ljava/lang/Iterable;)J
     381: lreturn

  public static final long access$main$part1(java.util.List);
    Code:
       0: aload_0
       1: invokestatic  #184                // Method main$part1:(Ljava/util/List;)J
       4: lreturn

  public static final long access$main$part2(java.util.List);
    Code:
       0: aload_0
       1: invokestatic  #187                // Method main$part2:(Ljava/util/List;)J
       4: lreturn
}

Compiled from "Day20.kt"
public final class Day20Kt$main$Wrapper {
  private final long value;

  public Day20Kt$main$Wrapper(long);
    Code:
       0: aload_0
       1: invokespecial #9                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: lload_1
       6: putfield      #13                 // Field value:J
       9: return

  public final long getValue();
    Code:
       0: aload_0
       1: getfield      #13                 // Field value:J
       4: lreturn
}