import Day23.draw
import Day23.proposeMoves

object Day23 {
    const val EXPECTED_PART1_CHECK_ANSWER = 110
    const val EXPECTED_PART2_CHECK_ANSWER = 20

    sealed interface GridCell
    object Empty : GridCell
    object Elf : GridCell

    class Grid {
        private val rows = mutableListOf<List<GridCell>>()
        var width: Int = 0
            private set
        var height: Int = 0
            private set

        fun addRow(cells: List<Day23.GridCell>) {
            rows += cells
            width = rows.maxOf { it.size }
            height = rows.size
        }

        fun doStep() {

        }
    }

    fun Array<Coordinates>.draw() {
        val fromX = minOf { it.x }
        val toX = maxOf { it.x }
        val fromY = minOf { it.y }
        val toY = maxOf { it.y }
        for (y in fromY..toY) {
            for (x in fromX..toX) {
                if (Coordinates(x, y) in this) {
                    print('#')
                } else {
                    print('.')
                }
            }
            println()
        }
    }

    fun Array<Coordinates>.proposeMoves(
        directions: Array<Direction>,
        directionStartIdx: Int
    ): List<Pair<Coordinates, Coordinates>> = mapNotNull { elf ->
        if (intersect(elf.adjacentPositions().toSet()).isNotEmpty()) {
            var proposedMove: Pair<Coordinates, Coordinates>? = null
            var directionIdx = directionStartIdx
            var directionsDoneCount = 0
            while (proposedMove == null && directionIdx < directions.size && directionsDoneCount++ <= directions.size) {
                if (intersect(elf.adjacentPositions(directions[directionIdx])).isEmpty()) {
                    proposedMove = Pair(elf, elf + directions[directionIdx].move)
                }
                directionIdx = (directionIdx + 1) % directions.size
            }
            proposedMove
        } else {
            null
        }
    }
}

fun main() {

    fun List<String>.parseElfsMap(): Array<Coordinates> = flatMapIndexed { row, line ->
            line.mapIndexedNotNull { col, cell ->
                when (cell) {
                    '.' -> null
                    '#' -> Coordinates(col, row)
                    else -> error("Unknown cell content $cell")
                }
            }
        }.toTypedArray()

    fun part1(input: List<String>, doDraw: Boolean): Int {
        val elfs = input.parseElfsMap()

        if (doDraw) {
            elfs.draw()
            println()
        }

        val directions = arrayOf(Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST)
        var directionStartIdx = 0
        repeat(10) {
            val proposedMoves = elfs.proposeMoves(directions, directionStartIdx)

            val allNewPositions = proposedMoves.map { it.second }
            proposedMoves.forEach { (currentPosition, proposedPosition) ->
                if (allNewPositions.count { it == proposedPosition } == 1) {
                    elfs[elfs.indexOf(currentPosition)] = proposedPosition
                }
            }

            directionStartIdx = (directionStartIdx + 1) % directions.size
            if (doDraw) {
                elfs.draw()
                println()
            }
        }
        val fromX = elfs.minOf { it.x }
        val toX = elfs.maxOf { it.x }
        val fromY = elfs.minOf { it.y }
        val toY = elfs.maxOf { it.y }
        return (fromY..toY).sumOf { y -> (fromX..toX).count { x -> !elfs.contains(Coordinates(x, y)) } }
    }

    fun part2(input: List<String>): Int {
        val elfs = input.parseElfsMap()

        val directions = arrayOf(Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST)
        var directionStartIdx = 0
        var round = 0
        var atLeastOneElfMoved: Boolean
        do {
            atLeastOneElfMoved = false
            val proposedMoves = elfs.proposeMoves(directions, directionStartIdx)

            val allNewPositions = proposedMoves.map { it.second }
            proposedMoves.forEach { (currentPosition, proposedPosition) ->
                if (allNewPositions.count { it == proposedPosition } == 1) {
                    elfs[elfs.indexOf(currentPosition)] = proposedPosition
                    atLeastOneElfMoved = true
                }
            }

            directionStartIdx = (directionStartIdx + 1) % directions.size
            round++
        } while (atLeastOneElfMoved)
        return round
    }

    // test if implementation meets criteria from the description, like:
    val testInput = readInput("Day23_test")
    check(part1(testInput, true) == Day23.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
    check(part2(testInput) == Day23.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }

    val input = readInput("Day23")
    println(part1(input, false))
    println(part2(input))
}

Compiled from "Day23.kt"
public final class Day23Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day23_test
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: iconst_1
       8: invokestatic  #18                 // Method main$part1:(Ljava/util/List;Z)I
      11: bipush        110
      13: if_icmpne     20
      16: iconst_1
      17: goto          21
      20: iconst_0
      21: ifne          41
      24: iconst_0
      25: istore_2
      26: ldc           #20                 // String Part 1 failed
      28: astore_2
      29: new           #22                 // class java/lang/IllegalStateException
      32: dup
      33: aload_2
      34: invokevirtual #26                 // Method java/lang/Object.toString:()Ljava/lang/String;
      37: invokespecial #30                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      40: athrow
      41: aload_0
      42: invokestatic  #34                 // Method main$part2:(Ljava/util/List;)I
      45: bipush        20
      47: if_icmpne     54
      50: iconst_1
      51: goto          55
      54: iconst_0
      55: ifne          75
      58: iconst_0
      59: istore_2
      60: ldc           #36                 // String Part 2 failed
      62: astore_2
      63: new           #22                 // class java/lang/IllegalStateException
      66: dup
      67: aload_2
      68: invokevirtual #26                 // Method java/lang/Object.toString:()Ljava/lang/String;
      71: invokespecial #30                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      74: athrow
      75: ldc           #38                 // String Day23
      77: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      80: astore_1
      81: aload_1
      82: iconst_0
      83: invokestatic  #18                 // Method main$part1:(Ljava/util/List;Z)I
      86: istore_2
      87: getstatic     #44                 // Field java/lang/System.out:Ljava/io/PrintStream;
      90: iload_2
      91: invokevirtual #50                 // Method java/io/PrintStream.println:(I)V
      94: aload_1
      95: invokestatic  #34                 // Method main$part2:(Ljava/util/List;)I
      98: istore_2
      99: getstatic     #44                 // Field java/lang/System.out:Ljava/io/PrintStream;
     102: iload_2
     103: invokevirtual #50                 // Method java/io/PrintStream.println:(I)V
     106: return

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

  private static final Coordinates[] main$parseElfsMap(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #68                 // class java/lang/Iterable
       4: astore_2
       5: new           #70                 // class java/util/ArrayList
       8: dup
       9: invokespecial #72                 // Method java/util/ArrayList."<init>":()V
      12: checkcast     #74                 // class java/util/Collection
      15: astore_3
      16: iconst_0
      17: istore        4
      19: aload_2
      20: invokeinterface #78,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      25: astore        5
      27: aload         5
      29: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      34: ifeq          292
      37: aload         5
      39: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      44: astore        6
      46: iload         4
      48: iinc          4, 1
      51: istore        7
      53: iload         7
      55: ifge          61
      58: invokestatic  #93                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      61: iload         7
      63: aload         6
      65: checkcast     #95                 // class java/lang/String
      68: astore        8
      70: istore        9
      72: iconst_0
      73: istore        10
      75: aload         8
      77: checkcast     #97                 // class java/lang/CharSequence
      80: astore        11
      82: iconst_0
      83: istore        12
      85: aload         11
      87: astore        13
      89: new           #70                 // class java/util/ArrayList
      92: dup
      93: invokespecial #72                 // Method java/util/ArrayList."<init>":()V
      96: checkcast     #74                 // class java/util/Collection
      99: astore        14
     101: iconst_0
     102: istore        15
     104: aload         13
     106: astore        16
     108: iconst_0
     109: istore        17
     111: iconst_0
     112: istore        18
     114: iconst_0
     115: istore        19
     117: iload         19
     119: aload         16
     121: invokeinterface #101,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     126: if_icmpge     272
     129: aload         16
     131: iload         19
     133: invokeinterface #105,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     138: istore        20
     140: iload         18
     142: iinc          18, 1
     145: iload         20
     147: istore        21
     149: istore        22
     151: iconst_0
     152: istore        23
     154: iload         22
     156: iload         21
     158: istore        24
     160: istore        25
     162: iconst_0
     163: istore        26
     165: iload         24
     167: lookupswitch  { // 2
                    35: 196
                    46: 192
               default: 210
          }
     192: aconst_null
     193: goto          241
     196: new           #107                // class Coordinates
     199: dup
     200: iload         25
     202: iload         9
     204: invokespecial #110                // Method Coordinates."<init>":(II)V
     207: goto          241
     210: new           #22                 // class java/lang/IllegalStateException
     213: dup
     214: new           #112                // class java/lang/StringBuilder
     217: dup
     218: invokespecial #113                // Method java/lang/StringBuilder."<init>":()V
     221: ldc           #115                // String Unknown cell content
     223: invokevirtual #119                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     226: iload         24
     228: invokevirtual #122                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     231: invokevirtual #123                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     234: invokevirtual #26                 // Method java/lang/Object.toString:()Ljava/lang/String;
     237: invokespecial #30                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     240: athrow
     241: nop
     242: dup
     243: ifnull        264
     246: astore        27
     248: iconst_0
     249: istore        28
     251: aload         14
     253: aload         27
     255: invokeinterface #127,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     260: pop
     261: goto          265
     264: pop
     265: nop
     266: iinc          19, 1
     269: goto          117
     272: nop
     273: aload         14
     275: checkcast     #58                 // class java/util/List
     278: nop
     279: checkcast     #68                 // class java/lang/Iterable
     282: nop
     283: aload_3
     284: swap
     285: invokestatic  #131                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     288: pop
     289: goto          27
     292: aload_3
     293: checkcast     #58                 // class java/util/List
     296: checkcast     #74                 // class java/util/Collection
     299: astore_1
     300: nop
     301: iconst_0
     302: istore_2
     303: aload_1
     304: astore_3
     305: aload_3
     306: iconst_0
     307: anewarray     #107                // class Coordinates
     310: invokeinterface #135,  2          // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;
     315: checkcast     #137                // class "[LCoordinates;"
     318: areturn

  private static final int main$part1(java.util.List<java.lang.String>, boolean);
    Code:
       0: aload_0
       1: invokestatic  #169                // Method main$parseElfsMap:(Ljava/util/List;)[LCoordinates;
       4: astore_2
       5: iload_1
       6: ifeq          22
       9: getstatic     #174                // Field Day23.INSTANCE:LDay23;
      12: aload_2
      13: invokevirtual #178                // Method Day23.draw:([LCoordinates;)V
      16: getstatic     #44                 // Field java/lang/System.out:Ljava/io/PrintStream;
      19: invokevirtual #180                // Method java/io/PrintStream.println:()V
      22: iconst_4
      23: anewarray     #182                // class Direction
      26: astore        4
      28: aload         4
      30: iconst_0
      31: getstatic     #186                // Field Direction.NORTH:LDirection;
      34: aastore
      35: aload         4
      37: iconst_1
      38: getstatic     #189                // Field Direction.SOUTH:LDirection;
      41: aastore
      42: aload         4
      44: iconst_2
      45: getstatic     #192                // Field Direction.WEST:LDirection;
      48: aastore
      49: aload         4
      51: iconst_3
      52: getstatic     #195                // Field Direction.EAST:LDirection;
      55: aastore
      56: aload         4
      58: astore_3
      59: iconst_0
      60: istore        4
      62: bipush        10
      64: istore        5
      66: iconst_0
      67: istore        6
      69: iload         6
      71: iload         5
      73: if_icmpge     424
      76: iload         6
      78: istore        7
      80: iconst_0
      81: istore        8
      83: getstatic     #174                // Field Day23.INSTANCE:LDay23;
      86: aload_2
      87: aload_3
      88: iload         4
      90: invokevirtual #199                // Method Day23.proposeMoves:([LCoordinates;[LDirection;I)Ljava/util/List;
      93: astore        9
      95: aload         9
      97: checkcast     #68                 // class java/lang/Iterable
     100: astore        10
     102: iconst_0
     103: istore        11
     105: aload         10
     107: astore        12
     109: new           #70                 // class java/util/ArrayList
     112: dup
     113: aload         10
     115: bipush        10
     117: invokestatic  #203                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     120: invokespecial #205                // Method java/util/ArrayList."<init>":(I)V
     123: checkcast     #74                 // class java/util/Collection
     126: astore        13
     128: iconst_0
     129: istore        14
     131: aload         12
     133: invokeinterface #78,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     138: astore        15
     140: aload         15
     142: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     147: ifeq          193
     150: aload         15
     152: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     157: astore        16
     159: aload         13
     161: aload         16
     163: checkcast     #207                // class kotlin/Pair
     166: astore        17
     168: astore        18
     170: iconst_0
     171: istore        19
     173: aload         17
     175: invokevirtual #210                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     178: checkcast     #107                // class Coordinates
     181: aload         18
     183: swap
     184: invokeinterface #127,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     189: pop
     190: goto          140
     193: aload         13
     195: checkcast     #58                 // class java/util/List
     198: nop
     199: astore        20
     201: aload         9
     203: checkcast     #68                 // class java/lang/Iterable
     206: astore        10
     208: iconst_0
     209: istore        11
     211: aload         10
     213: invokeinterface #78,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     218: astore        12
     220: aload         12
     222: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     227: ifeq          390
     230: aload         12
     232: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     237: astore        13
     239: aload         13
     241: checkcast     #207                // class kotlin/Pair
     244: astore        14
     246: iconst_0
     247: istore        15
     249: aload         14
     251: invokevirtual #213                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     254: checkcast     #107                // class Coordinates
     257: astore        16
     259: aload         14
     261: invokevirtual #216                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     264: checkcast     #107                // class Coordinates
     267: astore        17
     269: aload         20
     271: checkcast     #68                 // class java/lang/Iterable
     274: astore        19
     276: iconst_0
     277: istore        21
     279: aload         19
     281: instanceof    #74                 // class java/util/Collection
     284: ifeq          304
     287: aload         19
     289: checkcast     #74                 // class java/util/Collection
     292: invokeinterface #219,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     297: ifeq          304
     300: iconst_0
     301: goto          371
     304: iconst_0
     305: istore        22
     307: aload         19
     309: invokeinterface #78,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     314: astore        23
     316: aload         23
     318: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     323: ifeq          369
     326: aload         23
     328: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     333: astore        24
     335: aload         24
     337: checkcast     #107                // class Coordinates
     340: astore        25
     342: iconst_0
     343: istore        26
     345: aload         25
     347: aload         17
     349: invokestatic  #225                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     352: ifeq          316
     355: iinc          22, 1
     358: iload         22
     360: ifge          316
     363: invokestatic  #228                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     366: goto          316
     369: iload         22
     371: iconst_1
     372: if_icmpne     385
     375: aload_2
     376: aload_2
     377: aload         16
     379: invokestatic  #234                // Method kotlin/collections/ArraysKt.indexOf:([Ljava/lang/Object;Ljava/lang/Object;)I
     382: aload         17
     384: aastore
     385: nop
     386: nop
     387: goto          220
     390: nop
     391: iload         4
     393: iconst_1
     394: iadd
     395: aload_3
     396: arraylength
     397: irem
     398: istore        4
     400: iload_1
     401: ifeq          417
     404: getstatic     #174                // Field Day23.INSTANCE:LDay23;
     407: aload_2
     408: invokevirtual #178                // Method Day23.draw:([LCoordinates;)V
     411: getstatic     #44                 // Field java/lang/System.out:Ljava/io/PrintStream;
     414: invokevirtual #180                // Method java/io/PrintStream.println:()V
     417: nop
     418: iinc          6, 1
     421: goto          69
     424: aload_2
     425: astore        6
     427: aload         6
     429: arraylength
     430: ifne          437
     433: iconst_1
     434: goto          438
     437: iconst_0
     438: ifeq          449
     441: new           #236                // class java/util/NoSuchElementException
     444: dup
     445: invokespecial #237                // Method java/util/NoSuchElementException."<init>":()V
     448: athrow
     449: aload         6
     451: iconst_0
     452: aaload
     453: astore        7
     455: iconst_0
     456: istore        8
     458: aload         7
     460: invokevirtual #240                // Method Coordinates.getX:()I
     463: istore        7
     465: iconst_1
     466: istore        8
     468: aload         6
     470: invokestatic  #244                // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I
     473: istore        9
     475: iload         8
     477: iload         9
     479: if_icmpgt     523
     482: aload         6
     484: iload         8
     486: aaload
     487: astore        10
     489: iconst_0
     490: istore        11
     492: aload         10
     494: invokevirtual #240                // Method Coordinates.getX:()I
     497: istore        10
     499: iload         7
     501: iload         10
     503: if_icmple     510
     506: iload         10
     508: istore        7
     510: iload         8
     512: iload         9
     514: if_icmpeq     523
     517: iinc          8, 1
     520: goto          482
     523: iload         7
     525: istore        5
     527: aload_2
     528: astore        7
     530: aload         7
     532: arraylength
     533: ifne          540
     536: iconst_1
     537: goto          541
     540: iconst_0
     541: ifeq          552
     544: new           #236                // class java/util/NoSuchElementException
     547: dup
     548: invokespecial #237                // Method java/util/NoSuchElementException."<init>":()V
     551: athrow
     552: aload         7
     554: iconst_0
     555: aaload
     556: astore        8
     558: iconst_0
     559: istore        9
     561: aload         8
     563: invokevirtual #240                // Method Coordinates.getX:()I
     566: istore        8
     568: iconst_1
     569: istore        9
     571: aload         7
     573: invokestatic  #244                // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I
     576: istore        10
     578: iload         9
     580: iload         10
     582: if_icmpgt     626
     585: aload         7
     587: iload         9
     589: aaload
     590: astore        11
     592: iconst_0
     593: istore        12
     595: aload         11
     597: invokevirtual #240                // Method Coordinates.getX:()I
     600: istore        11
     602: iload         8
     604: iload         11
     606: if_icmpge     613
     609: iload         11
     611: istore        8
     613: iload         9
     615: iload         10
     617: if_icmpeq     626
     620: iinc          9, 1
     623: goto          585
     626: iload         8
     628: istore        6
     630: aload_2
     631: astore        8
     633: aload         8
     635: arraylength
     636: ifne          643
     639: iconst_1
     640: goto          644
     643: iconst_0
     644: ifeq          655
     647: new           #236                // class java/util/NoSuchElementException
     650: dup
     651: invokespecial #237                // Method java/util/NoSuchElementException."<init>":()V
     654: athrow
     655: aload         8
     657: iconst_0
     658: aaload
     659: astore        9
     661: iconst_0
     662: istore        10
     664: aload         9
     666: invokevirtual #247                // Method Coordinates.getY:()I
     669: istore        9
     671: iconst_1
     672: istore        10
     674: aload         8
     676: invokestatic  #244                // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I
     679: istore        11
     681: iload         10
     683: iload         11
     685: if_icmpgt     729
     688: aload         8
     690: iload         10
     692: aaload
     693: astore        12
     695: iconst_0
     696: istore        13
     698: aload         12
     700: invokevirtual #247                // Method Coordinates.getY:()I
     703: istore        12
     705: iload         9
     707: iload         12
     709: if_icmple     716
     712: iload         12
     714: istore        9
     716: iload         10
     718: iload         11
     720: if_icmpeq     729
     723: iinc          10, 1
     726: goto          688
     729: iload         9
     731: istore        7
     733: aload_2
     734: astore        9
     736: aload         9
     738: arraylength
     739: ifne          746
     742: iconst_1
     743: goto          747
     746: iconst_0
     747: ifeq          758
     750: new           #236                // class java/util/NoSuchElementException
     753: dup
     754: invokespecial #237                // Method java/util/NoSuchElementException."<init>":()V
     757: athrow
     758: aload         9
     760: iconst_0
     761: aaload
     762: astore        10
     764: iconst_0
     765: istore        11
     767: aload         10
     769: invokevirtual #247                // Method Coordinates.getY:()I
     772: istore        10
     774: iconst_1
     775: istore        11
     777: aload         9
     779: invokestatic  #244                // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I
     782: istore        12
     784: iload         11
     786: iload         12
     788: if_icmpgt     832
     791: aload         9
     793: iload         11
     795: aaload
     796: astore        13
     798: iconst_0
     799: istore        14
     801: aload         13
     803: invokevirtual #247                // Method Coordinates.getY:()I
     806: istore        13
     808: iload         10
     810: iload         13
     812: if_icmpge     819
     815: iload         13
     817: istore        10
     819: iload         11
     821: iload         12
     823: if_icmpeq     832
     826: iinc          11, 1
     829: goto          791
     832: iload         10
     834: istore        8
     836: new           #249                // class kotlin/ranges/IntRange
     839: dup
     840: iload         7
     842: iload         8
     844: invokespecial #250                // Method kotlin/ranges/IntRange."<init>":(II)V
     847: checkcast     #68                 // class java/lang/Iterable
     850: astore        9
     852: iconst_0
     853: istore        10
     855: aload         9
     857: invokeinterface #78,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     862: astore        11
     864: aload         11
     866: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     871: ifeq          1033
     874: aload         11
     876: checkcast     #252                // class kotlin/collections/IntIterator
     879: invokevirtual #255                // Method kotlin/collections/IntIterator.nextInt:()I
     882: istore        12
     884: iload         10
     886: iload         12
     888: istore        13
     890: istore        27
     892: iconst_0
     893: istore        14
     895: new           #249                // class kotlin/ranges/IntRange
     898: dup
     899: iload         5
     901: iload         6
     903: invokespecial #250                // Method kotlin/ranges/IntRange."<init>":(II)V
     906: checkcast     #68                 // class java/lang/Iterable
     909: astore        15
     911: iconst_0
     912: istore        16
     914: aload         15
     916: instanceof    #74                 // class java/util/Collection
     919: ifeq          939
     922: aload         15
     924: checkcast     #74                 // class java/util/Collection
     927: invokeinterface #219,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     932: ifeq          939
     935: iconst_0
     936: goto          1020
     939: iconst_0
     940: istore        17
     942: aload         15
     944: invokeinterface #78,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     949: astore        18
     951: aload         18
     953: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     958: ifeq          1018
     961: aload         18
     963: checkcast     #252                // class kotlin/collections/IntIterator
     966: invokevirtual #255                // Method kotlin/collections/IntIterator.nextInt:()I
     969: istore        19
     971: iload         19
     973: istore        20
     975: iconst_0
     976: istore        21
     978: aload_2
     979: new           #107                // class Coordinates
     982: dup
     983: iload         20
     985: iload         13
     987: invokespecial #110                // Method Coordinates."<init>":(II)V
     990: invokestatic  #259                // Method kotlin/collections/ArraysKt.contains:([Ljava/lang/Object;Ljava/lang/Object;)Z
     993: ifne          1000
     996: iconst_1
     997: goto          1001
    1000: iconst_0
    1001: ifeq          951
    1004: iinc          17, 1
    1007: iload         17
    1009: ifge          951
    1012: invokestatic  #228                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
    1015: goto          951
    1018: iload         17
    1020: nop
    1021: istore        28
    1023: iload         27
    1025: iload         28
    1027: iadd
    1028: istore        10
    1030: goto          864
    1033: iload         10
    1035: ireturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #169                // Method main$parseElfsMap:(Ljava/util/List;)[LCoordinates;
       4: astore_1
       5: iconst_4
       6: anewarray     #182                // class Direction
       9: astore_3
      10: aload_3
      11: iconst_0
      12: getstatic     #186                // Field Direction.NORTH:LDirection;
      15: aastore
      16: aload_3
      17: iconst_1
      18: getstatic     #189                // Field Direction.SOUTH:LDirection;
      21: aastore
      22: aload_3
      23: iconst_2
      24: getstatic     #192                // Field Direction.WEST:LDirection;
      27: aastore
      28: aload_3
      29: iconst_3
      30: getstatic     #195                // Field Direction.EAST:LDirection;
      33: aastore
      34: aload_3
      35: astore_2
      36: iconst_0
      37: istore_3
      38: iconst_0
      39: istore        4
      41: iconst_0
      42: istore        5
      44: iconst_0
      45: istore        5
      47: getstatic     #174                // Field Day23.INSTANCE:LDay23;
      50: aload_1
      51: aload_2
      52: iload_3
      53: invokevirtual #199                // Method Day23.proposeMoves:([LCoordinates;[LDirection;I)Ljava/util/List;
      56: astore        6
      58: aload         6
      60: checkcast     #68                 // class java/lang/Iterable
      63: astore        8
      65: iconst_0
      66: istore        9
      68: aload         8
      70: astore        10
      72: new           #70                 // class java/util/ArrayList
      75: dup
      76: aload         8
      78: bipush        10
      80: invokestatic  #203                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      83: invokespecial #205                // Method java/util/ArrayList."<init>":(I)V
      86: checkcast     #74                 // class java/util/Collection
      89: astore        11
      91: iconst_0
      92: istore        12
      94: aload         10
      96: invokeinterface #78,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     101: astore        13
     103: aload         13
     105: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     110: ifeq          156
     113: aload         13
     115: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     120: astore        14
     122: aload         11
     124: aload         14
     126: checkcast     #207                // class kotlin/Pair
     129: astore        15
     131: astore        23
     133: iconst_0
     134: istore        16
     136: aload         15
     138: invokevirtual #210                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     141: checkcast     #107                // class Coordinates
     144: aload         23
     146: swap
     147: invokeinterface #127,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     152: pop
     153: goto          103
     156: aload         11
     158: checkcast     #58                 // class java/util/List
     161: nop
     162: astore        7
     164: aload         6
     166: checkcast     #68                 // class java/lang/Iterable
     169: astore        8
     171: iconst_0
     172: istore        9
     174: aload         8
     176: invokeinterface #78,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     181: astore        10
     183: aload         10
     185: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     190: ifeq          356
     193: aload         10
     195: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     200: astore        11
     202: aload         11
     204: checkcast     #207                // class kotlin/Pair
     207: astore        12
     209: iconst_0
     210: istore        13
     212: aload         12
     214: invokevirtual #213                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     217: checkcast     #107                // class Coordinates
     220: astore        14
     222: aload         12
     224: invokevirtual #216                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     227: checkcast     #107                // class Coordinates
     230: astore        15
     232: aload         7
     234: checkcast     #68                 // class java/lang/Iterable
     237: astore        16
     239: iconst_0
     240: istore        17
     242: aload         16
     244: instanceof    #74                 // class java/util/Collection
     247: ifeq          267
     250: aload         16
     252: checkcast     #74                 // class java/util/Collection
     255: invokeinterface #219,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     260: ifeq          267
     263: iconst_0
     264: goto          334
     267: iconst_0
     268: istore        18
     270: aload         16
     272: invokeinterface #78,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     277: astore        19
     279: aload         19
     281: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     286: ifeq          332
     289: aload         19
     291: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     296: astore        20
     298: aload         20
     300: checkcast     #107                // class Coordinates
     303: astore        21
     305: iconst_0
     306: istore        22
     308: aload         21
     310: aload         15
     312: invokestatic  #225                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     315: ifeq          279
     318: iinc          18, 1
     321: iload         18
     323: ifge          279
     326: invokestatic  #228                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     329: goto          279
     332: iload         18
     334: iconst_1
     335: if_icmpne     351
     338: aload_1
     339: aload_1
     340: aload         14
     342: invokestatic  #234                // Method kotlin/collections/ArraysKt.indexOf:([Ljava/lang/Object;Ljava/lang/Object;)I
     345: aload         15
     347: aastore
     348: iconst_1
     349: istore        5
     351: nop
     352: nop
     353: goto          183
     356: nop
     357: iload_3
     358: iconst_1
     359: iadd
     360: aload_2
     361: arraylength
     362: irem
     363: istore_3
     364: iinc          4, 1
     367: iload         5
     369: ifne          44
     372: iload         4
     374: ireturn
}

Compiled from "Day23.kt"
public final class Day23$Elf implements Day23$GridCell {
  public static final Day23$Elf INSTANCE;

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

  static {};
    Code:
       0: new           #2                  // class Day23$Elf
       3: dup
       4: invokespecial #14                 // Method "<init>":()V
       7: putstatic     #17                 // Field INSTANCE:LDay23$Elf;
      10: return
}

Compiled from "Day23.kt"
public interface Day23$GridCell {
}

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

  public static final int EXPECTED_PART1_CHECK_ANSWER;

  public static final int EXPECTED_PART2_CHECK_ANSWER;

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

  public final void draw(Coordinates[]);
    Code:
       0: aload_1
       1: ldc           #15                 // String <this>
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: astore_3
       8: aload_3
       9: arraylength
      10: ifne          17
      13: iconst_1
      14: goto          18
      17: iconst_0
      18: ifeq          29
      21: new           #23                 // class java/util/NoSuchElementException
      24: dup
      25: invokespecial #24                 // Method java/util/NoSuchElementException."<init>":()V
      28: athrow
      29: aload_3
      30: iconst_0
      31: aaload
      32: astore        4
      34: iconst_0
      35: istore        5
      37: aload         4
      39: invokevirtual #30                 // Method Coordinates.getX:()I
      42: istore        4
      44: iconst_1
      45: istore        5
      47: aload_3
      48: invokestatic  #36                 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I
      51: istore        6
      53: iload         5
      55: iload         6
      57: if_icmpgt     100
      60: aload_3
      61: iload         5
      63: aaload
      64: astore        7
      66: iconst_0
      67: istore        8
      69: aload         7
      71: invokevirtual #30                 // Method Coordinates.getX:()I
      74: istore        7
      76: iload         4
      78: iload         7
      80: if_icmple     87
      83: iload         7
      85: istore        4
      87: iload         5
      89: iload         6
      91: if_icmpeq     100
      94: iinc          5, 1
      97: goto          60
     100: iload         4
     102: istore_2
     103: aload_1
     104: astore        4
     106: aload         4
     108: arraylength
     109: ifne          116
     112: iconst_1
     113: goto          117
     116: iconst_0
     117: ifeq          128
     120: new           #23                 // class java/util/NoSuchElementException
     123: dup
     124: invokespecial #24                 // Method java/util/NoSuchElementException."<init>":()V
     127: athrow
     128: aload         4
     130: iconst_0
     131: aaload
     132: astore        5
     134: iconst_0
     135: istore        6
     137: aload         5
     139: invokevirtual #30                 // Method Coordinates.getX:()I
     142: istore        5
     144: iconst_1
     145: istore        6
     147: aload         4
     149: invokestatic  #36                 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I
     152: istore        7
     154: iload         6
     156: iload         7
     158: if_icmpgt     202
     161: aload         4
     163: iload         6
     165: aaload
     166: astore        8
     168: iconst_0
     169: istore        9
     171: aload         8
     173: invokevirtual #30                 // Method Coordinates.getX:()I
     176: istore        8
     178: iload         5
     180: iload         8
     182: if_icmpge     189
     185: iload         8
     187: istore        5
     189: iload         6
     191: iload         7
     193: if_icmpeq     202
     196: iinc          6, 1
     199: goto          161
     202: iload         5
     204: istore_3
     205: aload_1
     206: astore        5
     208: aload         5
     210: arraylength
     211: ifne          218
     214: iconst_1
     215: goto          219
     218: iconst_0
     219: ifeq          230
     222: new           #23                 // class java/util/NoSuchElementException
     225: dup
     226: invokespecial #24                 // Method java/util/NoSuchElementException."<init>":()V
     229: athrow
     230: aload         5
     232: iconst_0
     233: aaload
     234: astore        6
     236: iconst_0
     237: istore        7
     239: aload         6
     241: invokevirtual #39                 // Method Coordinates.getY:()I
     244: istore        6
     246: iconst_1
     247: istore        7
     249: aload         5
     251: invokestatic  #36                 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I
     254: istore        8
     256: iload         7
     258: iload         8
     260: if_icmpgt     304
     263: aload         5
     265: iload         7
     267: aaload
     268: astore        9
     270: iconst_0
     271: istore        10
     273: aload         9
     275: invokevirtual #39                 // Method Coordinates.getY:()I
     278: istore        9
     280: iload         6
     282: iload         9
     284: if_icmple     291
     287: iload         9
     289: istore        6
     291: iload         7
     293: iload         8
     295: if_icmpeq     304
     298: iinc          7, 1
     301: goto          263
     304: iload         6
     306: istore        4
     308: aload_1
     309: astore        6
     311: aload         6
     313: arraylength
     314: ifne          321
     317: iconst_1
     318: goto          322
     321: iconst_0
     322: ifeq          333
     325: new           #23                 // class java/util/NoSuchElementException
     328: dup
     329: invokespecial #24                 // Method java/util/NoSuchElementException."<init>":()V
     332: athrow
     333: aload         6
     335: iconst_0
     336: aaload
     337: astore        7
     339: iconst_0
     340: istore        8
     342: aload         7
     344: invokevirtual #39                 // Method Coordinates.getY:()I
     347: istore        7
     349: iconst_1
     350: istore        8
     352: aload         6
     354: invokestatic  #36                 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I
     357: istore        9
     359: iload         8
     361: iload         9
     363: if_icmpgt     407
     366: aload         6
     368: iload         8
     370: aaload
     371: astore        10
     373: iconst_0
     374: istore        11
     376: aload         10
     378: invokevirtual #39                 // Method Coordinates.getY:()I
     381: istore        10
     383: iload         7
     385: iload         10
     387: if_icmpge     394
     390: iload         10
     392: istore        7
     394: iload         8
     396: iload         9
     398: if_icmpeq     407
     401: iinc          8, 1
     404: goto          366
     407: iload         7
     409: istore        5
     411: iload         4
     413: istore        6
     415: iload         6
     417: iload         5
     419: if_icmpgt     507
     422: iload_2
     423: istore        7
     425: iload         7
     427: iload_3
     428: if_icmpgt     488
     431: aload_1
     432: new           #26                 // class Coordinates
     435: dup
     436: iload         7
     438: iload         6
     440: invokespecial #42                 // Method Coordinates."<init>":(II)V
     443: invokestatic  #46                 // Method kotlin/collections/ArraysKt.contains:([Ljava/lang/Object;Ljava/lang/Object;)Z
     446: ifeq          464
     449: bipush        35
     451: istore        8
     453: getstatic     #52                 // Field java/lang/System.out:Ljava/io/PrintStream;
     456: iload         8
     458: invokevirtual #58                 // Method java/io/PrintStream.print:(C)V
     461: goto          476
     464: bipush        46
     466: istore        8
     468: getstatic     #52                 // Field java/lang/System.out:Ljava/io/PrintStream;
     471: iload         8
     473: invokevirtual #58                 // Method java/io/PrintStream.print:(C)V
     476: iload         7
     478: iload_3
     479: if_icmpeq     488
     482: iinc          7, 1
     485: goto          431
     488: getstatic     #52                 // Field java/lang/System.out:Ljava/io/PrintStream;
     491: invokevirtual #61                 // Method java/io/PrintStream.println:()V
     494: iload         6
     496: iload         5
     498: if_icmpeq     507
     501: iinc          6, 1
     504: goto          422
     507: return

  public final java.util.List<kotlin.Pair<Coordinates, Coordinates>> proposeMoves(Coordinates[], Direction[], int);
    Code:
       0: aload_1
       1: ldc           #15                 // String <this>
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #82                 // String directions
       9: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: astore        4
      15: iconst_0
      16: istore        5
      18: aload         4
      20: astore        6
      22: new           #84                 // class java/util/ArrayList
      25: dup
      26: invokespecial #85                 // Method java/util/ArrayList."<init>":()V
      29: checkcast     #87                 // class java/util/Collection
      32: astore        7
      34: iconst_0
      35: istore        8
      37: aload         6
      39: astore        9
      41: iconst_0
      42: istore        10
      44: iconst_0
      45: istore        11
      47: aload         9
      49: arraylength
      50: istore        12
      52: iload         11
      54: iload         12
      56: if_icmpge     250
      59: aload         9
      61: iload         11
      63: aaload
      64: astore        13
      66: aload         13
      68: astore        14
      70: iconst_0
      71: istore        15
      73: aload         14
      75: astore        16
      77: iconst_0
      78: istore        17
      80: aload_1
      81: aload         16
      83: iconst_0
      84: iconst_1
      85: aconst_null
      86: invokestatic  #91                 // Method Coordinates.adjacentPositions$default:(LCoordinates;ZILjava/lang/Object;)Ljava/util/Set;
      89: checkcast     #93                 // class java/lang/Iterable
      92: invokestatic  #99                 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
      95: checkcast     #93                 // class java/lang/Iterable
      98: invokestatic  #103                // Method kotlin/collections/ArraysKt.intersect:([Ljava/lang/Object;Ljava/lang/Iterable;)Ljava/util/Set;
     101: checkcast     #87                 // class java/util/Collection
     104: invokeinterface #107,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     109: ifne          116
     112: iconst_1
     113: goto          117
     116: iconst_0
     117: ifeq          218
     120: aconst_null
     121: astore        18
     123: iload_3
     124: istore        19
     126: iconst_0
     127: istore        20
     129: aload         18
     131: ifnonnull     213
     134: iload         19
     136: aload_2
     137: arraylength
     138: if_icmpge     213
     141: iload         20
     143: iinc          20, 1
     146: aload_2
     147: arraylength
     148: if_icmpgt     213
     151: aload_1
     152: aload         16
     154: aload_2
     155: iload         19
     157: aaload
     158: iconst_0
     159: iconst_2
     160: aconst_null
     161: invokestatic  #110                // Method Coordinates.adjacentPositions$default:(LCoordinates;LDirection;ZILjava/lang/Object;)Ljava/util/Set;
     164: checkcast     #93                 // class java/lang/Iterable
     167: invokestatic  #103                // Method kotlin/collections/ArraysKt.intersect:([Ljava/lang/Object;Ljava/lang/Iterable;)Ljava/util/Set;
     170: invokeinterface #113,  1          // InterfaceMethod java/util/Set.isEmpty:()Z
     175: ifeq          201
     178: new           #115                // class kotlin/Pair
     181: dup
     182: aload         16
     184: aload         16
     186: aload_2
     187: iload         19
     189: aaload
     190: invokevirtual #121                // Method Direction.getMove:()LCoordinates;
     193: invokevirtual #125                // Method Coordinates.plus:(LCoordinates;)LCoordinates;
     196: invokespecial #128                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     199: astore        18
     201: iload         19
     203: iconst_1
     204: iadd
     205: aload_2
     206: arraylength
     207: irem
     208: istore        19
     210: goto          129
     213: aload         18
     215: goto          219
     218: aconst_null
     219: nop
     220: dup
     221: ifnull        242
     224: astore        21
     226: iconst_0
     227: istore        22
     229: aload         7
     231: aload         21
     233: invokeinterface #132,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     238: pop
     239: goto          243
     242: pop
     243: nop
     244: iinc          11, 1
     247: goto          52
     250: nop
     251: aload         7
     253: checkcast     #134                // class java/util/List
     256: nop
     257: areturn

  static {};
    Code:
       0: new           #2                  // class Day23
       3: dup
       4: invokespecial #161                // Method "<init>":()V
       7: putstatic     #164                // Field INSTANCE:LDay23;
      10: return
}

Compiled from "Day23.kt"
public final class Day23$Empty implements Day23$GridCell {
  public static final Day23$Empty INSTANCE;

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

  static {};
    Code:
       0: new           #2                  // class Day23$Empty
       3: dup
       4: invokespecial #14                 // Method "<init>":()V
       7: putstatic     #17                 // Field INSTANCE:LDay23$Empty;
      10: return
}

Compiled from "Day23.kt"
public final class Day23$Grid {
  private final java.util.List<java.util.List<Day23$GridCell>> rows;

  private int width;

  private int height;

  public Day23$Grid();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: new           #10                 // class java/util/ArrayList
       8: dup
       9: invokespecial #11                 // Method java/util/ArrayList."<init>":()V
      12: checkcast     #13                 // class java/util/List
      15: putfield      #17                 // Field rows:Ljava/util/List;
      18: return

  public final int getWidth();
    Code:
       0: aload_0
       1: getfield      #25                 // Field width:I
       4: ireturn

  public final int getHeight();
    Code:
       0: aload_0
       1: getfield      #29                 // Field height:I
       4: ireturn

  public final void addRow(java.util.List<? extends Day23$GridCell>);
    Code:
       0: aload_1
       1: ldc           #35                 // String cells
       3: invokestatic  #41                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: getfield      #17                 // Field rows:Ljava/util/List;
      10: checkcast     #43                 // class java/util/Collection
      13: aload_1
      14: invokeinterface #47,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      19: pop
      20: aload_0
      21: aload_0
      22: getfield      #17                 // Field rows:Ljava/util/List;
      25: checkcast     #49                 // class java/lang/Iterable
      28: astore_2
      29: astore        7
      31: aload_2
      32: invokeinterface #53,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore_3
      38: aload_3
      39: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      44: ifne          55
      47: new           #61                 // class java/util/NoSuchElementException
      50: dup
      51: invokespecial #62                 // Method java/util/NoSuchElementException."<init>":()V
      54: athrow
      55: aload_3
      56: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: checkcast     #13                 // class java/util/List
      64: astore        4
      66: iconst_0
      67: istore        5
      69: aload         4
      71: invokeinterface #69,  1           // InterfaceMethod java/util/List.size:()I
      76: istore        4
      78: aload_3
      79: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      84: ifeq          124
      87: aload_3
      88: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      93: checkcast     #13                 // class java/util/List
      96: astore        5
      98: iconst_0
      99: istore        6
     101: aload         5
     103: invokeinterface #69,  1           // InterfaceMethod java/util/List.size:()I
     108: istore        5
     110: iload         4
     112: iload         5
     114: if_icmpge     78
     117: iload         5
     119: istore        4
     121: goto          78
     124: iload         4
     126: istore        8
     128: aload         7
     130: iload         8
     132: putfield      #25                 // Field width:I
     135: aload_0
     136: aload_0
     137: getfield      #17                 // Field rows:Ljava/util/List;
     140: invokeinterface #69,  1           // InterfaceMethod java/util/List.size:()I
     145: putfield      #29                 // Field height:I
     148: return

  public final void doStep();
    Code:
       0: return
}


object Day13 {
    const val EXPECTED_PART1_CHECK_ANSWER = 13
    const val EXPECTED_PART2_CHECK_ANSWER = 140

    const val PACKET_COMBOS_NR_OF_LINES = 3
    val NONE_NUMBER_CHARS = listOf('[', ']', ',')
    const val DIVIDER_PACKET_ONE = 2
    const val DIVIDER_PACKET_TWO = 6
    val DIVIDER_PACKETS: List<List<Any>> = listOf(
        listOf(listOf(DIVIDER_PACKET_ONE)),
        listOf(listOf(DIVIDER_PACKET_TWO))
    )
}

fun main() {

    fun String.parse(): List<Any> {
        val stack = ArrayDeque<MutableList<Any>>()
        var idx = 0
        do {
            when (this[idx]) {
                '[' -> {
                    stack.addFirst(mutableListOf())
                    idx++
                }

                ']' -> {
                    if (stack.size > 1) {
                        val innerList = stack.removeFirst()
                        stack.first().add(innerList)
                    }
                    idx++
                }

                in '0'..'9' -> {
                    var nrStr: String = this[idx].toString()
                    while (this[++idx] !in Day13.NONE_NUMBER_CHARS) {
                        nrStr += this[idx]
                    }
                    stack.first().add(nrStr.toInt())
                }

                else -> idx++
            }
        } while (idx < this.length)
        check(stack.size == 1) { "Stack should only have root left" }
        return stack.first()
    }

    operator fun List<Any>.compareTo(other: List<Any>): Int {
        for (leftIdx in this.indices) {
            val firstValue = this[leftIdx]
            if (leftIdx < other.size) {
                val secondValue = other[leftIdx]

                when {
                    firstValue is Int && secondValue is Int -> {
                        if (firstValue != secondValue) return firstValue.compareTo(secondValue)
                    }

                    else -> {
                        val firstValueList = if (firstValue is Int) listOf(firstValue) else firstValue as List<Any>
                        val secondValueList = if (secondValue is Int) listOf(secondValue) else secondValue as List<Any>
                        if (firstValueList != secondValueList) {
                            return firstValueList.compareTo(secondValueList)
                        }
                    }
                }
            } else {
                return 1
            }
        }
        return -1
    }

    fun part1(input: List<String>): Int {
        val pairs = input.chunked(Day13.PACKET_COMBOS_NR_OF_LINES).map { it[0].parse() to it[1].parse() }
        val compareResults = pairs.map { it.first.compareTo(it.second) }
        return compareResults.foldIndexed(0) { index, acc, compareResult ->
            if (compareResult < 0) acc + index + 1 else acc
        }
    }

    fun part2(input: List<String>): Int {
        val pairs = input.filter { it.isNotBlank() }.map { it.parse() } + Day13.DIVIDER_PACKETS

        val sorted = pairs.sortedWith { o1, o2 -> o1!!.compareTo(o2!!) }
        val result = Day13.DIVIDER_PACKETS.map {
            sorted.indexOf(it) + 1
        }.reduce(Int::times)
        return result
    }

    // test if implementation meets criteria from the description, like:
    val testInput = readInput("Day13_test")
    check(part1(testInput) == Day13.EXPECTED_PART1_CHECK_ANSWER) { "Part 1 failed" }
    check(part2(testInput) == Day13.EXPECTED_PART2_CHECK_ANSWER) { "Part 2 failed" }

    val input = readInput("Day13")
    println(part1(input))
    println(part2(input))
}

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

  public static final int EXPECTED_PART1_CHECK_ANSWER;

  public static final int EXPECTED_PART2_CHECK_ANSWER;

  public static final int PACKET_COMBOS_NR_OF_LINES;

  private static final java.util.List<java.lang.Character> NONE_NUMBER_CHARS;

  public static final int DIVIDER_PACKET_ONE;

  public static final int DIVIDER_PACKET_TWO;

  private static final java.util.List<java.util.List<java.lang.Object>> DIVIDER_PACKETS;

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

  public final java.util.List<java.lang.Character> getNONE_NUMBER_CHARS();
    Code:
       0: getstatic     #18                 // Field NONE_NUMBER_CHARS:Ljava/util/List;
       3: areturn

  public final java.util.List<java.util.List<java.lang.Object>> getDIVIDER_PACKETS();
    Code:
       0: getstatic     #23                 // Field DIVIDER_PACKETS:Ljava/util/List;
       3: areturn

  static {};
    Code:
       0: new           #2                  // class Day13
       3: dup
       4: invokespecial #25                 // Method "<init>":()V
       7: putstatic     #28                 // Field INSTANCE:LDay13;
      10: iconst_3
      11: anewarray     #30                 // class java/lang/Character
      14: astore_0
      15: aload_0
      16: iconst_0
      17: bipush        91
      19: invokestatic  #34                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      22: aastore
      23: aload_0
      24: iconst_1
      25: bipush        93
      27: invokestatic  #34                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      30: aastore
      31: aload_0
      32: iconst_2
      33: bipush        44
      35: invokestatic  #34                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      38: aastore
      39: aload_0
      40: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      43: putstatic     #18                 // Field NONE_NUMBER_CHARS:Ljava/util/List;
      46: iconst_2
      47: anewarray     #42                 // class java/util/List
      50: astore_0
      51: aload_0
      52: iconst_0
      53: iconst_2
      54: invokestatic  #47                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      57: invokestatic  #50                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      60: invokestatic  #50                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      63: aastore
      64: aload_0
      65: iconst_1
      66: bipush        6
      68: invokestatic  #47                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      71: invokestatic  #50                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      74: invokestatic  #50                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      77: aastore
      78: aload_0
      79: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      82: putstatic     #23                 // Field DIVIDER_PACKETS:Ljava/util/List;
      85: return
}

Compiled from "Day13.kt"
public final class Day13Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day13_test
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)I
      10: bipush        13
      12: if_icmpne     19
      15: iconst_1
      16: goto          20
      19: iconst_0
      20: ifne          40
      23: iconst_0
      24: istore_2
      25: ldc           #20                 // String Part 1 failed
      27: astore_2
      28: new           #22                 // class java/lang/IllegalStateException
      31: dup
      32: aload_2
      33: invokevirtual #26                 // Method java/lang/Object.toString:()Ljava/lang/String;
      36: invokespecial #30                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      39: athrow
      40: aload_0
      41: invokestatic  #33                 // Method main$part2:(Ljava/util/List;)I
      44: sipush        140
      47: if_icmpne     54
      50: iconst_1
      51: goto          55
      54: iconst_0
      55: ifne          75
      58: iconst_0
      59: istore_2
      60: ldc           #35                 // String Part 2 failed
      62: astore_2
      63: new           #22                 // class java/lang/IllegalStateException
      66: dup
      67: aload_2
      68: invokevirtual #26                 // Method java/lang/Object.toString:()Ljava/lang/String;
      71: invokespecial #30                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      74: athrow
      75: ldc           #37                 // String Day13
      77: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      80: astore_1
      81: aload_1
      82: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)I
      85: istore_2
      86: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      89: iload_2
      90: invokevirtual #49                 // Method java/io/PrintStream.println:(I)V
      93: aload_1
      94: invokestatic  #33                 // Method main$part2:(Ljava/util/List;)I
      97: istore_2
      98: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
     101: iload_2
     102: invokevirtual #49                 // Method java/io/PrintStream.println:(I)V
     105: return

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

  private static final java.util.List<java.lang.Object> main$parse(java.lang.String);
    Code:
       0: new           #66                 // class kotlin/collections/ArrayDeque
       3: dup
       4: invokespecial #68                 // Method kotlin/collections/ArrayDeque."<init>":()V
       7: astore_1
       8: iconst_0
       9: istore_2
      10: aload_0
      11: iload_2
      12: invokevirtual #74                 // Method java/lang/String.charAt:(I)C
      15: istore_3
      16: iload_3
      17: bipush        91
      19: if_icmpne     44
      22: aload_1
      23: new           #76                 // class java/util/ArrayList
      26: dup
      27: invokespecial #77                 // Method java/util/ArrayList."<init>":()V
      30: checkcast     #57                 // class java/util/List
      33: invokevirtual #81                 // Method kotlin/collections/ArrayDeque.addFirst:(Ljava/lang/Object;)V
      36: iload_2
      37: iinc          2, 1
      40: pop
      41: goto          206
      44: iload_3
      45: bipush        93
      47: if_icmpne     90
      50: aload_1
      51: invokevirtual #85                 // Method kotlin/collections/ArrayDeque.size:()I
      54: iconst_1
      55: if_icmple     82
      58: aload_1
      59: invokevirtual #89                 // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;
      62: checkcast     #57                 // class java/util/List
      65: astore        4
      67: aload_1
      68: invokevirtual #92                 // Method kotlin/collections/ArrayDeque.first:()Ljava/lang/Object;
      71: checkcast     #57                 // class java/util/List
      74: aload         4
      76: invokeinterface #96,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      81: pop
      82: iload_2
      83: iinc          2, 1
      86: pop
      87: goto          206
      90: bipush        48
      92: iload_3
      93: if_icmpgt     110
      96: iload_3
      97: bipush        58
      99: if_icmpge     106
     102: iconst_1
     103: goto          111
     106: iconst_0
     107: goto          111
     110: iconst_0
     111: ifeq          201
     114: aload_0
     115: iload_2
     116: invokevirtual #74                 // Method java/lang/String.charAt:(I)C
     119: invokestatic  #100                // Method java/lang/String.valueOf:(C)Ljava/lang/String;
     122: astore        4
     124: getstatic     #105                // Field Day13.INSTANCE:LDay13;
     127: invokevirtual #109                // Method Day13.getNONE_NUMBER_CHARS:()Ljava/util/List;
     130: aload_0
     131: iinc          2, 1
     134: iload_2
     135: invokevirtual #74                 // Method java/lang/String.charAt:(I)C
     138: invokestatic  #114                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     141: invokeinterface #117,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     146: ifne          177
     149: new           #119                // class java/lang/StringBuilder
     152: dup
     153: invokespecial #120                // Method java/lang/StringBuilder."<init>":()V
     156: aload         4
     158: invokevirtual #124                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     161: aload_0
     162: iload_2
     163: invokevirtual #74                 // Method java/lang/String.charAt:(I)C
     166: invokevirtual #127                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     169: invokevirtual #128                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     172: astore        4
     174: goto          124
     177: aload_1
     178: invokevirtual #92                 // Method kotlin/collections/ArrayDeque.first:()Ljava/lang/Object;
     181: checkcast     #57                 // class java/util/List
     184: aload         4
     186: invokestatic  #134                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     189: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     192: invokeinterface #96,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     197: pop
     198: goto          206
     201: iload_2
     202: iinc          2, 1
     205: pop
     206: iload_2
     207: aload_0
     208: invokevirtual #140                // Method java/lang/String.length:()I
     211: if_icmplt     10
     214: aload_1
     215: invokevirtual #85                 // Method kotlin/collections/ArrayDeque.size:()I
     218: iconst_1
     219: if_icmpne     226
     222: iconst_1
     223: goto          227
     226: iconst_0
     227: ifne          250
     230: iconst_0
     231: istore        4
     233: ldc           #142                // String Stack should only have root left
     235: astore        4
     237: new           #22                 // class java/lang/IllegalStateException
     240: dup
     241: aload         4
     243: invokevirtual #26                 // Method java/lang/Object.toString:()Ljava/lang/String;
     246: invokespecial #30                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     249: athrow
     250: aload_1
     251: invokevirtual #92                 // Method kotlin/collections/ArrayDeque.first:()Ljava/lang/Object;
     254: checkcast     #57                 // class java/util/List
     257: areturn

  private static final int main$compareTo(java.util.List<? extends java.lang.Object>, java.util.List<? extends java.lang.Object>);
    Code:
       0: aload_0
       1: ldc           #155                // String <this>
       3: invokestatic  #161                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_2
       8: aload_0
       9: checkcast     #163                // class java/util/Collection
      12: invokeinterface #164,  1          // InterfaceMethod java/util/Collection.size:()I
      17: istore_3
      18: iload_2
      19: iload_3
      20: if_icmpge     184
      23: aload_0
      24: iload_2
      25: invokeinterface #168,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      30: astore        4
      32: iload_2
      33: aload_1
      34: invokeinterface #169,  1          // InterfaceMethod java/util/List.size:()I
      39: if_icmpge     176
      42: aload_1
      43: iload_2
      44: invokeinterface #168,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      49: astore        5
      51: nop
      52: aload         4
      54: instanceof    #130                // class java/lang/Integer
      57: ifeq          98
      60: aload         5
      62: instanceof    #130                // class java/lang/Integer
      65: ifeq          98
      68: aload         4
      70: aload         5
      72: invokestatic  #173                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      75: ifne          178
      78: aload         4
      80: checkcast     #175                // class java/lang/Number
      83: invokevirtual #178                // Method java/lang/Number.intValue:()I
      86: aload         5
      88: checkcast     #175                // class java/lang/Number
      91: invokevirtual #178                // Method java/lang/Number.intValue:()I
      94: invokestatic  #182                // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
      97: ireturn
      98: aload         4
     100: instanceof    #130                // class java/lang/Integer
     103: ifeq          114
     106: aload         4
     108: invokestatic  #188                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     111: goto          126
     114: aload         4
     116: ldc           #190                // String null cannot be cast to non-null type kotlin.collections.List<kotlin.Any>
     118: invokestatic  #193                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V
     121: aload         4
     123: checkcast     #57                 // class java/util/List
     126: astore        6
     128: aload         5
     130: instanceof    #130                // class java/lang/Integer
     133: ifeq          144
     136: aload         5
     138: invokestatic  #188                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     141: goto          156
     144: aload         5
     146: ldc           #190                // String null cannot be cast to non-null type kotlin.collections.List<kotlin.Any>
     148: invokestatic  #193                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V
     151: aload         5
     153: checkcast     #57                 // class java/util/List
     156: astore        7
     158: aload         6
     160: aload         7
     162: invokestatic  #173                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     165: ifne          178
     168: aload         6
     170: aload         7
     172: invokestatic  #195                // Method main$compareTo:(Ljava/util/List;Ljava/util/List;)I
     175: ireturn
     176: iconst_1
     177: ireturn
     178: iinc          2, 1
     181: goto          18
     184: iconst_m1
     185: ireturn

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #206                // class java/lang/Iterable
       4: iconst_3
       5: invokestatic  #210                // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;
       8: checkcast     #206                // class java/lang/Iterable
      11: astore_2
      12: iconst_0
      13: istore_3
      14: aload_2
      15: astore        4
      17: new           #76                 // class java/util/ArrayList
      20: dup
      21: aload_2
      22: bipush        10
      24: invokestatic  #214                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      27: invokespecial #216                // Method java/util/ArrayList."<init>":(I)V
      30: checkcast     #163                // class java/util/Collection
      33: astore        5
      35: iconst_0
      36: istore        6
      38: aload         4
      40: invokeinterface #220,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      45: astore        7
      47: aload         7
      49: invokeinterface #226,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      54: ifeq          123
      57: aload         7
      59: invokeinterface #229,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      64: astore        8
      66: aload         5
      68: aload         8
      70: checkcast     #57                 // class java/util/List
      73: astore        9
      75: astore        15
      77: iconst_0
      78: istore        10
      80: aload         9
      82: iconst_0
      83: invokeinterface #168,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      88: checkcast     #70                 // class java/lang/String
      91: invokestatic  #231                // Method main$parse:(Ljava/lang/String;)Ljava/util/List;
      94: aload         9
      96: iconst_1
      97: invokeinterface #168,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     102: checkcast     #70                 // class java/lang/String
     105: invokestatic  #231                // Method main$parse:(Ljava/lang/String;)Ljava/util/List;
     108: invokestatic  #237                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     111: aload         15
     113: swap
     114: invokeinterface #238,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     119: pop
     120: goto          47
     123: aload         5
     125: checkcast     #57                 // class java/util/List
     128: nop
     129: astore_1
     130: aload_1
     131: checkcast     #206                // class java/lang/Iterable
     134: astore_3
     135: iconst_0
     136: istore        4
     138: aload_3
     139: astore        5
     141: new           #76                 // class java/util/ArrayList
     144: dup
     145: aload_3
     146: bipush        10
     148: invokestatic  #214                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     151: invokespecial #216                // Method java/util/ArrayList."<init>":(I)V
     154: checkcast     #163                // class java/util/Collection
     157: astore        6
     159: iconst_0
     160: istore        7
     162: aload         5
     164: invokeinterface #220,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     169: astore        8
     171: aload         8
     173: invokeinterface #226,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     178: ifeq          238
     181: aload         8
     183: invokeinterface #229,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     188: astore        9
     190: aload         6
     192: aload         9
     194: checkcast     #240                // class kotlin/Pair
     197: astore        10
     199: astore        15
     201: iconst_0
     202: istore        11
     204: aload         10
     206: invokevirtual #243                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     209: checkcast     #57                 // class java/util/List
     212: aload         10
     214: invokevirtual #246                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     217: checkcast     #57                 // class java/util/List
     220: invokestatic  #195                // Method main$compareTo:(Ljava/util/List;Ljava/util/List;)I
     223: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     226: aload         15
     228: swap
     229: invokeinterface #238,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     234: pop
     235: goto          171
     238: aload         6
     240: checkcast     #57                 // class java/util/List
     243: nop
     244: astore_2
     245: aload_2
     246: checkcast     #206                // class java/lang/Iterable
     249: astore_3
     250: iconst_0
     251: istore        4
     253: iconst_0
     254: istore        5
     256: iconst_0
     257: istore        6
     259: iload         4
     261: istore        7
     263: aload_3
     264: invokeinterface #220,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     269: astore        8
     271: aload         8
     273: invokeinterface #226,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     278: ifeq          348
     281: aload         8
     283: invokeinterface #229,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     288: astore        9
     290: iload         6
     292: iinc          6, 1
     295: istore        10
     297: iload         10
     299: ifge          305
     302: invokestatic  #249                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     305: iload         10
     307: iload         7
     309: aload         9
     311: checkcast     #175                // class java/lang/Number
     314: invokevirtual #178                // Method java/lang/Number.intValue:()I
     317: istore        11
     319: istore        12
     321: istore        13
     323: iconst_0
     324: istore        14
     326: iload         11
     328: ifge          341
     331: iload         12
     333: iload         13
     335: iadd
     336: iconst_1
     337: iadd
     338: goto          343
     341: iload         12
     343: istore        7
     345: goto          271
     348: iload         7
     350: ireturn

  private static final int main$part2$lambda$6(java.util.List, java.util.List);
    Code:
       0: aload_0
       1: dup
       2: invokestatic  #276                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       5: aload_1
       6: dup
       7: invokestatic  #276                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      10: invokestatic  #195                // Method main$compareTo:(Ljava/util/List;Ljava/util/List;)I
      13: ireturn

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

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #206                // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: astore        4
      10: new           #76                 // class java/util/ArrayList
      13: dup
      14: invokespecial #77                 // Method java/util/ArrayList."<init>":()V
      17: checkcast     #163                // class java/util/Collection
      20: astore        5
      22: iconst_0
      23: istore        6
      25: aload         4
      27: invokeinterface #220,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      32: astore        7
      34: aload         7
      36: invokeinterface #226,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      41: ifeq          96
      44: aload         7
      46: invokeinterface #229,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      51: astore        8
      53: aload         8
      55: checkcast     #70                 // class java/lang/String
      58: astore        9
      60: iconst_0
      61: istore        10
      63: aload         9
      65: checkcast     #292                // class java/lang/CharSequence
      68: invokestatic  #298                // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z
      71: ifne          78
      74: iconst_1
      75: goto          79
      78: iconst_0
      79: nop
      80: ifeq          34
      83: aload         5
      85: aload         8
      87: invokeinterface #238,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      92: pop
      93: goto          34
      96: aload         5
      98: checkcast     #57                 // class java/util/List
     101: nop
     102: checkcast     #206                // class java/lang/Iterable
     105: astore_2
     106: nop
     107: iconst_0
     108: istore_3
     109: aload_2
     110: astore        4
     112: new           #76                 // class java/util/ArrayList
     115: dup
     116: aload_2
     117: bipush        10
     119: invokestatic  #214                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     122: invokespecial #216                // Method java/util/ArrayList."<init>":(I)V
     125: checkcast     #163                // class java/util/Collection
     128: astore        5
     130: iconst_0
     131: istore        6
     133: aload         4
     135: invokeinterface #220,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     140: astore        7
     142: aload         7
     144: invokeinterface #226,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     149: ifeq          192
     152: aload         7
     154: invokeinterface #229,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     159: astore        8
     161: aload         5
     163: aload         8
     165: checkcast     #70                 // class java/lang/String
     168: astore        9
     170: astore        13
     172: iconst_0
     173: istore        10
     175: aload         9
     177: invokestatic  #231                // Method main$parse:(Ljava/lang/String;)Ljava/util/List;
     180: aload         13
     182: swap
     183: invokeinterface #238,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     188: pop
     189: goto          142
     192: aload         5
     194: checkcast     #57                 // class java/util/List
     197: nop
     198: checkcast     #163                // class java/util/Collection
     201: getstatic     #105                // Field Day13.INSTANCE:LDay13;
     204: invokevirtual #301                // Method Day13.getDIVIDER_PACKETS:()Ljava/util/List;
     207: checkcast     #206                // class java/lang/Iterable
     210: invokestatic  #305                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     213: astore_1
     214: aload_1
     215: checkcast     #206                // class java/lang/Iterable
     218: invokedynamic #321,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;
     223: invokedynamic #329,  0            // InvokeDynamic #1:compare:(Lkotlin/jvm/functions/Function2;)Ljava/util/Comparator;
     228: invokestatic  #333                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
     231: astore_2
     232: getstatic     #105                // Field Day13.INSTANCE:LDay13;
     235: invokevirtual #301                // Method Day13.getDIVIDER_PACKETS:()Ljava/util/List;
     238: checkcast     #206                // class java/lang/Iterable
     241: astore        4
     243: iconst_0
     244: istore        5
     246: aload         4
     248: astore        6
     250: new           #76                 // class java/util/ArrayList
     253: dup
     254: aload         4
     256: bipush        10
     258: invokestatic  #214                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     261: invokespecial #216                // Method java/util/ArrayList."<init>":(I)V
     264: checkcast     #163                // class java/util/Collection
     267: astore        7
     269: iconst_0
     270: istore        8
     272: aload         6
     274: invokeinterface #220,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     279: astore        9
     281: aload         9
     283: invokeinterface #226,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     288: ifeq          339
     291: aload         9
     293: invokeinterface #229,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     298: astore        10
     300: aload         7
     302: aload         10
     304: checkcast     #57                 // class java/util/List
     307: astore        11
     309: astore        13
     311: iconst_0
     312: istore        12
     314: aload_2
     315: aload         11
     317: invokeinterface #337,  2          // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I
     322: iconst_1
     323: iadd
     324: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     327: aload         13
     329: swap
     330: invokeinterface #238,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     335: pop
     336: goto          281
     339: aload         7
     341: checkcast     #57                 // class java/util/List
     344: nop
     345: checkcast     #206                // class java/lang/Iterable
     348: astore        4
     350: nop
     351: iconst_0
     352: istore        5
     354: aload         4
     356: invokeinterface #220,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     361: astore        6
     363: aload         6
     365: invokeinterface #226,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     370: ifne          384
     373: new           #339                // class java/lang/UnsupportedOperationException
     376: dup
     377: ldc_w         #341                // String Empty collection can\'t be reduced.
     380: invokespecial #342                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     383: athrow
     384: aload         6
     386: invokeinterface #229,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     391: astore        7
     393: aload         6
     395: invokeinterface #226,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     400: ifeq          444
     403: aload         7
     405: aload         6
     407: invokeinterface #229,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     412: checkcast     #175                // class java/lang/Number
     415: invokevirtual #178                // Method java/lang/Number.intValue:()I
     418: istore        8
     420: checkcast     #175                // class java/lang/Number
     423: invokevirtual #178                // Method java/lang/Number.intValue:()I
     426: istore        9
     428: iconst_0
     429: istore        10
     431: iload         9
     433: iload         8
     435: imul
     436: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     439: astore        7
     441: goto          393
     444: aload         7
     446: checkcast     #175                // class java/lang/Number
     449: invokevirtual #178                // Method java/lang/Number.intValue:()I
     452: istore_3
     453: iload_3
     454: ireturn
}