package shortestpath

import java.util.*
import kotlin.Comparator
import kotlin.math.*

private const val INF = 1e9.toInt()

fun main(){
    val sc = Scanner(System.`in`)
    //노드의 개수와 간선의 개수 입력받기
    val n = sc.nextInt()
    val m = sc.nextInt()
    //시작노드 번호 입력받기
    val start = sc.nextInt()
    //최단거리 테이블 초기화
    val distances = IntArray(n + 1) { INF }
    //그래프 입력받기
    val graph = mutableListOf<MutableList<Node>>()
    for(i in 0 .. n){
        graph.add(mutableListOf())
    }
    for(i in 0 until m){
        val a = sc.nextInt()
        val b = sc.nextInt()
        val cost = sc.nextInt()

        graph[a].add(Node(b, cost))
    }

    fun dijkstra(start: Int){
        val pq = PriorityQueue<Node>()
        //시작 노드는 최단 경로를 0으로 설정
        pq.add(Node(start, 0))
        distances[start] = 0
        //큐가 빌 때까지 반복
        while(!pq.isEmpty()){
            val node = pq.poll()
            val now = node.index
            val distance = node.distance
            //현재 노드가 이미 처리된 적이 있다면 무시
            if(distances[now] < distance) continue
            //현재 노드와 연결된 다른 인접한 노드들을 확인
            for(i in 0 until graph[now].size){
                val cost = distance + graph[now][i].distance
                //비용이 더 적게 든다면
                if(cost < distances[graph[now][i].index]){
                    distances[graph[now][i].index] = cost
                    pq.offer(Node(graph[now][i].index, cost))
                }
            }
        }
    }

    dijkstra(start)

    for(i in 1 .. n){
        when(distances[i]){
            INF -> println("INFINITY")
            else -> println(distances[i])
        }
    }
}

data class Node(val index: Int, val distance: Int): Comparable<Node> {
    override fun compareTo(other: Node): Int = this.distance - other.distance
}

Compiled from "개선된_다익스트라_알고리즘.kt"
public final class shortestpath.개선된_다익스트라_알고리즘Kt {
  private static final int INF;

  public static final void main();
    Code:
       0: new           #8                  // class java/util/Scanner
       3: dup
       4: getstatic     #14                 // Field java/lang/System.in:Ljava/io/InputStream;
       7: invokespecial #18                 // Method java/util/Scanner."<init>":(Ljava/io/InputStream;)V
      10: astore_0
      11: aload_0
      12: invokevirtual #22                 // Method java/util/Scanner.nextInt:()I
      15: istore_1
      16: aload_0
      17: invokevirtual #22                 // Method java/util/Scanner.nextInt:()I
      20: istore_2
      21: aload_0
      22: invokevirtual #22                 // Method java/util/Scanner.nextInt:()I
      25: istore_3
      26: iconst_0
      27: istore        5
      29: iload_1
      30: iconst_1
      31: iadd
      32: istore        6
      34: iload         6
      36: newarray       int
      38: astore        7
      40: iload         5
      42: iload         6
      44: if_icmpge     64
      47: iload         5
      49: istore        8
      51: aload         7
      53: iload         8
      55: ldc           #23                 // int 1000000000
      57: iastore
      58: iinc          5, 1
      61: goto          40
      64: aload         7
      66: astore        4
      68: new           #25                 // class java/util/ArrayList
      71: dup
      72: invokespecial #27                 // Method java/util/ArrayList."<init>":()V
      75: checkcast     #29                 // class java/util/List
      78: astore        5
      80: iconst_0
      81: istore        6
      83: iload         6
      85: iload_1
      86: if_icmpgt     119
      89: aload         5
      91: new           #25                 // class java/util/ArrayList
      94: dup
      95: invokespecial #27                 // Method java/util/ArrayList."<init>":()V
      98: checkcast     #29                 // class java/util/List
     101: invokeinterface #33,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     106: pop
     107: iload         6
     109: iload_1
     110: if_icmpeq     119
     113: iinc          6, 1
     116: goto          89
     119: iconst_0
     120: istore        6
     122: iload         6
     124: iload_2
     125: if_icmpge     181
     128: aload_0
     129: invokevirtual #22                 // Method java/util/Scanner.nextInt:()I
     132: istore        7
     134: aload_0
     135: invokevirtual #22                 // Method java/util/Scanner.nextInt:()I
     138: istore        8
     140: aload_0
     141: invokevirtual #22                 // Method java/util/Scanner.nextInt:()I
     144: istore        9
     146: aload         5
     148: iload         7
     150: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     155: checkcast     #29                 // class java/util/List
     158: new           #39                 // class shortestpath/Node
     161: dup
     162: iload         8
     164: iload         9
     166: invokespecial #42                 // Method shortestpath/Node."<init>":(II)V
     169: invokeinterface #33,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     174: pop
     175: iinc          6, 1
     178: goto          122
     181: aload         4
     183: aload         5
     185: iload_3
     186: invokestatic  #46                 // Method main$dijkstra:([ILjava/util/List;I)V
     189: iconst_1
     190: istore        6
     192: iload         6
     194: iload_1
     195: if_icmpgt     247
     198: aload         4
     200: iload         6
     202: iaload
     203: ldc           #23                 // int 1000000000
     205: if_icmpne     220
     208: ldc           #48                 // String INFINITY
     210: getstatic     #52                 // Field java/lang/System.out:Ljava/io/PrintStream;
     213: swap
     214: invokevirtual #58                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     217: goto          235
     220: aload         4
     222: iload         6
     224: iaload
     225: istore        8
     227: getstatic     #52                 // Field java/lang/System.out:Ljava/io/PrintStream;
     230: iload         8
     232: invokevirtual #61                 // Method java/io/PrintStream.println:(I)V
     235: iload         6
     237: iload_1
     238: if_icmpeq     247
     241: iinc          6, 1
     244: goto          198
     247: return

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

  private static final void main$dijkstra(int[], java.util.List<java.util.List<shortestpath.Node>>, int);
    Code:
       0: new           #84                 // class java/util/PriorityQueue
       3: dup
       4: invokespecial #85                 // Method java/util/PriorityQueue."<init>":()V
       7: astore_3
       8: aload_3
       9: new           #39                 // class shortestpath/Node
      12: dup
      13: iload_2
      14: iconst_0
      15: invokespecial #42                 // Method shortestpath/Node."<init>":(II)V
      18: invokevirtual #86                 // Method java/util/PriorityQueue.add:(Ljava/lang/Object;)Z
      21: pop
      22: aload_0
      23: iload_2
      24: iconst_0
      25: iastore
      26: aload_3
      27: invokevirtual #90                 // Method java/util/PriorityQueue.isEmpty:()Z
      30: ifne          225
      33: aload_3
      34: invokevirtual #94                 // Method java/util/PriorityQueue.poll:()Ljava/lang/Object;
      37: checkcast     #39                 // class shortestpath/Node
      40: astore        4
      42: aload         4
      44: invokevirtual #97                 // Method shortestpath/Node.getIndex:()I
      47: istore        5
      49: aload         4
      51: invokevirtual #100                // Method shortestpath/Node.getDistance:()I
      54: istore        6
      56: aload_0
      57: iload         5
      59: iaload
      60: iload         6
      62: if_icmplt     26
      65: iconst_0
      66: istore        7
      68: aload_1
      69: iload         5
      71: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      76: checkcast     #29                 // class java/util/List
      79: invokeinterface #103,  1          // InterfaceMethod java/util/List.size:()I
      84: istore        8
      86: iload         7
      88: iload         8
      90: if_icmpge     26
      93: iload         6
      95: aload_1
      96: iload         5
      98: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     103: checkcast     #29                 // class java/util/List
     106: iload         7
     108: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     113: checkcast     #39                 // class shortestpath/Node
     116: invokevirtual #100                // Method shortestpath/Node.getDistance:()I
     119: iadd
     120: istore        9
     122: iload         9
     124: aload_0
     125: aload_1
     126: iload         5
     128: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     133: checkcast     #29                 // class java/util/List
     136: iload         7
     138: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     143: checkcast     #39                 // class shortestpath/Node
     146: invokevirtual #97                 // Method shortestpath/Node.getIndex:()I
     149: iaload
     150: if_icmpge     219
     153: aload_0
     154: aload_1
     155: iload         5
     157: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     162: checkcast     #29                 // class java/util/List
     165: iload         7
     167: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     172: checkcast     #39                 // class shortestpath/Node
     175: invokevirtual #97                 // Method shortestpath/Node.getIndex:()I
     178: iload         9
     180: iastore
     181: aload_3
     182: new           #39                 // class shortestpath/Node
     185: dup
     186: aload_1
     187: iload         5
     189: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     194: checkcast     #29                 // class java/util/List
     197: iload         7
     199: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     204: checkcast     #39                 // class shortestpath/Node
     207: invokevirtual #97                 // Method shortestpath/Node.getIndex:()I
     210: iload         9
     212: invokespecial #42                 // Method shortestpath/Node."<init>":(II)V
     215: invokevirtual #106                // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z
     218: pop
     219: iinc          7, 1
     222: goto          86
     225: return
}


package dfsbfs

import java.util.*
import kotlin.math.*

fun main(){
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()    //도시의 개수
    val m = sc.nextInt()    //도로의 개수
    val k = sc.nextInt()    //거리 정보
    val x = sc.nextInt()    //출발 도시의 번호

    //최단거리 테이블 초기화
    val distances = IntArray(n + 1) { 1e9.toInt() }
    //그래프 초기화
    val graph = mutableListOf<MutableList<City>>()
    for(i in 0..n){
        graph.add(mutableListOf())
    }
    //그래프 입력받기
    for(i in 0 until m){
        val a = sc.nextInt()
        val b = sc.nextInt()

        graph[a].add(City(b, 1))
    }

    fun dijkstra(start: Int){
        val pq = PriorityQueue<City>()
        //시작 도시 큐에 삽입
        pq.offer(City(start, 0))
        distances[start] = 0
        //큐가 빌 때까지 반복
        while(!pq.isEmpty()){
            val now = pq.poll()
            val cityNumber = now.number
            val distance = now.distance
            //이미 처리된 도시라면 무시
            if(distances[cityNumber] < distance) continue
            //현재 도시와 연결되어있는 도시 방문
            for(city in graph[cityNumber]){
                val cost = distance + city.distance
                //거리가 더 가깝다면
                if(cost < distances[city.number]){
                    pq.offer(City(city.number, cost))
                    distances[city.number] = cost
                }
            }
        }
    }
    //다익스트라 최단경로 알고리즘 수행
    dijkstra(x)

    if(distances.count{ it == k } == 0) {
        println(-1)
        return
    }

    for(i in distances.indices){
        if(distances[i] == k) println(i)
    }
}

data class City(val number: Int, val distance: Int): Comparable<City> {
    override fun compareTo(other: City): Int = this.distance - other.distance
}

Compiled from "특정_거리의_도시_찾기.kt"
public final class dfsbfs.특정_거리의_도시_찾기Kt {
  public static final void main();
    Code:
       0: new           #8                  // class java/util/Scanner
       3: dup
       4: getstatic     #14                 // Field java/lang/System.in:Ljava/io/InputStream;
       7: invokespecial #18                 // Method java/util/Scanner."<init>":(Ljava/io/InputStream;)V
      10: astore_0
      11: aload_0
      12: invokevirtual #22                 // Method java/util/Scanner.nextInt:()I
      15: istore_1
      16: aload_0
      17: invokevirtual #22                 // Method java/util/Scanner.nextInt:()I
      20: istore_2
      21: aload_0
      22: invokevirtual #22                 // Method java/util/Scanner.nextInt:()I
      25: istore_3
      26: aload_0
      27: invokevirtual #22                 // Method java/util/Scanner.nextInt:()I
      30: istore        4
      32: iconst_0
      33: istore        6
      35: iload_1
      36: iconst_1
      37: iadd
      38: istore        7
      40: iload         7
      42: newarray       int
      44: astore        8
      46: iload         6
      48: iload         7
      50: if_icmpge     70
      53: iload         6
      55: istore        9
      57: aload         8
      59: iload         9
      61: ldc           #23                 // int 1000000000
      63: iastore
      64: iinc          6, 1
      67: goto          46
      70: aload         8
      72: astore        5
      74: new           #25                 // class java/util/ArrayList
      77: dup
      78: invokespecial #27                 // Method java/util/ArrayList."<init>":()V
      81: checkcast     #29                 // class java/util/List
      84: astore        6
      86: iconst_0
      87: istore        7
      89: iload         7
      91: iload_1
      92: if_icmpgt     125
      95: aload         6
      97: new           #25                 // class java/util/ArrayList
     100: dup
     101: invokespecial #27                 // Method java/util/ArrayList."<init>":()V
     104: checkcast     #29                 // class java/util/List
     107: invokeinterface #33,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     112: pop
     113: iload         7
     115: iload_1
     116: if_icmpeq     125
     119: iinc          7, 1
     122: goto          95
     125: iconst_0
     126: istore        7
     128: iload         7
     130: iload_2
     131: if_icmpge     180
     134: aload_0
     135: invokevirtual #22                 // Method java/util/Scanner.nextInt:()I
     138: istore        8
     140: aload_0
     141: invokevirtual #22                 // Method java/util/Scanner.nextInt:()I
     144: istore        9
     146: aload         6
     148: iload         8
     150: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     155: checkcast     #29                 // class java/util/List
     158: new           #39                 // class dfsbfs/City
     161: dup
     162: iload         9
     164: iconst_1
     165: invokespecial #42                 // Method dfsbfs/City."<init>":(II)V
     168: invokeinterface #33,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     173: pop
     174: iinc          7, 1
     177: goto          128
     180: aload         5
     182: aload         6
     184: iload         4
     186: invokestatic  #46                 // Method main$dijkstra:([ILjava/util/List;I)V
     189: aload         5
     191: astore        7
     193: iconst_0
     194: istore        8
     196: iconst_0
     197: istore        9
     199: iconst_0
     200: istore        10
     202: aload         7
     204: arraylength
     205: istore        11
     207: iload         10
     209: iload         11
     211: if_icmpge     251
     214: aload         7
     216: iload         10
     218: iaload
     219: istore        12
     221: iload         12
     223: istore        13
     225: iconst_0
     226: istore        14
     228: iload         13
     230: iload_3
     231: if_icmpne     238
     234: iconst_1
     235: goto          239
     238: iconst_0
     239: ifeq          245
     242: iinc          9, 1
     245: iinc          10, 1
     248: goto          207
     251: iload         9
     253: ifne          268
     256: iconst_m1
     257: istore        7
     259: getstatic     #50                 // Field java/lang/System.out:Ljava/io/PrintStream;
     262: iload         7
     264: invokevirtual #56                 // Method java/io/PrintStream.println:(I)V
     267: return
     268: iconst_0
     269: istore        7
     271: aload         5
     273: arraylength
     274: istore        8
     276: iload         7
     278: iload         8
     280: if_icmpge     306
     283: aload         5
     285: iload         7
     287: iaload
     288: iload_3
     289: if_icmpne     300
     292: getstatic     #50                 // Field java/lang/System.out:Ljava/io/PrintStream;
     295: iload         7
     297: invokevirtual #56                 // Method java/io/PrintStream.println:(I)V
     300: iinc          7, 1
     303: goto          276
     306: return

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

  private static final void main$dijkstra(int[], java.util.List<java.util.List<dfsbfs.City>>, int);
    Code:
       0: new           #85                 // class java/util/PriorityQueue
       3: dup
       4: invokespecial #86                 // Method java/util/PriorityQueue."<init>":()V
       7: astore_3
       8: aload_3
       9: new           #39                 // class dfsbfs/City
      12: dup
      13: iload_2
      14: iconst_0
      15: invokespecial #42                 // Method dfsbfs/City."<init>":(II)V
      18: invokevirtual #89                 // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z
      21: pop
      22: aload_0
      23: iload_2
      24: iconst_0
      25: iastore
      26: aload_3
      27: invokevirtual #93                 // Method java/util/PriorityQueue.isEmpty:()Z
      30: ifne          158
      33: aload_3
      34: invokevirtual #97                 // Method java/util/PriorityQueue.poll:()Ljava/lang/Object;
      37: checkcast     #39                 // class dfsbfs/City
      40: astore        4
      42: aload         4
      44: invokevirtual #100                // Method dfsbfs/City.getNumber:()I
      47: istore        5
      49: aload         4
      51: invokevirtual #103                // Method dfsbfs/City.getDistance:()I
      54: istore        6
      56: aload_0
      57: iload         5
      59: iaload
      60: iload         6
      62: if_icmplt     26
      65: aload_1
      66: iload         5
      68: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      73: checkcast     #29                 // class java/util/List
      76: invokeinterface #107,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      81: astore        7
      83: aload         7
      85: invokeinterface #112,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      90: ifeq          26
      93: aload         7
      95: invokeinterface #115,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     100: checkcast     #39                 // class dfsbfs/City
     103: astore        8
     105: iload         6
     107: aload         8
     109: invokevirtual #103                // Method dfsbfs/City.getDistance:()I
     112: iadd
     113: istore        9
     115: iload         9
     117: aload_0
     118: aload         8
     120: invokevirtual #100                // Method dfsbfs/City.getNumber:()I
     123: iaload
     124: if_icmpge     83
     127: aload_3
     128: new           #39                 // class dfsbfs/City
     131: dup
     132: aload         8
     134: invokevirtual #100                // Method dfsbfs/City.getNumber:()I
     137: iload         9
     139: invokespecial #42                 // Method dfsbfs/City."<init>":(II)V
     142: invokevirtual #89                 // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z
     145: pop
     146: aload_0
     147: aload         8
     149: invokevirtual #100                // Method dfsbfs/City.getNumber:()I
     152: iload         9
     154: iastore
     155: goto          83
     158: return
}


package day09

import java.io.File

fun main() {
    val data = parse("src/main/kotlin/day09/Day09.txt")

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

    println("🎄 Day 09 🎄")

    println()

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

    println()

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

private fun parse(path: String): Triple<Int, Int, List<Int>> {
    val lines = File(path).readLines()

    val width = lines.first().length
    val height = lines.size

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

    return Triple(width, height, locations)
}

private fun Triple<Int, Int, List<Int>>.toHeightmap() =
    let { (width, height, locations) ->
        Heightmap(width, height, locations.map(::Location))
    }

private data class Heightmap(
    val width: Int,
    val height: Int,
    val locations: List<Location>,
)

private data class Location(
    val height: Int,
    var visited: Boolean = false,
)

private operator fun Heightmap.get(x: Int, y: Int) =
    locations[y * width + x]

private fun adjacentNodes(x: Int, y: Int, width: Int, height: Int) =
    listOfNotNull(
        if (x - 1 >= 0)     x - 1 to y else null,
        if (x + 1 < width)  x + 1 to y else null,
        if (y - 1 >= 0)     x to y - 1 else null,
        if (y + 1 < height) x to y + 1 else null,
    )

private fun part1(heightmap: Heightmap): Int {
    var sum = 0
    val (width, height) = heightmap
    for (y in 0 until height) {
        for (x in 0 until width) {
            val node = heightmap[x, y]
            val isLowestPoint = adjacentNodes(x, y, width, height)
                .all { (nx, ny) -> heightmap[nx, ny].height > node.height }

            if (isLowestPoint) {
                sum += node.height + 1
            }
        }
    }
    return sum
}

private fun Location.isInsideUnexploredBasin() =
    !visited && height != 9

private fun Location.visit() {
    visited = true
}

private fun countNodesInBasin(heightmap: Heightmap, x: Int, y: Int): Int {
    val nodesToVisit = ArrayDeque(listOf(x to y))

    var count = 0
    while (nodesToVisit.isNotEmpty()) {
        val (nx, ny) = nodesToVisit.removeLast()

        val node = heightmap[nx, ny]
        if (node.isInsideUnexploredBasin()) {
            node.visit()
            count += 1

            adjacentNodes(nx, ny, heightmap.width, heightmap.height)
                .forEach(nodesToVisit::addLast)
        }
    }

    return count
}

private fun part2(heightmap: Heightmap): Int {
    val basins = mutableListOf<Int>()

    val (width, height) = heightmap
    for (y in 0 until height) {
        for (x in 0 until width) {
            val node = heightmap[x, y]
            if (node.isInsideUnexploredBasin()) {
                basins.add(countNodesInBasin(heightmap, x, y))
            }
        }
    }

    return basins
        .sortedDescending()
        .take(3)
        .fold(1, Int::times)
}

Compiled from "Day09.kt"
public final class day09.Day09Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String src/main/kotlin/day09/Day09.txt
       2: invokestatic  #12                 // Method parse:(Ljava/lang/String;)Lkotlin/Triple;
       5: astore_0
       6: aload_0
       7: invokestatic  #16                 // Method toHeightmap:(Lkotlin/Triple;)Lday09/Heightmap;
      10: invokestatic  #20                 // Method part1:(Lday09/Heightmap;)I
      13: istore_1
      14: aload_0
      15: invokestatic  #16                 // Method toHeightmap:(Lkotlin/Triple;)Lday09/Heightmap;
      18: invokestatic  #23                 // Method part2:(Lday09/Heightmap;)I
      21: istore_2
      22: ldc           #25                 // String 🎄 Day 09 🎄
      24: getstatic     #31                 // Field java/lang/System.out:Ljava/io/PrintStream;
      27: swap
      28: invokevirtual #37                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      31: getstatic     #31                 // Field java/lang/System.out:Ljava/io/PrintStream;
      34: invokevirtual #39                 // Method java/io/PrintStream.println:()V
      37: ldc           #41                 // String [Part 1]
      39: getstatic     #31                 // Field java/lang/System.out:Ljava/io/PrintStream;
      42: swap
      43: invokevirtual #37                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      46: new           #43                 // class java/lang/StringBuilder
      49: dup
      50: invokespecial #46                 // Method java/lang/StringBuilder."<init>":()V
      53: ldc           #48                 // String Answer:
      55: invokevirtual #52                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      58: iload_1
      59: invokevirtual #55                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      62: invokevirtual #59                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      65: getstatic     #31                 // Field java/lang/System.out:Ljava/io/PrintStream;
      68: swap
      69: invokevirtual #37                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      72: getstatic     #31                 // Field java/lang/System.out:Ljava/io/PrintStream;
      75: invokevirtual #39                 // Method java/io/PrintStream.println:()V
      78: ldc           #61                 // String [Part 2]
      80: getstatic     #31                 // Field java/lang/System.out:Ljava/io/PrintStream;
      83: swap
      84: invokevirtual #37                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      87: new           #43                 // class java/lang/StringBuilder
      90: dup
      91: invokespecial #46                 // Method java/lang/StringBuilder."<init>":()V
      94: ldc           #48                 // String Answer:
      96: invokevirtual #52                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      99: iload_2
     100: invokevirtual #55                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     103: invokevirtual #59                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     106: getstatic     #31                 // Field java/lang/System.out:Ljava/io/PrintStream;
     109: swap
     110: invokevirtual #37                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     113: return

  private static final kotlin.Triple<java.lang.Integer, java.lang.Integer, java.util.List<java.lang.Integer>> parse(java.lang.String);
    Code:
       0: new           #69                 // class java/io/File
       3: dup
       4: aload_0
       5: invokespecial #72                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       8: aconst_null
       9: iconst_1
      10: aconst_null
      11: invokestatic  #78                 // 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: invokestatic  #84                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      19: checkcast     #86                 // class java/lang/String
      22: invokevirtual #90                 // Method java/lang/String.length:()I
      25: istore_2
      26: aload_1
      27: invokeinterface #95,  1           // InterfaceMethod java/util/List.size:()I
      32: istore_3
      33: aload_1
      34: checkcast     #97                 // class java/lang/Iterable
      37: astore        5
      39: iconst_0
      40: istore        6
      42: aload         5
      44: astore        7
      46: new           #99                 // class java/util/ArrayList
      49: dup
      50: invokespecial #100                // Method java/util/ArrayList."<init>":()V
      53: checkcast     #102                // class java/util/Collection
      56: astore        8
      58: iconst_0
      59: istore        9
      61: aload         7
      63: invokeinterface #106,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      68: astore        10
      70: aload         10
      72: invokeinterface #112,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      77: ifeq          218
      80: aload         10
      82: invokeinterface #116,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      87: astore        11
      89: aload         11
      91: checkcast     #86                 // class java/lang/String
      94: astore        12
      96: iconst_0
      97: istore        13
      99: aload         12
     101: checkcast     #118                // class java/lang/CharSequence
     104: astore        14
     106: iconst_0
     107: istore        15
     109: aload         14
     111: astore        16
     113: new           #99                 // class java/util/ArrayList
     116: dup
     117: aload         14
     119: invokeinterface #119,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     124: invokespecial #122                // Method java/util/ArrayList."<init>":(I)V
     127: checkcast     #102                // class java/util/Collection
     130: astore        17
     132: iconst_0
     133: istore        18
     135: iconst_0
     136: istore        19
     138: iload         19
     140: aload         16
     142: invokeinterface #119,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     147: if_icmpge     195
     150: aload         16
     152: iload         19
     154: invokeinterface #126,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     159: istore        20
     161: aload         17
     163: iload         20
     165: istore        21
     167: astore        22
     169: iconst_0
     170: istore        23
     172: iload         21
     174: invokestatic  #132                // Method kotlin/text/CharsKt.digitToInt:(C)I
     177: invokestatic  #138                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     180: aload         22
     182: swap
     183: invokeinterface #142,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     188: pop
     189: iinc          19, 1
     192: goto          138
     195: aload         17
     197: checkcast     #92                 // class java/util/List
     200: nop
     201: checkcast     #97                 // class java/lang/Iterable
     204: nop
     205: astore        12
     207: aload         8
     209: aload         12
     211: invokestatic  #146                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     214: pop
     215: goto          70
     218: aload         8
     220: checkcast     #92                 // class java/util/List
     223: nop
     224: astore        4
     226: new           #148                // class kotlin/Triple
     229: dup
     230: iload_2
     231: invokestatic  #138                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     234: iload_3
     235: invokestatic  #138                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     238: aload         4
     240: invokespecial #151                // Method kotlin/Triple."<init>":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
     243: areturn

  private static final day09.Heightmap toHeightmap(kotlin.Triple<java.lang.Integer, java.lang.Integer, ? extends java.util.List<java.lang.Integer>>);
    Code:
       0: aload_0
       1: astore_1
       2: iconst_0
       3: istore_2
       4: aload_1
       5: invokevirtual #183                // Method kotlin/Triple.component1:()Ljava/lang/Object;
       8: checkcast     #185                // class java/lang/Number
      11: invokevirtual #188                // Method java/lang/Number.intValue:()I
      14: istore_3
      15: aload_1
      16: invokevirtual #191                // Method kotlin/Triple.component2:()Ljava/lang/Object;
      19: checkcast     #185                // class java/lang/Number
      22: invokevirtual #188                // Method java/lang/Number.intValue:()I
      25: istore        4
      27: aload_1
      28: invokevirtual #194                // Method kotlin/Triple.component3:()Ljava/lang/Object;
      31: checkcast     #92                 // class java/util/List
      34: astore        5
      36: iload_3
      37: iload         4
      39: aload         5
      41: checkcast     #97                 // class java/lang/Iterable
      44: astore        6
      46: istore        7
      48: istore        8
      50: iconst_0
      51: istore        9
      53: aload         6
      55: astore        10
      57: new           #99                 // class java/util/ArrayList
      60: dup
      61: aload         6
      63: bipush        10
      65: invokestatic  #198                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      68: invokespecial #122                // Method java/util/ArrayList."<init>":(I)V
      71: checkcast     #102                // class java/util/Collection
      74: astore        11
      76: iconst_0
      77: istore        12
      79: aload         10
      81: invokeinterface #106,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      86: astore        13
      88: aload         13
      90: invokeinterface #112,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      95: ifeq          148
      98: aload         13
     100: invokeinterface #116,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     105: astore        14
     107: aload         11
     109: aload         14
     111: checkcast     #185                // class java/lang/Number
     114: invokevirtual #188                // Method java/lang/Number.intValue:()I
     117: istore        15
     119: astore        16
     121: iconst_0
     122: istore        17
     124: new           #200                // class day09/Location
     127: dup
     128: iload         15
     130: iconst_0
     131: iconst_2
     132: aconst_null
     133: invokespecial #203                // Method day09/Location."<init>":(IZILkotlin/jvm/internal/DefaultConstructorMarker;)V
     136: aload         16
     138: swap
     139: invokeinterface #142,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     144: pop
     145: goto          88
     148: aload         11
     150: checkcast     #92                 // class java/util/List
     153: nop
     154: astore        16
     156: iload         8
     158: iload         7
     160: aload         16
     162: astore        18
     164: istore        19
     166: istore        20
     168: new           #205                // class day09/Heightmap
     171: dup
     172: iload         20
     174: iload         19
     176: aload         18
     178: invokespecial #208                // Method day09/Heightmap."<init>":(IILjava/util/List;)V
     181: nop
     182: areturn

  private static final day09.Location get(day09.Heightmap, int, int);
    Code:
       0: aload_0
       1: ldc           #215                // String <this>
       3: invokestatic  #221                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #225                // Method day09/Heightmap.getLocations:()Ljava/util/List;
      10: iload_2
      11: aload_0
      12: invokevirtual #228                // Method day09/Heightmap.getWidth:()I
      15: imul
      16: iload_1
      17: iadd
      18: invokeinterface #231,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      23: checkcast     #200                // class day09/Location
      26: areturn

  private static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> adjacentNodes(int, int, int, int);
    Code:
       0: iconst_4
       1: anewarray     #240                // class kotlin/Pair
       4: astore        4
       6: aload         4
       8: iconst_0
       9: iload_0
      10: iconst_1
      11: isub
      12: iflt          31
      15: iload_0
      16: iconst_1
      17: isub
      18: invokestatic  #138                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      21: iload_1
      22: invokestatic  #138                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      25: invokestatic  #246                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      28: goto          32
      31: aconst_null
      32: aastore
      33: aload         4
      35: iconst_1
      36: iload_0
      37: iconst_1
      38: iadd
      39: iload_2
      40: if_icmpge     59
      43: iload_0
      44: iconst_1
      45: iadd
      46: invokestatic  #138                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      49: iload_1
      50: invokestatic  #138                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      53: invokestatic  #246                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      56: goto          60
      59: aconst_null
      60: aastore
      61: aload         4
      63: iconst_2
      64: iload_1
      65: iconst_1
      66: isub
      67: iflt          86
      70: iload_0
      71: invokestatic  #138                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      74: iload_1
      75: iconst_1
      76: isub
      77: invokestatic  #138                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      80: invokestatic  #246                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      83: goto          87
      86: aconst_null
      87: aastore
      88: aload         4
      90: iconst_3
      91: iload_1
      92: iconst_1
      93: iadd
      94: iload_3
      95: if_icmpge     114
      98: iload_0
      99: invokestatic  #138                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     102: iload_1
     103: iconst_1
     104: iadd
     105: invokestatic  #138                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     108: invokestatic  #246                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     111: goto          115
     114: aconst_null
     115: aastore
     116: aload         4
     118: invokestatic  #250                // Method kotlin/collections/CollectionsKt.listOfNotNull:([Ljava/lang/Object;)Ljava/util/List;
     121: areturn

  private static final int part1(day09.Heightmap);
    Code:
       0: iconst_0
       1: istore_1
       2: aload_0
       3: invokevirtual #254                // Method day09/Heightmap.component1:()I
       6: istore_2
       7: aload_0
       8: invokevirtual #256                // Method day09/Heightmap.component2:()I
      11: istore_3
      12: iconst_0
      13: istore        4
      15: iload         4
      17: iload_3
      18: if_icmpge     208
      21: iconst_0
      22: istore        5
      24: iload         5
      26: iload_2
      27: if_icmpge     202
      30: aload_0
      31: iload         5
      33: iload         4
      35: invokestatic  #258                // Method get:(Lday09/Heightmap;II)Lday09/Location;
      38: astore        6
      40: iload         5
      42: iload         4
      44: iload_2
      45: iload_3
      46: invokestatic  #260                // Method adjacentNodes:(IIII)Ljava/util/List;
      49: checkcast     #97                 // class java/lang/Iterable
      52: astore        8
      54: nop
      55: iconst_0
      56: istore        9
      58: aload         8
      60: instanceof    #102                // class java/util/Collection
      63: ifeq          83
      66: aload         8
      68: checkcast     #102                // class java/util/Collection
      71: invokeinterface #263,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      76: ifeq          83
      79: iconst_1
      80: goto          179
      83: aload         8
      85: invokeinterface #106,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      90: astore        10
      92: aload         10
      94: invokeinterface #112,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      99: ifeq          178
     102: aload         10
     104: invokeinterface #116,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     109: astore        11
     111: aload         11
     113: checkcast     #240                // class kotlin/Pair
     116: astore        12
     118: iconst_0
     119: istore        13
     121: aload         12
     123: invokevirtual #264                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     126: checkcast     #185                // class java/lang/Number
     129: invokevirtual #188                // Method java/lang/Number.intValue:()I
     132: istore        14
     134: aload         12
     136: invokevirtual #265                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     139: checkcast     #185                // class java/lang/Number
     142: invokevirtual #188                // Method java/lang/Number.intValue:()I
     145: istore        15
     147: aload_0
     148: iload         14
     150: iload         15
     152: invokestatic  #258                // Method get:(Lday09/Heightmap;II)Lday09/Location;
     155: invokevirtual #268                // Method day09/Location.getHeight:()I
     158: aload         6
     160: invokevirtual #268                // Method day09/Location.getHeight:()I
     163: if_icmple     170
     166: iconst_1
     167: goto          171
     170: iconst_0
     171: ifne          92
     174: iconst_0
     175: goto          179
     178: iconst_1
     179: istore        7
     181: iload         7
     183: ifeq          196
     186: iload_1
     187: aload         6
     189: invokevirtual #268                // Method day09/Location.getHeight:()I
     192: iconst_1
     193: iadd
     194: iadd
     195: istore_1
     196: iinc          5, 1
     199: goto          24
     202: iinc          4, 1
     205: goto          15
     208: iload_1
     209: ireturn

  private static final boolean isInsideUnexploredBasin(day09.Location);
    Code:
       0: aload_0
       1: invokevirtual #285                // Method day09/Location.getVisited:()Z
       4: ifne          20
       7: aload_0
       8: invokevirtual #268                // Method day09/Location.getHeight:()I
      11: bipush        9
      13: if_icmpeq     20
      16: iconst_1
      17: goto          21
      20: iconst_0
      21: ireturn

  private static final void visit(day09.Location);
    Code:
       0: aload_0
       1: iconst_1
       2: invokevirtual #292                // Method day09/Location.setVisited:(Z)V
       5: return

  private static final int countNodesInBasin(day09.Heightmap, int, int);
    Code:
       0: new           #297                // class kotlin/collections/ArrayDeque
       3: dup
       4: iload_1
       5: invokestatic  #138                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
       8: iload_2
       9: invokestatic  #138                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      12: invokestatic  #246                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      15: invokestatic  #301                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      18: checkcast     #102                // class java/util/Collection
      21: invokespecial #304                // Method kotlin/collections/ArrayDeque."<init>":(Ljava/util/Collection;)V
      24: astore_3
      25: iconst_0
      26: istore        4
      28: aload_3
      29: checkcast     #102                // class java/util/Collection
      32: invokeinterface #263,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      37: ifne          44
      40: iconst_1
      41: goto          45
      44: iconst_0
      45: ifeq          185
      48: aload_3
      49: invokevirtual #307                // Method kotlin/collections/ArrayDeque.removeLast:()Ljava/lang/Object;
      52: checkcast     #240                // class kotlin/Pair
      55: astore        5
      57: aload         5
      59: invokevirtual #264                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      62: checkcast     #185                // class java/lang/Number
      65: invokevirtual #188                // Method java/lang/Number.intValue:()I
      68: istore        6
      70: aload         5
      72: invokevirtual #265                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      75: checkcast     #185                // class java/lang/Number
      78: invokevirtual #188                // Method java/lang/Number.intValue:()I
      81: istore        7
      83: aload_0
      84: iload         6
      86: iload         7
      88: invokestatic  #258                // Method get:(Lday09/Heightmap;II)Lday09/Location;
      91: astore        8
      93: aload         8
      95: invokestatic  #309                // Method isInsideUnexploredBasin:(Lday09/Location;)Z
      98: ifeq          28
     101: aload         8
     103: invokestatic  #311                // Method visit:(Lday09/Location;)V
     106: iinc          4, 1
     109: iload         6
     111: iload         7
     113: aload_0
     114: invokevirtual #228                // Method day09/Heightmap.getWidth:()I
     117: aload_0
     118: invokevirtual #312                // Method day09/Heightmap.getHeight:()I
     121: invokestatic  #260                // Method adjacentNodes:(IIII)Ljava/util/List;
     124: checkcast     #97                 // class java/lang/Iterable
     127: astore        9
     129: nop
     130: iconst_0
     131: istore        10
     133: aload         9
     135: invokeinterface #106,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     140: astore        11
     142: aload         11
     144: invokeinterface #112,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     149: ifeq          181
     152: aload         11
     154: invokeinterface #116,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     159: astore        12
     161: aload         12
     163: checkcast     #240                // class kotlin/Pair
     166: astore        13
     168: iconst_0
     169: istore        14
     171: aload_3
     172: aload         13
     174: invokevirtual #315                // Method kotlin/collections/ArrayDeque.addLast:(Ljava/lang/Object;)V
     177: nop
     178: goto          142
     181: nop
     182: goto          28
     185: iload         4
     187: ireturn

  private static final int part2(day09.Heightmap);
    Code:
       0: new           #99                 // class java/util/ArrayList
       3: dup
       4: invokespecial #100                // Method java/util/ArrayList."<init>":()V
       7: checkcast     #92                 // class java/util/List
      10: astore_1
      11: aload_0
      12: invokevirtual #254                // Method day09/Heightmap.component1:()I
      15: istore_2
      16: aload_0
      17: invokevirtual #256                // Method day09/Heightmap.component2:()I
      20: istore_3
      21: iconst_0
      22: istore        4
      24: iload         4
      26: iload_3
      27: if_icmpge     87
      30: iconst_0
      31: istore        5
      33: iload         5
      35: iload_2
      36: if_icmpge     81
      39: aload_0
      40: iload         5
      42: iload         4
      44: invokestatic  #258                // Method get:(Lday09/Heightmap;II)Lday09/Location;
      47: astore        6
      49: aload         6
      51: invokestatic  #309                // Method isInsideUnexploredBasin:(Lday09/Location;)Z
      54: ifeq          75
      57: aload_1
      58: aload_0
      59: iload         5
      61: iload         4
      63: invokestatic  #324                // Method countNodesInBasin:(Lday09/Heightmap;II)I
      66: invokestatic  #138                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      69: invokeinterface #325,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      74: pop
      75: iinc          5, 1
      78: goto          33
      81: iinc          4, 1
      84: goto          24
      87: aload_1
      88: checkcast     #97                 // class java/lang/Iterable
      91: invokestatic  #329                // Method kotlin/collections/CollectionsKt.sortedDescending:(Ljava/lang/Iterable;)Ljava/util/List;
      94: checkcast     #97                 // class java/lang/Iterable
      97: iconst_3
      98: invokestatic  #333                // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
     101: checkcast     #97                 // class java/lang/Iterable
     104: astore        4
     106: iconst_1
     107: istore        5
     109: iconst_0
     110: istore        6
     112: iload         5
     114: istore        7
     116: aload         4
     118: invokeinterface #106,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     123: astore        8
     125: aload         8
     127: invokeinterface #112,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     132: ifeq          171
     135: aload         8
     137: invokeinterface #116,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     142: astore        9
     144: iload         7
     146: aload         9
     148: checkcast     #185                // class java/lang/Number
     151: invokevirtual #188                // Method java/lang/Number.intValue:()I
     154: istore        10
     156: istore        11
     158: iconst_0
     159: istore        12
     161: iload         11
     163: iload         10
     165: imul
     166: istore        7
     168: goto          125
     171: iload         7
     173: ireturn

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


package day08

import java.io.File

fun main() {
    val data = parse("src/main/kotlin/day08/Day08.txt")

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

    println("🎄 Day 08 🎄")

    println()

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

    println()

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

private typealias Segments = Set<Char>
private typealias Entry = Pair<List<Segments>, List<Segments>>

private fun parse(path: String): List<Entry> =
    File(path)
        .readLines()
        .map(String::toEntry)

private fun String.toEntry(): Entry =
    this.split("|")
        .map { part -> part
            .trim()
            .split(" ")
            .map(String::toSet)
        }
        .let { (patterns, digits) -> Entry(patterns, digits) }

private fun part1(entries: List<Entry>) =
    entries.sumOf { (_, digits) ->
        digits.count { digit -> digit.size in arrayOf(2, 3, 4, 7) }
    }

private fun part2(entries: List<Entry>) =
    entries.sumOf { (patterns, digits) ->
        // The approach of this solution is to directly determine which
        // combinations of letters map to which digits.
        val mappings = Array(10) { setOf<Char>() }

        // First, we partition the unique digit patterns:
        // 1) digit '1' maps to the pattern with length 2
        // 2) digit '4' maps to the pattern with length 4
        // 3) digit '7' maps to the pattern with length 3
        // 4) digit '8' maps to the pattern with length 7
        //
        // Out of all digits, only 6 now remain:
        // - 3 of them have length 5 and may be one of '2','3','5'
        // - 3 of them have length 6 and may be one of '0','6','9'

        val patternsWithLength5 = mutableListOf<Segments>()
        val patternsWithLength6 = mutableListOf<Segments>()

        for (pattern in patterns) {
            when (pattern.size) {
                2 -> mappings[1] = pattern
                3 -> mappings[7] = pattern
                4 -> mappings[4] = pattern
                7 -> mappings[8] = pattern
                5 -> patternsWithLength5.add(pattern)
                6 -> patternsWithLength6.add(pattern)
            }
        }

        // Second, we can observe that there are overlaps between digit
        // patterns. We may use them to deduce new patterns from the
        // ones we already know.

        // 5) digit '6' maps to the pattern of length 6 that does not
        // contain all segments of digit '1'.
        mappings[6] = patternsWithLength6.first { pattern ->
            !pattern.containsAll(mappings[1])
        }
        // 6) digit '9' maps to the pattern of length 6 that contains
        // all segments of digit '4'
        mappings[9] = patternsWithLength6.first { pattern ->
            pattern.containsAll(mappings[4])
        }
        // 7) digit '0' maps to the last remaining pattern of length 6
        mappings[0] = patternsWithLength6.first { pattern ->
            pattern != mappings[6] && pattern != mappings[9]
        }
        // 8) digit '3' maps to the pattern of length 5 that contains
        // both segments of digit '1'
        mappings[3] = patternsWithLength5.first { pattern ->
            pattern.containsAll(mappings[1])
        }

        // Here the situation becomes trickier. I could not find a fitting
        // overlap to differentiate between digits 2 and 5, so we're going
        // to use another trick. Each pattern contains a segment initially
        // labelled 'f', except for digit '2'. If we find that segment,
        // the '2' is simply the pattern without it.
        val foundPatterns = mappings.filter(Set<Char>::isNotEmpty)
        val f = ('a'..'g').first { label ->
            foundPatterns.all { pattern -> pattern.contains(label) }
        }

        // 9) digit '2' maps to the pattern of length 5 that does not contain
        // segment initially labelled 'f'
        mappings[2] = patternsWithLength5.first { pattern ->
            !pattern.contains(f)
        }
        // 10) digit '5' maps to the last remaining pattern of length 5
        mappings[5] = patternsWithLength5.first { pattern ->
            pattern != mappings[3] && pattern != mappings[2]
        }

        // At this point it is enough to apply the mapping to each output
        // digit and combine them into an integer.
        digits.fold(0) { acc: Int, digit ->
            acc * 10 + mappings.indexOfFirst { it == digit }
        }
    }

Compiled from "Day08.kt"
public final class day08.Day08Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String src/main/kotlin/day08/Day08.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;)I
      10: istore_1
      11: aload_0
      12: invokestatic  #19                 // Method part2:(Ljava/util/List;)I
      15: istore_2
      16: ldc           #21                 // String 🎄 Day 08 🎄
      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.List<kotlin.Pair<java.util.List<java.util.Set<java.lang.Character>>, java.util.List<java.util.Set<java.lang.Character>>>> 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: nop
      19: iconst_0
      20: istore_2
      21: aload_1
      22: astore_3
      23: new           #78                 // class java/util/ArrayList
      26: dup
      27: aload_1
      28: bipush        10
      30: invokestatic  #84                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      33: invokespecial #87                 // Method java/util/ArrayList."<init>":(I)V
      36: checkcast     #89                 // class java/util/Collection
      39: astore        4
      41: iconst_0
      42: istore        5
      44: aload_3
      45: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      50: astore        6
      52: aload         6
      54: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      59: ifeq          102
      62: aload         6
      64: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      69: astore        7
      71: aload         4
      73: aload         7
      75: checkcast     #105                // class java/lang/String
      78: astore        8
      80: astore        10
      82: iconst_0
      83: istore        9
      85: aload         8
      87: invokestatic  #109                // Method toEntry:(Ljava/lang/String;)Lkotlin/Pair;
      90: aload         10
      92: swap
      93: invokeinterface #113,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      98: pop
      99: goto          52
     102: aload         4
     104: checkcast     #115                // class java/util/List
     107: nop
     108: areturn

  private static final kotlin.Pair<java.util.List<java.util.Set<java.lang.Character>>, java.util.List<java.util.Set<java.lang.Character>>> toEntry(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #131                // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #105                // class java/lang/String
       8: astore_1
       9: aload_1
      10: iconst_0
      11: ldc           #133                // String |
      13: aastore
      14: aload_1
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #139                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: checkcast     #76                 // class java/lang/Iterable
      26: astore_1
      27: nop
      28: iconst_0
      29: istore_2
      30: aload_1
      31: astore_3
      32: new           #78                 // class java/util/ArrayList
      35: dup
      36: aload_1
      37: bipush        10
      39: invokestatic  #84                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      42: invokespecial #87                 // Method java/util/ArrayList."<init>":(I)V
      45: checkcast     #89                 // class java/util/Collection
      48: astore        4
      50: iconst_0
      51: istore        5
      53: aload_3
      54: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      59: astore        6
      61: aload         6
      63: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      68: ifeq          247
      71: aload         6
      73: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      78: astore        7
      80: aload         4
      82: aload         7
      84: checkcast     #105                // class java/lang/String
      87: astore        8
      89: astore        20
      91: iconst_0
      92: istore        9
      94: nop
      95: aload         8
      97: checkcast     #131                // class java/lang/CharSequence
     100: invokestatic  #143                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     103: invokevirtual #144                // Method java/lang/Object.toString:()Ljava/lang/String;
     106: checkcast     #131                // class java/lang/CharSequence
     109: iconst_1
     110: anewarray     #105                // class java/lang/String
     113: astore        10
     115: aload         10
     117: iconst_0
     118: ldc           #146                // String
     120: aastore
     121: aload         10
     123: iconst_0
     124: iconst_0
     125: bipush        6
     127: aconst_null
     128: invokestatic  #139                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     131: checkcast     #76                 // class java/lang/Iterable
     134: astore        10
     136: nop
     137: iconst_0
     138: istore        11
     140: aload         10
     142: astore        12
     144: new           #78                 // class java/util/ArrayList
     147: dup
     148: aload         10
     150: bipush        10
     152: invokestatic  #84                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     155: invokespecial #87                 // Method java/util/ArrayList."<init>":(I)V
     158: checkcast     #89                 // class java/util/Collection
     161: astore        13
     163: iconst_0
     164: istore        14
     166: aload         12
     168: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     173: astore        15
     175: aload         15
     177: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     182: ifeq          228
     185: aload         15
     187: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     192: astore        16
     194: aload         13
     196: aload         16
     198: checkcast     #105                // class java/lang/String
     201: astore        17
     203: astore        18
     205: iconst_0
     206: istore        19
     208: aload         17
     210: checkcast     #131                // class java/lang/CharSequence
     213: invokestatic  #150                // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;
     216: aload         18
     218: swap
     219: invokeinterface #113,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     224: pop
     225: goto          175
     228: aload         13
     230: checkcast     #115                // class java/util/List
     233: nop
     234: nop
     235: aload         20
     237: swap
     238: invokeinterface #113,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     243: pop
     244: goto          61
     247: aload         4
     249: checkcast     #115                // class java/util/List
     252: nop
     253: astore_2
     254: iconst_0
     255: istore_3
     256: aload_2
     257: iconst_0
     258: invokeinterface #154,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     263: checkcast     #115                // class java/util/List
     266: astore        4
     268: aload_2
     269: iconst_1
     270: invokeinterface #154,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     275: checkcast     #115                // class java/util/List
     278: astore        5
     280: new           #156                // class kotlin/Pair
     283: dup
     284: aload         4
     286: aload         5
     288: invokespecial #159                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     291: nop
     292: areturn

  private static final int part1(java.util.List<? extends kotlin.Pair<? extends java.util.List<? extends java.util.Set<java.lang.Character>>, ? extends java.util.List<? extends java.util.Set<java.lang.Character>>>>);
    Code:
       0: aload_0
       1: checkcast     #76                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      13: astore_3
      14: aload_3
      15: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      20: ifeq          215
      23: aload_3
      24: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      29: astore        4
      31: iload_2
      32: aload         4
      34: checkcast     #156                // class kotlin/Pair
      37: astore        5
      39: istore        16
      41: iconst_0
      42: istore        6
      44: aload         5
      46: invokevirtual #170                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      49: checkcast     #115                // class java/util/List
      52: astore        7
      54: aload         7
      56: checkcast     #76                 // class java/lang/Iterable
      59: astore        8
      61: iconst_0
      62: istore        9
      64: aload         8
      66: instanceof    #89                 // class java/util/Collection
      69: ifeq          89
      72: aload         8
      74: checkcast     #89                 // class java/util/Collection
      77: invokeinterface #173,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      82: ifeq          89
      85: iconst_0
      86: goto          203
      89: iconst_0
      90: istore        10
      92: aload         8
      94: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      99: astore        11
     101: aload         11
     103: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     108: ifeq          201
     111: aload         11
     113: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     118: astore        12
     120: aload         12
     122: checkcast     #175                // class java/util/Set
     125: astore        13
     127: iconst_0
     128: istore        14
     130: iconst_4
     131: anewarray     #177                // class java/lang/Integer
     134: astore        15
     136: aload         15
     138: iconst_0
     139: iconst_2
     140: invokestatic  #181                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     143: aastore
     144: aload         15
     146: iconst_1
     147: iconst_3
     148: invokestatic  #181                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     151: aastore
     152: aload         15
     154: iconst_2
     155: iconst_4
     156: invokestatic  #181                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     159: aastore
     160: aload         15
     162: iconst_3
     163: bipush        7
     165: invokestatic  #181                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     168: aastore
     169: aload         15
     171: aload         13
     173: invokeinterface #185,  1          // InterfaceMethod java/util/Set.size:()I
     178: invokestatic  #181                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     181: invokestatic  #191                // Method kotlin/collections/ArraysKt.contains:([Ljava/lang/Object;Ljava/lang/Object;)Z
     184: ifeq          101
     187: iinc          10, 1
     190: iload         10
     192: ifge          101
     195: invokestatic  #194                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     198: goto          101
     201: iload         10
     203: nop
     204: istore        17
     206: iload         16
     208: iload         17
     210: iadd
     211: istore_2
     212: goto          14
     215: iload_2
     216: ireturn

  private static final int part2(java.util.List<? extends kotlin.Pair<? extends java.util.List<? extends java.util.Set<java.lang.Character>>, ? extends java.util.List<? extends java.util.Set<java.lang.Character>>>>);
    Code:
       0: aload_0
       1: checkcast     #76                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      13: astore_3
      14: aload_3
      15: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      20: ifeq          1308
      23: aload_3
      24: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      29: astore        4
      31: iload_2
      32: aload         4
      34: checkcast     #156                // class kotlin/Pair
      37: astore        5
      39: istore        34
      41: iconst_0
      42: istore        6
      44: aload         5
      46: invokevirtual #206                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      49: checkcast     #115                // class java/util/List
      52: astore        7
      54: aload         5
      56: invokevirtual #170                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      59: checkcast     #115                // class java/util/List
      62: astore        8
      64: iconst_0
      65: istore        9
      67: bipush        10
      69: anewarray     #175                // class java/util/Set
      72: astore        10
      74: iload         9
      76: bipush        10
      78: if_icmpge     99
      81: iload         9
      83: istore        11
      85: aload         10
      87: iload         11
      89: invokestatic  #212                // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;
      92: aastore
      93: iinc          9, 1
      96: goto          74
      99: aload         10
     101: astore        12
     103: new           #78                 // class java/util/ArrayList
     106: dup
     107: invokespecial #213                // Method java/util/ArrayList."<init>":()V
     110: checkcast     #115                // class java/util/List
     113: astore        9
     115: new           #78                 // class java/util/ArrayList
     118: dup
     119: invokespecial #213                // Method java/util/ArrayList."<init>":()V
     122: checkcast     #115                // class java/util/List
     125: astore        10
     127: aload         7
     129: invokeinterface #214,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     134: astore        11
     136: aload         11
     138: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     143: ifeq          268
     146: aload         11
     148: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     153: checkcast     #175                // class java/util/Set
     156: astore        13
     158: aload         13
     160: invokeinterface #185,  1          // InterfaceMethod java/util/Set.size:()I
     165: tableswitch   { // 2 to 7
                     2: 204
                     3: 213
                     4: 223
                     5: 242
                     6: 255
                     7: 232
               default: 265
          }
     204: aload         12
     206: iconst_1
     207: aload         13
     209: aastore
     210: goto          136
     213: aload         12
     215: bipush        7
     217: aload         13
     219: aastore
     220: goto          136
     223: aload         12
     225: iconst_4
     226: aload         13
     228: aastore
     229: goto          136
     232: aload         12
     234: bipush        8
     236: aload         13
     238: aastore
     239: goto          136
     242: aload         9
     244: aload         13
     246: invokeinterface #215,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     251: pop
     252: goto          136
     255: aload         10
     257: aload         13
     259: invokeinterface #215,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     264: pop
     265: goto          136
     268: aload         12
     270: bipush        6
     272: aload         10
     274: checkcast     #76                 // class java/lang/Iterable
     277: astore        11
     279: istore        14
     281: astore        15
     283: iconst_0
     284: istore        13
     286: aload         11
     288: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     293: astore        16
     295: aload         16
     297: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     302: ifeq          354
     305: aload         16
     307: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     312: astore        17
     314: aload         17
     316: checkcast     #175                // class java/util/Set
     319: astore        18
     321: iconst_0
     322: istore        19
     324: aload         18
     326: aload         12
     328: iconst_1
     329: aaload
     330: checkcast     #89                 // class java/util/Collection
     333: invokeinterface #219,  2          // InterfaceMethod java/util/Set.containsAll:(Ljava/util/Collection;)Z
     338: ifne          345
     341: iconst_1
     342: goto          346
     345: iconst_0
     346: ifeq          295
     349: aload         17
     351: goto          364
     354: new           #221                // class java/util/NoSuchElementException
     357: dup
     358: ldc           #223                // String Collection contains no element matching the predicate.
     360: invokespecial #224                // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
     363: athrow
     364: astore        20
     366: aload         15
     368: iload         14
     370: aload         20
     372: aastore
     373: aload         12
     375: bipush        9
     377: aload         10
     379: checkcast     #76                 // class java/lang/Iterable
     382: astore        11
     384: istore        14
     386: astore        15
     388: iconst_0
     389: istore        13
     391: aload         11
     393: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     398: astore        16
     400: aload         16
     402: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     407: ifeq          451
     410: aload         16
     412: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     417: astore        17
     419: aload         17
     421: checkcast     #175                // class java/util/Set
     424: astore        18
     426: iconst_0
     427: istore        19
     429: aload         18
     431: aload         12
     433: iconst_4
     434: aaload
     435: checkcast     #89                 // class java/util/Collection
     438: invokeinterface #219,  2          // InterfaceMethod java/util/Set.containsAll:(Ljava/util/Collection;)Z
     443: ifeq          400
     446: aload         17
     448: goto          461
     451: new           #221                // class java/util/NoSuchElementException
     454: dup
     455: ldc           #223                // String Collection contains no element matching the predicate.
     457: invokespecial #224                // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
     460: athrow
     461: astore        20
     463: aload         15
     465: iload         14
     467: aload         20
     469: aastore
     470: aload         12
     472: iconst_0
     473: aload         10
     475: checkcast     #76                 // class java/lang/Iterable
     478: astore        11
     480: istore        14
     482: astore        15
     484: iconst_0
     485: istore        13
     487: aload         11
     489: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     494: astore        16
     496: aload         16
     498: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     503: ifeq          564
     506: aload         16
     508: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     513: astore        17
     515: aload         17
     517: checkcast     #175                // class java/util/Set
     520: astore        18
     522: iconst_0
     523: istore        19
     525: aload         18
     527: aload         12
     529: bipush        6
     531: aaload
     532: invokestatic  #230                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     535: ifne          555
     538: aload         18
     540: aload         12
     542: bipush        9
     544: aaload
     545: invokestatic  #230                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     548: ifne          555
     551: iconst_1
     552: goto          556
     555: iconst_0
     556: ifeq          496
     559: aload         17
     561: goto          574
     564: new           #221                // class java/util/NoSuchElementException
     567: dup
     568: ldc           #223                // String Collection contains no element matching the predicate.
     570: invokespecial #224                // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
     573: athrow
     574: astore        20
     576: aload         15
     578: iload         14
     580: aload         20
     582: aastore
     583: aload         12
     585: iconst_3
     586: aload         9
     588: checkcast     #76                 // class java/lang/Iterable
     591: astore        11
     593: istore        14
     595: astore        15
     597: iconst_0
     598: istore        13
     600: aload         11
     602: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     607: astore        16
     609: aload         16
     611: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     616: ifeq          660
     619: aload         16
     621: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     626: astore        17
     628: aload         17
     630: checkcast     #175                // class java/util/Set
     633: astore        18
     635: iconst_0
     636: istore        19
     638: aload         18
     640: aload         12
     642: iconst_1
     643: aaload
     644: checkcast     #89                 // class java/util/Collection
     647: invokeinterface #219,  2          // InterfaceMethod java/util/Set.containsAll:(Ljava/util/Collection;)Z
     652: ifeq          609
     655: aload         17
     657: goto          670
     660: new           #221                // class java/util/NoSuchElementException
     663: dup
     664: ldc           #223                // String Collection contains no element matching the predicate.
     666: invokespecial #224                // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
     669: athrow
     670: astore        20
     672: aload         15
     674: iload         14
     676: aload         20
     678: aastore
     679: aload         12
     681: astore        13
     683: iconst_0
     684: istore        16
     686: aload         13
     688: astore        17
     690: new           #78                 // class java/util/ArrayList
     693: dup
     694: invokespecial #213                // Method java/util/ArrayList."<init>":()V
     697: checkcast     #89                 // class java/util/Collection
     700: astore        18
     702: iconst_0
     703: istore        19
     705: iconst_0
     706: istore        21
     708: aload         17
     710: arraylength
     711: istore        22
     713: iload         21
     715: iload         22
     717: if_icmpge     772
     720: aload         17
     722: iload         21
     724: aaload
     725: astore        23
     727: aload         23
     729: astore        24
     731: iconst_0
     732: istore        25
     734: aload         24
     736: checkcast     #89                 // class java/util/Collection
     739: invokeinterface #173,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     744: ifne          751
     747: iconst_1
     748: goto          752
     751: iconst_0
     752: nop
     753: ifeq          766
     756: aload         18
     758: aload         23
     760: invokeinterface #113,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     765: pop
     766: iinc          21, 1
     769: goto          713
     772: aload         18
     774: checkcast     #115                // class java/util/List
     777: nop
     778: astore        11
     780: new           #232                // class kotlin/ranges/CharRange
     783: dup
     784: bipush        97
     786: bipush        103
     788: invokespecial #235                // Method kotlin/ranges/CharRange."<init>":(CC)V
     791: checkcast     #76                 // class java/lang/Iterable
     794: astore        16
     796: iconst_0
     797: istore        17
     799: aload         16
     801: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     806: astore        18
     808: aload         18
     810: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     815: ifeq          937
     818: aload         18
     820: checkcast     #237                // class kotlin/collections/CharIterator
     823: invokevirtual #241                // Method kotlin/collections/CharIterator.nextChar:()C
     826: istore        19
     828: iload         19
     830: istore        21
     832: iconst_0
     833: istore        22
     835: aload         11
     837: checkcast     #76                 // class java/lang/Iterable
     840: astore        23
     842: iconst_0
     843: istore        24
     845: aload         23
     847: instanceof    #89                 // class java/util/Collection
     850: ifeq          870
     853: aload         23
     855: checkcast     #89                 // class java/util/Collection
     858: invokeinterface #173,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     863: ifeq          870
     866: iconst_1
     867: goto          928
     870: aload         23
     872: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     877: astore        25
     879: aload         25
     881: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     886: ifeq          927
     889: aload         25
     891: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     896: astore        26
     898: aload         26
     900: checkcast     #175                // class java/util/Set
     903: astore        27
     905: iconst_0
     906: istore        28
     908: aload         27
     910: iload         21
     912: invokestatic  #246                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     915: invokeinterface #248,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     920: ifne          879
     923: iconst_0
     924: goto          928
     927: iconst_1
     928: nop
     929: ifeq          808
     932: iload         19
     934: goto          947
     937: new           #221                // class java/util/NoSuchElementException
     940: dup
     941: ldc           #223                // String Collection contains no element matching the predicate.
     943: invokespecial #224                // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
     946: athrow
     947: istore        13
     949: aload         12
     951: iconst_2
     952: aload         9
     954: checkcast     #76                 // class java/lang/Iterable
     957: astore        16
     959: istore        14
     961: astore        15
     963: iconst_0
     964: istore        17
     966: aload         16
     968: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     973: astore        18
     975: aload         18
     977: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     982: ifeq          1032
     985: aload         18
     987: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     992: astore        19
     994: aload         19
     996: checkcast     #175                // class java/util/Set
     999: astore        21
    1001: iconst_0
    1002: istore        22
    1004: aload         21
    1006: iload         13
    1008: invokestatic  #246                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
    1011: invokeinterface #248,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
    1016: ifne          1023
    1019: iconst_1
    1020: goto          1024
    1023: iconst_0
    1024: ifeq          975
    1027: aload         19
    1029: goto          1042
    1032: new           #221                // class java/util/NoSuchElementException
    1035: dup
    1036: ldc           #223                // String Collection contains no element matching the predicate.
    1038: invokespecial #224                // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
    1041: athrow
    1042: astore        20
    1044: aload         15
    1046: iload         14
    1048: aload         20
    1050: aastore
    1051: aload         12
    1053: iconst_5
    1054: aload         9
    1056: checkcast     #76                 // class java/lang/Iterable
    1059: astore        16
    1061: istore        14
    1063: astore        15
    1065: iconst_0
    1066: istore        17
    1068: aload         16
    1070: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
    1075: astore        18
    1077: aload         18
    1079: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1084: ifeq          1143
    1087: aload         18
    1089: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1094: astore        19
    1096: aload         19
    1098: checkcast     #175                // class java/util/Set
    1101: astore        21
    1103: iconst_0
    1104: istore        22
    1106: aload         21
    1108: aload         12
    1110: iconst_3
    1111: aaload
    1112: invokestatic  #230                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
    1115: ifne          1134
    1118: aload         21
    1120: aload         12
    1122: iconst_2
    1123: aaload
    1124: invokestatic  #230                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
    1127: ifne          1134
    1130: iconst_1
    1131: goto          1135
    1134: iconst_0
    1135: ifeq          1077
    1138: aload         19
    1140: goto          1153
    1143: new           #221                // class java/util/NoSuchElementException
    1146: dup
    1147: ldc           #223                // String Collection contains no element matching the predicate.
    1149: invokespecial #224                // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
    1152: athrow
    1153: astore        20
    1155: aload         15
    1157: iload         14
    1159: aload         20
    1161: aastore
    1162: aload         8
    1164: checkcast     #76                 // class java/lang/Iterable
    1167: astore        16
    1169: iconst_0
    1170: istore        17
    1172: iconst_0
    1173: istore        18
    1175: iload         17
    1177: istore        19
    1179: aload         16
    1181: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
    1186: astore        21
    1188: aload         21
    1190: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1195: ifeq          1294
    1198: aload         21
    1200: invokeinterface #103,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1205: astore        22
    1207: iload         19
    1209: aload         22
    1211: checkcast     #175                // class java/util/Set
    1214: astore        23
    1216: istore        24
    1218: iconst_0
    1219: istore        25
    1221: iload         24
    1223: bipush        10
    1225: imul
    1226: aload         12
    1228: astore        26
    1230: istore        27
    1232: iconst_0
    1233: istore        28
    1235: iconst_0
    1236: istore        29
    1238: aload         26
    1240: arraylength
    1241: istore        30
    1243: iload         29
    1245: iload         30
    1247: if_icmpge     1281
    1250: aload         26
    1252: iload         29
    1254: aaload
    1255: astore        31
    1257: iconst_0
    1258: istore        32
    1260: aload         31
    1262: aload         23
    1264: invokestatic  #230                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
    1267: ifeq          1275
    1270: iload         29
    1272: goto          1282
    1275: iinc          29, 1
    1278: goto          1243
    1281: iconst_m1
    1282: istore        33
    1284: iload         27
    1286: iload         33
    1288: iadd
    1289: istore        19
    1291: goto          1188
    1294: iload         19
    1296: nop
    1297: istore        35
    1299: iload         34
    1301: iload         35
    1303: iadd
    1304: istore_2
    1305: goto          14
    1308: iload_2
    1309: ireturn

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