package day18

import java.io.File

fun main() {
    val data = parse("src/main/kotlin/day18/Day18.txt")

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

    println("🎄 Day 18 🎄")

    println()

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

    println()

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

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

@Suppress("SameParameterValue")
private fun parse(path: String): Set<Point> =
    File(path).readLines().mapTo(HashSet()) { line ->
        line.split(",")
            .map { it.toInt() }
            .let { (x, y, z) -> Point(x, y, z) }
    }

private fun Point.neighbors(): Set<Point> {
    return setOf(
        Point(x + 1, y + 0, z + 0),
        Point(x - 1, y + 0, z + 0),
        Point(x + 0, y + 1, z + 0),
        Point(x + 0, y - 1, z + 0),
        Point(x + 0, y + 0, z + 1),
        Point(x + 0, y + 0, z - 1),
    )
}

private fun part1(data: Set<Point>): Int =
    data.flatMap { it.neighbors() }
        .count { it !in data }

private fun part2(data: Set<Point>): Int {
    val xRange = (data.minOf { it.x } - 1)..(data.maxOf { it.x } + 1)
    val yRange = (data.minOf { it.y } - 1)..(data.maxOf { it.y } + 1)
    val zRange = (data.minOf { it.z } - 1)..(data.maxOf { it.z } + 1)

    val start = Point(
        xRange.first,
        yRange.first,
        zRange.first,
    )

    val queue = ArrayDeque<Point>().apply { add(start) }
    val visited = mutableSetOf<Point>()

    var area = 0
    while (queue.isNotEmpty()) {
        val point = queue.removeFirst()
        if (point in visited) {
            continue
        }

        visited += point
        for (neighbor in point.neighbors()) {
            val (x, y, z) = neighbor
            if (x in xRange && y in yRange && z in zRange) {
                if (neighbor in data) {
                    area += 1
                } else if (neighbor !in visited) {
                    queue += neighbor
                }
            }
        }
    }

    return area
}

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

  private static final java.util.Set<day18.Point> parse(java.lang.String);
    Code:
       0: new           #65                 // class java/io/File
       3: dup
       4: aload_0
       5: invokespecial #68                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       8: aconst_null
       9: iconst_1
      10: aconst_null
      11: invokestatic  #74                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      14: checkcast     #76                 // class java/lang/Iterable
      17: astore_1
      18: new           #78                 // class java/util/HashSet
      21: dup
      22: invokespecial #79                 // Method java/util/HashSet."<init>":()V
      25: checkcast     #81                 // class java/util/Collection
      28: astore_2
      29: iconst_0
      30: istore_3
      31: aload_1
      32: invokeinterface #85,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        4
      39: aload         4
      41: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          282
      49: aload         4
      51: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        5
      58: aload_2
      59: aload         5
      61: checkcast     #97                 // class java/lang/String
      64: astore        6
      66: astore        18
      68: iconst_0
      69: istore        7
      71: aload         6
      73: checkcast     #99                 // class java/lang/CharSequence
      76: iconst_1
      77: anewarray     #97                 // class java/lang/String
      80: astore        8
      82: aload         8
      84: iconst_0
      85: ldc           #101                // String ,
      87: aastore
      88: aload         8
      90: iconst_0
      91: iconst_0
      92: bipush        6
      94: aconst_null
      95: invokestatic  #107                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      98: checkcast     #76                 // class java/lang/Iterable
     101: astore        8
     103: nop
     104: iconst_0
     105: istore        9
     107: aload         8
     109: astore        10
     111: new           #109                // class java/util/ArrayList
     114: dup
     115: aload         8
     117: bipush        10
     119: invokestatic  #115                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     122: invokespecial #118                // Method java/util/ArrayList."<init>":(I)V
     125: checkcast     #81                 // class java/util/Collection
     128: astore        11
     130: iconst_0
     131: istore        12
     133: aload         10
     135: invokeinterface #85,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     140: astore        13
     142: aload         13
     144: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     149: ifeq          196
     152: aload         13
     154: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     159: astore        14
     161: aload         11
     163: aload         14
     165: checkcast     #97                 // class java/lang/String
     168: astore        15
     170: astore        16
     172: iconst_0
     173: istore        17
     175: aload         15
     177: invokestatic  #124                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     180: nop
     181: invokestatic  #128                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     184: aload         16
     186: swap
     187: invokeinterface #132,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     192: pop
     193: goto          142
     196: aload         11
     198: checkcast     #134                // class java/util/List
     201: nop
     202: astore        9
     204: iconst_0
     205: istore        10
     207: aload         9
     209: iconst_0
     210: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     215: checkcast     #140                // class java/lang/Number
     218: invokevirtual #144                // Method java/lang/Number.intValue:()I
     221: istore        11
     223: aload         9
     225: iconst_1
     226: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     231: checkcast     #140                // class java/lang/Number
     234: invokevirtual #144                // Method java/lang/Number.intValue:()I
     237: istore        12
     239: aload         9
     241: iconst_2
     242: invokeinterface #138,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     247: checkcast     #140                // class java/lang/Number
     250: invokevirtual #144                // Method java/lang/Number.intValue:()I
     253: istore        13
     255: new           #146                // class day18/Point
     258: dup
     259: iload         11
     261: iload         12
     263: iload         13
     265: invokespecial #149                // Method day18/Point."<init>":(III)V
     268: nop
     269: nop
     270: aload         18
     272: swap
     273: invokeinterface #132,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     278: pop
     279: goto          39
     282: aload_2
     283: checkcast     #151                // class java/util/Set
     286: areturn

  private static final java.util.Set<day18.Point> neighbors(day18.Point);
    Code:
       0: bipush        6
       2: anewarray     #146                // class day18/Point
       5: astore_1
       6: aload_1
       7: iconst_0
       8: new           #146                // class day18/Point
      11: dup
      12: aload_0
      13: invokevirtual #179                // Method day18/Point.getX:()I
      16: iconst_1
      17: iadd
      18: aload_0
      19: invokevirtual #182                // Method day18/Point.getY:()I
      22: iconst_0
      23: iadd
      24: aload_0
      25: invokevirtual #185                // Method day18/Point.getZ:()I
      28: iconst_0
      29: iadd
      30: invokespecial #149                // Method day18/Point."<init>":(III)V
      33: aastore
      34: aload_1
      35: iconst_1
      36: new           #146                // class day18/Point
      39: dup
      40: aload_0
      41: invokevirtual #179                // Method day18/Point.getX:()I
      44: iconst_1
      45: isub
      46: aload_0
      47: invokevirtual #182                // Method day18/Point.getY:()I
      50: iconst_0
      51: iadd
      52: aload_0
      53: invokevirtual #185                // Method day18/Point.getZ:()I
      56: iconst_0
      57: iadd
      58: invokespecial #149                // Method day18/Point."<init>":(III)V
      61: aastore
      62: aload_1
      63: iconst_2
      64: new           #146                // class day18/Point
      67: dup
      68: aload_0
      69: invokevirtual #179                // Method day18/Point.getX:()I
      72: iconst_0
      73: iadd
      74: aload_0
      75: invokevirtual #182                // Method day18/Point.getY:()I
      78: iconst_1
      79: iadd
      80: aload_0
      81: invokevirtual #185                // Method day18/Point.getZ:()I
      84: iconst_0
      85: iadd
      86: invokespecial #149                // Method day18/Point."<init>":(III)V
      89: aastore
      90: aload_1
      91: iconst_3
      92: new           #146                // class day18/Point
      95: dup
      96: aload_0
      97: invokevirtual #179                // Method day18/Point.getX:()I
     100: iconst_0
     101: iadd
     102: aload_0
     103: invokevirtual #182                // Method day18/Point.getY:()I
     106: iconst_1
     107: isub
     108: aload_0
     109: invokevirtual #185                // Method day18/Point.getZ:()I
     112: iconst_0
     113: iadd
     114: invokespecial #149                // Method day18/Point."<init>":(III)V
     117: aastore
     118: aload_1
     119: iconst_4
     120: new           #146                // class day18/Point
     123: dup
     124: aload_0
     125: invokevirtual #179                // Method day18/Point.getX:()I
     128: iconst_0
     129: iadd
     130: aload_0
     131: invokevirtual #182                // Method day18/Point.getY:()I
     134: iconst_0
     135: iadd
     136: aload_0
     137: invokevirtual #185                // Method day18/Point.getZ:()I
     140: iconst_1
     141: iadd
     142: invokespecial #149                // Method day18/Point."<init>":(III)V
     145: aastore
     146: aload_1
     147: iconst_5
     148: new           #146                // class day18/Point
     151: dup
     152: aload_0
     153: invokevirtual #179                // Method day18/Point.getX:()I
     156: iconst_0
     157: iadd
     158: aload_0
     159: invokevirtual #182                // Method day18/Point.getY:()I
     162: iconst_0
     163: iadd
     164: aload_0
     165: invokevirtual #185                // Method day18/Point.getZ:()I
     168: iconst_1
     169: isub
     170: invokespecial #149                // Method day18/Point."<init>":(III)V
     173: aastore
     174: aload_1
     175: invokestatic  #191                // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;
     178: areturn

  private static final int part1(java.util.Set<day18.Point>);
    Code:
       0: aload_0
       1: checkcast     #76                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: astore_3
       9: new           #109                // class java/util/ArrayList
      12: dup
      13: invokespecial #195                // Method java/util/ArrayList."<init>":()V
      16: checkcast     #81                 // class java/util/Collection
      19: astore        4
      21: iconst_0
      22: istore        5
      24: aload_3
      25: invokeinterface #85,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      30: astore        6
      32: aload         6
      34: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      39: ifeq          82
      42: aload         6
      44: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      49: astore        7
      51: aload         7
      53: checkcast     #146                // class day18/Point
      56: astore        8
      58: iconst_0
      59: istore        9
      61: aload         8
      63: invokestatic  #197                // Method neighbors:(Lday18/Point;)Ljava/util/Set;
      66: checkcast     #76                 // class java/lang/Iterable
      69: astore        8
      71: aload         4
      73: aload         8
      75: invokestatic  #201                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
      78: pop
      79: goto          32
      82: aload         4
      84: checkcast     #134                // class java/util/List
      87: nop
      88: checkcast     #76                 // class java/lang/Iterable
      91: astore_1
      92: nop
      93: iconst_0
      94: istore_2
      95: aload_1
      96: instanceof    #81                 // class java/util/Collection
      99: ifeq          118
     102: aload_1
     103: checkcast     #81                 // class java/util/Collection
     106: invokeinterface #204,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     111: ifeq          118
     114: iconst_0
     115: goto          190
     118: iconst_0
     119: istore_3
     120: aload_1
     121: invokeinterface #85,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     126: astore        4
     128: aload         4
     130: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     135: ifeq          189
     138: aload         4
     140: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     145: astore        5
     147: aload         5
     149: checkcast     #146                // class day18/Point
     152: astore        6
     154: iconst_0
     155: istore        7
     157: aload_0
     158: aload         6
     160: invokeinterface #207,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     165: ifne          172
     168: iconst_1
     169: goto          173
     172: iconst_0
     173: ifeq          128
     176: iinc          3, 1
     179: iload_3
     180: ifge          128
     183: invokestatic  #210                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     186: goto          128
     189: iload_3
     190: ireturn

  private static final int part2(java.util.Set<day18.Point>);
    Code:
       0: aload_0
       1: checkcast     #76                 // class java/lang/Iterable
       4: invokeinterface #85,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
       9: astore_3
      10: aload_3
      11: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      16: ifne          27
      19: new           #224                // class java/util/NoSuchElementException
      22: dup
      23: invokespecial #225                // Method java/util/NoSuchElementException."<init>":()V
      26: athrow
      27: aload_3
      28: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      33: checkcast     #146                // class day18/Point
      36: astore        4
      38: iconst_0
      39: istore        5
      41: aload         4
      43: invokevirtual #179                // Method day18/Point.getX:()I
      46: istore        4
      48: aload_3
      49: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      54: ifeq          92
      57: aload_3
      58: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: checkcast     #146                // class day18/Point
      66: astore        5
      68: iconst_0
      69: istore        6
      71: aload         5
      73: invokevirtual #179                // Method day18/Point.getX:()I
      76: istore        5
      78: iload         4
      80: iload         5
      82: if_icmple     48
      85: iload         5
      87: istore        4
      89: goto          48
      92: iload         4
      94: iconst_1
      95: isub
      96: aload_0
      97: checkcast     #76                 // class java/lang/Iterable
     100: astore_2
     101: istore        15
     103: aload_2
     104: invokeinterface #85,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     109: astore_3
     110: aload_3
     111: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     116: ifne          127
     119: new           #224                // class java/util/NoSuchElementException
     122: dup
     123: invokespecial #225                // Method java/util/NoSuchElementException."<init>":()V
     126: athrow
     127: aload_3
     128: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     133: checkcast     #146                // class day18/Point
     136: astore        4
     138: iconst_0
     139: istore        5
     141: aload         4
     143: invokevirtual #179                // Method day18/Point.getX:()I
     146: istore        4
     148: aload_3
     149: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     154: ifeq          192
     157: aload_3
     158: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     163: checkcast     #146                // class day18/Point
     166: astore        5
     168: iconst_0
     169: istore        6
     171: aload         5
     173: invokevirtual #179                // Method day18/Point.getX:()I
     176: istore        5
     178: iload         4
     180: iload         5
     182: if_icmpge     148
     185: iload         5
     187: istore        4
     189: goto          148
     192: iload         4
     194: istore        16
     196: iload         15
     198: iload         16
     200: iconst_1
     201: iadd
     202: istore        17
     204: istore        18
     206: new           #227                // class kotlin/ranges/IntRange
     209: dup
     210: iload         18
     212: iload         17
     214: invokespecial #230                // Method kotlin/ranges/IntRange."<init>":(II)V
     217: astore_1
     218: aload_0
     219: checkcast     #76                 // class java/lang/Iterable
     222: invokeinterface #85,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     227: astore        4
     229: aload         4
     231: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     236: ifne          247
     239: new           #224                // class java/util/NoSuchElementException
     242: dup
     243: invokespecial #225                // Method java/util/NoSuchElementException."<init>":()V
     246: athrow
     247: aload         4
     249: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     254: checkcast     #146                // class day18/Point
     257: astore        5
     259: iconst_0
     260: istore        6
     262: aload         5
     264: invokevirtual #182                // Method day18/Point.getY:()I
     267: istore        5
     269: aload         4
     271: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     276: ifeq          315
     279: aload         4
     281: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     286: checkcast     #146                // class day18/Point
     289: astore        6
     291: iconst_0
     292: istore        7
     294: aload         6
     296: invokevirtual #182                // Method day18/Point.getY:()I
     299: istore        6
     301: iload         5
     303: iload         6
     305: if_icmple     269
     308: iload         6
     310: istore        5
     312: goto          269
     315: iload         5
     317: iconst_1
     318: isub
     319: aload_0
     320: checkcast     #76                 // class java/lang/Iterable
     323: astore_3
     324: istore        15
     326: aload_3
     327: invokeinterface #85,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     332: astore        4
     334: aload         4
     336: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     341: ifne          352
     344: new           #224                // class java/util/NoSuchElementException
     347: dup
     348: invokespecial #225                // Method java/util/NoSuchElementException."<init>":()V
     351: athrow
     352: aload         4
     354: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     359: checkcast     #146                // class day18/Point
     362: astore        5
     364: iconst_0
     365: istore        6
     367: aload         5
     369: invokevirtual #182                // Method day18/Point.getY:()I
     372: istore        5
     374: aload         4
     376: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     381: ifeq          420
     384: aload         4
     386: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     391: checkcast     #146                // class day18/Point
     394: astore        6
     396: iconst_0
     397: istore        7
     399: aload         6
     401: invokevirtual #182                // Method day18/Point.getY:()I
     404: istore        6
     406: iload         5
     408: iload         6
     410: if_icmpge     374
     413: iload         6
     415: istore        5
     417: goto          374
     420: iload         5
     422: istore        16
     424: iload         15
     426: iload         16
     428: iconst_1
     429: iadd
     430: istore        19
     432: istore        20
     434: new           #227                // class kotlin/ranges/IntRange
     437: dup
     438: iload         20
     440: iload         19
     442: invokespecial #230                // Method kotlin/ranges/IntRange."<init>":(II)V
     445: astore_2
     446: aload_0
     447: checkcast     #76                 // class java/lang/Iterable
     450: invokeinterface #85,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     455: astore        5
     457: aload         5
     459: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     464: ifne          475
     467: new           #224                // class java/util/NoSuchElementException
     470: dup
     471: invokespecial #225                // Method java/util/NoSuchElementException."<init>":()V
     474: athrow
     475: aload         5
     477: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     482: checkcast     #146                // class day18/Point
     485: astore        6
     487: iconst_0
     488: istore        7
     490: aload         6
     492: invokevirtual #185                // Method day18/Point.getZ:()I
     495: istore        6
     497: aload         5
     499: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     504: ifeq          543
     507: aload         5
     509: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     514: checkcast     #146                // class day18/Point
     517: astore        7
     519: iconst_0
     520: istore        8
     522: aload         7
     524: invokevirtual #185                // Method day18/Point.getZ:()I
     527: istore        7
     529: iload         6
     531: iload         7
     533: if_icmple     497
     536: iload         7
     538: istore        6
     540: goto          497
     543: iload         6
     545: iconst_1
     546: isub
     547: aload_0
     548: checkcast     #76                 // class java/lang/Iterable
     551: astore        4
     553: istore        15
     555: aload         4
     557: invokeinterface #85,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     562: astore        5
     564: aload         5
     566: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     571: ifne          582
     574: new           #224                // class java/util/NoSuchElementException
     577: dup
     578: invokespecial #225                // Method java/util/NoSuchElementException."<init>":()V
     581: athrow
     582: aload         5
     584: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     589: checkcast     #146                // class day18/Point
     592: astore        6
     594: iconst_0
     595: istore        7
     597: aload         6
     599: invokevirtual #185                // Method day18/Point.getZ:()I
     602: istore        6
     604: aload         5
     606: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     611: ifeq          650
     614: aload         5
     616: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     621: checkcast     #146                // class day18/Point
     624: astore        7
     626: iconst_0
     627: istore        8
     629: aload         7
     631: invokevirtual #185                // Method day18/Point.getZ:()I
     634: istore        7
     636: iload         6
     638: iload         7
     640: if_icmpge     604
     643: iload         7
     645: istore        6
     647: goto          604
     650: iload         6
     652: istore        16
     654: iload         15
     656: iload         16
     658: iconst_1
     659: iadd
     660: istore        21
     662: istore        22
     664: new           #227                // class kotlin/ranges/IntRange
     667: dup
     668: iload         22
     670: iload         21
     672: invokespecial #230                // Method kotlin/ranges/IntRange."<init>":(II)V
     675: astore_3
     676: new           #146                // class day18/Point
     679: dup
     680: aload_1
     681: invokevirtual #233                // Method kotlin/ranges/IntRange.getFirst:()I
     684: aload_2
     685: invokevirtual #233                // Method kotlin/ranges/IntRange.getFirst:()I
     688: aload_3
     689: invokevirtual #233                // Method kotlin/ranges/IntRange.getFirst:()I
     692: invokespecial #149                // Method day18/Point."<init>":(III)V
     695: astore        4
     697: new           #235                // class kotlin/collections/ArrayDeque
     700: dup
     701: invokespecial #236                // Method kotlin/collections/ArrayDeque."<init>":()V
     704: astore        6
     706: aload         6
     708: astore        7
     710: iconst_0
     711: istore        8
     713: aload         7
     715: aload         4
     717: invokevirtual #237                // Method kotlin/collections/ArrayDeque.add:(Ljava/lang/Object;)Z
     720: pop
     721: aload         6
     723: astore        5
     725: new           #239                // class java/util/LinkedHashSet
     728: dup
     729: invokespecial #240                // Method java/util/LinkedHashSet."<init>":()V
     732: checkcast     #151                // class java/util/Set
     735: astore        6
     737: iconst_0
     738: istore        7
     740: aload         5
     742: checkcast     #81                 // class java/util/Collection
     745: invokeinterface #204,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     750: ifne          757
     753: iconst_1
     754: goto          758
     757: iconst_0
     758: ifeq          1001
     761: aload         5
     763: invokevirtual #243                // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;
     766: checkcast     #146                // class day18/Point
     769: astore        8
     771: aload         6
     773: aload         8
     775: invokeinterface #207,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     780: ifeq          786
     783: goto          740
     786: aload         6
     788: checkcast     #81                 // class java/util/Collection
     791: aload         8
     793: invokeinterface #132,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     798: pop
     799: aload         8
     801: invokestatic  #197                // Method neighbors:(Lday18/Point;)Ljava/util/Set;
     804: invokeinterface #244,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     809: astore        9
     811: aload         9
     813: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     818: ifeq          740
     821: aload         9
     823: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     828: checkcast     #146                // class day18/Point
     831: astore        10
     833: aload         10
     835: invokevirtual #247                // Method day18/Point.component1:()I
     838: istore        11
     840: aload         10
     842: invokevirtual #250                // Method day18/Point.component2:()I
     845: istore        12
     847: aload         10
     849: invokevirtual #253                // Method day18/Point.component3:()I
     852: istore        13
     854: aload_1
     855: invokevirtual #233                // Method kotlin/ranges/IntRange.getFirst:()I
     858: istore        14
     860: iload         11
     862: aload_1
     863: invokevirtual #256                // Method kotlin/ranges/IntRange.getLast:()I
     866: if_icmpgt     884
     869: iload         14
     871: iload         11
     873: if_icmpgt     880
     876: iconst_1
     877: goto          885
     880: iconst_0
     881: goto          885
     884: iconst_0
     885: ifeq          811
     888: aload_2
     889: invokevirtual #233                // Method kotlin/ranges/IntRange.getFirst:()I
     892: istore        14
     894: iload         12
     896: aload_2
     897: invokevirtual #256                // Method kotlin/ranges/IntRange.getLast:()I
     900: if_icmpgt     918
     903: iload         14
     905: iload         12
     907: if_icmpgt     914
     910: iconst_1
     911: goto          919
     914: iconst_0
     915: goto          919
     918: iconst_0
     919: ifeq          811
     922: aload_3
     923: invokevirtual #233                // Method kotlin/ranges/IntRange.getFirst:()I
     926: istore        14
     928: iload         13
     930: aload_3
     931: invokevirtual #256                // Method kotlin/ranges/IntRange.getLast:()I
     934: if_icmpgt     952
     937: iload         14
     939: iload         13
     941: if_icmpgt     948
     944: iconst_1
     945: goto          953
     948: iconst_0
     949: goto          953
     952: iconst_0
     953: ifeq          811
     956: aload_0
     957: aload         10
     959: invokeinterface #207,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     964: ifeq          973
     967: iinc          7, 1
     970: goto          811
     973: aload         6
     975: aload         10
     977: invokeinterface #207,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     982: ifne          811
     985: aload         5
     987: checkcast     #81                 // class java/util/Collection
     990: aload         10
     992: invokeinterface #132,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     997: pop
     998: goto          811
    1001: iload         7
    1003: ireturn

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


package day20

import java.io.File

fun main() {
    val data = parse("src/main/kotlin/day20/Day20.txt")

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

    println("🎄 Day 20 🎄")

    println()

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

    println()

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

@Suppress("SameParameterValue")
private fun parse(path: String): List<Int> =
    File(path).readLines().map(String::toInt)

private fun solve(data: List<Int>, times: Int = 1, key: Long = 1L): Long {
    val numbers = data.map { it * key }
    val mixed = (0..data.lastIndex).toMutableList()
    repeat(times) {
        for ((i, number) in numbers.withIndex()) {
            val oldMixedIndex = mixed.indexOf(i)
            mixed.removeAt(oldMixedIndex)

            val newMixedIndex = (oldMixedIndex + number).mod(mixed.size)
            mixed.add(newMixedIndex, i)
        }
    }

    val zeroIndex = mixed.indexOf(data.indexOf(0))
    return listOf(1000, 2000, 3000).sumOf { offset ->
        numbers[mixed[(zeroIndex + offset) % mixed.size]]
    }
}

private fun part1(data: List<Int>): Long =
    solve(data)

private fun part2(data: List<Int>): Long =
    solve(data, times = 10, key = 811589153L)

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

  private static final java.util.List<java.lang.Integer> parse(java.lang.String);
    Code:
       0: new           #65                 // class java/io/File
       3: dup
       4: aload_0
       5: invokespecial #68                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       8: aconst_null
       9: iconst_1
      10: aconst_null
      11: invokestatic  #74                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      14: checkcast     #76                 // class java/lang/Iterable
      17: astore_1
      18: iconst_0
      19: istore_2
      20: aload_1
      21: astore_3
      22: new           #78                 // class java/util/ArrayList
      25: dup
      26: aload_1
      27: bipush        10
      29: invokestatic  #84                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      32: invokespecial #87                 // Method java/util/ArrayList."<init>":(I)V
      35: checkcast     #89                 // class java/util/Collection
      38: astore        4
      40: iconst_0
      41: istore        5
      43: aload_3
      44: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      49: astore        6
      51: aload         6
      53: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      58: ifeq          105
      61: aload         6
      63: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      68: astore        7
      70: aload         4
      72: aload         7
      74: checkcast     #105                // class java/lang/String
      77: astore        8
      79: astore        10
      81: iconst_0
      82: istore        9
      84: aload         8
      86: invokestatic  #111                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      89: nop
      90: invokestatic  #115                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      93: aload         10
      95: swap
      96: invokeinterface #119,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     101: pop
     102: goto          51
     105: aload         4
     107: checkcast     #121                // class java/util/List
     110: nop
     111: areturn

  private static final long solve(java.util.List<java.lang.Integer>, int, long);
    Code:
       0: aload_0
       1: checkcast     #76                 // class java/lang/Iterable
       4: astore        5
       6: iconst_0
       7: istore        6
       9: aload         5
      11: astore        7
      13: new           #78                 // class java/util/ArrayList
      16: dup
      17: aload         5
      19: bipush        10
      21: invokestatic  #84                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      24: invokespecial #87                 // Method java/util/ArrayList."<init>":(I)V
      27: checkcast     #89                 // class java/util/Collection
      30: astore        8
      32: iconst_0
      33: istore        9
      35: aload         7
      37: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        10
      44: aload         10
      46: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          100
      54: aload         10
      56: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        11
      63: aload         8
      65: aload         11
      67: checkcast     #140                // class java/lang/Number
      70: invokevirtual #144                // Method java/lang/Number.intValue:()I
      73: istore        12
      75: astore        22
      77: iconst_0
      78: istore        13
      80: iload         12
      82: i2l
      83: lload_2
      84: lmul
      85: invokestatic  #149                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      88: aload         22
      90: swap
      91: invokeinterface #119,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      96: pop
      97: goto          44
     100: aload         8
     102: checkcast     #121                // class java/util/List
     105: nop
     106: astore        4
     108: new           #151                // class kotlin/ranges/IntRange
     111: dup
     112: iconst_0
     113: aload_0
     114: invokestatic  #155                // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
     117: invokespecial #158                // Method kotlin/ranges/IntRange."<init>":(II)V
     120: checkcast     #76                 // class java/lang/Iterable
     123: invokestatic  #162                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/lang/Iterable;)Ljava/util/List;
     126: astore        5
     128: iconst_0
     129: istore        6
     131: iload         6
     133: iload_1
     134: if_icmpge     291
     137: iload         6
     139: istore        7
     141: iconst_0
     142: istore        8
     144: aload         4
     146: checkcast     #76                 // class java/lang/Iterable
     149: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     154: astore        9
     156: iconst_0
     157: istore        10
     159: aload         9
     161: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     166: ifeq          284
     169: iload         10
     171: istore        11
     173: iload         10
     175: iconst_1
     176: iadd
     177: istore        10
     179: aload         9
     181: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     186: checkcast     #140                // class java/lang/Number
     189: invokevirtual #166                // Method java/lang/Number.longValue:()J
     192: lstore        12
     194: aload         5
     196: iload         11
     198: invokestatic  #115                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     201: invokeinterface #170,  2          // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I
     206: istore        14
     208: aload         5
     210: iload         14
     212: invokeinterface #174,  2          // InterfaceMethod java/util/List.remove:(I)Ljava/lang/Object;
     217: pop
     218: iload         14
     220: i2l
     221: lload         12
     223: ladd
     224: lstore        15
     226: aload         5
     228: invokeinterface #177,  1          // InterfaceMethod java/util/List.size:()I
     233: i2l
     234: lstore        17
     236: lload         15
     238: lload         17
     240: lrem
     241: lstore        19
     243: lload         19
     245: lload         17
     247: lload         19
     249: lload         17
     251: lxor
     252: lload         19
     254: lload         19
     256: lneg
     257: lor
     258: land
     259: bipush        63
     261: lshr
     262: land
     263: ladd
     264: l2i
     265: istore        21
     267: aload         5
     269: iload         21
     271: iload         11
     273: invokestatic  #115                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     276: invokeinterface #180,  3          // InterfaceMethod java/util/List.add:(ILjava/lang/Object;)V
     281: goto          159
     284: nop
     285: iinc          6, 1
     288: goto          131
     291: aload         5
     293: aload_0
     294: iconst_0
     295: invokestatic  #115                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     298: invokeinterface #170,  2          // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I
     303: invokestatic  #115                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     306: invokeinterface #170,  2          // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I
     311: istore        6
     313: iconst_3
     314: anewarray     #107                // class java/lang/Integer
     317: astore        7
     319: aload         7
     321: iconst_0
     322: sipush        1000
     325: invokestatic  #115                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     328: aastore
     329: aload         7
     331: iconst_1
     332: sipush        2000
     335: invokestatic  #115                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     338: aastore
     339: aload         7
     341: iconst_2
     342: sipush        3000
     345: invokestatic  #115                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     348: aastore
     349: aload         7
     351: invokestatic  #184                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     354: checkcast     #76                 // class java/lang/Iterable
     357: astore        7
     359: lconst_0
     360: lstore        8
     362: aload         7
     364: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     369: astore        10
     371: aload         10
     373: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     378: ifeq          458
     381: aload         10
     383: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     388: astore        11
     390: lload         8
     392: aload         11
     394: checkcast     #140                // class java/lang/Number
     397: invokevirtual #144                // Method java/lang/Number.intValue:()I
     400: istore        12
     402: lstore        22
     404: iconst_0
     405: istore        13
     407: aload         4
     409: aload         5
     411: iload         6
     413: iload         12
     415: iadd
     416: aload         5
     418: invokeinterface #177,  1          // InterfaceMethod java/util/List.size:()I
     423: irem
     424: invokeinterface #187,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     429: checkcast     #140                // class java/lang/Number
     432: invokevirtual #144                // Method java/lang/Number.intValue:()I
     435: invokeinterface #187,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     440: checkcast     #140                // class java/lang/Number
     443: invokevirtual #166                // Method java/lang/Number.longValue:()J
     446: lstore        24
     448: lload         22
     450: lload         24
     452: ladd
     453: lstore        8
     455: goto          371
     458: lload         8
     460: lreturn

  static long solve$default(java.util.List, int, long, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_2
       3: iand
       4: ifeq          9
       7: iconst_1
       8: istore_1
       9: iload         4
      11: iconst_4
      12: iand
      13: ifeq          18
      16: lconst_1
      17: lstore_2
      18: aload_0
      19: iload_1
      20: lload_2
      21: invokestatic  #205                // Method solve:(Ljava/util/List;IJ)J
      24: lreturn

  private static final long part1(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: iconst_0
       2: lconst_0
       3: bipush        6
       5: aconst_null
       6: invokestatic  #208                // Method solve$default:(Ljava/util/List;IJILjava/lang/Object;)J
       9: lreturn

  private static final long part2(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: bipush        10
       3: ldc2_w        #209                // long 811589153l
       6: invokestatic  #205                // Method solve:(Ljava/util/List;IJ)J
       9: lreturn

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


package day16

import java.io.File

fun main() {
    val data = parse("src/main/kotlin/day16/Day16.txt")

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

    println("🎄 Day 16 🎄")

    println()

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

    println()

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

private data class Cave(
    val rates: Map<String, Int>,
    val edges: Map<String, List<String>>,
    val costs: Map<Pair<String, String>, Int>,
    val useful: Set<String>,
)

@Suppress("SameParameterValue")
private fun parse(path: String): Cave {
    val rates = mutableMapOf<String, Int>()
    val edges = mutableMapOf<String, List<String>>()
    val useful = mutableSetOf<String>()

    val pattern = Regex("""Valve (\w\w) has flow rate=(\d+); tunnels? leads? to valves? (.*)""")
    File(path).forEachLine { line ->
        val (name, rate, tunnels) = (pattern.matchEntire(line) ?: error("Couldn't parse: $line")).destructured
        rates[name] = rate.toInt()
        edges[name] = tunnels.split(", ")
        if (rate.toInt() != 0) {
            useful += name
        }
    }

    val costs = floydWarshall(edges)
    return Cave(rates, edges, costs, useful)
}

private fun floydWarshall(edges: Map<String, List<String>>): Map<Pair<String, String>, Int> {
    val nodes = edges.keys
    val costs = mutableMapOf<Pair<String, String>, Int>()

    for (source in nodes) {
        for (target in nodes) {
            costs[source to target] = nodes.size + 1
        }
    }
    for ((source, neighbors) in edges) {
        for (target in neighbors) {
            costs[source to target] = 1
        }
    }

    for (source in nodes) {
        costs[source to source] = 0
    }

    for (via in nodes) {
        for (source in nodes) {
            for (target in nodes) {
                if (costs[source to target]!! > costs[source to via]!! + costs[via to target]!!) {
                    costs[source to target] = costs[source to via]!! + costs[via to target]!!
                }
            }
        }
    }

    return costs
}

private fun Cave.dfs(
    source: String,
    minutesLeft: Int,
    candidates: Set<String> = useful,
    rate: Int = 0,
    pressure: Int = 0,
    elephantAllowed: Boolean = false,
): Int {
    var maxPressure = pressure + rate * minutesLeft

    // This solution is really slow and ugly, but I don't care ¯\_(ツ)_/¯
    if (elephantAllowed) {
        maxPressure += dfs(source = "AA", minutesLeft = 26, candidates = candidates, elephantAllowed = false)
    }

    for (target in candidates) {
        val cost = costs.getValue(source to target) + 1
        if (minutesLeft - cost <= 0) {
            continue
        }

        val newPressure = dfs(
            source = target,
            minutesLeft = minutesLeft - cost,
            candidates = candidates - target,
            rate = rate + rates.getValue(target),
            pressure = pressure + rate * cost,
            elephantAllowed = elephantAllowed
        )

        if (newPressure > maxPressure) {
            maxPressure = newPressure
        }
    }

    return maxPressure
}

private fun part1(cave: Cave): Int =
    cave.dfs(source = "AA", minutesLeft = 30)

private fun part2(cave: Cave): Int =
    cave.dfs(source = "AA", minutesLeft = 26, elephantAllowed = true)

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

  private static final day16.Cave parse(java.lang.String);
    Code:
       0: new           #64                 // class java/util/LinkedHashMap
       3: dup
       4: invokespecial #65                 // Method java/util/LinkedHashMap."<init>":()V
       7: checkcast     #67                 // class java/util/Map
      10: astore_1
      11: new           #64                 // class java/util/LinkedHashMap
      14: dup
      15: invokespecial #65                 // Method java/util/LinkedHashMap."<init>":()V
      18: checkcast     #67                 // class java/util/Map
      21: astore_2
      22: new           #69                 // class java/util/LinkedHashSet
      25: dup
      26: invokespecial #70                 // Method java/util/LinkedHashSet."<init>":()V
      29: checkcast     #72                 // class java/util/Set
      32: astore_3
      33: new           #74                 // class kotlin/text/Regex
      36: dup
      37: ldc           #76                 // String Valve (\\w\\w) has flow rate=(\\d+); tunnels? leads? to valves? (.*)
      39: invokespecial #79                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      42: astore        4
      44: new           #81                 // class java/io/File
      47: dup
      48: aload_0
      49: invokespecial #82                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      52: aconst_null
      53: aload         4
      55: aload_1
      56: aload_2
      57: aload_3
      58: invokedynamic #102,  0            // InvokeDynamic #0:invoke:(Lkotlin/text/Regex;Ljava/util/Map;Ljava/util/Map;Ljava/util/Set;)Lkotlin/jvm/functions/Function1;
      63: iconst_1
      64: aconst_null
      65: invokestatic  #108                // Method kotlin/io/FilesKt.forEachLine$default:(Ljava/io/File;Ljava/nio/charset/Charset;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
      68: aload_2
      69: invokestatic  #112                // Method floydWarshall:(Ljava/util/Map;)Ljava/util/Map;
      72: astore        5
      74: new           #114                // class day16/Cave
      77: dup
      78: aload_1
      79: aload_2
      80: aload         5
      82: aload_3
      83: invokespecial #117                // Method day16/Cave."<init>":(Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Set;)V
      86: areturn

  private static final java.util.Map<kotlin.Pair<java.lang.String, java.lang.String>, java.lang.Integer> floydWarshall(java.util.Map<java.lang.String, ? extends java.util.List<java.lang.String>>);
    Code:
       0: aload_0
       1: invokeinterface #132,  1          // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;
       6: astore_1
       7: new           #64                 // class java/util/LinkedHashMap
      10: dup
      11: invokespecial #65                 // Method java/util/LinkedHashMap."<init>":()V
      14: checkcast     #67                 // class java/util/Map
      17: astore_2
      18: aload_1
      19: invokeinterface #136,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
      24: astore_3
      25: aload_3
      26: invokeinterface #142,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      31: ifeq          103
      34: aload_3
      35: invokeinterface #146,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      40: checkcast     #148                // class java/lang/String
      43: astore        4
      45: aload_1
      46: invokeinterface #136,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
      51: astore        5
      53: aload         5
      55: invokeinterface #142,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      60: ifeq          25
      63: aload         5
      65: invokeinterface #146,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      70: checkcast     #148                // class java/lang/String
      73: astore        6
      75: aload_2
      76: aload         4
      78: aload         6
      80: invokestatic  #154                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      83: aload_1
      84: invokeinterface #158,  1          // InterfaceMethod java/util/Set.size:()I
      89: iconst_1
      90: iadd
      91: invokestatic  #164                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      94: invokeinterface #168,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      99: pop
     100: goto          53
     103: aload_0
     104: invokeinterface #171,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     109: invokeinterface #136,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     114: astore_3
     115: aload_3
     116: invokeinterface #142,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     121: ifeq          211
     124: aload_3
     125: invokeinterface #146,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     130: checkcast     #173                // class java/util/Map$Entry
     133: astore        4
     135: aload         4
     137: invokeinterface #176,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     142: checkcast     #148                // class java/lang/String
     145: astore        5
     147: aload         4
     149: invokeinterface #179,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     154: checkcast     #181                // class java/util/List
     157: astore        6
     159: aload         6
     161: invokeinterface #182,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     166: astore        7
     168: aload         7
     170: invokeinterface #142,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     175: ifeq          115
     178: aload         7
     180: invokeinterface #146,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     185: checkcast     #148                // class java/lang/String
     188: astore        8
     190: aload_2
     191: aload         5
     193: aload         8
     195: invokestatic  #154                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     198: iconst_1
     199: invokestatic  #164                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     202: invokeinterface #168,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     207: pop
     208: goto          168
     211: aload_1
     212: invokeinterface #136,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     217: astore_3
     218: aload_3
     219: invokeinterface #142,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     224: ifeq          259
     227: aload_3
     228: invokeinterface #146,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     233: checkcast     #148                // class java/lang/String
     236: astore        4
     238: aload_2
     239: aload         4
     241: aload         4
     243: invokestatic  #154                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     246: iconst_0
     247: invokestatic  #164                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     250: invokeinterface #168,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     255: pop
     256: goto          218
     259: aload_1
     260: invokeinterface #136,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     265: astore_3
     266: aload_3
     267: invokeinterface #142,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     272: ifeq          486
     275: aload_3
     276: invokeinterface #146,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     281: checkcast     #148                // class java/lang/String
     284: astore        4
     286: aload_1
     287: invokeinterface #136,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     292: astore        5
     294: aload         5
     296: invokeinterface #142,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     301: ifeq          266
     304: aload         5
     306: invokeinterface #146,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     311: checkcast     #148                // class java/lang/String
     314: astore        6
     316: aload_1
     317: invokeinterface #136,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     322: astore        7
     324: aload         7
     326: invokeinterface #142,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     331: ifeq          294
     334: aload         7
     336: invokeinterface #146,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     341: checkcast     #148                // class java/lang/String
     344: astore        8
     346: aload_2
     347: aload         6
     349: aload         8
     351: invokestatic  #154                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     354: invokeinterface #185,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     359: dup
     360: invokestatic  #190                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     363: checkcast     #192                // class java/lang/Number
     366: invokevirtual #195                // Method java/lang/Number.intValue:()I
     369: aload_2
     370: aload         6
     372: aload         4
     374: invokestatic  #154                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     377: invokeinterface #185,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     382: dup
     383: invokestatic  #190                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     386: checkcast     #192                // class java/lang/Number
     389: invokevirtual #195                // Method java/lang/Number.intValue:()I
     392: aload_2
     393: aload         4
     395: aload         8
     397: invokestatic  #154                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     400: invokeinterface #185,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     405: dup
     406: invokestatic  #190                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     409: checkcast     #192                // class java/lang/Number
     412: invokevirtual #195                // Method java/lang/Number.intValue:()I
     415: iadd
     416: if_icmple     324
     419: aload_2
     420: aload         6
     422: aload         8
     424: invokestatic  #154                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     427: aload_2
     428: aload         6
     430: aload         4
     432: invokestatic  #154                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     435: invokeinterface #185,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     440: dup
     441: invokestatic  #190                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     444: checkcast     #192                // class java/lang/Number
     447: invokevirtual #195                // Method java/lang/Number.intValue:()I
     450: aload_2
     451: aload         4
     453: aload         8
     455: invokestatic  #154                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     458: invokeinterface #185,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     463: dup
     464: invokestatic  #190                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     467: checkcast     #192                // class java/lang/Number
     470: invokevirtual #195                // Method java/lang/Number.intValue:()I
     473: iadd
     474: invokestatic  #164                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     477: invokeinterface #168,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     482: pop
     483: goto          324
     486: aload_2
     487: areturn

  private static final int dfs(day16.Cave, java.lang.String, int, java.util.Set<java.lang.String>, int, int, boolean);
    Code:
       0: iload         5
       2: iload         4
       4: iload_2
       5: imul
       6: iadd
       7: istore        7
       9: iload         6
      11: ifeq          34
      14: iload         7
      16: aload_0
      17: ldc           #206                // String AA
      19: bipush        26
      21: aload_3
      22: iconst_0
      23: iconst_0
      24: iconst_0
      25: bipush        24
      27: aconst_null
      28: invokestatic  #210                // Method dfs$default:(Lday16/Cave;Ljava/lang/String;ILjava/util/Set;IIZILjava/lang/Object;)I
      31: iadd
      32: istore        7
      34: aload_3
      35: invokeinterface #136,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
      40: astore        8
      42: aload         8
      44: invokeinterface #142,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      49: ifeq          157
      52: aload         8
      54: invokeinterface #146,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      59: checkcast     #148                // class java/lang/String
      62: astore        9
      64: aload_0
      65: invokevirtual #214                // Method day16/Cave.getCosts:()Ljava/util/Map;
      68: aload_1
      69: aload         9
      71: invokestatic  #154                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      74: invokestatic  #219                // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;
      77: checkcast     #192                // class java/lang/Number
      80: invokevirtual #195                // Method java/lang/Number.intValue:()I
      83: iconst_1
      84: iadd
      85: istore        10
      87: iload_2
      88: iload         10
      90: isub
      91: ifgt          97
      94: goto          42
      97: aload_0
      98: aload         9
     100: iload_2
     101: iload         10
     103: isub
     104: aload_3
     105: aload         9
     107: invokestatic  #225                // Method kotlin/collections/SetsKt.minus:(Ljava/util/Set;Ljava/lang/Object;)Ljava/util/Set;
     110: iload         4
     112: aload_0
     113: invokevirtual #228                // Method day16/Cave.getRates:()Ljava/util/Map;
     116: aload         9
     118: invokestatic  #219                // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;
     121: checkcast     #192                // class java/lang/Number
     124: invokevirtual #195                // Method java/lang/Number.intValue:()I
     127: iadd
     128: iload         5
     130: iload         4
     132: iload         10
     134: imul
     135: iadd
     136: iload         6
     138: invokestatic  #230                // Method dfs:(Lday16/Cave;Ljava/lang/String;ILjava/util/Set;IIZ)I
     141: istore        11
     143: iload         11
     145: iload         7
     147: if_icmple     42
     150: iload         11
     152: istore        7
     154: goto          42
     157: iload         7
     159: ireturn

  static int dfs$default(day16.Cave, java.lang.String, int, java.util.Set, int, int, boolean, int, java.lang.Object);
    Code:
       0: iload         7
       2: iconst_4
       3: iand
       4: ifeq          12
       7: aload_0
       8: invokevirtual #243                // Method day16/Cave.getUseful:()Ljava/util/Set;
      11: astore_3
      12: iload         7
      14: bipush        8
      16: iand
      17: ifeq          23
      20: iconst_0
      21: istore        4
      23: iload         7
      25: bipush        16
      27: iand
      28: ifeq          34
      31: iconst_0
      32: istore        5
      34: iload         7
      36: bipush        32
      38: iand
      39: ifeq          45
      42: iconst_0
      43: istore        6
      45: aload_0
      46: aload_1
      47: iload_2
      48: aload_3
      49: iload         4
      51: iload         5
      53: iload         6
      55: invokestatic  #230                // Method dfs:(Lday16/Cave;Ljava/lang/String;ILjava/util/Set;IIZ)I
      58: ireturn

  private static final int part1(day16.Cave);
    Code:
       0: aload_0
       1: ldc           #206                // String AA
       3: bipush        30
       5: aconst_null
       6: iconst_0
       7: iconst_0
       8: iconst_0
       9: bipush        60
      11: aconst_null
      12: invokestatic  #210                // Method dfs$default:(Lday16/Cave;Ljava/lang/String;ILjava/util/Set;IIZILjava/lang/Object;)I
      15: ireturn

  private static final int part2(day16.Cave);
    Code:
       0: aload_0
       1: ldc           #206                // String AA
       3: bipush        26
       5: aconst_null
       6: iconst_0
       7: iconst_0
       8: iconst_1
       9: bipush        28
      11: aconst_null
      12: invokestatic  #210                // Method dfs$default:(Lday16/Cave;Ljava/lang/String;ILjava/util/Set;IIZILjava/lang/Object;)I
      15: ireturn

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

  private static final kotlin.Unit parse$lambda$0(kotlin.text.Regex, java.util.Map, java.util.Map, java.util.Set, java.lang.String);
    Code:
       0: aload         4
       2: ldc           #251                // String line
       4: invokestatic  #255                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: aload         4
      10: checkcast     #257                // class java/lang/CharSequence
      13: invokevirtual #261                // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;
      16: dup
      17: ifnonnull     53
      20: pop
      21: new           #263                // class java/lang/IllegalStateException
      24: dup
      25: new           #39                 // class java/lang/StringBuilder
      28: dup
      29: invokespecial #42                 // Method java/lang/StringBuilder."<init>":()V
      32: ldc_w         #265                // String Couldn\'t parse:
      35: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      38: aload         4
      40: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      43: invokevirtual #55                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      46: invokevirtual #266                // Method java/lang/Object.toString:()Ljava/lang/String;
      49: invokespecial #267                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      52: athrow
      53: invokeinterface #273,  1          // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;
      58: astore        5
      60: aload         5
      62: invokevirtual #279                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
      65: invokeinterface #283,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
      70: iconst_1
      71: invokeinterface #286,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      76: checkcast     #148                // class java/lang/String
      79: astore        6
      81: aload         5
      83: invokevirtual #279                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
      86: invokeinterface #283,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
      91: iconst_2
      92: invokeinterface #286,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      97: checkcast     #148                // class java/lang/String
     100: astore        7
     102: aload         5
     104: invokevirtual #279                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     107: invokeinterface #283,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     112: iconst_3
     113: invokeinterface #286,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     118: checkcast     #148                // class java/lang/String
     121: astore        8
     123: nop
     124: aload_1
     125: aload         6
     127: aload         7
     129: invokestatic  #290                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     132: invokestatic  #164                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     135: invokeinterface #168,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     140: pop
     141: aload_2
     142: astore        9
     144: aload         8
     146: checkcast     #257                // class java/lang/CharSequence
     149: iconst_1
     150: anewarray     #148                // class java/lang/String
     153: astore        10
     155: aload         10
     157: iconst_0
     158: ldc_w         #292                // String ,
     161: aastore
     162: aload         10
     164: iconst_0
     165: iconst_0
     166: bipush        6
     168: aconst_null
     169: invokestatic  #298                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     172: astore        10
     174: aload         9
     176: aload         6
     178: aload         10
     180: invokeinterface #168,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     185: pop
     186: aload         7
     188: invokestatic  #290                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     191: ifeq          206
     194: aload_3
     195: checkcast     #300                // class java/util/Collection
     198: aload         6
     200: invokeinterface #304,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     205: pop
     206: getstatic     #310                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     209: areturn
}