package day7

import java.io.File
import kotlin.math.absoluteValue

fun readCrabSubmarines(): List<Int> {
    return File("day7.txt")
        .readLines()[0]
        .split(",")
        .map { it.toInt() }
}

fun calculateFuelSimple(crabSubmarines: List<Int>, position: Int): Int {
    return crabSubmarines.sumOf { current ->
        (current - position).absoluteValue
    }
}

fun calculateFuelComplex(crabSubmarines: List<Int>, position: Int): Int {
    return crabSubmarines.sumOf { current ->
        val steps = (current - position).absoluteValue
        (steps * (steps + 1)) / 2
    }
}

fun List<Int>.findCheapestPosition(
    calculateFuel: (List<Int>, Int) -> Int
): Pair<Int, Int> {
    val min = minOrNull() ?: throw IllegalStateException("No min")
    val max = maxOrNull() ?: throw IllegalStateException("No max")

    println("Range: $min - $max")

    var cheapestPosition: Int? = null
    var fuelNeeded: Int? = null

    for (position in min..max) {
        val fuel = calculateFuel(this, position)
        if (fuelNeeded == null || fuel < fuelNeeded) {
            cheapestPosition = position
            fuelNeeded = fuel
        }
    }

    return Pair(cheapestPosition!!, fuelNeeded!!)
}

fun part2() {
    val crabSubmarines = readCrabSubmarines()
    val (position, fuel) = crabSubmarines.findCheapestPosition { submarines, position ->
        calculateFuelComplex(submarines, position)
    }

    println("Position: $position")
    println("Fuel: $fuel")
}

fun part1() {
    val crabSubmarines = readCrabSubmarines()
    val (position, fuel) = crabSubmarines.findCheapestPosition { submarines, position ->
        calculateFuelSimple(submarines, position)
    }

    println("Position: $position")
    println("Fuel: $fuel")
}

fun main() {
    part2()
}

Compiled from "Day7.kt"
public final class day7.Day7Kt {
  public static final java.util.List<java.lang.Integer> readCrabSubmarines();
    Code:
       0: new           #10                 // class java/io/File
       3: dup
       4: ldc           #12                 // String day7.txt
       6: invokespecial #16                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #22                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      15: iconst_0
      16: invokeinterface #28,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      21: checkcast     #30                 // class java/lang/CharSequence
      24: iconst_1
      25: anewarray     #32                 // class java/lang/String
      28: astore_0
      29: aload_0
      30: iconst_0
      31: ldc           #34                 // String ,
      33: aastore
      34: aload_0
      35: iconst_0
      36: iconst_0
      37: bipush        6
      39: aconst_null
      40: invokestatic  #40                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      43: checkcast     #42                 // class java/lang/Iterable
      46: astore_0
      47: nop
      48: iconst_0
      49: istore_1
      50: aload_0
      51: astore_2
      52: new           #44                 // class java/util/ArrayList
      55: dup
      56: aload_0
      57: bipush        10
      59: invokestatic  #50                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      62: invokespecial #53                 // Method java/util/ArrayList."<init>":(I)V
      65: checkcast     #55                 // class java/util/Collection
      68: astore_3
      69: iconst_0
      70: istore        4
      72: aload_2
      73: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      78: astore        5
      80: aload         5
      82: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      87: ifeq          133
      90: aload         5
      92: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      97: astore        6
      99: aload_3
     100: aload         6
     102: checkcast     #32                 // class java/lang/String
     105: astore        7
     107: astore        9
     109: iconst_0
     110: istore        8
     112: aload         7
     114: invokestatic  #75                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     117: nop
     118: invokestatic  #79                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     121: aload         9
     123: swap
     124: invokeinterface #83,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     129: pop
     130: goto          80
     133: aload_3
     134: checkcast     #24                 // class java/util/List
     137: nop
     138: areturn

  public static final int calculateFuelSimple(java.util.List<java.lang.Integer>, int);
    Code:
       0: aload_0
       1: ldc           #101                // String crabSubmarines
       3: invokestatic  #107                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #42                 // class java/lang/Iterable
      10: astore_2
      11: iconst_0
      12: istore_3
      13: aload_2
      14: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      19: astore        4
      21: aload         4
      23: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      28: ifeq          75
      31: aload         4
      33: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      38: astore        5
      40: iload_3
      41: aload         5
      43: checkcast     #109                // class java/lang/Number
      46: invokevirtual #113                // Method java/lang/Number.intValue:()I
      49: istore        6
      51: istore        8
      53: iconst_0
      54: istore        7
      56: iload         6
      58: iload_1
      59: isub
      60: invokestatic  #119                // Method java/lang/Math.abs:(I)I
      63: nop
      64: istore        9
      66: iload         8
      68: iload         9
      70: iadd
      71: istore_3
      72: goto          21
      75: iload_3
      76: ireturn

  public static final int calculateFuelComplex(java.util.List<java.lang.Integer>, int);
    Code:
       0: aload_0
       1: ldc           #101                // String crabSubmarines
       3: invokestatic  #107                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #42                 // class java/lang/Iterable
      10: astore_2
      11: iconst_0
      12: istore_3
      13: aload_2
      14: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      19: astore        4
      21: aload         4
      23: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      28: ifeq          85
      31: aload         4
      33: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      38: astore        5
      40: iload_3
      41: aload         5
      43: checkcast     #109                // class java/lang/Number
      46: invokevirtual #113                // Method java/lang/Number.intValue:()I
      49: istore        6
      51: istore        9
      53: iconst_0
      54: istore        7
      56: iload         6
      58: iload_1
      59: isub
      60: invokestatic  #119                // Method java/lang/Math.abs:(I)I
      63: istore        8
      65: iload         8
      67: iload         8
      69: iconst_1
      70: iadd
      71: imul
      72: iconst_2
      73: idiv
      74: istore        10
      76: iload         9
      78: iload         10
      80: iadd
      81: istore_3
      82: goto          21
      85: iload_3
      86: ireturn

  public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> findCheapestPosition(java.util.List<java.lang.Integer>, kotlin.jvm.functions.Function2<? super java.util.List<java.lang.Integer>, ? super java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #131                // String <this>
       3: invokestatic  #107                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #133                // String calculateFuel
       9: invokestatic  #107                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: checkcast     #42                 // class java/lang/Iterable
      16: invokestatic  #137                // Method kotlin/collections/CollectionsKt.minOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
      19: checkcast     #71                 // class java/lang/Integer
      22: dup
      23: ifnull        32
      26: invokevirtual #138                // Method java/lang/Integer.intValue:()I
      29: goto          43
      32: pop
      33: new           #140                // class java/lang/IllegalStateException
      36: dup
      37: ldc           #142                // String No min
      39: invokespecial #143                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      42: athrow
      43: istore_2
      44: aload_0
      45: checkcast     #42                 // class java/lang/Iterable
      48: invokestatic  #146                // Method kotlin/collections/CollectionsKt.maxOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
      51: checkcast     #71                 // class java/lang/Integer
      54: dup
      55: ifnull        64
      58: invokevirtual #138                // Method java/lang/Integer.intValue:()I
      61: goto          75
      64: pop
      65: new           #140                // class java/lang/IllegalStateException
      68: dup
      69: ldc           #148                // String No max
      71: invokespecial #143                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      74: athrow
      75: istore_3
      76: new           #150                // class java/lang/StringBuilder
      79: dup
      80: invokespecial #153                // Method java/lang/StringBuilder."<init>":()V
      83: ldc           #155                // String Range:
      85: invokevirtual #159                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      88: iload_2
      89: invokevirtual #162                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      92: ldc           #164                // String  -
      94: invokevirtual #159                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      97: iload_3
      98: invokevirtual #162                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     101: invokevirtual #168                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     104: getstatic     #174                // Field java/lang/System.out:Ljava/io/PrintStream;
     107: swap
     108: invokevirtual #180                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     111: aconst_null
     112: astore        4
     114: aconst_null
     115: astore        5
     117: iload_2
     118: istore        6
     120: iload         6
     122: iload_3
     123: if_icmpgt     187
     126: aload_1
     127: aload_0
     128: iload         6
     130: invokestatic  #79                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     133: invokeinterface #186,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     138: checkcast     #109                // class java/lang/Number
     141: invokevirtual #113                // Method java/lang/Number.intValue:()I
     144: istore        7
     146: aload         5
     148: ifnull        161
     151: iload         7
     153: aload         5
     155: invokevirtual #138                // Method java/lang/Integer.intValue:()I
     158: if_icmpge     175
     161: iload         6
     163: invokestatic  #79                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     166: astore        4
     168: iload         7
     170: invokestatic  #79                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     173: astore        5
     175: iload         6
     177: iload_3
     178: if_icmpeq     187
     181: iinc          6, 1
     184: goto          126
     187: new           #188                // class kotlin/Pair
     190: dup
     191: aload         4
     193: dup
     194: invokestatic  #191                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     197: aload         5
     199: dup
     200: invokestatic  #191                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     203: invokespecial #194                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     206: areturn

  public static final void part2();
    Code:
       0: invokestatic  #205                // Method readCrabSubmarines:()Ljava/util/List;
       3: astore_0
       4: aload_0
       5: invokedynamic #222,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;
      10: invokestatic  #224                // Method findCheapestPosition:(Ljava/util/List;Lkotlin/jvm/functions/Function2;)Lkotlin/Pair;
      13: astore_1
      14: aload_1
      15: invokevirtual #227                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      18: checkcast     #109                // class java/lang/Number
      21: invokevirtual #113                // Method java/lang/Number.intValue:()I
      24: istore_2
      25: aload_1
      26: invokevirtual #230                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      29: checkcast     #109                // class java/lang/Number
      32: invokevirtual #113                // Method java/lang/Number.intValue:()I
      35: istore_3
      36: new           #150                // class java/lang/StringBuilder
      39: dup
      40: invokespecial #153                // Method java/lang/StringBuilder."<init>":()V
      43: ldc           #232                // String Position:
      45: invokevirtual #159                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      48: iload_2
      49: invokevirtual #162                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      52: invokevirtual #168                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      55: getstatic     #174                // Field java/lang/System.out:Ljava/io/PrintStream;
      58: swap
      59: invokevirtual #180                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      62: new           #150                // class java/lang/StringBuilder
      65: dup
      66: invokespecial #153                // Method java/lang/StringBuilder."<init>":()V
      69: ldc           #234                // String Fuel:
      71: invokevirtual #159                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      74: iload_3
      75: invokevirtual #162                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      78: invokevirtual #168                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      81: getstatic     #174                // Field java/lang/System.out:Ljava/io/PrintStream;
      84: swap
      85: invokevirtual #180                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      88: return

  public static final void part1();
    Code:
       0: invokestatic  #205                // Method readCrabSubmarines:()Ljava/util/List;
       3: astore_0
       4: aload_0
       5: invokedynamic #240,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function2;
      10: invokestatic  #224                // Method findCheapestPosition:(Ljava/util/List;Lkotlin/jvm/functions/Function2;)Lkotlin/Pair;
      13: astore_1
      14: aload_1
      15: invokevirtual #227                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      18: checkcast     #109                // class java/lang/Number
      21: invokevirtual #113                // Method java/lang/Number.intValue:()I
      24: istore_2
      25: aload_1
      26: invokevirtual #230                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      29: checkcast     #109                // class java/lang/Number
      32: invokevirtual #113                // Method java/lang/Number.intValue:()I
      35: istore_3
      36: new           #150                // class java/lang/StringBuilder
      39: dup
      40: invokespecial #153                // Method java/lang/StringBuilder."<init>":()V
      43: ldc           #232                // String Position:
      45: invokevirtual #159                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      48: iload_2
      49: invokevirtual #162                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      52: invokevirtual #168                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      55: getstatic     #174                // Field java/lang/System.out:Ljava/io/PrintStream;
      58: swap
      59: invokevirtual #180                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      62: new           #150                // class java/lang/StringBuilder
      65: dup
      66: invokespecial #153                // Method java/lang/StringBuilder."<init>":()V
      69: ldc           #234                // String Fuel:
      71: invokevirtual #159                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      74: iload_3
      75: invokevirtual #162                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      78: invokevirtual #168                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      81: getstatic     #174                // Field java/lang/System.out:Ljava/io/PrintStream;
      84: swap
      85: invokevirtual #180                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      88: return

  public static final void main();
    Code:
       0: invokestatic  #243                // Method part2:()V
       3: return

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

  private static final int part2$lambda$3(java.util.List, int);
    Code:
       0: aload_0
       1: ldc           #250                // String submarines
       3: invokestatic  #107                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iload_1
       8: invokestatic  #252                // Method calculateFuelComplex:(Ljava/util/List;I)I
      11: ireturn

  private static final int part1$lambda$4(java.util.List, int);
    Code:
       0: aload_0
       1: ldc           #250                // String submarines
       3: invokestatic  #107                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iload_1
       8: invokestatic  #254                // Method calculateFuelSimple:(Ljava/util/List;I)I
      11: ireturn
}


package day9

import java.io.File

fun readInput(filename: String = "day9.txt"): List<List<Int>>{
    return File(filename)
        .readLines()
        .map { line -> line.toCharArray().map { character -> character.digitToInt() } }
}

fun List<List<Int>>.neighbours(x: Int, y: Int): List<Int> {
    val top = get(x).getOrNull(y - 1)
    val bottom = get(x).getOrNull(y + 1)
    val left = getOrNull(x - 1)?.get(y)
    val right = getOrNull(x + 1)?.get(y)

    return listOfNotNull(top, left, right, bottom)
}

fun List<List<Int>>.isValid(x: Int, y: Int): Boolean {
    return x in indices && y in get(0).indices
}

fun List<List<Int>>.neighbourPositions(x: Int, y: Int): List<Pair<Int, Int>> {
    val top = Pair(x, y - 1)
    val bottom = Pair(x, y + 1)
    val left = Pair(x - 1, y)
    val right = Pair(x + 1, y)

    return listOf(top, bottom, left, right).filter { (x, y) -> isValid(x, y) }
}

fun part1() {
    val input = readInput()
    var riskLevel = 0

    for (x in input.indices) {
        for (y in input[0].indices) {
            val current = input[x][y]
            val neighbours = input.neighbours(x, y)
            if (neighbours.all { value -> value > current }) {
                riskLevel += current + 1
            }
        }
    }

    println("Risk level: $riskLevel")
}

fun List<List<Int>>.findLowPoints(): List<Pair<Int, Int>> {
    val lowPoints = mutableListOf<Pair<Int, Int>>()

    for (x in indices) {
        for (y in get(0).indices) {
            val current = get(x)[y]
            val neighbours = neighbours(x, y)

            if (neighbours.all { value -> value > current }) {
                lowPoints.add(Pair(x, y))
            }
        }
    }

    return lowPoints
}

fun List<List<Int>>.findBasin(x: Int, y: Int): Set<Pair<Int, Int>> {
    val visitedPoints = mutableSetOf<Pair<Int, Int>>()
    val queue = mutableListOf(Pair(x, y))

    while (queue.isNotEmpty()) {
        val point = queue.removeFirst()
        visitedPoints.add(point)

        val neighbours = neighbourPositions(point.first, point.second)
        neighbours.forEach { neighbour ->
            if (!visitedPoints.contains(neighbour)) {
                if (get(neighbour.first)[neighbour.second] != 9) {
                    queue.add(neighbour)
                }
            }
        }
    }

    return visitedPoints
}

fun part2() {
    val input = readInput("day9.txt")
    val lowPoints = input.findLowPoints()

    val basins = lowPoints.map { point ->
        input.findBasin(point.first, point.second)
    }.sortedByDescending { points ->
        points.size
    }

    println("Basins: ${basins.size}")

    var result = 1
    basins.take(3).forEach { points ->
        result *= points.size
    }

    println("Result: $result")
}

fun main() {
    part2()
}

Compiled from "Day9.kt"
public final class day9.Day9Kt {
  public static final java.util.List<java.util.List<java.lang.Integer>> readInput(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #10                 // String filename
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #18                 // class java/io/File
       9: dup
      10: aload_0
      11: invokespecial #22                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      14: aconst_null
      15: iconst_1
      16: aconst_null
      17: invokestatic  #28                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      20: checkcast     #30                 // class java/lang/Iterable
      23: astore_1
      24: nop
      25: iconst_0
      26: istore_2
      27: aload_1
      28: astore_3
      29: new           #32                 // class java/util/ArrayList
      32: dup
      33: aload_1
      34: bipush        10
      36: invokestatic  #38                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      39: invokespecial #41                 // Method java/util/ArrayList."<init>":(I)V
      42: checkcast     #43                 // class java/util/Collection
      45: astore        4
      47: iconst_0
      48: istore        5
      50: aload_3
      51: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      56: astore        6
      58: aload         6
      60: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      65: ifeq          205
      68: aload         6
      70: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      75: astore        7
      77: aload         4
      79: aload         7
      81: checkcast     #59                 // class java/lang/String
      84: astore        8
      86: astore        21
      88: iconst_0
      89: istore        9
      91: aload         8
      93: invokevirtual #63                 // Method java/lang/String.toCharArray:()[C
      96: dup
      97: ldc           #65                 // String toCharArray(...)
      99: invokestatic  #68                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     102: astore        10
     104: nop
     105: iconst_0
     106: istore        11
     108: aload         10
     110: astore        12
     112: new           #32                 // class java/util/ArrayList
     115: dup
     116: aload         10
     118: arraylength
     119: invokespecial #41                 // Method java/util/ArrayList."<init>":(I)V
     122: checkcast     #43                 // class java/util/Collection
     125: astore        13
     127: iconst_0
     128: istore        14
     130: iconst_0
     131: istore        15
     133: aload         12
     135: arraylength
     136: istore        16
     138: iload         15
     140: iload         16
     142: if_icmpge     186
     145: aload         12
     147: iload         15
     149: caload
     150: istore        17
     152: aload         13
     154: iload         17
     156: istore        18
     158: astore        19
     160: iconst_0
     161: istore        20
     163: iload         18
     165: invokestatic  #74                 // Method kotlin/text/CharsKt.digitToInt:(C)I
     168: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     171: aload         19
     173: swap
     174: invokeinterface #84,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     179: pop
     180: iinc          15, 1
     183: goto          138
     186: aload         13
     188: checkcast     #86                 // class java/util/List
     191: nop
     192: nop
     193: aload         21
     195: swap
     196: invokeinterface #84,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     201: pop
     202: goto          58
     205: aload         4
     207: checkcast     #86                 // class java/util/List
     210: nop
     211: areturn

  public static java.util.List readInput$default(java.lang.String, int, java.lang.Object);
    Code:
       0: iload_1
       1: iconst_1
       2: iand
       3: ifeq          9
       6: ldc           #108                // String day9.txt
       8: astore_0
       9: aload_0
      10: invokestatic  #110                // Method readInput:(Ljava/lang/String;)Ljava/util/List;
      13: areturn

  public static final java.util.List<java.lang.Integer> neighbours(java.util.List<? extends java.util.List<java.lang.Integer>>, int, int);
    Code:
       0: aload_0
       1: ldc           #115                // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iload_1
       8: invokeinterface #119,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      13: checkcast     #86                 // class java/util/List
      16: iload_2
      17: iconst_1
      18: isub
      19: invokestatic  #123                // Method kotlin/collections/CollectionsKt.getOrNull:(Ljava/util/List;I)Ljava/lang/Object;
      22: checkcast     #76                 // class java/lang/Integer
      25: astore_3
      26: aload_0
      27: iload_1
      28: invokeinterface #119,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      33: checkcast     #86                 // class java/util/List
      36: iload_2
      37: iconst_1
      38: iadd
      39: invokestatic  #123                // Method kotlin/collections/CollectionsKt.getOrNull:(Ljava/util/List;I)Ljava/lang/Object;
      42: checkcast     #76                 // class java/lang/Integer
      45: astore        4
      47: aload_0
      48: iload_1
      49: iconst_1
      50: isub
      51: invokestatic  #123                // Method kotlin/collections/CollectionsKt.getOrNull:(Ljava/util/List;I)Ljava/lang/Object;
      54: checkcast     #86                 // class java/util/List
      57: dup
      58: ifnull        73
      61: iload_2
      62: invokeinterface #119,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      67: checkcast     #76                 // class java/lang/Integer
      70: goto          75
      73: pop
      74: aconst_null
      75: astore        5
      77: aload_0
      78: iload_1
      79: iconst_1
      80: iadd
      81: invokestatic  #123                // Method kotlin/collections/CollectionsKt.getOrNull:(Ljava/util/List;I)Ljava/lang/Object;
      84: checkcast     #86                 // class java/util/List
      87: dup
      88: ifnull        103
      91: iload_2
      92: invokeinterface #119,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      97: checkcast     #76                 // class java/lang/Integer
     100: goto          105
     103: pop
     104: aconst_null
     105: astore        6
     107: iconst_4
     108: anewarray     #76                 // class java/lang/Integer
     111: astore        7
     113: aload         7
     115: iconst_0
     116: aload_3
     117: aastore
     118: aload         7
     120: iconst_1
     121: aload         5
     123: aastore
     124: aload         7
     126: iconst_2
     127: aload         6
     129: aastore
     130: aload         7
     132: iconst_3
     133: aload         4
     135: aastore
     136: aload         7
     138: invokestatic  #127                // Method kotlin/collections/CollectionsKt.listOfNotNull:([Ljava/lang/Object;)Ljava/util/List;
     141: areturn

  public static final boolean isValid(java.util.List<? extends java.util.List<java.lang.Integer>>, int, int);
    Code:
       0: aload_0
       1: ldc           #115                // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: iload_1
       8: if_icmpgt     32
      11: iload_1
      12: aload_0
      13: checkcast     #43                 // class java/util/Collection
      16: invokeinterface #143,  1          // InterfaceMethod java/util/Collection.size:()I
      21: if_icmpge     28
      24: iconst_1
      25: goto          33
      28: iconst_0
      29: goto          33
      32: iconst_0
      33: ifeq          76
      36: iconst_0
      37: iload_2
      38: if_icmpgt     68
      41: iload_2
      42: aload_0
      43: iconst_0
      44: invokeinterface #119,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      49: checkcast     #43                 // class java/util/Collection
      52: invokeinterface #143,  1          // InterfaceMethod java/util/Collection.size:()I
      57: if_icmpge     64
      60: iconst_1
      61: goto          69
      64: iconst_0
      65: goto          69
      68: iconst_0
      69: ifeq          76
      72: iconst_1
      73: goto          77
      76: iconst_0
      77: ireturn

  public static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> neighbourPositions(java.util.List<? extends java.util.List<java.lang.Integer>>, int, int);
    Code:
       0: aload_0
       1: ldc           #115                // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #148                // class kotlin/Pair
       9: dup
      10: iload_1
      11: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      14: iload_2
      15: iconst_1
      16: isub
      17: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      20: invokespecial #151                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      23: astore_3
      24: new           #148                // class kotlin/Pair
      27: dup
      28: iload_1
      29: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      32: iload_2
      33: iconst_1
      34: iadd
      35: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      38: invokespecial #151                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      41: astore        4
      43: new           #148                // class kotlin/Pair
      46: dup
      47: iload_1
      48: iconst_1
      49: isub
      50: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      53: iload_2
      54: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      57: invokespecial #151                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      60: astore        5
      62: new           #148                // class kotlin/Pair
      65: dup
      66: iload_1
      67: iconst_1
      68: iadd
      69: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      72: iload_2
      73: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      76: invokespecial #151                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      79: astore        6
      81: iconst_4
      82: anewarray     #148                // class kotlin/Pair
      85: astore        7
      87: aload         7
      89: iconst_0
      90: aload_3
      91: aastore
      92: aload         7
      94: iconst_1
      95: aload         4
      97: aastore
      98: aload         7
     100: iconst_2
     101: aload         5
     103: aastore
     104: aload         7
     106: iconst_3
     107: aload         6
     109: aastore
     110: aload         7
     112: invokestatic  #154                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     115: checkcast     #30                 // class java/lang/Iterable
     118: astore        7
     120: iconst_0
     121: istore        8
     123: aload         7
     125: astore        9
     127: new           #32                 // class java/util/ArrayList
     130: dup
     131: invokespecial #157                // Method java/util/ArrayList."<init>":()V
     134: checkcast     #43                 // class java/util/Collection
     137: astore        10
     139: iconst_0
     140: istore        11
     142: aload         9
     144: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     149: astore        12
     151: aload         12
     153: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     158: ifeq          230
     161: aload         12
     163: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     168: astore        13
     170: aload         13
     172: checkcast     #148                // class kotlin/Pair
     175: astore        14
     177: iconst_0
     178: istore        15
     180: aload         14
     182: invokevirtual #160                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     185: checkcast     #162                // class java/lang/Number
     188: invokevirtual #165                // Method java/lang/Number.intValue:()I
     191: istore        16
     193: aload         14
     195: invokevirtual #168                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     198: checkcast     #162                // class java/lang/Number
     201: invokevirtual #165                // Method java/lang/Number.intValue:()I
     204: istore        17
     206: aload_0
     207: iload         16
     209: iload         17
     211: invokestatic  #170                // Method isValid:(Ljava/util/List;II)Z
     214: ifeq          151
     217: aload         10
     219: aload         13
     221: invokeinterface #84,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     226: pop
     227: goto          151
     230: aload         10
     232: checkcast     #86                 // class java/util/List
     235: nop
     236: areturn

  public static final void part1();
    Code:
       0: aconst_null
       1: iconst_1
       2: aconst_null
       3: invokestatic  #181                // Method readInput$default:(Ljava/lang/String;ILjava/lang/Object;)Ljava/util/List;
       6: astore_0
       7: iconst_0
       8: istore_1
       9: iconst_0
      10: istore_2
      11: aload_0
      12: checkcast     #43                 // class java/util/Collection
      15: invokeinterface #143,  1          // InterfaceMethod java/util/Collection.size:()I
      20: istore_3
      21: iload_2
      22: iload_3
      23: if_icmpge     205
      26: iconst_0
      27: istore        4
      29: aload_0
      30: iconst_0
      31: invokeinterface #119,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      36: checkcast     #43                 // class java/util/Collection
      39: invokeinterface #143,  1          // InterfaceMethod java/util/Collection.size:()I
      44: istore        5
      46: iload         4
      48: iload         5
      50: if_icmpge     199
      53: aload_0
      54: iload_2
      55: invokeinterface #119,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      60: checkcast     #86                 // class java/util/List
      63: iload         4
      65: invokeinterface #119,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      70: checkcast     #162                // class java/lang/Number
      73: invokevirtual #165                // Method java/lang/Number.intValue:()I
      76: istore        6
      78: aload_0
      79: iload_2
      80: iload         4
      82: invokestatic  #183                // Method neighbours:(Ljava/util/List;II)Ljava/util/List;
      85: astore        7
      87: aload         7
      89: checkcast     #30                 // class java/lang/Iterable
      92: astore        8
      94: iconst_0
      95: istore        9
      97: aload         8
      99: instanceof    #43                 // class java/util/Collection
     102: ifeq          122
     105: aload         8
     107: checkcast     #43                 // class java/util/Collection
     110: invokeinterface #186,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     115: ifeq          122
     118: iconst_1
     119: goto          183
     122: aload         8
     124: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     129: astore        10
     131: aload         10
     133: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     138: ifeq          182
     141: aload         10
     143: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     148: astore        11
     150: aload         11
     152: checkcast     #162                // class java/lang/Number
     155: invokevirtual #165                // Method java/lang/Number.intValue:()I
     158: istore        12
     160: iconst_0
     161: istore        13
     163: iload         12
     165: iload         6
     167: if_icmple     174
     170: iconst_1
     171: goto          175
     174: iconst_0
     175: ifne          131
     178: iconst_0
     179: goto          183
     182: iconst_1
     183: ifeq          193
     186: iload_1
     187: iload         6
     189: iconst_1
     190: iadd
     191: iadd
     192: istore_1
     193: iinc          4, 1
     196: goto          46
     199: iinc          2, 1
     202: goto          21
     205: new           #188                // class java/lang/StringBuilder
     208: dup
     209: invokespecial #189                // Method java/lang/StringBuilder."<init>":()V
     212: ldc           #191                // String Risk level:
     214: invokevirtual #195                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     217: iload_1
     218: invokevirtual #198                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     221: invokevirtual #202                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     224: getstatic     #208                // Field java/lang/System.out:Ljava/io/PrintStream;
     227: swap
     228: invokevirtual #214                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     231: return

  public static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> findLowPoints(java.util.List<? extends java.util.List<java.lang.Integer>>);
    Code:
       0: aload_0
       1: ldc           #115                // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #32                 // class java/util/ArrayList
       9: dup
      10: invokespecial #157                // Method java/util/ArrayList."<init>":()V
      13: checkcast     #86                 // class java/util/List
      16: astore_1
      17: iconst_0
      18: istore_2
      19: aload_0
      20: checkcast     #43                 // class java/util/Collection
      23: invokeinterface #143,  1          // InterfaceMethod java/util/Collection.size:()I
      28: istore_3
      29: iload_2
      30: iload_3
      31: if_icmpge     229
      34: iconst_0
      35: istore        4
      37: aload_0
      38: iconst_0
      39: invokeinterface #119,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      44: checkcast     #43                 // class java/util/Collection
      47: invokeinterface #143,  1          // InterfaceMethod java/util/Collection.size:()I
      52: istore        5
      54: iload         4
      56: iload         5
      58: if_icmpge     223
      61: aload_0
      62: iload_2
      63: invokeinterface #119,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      68: checkcast     #86                 // class java/util/List
      71: iload         4
      73: invokeinterface #119,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      78: checkcast     #162                // class java/lang/Number
      81: invokevirtual #165                // Method java/lang/Number.intValue:()I
      84: istore        6
      86: aload_0
      87: iload_2
      88: iload         4
      90: invokestatic  #183                // Method neighbours:(Ljava/util/List;II)Ljava/util/List;
      93: astore        7
      95: aload         7
      97: checkcast     #30                 // class java/lang/Iterable
     100: astore        8
     102: iconst_0
     103: istore        9
     105: aload         8
     107: instanceof    #43                 // class java/util/Collection
     110: ifeq          130
     113: aload         8
     115: checkcast     #43                 // class java/util/Collection
     118: invokeinterface #186,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     123: ifeq          130
     126: iconst_1
     127: goto          191
     130: aload         8
     132: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     137: astore        10
     139: aload         10
     141: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     146: ifeq          190
     149: aload         10
     151: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     156: astore        11
     158: aload         11
     160: checkcast     #162                // class java/lang/Number
     163: invokevirtual #165                // Method java/lang/Number.intValue:()I
     166: istore        12
     168: iconst_0
     169: istore        13
     171: iload         12
     173: iload         6
     175: if_icmple     182
     178: iconst_1
     179: goto          183
     182: iconst_0
     183: ifne          139
     186: iconst_0
     187: goto          191
     190: iconst_1
     191: ifeq          217
     194: aload_1
     195: new           #148                // class kotlin/Pair
     198: dup
     199: iload_2
     200: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     203: iload         4
     205: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     208: invokespecial #151                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     211: invokeinterface #226,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     216: pop
     217: iinc          4, 1
     220: goto          54
     223: iinc          2, 1
     226: goto          29
     229: aload_1
     230: areturn

  public static final java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>> findBasin(java.util.List<? extends java.util.List<java.lang.Integer>>, int, int);
    Code:
       0: aload_0
       1: ldc           #115                // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #234                // class java/util/LinkedHashSet
       9: dup
      10: invokespecial #235                // Method java/util/LinkedHashSet."<init>":()V
      13: checkcast     #237                // class java/util/Set
      16: astore_3
      17: iconst_1
      18: anewarray     #148                // class kotlin/Pair
      21: astore        5
      23: aload         5
      25: iconst_0
      26: new           #148                // class kotlin/Pair
      29: dup
      30: iload_1
      31: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      34: iload_2
      35: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      38: invokespecial #151                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      41: aastore
      42: aload         5
      44: invokestatic  #240                // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
      47: astore        4
      49: aload         4
      51: checkcast     #43                 // class java/util/Collection
      54: invokeinterface #186,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      59: ifne          66
      62: iconst_1
      63: goto          67
      66: iconst_0
      67: ifeq          250
      70: aload         4
      72: invokeinterface #243,  1          // InterfaceMethod java/util/List.removeFirst:()Ljava/lang/Object;
      77: dup
      78: ldc           #245                // String removeFirst(...)
      80: invokestatic  #68                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      83: checkcast     #148                // class kotlin/Pair
      86: astore        5
      88: aload_3
      89: aload         5
      91: invokeinterface #246,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
      96: pop
      97: aload_0
      98: aload         5
     100: invokevirtual #249                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     103: checkcast     #162                // class java/lang/Number
     106: invokevirtual #165                // Method java/lang/Number.intValue:()I
     109: aload         5
     111: invokevirtual #252                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     114: checkcast     #162                // class java/lang/Number
     117: invokevirtual #165                // Method java/lang/Number.intValue:()I
     120: invokestatic  #254                // Method neighbourPositions:(Ljava/util/List;II)Ljava/util/List;
     123: astore        6
     125: aload         6
     127: checkcast     #30                 // class java/lang/Iterable
     130: astore        7
     132: iconst_0
     133: istore        8
     135: aload         7
     137: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     142: astore        9
     144: aload         9
     146: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     151: ifeq          246
     154: aload         9
     156: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     161: astore        10
     163: aload         10
     165: checkcast     #148                // class kotlin/Pair
     168: astore        11
     170: iconst_0
     171: istore        12
     173: aload_3
     174: aload         11
     176: invokeinterface #257,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     181: ifne          241
     184: aload_0
     185: aload         11
     187: invokevirtual #249                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     190: checkcast     #162                // class java/lang/Number
     193: invokevirtual #165                // Method java/lang/Number.intValue:()I
     196: invokeinterface #119,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     201: checkcast     #86                 // class java/util/List
     204: aload         11
     206: invokevirtual #252                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     209: checkcast     #162                // class java/lang/Number
     212: invokevirtual #165                // Method java/lang/Number.intValue:()I
     215: invokeinterface #119,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     220: checkcast     #162                // class java/lang/Number
     223: invokevirtual #165                // Method java/lang/Number.intValue:()I
     226: bipush        9
     228: if_icmpeq     241
     231: aload         4
     233: aload         11
     235: invokeinterface #226,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     240: pop
     241: nop
     242: nop
     243: goto          144
     246: nop
     247: goto          49
     250: aload_3
     251: areturn

  public static final void part2();
    Code:
       0: ldc           #108                // String day9.txt
       2: invokestatic  #110                // Method readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #269                // Method findLowPoints:(Ljava/util/List;)Ljava/util/List;
      10: astore_1
      11: aload_1
      12: checkcast     #30                 // class java/lang/Iterable
      15: astore_3
      16: iconst_0
      17: istore        4
      19: aload_3
      20: astore        5
      22: new           #32                 // class java/util/ArrayList
      25: dup
      26: aload_3
      27: bipush        10
      29: invokestatic  #38                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      32: invokespecial #41                 // Method java/util/ArrayList."<init>":(I)V
      35: checkcast     #43                 // class java/util/Collection
      38: astore        6
      40: iconst_0
      41: istore        7
      43: aload         5
      45: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      50: astore        8
      52: aload         8
      54: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      59: ifeq          123
      62: aload         8
      64: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      69: astore        9
      71: aload         6
      73: aload         9
      75: checkcast     #148                // class kotlin/Pair
      78: astore        10
      80: astore        12
      82: iconst_0
      83: istore        11
      85: aload_0
      86: aload         10
      88: invokevirtual #249                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      91: checkcast     #162                // class java/lang/Number
      94: invokevirtual #165                // Method java/lang/Number.intValue:()I
      97: aload         10
      99: invokevirtual #252                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     102: checkcast     #162                // class java/lang/Number
     105: invokevirtual #165                // Method java/lang/Number.intValue:()I
     108: invokestatic  #271                // Method findBasin:(Ljava/util/List;II)Ljava/util/Set;
     111: aload         12
     113: swap
     114: invokeinterface #84,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     119: pop
     120: goto          52
     123: aload         6
     125: checkcast     #86                 // class java/util/List
     128: nop
     129: checkcast     #30                 // class java/lang/Iterable
     132: astore_3
     133: nop
     134: iconst_0
     135: istore        4
     137: aload_3
     138: new           #273                // class day9/Day9Kt$part2$$inlined$sortedByDescending$1
     141: dup
     142: invokespecial #274                // Method day9/Day9Kt$part2$$inlined$sortedByDescending$1."<init>":()V
     145: checkcast     #276                // class java/util/Comparator
     148: invokestatic  #280                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
     151: astore_2
     152: new           #188                // class java/lang/StringBuilder
     155: dup
     156: invokespecial #189                // Method java/lang/StringBuilder."<init>":()V
     159: ldc_w         #282                // String Basins:
     162: invokevirtual #195                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     165: aload_2
     166: invokeinterface #283,  1          // InterfaceMethod java/util/List.size:()I
     171: invokevirtual #198                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     174: invokevirtual #202                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     177: getstatic     #208                // Field java/lang/System.out:Ljava/io/PrintStream;
     180: swap
     181: invokevirtual #214                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     184: iconst_0
     185: istore_3
     186: iconst_1
     187: istore_3
     188: aload_2
     189: checkcast     #30                 // class java/lang/Iterable
     192: iconst_3
     193: invokestatic  #287                // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
     196: checkcast     #30                 // class java/lang/Iterable
     199: astore        4
     201: iconst_0
     202: istore        5
     204: aload         4
     206: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     211: astore        6
     213: aload         6
     215: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     220: ifeq          257
     223: aload         6
     225: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     230: astore        7
     232: aload         7
     234: checkcast     #237                // class java/util/Set
     237: astore        8
     239: iconst_0
     240: istore        9
     242: iload_3
     243: aload         8
     245: invokeinterface #288,  1          // InterfaceMethod java/util/Set.size:()I
     250: imul
     251: istore_3
     252: nop
     253: nop
     254: goto          213
     257: nop
     258: new           #188                // class java/lang/StringBuilder
     261: dup
     262: invokespecial #189                // Method java/lang/StringBuilder."<init>":()V
     265: ldc_w         #290                // String Result:
     268: invokevirtual #195                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     271: iload_3
     272: invokevirtual #198                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     275: invokevirtual #202                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     278: getstatic     #208                // Field java/lang/System.out:Ljava/io/PrintStream;
     281: swap
     282: invokevirtual #214                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     285: return

  public static final void main();
    Code:
       0: invokestatic  #300                // Method part2:()V
       3: return

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

Compiled from "Comparisons.kt"
public final class day9.Day9Kt$part2$$inlined$sortedByDescending$1<T> implements java.util.Comparator {
  public day9.Day9Kt$part2$$inlined$sortedByDescending$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

  public final int compare(T, T);
    Code:
       0: aload_2
       1: checkcast     #23                 // class java/util/Set
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokeinterface #27,  1           // InterfaceMethod java/util/Set.size:()I
      14: invokestatic  #33                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      17: checkcast     #35                 // class java/lang/Comparable
      20: aload_1
      21: checkcast     #23                 // class java/util/Set
      24: astore_3
      25: astore        5
      27: iconst_0
      28: istore        4
      30: aload_3
      31: invokeinterface #27,  1           // InterfaceMethod java/util/Set.size:()I
      36: invokestatic  #33                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      39: aload         5
      41: swap
      42: checkcast     #35                 // class java/lang/Comparable
      45: invokestatic  #41                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      48: ireturn
}