import java.io.File
import kotlin.collections.fill
import java.math.BigInteger

// So... this returned a couple possible solutions for part 2, the first one that came out ended up being correct
// and it's 01:28a so I'm going to bed. Hopefully I'll find time tomorrow to come back to this to clean it up.
fun main() {

    var validMin: Int = 0
    var validMax: Int = 4000000
    var rowCheck: Int = 2000000

    var directions: List<String> = File("Day15.txt").readLines()
    var sbpairs: MutableList<Pair<Pair<Int, Int>, Pair<Int, Int>>> = directions.map {
        val parts = it.replace("Sensor at x=", "")
                      .replace(", y=", ",")
                      .replace(": closest beacon is at x=", ",")
                      .split(",")
        Pair(Pair(parts[0].toInt(), parts[1].toInt()), Pair(parts[2].toInt(), parts[3].toInt()))
    }.toMutableList()

    // get all x and y values with the same euclidian distance to the beacon in a specified row
    var points: MutableSet<Pair<Int, Int>> = mutableSetOf()
    sbpairs.forEach {
        var possPoints = getPoints(it.first, it.second, rowCheck)
        var beacons = sbpairs.map { it.second }
        possPoints.forEach {
            if (!beacons.contains(it)) {
                points.add(it)
            }
        }
    }
    println("Part 1 Answer: ${points.size}")
    println()

    var possPoints: MutableList<Pair<Int, Int>> = mutableListOf()
    sbpairs.forEach {
        //println("Getting Diamond For ${it.first.toString()} to ${it.second.toString()}")
        possPoints.addAll(getDiamondOutsides(it.first, it.second))
    }

    // Don't run this for the large grid or you're going to have a bad time
    // var innerPoints: MutableList<Pair<Int, Int>> = mutableListOf()
    // sbpairs.forEach {
    //     innerPoints.addAll(getPoints(it.first, it.second, -1))
    // }
    // for (i in validMin..validMax) {
    //     for (j in validMin..validMax) {
    //         if (sbpairs.map { it.second }.contains(Pair(j, i))) {
    //             print("🟣")
    //         }
    //         else if (sbpairs.map { it.first }.contains(Pair(j, i))) {
    //             print("🟢")
    //         }
    //         else if (innerPoints.contains(Pair(j, i))) {
    //             print("⚫")
    //         } else {
    //             print("🤪")
    //         }
    //     }
    //     println()
    // }

    // Sort the possible points by x and then y so that we can find duplicates
    possPoints.sortWith(compareBy({ it.first }, { it.second }))

    // Run through the list sequentially and tally up the duplicates
    var dups: MutableList<Pair<Pair<Int, Int>, Int>> = mutableListOf()
    var i: Int = 0
    while (i <= possPoints.size - 1) {
        if (possPoints[i].first >= validMin && possPoints[i].first <= validMax && possPoints[i].second >= validMin && possPoints[i].second <= validMax && i < possPoints.size - 1) {
            if (possPoints[i] == possPoints[i+1]) {
                var count = 1
                while (possPoints[i] == possPoints[i+count]) {
                    count++
                }

                dups.add(Pair(possPoints[i], count))
                i += (count - 1)
            } else {
                i++
            }
        } else {
            i++
        }
    }
    // Sort the duplicates by the number of duplicates to test the most likely locations first
    dups.sortByDescending({ it.second })
    // Get a map of our sensors and beacons and distances for testing
    var beacons: List<SBPair> = sbpairs.map { SBPair(it.first, it.second, getDistance(it.first, it.second)) }
    var distressLocation: Pair<Int, Int> = Pair(0, 0)
    run dups@ {
        dups.forEach { dup ->
            //println("Testing For Distress Location @ ${dup.first.toString()} | ${dup.second} duplicates")

            var isValid = true
            beacons.forEach beacon@ { beacon ->
                if (getDistance(dup.first, beacon.start) <= beacon.distance) {
                    isValid = false
                    return@beacon
                }
            }
            if (isValid) {
                //println("Found our distress location: ${dup.first.toString()}")
                distressLocation = dup.first
                return@dups
            }
        }
    }

    println("Part 2 Answer: | ${(BigInteger(distressLocation.first.toInt().toString()).multiply(BigInteger("4000000"))).plus(BigInteger(distressLocation.second.toInt().toString()))}")
}

class SBPair(start: Pair<Int, Int>, end: Pair<Int, Int>, distance: Int) {
    var start: Pair<Int, Int> = start
    var end: Pair<Int, Int> = end
    var distance: Int = distance
}

enum class DiamondDirection {
    DOWNLEFT, DOWNRIGHT, UPRIGHT, UPLEFT
}

fun getPointsAround(start: Pair<Int,Int>): MutableList<Pair<Int, Int>> {
    val points: MutableList<Pair<Int, Int>> = mutableListOf()
    points.add(Pair(start.first - 1, start.second))
    points.add(Pair(start.first + 1, start.second))
    points.add(Pair(start.first, start.second - 1))
    points.add(Pair(start.first, start.second + 1))
    return points
}

fun getDistance(start: Pair<Int, Int>, end: Pair<Int, Int>): Int {
    val xDiff = start.first - end.first
    val yDiff = start.second - end.second
    return Math.abs(xDiff) + Math.abs(yDiff)
}

fun getDiamondOutsides(start: Pair<Int, Int>, end: Pair<Int, Int>): MutableList<Pair<Int, Int>> {
    val points: MutableList<Pair<Int, Int>> = mutableListOf()
    // Adding 1 to the distance to get the points just outside the diamond
    val distance = getDistance(start, end) + 1
    var iterator = Pair(0,distance)
    do {
        if (iterator.second != 0) points.add(Pair(start.first + iterator.first, start.second + iterator.second))
        if (iterator.second != 0) points.add(Pair(start.first + iterator.first, start.second - iterator.second))
        if (iterator.first != 0) points.add(Pair(start.first - iterator.first, start.second + iterator.second))
        if (iterator.first != 0) points.add(Pair(start.first - iterator.first, start.second - iterator.second))
        iterator = Pair(iterator.first + 1, iterator.second - 1)
    } while (iterator.second != 0)

    return points
}

fun getPoints(start: Pair<Int, Int>, end: Pair<Int, Int>, row: Int): List<Pair<Int, Int>> {
    val points: MutableList<Pair<Int, Int>> = mutableListOf()
    val distance = getDistance(start, end)

    if (row != -1) {
        for (i in (start.first-distance)..(start.first+distance)) {
            var testXDiff = start.first - i
            var testYDiff = start.second - row
            if (Math.abs(testXDiff) + Math.abs(testYDiff) <= distance) {
                points.add(Pair(i, row))
            }
        }
    } else {
        for (i in (start.first-distance)..(start.first+distance)) {
            for (j in (start.second-distance)..(start.second+distance)) {
                var testXDiff = start.first - i
                var testYDiff = start.second - j
                if (Math.abs(testXDiff) + Math.abs(testYDiff) <= distance) {
                    points.add(Pair(i, j))
                }
            }
        }
    }
    return points
}

Compiled from "Day15.kt"
public final class Day15Kt {
  public static final void main();
    Code:
       0: iconst_0
       1: istore_0
       2: ldc           #7                  // int 4000000
       4: istore_1
       5: iconst_0
       6: istore_2
       7: ldc           #8                  // int 2000000
       9: istore_2
      10: new           #10                 // class java/io/File
      13: dup
      14: ldc           #12                 // String Day15.txt
      16: invokespecial #16                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      19: aconst_null
      20: iconst_1
      21: aconst_null
      22: invokestatic  #22                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      25: astore_3
      26: aconst_null
      27: astore        4
      29: aload_3
      30: checkcast     #24                 // class java/lang/Iterable
      33: astore        5
      35: iconst_0
      36: istore        6
      38: aload         5
      40: astore        7
      42: new           #26                 // class java/util/ArrayList
      45: dup
      46: aload         5
      48: bipush        10
      50: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      53: invokespecial #35                 // Method java/util/ArrayList."<init>":(I)V
      56: checkcast     #37                 // class java/util/Collection
      59: astore        8
      61: iconst_0
      62: istore        9
      64: aload         7
      66: invokeinterface #41,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      71: astore        10
      73: aload         10
      75: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      80: ifeq          266
      83: aload         10
      85: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      90: astore        11
      92: aload         8
      94: aload         11
      96: checkcast     #53                 // class java/lang/String
      99: astore        12
     101: astore        25
     103: iconst_0
     104: istore        13
     106: aload         12
     108: ldc           #55                 // String Sensor at x=
     110: ldc           #57                 // String
     112: iconst_0
     113: iconst_4
     114: aconst_null
     115: invokestatic  #63                 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
     118: ldc           #65                 // String , y=
     120: ldc           #67                 // String ,
     122: iconst_0
     123: iconst_4
     124: aconst_null
     125: invokestatic  #63                 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
     128: ldc           #69                 // String : closest beacon is at x=
     130: ldc           #67                 // String ,
     132: iconst_0
     133: iconst_4
     134: aconst_null
     135: invokestatic  #63                 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
     138: checkcast     #71                 // class java/lang/CharSequence
     141: iconst_1
     142: anewarray     #53                 // class java/lang/String
     145: astore        14
     147: aload         14
     149: iconst_0
     150: ldc           #67                 // String ,
     152: aastore
     153: aload         14
     155: iconst_0
     156: iconst_0
     157: bipush        6
     159: aconst_null
     160: invokestatic  #75                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     163: astore        15
     165: new           #77                 // class kotlin/Pair
     168: dup
     169: new           #77                 // class kotlin/Pair
     172: dup
     173: aload         15
     175: iconst_0
     176: invokeinterface #83,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     181: checkcast     #53                 // class java/lang/String
     184: invokestatic  #89                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     187: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     190: aload         15
     192: iconst_1
     193: invokeinterface #83,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     198: checkcast     #53                 // class java/lang/String
     201: invokestatic  #89                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     204: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     207: invokespecial #96                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     210: new           #77                 // class kotlin/Pair
     213: dup
     214: aload         15
     216: iconst_2
     217: invokeinterface #83,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     222: checkcast     #53                 // class java/lang/String
     225: invokestatic  #89                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     228: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     231: aload         15
     233: iconst_3
     234: invokeinterface #83,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     239: checkcast     #53                 // class java/lang/String
     242: invokestatic  #89                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     245: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     248: invokespecial #96                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     251: invokespecial #96                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     254: aload         25
     256: swap
     257: invokeinterface #100,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     262: pop
     263: goto          73
     266: aload         8
     268: checkcast     #79                 // class java/util/List
     271: nop
     272: checkcast     #37                 // class java/util/Collection
     275: invokestatic  #104                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     278: astore        4
     280: aconst_null
     281: astore        5
     283: new           #106                // class java/util/LinkedHashSet
     286: dup
     287: invokespecial #108                // Method java/util/LinkedHashSet."<init>":()V
     290: checkcast     #110                // class java/util/Set
     293: astore        5
     295: aload         4
     297: checkcast     #24                 // class java/lang/Iterable
     300: astore        6
     302: iconst_0
     303: istore        7
     305: aload         6
     307: invokeinterface #41,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     312: astore        8
     314: aload         8
     316: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     321: ifeq          575
     324: aload         8
     326: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     331: astore        9
     333: aload         9
     335: checkcast     #77                 // class kotlin/Pair
     338: astore        10
     340: iconst_0
     341: istore        11
     343: aload         10
     345: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     348: checkcast     #77                 // class kotlin/Pair
     351: aload         10
     353: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     356: checkcast     #77                 // class kotlin/Pair
     359: iload_2
     360: invokestatic  #120                // Method getPoints:(Lkotlin/Pair;Lkotlin/Pair;I)Ljava/util/List;
     363: astore        12
     365: new           #122                // class kotlin/jvm/internal/Ref$ObjectRef
     368: dup
     369: invokespecial #123                // Method kotlin/jvm/internal/Ref$ObjectRef."<init>":()V
     372: astore        13
     374: aload         13
     376: aload         4
     378: checkcast     #24                 // class java/lang/Iterable
     381: astore        14
     383: astore        15
     385: iconst_0
     386: istore        16
     388: aload         14
     390: astore        17
     392: new           #26                 // class java/util/ArrayList
     395: dup
     396: aload         14
     398: bipush        10
     400: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     403: invokespecial #35                 // Method java/util/ArrayList."<init>":(I)V
     406: checkcast     #37                 // class java/util/Collection
     409: astore        18
     411: iconst_0
     412: istore        19
     414: aload         17
     416: invokeinterface #41,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     421: astore        20
     423: aload         20
     425: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     430: ifeq          476
     433: aload         20
     435: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     440: astore        21
     442: aload         18
     444: aload         21
     446: checkcast     #77                 // class kotlin/Pair
     449: astore        22
     451: astore        23
     453: iconst_0
     454: istore        24
     456: aload         22
     458: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     461: checkcast     #77                 // class kotlin/Pair
     464: aload         23
     466: swap
     467: invokeinterface #100,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     472: pop
     473: goto          423
     476: aload         18
     478: checkcast     #79                 // class java/util/List
     481: nop
     482: aload         15
     484: swap
     485: putfield      #127                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     488: aload         12
     490: checkcast     #24                 // class java/lang/Iterable
     493: astore        14
     495: iconst_0
     496: istore        16
     498: aload         14
     500: invokeinterface #41,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     505: astore        17
     507: aload         17
     509: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     514: ifeq          569
     517: aload         17
     519: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     524: astore        18
     526: aload         18
     528: checkcast     #77                 // class kotlin/Pair
     531: astore        19
     533: iconst_0
     534: istore        20
     536: aload         13
     538: getfield      #127                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     541: checkcast     #79                 // class java/util/List
     544: aload         19
     546: invokeinterface #130,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     551: ifne          564
     554: aload         5
     556: aload         19
     558: invokeinterface #131,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     563: pop
     564: nop
     565: nop
     566: goto          507
     569: nop
     570: nop
     571: nop
     572: goto          314
     575: nop
     576: new           #133                // class java/lang/StringBuilder
     579: dup
     580: invokespecial #134                // Method java/lang/StringBuilder."<init>":()V
     583: ldc           #136                // String Part 1 Answer:
     585: invokevirtual #140                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     588: aload         5
     590: invokeinterface #144,  1          // InterfaceMethod java/util/Set.size:()I
     595: invokevirtual #147                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     598: invokevirtual #151                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     601: getstatic     #157                // Field java/lang/System.out:Ljava/io/PrintStream;
     604: swap
     605: invokevirtual #163                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     608: getstatic     #157                // Field java/lang/System.out:Ljava/io/PrintStream;
     611: invokevirtual #165                // Method java/io/PrintStream.println:()V
     614: aconst_null
     615: astore        6
     617: new           #26                 // class java/util/ArrayList
     620: dup
     621: invokespecial #166                // Method java/util/ArrayList."<init>":()V
     624: checkcast     #79                 // class java/util/List
     627: astore        6
     629: aload         4
     631: checkcast     #24                 // class java/lang/Iterable
     634: astore        7
     636: iconst_0
     637: istore        8
     639: aload         7
     641: invokeinterface #41,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     646: astore        9
     648: aload         9
     650: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     655: ifeq          712
     658: aload         9
     660: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     665: astore        10
     667: aload         10
     669: checkcast     #77                 // class kotlin/Pair
     672: astore        11
     674: iconst_0
     675: istore        12
     677: aload         6
     679: aload         11
     681: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     684: checkcast     #77                 // class kotlin/Pair
     687: aload         11
     689: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     692: checkcast     #77                 // class kotlin/Pair
     695: invokestatic  #170                // Method getDiamondOutsides:(Lkotlin/Pair;Lkotlin/Pair;)Ljava/util/List;
     698: checkcast     #37                 // class java/util/Collection
     701: invokeinterface #174,  2          // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z
     706: pop
     707: nop
     708: nop
     709: goto          648
     712: nop
     713: aload         6
     715: iconst_2
     716: anewarray     #176                // class kotlin/jvm/functions/Function1
     719: astore        7
     721: aload         7
     723: iconst_0
     724: invokedynamic #195,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     729: aastore
     730: aload         7
     732: iconst_1
     733: invokedynamic #200,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
     738: aastore
     739: aload         7
     741: invokestatic  #206                // Method kotlin/comparisons/ComparisonsKt.compareBy:([Lkotlin/jvm/functions/Function1;)Ljava/util/Comparator;
     744: invokestatic  #210                // Method kotlin/collections/CollectionsKt.sortWith:(Ljava/util/List;Ljava/util/Comparator;)V
     747: aconst_null
     748: astore        7
     750: new           #26                 // class java/util/ArrayList
     753: dup
     754: invokespecial #166                // Method java/util/ArrayList."<init>":()V
     757: checkcast     #79                 // class java/util/List
     760: astore        7
     762: iconst_0
     763: istore        8
     765: iload         8
     767: aload         6
     769: invokeinterface #211,  1          // InterfaceMethod java/util/List.size:()I
     774: iconst_1
     775: isub
     776: if_icmpgt     1012
     779: aload         6
     781: iload         8
     783: invokeinterface #83,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     788: checkcast     #77                 // class kotlin/Pair
     791: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     794: checkcast     #213                // class java/lang/Number
     797: invokevirtual #216                // Method java/lang/Number.intValue:()I
     800: iflt          1003
     803: aload         6
     805: iload         8
     807: invokeinterface #83,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     812: checkcast     #77                 // class kotlin/Pair
     815: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     818: checkcast     #213                // class java/lang/Number
     821: invokevirtual #216                // Method java/lang/Number.intValue:()I
     824: iload_1
     825: if_icmpgt     1003
     828: aload         6
     830: iload         8
     832: invokeinterface #83,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     837: checkcast     #77                 // class kotlin/Pair
     840: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     843: checkcast     #213                // class java/lang/Number
     846: invokevirtual #216                // Method java/lang/Number.intValue:()I
     849: iflt          1003
     852: aload         6
     854: iload         8
     856: invokeinterface #83,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     861: checkcast     #77                 // class kotlin/Pair
     864: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     867: checkcast     #213                // class java/lang/Number
     870: invokevirtual #216                // Method java/lang/Number.intValue:()I
     873: iload_1
     874: if_icmpgt     1003
     877: iload         8
     879: aload         6
     881: invokeinterface #211,  1          // InterfaceMethod java/util/List.size:()I
     886: iconst_1
     887: isub
     888: if_icmpge     1003
     891: aload         6
     893: iload         8
     895: invokeinterface #83,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     900: aload         6
     902: iload         8
     904: iconst_1
     905: iadd
     906: invokeinterface #83,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     911: invokestatic  #222                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     914: ifeq          994
     917: iconst_1
     918: istore        9
     920: aload         6
     922: iload         8
     924: invokeinterface #83,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     929: aload         6
     931: iload         8
     933: iload         9
     935: iadd
     936: invokeinterface #83,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     941: invokestatic  #222                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     944: ifeq          953
     947: iinc          9, 1
     950: goto          920
     953: aload         7
     955: new           #77                 // class kotlin/Pair
     958: dup
     959: aload         6
     961: iload         8
     963: invokeinterface #83,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     968: iload         9
     970: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     973: invokespecial #96                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     976: invokeinterface #223,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     981: pop
     982: iload         8
     984: iload         9
     986: iconst_1
     987: isub
     988: iadd
     989: istore        8
     991: goto          765
     994: iload         8
     996: iinc          8, 1
     999: pop
    1000: goto          765
    1003: iload         8
    1005: iinc          8, 1
    1008: pop
    1009: goto          765
    1012: aload         7
    1014: astore        9
    1016: iconst_0
    1017: istore        10
    1019: aload         9
    1021: invokeinterface #211,  1          // InterfaceMethod java/util/List.size:()I
    1026: iconst_1
    1027: if_icmple     1045
    1030: aload         9
    1032: new           #225                // class Day15Kt$main$$inlined$sortByDescending$1
    1035: dup
    1036: invokespecial #226                // Method Day15Kt$main$$inlined$sortByDescending$1."<init>":()V
    1039: checkcast     #228                // class java/util/Comparator
    1042: invokestatic  #210                // Method kotlin/collections/CollectionsKt.sortWith:(Ljava/util/List;Ljava/util/Comparator;)V
    1045: nop
    1046: aconst_null
    1047: astore        9
    1049: aload         4
    1051: checkcast     #24                 // class java/lang/Iterable
    1054: astore        10
    1056: iconst_0
    1057: istore        11
    1059: aload         10
    1061: astore        12
    1063: new           #26                 // class java/util/ArrayList
    1066: dup
    1067: aload         10
    1069: bipush        10
    1071: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
    1074: invokespecial #35                 // Method java/util/ArrayList."<init>":(I)V
    1077: checkcast     #37                 // class java/util/Collection
    1080: astore        13
    1082: iconst_0
    1083: istore        14
    1085: aload         12
    1087: invokeinterface #41,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
    1092: astore        15
    1094: aload         15
    1096: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1101: ifeq          1181
    1104: aload         15
    1106: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1111: astore        16
    1113: aload         13
    1115: aload         16
    1117: checkcast     #77                 // class kotlin/Pair
    1120: astore        17
    1122: astore        25
    1124: iconst_0
    1125: istore        18
    1127: new           #230                // class SBPair
    1130: dup
    1131: aload         17
    1133: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
    1136: checkcast     #77                 // class kotlin/Pair
    1139: aload         17
    1141: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
    1144: checkcast     #77                 // class kotlin/Pair
    1147: aload         17
    1149: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
    1152: checkcast     #77                 // class kotlin/Pair
    1155: aload         17
    1157: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
    1160: checkcast     #77                 // class kotlin/Pair
    1163: invokestatic  #234                // Method getDistance:(Lkotlin/Pair;Lkotlin/Pair;)I
    1166: invokespecial #237                // Method SBPair."<init>":(Lkotlin/Pair;Lkotlin/Pair;I)V
    1169: aload         25
    1171: swap
    1172: invokeinterface #100,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
    1177: pop
    1178: goto          1094
    1181: aload         13
    1183: checkcast     #79                 // class java/util/List
    1186: nop
    1187: astore        9
    1189: aconst_null
    1190: astore        10
    1192: new           #77                 // class kotlin/Pair
    1195: dup
    1196: iconst_0
    1197: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1200: iconst_0
    1201: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1204: invokespecial #96                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
    1207: astore        10
    1209: iconst_0
    1210: istore        11
    1212: aload         7
    1214: checkcast     #24                 // class java/lang/Iterable
    1217: astore        12
    1219: iconst_0
    1220: istore        13
    1222: aload         12
    1224: invokeinterface #41,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
    1229: astore        14
    1231: aload         14
    1233: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1238: ifeq          1370
    1241: aload         14
    1243: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1248: astore        15
    1250: aload         15
    1252: checkcast     #77                 // class kotlin/Pair
    1255: astore        16
    1257: iconst_0
    1258: istore        17
    1260: iconst_0
    1261: istore        18
    1263: iconst_1
    1264: istore        18
    1266: aload         9
    1268: checkcast     #24                 // class java/lang/Iterable
    1271: astore        19
    1273: iconst_0
    1274: istore        20
    1276: aload         19
    1278: invokeinterface #41,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
    1283: astore        21
    1285: aload         21
    1287: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1292: ifeq          1349
    1295: aload         21
    1297: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1302: astore        22
    1304: aload         22
    1306: checkcast     #230                // class SBPair
    1309: astore        23
    1311: iconst_0
    1312: istore        24
    1314: aload         16
    1316: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
    1319: checkcast     #77                 // class kotlin/Pair
    1322: aload         23
    1324: invokevirtual #241                // Method SBPair.getStart:()Lkotlin/Pair;
    1327: invokestatic  #234                // Method getDistance:(Lkotlin/Pair;Lkotlin/Pair;)I
    1330: aload         23
    1332: invokevirtual #243                // Method SBPair.getDistance:()I
    1335: if_icmpgt     1344
    1338: iconst_0
    1339: istore        18
    1341: goto          1345
    1344: nop
    1345: nop
    1346: goto          1285
    1349: nop
    1350: iload         18
    1352: ifeq          1365
    1355: aload         16
    1357: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
    1360: astore        10
    1362: goto          1372
    1365: nop
    1366: nop
    1367: goto          1231
    1370: nop
    1371: nop
    1372: nop
    1373: new           #133                // class java/lang/StringBuilder
    1376: dup
    1377: invokespecial #134                // Method java/lang/StringBuilder."<init>":()V
    1380: ldc           #245                // String Part 2 Answer: |
    1382: invokevirtual #140                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
    1385: new           #247                // class java/math/BigInteger
    1388: dup
    1389: aload         10
    1391: checkcast     #77                 // class kotlin/Pair
    1394: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
    1397: checkcast     #213                // class java/lang/Number
    1400: invokevirtual #216                // Method java/lang/Number.intValue:()I
    1403: invokestatic  #250                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
    1406: invokespecial #251                // Method java/math/BigInteger."<init>":(Ljava/lang/String;)V
    1409: new           #247                // class java/math/BigInteger
    1412: dup
    1413: ldc           #253                // String 4000000
    1415: invokespecial #251                // Method java/math/BigInteger."<init>":(Ljava/lang/String;)V
    1418: invokevirtual #257                // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
    1421: dup
    1422: ldc_w         #259                // String multiply(...)
    1425: invokestatic  #263                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
    1428: astore        11
    1430: new           #247                // class java/math/BigInteger
    1433: dup
    1434: aload         10
    1436: checkcast     #77                 // class kotlin/Pair
    1439: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
    1442: checkcast     #213                // class java/lang/Number
    1445: invokevirtual #216                // Method java/lang/Number.intValue:()I
    1448: invokestatic  #250                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
    1451: invokespecial #251                // Method java/math/BigInteger."<init>":(Ljava/lang/String;)V
    1454: aload         11
    1456: swap
    1457: invokevirtual #265                // Method java/math/BigInteger.add:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
    1460: dup
    1461: ldc_w         #267                // String add(...)
    1464: invokestatic  #263                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
    1467: invokevirtual #270                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
    1470: invokevirtual #151                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
    1473: getstatic     #157                // Field java/lang/System.out:Ljava/io/PrintStream;
    1476: swap
    1477: invokevirtual #163                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
    1480: return

  public static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> getPointsAround(kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc_w         #322                // String start
       4: invokestatic  #325                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: new           #26                 // class java/util/ArrayList
      10: dup
      11: invokespecial #166                // Method java/util/ArrayList."<init>":()V
      14: checkcast     #79                 // class java/util/List
      17: astore_1
      18: aload_1
      19: new           #77                 // class kotlin/Pair
      22: dup
      23: aload_0
      24: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      27: checkcast     #213                // class java/lang/Number
      30: invokevirtual #216                // Method java/lang/Number.intValue:()I
      33: iconst_1
      34: isub
      35: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      38: aload_0
      39: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      42: invokespecial #96                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      45: invokeinterface #223,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      50: pop
      51: aload_1
      52: new           #77                 // class kotlin/Pair
      55: dup
      56: aload_0
      57: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      60: checkcast     #213                // class java/lang/Number
      63: invokevirtual #216                // Method java/lang/Number.intValue:()I
      66: iconst_1
      67: iadd
      68: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      71: aload_0
      72: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      75: invokespecial #96                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      78: invokeinterface #223,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      83: pop
      84: aload_1
      85: new           #77                 // class kotlin/Pair
      88: dup
      89: aload_0
      90: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      93: aload_0
      94: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      97: checkcast     #213                // class java/lang/Number
     100: invokevirtual #216                // Method java/lang/Number.intValue:()I
     103: iconst_1
     104: isub
     105: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     108: invokespecial #96                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     111: invokeinterface #223,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     116: pop
     117: aload_1
     118: new           #77                 // class kotlin/Pair
     121: dup
     122: aload_0
     123: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     126: aload_0
     127: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     130: checkcast     #213                // class java/lang/Number
     133: invokevirtual #216                // Method java/lang/Number.intValue:()I
     136: iconst_1
     137: iadd
     138: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     141: invokespecial #96                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     144: invokeinterface #223,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     149: pop
     150: aload_1
     151: areturn

  public static final int getDistance(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc_w         #322                // String start
       4: invokestatic  #325                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: ldc_w         #328                // String end
      11: invokestatic  #325                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      14: aload_0
      15: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      18: checkcast     #213                // class java/lang/Number
      21: invokevirtual #216                // Method java/lang/Number.intValue:()I
      24: aload_1
      25: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      28: checkcast     #213                // class java/lang/Number
      31: invokevirtual #216                // Method java/lang/Number.intValue:()I
      34: isub
      35: istore_2
      36: aload_0
      37: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      40: checkcast     #213                // class java/lang/Number
      43: invokevirtual #216                // Method java/lang/Number.intValue:()I
      46: aload_1
      47: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      50: checkcast     #213                // class java/lang/Number
      53: invokevirtual #216                // Method java/lang/Number.intValue:()I
      56: isub
      57: istore_3
      58: iload_2
      59: invokestatic  #334                // Method java/lang/Math.abs:(I)I
      62: iload_3
      63: invokestatic  #334                // Method java/lang/Math.abs:(I)I
      66: iadd
      67: ireturn

  public static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> getDiamondOutsides(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc_w         #322                // String start
       4: invokestatic  #325                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: ldc_w         #328                // String end
      11: invokestatic  #325                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      14: new           #26                 // class java/util/ArrayList
      17: dup
      18: invokespecial #166                // Method java/util/ArrayList."<init>":()V
      21: checkcast     #79                 // class java/util/List
      24: astore_2
      25: aload_0
      26: aload_1
      27: invokestatic  #234                // Method getDistance:(Lkotlin/Pair;Lkotlin/Pair;)I
      30: iconst_1
      31: iadd
      32: istore_3
      33: new           #77                 // class kotlin/Pair
      36: dup
      37: iconst_0
      38: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      41: iload_3
      42: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      45: invokespecial #96                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      48: astore        4
      50: aload         4
      52: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      55: checkcast     #213                // class java/lang/Number
      58: invokevirtual #216                // Method java/lang/Number.intValue:()I
      61: ifeq          128
      64: aload_2
      65: new           #77                 // class kotlin/Pair
      68: dup
      69: aload_0
      70: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      73: checkcast     #213                // class java/lang/Number
      76: invokevirtual #216                // Method java/lang/Number.intValue:()I
      79: aload         4
      81: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      84: checkcast     #213                // class java/lang/Number
      87: invokevirtual #216                // Method java/lang/Number.intValue:()I
      90: iadd
      91: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      94: aload_0
      95: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      98: checkcast     #213                // class java/lang/Number
     101: invokevirtual #216                // Method java/lang/Number.intValue:()I
     104: aload         4
     106: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     109: checkcast     #213                // class java/lang/Number
     112: invokevirtual #216                // Method java/lang/Number.intValue:()I
     115: iadd
     116: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     119: invokespecial #96                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     122: invokeinterface #223,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     127: pop
     128: aload         4
     130: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     133: checkcast     #213                // class java/lang/Number
     136: invokevirtual #216                // Method java/lang/Number.intValue:()I
     139: ifeq          206
     142: aload_2
     143: new           #77                 // class kotlin/Pair
     146: dup
     147: aload_0
     148: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     151: checkcast     #213                // class java/lang/Number
     154: invokevirtual #216                // Method java/lang/Number.intValue:()I
     157: aload         4
     159: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     162: checkcast     #213                // class java/lang/Number
     165: invokevirtual #216                // Method java/lang/Number.intValue:()I
     168: iadd
     169: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     172: aload_0
     173: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     176: checkcast     #213                // class java/lang/Number
     179: invokevirtual #216                // Method java/lang/Number.intValue:()I
     182: aload         4
     184: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     187: checkcast     #213                // class java/lang/Number
     190: invokevirtual #216                // Method java/lang/Number.intValue:()I
     193: isub
     194: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     197: invokespecial #96                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     200: invokeinterface #223,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     205: pop
     206: aload         4
     208: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     211: checkcast     #213                // class java/lang/Number
     214: invokevirtual #216                // Method java/lang/Number.intValue:()I
     217: ifeq          284
     220: aload_2
     221: new           #77                 // class kotlin/Pair
     224: dup
     225: aload_0
     226: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     229: checkcast     #213                // class java/lang/Number
     232: invokevirtual #216                // Method java/lang/Number.intValue:()I
     235: aload         4
     237: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     240: checkcast     #213                // class java/lang/Number
     243: invokevirtual #216                // Method java/lang/Number.intValue:()I
     246: isub
     247: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     250: aload_0
     251: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     254: checkcast     #213                // class java/lang/Number
     257: invokevirtual #216                // Method java/lang/Number.intValue:()I
     260: aload         4
     262: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     265: checkcast     #213                // class java/lang/Number
     268: invokevirtual #216                // Method java/lang/Number.intValue:()I
     271: iadd
     272: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     275: invokespecial #96                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     278: invokeinterface #223,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     283: pop
     284: aload         4
     286: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     289: checkcast     #213                // class java/lang/Number
     292: invokevirtual #216                // Method java/lang/Number.intValue:()I
     295: ifeq          362
     298: aload_2
     299: new           #77                 // class kotlin/Pair
     302: dup
     303: aload_0
     304: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     307: checkcast     #213                // class java/lang/Number
     310: invokevirtual #216                // Method java/lang/Number.intValue:()I
     313: aload         4
     315: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     318: checkcast     #213                // class java/lang/Number
     321: invokevirtual #216                // Method java/lang/Number.intValue:()I
     324: isub
     325: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     328: aload_0
     329: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     332: checkcast     #213                // class java/lang/Number
     335: invokevirtual #216                // Method java/lang/Number.intValue:()I
     338: aload         4
     340: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     343: checkcast     #213                // class java/lang/Number
     346: invokevirtual #216                // Method java/lang/Number.intValue:()I
     349: isub
     350: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     353: invokespecial #96                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     356: invokeinterface #223,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     361: pop
     362: new           #77                 // class kotlin/Pair
     365: dup
     366: aload         4
     368: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     371: checkcast     #213                // class java/lang/Number
     374: invokevirtual #216                // Method java/lang/Number.intValue:()I
     377: iconst_1
     378: iadd
     379: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     382: aload         4
     384: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     387: checkcast     #213                // class java/lang/Number
     390: invokevirtual #216                // Method java/lang/Number.intValue:()I
     393: iconst_1
     394: isub
     395: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     398: invokespecial #96                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     401: astore        4
     403: aload         4
     405: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     408: checkcast     #213                // class java/lang/Number
     411: invokevirtual #216                // Method java/lang/Number.intValue:()I
     414: ifne          50
     417: aload_2
     418: areturn

  public static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> getPoints(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>, int);
    Code:
       0: aload_0
       1: ldc_w         #322                // String start
       4: invokestatic  #325                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: ldc_w         #328                // String end
      11: invokestatic  #325                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      14: new           #26                 // class java/util/ArrayList
      17: dup
      18: invokespecial #166                // Method java/util/ArrayList."<init>":()V
      21: checkcast     #79                 // class java/util/List
      24: astore_3
      25: aload_0
      26: aload_1
      27: invokestatic  #234                // Method getDistance:(Lkotlin/Pair;Lkotlin/Pair;)I
      30: istore        4
      32: iload_2
      33: iconst_m1
      34: if_icmpeq     155
      37: aload_0
      38: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      41: checkcast     #213                // class java/lang/Number
      44: invokevirtual #216                // Method java/lang/Number.intValue:()I
      47: iload         4
      49: isub
      50: istore        5
      52: aload_0
      53: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      56: checkcast     #213                // class java/lang/Number
      59: invokevirtual #216                // Method java/lang/Number.intValue:()I
      62: iload         4
      64: iadd
      65: istore        6
      67: iload         5
      69: iload         6
      71: if_icmpgt     325
      74: aload_0
      75: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      78: checkcast     #213                // class java/lang/Number
      81: invokevirtual #216                // Method java/lang/Number.intValue:()I
      84: iload         5
      86: isub
      87: istore        7
      89: aload_0
      90: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      93: checkcast     #213                // class java/lang/Number
      96: invokevirtual #216                // Method java/lang/Number.intValue:()I
      99: iload_2
     100: isub
     101: istore        8
     103: iload         7
     105: invokestatic  #334                // Method java/lang/Math.abs:(I)I
     108: iload         8
     110: invokestatic  #334                // Method java/lang/Math.abs:(I)I
     113: iadd
     114: iload         4
     116: if_icmpgt     142
     119: aload_3
     120: new           #77                 // class kotlin/Pair
     123: dup
     124: iload         5
     126: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     129: iload_2
     130: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     133: invokespecial #96                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     136: invokeinterface #223,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     141: pop
     142: iload         5
     144: iload         6
     146: if_icmpeq     325
     149: iinc          5, 1
     152: goto          74
     155: aload_0
     156: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     159: checkcast     #213                // class java/lang/Number
     162: invokevirtual #216                // Method java/lang/Number.intValue:()I
     165: iload         4
     167: isub
     168: istore        5
     170: aload_0
     171: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     174: checkcast     #213                // class java/lang/Number
     177: invokevirtual #216                // Method java/lang/Number.intValue:()I
     180: iload         4
     182: iadd
     183: istore        6
     185: iload         5
     187: iload         6
     189: if_icmpgt     325
     192: aload_0
     193: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     196: checkcast     #213                // class java/lang/Number
     199: invokevirtual #216                // Method java/lang/Number.intValue:()I
     202: iload         4
     204: isub
     205: istore        7
     207: aload_0
     208: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     211: checkcast     #213                // class java/lang/Number
     214: invokevirtual #216                // Method java/lang/Number.intValue:()I
     217: iload         4
     219: iadd
     220: istore        8
     222: iload         7
     224: iload         8
     226: if_icmpgt     312
     229: aload_0
     230: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     233: checkcast     #213                // class java/lang/Number
     236: invokevirtual #216                // Method java/lang/Number.intValue:()I
     239: iload         5
     241: isub
     242: istore        9
     244: aload_0
     245: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     248: checkcast     #213                // class java/lang/Number
     251: invokevirtual #216                // Method java/lang/Number.intValue:()I
     254: iload         7
     256: isub
     257: istore        10
     259: iload         9
     261: invokestatic  #334                // Method java/lang/Math.abs:(I)I
     264: iload         10
     266: invokestatic  #334                // Method java/lang/Math.abs:(I)I
     269: iadd
     270: iload         4
     272: if_icmpgt     299
     275: aload_3
     276: new           #77                 // class kotlin/Pair
     279: dup
     280: iload         5
     282: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     285: iload         7
     287: invokestatic  #93                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     290: invokespecial #96                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     293: invokeinterface #223,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     298: pop
     299: iload         7
     301: iload         8
     303: if_icmpeq     312
     306: iinc          7, 1
     309: goto          229
     312: iload         5
     314: iload         6
     316: if_icmpeq     325
     319: iinc          5, 1
     322: goto          192
     325: aload_3
     326: areturn

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

  private static final java.lang.Comparable main$lambda$5(kotlin.Pair);
    Code:
       0: aload_0
       1: ldc_w         #349                // String it
       4: invokestatic  #325                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokevirtual #113                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      11: checkcast     #351                // class java/lang/Comparable
      14: areturn

  private static final java.lang.Comparable main$lambda$6(kotlin.Pair);
    Code:
       0: aload_0
       1: ldc_w         #349                // String it
       4: invokestatic  #325                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokevirtual #116                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      11: checkcast     #351                // class java/lang/Comparable
      14: areturn
}

Compiled from "Comparisons.kt"
public final class Day15Kt$main$$inlined$sortByDescending$1<T> implements java.util.Comparator {
  public Day15Kt$main$$inlined$sortByDescending$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 kotlin/Pair
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      12: checkcast     #29                 // class java/lang/Integer
      15: checkcast     #31                 // class java/lang/Comparable
      18: aload_1
      19: checkcast     #23                 // class kotlin/Pair
      22: astore_3
      23: astore        5
      25: iconst_0
      26: istore        4
      28: aload_3
      29: invokevirtual #27                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      32: checkcast     #29                 // class java/lang/Integer
      35: aload         5
      37: swap
      38: checkcast     #31                 // class java/lang/Comparable
      41: invokestatic  #37                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      44: ireturn
}