package day12

import java.io.File

fun main() {
    val data = parse("src/main/kotlin/day12/Day12.txt")

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

    println("🎄 Day 12 🎄")

    println()

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

    println()

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

private typealias Label = String
private typealias Graph = Map<Label, List<Label>>

private fun parse(path: String): Graph {
    val graph = mutableMapOf<Label, List<Label>>()

    for (line in File(path).readLines()) {
        val (lhs, rhs) = line.split("-")
        graph.merge(lhs, listOf(rhs)) { a, b -> a + b }
        graph.merge(rhs, listOf(lhs)) { a, b -> a + b }
    }

    return graph
}

// Depth-first count of all possible paths from a node to the end of the graph.
// When bias is set to true, a single small cave is allowed to be visited twice.
private fun countPaths(
    graph: Graph,
    current: Label,
    visited: List<Label> = listOf(current),
    bias: Boolean = false
): Int =
    graph.getValue(current).sumOf { neighbour ->
        if (neighbour == "end") {
            1
        } else if (neighbour == "start") {
            0
        } else if (neighbour.all(Char::isLowerCase)) {
            if (!visited.contains(neighbour)) {
                countPaths(graph, neighbour, visited + neighbour, bias)
            } else if (bias) {
                countPaths(graph, neighbour, visited + neighbour)
            } else {
                0
            }
        } else {
            countPaths(graph, neighbour, visited + neighbour, bias)
        }
    }

fun part1(graph: Graph) =
    countPaths(graph, "start")

fun part2(graph: Graph) =
    countPaths(graph, "start", bias = true)

Compiled from "Day12.kt"
public final class day12.Day12Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String src/main/kotlin/day12/Day12.txt
       2: invokestatic  #12                 // Method parse:(Ljava/lang/String;)Ljava/util/Map;
       5: astore_0
       6: aload_0
       7: invokestatic  #16                 // Method part1:(Ljava/util/Map;)I
      10: istore_1
      11: aload_0
      12: invokestatic  #19                 // Method part2:(Ljava/util/Map;)I
      15: istore_2
      16: ldc           #21                 // String 🎄 Day 12 🎄
      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.Map<java.lang.String, java.util.List<java.lang.String>> parse(java.lang.String);
    Code:
       0: new           #65                 // class java/util/LinkedHashMap
       3: dup
       4: invokespecial #66                 // Method java/util/LinkedHashMap."<init>":()V
       7: checkcast     #68                 // class java/util/Map
      10: astore_1
      11: new           #70                 // class java/io/File
      14: dup
      15: aload_0
      16: invokespecial #73                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      19: aconst_null
      20: iconst_1
      21: aconst_null
      22: invokestatic  #79                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      25: invokeinterface #85,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      30: astore_2
      31: aload_2
      32: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      37: ifeq          155
      40: aload_2
      41: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      46: checkcast     #97                 // class java/lang/String
      49: astore_3
      50: aload_3
      51: checkcast     #99                 // class java/lang/CharSequence
      54: iconst_1
      55: anewarray     #97                 // class java/lang/String
      58: astore        5
      60: aload         5
      62: iconst_0
      63: ldc           #101                // String -
      65: aastore
      66: aload         5
      68: iconst_0
      69: iconst_0
      70: bipush        6
      72: aconst_null
      73: invokestatic  #107                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      76: astore        4
      78: aload         4
      80: iconst_0
      81: invokeinterface #111,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      86: checkcast     #97                 // class java/lang/String
      89: astore        5
      91: aload         4
      93: iconst_1
      94: invokeinterface #111,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      99: checkcast     #97                 // class java/lang/String
     102: astore        6
     104: aload_1
     105: aload         5
     107: aload         6
     109: invokestatic  #117                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     112: invokedynamic #136,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;
     117: invokedynamic #147,  0            // InvokeDynamic #1:apply:(Lkotlin/jvm/functions/Function2;)Ljava/util/function/BiFunction;
     122: invokeinterface #151,  4          // InterfaceMethod java/util/Map.merge:(Ljava/lang/Object;Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;
     127: pop
     128: aload_1
     129: aload         6
     131: aload         5
     133: invokestatic  #117                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     136: invokedynamic #156,  0            // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function2;
     141: invokedynamic #161,  0            // InvokeDynamic #3:apply:(Lkotlin/jvm/functions/Function2;)Ljava/util/function/BiFunction;
     146: invokeinterface #151,  4          // InterfaceMethod java/util/Map.merge:(Ljava/lang/Object;Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;
     151: pop
     152: goto          31
     155: aload_1
     156: areturn

  private static final int countPaths(java.util.Map<java.lang.String, ? extends java.util.List<java.lang.String>>, java.lang.String, java.util.List<java.lang.String>, boolean);
    Code:
       0: aload_0
       1: aload_1
       2: invokestatic  #176                // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;
       5: checkcast     #178                // class java/lang/Iterable
       8: astore        4
      10: iconst_0
      11: istore        5
      13: aload         4
      15: invokeinterface #179,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      20: astore        6
      22: aload         6
      24: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      29: ifeq          238
      32: aload         6
      34: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      39: astore        7
      41: iload         5
      43: aload         7
      45: checkcast     #97                 // class java/lang/String
      48: astore        8
      50: istore        16
      52: iconst_0
      53: istore        9
      55: aload         8
      57: ldc           #181                // String end
      59: invokestatic  #187                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      62: ifeq          69
      65: iconst_1
      66: goto          225
      69: aload         8
      71: ldc           #189                // String start
      73: invokestatic  #187                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      76: ifeq          83
      79: iconst_0
      80: goto          225
      83: aload         8
      85: checkcast     #99                 // class java/lang/CharSequence
      88: astore        10
      90: iconst_0
      91: istore        11
      93: iconst_0
      94: istore        12
      96: iload         12
      98: aload         10
     100: invokeinterface #193,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     105: if_icmpge     145
     108: aload         10
     110: iload         12
     112: invokeinterface #197,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     117: istore        13
     119: iload         13
     121: istore        14
     123: iconst_0
     124: istore        15
     126: iload         14
     128: invokestatic  #203                // Method java/lang/Character.isLowerCase:(C)Z
     131: nop
     132: ifne          139
     135: iconst_0
     136: goto          146
     139: iinc          12, 1
     142: goto          96
     145: iconst_1
     146: ifeq          209
     149: aload_2
     150: aload         8
     152: invokeinterface #207,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     157: ifne          179
     160: aload_0
     161: aload         8
     163: aload_2
     164: checkcast     #209                // class java/util/Collection
     167: aload         8
     169: invokestatic  #213                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     172: iload_3
     173: invokestatic  #215                // Method countPaths:(Ljava/util/Map;Ljava/lang/String;Ljava/util/List;Z)I
     176: goto          225
     179: iload_3
     180: ifeq          205
     183: aload_0
     184: aload         8
     186: aload_2
     187: checkcast     #209                // class java/util/Collection
     190: aload         8
     192: invokestatic  #213                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     195: iconst_0
     196: bipush        8
     198: aconst_null
     199: invokestatic  #219                // Method countPaths$default:(Ljava/util/Map;Ljava/lang/String;Ljava/util/List;ZILjava/lang/Object;)I
     202: goto          225
     205: iconst_0
     206: goto          225
     209: aload_0
     210: aload         8
     212: aload_2
     213: checkcast     #209                // class java/util/Collection
     216: aload         8
     218: invokestatic  #213                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     221: iload_3
     222: invokestatic  #215                // Method countPaths:(Ljava/util/Map;Ljava/lang/String;Ljava/util/List;Z)I
     225: nop
     226: istore        17
     228: iload         16
     230: iload         17
     232: iadd
     233: istore        5
     235: goto          22
     238: iload         5
     240: ireturn

  static int countPaths$default(java.util.Map, java.lang.String, java.util.List, boolean, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_4
       3: iand
       4: ifeq          12
       7: aload_1
       8: invokestatic  #117                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      11: astore_2
      12: iload         4
      14: bipush        8
      16: iand
      17: ifeq          22
      20: iconst_0
      21: istore_3
      22: aload_0
      23: aload_1
      24: aload_2
      25: iload_3
      26: invokestatic  #215                // Method countPaths:(Ljava/util/Map;Ljava/lang/String;Ljava/util/List;Z)I
      29: ireturn

  public static final int part1(java.util.Map<java.lang.String, ? extends java.util.List<java.lang.String>>);
    Code:
       0: aload_0
       1: ldc           #236                // String graph
       3: invokestatic  #240                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: ldc           #189                // String start
       9: aconst_null
      10: iconst_0
      11: bipush        12
      13: aconst_null
      14: invokestatic  #219                // Method countPaths$default:(Ljava/util/Map;Ljava/lang/String;Ljava/util/List;ZILjava/lang/Object;)I
      17: ireturn

  public static final int part2(java.util.Map<java.lang.String, ? extends java.util.List<java.lang.String>>);
    Code:
       0: aload_0
       1: ldc           #236                // String graph
       3: invokestatic  #240                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: ldc           #189                // String start
       9: aconst_null
      10: iconst_1
      11: iconst_4
      12: aconst_null
      13: invokestatic  #219                // Method countPaths$default:(Ljava/util/Map;Ljava/lang/String;Ljava/util/List;ZILjava/lang/Object;)I
      16: ireturn

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

  private static final java.util.List parse$lambda$0(java.util.List, java.util.List);
    Code:
       0: aload_0
       1: ldc           #247                // String a
       3: invokestatic  #240                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #249                // String b
       9: invokestatic  #240                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: checkcast     #209                // class java/util/Collection
      16: aload_1
      17: checkcast     #178                // class java/lang/Iterable
      20: invokestatic  #252                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
      23: areturn

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

  private static final java.util.List parse$lambda$2(java.util.List, java.util.List);
    Code:
       0: aload_0
       1: ldc           #247                // String a
       3: invokestatic  #240                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #249                // String b
       9: invokestatic  #240                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: checkcast     #209                // class java/util/Collection
      16: aload_1
      17: checkcast     #178                // class java/lang/Iterable
      20: invokestatic  #252                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
      23: areturn

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


package day15

import java.io.File
import java.util.*

fun main() {
    val data = parse("src/main/kotlin/day15/Day15.txt")

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

    println("🎄 Day 15 🎄")

    println()

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

    println()

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

private data class Graph(
    val size: Int,
    val vertices: List<Int>,
)

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

private data class Path(
    val target: Vertex,
    val distance: Int,
) : Comparable<Path> {

    override fun compareTo(other: Path): Int =
        distance.compareTo(other.distance)
}

private fun parse(path: String): Graph {
    val lines = File(path).readLines()

    val size = lines.size
    val nodes = lines.flatMap { line ->
        line.map(Char::digitToInt)
    }

    return Graph(size, nodes)
}

private fun Graph.distanceAt(vertex: Vertex): Int {
    val dx = vertex.x / size
    val dy = vertex.y / size

    val px = vertex.x % size
    val py = vertex.y % size

    val combinedCost = vertices[py * size + px] + dx + dy
    return (combinedCost - 1) % 9 + 1
}

private fun Vertex.edges(target: Vertex): List<Vertex> =
    listOfNotNull(
        if (x - 1 > 0)         Vertex(x - 1, y) else null,
        if (x + 1 <= target.x) Vertex(x + 1, y) else null,
        if (y - 1 > 0)         Vertex(x, y - 1) else null,
        if (y + 1 <= target.y) Vertex(x, y + 1) else null,
    )

private fun findPath(graph: Graph, target: Vertex): Int {
    val source = Vertex(0, 0)

    val distances = mutableMapOf(source to 0)
    val frontier = PriorityQueue<Path>()
        .apply { add(Path(target = source, distance = 0)) }

    while (frontier.isNotEmpty()) {
        val (vertex, distance) = frontier.poll()
        if (vertex == target) {
            return distance
        }

        if (distance > distances.getValue(vertex)) continue
        for (edge in vertex.edges(target)) {
            val distanceToEdge = distance + graph.distanceAt(edge)
            if (distanceToEdge < distances.getOrDefault(edge, Int.MAX_VALUE)) {
                distances[edge] = distanceToEdge
                frontier.add(Path(edge, distanceToEdge))
            }
        }
    }

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

private fun part1(graph: Graph): Int =
    findPath(graph, target = Vertex(graph.size - 1, graph.size - 1))

private fun part2(graph: Graph): Int =
    findPath(graph, target = Vertex(graph.size * 5 - 1, graph.size * 5 - 1))

Compiled from "Day15.kt"
public final class day15.Day15Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String src/main/kotlin/day15/Day15.txt
       2: invokestatic  #12                 // Method parse:(Ljava/lang/String;)Lday15/Graph;
       5: astore_0
       6: aload_0
       7: invokestatic  #16                 // Method part1:(Lday15/Graph;)I
      10: istore_1
      11: aload_0
      12: invokestatic  #19                 // Method part2:(Lday15/Graph;)I
      15: istore_2
      16: ldc           #21                 // String 🎄 Day 15 🎄
      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 day15.Graph parse(java.lang.String);
    Code:
       0: new           #64                 // class java/io/File
       3: dup
       4: aload_0
       5: invokespecial #67                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       8: aconst_null
       9: iconst_1
      10: aconst_null
      11: invokestatic  #73                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      14: astore_1
      15: aload_1
      16: invokeinterface #79,  1           // InterfaceMethod java/util/List.size:()I
      21: istore_2
      22: aload_1
      23: checkcast     #81                 // class java/lang/Iterable
      26: astore        4
      28: iconst_0
      29: istore        5
      31: aload         4
      33: astore        6
      35: new           #83                 // class java/util/ArrayList
      38: dup
      39: invokespecial #84                 // Method java/util/ArrayList."<init>":()V
      42: checkcast     #86                 // class java/util/Collection
      45: astore        7
      47: iconst_0
      48: istore        8
      50: aload         6
      52: invokeinterface #90,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      57: astore        9
      59: aload         9
      61: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      66: ifeq          207
      69: aload         9
      71: invokeinterface #100,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      76: astore        10
      78: aload         10
      80: checkcast     #102                // class java/lang/String
      83: astore        11
      85: iconst_0
      86: istore        12
      88: aload         11
      90: checkcast     #104                // class java/lang/CharSequence
      93: astore        13
      95: iconst_0
      96: istore        14
      98: aload         13
     100: astore        15
     102: new           #83                 // class java/util/ArrayList
     105: dup
     106: aload         13
     108: invokeinterface #107,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     113: invokespecial #110                // Method java/util/ArrayList."<init>":(I)V
     116: checkcast     #86                 // class java/util/Collection
     119: astore        16
     121: iconst_0
     122: istore        17
     124: iconst_0
     125: istore        18
     127: iload         18
     129: aload         15
     131: invokeinterface #107,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     136: if_icmpge     184
     139: aload         15
     141: iload         18
     143: invokeinterface #114,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     148: istore        19
     150: aload         16
     152: iload         19
     154: istore        20
     156: astore        21
     158: iconst_0
     159: istore        22
     161: iload         20
     163: invokestatic  #120                // Method kotlin/text/CharsKt.digitToInt:(C)I
     166: invokestatic  #126                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     169: aload         21
     171: swap
     172: invokeinterface #130,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     177: pop
     178: iinc          18, 1
     181: goto          127
     184: aload         16
     186: checkcast     #75                 // class java/util/List
     189: nop
     190: checkcast     #81                 // class java/lang/Iterable
     193: nop
     194: astore        11
     196: aload         7
     198: aload         11
     200: invokestatic  #136                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     203: pop
     204: goto          59
     207: aload         7
     209: checkcast     #75                 // class java/util/List
     212: nop
     213: astore_3
     214: new           #138                // class day15/Graph
     217: dup
     218: iload_2
     219: aload_3
     220: invokespecial #141                // Method day15/Graph."<init>":(ILjava/util/List;)V
     223: areturn

  private static final int distanceAt(day15.Graph, day15.Vertex);
    Code:
       0: aload_1
       1: invokevirtual #174                // Method day15/Vertex.getX:()I
       4: aload_0
       5: invokevirtual #177                // Method day15/Graph.getSize:()I
       8: idiv
       9: istore_2
      10: aload_1
      11: invokevirtual #180                // Method day15/Vertex.getY:()I
      14: aload_0
      15: invokevirtual #177                // Method day15/Graph.getSize:()I
      18: idiv
      19: istore_3
      20: aload_1
      21: invokevirtual #174                // Method day15/Vertex.getX:()I
      24: aload_0
      25: invokevirtual #177                // Method day15/Graph.getSize:()I
      28: irem
      29: istore        4
      31: aload_1
      32: invokevirtual #180                // Method day15/Vertex.getY:()I
      35: aload_0
      36: invokevirtual #177                // Method day15/Graph.getSize:()I
      39: irem
      40: istore        5
      42: aload_0
      43: invokevirtual #184                // Method day15/Graph.getVertices:()Ljava/util/List;
      46: iload         5
      48: aload_0
      49: invokevirtual #177                // Method day15/Graph.getSize:()I
      52: imul
      53: iload         4
      55: iadd
      56: invokeinterface #188,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      61: checkcast     #190                // class java/lang/Number
      64: invokevirtual #193                // Method java/lang/Number.intValue:()I
      67: iload_2
      68: iadd
      69: iload_3
      70: iadd
      71: istore        6
      73: iload         6
      75: iconst_1
      76: isub
      77: bipush        9
      79: irem
      80: iconst_1
      81: iadd
      82: ireturn

  private static final java.util.List<day15.Vertex> edges(day15.Vertex, day15.Vertex);
    Code:
       0: iconst_4
       1: anewarray     #171                // class day15/Vertex
       4: astore_2
       5: aload_2
       6: iconst_0
       7: aload_0
       8: invokevirtual #174                // Method day15/Vertex.getX:()I
      11: iconst_1
      12: isub
      13: ifle          36
      16: new           #171                // class day15/Vertex
      19: dup
      20: aload_0
      21: invokevirtual #174                // Method day15/Vertex.getX:()I
      24: iconst_1
      25: isub
      26: aload_0
      27: invokevirtual #180                // Method day15/Vertex.getY:()I
      30: invokespecial #207                // Method day15/Vertex."<init>":(II)V
      33: goto          37
      36: aconst_null
      37: aastore
      38: aload_2
      39: iconst_1
      40: aload_0
      41: invokevirtual #174                // Method day15/Vertex.getX:()I
      44: iconst_1
      45: iadd
      46: aload_1
      47: invokevirtual #174                // Method day15/Vertex.getX:()I
      50: if_icmpgt     73
      53: new           #171                // class day15/Vertex
      56: dup
      57: aload_0
      58: invokevirtual #174                // Method day15/Vertex.getX:()I
      61: iconst_1
      62: iadd
      63: aload_0
      64: invokevirtual #180                // Method day15/Vertex.getY:()I
      67: invokespecial #207                // Method day15/Vertex."<init>":(II)V
      70: goto          74
      73: aconst_null
      74: aastore
      75: aload_2
      76: iconst_2
      77: aload_0
      78: invokevirtual #180                // Method day15/Vertex.getY:()I
      81: iconst_1
      82: isub
      83: ifle          106
      86: new           #171                // class day15/Vertex
      89: dup
      90: aload_0
      91: invokevirtual #174                // Method day15/Vertex.getX:()I
      94: aload_0
      95: invokevirtual #180                // Method day15/Vertex.getY:()I
      98: iconst_1
      99: isub
     100: invokespecial #207                // Method day15/Vertex."<init>":(II)V
     103: goto          107
     106: aconst_null
     107: aastore
     108: aload_2
     109: iconst_3
     110: aload_0
     111: invokevirtual #180                // Method day15/Vertex.getY:()I
     114: iconst_1
     115: iadd
     116: aload_1
     117: invokevirtual #180                // Method day15/Vertex.getY:()I
     120: if_icmpgt     143
     123: new           #171                // class day15/Vertex
     126: dup
     127: aload_0
     128: invokevirtual #174                // Method day15/Vertex.getX:()I
     131: aload_0
     132: invokevirtual #180                // Method day15/Vertex.getY:()I
     135: iconst_1
     136: iadd
     137: invokespecial #207                // Method day15/Vertex."<init>":(II)V
     140: goto          144
     143: aconst_null
     144: aastore
     145: aload_2
     146: invokestatic  #211                // Method kotlin/collections/CollectionsKt.listOfNotNull:([Ljava/lang/Object;)Ljava/util/List;
     149: areturn

  private static final int findPath(day15.Graph, day15.Vertex);
    Code:
       0: new           #171                // class day15/Vertex
       3: dup
       4: iconst_0
       5: iconst_0
       6: invokespecial #207                // Method day15/Vertex."<init>":(II)V
       9: astore_2
      10: iconst_1
      11: anewarray     #218                // class kotlin/Pair
      14: astore        4
      16: aload         4
      18: iconst_0
      19: aload_2
      20: iconst_0
      21: invokestatic  #126                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      24: invokestatic  #224                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      27: aastore
      28: aload         4
      30: invokestatic  #230                // Method kotlin/collections/MapsKt.mutableMapOf:([Lkotlin/Pair;)Ljava/util/Map;
      33: astore_3
      34: new           #232                // class java/util/PriorityQueue
      37: dup
      38: invokespecial #233                // Method java/util/PriorityQueue."<init>":()V
      41: astore        5
      43: aload         5
      45: astore        6
      47: iconst_0
      48: istore        7
      50: aload         6
      52: new           #235                // class day15/Path
      55: dup
      56: aload_2
      57: iconst_0
      58: invokespecial #238                // Method day15/Path."<init>":(Lday15/Vertex;I)V
      61: invokevirtual #239                // Method java/util/PriorityQueue.add:(Ljava/lang/Object;)Z
      64: pop
      65: aload         5
      67: astore        4
      69: aload         4
      71: checkcast     #86                 // class java/util/Collection
      74: invokeinterface #242,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      79: ifne          86
      82: iconst_1
      83: goto          87
      86: iconst_0
      87: ifeq          252
      90: aload         4
      92: invokevirtual #245                // Method java/util/PriorityQueue.poll:()Ljava/lang/Object;
      95: checkcast     #235                // class day15/Path
      98: astore        5
     100: aload         5
     102: invokevirtual #249                // Method day15/Path.component1:()Lday15/Vertex;
     105: astore        6
     107: aload         5
     109: invokevirtual #252                // Method day15/Path.component2:()I
     112: istore        7
     114: aload         6
     116: aload_1
     117: invokestatic  #258                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     120: ifeq          126
     123: iload         7
     125: ireturn
     126: iload         7
     128: aload_3
     129: aload         6
     131: invokestatic  #262                // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;
     134: checkcast     #190                // class java/lang/Number
     137: invokevirtual #193                // Method java/lang/Number.intValue:()I
     140: if_icmpgt     69
     143: aload         6
     145: aload_1
     146: invokestatic  #264                // Method edges:(Lday15/Vertex;Lday15/Vertex;)Ljava/util/List;
     149: invokeinterface #265,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     154: astore        8
     156: aload         8
     158: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     163: ifeq          69
     166: aload         8
     168: invokeinterface #100,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     173: checkcast     #171                // class day15/Vertex
     176: astore        9
     178: iload         7
     180: aload_0
     181: aload         9
     183: invokestatic  #267                // Method distanceAt:(Lday15/Graph;Lday15/Vertex;)I
     186: iadd
     187: istore        10
     189: iload         10
     191: aload_3
     192: aload         9
     194: ldc_w         #268                // int 2147483647
     197: invokestatic  #126                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     200: invokeinterface #274,  3          // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     205: checkcast     #190                // class java/lang/Number
     208: invokevirtual #193                // Method java/lang/Number.intValue:()I
     211: if_icmpge     156
     214: iload         10
     216: invokestatic  #126                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     219: astore        11
     221: aload_3
     222: aload         9
     224: aload         11
     226: invokeinterface #277,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     231: pop
     232: aload         4
     234: new           #235                // class day15/Path
     237: dup
     238: aload         9
     240: iload         10
     242: invokespecial #238                // Method day15/Path."<init>":(Lday15/Vertex;I)V
     245: invokevirtual #239                // Method java/util/PriorityQueue.add:(Ljava/lang/Object;)Z
     248: pop
     249: goto          156
     252: new           #279                // class java/lang/IllegalStateException
     255: dup
     256: ldc_w         #281                // String Could not find the shortest path.
     259: invokevirtual #282                // Method java/lang/Object.toString:()Ljava/lang/String;
     262: invokespecial #283                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     265: athrow

  private static final int part1(day15.Graph);
    Code:
       0: aload_0
       1: new           #171                // class day15/Vertex
       4: dup
       5: aload_0
       6: invokevirtual #177                // Method day15/Graph.getSize:()I
       9: iconst_1
      10: isub
      11: aload_0
      12: invokevirtual #177                // Method day15/Graph.getSize:()I
      15: iconst_1
      16: isub
      17: invokespecial #207                // Method day15/Vertex."<init>":(II)V
      20: invokestatic  #296                // Method findPath:(Lday15/Graph;Lday15/Vertex;)I
      23: ireturn

  private static final int part2(day15.Graph);
    Code:
       0: aload_0
       1: new           #171                // class day15/Vertex
       4: dup
       5: aload_0
       6: invokevirtual #177                // Method day15/Graph.getSize:()I
       9: iconst_5
      10: imul
      11: iconst_1
      12: isub
      13: aload_0
      14: invokevirtual #177                // Method day15/Graph.getSize:()I
      17: iconst_5
      18: imul
      19: iconst_1
      20: isub
      21: invokespecial #207                // Method day15/Vertex."<init>":(II)V
      24: invokestatic  #296                // Method findPath:(Lday15/Graph;Lday15/Vertex;)I
      27: ireturn

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


package day14

import java.io.File

fun main() {
    val (template, rules) = parse("src/main/kotlin/day14/Day14.txt")

    val answer1 = part1(template, rules)
    val answer2 = part2(template, rules)

    println("🎄 Day 14 🎄")

    println()

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

    println()

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

private typealias Template = String
private typealias Rules = Map<String, Char>

private fun parse(path: String): Pair<Template, Rules> {
    val (template, rulesPart) = File(path)
        .readText()
        .trim()
        .split("""(\n\n)|(\r\n\r\n)""".toRegex())

    val rules = rulesPart
        .lines()
        .associate(String::toRule)

    return template to rules
}

private fun String.toRule() =
    this.split(" -> ")
        .let { (match, element) -> match to element.first() }

private fun expand(template: Template, rules: Rules, iterations: Int): Long {
    val frequencies = template
        .groupingBy { it }
        .eachCount()
        .mapValuesTo(mutableMapOf()) { (_, v) -> v.toLong() }

    var patterns = template
        .zipWithNext { a, b -> "$a$b" }
        .groupingBy { it }
        .eachCount()
        .mapValues { (_, v) -> v.toLong() }

    repeat(iterations) {
        val next = mutableMapOf<String, Long>()
        for ((pattern, count) in patterns) {
            val element = rules.getValue(pattern)

            val lhs = "${pattern[0]}$element"
            val rhs = "$element${pattern[1]}"

            next.merge(lhs, count, Long::plus)
            next.merge(rhs, count, Long::plus)

            frequencies.merge(element, count, Long::plus)
        }
        patterns = next
    }

    val max = frequencies.maxOf { it.value }
    val min = frequencies.minOf { it.value }
    return max - min
}

private fun part1(template: Template, rules: Rules) =
    expand(template, rules, iterations = 10)

private fun part2(template: Template, rules: Rules) =
    expand(template, rules, iterations = 40)

Compiled from "Day14.kt"
final class day14.Day14Kt$expand$1$3 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<java.lang.Long, java.lang.Long, java.lang.Long> {
  public static final day14.Day14Kt$expand$1$3 INSTANCE;

  day14.Day14Kt$expand$1$3();
    Code:
       0: aload_0
       1: iconst_2
       2: getstatic     #15                 // Field java/lang/Long.TYPE:Ljava/lang/Class;
       5: ldc           #17                 // String plus
       7: ldc           #19                 // String plus(J)J
       9: iconst_0
      10: invokespecial #22                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      13: return

  public final java.lang.Long invoke(long, long);
    Code:
       0: lload_1
       1: lload_3
       2: ladd
       3: invokestatic  #30                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
       6: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #36                 // class java/lang/Number
       5: invokevirtual #40                 // Method java/lang/Number.longValue:()J
       8: aload_2
       9: checkcast     #36                 // class java/lang/Number
      12: invokevirtual #40                 // Method java/lang/Number.longValue:()J
      15: invokevirtual #42                 // Method invoke:(JJ)Ljava/lang/Long;
      18: areturn

  static {};
    Code:
       0: new           #2                  // class day14/Day14Kt$expand$1$3
       3: dup
       4: invokespecial #47                 // Method "<init>":()V
       7: putstatic     #50                 // Field INSTANCE:Lday14/Day14Kt$expand$1$3;
      10: return
}

Compiled from "Day14.kt"
public final class day14.Day14Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String src/main/kotlin/day14/Day14.txt
       2: invokestatic  #12                 // Method parse:(Ljava/lang/String;)Lkotlin/Pair;
       5: astore_0
       6: aload_0
       7: invokevirtual #18                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
      10: checkcast     #20                 // class java/lang/String
      13: astore_1
      14: aload_0
      15: invokevirtual #23                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
      18: checkcast     #25                 // class java/util/Map
      21: astore_2
      22: aload_1
      23: aload_2
      24: invokestatic  #29                 // Method part1:(Ljava/lang/String;Ljava/util/Map;)J
      27: lstore_3
      28: aload_1
      29: aload_2
      30: invokestatic  #32                 // Method part2:(Ljava/lang/String;Ljava/util/Map;)J
      33: lstore        5
      35: ldc           #34                 // String 🎄 Day 14 🎄
      37: getstatic     #40                 // Field java/lang/System.out:Ljava/io/PrintStream;
      40: swap
      41: invokevirtual #46                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      44: getstatic     #40                 // Field java/lang/System.out:Ljava/io/PrintStream;
      47: invokevirtual #48                 // Method java/io/PrintStream.println:()V
      50: ldc           #50                 // String [Part 1]
      52: getstatic     #40                 // Field java/lang/System.out:Ljava/io/PrintStream;
      55: swap
      56: invokevirtual #46                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      59: new           #52                 // class java/lang/StringBuilder
      62: dup
      63: invokespecial #55                 // Method java/lang/StringBuilder."<init>":()V
      66: ldc           #57                 // String Answer:
      68: invokevirtual #61                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      71: lload_3
      72: invokevirtual #64                 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
      75: invokevirtual #68                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      78: getstatic     #40                 // Field java/lang/System.out:Ljava/io/PrintStream;
      81: swap
      82: invokevirtual #46                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      85: getstatic     #40                 // Field java/lang/System.out:Ljava/io/PrintStream;
      88: invokevirtual #48                 // Method java/io/PrintStream.println:()V
      91: ldc           #70                 // String [Part 2]
      93: getstatic     #40                 // Field java/lang/System.out:Ljava/io/PrintStream;
      96: swap
      97: invokevirtual #46                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     100: new           #52                 // class java/lang/StringBuilder
     103: dup
     104: invokespecial #55                 // Method java/lang/StringBuilder."<init>":()V
     107: ldc           #57                 // String Answer:
     109: invokevirtual #61                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     112: lload         5
     114: invokevirtual #64                 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     117: invokevirtual #68                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     120: getstatic     #40                 // Field java/lang/System.out:Ljava/io/PrintStream;
     123: swap
     124: invokevirtual #46                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     127: return

  private static final kotlin.Pair<java.lang.String, java.util.Map<java.lang.String, java.lang.Character>> parse(java.lang.String);
    Code:
       0: nop
       1: new           #80                 // class java/io/File
       4: dup
       5: aload_0
       6: invokespecial #83                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #89                 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
      15: checkcast     #91                 // class java/lang/CharSequence
      18: invokestatic  #97                 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      21: invokevirtual #98                 // Method java/lang/Object.toString:()Ljava/lang/String;
      24: checkcast     #91                 // class java/lang/CharSequence
      27: astore_2
      28: new           #100                // class kotlin/text/Regex
      31: dup
      32: ldc           #102                // String (\\n\\n)|(\\r\\n\\r\\n)
      34: invokespecial #103                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      37: astore_3
      38: iconst_0
      39: istore        4
      41: aload_3
      42: aload_2
      43: iload         4
      45: invokevirtual #107                // Method kotlin/text/Regex.split:(Ljava/lang/CharSequence;I)Ljava/util/List;
      48: astore_1
      49: aload_1
      50: iconst_0
      51: invokeinterface #113,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      56: checkcast     #20                 // class java/lang/String
      59: astore_2
      60: aload_1
      61: iconst_1
      62: invokeinterface #113,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      67: checkcast     #20                 // class java/lang/String
      70: astore_3
      71: aload_3
      72: checkcast     #91                 // class java/lang/CharSequence
      75: invokestatic  #117                // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;
      78: checkcast     #119                // class java/lang/Iterable
      81: astore        5
      83: nop
      84: iconst_0
      85: istore        6
      87: aload         5
      89: bipush        10
      91: invokestatic  #125                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      94: invokestatic  #131                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
      97: bipush        16
      99: invokestatic  #137                // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I
     102: istore        7
     104: aload         5
     106: astore        8
     108: new           #139                // class java/util/LinkedHashMap
     111: dup
     112: iload         7
     114: invokespecial #142                // Method java/util/LinkedHashMap."<init>":(I)V
     117: checkcast     #25                 // class java/util/Map
     120: astore        9
     122: iconst_0
     123: istore        10
     125: aload         8
     127: invokeinterface #146,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     132: astore        11
     134: aload         11
     136: invokeinterface #152,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     141: ifeq          195
     144: aload         11
     146: invokeinterface #155,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     151: astore        12
     153: aload         9
     155: astore        13
     157: aload         12
     159: checkcast     #20                 // class java/lang/String
     162: astore        14
     164: iconst_0
     165: istore        15
     167: aload         14
     169: invokestatic  #158                // Method toRule:(Ljava/lang/String;)Lkotlin/Pair;
     172: astore        14
     174: aload         13
     176: aload         14
     178: invokevirtual #161                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     181: aload         14
     183: invokevirtual #164                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     186: invokeinterface #168,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     191: pop
     192: goto          134
     195: aload         9
     197: nop
     198: astore        4
     200: aload_2
     201: aload         4
     203: invokestatic  #174                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     206: areturn

  private static final kotlin.Pair<java.lang.String, java.lang.Character> toRule(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #91                 // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #20                 // class java/lang/String
       8: astore_1
       9: aload_1
      10: iconst_0
      11: ldc           #191                // String  ->
      13: aastore
      14: aload_1
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #195                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: astore_2
      24: iconst_0
      25: istore_3
      26: aload_2
      27: iconst_0
      28: invokeinterface #113,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      33: checkcast     #20                 // class java/lang/String
      36: astore        4
      38: aload_2
      39: iconst_1
      40: invokeinterface #113,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      45: checkcast     #20                 // class java/lang/String
      48: astore        5
      50: aload         4
      52: aload         5
      54: checkcast     #91                 // class java/lang/CharSequence
      57: invokestatic  #199                // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C
      60: invokestatic  #205                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      63: invokestatic  #174                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      66: nop
      67: areturn

  private static final long expand(java.lang.String, java.util.Map<java.lang.String, java.lang.Character>, int);
    Code:
       0: aload_0
       1: checkcast     #91                 // class java/lang/CharSequence
       4: astore        4
       6: nop
       7: iconst_0
       8: istore        5
      10: new           #214                // class day14/Day14Kt$expand$$inlined$groupingBy$1
      13: dup
      14: aload         4
      16: invokespecial #217                // Method day14/Day14Kt$expand$$inlined$groupingBy$1."<init>":(Ljava/lang/CharSequence;)V
      19: checkcast     #219                // class kotlin/collections/Grouping
      22: invokestatic  #225                // Method kotlin/collections/GroupingKt.eachCount:(Lkotlin/collections/Grouping;)Ljava/util/Map;
      25: astore        4
      27: new           #139                // class java/util/LinkedHashMap
      30: dup
      31: invokespecial #226                // Method java/util/LinkedHashMap."<init>":()V
      34: checkcast     #25                 // class java/util/Map
      37: astore        5
      39: nop
      40: iconst_0
      41: istore        6
      43: aload         4
      45: invokeinterface #230,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
      50: checkcast     #119                // class java/lang/Iterable
      53: astore        7
      55: iconst_0
      56: istore        8
      58: aload         7
      60: invokeinterface #146,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      65: astore        9
      67: aload         9
      69: invokeinterface #152,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      74: ifeq          162
      77: aload         9
      79: invokeinterface #155,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      84: astore        11
      86: aload         5
      88: aload         11
      90: checkcast     #232                // class java/util/Map$Entry
      93: astore        13
      95: astore        15
      97: iconst_0
      98: istore        17
     100: aload         13
     102: invokeinterface #235,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     107: aload         15
     109: swap
     110: aload         11
     112: checkcast     #232                // class java/util/Map$Entry
     115: astore        18
     117: astore        25
     119: astore        24
     121: iconst_0
     122: istore        19
     124: aload         18
     126: invokeinterface #238,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     131: checkcast     #240                // class java/lang/Number
     134: invokevirtual #244                // Method java/lang/Number.intValue:()I
     137: istore        20
     139: iload         20
     141: i2l
     142: invokestatic  #249                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     145: astore        26
     147: aload         24
     149: aload         25
     151: aload         26
     153: invokeinterface #168,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     158: pop
     159: goto          67
     162: aload         5
     164: nop
     165: astore_3
     166: aconst_null
     167: astore        4
     169: aload_0
     170: checkcast     #91                 // class java/lang/CharSequence
     173: astore        5
     175: nop
     176: iconst_0
     177: istore        6
     179: aload         5
     181: invokeinterface #252,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     186: iconst_1
     187: isub
     188: istore        7
     190: iload         7
     192: iconst_1
     193: if_icmpge     202
     196: invokestatic  #256                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     199: goto          292
     202: new           #258                // class java/util/ArrayList
     205: dup
     206: iload         7
     208: invokespecial #259                // Method java/util/ArrayList."<init>":(I)V
     211: astore        8
     213: iconst_0
     214: istore        9
     216: iload         9
     218: iload         7
     220: if_icmpge     287
     223: aload         8
     225: aload         5
     227: iload         9
     229: invokeinterface #263,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     234: aload         5
     236: iload         9
     238: iconst_1
     239: iadd
     240: invokeinterface #263,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     245: istore        11
     247: istore        13
     249: astore        25
     251: iconst_0
     252: istore        15
     254: new           #52                 // class java/lang/StringBuilder
     257: dup
     258: invokespecial #55                 // Method java/lang/StringBuilder."<init>":()V
     261: iload         13
     263: invokevirtual #266                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     266: iload         11
     268: invokevirtual #266                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     271: invokevirtual #68                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     274: aload         25
     276: swap
     277: invokevirtual #270                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     280: pop
     281: iinc          9, 1
     284: goto          216
     287: aload         8
     289: checkcast     #109                // class java/util/List
     292: checkcast     #119                // class java/lang/Iterable
     295: astore        5
     297: nop
     298: iconst_0
     299: istore        6
     301: new           #272                // class day14/Day14Kt$expand$$inlined$groupingBy$2
     304: dup
     305: aload         5
     307: invokespecial #275                // Method day14/Day14Kt$expand$$inlined$groupingBy$2."<init>":(Ljava/lang/Iterable;)V
     310: checkcast     #219                // class kotlin/collections/Grouping
     313: invokestatic  #225                // Method kotlin/collections/GroupingKt.eachCount:(Lkotlin/collections/Grouping;)Ljava/util/Map;
     316: astore        5
     318: nop
     319: iconst_0
     320: istore        6
     322: aload         5
     324: astore        7
     326: new           #139                // class java/util/LinkedHashMap
     329: dup
     330: aload         5
     332: invokeinterface #278,  1          // InterfaceMethod java/util/Map.size:()I
     337: invokestatic  #131                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
     340: invokespecial #142                // Method java/util/LinkedHashMap."<init>":(I)V
     343: checkcast     #25                 // class java/util/Map
     346: astore        8
     348: iconst_0
     349: istore        9
     351: aload         7
     353: invokeinterface #230,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     358: checkcast     #119                // class java/lang/Iterable
     361: astore        11
     363: iconst_0
     364: istore        13
     366: aload         11
     368: invokeinterface #146,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     373: astore        15
     375: aload         15
     377: invokeinterface #152,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     382: ifeq          470
     385: aload         15
     387: invokeinterface #155,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     392: astore        17
     394: aload         8
     396: aload         17
     398: checkcast     #232                // class java/util/Map$Entry
     401: astore        18
     403: astore        19
     405: iconst_0
     406: istore        20
     408: aload         18
     410: invokeinterface #235,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     415: aload         19
     417: swap
     418: aload         17
     420: checkcast     #232                // class java/util/Map$Entry
     423: astore        21
     425: astore        26
     427: astore        25
     429: iconst_0
     430: istore        22
     432: aload         21
     434: invokeinterface #238,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     439: checkcast     #240                // class java/lang/Number
     442: invokevirtual #244                // Method java/lang/Number.intValue:()I
     445: istore        23
     447: iload         23
     449: i2l
     450: invokestatic  #249                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     453: astore        27
     455: aload         25
     457: aload         26
     459: aload         27
     461: invokeinterface #168,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     466: pop
     467: goto          375
     470: aload         8
     472: nop
     473: nop
     474: astore        4
     476: iconst_0
     477: istore        5
     479: iload         5
     481: iload_2
     482: if_icmpge     727
     485: iload         5
     487: istore        6
     489: iconst_0
     490: istore        7
     492: new           #139                // class java/util/LinkedHashMap
     495: dup
     496: invokespecial #226                // Method java/util/LinkedHashMap."<init>":()V
     499: checkcast     #25                 // class java/util/Map
     502: astore        8
     504: aload         4
     506: invokeinterface #230,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     511: invokeinterface #281,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     516: astore        9
     518: aload         9
     520: invokeinterface #152,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     525: ifeq          716
     528: aload         9
     530: invokeinterface #155,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     535: checkcast     #232                // class java/util/Map$Entry
     538: astore        11
     540: aload         11
     542: invokeinterface #235,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     547: checkcast     #20                 // class java/lang/String
     550: astore        13
     552: aload         11
     554: invokeinterface #238,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     559: checkcast     #240                // class java/lang/Number
     562: invokevirtual #285                // Method java/lang/Number.longValue:()J
     565: lstore        15
     567: aload_1
     568: aload         13
     570: invokestatic  #288                // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;
     573: checkcast     #201                // class java/lang/Character
     576: invokevirtual #292                // Method java/lang/Character.charValue:()C
     579: istore        18
     581: new           #52                 // class java/lang/StringBuilder
     584: dup
     585: invokespecial #55                 // Method java/lang/StringBuilder."<init>":()V
     588: aload         13
     590: iconst_0
     591: invokevirtual #293                // Method java/lang/String.charAt:(I)C
     594: invokevirtual #266                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     597: iload         18
     599: invokevirtual #266                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     602: invokevirtual #68                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     605: astore        19
     607: new           #52                 // class java/lang/StringBuilder
     610: dup
     611: invokespecial #55                 // Method java/lang/StringBuilder."<init>":()V
     614: iload         18
     616: invokevirtual #266                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     619: aload         13
     621: iconst_1
     622: invokevirtual #293                // Method java/lang/String.charAt:(I)C
     625: invokevirtual #266                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     628: invokevirtual #68                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     631: astore        20
     633: aload         8
     635: aload         19
     637: lload         15
     639: invokestatic  #249                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     642: getstatic     #299                // Field day14/Day14Kt$expand$1$1.INSTANCE:Lday14/Day14Kt$expand$1$1;
     645: checkcast     #301                // class kotlin/jvm/functions/Function2
     648: invokedynamic #320,  0            // InvokeDynamic #0:apply:(Lkotlin/jvm/functions/Function2;)Ljava/util/function/BiFunction;
     653: invokeinterface #324,  4          // InterfaceMethod java/util/Map.merge:(Ljava/lang/Object;Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;
     658: pop
     659: aload         8
     661: aload         20
     663: lload         15
     665: invokestatic  #249                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     668: getstatic     #329                // Field day14/Day14Kt$expand$1$2.INSTANCE:Lday14/Day14Kt$expand$1$2;
     671: checkcast     #301                // class kotlin/jvm/functions/Function2
     674: invokedynamic #334,  0            // InvokeDynamic #1:apply:(Lkotlin/jvm/functions/Function2;)Ljava/util/function/BiFunction;
     679: invokeinterface #324,  4          // InterfaceMethod java/util/Map.merge:(Ljava/lang/Object;Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;
     684: pop
     685: aload_3
     686: iload         18
     688: invokestatic  #205                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     691: lload         15
     693: invokestatic  #249                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     696: getstatic     #339                // Field day14/Day14Kt$expand$1$3.INSTANCE:Lday14/Day14Kt$expand$1$3;
     699: checkcast     #301                // class kotlin/jvm/functions/Function2
     702: invokedynamic #344,  0            // InvokeDynamic #2:apply:(Lkotlin/jvm/functions/Function2;)Ljava/util/function/BiFunction;
     707: invokeinterface #324,  4          // InterfaceMethod java/util/Map.merge:(Ljava/lang/Object;Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;
     712: pop
     713: goto          518
     716: aload         8
     718: astore        4
     720: nop
     721: iinc          5, 1
     724: goto          479
     727: aload_3
     728: invokeinterface #230,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     733: checkcast     #119                // class java/lang/Iterable
     736: invokeinterface #146,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     741: astore        8
     743: aload         8
     745: invokeinterface #152,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     750: ifne          761
     753: new           #346                // class java/util/NoSuchElementException
     756: dup
     757: invokespecial #347                // Method java/util/NoSuchElementException."<init>":()V
     760: athrow
     761: aload         8
     763: invokeinterface #155,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     768: checkcast     #232                // class java/util/Map$Entry
     771: astore        9
     773: iconst_0
     774: istore        11
     776: aload         9
     778: invokeinterface #238,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     783: checkcast     #240                // class java/lang/Number
     786: invokevirtual #285                // Method java/lang/Number.longValue:()J
     789: lstore        9
     791: aload         8
     793: invokeinterface #152,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     798: ifeq          846
     801: aload         8
     803: invokeinterface #155,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     808: checkcast     #232                // class java/util/Map$Entry
     811: astore        11
     813: iconst_0
     814: istore        13
     816: aload         11
     818: invokeinterface #238,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     823: checkcast     #240                // class java/lang/Number
     826: invokevirtual #285                // Method java/lang/Number.longValue:()J
     829: lstore        11
     831: lload         9
     833: lload         11
     835: lcmp
     836: ifge          791
     839: lload         11
     841: lstore        9
     843: goto          791
     846: lload         9
     848: lstore        5
     850: aload_3
     851: invokeinterface #230,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     856: checkcast     #119                // class java/lang/Iterable
     859: invokeinterface #146,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     864: astore        11
     866: aload         11
     868: invokeinterface #152,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     873: ifne          884
     876: new           #346                // class java/util/NoSuchElementException
     879: dup
     880: invokespecial #347                // Method java/util/NoSuchElementException."<init>":()V
     883: athrow
     884: aload         11
     886: invokeinterface #155,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     891: checkcast     #232                // class java/util/Map$Entry
     894: astore        13
     896: iconst_0
     897: istore        15
     899: aload         13
     901: invokeinterface #238,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     906: checkcast     #240                // class java/lang/Number
     909: invokevirtual #285                // Method java/lang/Number.longValue:()J
     912: lstore        13
     914: aload         11
     916: invokeinterface #152,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     921: ifeq          969
     924: aload         11
     926: invokeinterface #155,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     931: checkcast     #232                // class java/util/Map$Entry
     934: astore        15
     936: iconst_0
     937: istore        17
     939: aload         15
     941: invokeinterface #238,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     946: checkcast     #240                // class java/lang/Number
     949: invokevirtual #285                // Method java/lang/Number.longValue:()J
     952: lstore        15
     954: lload         13
     956: lload         15
     958: lcmp
     959: ifle          914
     962: lload         15
     964: lstore        13
     966: goto          914
     969: lload         13
     971: lstore        7
     973: lload         5
     975: lload         7
     977: lsub
     978: lreturn

  private static final long part1(java.lang.String, java.util.Map<java.lang.String, java.lang.Character>);
    Code:
       0: aload_0
       1: aload_1
       2: bipush        10
       4: invokestatic  #394                // Method expand:(Ljava/lang/String;Ljava/util/Map;I)J
       7: lreturn

  private static final long part2(java.lang.String, java.util.Map<java.lang.String, java.lang.Character>);
    Code:
       0: aload_0
       1: aload_1
       2: bipush        40
       4: invokestatic  #394                // Method expand:(Ljava/lang/String;Ljava/util/Map;I)J
       7: lreturn

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

  private static final java.lang.Long expand$lambda$9$lambda$6(kotlin.jvm.functions.Function2, java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokeinterface #402,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
       8: checkcast     #246                // class java/lang/Long
      11: areturn

  private static final java.lang.Long expand$lambda$9$lambda$7(kotlin.jvm.functions.Function2, java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokeinterface #402,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
       8: checkcast     #246                // class java/lang/Long
      11: areturn

  private static final java.lang.Long expand$lambda$9$lambda$8(kotlin.jvm.functions.Function2, java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokeinterface #402,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
       8: checkcast     #246                // class java/lang/Long
      11: areturn
}

Compiled from "Day14.kt"
final class day14.Day14Kt$expand$1$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<java.lang.Long, java.lang.Long, java.lang.Long> {
  public static final day14.Day14Kt$expand$1$1 INSTANCE;

  day14.Day14Kt$expand$1$1();
    Code:
       0: aload_0
       1: iconst_2
       2: getstatic     #15                 // Field java/lang/Long.TYPE:Ljava/lang/Class;
       5: ldc           #17                 // String plus
       7: ldc           #19                 // String plus(J)J
       9: iconst_0
      10: invokespecial #22                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      13: return

  public final java.lang.Long invoke(long, long);
    Code:
       0: lload_1
       1: lload_3
       2: ladd
       3: invokestatic  #30                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
       6: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #36                 // class java/lang/Number
       5: invokevirtual #40                 // Method java/lang/Number.longValue:()J
       8: aload_2
       9: checkcast     #36                 // class java/lang/Number
      12: invokevirtual #40                 // Method java/lang/Number.longValue:()J
      15: invokevirtual #42                 // Method invoke:(JJ)Ljava/lang/Long;
      18: areturn

  static {};
    Code:
       0: new           #2                  // class day14/Day14Kt$expand$1$1
       3: dup
       4: invokespecial #47                 // Method "<init>":()V
       7: putstatic     #50                 // Field INSTANCE:Lday14/Day14Kt$expand$1$1;
      10: return
}

Compiled from "Day14.kt"
final class day14.Day14Kt$expand$1$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<java.lang.Long, java.lang.Long, java.lang.Long> {
  public static final day14.Day14Kt$expand$1$2 INSTANCE;

  day14.Day14Kt$expand$1$2();
    Code:
       0: aload_0
       1: iconst_2
       2: getstatic     #15                 // Field java/lang/Long.TYPE:Ljava/lang/Class;
       5: ldc           #17                 // String plus
       7: ldc           #19                 // String plus(J)J
       9: iconst_0
      10: invokespecial #22                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      13: return

  public final java.lang.Long invoke(long, long);
    Code:
       0: lload_1
       1: lload_3
       2: ladd
       3: invokestatic  #30                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
       6: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #36                 // class java/lang/Number
       5: invokevirtual #40                 // Method java/lang/Number.longValue:()J
       8: aload_2
       9: checkcast     #36                 // class java/lang/Number
      12: invokevirtual #40                 // Method java/lang/Number.longValue:()J
      15: invokevirtual #42                 // Method invoke:(JJ)Ljava/lang/Long;
      18: areturn

  static {};
    Code:
       0: new           #2                  // class day14/Day14Kt$expand$1$2
       3: dup
       4: invokespecial #47                 // Method "<init>":()V
       7: putstatic     #50                 // Field INSTANCE:Lday14/Day14Kt$expand$1$2;
      10: return
}

Compiled from "_Strings.kt"
public final class day14.Day14Kt$expand$$inlined$groupingBy$1 implements kotlin.collections.Grouping<java.lang.Character, java.lang.Character> {
  final java.lang.CharSequence $this_groupingBy;

  public day14.Day14Kt$expand$$inlined$groupingBy$1(java.lang.CharSequence);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #18                 // Field $this_groupingBy:Ljava/lang/CharSequence;
       5: aload_0
       6: invokespecial #21                 // Method java/lang/Object."<init>":()V
       9: return

  public java.util.Iterator<java.lang.Character> sourceIterator();
    Code:
       0: aload_0
       1: getfield      #18                 // Field $this_groupingBy:Ljava/lang/CharSequence;
       4: invokestatic  #33                 // Method kotlin/text/StringsKt.iterator:(Ljava/lang/CharSequence;)Lkotlin/collections/CharIterator;
       7: checkcast     #35                 // class java/util/Iterator
      10: areturn

  public java.lang.Character keyOf(char);
    Code:
       0: iload_1
       1: istore_2
       2: iconst_0
       3: istore_3
       4: iload_2
       5: invokestatic  #43                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
       8: areturn

  public java.lang.Object keyOf(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #40                 // class java/lang/Character
       5: invokevirtual #53                 // Method java/lang/Character.charValue:()C
       8: invokevirtual #55                 // Method keyOf:(C)Ljava/lang/Object;
      11: areturn
}

Compiled from "_Collections.kt"
public final class day14.Day14Kt$expand$$inlined$groupingBy$2 implements kotlin.collections.Grouping<java.lang.String, java.lang.String> {
  final java.lang.Iterable $this_groupingBy;

  public day14.Day14Kt$expand$$inlined$groupingBy$2(java.lang.Iterable);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #18                 // Field $this_groupingBy:Ljava/lang/Iterable;
       5: aload_0
       6: invokespecial #21                 // Method java/lang/Object."<init>":()V
       9: return

  public java.util.Iterator<java.lang.String> sourceIterator();
    Code:
       0: aload_0
       1: getfield      #18                 // Field $this_groupingBy:Ljava/lang/Iterable;
       4: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
       9: areturn

  public java.lang.String keyOf(java.lang.String);
    Code:
       0: aload_1
       1: checkcast     #37                 // class java/lang/String
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: areturn
}