import java.io.File

fun main() {
    fun part1(elves: List<Int>): Int {
        return elves.fold(0) { mx, calories -> maxOf(mx, calories) }
    }

    fun part2(elves: List<Int>): Int {
        return elves.fold(mutableListOf(0, 0, 0)) { mx, calories ->
            if (calories > mx[0]) {
                mx[2] = mx[1]
                mx[1] = mx[0]
                mx[0] = calories
            } else if (calories > mx[1]) {
                mx[2] = mx[1]
                mx[1] = calories
            } else if (calories > mx[2]) {
                mx[2] = calories
            }
            mx
        }.sum()
    }

    val t0 = System.currentTimeMillis()

    // input parsing
    val input = File("src", "Day01.txt").readText()
    val elves = input
        .trim().split("\n\n")
        .map { elf -> elf.lines().sumOf { line -> line.toInt() } }
        .toList()
    val tParse = System.currentTimeMillis()

    // part 1
    val exp1 = 67658
    val sol1 = part1(elves)
    val t1 = System.currentTimeMillis()
    check(sol1 == exp1) { "Expected solution for part 1: $exp1, found $sol1" }

    // part 2
    val exp2 = 200158
    val sol2 = part2(elves)
    val t2 = System.currentTimeMillis()
    check(sol2 == exp2) { "Expected solution for part 1: $exp2, found $sol2" }

    // results
    println("Solved puzzle 2022/01")
    println("  parsed input in ${tParse - t0}ms")
    println("  solved part 1 in ${t1 - tParse}ms => $sol1")
    println("  solved part 2 in ${t2 - t1}ms => $sol2")
    println("  ---")
    println("  total time: ${t2 - t0}ms")
}

Compiled from "Day01.kt"
public final class Day01Kt {
  public static final void main();
    Code:
       0: invokestatic  #12                 // Method java/lang/System.currentTimeMillis:()J
       3: lstore_0
       4: new           #14                 // class java/io/File
       7: dup
       8: ldc           #16                 // String src
      10: ldc           #18                 // String Day01.txt
      12: invokespecial #22                 // Method java/io/File."<init>":(Ljava/lang/String;Ljava/lang/String;)V
      15: aconst_null
      16: iconst_1
      17: aconst_null
      18: invokestatic  #28                 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
      21: astore_2
      22: nop
      23: aload_2
      24: checkcast     #30                 // class java/lang/CharSequence
      27: invokestatic  #36                 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      30: invokevirtual #40                 // Method java/lang/Object.toString:()Ljava/lang/String;
      33: checkcast     #30                 // class java/lang/CharSequence
      36: iconst_1
      37: anewarray     #42                 // class java/lang/String
      40: astore        4
      42: aload         4
      44: iconst_0
      45: ldc           #44                 // String \n\n
      47: aastore
      48: aload         4
      50: iconst_0
      51: iconst_0
      52: bipush        6
      54: aconst_null
      55: invokestatic  #48                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      58: checkcast     #50                 // class java/lang/Iterable
      61: astore        4
      63: nop
      64: iconst_0
      65: istore        5
      67: aload         4
      69: astore        6
      71: new           #52                 // class java/util/ArrayList
      74: dup
      75: aload         4
      77: bipush        10
      79: invokestatic  #58                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      82: invokespecial #61                 // Method java/util/ArrayList."<init>":(I)V
      85: checkcast     #63                 // class java/util/Collection
      88: astore        7
      90: iconst_0
      91: istore        8
      93: aload         6
      95: invokeinterface #67,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     100: astore        9
     102: aload         9
     104: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     109: ifeq          229
     112: aload         9
     114: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     119: astore        10
     121: aload         7
     123: aload         10
     125: checkcast     #42                 // class java/lang/String
     128: astore        11
     130: astore        21
     132: iconst_0
     133: istore        12
     135: aload         11
     137: checkcast     #30                 // class java/lang/CharSequence
     140: invokestatic  #81                 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;
     143: checkcast     #50                 // class java/lang/Iterable
     146: astore        13
     148: iconst_0
     149: istore        14
     151: aload         13
     153: invokeinterface #67,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     158: astore        15
     160: aload         15
     162: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     167: ifeq          211
     170: aload         15
     172: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     177: astore        16
     179: iload         14
     181: aload         16
     183: checkcast     #42                 // class java/lang/String
     186: astore        17
     188: istore        18
     190: iconst_0
     191: istore        19
     193: aload         17
     195: invokestatic  #87                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     198: nop
     199: istore        20
     201: iload         18
     203: iload         20
     205: iadd
     206: istore        14
     208: goto          160
     211: iload         14
     213: nop
     214: invokestatic  #91                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     217: aload         21
     219: swap
     220: invokeinterface #95,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     225: pop
     226: goto          102
     229: aload         7
     231: checkcast     #97                 // class java/util/List
     234: nop
     235: checkcast     #50                 // class java/lang/Iterable
     238: invokestatic  #101                // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     241: astore_3
     242: invokestatic  #12                 // Method java/lang/System.currentTimeMillis:()J
     245: lstore        4
     247: ldc           #102                // int 67658
     249: istore        6
     251: aload_3
     252: invokestatic  #106                // Method main$part1:(Ljava/util/List;)I
     255: istore        7
     257: invokestatic  #12                 // Method java/lang/System.currentTimeMillis:()J
     260: lstore        8
     262: iload         7
     264: iload         6
     266: if_icmpne     273
     269: iconst_1
     270: goto          274
     273: iconst_0
     274: ifne          325
     277: iconst_0
     278: istore        11
     280: new           #108                // class java/lang/StringBuilder
     283: dup
     284: invokespecial #110                // Method java/lang/StringBuilder."<init>":()V
     287: ldc           #112                // String Expected solution for part 1:
     289: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     292: iload         6
     294: invokevirtual #119                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     297: ldc           #121                // String , found
     299: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     302: iload         7
     304: invokevirtual #119                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     307: invokevirtual #122                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     310: astore        11
     312: new           #124                // class java/lang/IllegalStateException
     315: dup
     316: aload         11
     318: invokevirtual #40                 // Method java/lang/Object.toString:()Ljava/lang/String;
     321: invokespecial #127                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     324: athrow
     325: ldc           #128                // int 200158
     327: istore        10
     329: aload_3
     330: invokestatic  #131                // Method main$part2:(Ljava/util/List;)I
     333: istore        11
     335: invokestatic  #12                 // Method java/lang/System.currentTimeMillis:()J
     338: lstore        12
     340: iload         11
     342: iload         10
     344: if_icmpne     351
     347: iconst_1
     348: goto          352
     351: iconst_0
     352: ifne          403
     355: iconst_0
     356: istore        15
     358: new           #108                // class java/lang/StringBuilder
     361: dup
     362: invokespecial #110                // Method java/lang/StringBuilder."<init>":()V
     365: ldc           #112                // String Expected solution for part 1:
     367: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     370: iload         10
     372: invokevirtual #119                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     375: ldc           #121                // String , found
     377: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     380: iload         11
     382: invokevirtual #119                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     385: invokevirtual #122                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     388: astore        15
     390: new           #124                // class java/lang/IllegalStateException
     393: dup
     394: aload         15
     396: invokevirtual #40                 // Method java/lang/Object.toString:()Ljava/lang/String;
     399: invokespecial #127                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     402: athrow
     403: ldc           #133                // String Solved puzzle 2022/01
     405: getstatic     #137                // Field java/lang/System.out:Ljava/io/PrintStream;
     408: swap
     409: invokevirtual #143                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     412: new           #108                // class java/lang/StringBuilder
     415: dup
     416: invokespecial #110                // Method java/lang/StringBuilder."<init>":()V
     419: ldc           #145                // String   parsed input in
     421: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     424: lload         4
     426: lload_0
     427: lsub
     428: invokevirtual #148                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     431: ldc           #150                // String ms
     433: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     436: invokevirtual #122                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     439: getstatic     #137                // Field java/lang/System.out:Ljava/io/PrintStream;
     442: swap
     443: invokevirtual #143                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     446: new           #108                // class java/lang/StringBuilder
     449: dup
     450: invokespecial #110                // Method java/lang/StringBuilder."<init>":()V
     453: ldc           #152                // String   solved part 1 in
     455: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     458: lload         8
     460: lload         4
     462: lsub
     463: invokevirtual #148                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     466: ldc           #154                // String ms =>
     468: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     471: iload         7
     473: invokevirtual #119                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     476: invokevirtual #122                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     479: getstatic     #137                // Field java/lang/System.out:Ljava/io/PrintStream;
     482: swap
     483: invokevirtual #143                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     486: new           #108                // class java/lang/StringBuilder
     489: dup
     490: invokespecial #110                // Method java/lang/StringBuilder."<init>":()V
     493: ldc           #156                // String   solved part 2 in
     495: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     498: lload         12
     500: lload         8
     502: lsub
     503: invokevirtual #148                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     506: ldc           #154                // String ms =>
     508: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     511: iload         11
     513: invokevirtual #119                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     516: invokevirtual #122                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     519: getstatic     #137                // Field java/lang/System.out:Ljava/io/PrintStream;
     522: swap
     523: invokevirtual #143                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     526: ldc           #158                // String   ---
     528: getstatic     #137                // Field java/lang/System.out:Ljava/io/PrintStream;
     531: swap
     532: invokevirtual #143                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     535: new           #108                // class java/lang/StringBuilder
     538: dup
     539: invokespecial #110                // Method java/lang/StringBuilder."<init>":()V
     542: ldc           #160                // String   total time:
     544: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     547: lload         12
     549: lload_0
     550: lsub
     551: invokevirtual #148                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     554: ldc           #150                // String ms
     556: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     559: invokevirtual #122                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     562: getstatic     #137                // Field java/lang/System.out:Ljava/io/PrintStream;
     565: swap
     566: invokevirtual #143                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     569: return

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

  private static final int main$part1(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: checkcast     #50                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: iconst_0
       8: istore_3
       9: iload_2
      10: istore        4
      12: aload_1
      13: invokeinterface #67,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      18: astore        5
      20: aload         5
      22: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      27: ifeq          69
      30: aload         5
      32: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      37: astore        6
      39: iload         4
      41: aload         6
      43: checkcast     #197                // class java/lang/Number
      46: invokevirtual #201                // Method java/lang/Number.intValue:()I
      49: istore        7
      51: istore        8
      53: iconst_0
      54: istore        9
      56: iload         8
      58: iload         7
      60: invokestatic  #207                // Method java/lang/Math.max:(II)I
      63: nop
      64: istore        4
      66: goto          20
      69: iload         4
      71: ireturn

  private static final int main$part2(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: checkcast     #50                 // class java/lang/Iterable
       4: astore_1
       5: iconst_3
       6: anewarray     #83                 // class java/lang/Integer
       9: astore_2
      10: aload_2
      11: iconst_0
      12: iconst_0
      13: invokestatic  #91                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      16: aastore
      17: aload_2
      18: iconst_1
      19: iconst_0
      20: invokestatic  #91                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      23: aastore
      24: aload_2
      25: iconst_2
      26: iconst_0
      27: invokestatic  #91                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      30: aastore
      31: aload_2
      32: invokestatic  #219                // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
      35: astore_2
      36: iconst_0
      37: istore_3
      38: aload_2
      39: astore        4
      41: aload_1
      42: invokeinterface #67,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      47: astore        5
      49: aload         5
      51: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      56: ifeq          248
      59: aload         5
      61: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      66: astore        6
      68: aload         4
      70: aload         6
      72: checkcast     #197                // class java/lang/Number
      75: invokevirtual #201                // Method java/lang/Number.intValue:()I
      78: istore        7
      80: astore        8
      82: iconst_0
      83: istore        9
      85: iload         7
      87: aload         8
      89: iconst_0
      90: invokeinterface #223,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      95: checkcast     #197                // class java/lang/Number
      98: invokevirtual #201                // Method java/lang/Number.intValue:()I
     101: if_icmple     155
     104: aload         8
     106: iconst_2
     107: aload         8
     109: iconst_1
     110: invokeinterface #223,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     115: invokeinterface #227,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     120: pop
     121: aload         8
     123: iconst_1
     124: aload         8
     126: iconst_0
     127: invokeinterface #223,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     132: invokeinterface #227,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     137: pop
     138: aload         8
     140: iconst_0
     141: iload         7
     143: invokestatic  #91                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     146: invokeinterface #227,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     151: pop
     152: goto          241
     155: iload         7
     157: aload         8
     159: iconst_1
     160: invokeinterface #223,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     165: checkcast     #197                // class java/lang/Number
     168: invokevirtual #201                // Method java/lang/Number.intValue:()I
     171: if_icmple     208
     174: aload         8
     176: iconst_2
     177: aload         8
     179: iconst_1
     180: invokeinterface #223,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     185: invokeinterface #227,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     190: pop
     191: aload         8
     193: iconst_1
     194: iload         7
     196: invokestatic  #91                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     199: invokeinterface #227,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     204: pop
     205: goto          241
     208: iload         7
     210: aload         8
     212: iconst_2
     213: invokeinterface #223,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     218: checkcast     #197                // class java/lang/Number
     221: invokevirtual #201                // Method java/lang/Number.intValue:()I
     224: if_icmple     241
     227: aload         8
     229: iconst_2
     230: iload         7
     232: invokestatic  #91                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     235: invokeinterface #227,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     240: pop
     241: aload         8
     243: astore        4
     245: goto          49
     248: aload         4
     250: checkcast     #50                 // class java/lang/Iterable
     253: invokestatic  #231                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     256: ireturn
}


import java.io.File

/**
 * Reads lines from the given input txt file.
 */
fun readInput(name: String) = File("src", "$name.txt")
    .readLines()

fun String.allInts() = allIntsInString(this)
fun allIntsInString(line: String): List<Int> {
    return """-?\d+""".toRegex().findAll(line)
        .map { it.value.toInt() }
        .toList()
}

fun <T> List<T>.nth(n: Int): T =
    this[n % size]

inline fun <T> List<T>.indexOfLast(predicate: (T) -> Boolean): Int {
    for (i in this.indices.reversed()) {
        if (predicate(this[i])) {
            return i
        }
    }

    return -1
}

data class Point(var x: Int = 0, var y: Int = 0) {
    operator fun plus(other: Point): Point {
        return Point(this.x + other.x, this.y + other.y)
    }

    fun adjacents(): Set<Point> =
        setOf(
            copy(x = x - 1),
            copy(x = x + 1),
            copy(y = y - 1),
            copy(y = y + 1)
        )

    fun set(x: Int, y: Int) {
        this.x = x
        this.y = y
    }

    operator fun plusAssign(p: Point) {
        x += p.x
        y += p.y
    }

    operator fun minus(point: Point): Point {
        return Point(x + point.x, y - point.y)
    }
}

inline fun List<List<Char>>.forEach(block: (row: Int, col: Int) -> Unit) {
    for (i in indices) {
        val inner = this[i]
        for (j in inner.indices) {
            block(i, j)
        }
    }
}

fun List<List<Char>>.maxOf(block: (row: Int, col: Int) -> Int): Int {
    var max = 0

    forEach { row, col ->
        val value = block(row, col)
        max = if (value > max) value else max
    }

    return max
}

fun List<List<Char>>.count(block: (row: Int, col: Int) -> Boolean): Int {
    var count = 0

    forEach { row, col ->
        count += if (block(row, col)) 1 else 0
    }

    return count
}

Compiled from "Utils.kt"
public final class UtilsKt {
  public static final java.util.List<java.lang.String> readInput(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #10                 // String name
       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: ldc           #20                 // String src
      12: new           #22                 // class java/lang/StringBuilder
      15: dup
      16: invokespecial #26                 // Method java/lang/StringBuilder."<init>":()V
      19: aload_0
      20: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      23: ldc           #32                 // String .txt
      25: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      28: invokevirtual #36                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      31: invokespecial #39                 // Method java/io/File."<init>":(Ljava/lang/String;Ljava/lang/String;)V
      34: aconst_null
      35: iconst_1
      36: aconst_null
      37: invokestatic  #45                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      40: areturn

  public static final java.util.List<java.lang.Integer> allInts(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #50                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #53                 // Method allIntsInString:(Ljava/lang/String;)Ljava/util/List;
      10: areturn

  public static final java.util.List<java.lang.Integer> allIntsInString(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #56                 // String line
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #58                 // class kotlin/text/Regex
       9: dup
      10: ldc           #60                 // String -?\\d+
      12: invokespecial #63                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      15: aload_0
      16: checkcast     #65                 // class java/lang/CharSequence
      19: iconst_0
      20: iconst_2
      21: aconst_null
      22: invokestatic  #69                 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;
      25: invokedynamic #89,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      30: invokestatic  #95                 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      33: invokestatic  #99                 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
      36: areturn

  public static final <T> T nth(java.util.List<? extends T>, int);
    Code:
       0: aload_0
       1: ldc           #50                 // 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: aload_0
       9: invokeinterface #108,  1          // InterfaceMethod java/util/List.size:()I
      14: irem
      15: invokeinterface #112,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      20: areturn

  public static final <T> int indexOfLast(java.util.List<? extends T>, kotlin.jvm.functions.Function1<? super T, java.lang.Boolean>);
    Code:
       0: aload_0
       1: ldc           #50                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #121                // String predicate
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iconst_0
      13: istore_2
      14: aload_0
      15: checkcast     #123                // class java/util/Collection
      18: invokeinterface #124,  1          // InterfaceMethod java/util/Collection.size:()I
      23: iconst_m1
      24: iadd
      25: istore_3
      26: iconst_0
      27: iload_3
      28: if_icmpgt     68
      31: iload_3
      32: istore        4
      34: iinc          3, -1
      37: aload_1
      38: aload_0
      39: iload         4
      41: invokeinterface #112,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      46: invokeinterface #128,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      51: checkcast     #130                // class java/lang/Boolean
      54: invokevirtual #134                // Method java/lang/Boolean.booleanValue:()Z
      57: ifeq          63
      60: iload         4
      62: ireturn
      63: iconst_0
      64: iload_3
      65: if_icmple     31
      68: iconst_m1
      69: ireturn

  public static final void forEach(java.util.List<? extends java.util.List<java.lang.Character>>, kotlin.jvm.functions.Function2<? super java.lang.Integer, ? super java.lang.Integer, kotlin.Unit>);
    Code:
       0: aload_0
       1: ldc           #50                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #143                // String block
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iconst_0
      13: istore_2
      14: iconst_0
      15: istore_3
      16: aload_0
      17: checkcast     #123                // class java/util/Collection
      20: invokeinterface #124,  1          // InterfaceMethod java/util/Collection.size:()I
      25: istore        4
      27: iload_3
      28: iload         4
      30: if_icmpge     95
      33: aload_0
      34: iload_3
      35: invokeinterface #112,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      40: checkcast     #104                // class java/util/List
      43: astore        5
      45: iconst_0
      46: istore        6
      48: aload         5
      50: checkcast     #123                // class java/util/Collection
      53: invokeinterface #124,  1          // InterfaceMethod java/util/Collection.size:()I
      58: istore        7
      60: iload         6
      62: iload         7
      64: if_icmpge     89
      67: aload_1
      68: iload_3
      69: invokestatic  #149                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      72: iload         6
      74: invokestatic  #149                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      77: invokeinterface #154,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      82: pop
      83: iinc          6, 1
      86: goto          60
      89: iinc          3, 1
      92: goto          27
      95: return

  public static final int maxOf(java.util.List<? extends java.util.List<java.lang.Character>>, kotlin.jvm.functions.Function2<? super java.lang.Integer, ? super java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #50                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #143                // String block
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iconst_0
      13: istore_2
      14: aload_0
      15: astore_3
      16: iconst_0
      17: istore        4
      19: iconst_0
      20: istore        5
      22: aload_3
      23: checkcast     #123                // class java/util/Collection
      26: invokeinterface #124,  1          // InterfaceMethod java/util/Collection.size:()I
      31: istore        6
      33: iload         5
      35: iload         6
      37: if_icmpge     137
      40: aload_3
      41: iload         5
      43: invokeinterface #112,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      48: checkcast     #104                // class java/util/List
      51: astore        7
      53: iconst_0
      54: istore        8
      56: aload         7
      58: checkcast     #123                // class java/util/Collection
      61: invokeinterface #124,  1          // InterfaceMethod java/util/Collection.size:()I
      66: istore        9
      68: iload         8
      70: iload         9
      72: if_icmpge     131
      75: iload         5
      77: iload         8
      79: istore        10
      81: istore        11
      83: iconst_0
      84: istore        12
      86: aload_1
      87: iload         11
      89: invokestatic  #149                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      92: iload         10
      94: invokestatic  #149                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      97: invokeinterface #154,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     102: checkcast     #164                // class java/lang/Number
     105: invokevirtual #167                // Method java/lang/Number.intValue:()I
     108: istore        13
     110: iload         13
     112: iload_2
     113: if_icmple     121
     116: iload         13
     118: goto          122
     121: iload_2
     122: istore_2
     123: nop
     124: nop
     125: iinc          8, 1
     128: goto          68
     131: iinc          5, 1
     134: goto          33
     137: nop
     138: iload_2
     139: ireturn

  public static final int count(java.util.List<? extends java.util.List<java.lang.Character>>, kotlin.jvm.functions.Function2<? super java.lang.Integer, ? super java.lang.Integer, java.lang.Boolean>);
    Code:
       0: aload_0
       1: ldc           #50                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #143                // String block
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iconst_0
      13: istore_2
      14: aload_0
      15: astore_3
      16: iconst_0
      17: istore        4
      19: iconst_0
      20: istore        5
      22: aload_3
      23: checkcast     #123                // class java/util/Collection
      26: invokeinterface #124,  1          // InterfaceMethod java/util/Collection.size:()I
      31: istore        6
      33: iload         5
      35: iload         6
      37: if_icmpge     133
      40: aload_3
      41: iload         5
      43: invokeinterface #112,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      48: checkcast     #104                // class java/util/List
      51: astore        7
      53: iconst_0
      54: istore        8
      56: aload         7
      58: checkcast     #123                // class java/util/Collection
      61: invokeinterface #124,  1          // InterfaceMethod java/util/Collection.size:()I
      66: istore        9
      68: iload         8
      70: iload         9
      72: if_icmpge     127
      75: iload         5
      77: iload         8
      79: istore        10
      81: istore        11
      83: iconst_0
      84: istore        12
      86: iload_2
      87: aload_1
      88: iload         11
      90: invokestatic  #149                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      93: iload         10
      95: invokestatic  #149                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      98: invokeinterface #154,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     103: checkcast     #130                // class java/lang/Boolean
     106: invokevirtual #134                // Method java/lang/Boolean.booleanValue:()Z
     109: ifeq          116
     112: iconst_1
     113: goto          117
     116: iconst_0
     117: iadd
     118: istore_2
     119: nop
     120: nop
     121: iinc          8, 1
     124: goto          68
     127: iinc          5, 1
     130: goto          33
     133: nop
     134: iload_2
     135: ireturn

  private static final int allIntsInString$lambda$0(kotlin.text.MatchResult);
    Code:
       0: aload_0
       1: ldc           #183                // String it
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokeinterface #188,  1          // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;
      12: invokestatic  #192                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      15: ireturn
}


import Type.*

enum class Type { NONE, SAND, WALL }

fun main() {

    fun parse(input: List<String>): MutableMap<Point, Type> {
        val terrain = mutableMapOf<Point, Type>()

        val walls = input.map { it.split(" -> ")
                .map { it.split(",") }
                .map { (x, y) -> Point(x.toInt(), y.toInt()) }
        }

        walls.forEach { wall ->
            wall.reduce { p1, p2 ->
                val xRange = if (p1.x > p2.x) {
                    p2.x..p1.x
                } else {
                    p1.x..p2.x
                }

                val yRange = if (p1.y > p2.y) {
                    p2.y..p1.y
                } else {
                    p1.y..p2.y
                }

                for (x in xRange) {
                    terrain[Point(x, p1.y)] = WALL
                }
                for (y in yRange) {
                    terrain[Point(p1.x, y)] = WALL
                }

                p2
            }
        }

        return terrain
    }

    fun findMaxY(terrain: MutableMap<Point, Type>): Int {
        return terrain.keys.maxOf { it.y }
    }

    fun addSand(terrain: MutableMap<Point, Type>): Boolean {
        val maxY = findMaxY(terrain)
        val sandPoint = Point(500, 0)
        while (true) {
            sandPoint += Point(0, 1)

            if (sandPoint.y > maxY) {
                return false
            }

            val type = terrain[sandPoint] ?: NONE
            when (type) {
                NONE -> continue
                SAND, WALL -> {
                    val leftType = terrain[sandPoint + Point(-1, 0)] ?: NONE
                    when (leftType) {
                        NONE -> sandPoint += Point(-1, 0)
                        WALL, SAND -> {
                            val rightType = terrain[sandPoint + Point(+1, 0)] ?: NONE
                            if (rightType == NONE) {
                                sandPoint += Point(+1, 0)
                            } else {
                                terrain[sandPoint + Point(0, -1)] = SAND
                                return true
                            }
                        }
                    }
                }
            }
        }
    }

    fun addSand2(terrain: MutableMap<Point, Type>, maxY: Int): Boolean {
        val sandPoint = Point(500, 0)
        while (true) {
            sandPoint += Point(0, 1)

            if (sandPoint.y >= maxY+2) {
                terrain[sandPoint + Point(0, -1)] = SAND
                return true
            }

            val type = terrain[sandPoint] ?: NONE
            when (type) {
                NONE -> continue
                SAND, WALL -> {
                    val leftType = terrain[sandPoint + Point(-1, 0)] ?: NONE
                    when (leftType) {
                        NONE -> sandPoint += Point(-1, 0)
                        WALL, SAND -> {
                            val rightType = terrain[sandPoint + Point(+1, 0)] ?: NONE
                            if (rightType == NONE) {
                                sandPoint += Point(+1, 0)
                            } else {
                                val restPoint = sandPoint + Point(0, -1)
                                terrain[restPoint] = SAND

                                if (restPoint.x == 500 && restPoint.y == 0) {
                                    return false
                                }

                                return true
                            }
                        }
                    }
                }
            }
        }
    }

    fun part1(input: List<String>): Int {
        val terrain = parse(input)

        var counter = 0
        while (addSand(terrain)) {
            counter++
        }

        return counter
    }

    fun part2(input: List<String>): Int {
        val terrain = parse(input)
        val maxY = findMaxY(terrain)

        var counter = 0
        while (addSand2(terrain, maxY)) {
            counter++
        }

        return counter+1
    }

    val input = readInput("inputs/Day14")
    println(part1(input))
    println(part2(input))
}

Compiled from "Day14.kt"
public final class Day14Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String inputs/Day14
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)I
      10: istore_1
      11: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      14: iload_1
      15: invokevirtual #30                 // Method java/io/PrintStream.println:(I)V
      18: aload_0
      19: invokestatic  #33                 // Method main$part2:(Ljava/util/List;)I
      22: istore_1
      23: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      26: iload_1
      27: invokevirtual #30                 // Method java/io/PrintStream.println:(I)V
      30: return

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

  private static final java.util.Map<Point, Type> main$parse(java.util.List<java.lang.String>);
    Code:
       0: new           #45                 // class java/util/LinkedHashMap
       3: dup
       4: invokespecial #48                 // Method java/util/LinkedHashMap."<init>":()V
       7: checkcast     #50                 // class java/util/Map
      10: astore_1
      11: aload_0
      12: checkcast     #52                 // class java/lang/Iterable
      15: astore_3
      16: iconst_0
      17: istore        4
      19: aload_3
      20: astore        5
      22: new           #54                 // class java/util/ArrayList
      25: dup
      26: aload_3
      27: bipush        10
      29: invokestatic  #60                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      32: invokespecial #62                 // Method java/util/ArrayList."<init>":(I)V
      35: checkcast     #64                 // class java/util/Collection
      38: astore        6
      40: iconst_0
      41: istore        7
      43: aload         5
      45: invokeinterface #68,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      50: astore        8
      52: aload         8
      54: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      59: ifeq          385
      62: aload         8
      64: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      69: astore        9
      71: aload         6
      73: aload         9
      75: checkcast     #80                 // class java/lang/String
      78: astore        10
      80: astore        24
      82: iconst_0
      83: istore        11
      85: aload         10
      87: checkcast     #82                 // class java/lang/CharSequence
      90: iconst_1
      91: anewarray     #80                 // class java/lang/String
      94: astore        12
      96: aload         12
      98: iconst_0
      99: ldc           #84                 // String  ->
     101: aastore
     102: aload         12
     104: iconst_0
     105: iconst_0
     106: bipush        6
     108: aconst_null
     109: invokestatic  #90                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     112: checkcast     #52                 // class java/lang/Iterable
     115: astore        12
     117: nop
     118: iconst_0
     119: istore        13
     121: aload         12
     123: astore        14
     125: new           #54                 // class java/util/ArrayList
     128: dup
     129: aload         12
     131: bipush        10
     133: invokestatic  #60                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     136: invokespecial #62                 // Method java/util/ArrayList."<init>":(I)V
     139: checkcast     #64                 // class java/util/Collection
     142: astore        15
     144: iconst_0
     145: istore        16
     147: aload         14
     149: invokeinterface #68,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     154: astore        17
     156: aload         17
     158: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     163: ifeq          228
     166: aload         17
     168: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     173: astore        18
     175: aload         15
     177: aload         18
     179: checkcast     #80                 // class java/lang/String
     182: astore        19
     184: astore        20
     186: iconst_0
     187: istore        21
     189: aload         19
     191: checkcast     #82                 // class java/lang/CharSequence
     194: iconst_1
     195: anewarray     #80                 // class java/lang/String
     198: astore        22
     200: aload         22
     202: iconst_0
     203: ldc           #92                 // String ,
     205: aastore
     206: aload         22
     208: iconst_0
     209: iconst_0
     210: bipush        6
     212: aconst_null
     213: invokestatic  #90                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     216: aload         20
     218: swap
     219: invokeinterface #96,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     224: pop
     225: goto          156
     228: aload         15
     230: checkcast     #98                 // class java/util/List
     233: nop
     234: checkcast     #52                 // class java/lang/Iterable
     237: astore        12
     239: nop
     240: iconst_0
     241: istore        13
     243: aload         12
     245: astore        14
     247: new           #54                 // class java/util/ArrayList
     250: dup
     251: aload         12
     253: bipush        10
     255: invokestatic  #60                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     258: invokespecial #62                 // Method java/util/ArrayList."<init>":(I)V
     261: checkcast     #64                 // class java/util/Collection
     264: astore        15
     266: iconst_0
     267: istore        16
     269: aload         14
     271: invokeinterface #68,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     276: astore        17
     278: aload         17
     280: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     285: ifeq          366
     288: aload         17
     290: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     295: astore        18
     297: aload         15
     299: aload         18
     301: checkcast     #98                 // class java/util/List
     304: astore        19
     306: astore        20
     308: iconst_0
     309: istore        21
     311: aload         19
     313: iconst_0
     314: invokeinterface #102,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     319: checkcast     #80                 // class java/lang/String
     322: astore        22
     324: aload         19
     326: iconst_1
     327: invokeinterface #102,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     332: checkcast     #80                 // class java/lang/String
     335: astore        23
     337: new           #104                // class Point
     340: dup
     341: aload         22
     343: invokestatic  #110                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     346: aload         23
     348: invokestatic  #110                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     351: invokespecial #113                // Method Point."<init>":(II)V
     354: aload         20
     356: swap
     357: invokeinterface #96,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     362: pop
     363: goto          278
     366: aload         15
     368: checkcast     #98                 // class java/util/List
     371: nop
     372: nop
     373: aload         24
     375: swap
     376: invokeinterface #96,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     381: pop
     382: goto          52
     385: aload         6
     387: checkcast     #98                 // class java/util/List
     390: nop
     391: astore_2
     392: aload_2
     393: checkcast     #52                 // class java/lang/Iterable
     396: astore_3
     397: iconst_0
     398: istore        4
     400: aload_3
     401: invokeinterface #68,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     406: astore        5
     408: aload         5
     410: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     415: ifeq          750
     418: aload         5
     420: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     425: astore        6
     427: aload         6
     429: checkcast     #98                 // class java/util/List
     432: astore        7
     434: iconst_0
     435: istore        8
     437: aload         7
     439: checkcast     #52                 // class java/lang/Iterable
     442: astore        9
     444: iconst_0
     445: istore        10
     447: aload         9
     449: invokeinterface #68,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     454: astore        11
     456: aload         11
     458: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     463: ifne          476
     466: new           #115                // class java/lang/UnsupportedOperationException
     469: dup
     470: ldc           #117                // String Empty collection can\'t be reduced.
     472: invokespecial #120                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     475: athrow
     476: aload         11
     478: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     483: astore        12
     485: aload         11
     487: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     492: ifeq          744
     495: aload         12
     497: aload         11
     499: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     504: checkcast     #104                // class Point
     507: astore        13
     509: checkcast     #104                // class Point
     512: astore        14
     514: iconst_0
     515: istore        15
     517: aload         14
     519: invokevirtual #124                // Method Point.getX:()I
     522: aload         13
     524: invokevirtual #124                // Method Point.getX:()I
     527: if_icmple     550
     530: new           #126                // class kotlin/ranges/IntRange
     533: dup
     534: aload         13
     536: invokevirtual #124                // Method Point.getX:()I
     539: aload         14
     541: invokevirtual #124                // Method Point.getX:()I
     544: invokespecial #127                // Method kotlin/ranges/IntRange."<init>":(II)V
     547: goto          567
     550: new           #126                // class kotlin/ranges/IntRange
     553: dup
     554: aload         14
     556: invokevirtual #124                // Method Point.getX:()I
     559: aload         13
     561: invokevirtual #124                // Method Point.getX:()I
     564: invokespecial #127                // Method kotlin/ranges/IntRange."<init>":(II)V
     567: astore        16
     569: aload         14
     571: invokevirtual #130                // Method Point.getY:()I
     574: aload         13
     576: invokevirtual #130                // Method Point.getY:()I
     579: if_icmple     602
     582: new           #126                // class kotlin/ranges/IntRange
     585: dup
     586: aload         13
     588: invokevirtual #130                // Method Point.getY:()I
     591: aload         14
     593: invokevirtual #130                // Method Point.getY:()I
     596: invokespecial #127                // Method kotlin/ranges/IntRange."<init>":(II)V
     599: goto          619
     602: new           #126                // class kotlin/ranges/IntRange
     605: dup
     606: aload         14
     608: invokevirtual #130                // Method Point.getY:()I
     611: aload         13
     613: invokevirtual #130                // Method Point.getY:()I
     616: invokespecial #127                // Method kotlin/ranges/IntRange."<init>":(II)V
     619: astore        17
     621: aload         16
     623: invokevirtual #133                // Method kotlin/ranges/IntRange.getFirst:()I
     626: istore        18
     628: aload         16
     630: invokevirtual #136                // Method kotlin/ranges/IntRange.getLast:()I
     633: istore        19
     635: iload         18
     637: iload         19
     639: if_icmpgt     679
     642: aload_1
     643: new           #104                // class Point
     646: dup
     647: iload         18
     649: aload         14
     651: invokevirtual #130                // Method Point.getY:()I
     654: invokespecial #113                // Method Point."<init>":(II)V
     657: getstatic     #142                // Field Type.WALL:LType;
     660: invokeinterface #146,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     665: pop
     666: iload         18
     668: iload         19
     670: if_icmpeq     679
     673: iinc          18, 1
     676: goto          642
     679: aload         17
     681: invokevirtual #133                // Method kotlin/ranges/IntRange.getFirst:()I
     684: istore        18
     686: aload         17
     688: invokevirtual #136                // Method kotlin/ranges/IntRange.getLast:()I
     691: istore        19
     693: iload         18
     695: iload         19
     697: if_icmpgt     737
     700: aload_1
     701: new           #104                // class Point
     704: dup
     705: aload         14
     707: invokevirtual #124                // Method Point.getX:()I
     710: iload         18
     712: invokespecial #113                // Method Point."<init>":(II)V
     715: getstatic     #142                // Field Type.WALL:LType;
     718: invokeinterface #146,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     723: pop
     724: iload         18
     726: iload         19
     728: if_icmpeq     737
     731: iinc          18, 1
     734: goto          700
     737: aload         13
     739: astore        12
     741: goto          485
     744: nop
     745: nop
     746: nop
     747: goto          408
     750: nop
     751: aload_1
     752: areturn

  private static final int main$findMaxY(java.util.Map<Point, Type>);
    Code:
       0: aload_0
       1: invokeinterface #190,  1          // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;
       6: checkcast     #52                 // class java/lang/Iterable
       9: invokeinterface #68,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      14: astore_1
      15: aload_1
      16: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      21: ifne          32
      24: new           #192                // class java/util/NoSuchElementException
      27: dup
      28: invokespecial #193                // Method java/util/NoSuchElementException."<init>":()V
      31: athrow
      32: aload_1
      33: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      38: checkcast     #104                // class Point
      41: astore_2
      42: iconst_0
      43: istore_3
      44: aload_2
      45: invokevirtual #130                // Method Point.getY:()I
      48: istore_2
      49: aload_1
      50: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      55: ifeq          86
      58: aload_1
      59: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      64: checkcast     #104                // class Point
      67: astore_3
      68: iconst_0
      69: istore        4
      71: aload_3
      72: invokevirtual #130                // Method Point.getY:()I
      75: istore_3
      76: iload_2
      77: iload_3
      78: if_icmpge     49
      81: iload_3
      82: istore_2
      83: goto          49
      86: iload_2
      87: ireturn

  private static final boolean main$addSand(java.util.Map<Point, Type>);
    Code:
       0: aload_0
       1: invokestatic  #199                // Method main$findMaxY:(Ljava/util/Map;)I
       4: istore_1
       5: new           #104                // class Point
       8: dup
       9: sipush        500
      12: iconst_0
      13: invokespecial #113                // Method Point."<init>":(II)V
      16: astore_2
      17: nop
      18: aload_2
      19: new           #104                // class Point
      22: dup
      23: iconst_0
      24: iconst_1
      25: invokespecial #113                // Method Point."<init>":(II)V
      28: invokevirtual #203                // Method Point.plusAssign:(LPoint;)V
      31: aload_2
      32: invokevirtual #130                // Method Point.getY:()I
      35: iload_1
      36: if_icmple     41
      39: iconst_0
      40: ireturn
      41: aload_0
      42: aload_2
      43: invokeinterface #206,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      48: checkcast     #138                // class Type
      51: dup
      52: ifnonnull     59
      55: pop
      56: getstatic     #209                // Field Type.NONE:LType;
      59: astore_3
      60: aload_3
      61: getstatic     #215                // Field Day14Kt$WhenMappings.$EnumSwitchMapping$0:[I
      64: swap
      65: invokevirtual #218                // Method Type.ordinal:()I
      68: iaload
      69: tableswitch   { // 1 to 3
                     1: 96
                     2: 99
                     3: 99
               default: 273
          }
      96: goto          17
      99: aload_0
     100: aload_2
     101: new           #104                // class Point
     104: dup
     105: iconst_m1
     106: iconst_0
     107: invokespecial #113                // Method Point."<init>":(II)V
     110: invokevirtual #222                // Method Point.plus:(LPoint;)LPoint;
     113: invokeinterface #206,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     118: checkcast     #138                // class Type
     121: dup
     122: ifnonnull     129
     125: pop
     126: getstatic     #209                // Field Type.NONE:LType;
     129: astore        4
     131: aload         4
     133: getstatic     #215                // Field Day14Kt$WhenMappings.$EnumSwitchMapping$0:[I
     136: swap
     137: invokevirtual #218                // Method Type.ordinal:()I
     140: iaload
     141: tableswitch   { // 1 to 3
                     1: 168
                     2: 184
                     3: 184
               default: 265
          }
     168: aload_2
     169: new           #104                // class Point
     172: dup
     173: iconst_m1
     174: iconst_0
     175: invokespecial #113                // Method Point."<init>":(II)V
     178: invokevirtual #203                // Method Point.plusAssign:(LPoint;)V
     181: goto          17
     184: aload_0
     185: aload_2
     186: new           #104                // class Point
     189: dup
     190: iconst_1
     191: iconst_0
     192: invokespecial #113                // Method Point."<init>":(II)V
     195: invokevirtual #222                // Method Point.plus:(LPoint;)LPoint;
     198: invokeinterface #206,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     203: checkcast     #138                // class Type
     206: dup
     207: ifnonnull     214
     210: pop
     211: getstatic     #209                // Field Type.NONE:LType;
     214: astore        5
     216: aload         5
     218: getstatic     #209                // Field Type.NONE:LType;
     221: if_acmpne     240
     224: aload_2
     225: new           #104                // class Point
     228: dup
     229: iconst_1
     230: iconst_0
     231: invokespecial #113                // Method Point."<init>":(II)V
     234: invokevirtual #203                // Method Point.plusAssign:(LPoint;)V
     237: goto          17
     240: aload_0
     241: aload_2
     242: new           #104                // class Point
     245: dup
     246: iconst_0
     247: iconst_m1
     248: invokespecial #113                // Method Point."<init>":(II)V
     251: invokevirtual #222                // Method Point.plus:(LPoint;)LPoint;
     254: getstatic     #225                // Field Type.SAND:LType;
     257: invokeinterface #146,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     262: pop
     263: iconst_1
     264: ireturn
     265: new           #227                // class kotlin/NoWhenBranchMatchedException
     268: dup
     269: invokespecial #228                // Method kotlin/NoWhenBranchMatchedException."<init>":()V
     272: athrow
     273: new           #227                // class kotlin/NoWhenBranchMatchedException
     276: dup
     277: invokespecial #228                // Method kotlin/NoWhenBranchMatchedException."<init>":()V
     280: athrow

  private static final boolean main$addSand2(java.util.Map<Point, Type>, int);
    Code:
       0: new           #104                // class Point
       3: dup
       4: sipush        500
       7: iconst_0
       8: invokespecial #113                // Method Point."<init>":(II)V
      11: astore_2
      12: nop
      13: aload_2
      14: new           #104                // class Point
      17: dup
      18: iconst_0
      19: iconst_1
      20: invokespecial #113                // Method Point."<init>":(II)V
      23: invokevirtual #203                // Method Point.plusAssign:(LPoint;)V
      26: aload_2
      27: invokevirtual #130                // Method Point.getY:()I
      30: iload_1
      31: iconst_2
      32: iadd
      33: if_icmplt     61
      36: aload_0
      37: aload_2
      38: new           #104                // class Point
      41: dup
      42: iconst_0
      43: iconst_m1
      44: invokespecial #113                // Method Point."<init>":(II)V
      47: invokevirtual #222                // Method Point.plus:(LPoint;)LPoint;
      50: getstatic     #225                // Field Type.SAND:LType;
      53: invokeinterface #146,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      58: pop
      59: iconst_1
      60: ireturn
      61: aload_0
      62: aload_2
      63: invokeinterface #206,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      68: checkcast     #138                // class Type
      71: dup
      72: ifnonnull     79
      75: pop
      76: getstatic     #209                // Field Type.NONE:LType;
      79: astore_3
      80: aload_3
      81: getstatic     #215                // Field Day14Kt$WhenMappings.$EnumSwitchMapping$0:[I
      84: swap
      85: invokevirtual #218                // Method Type.ordinal:()I
      88: iaload
      89: tableswitch   { // 1 to 3
                     1: 116
                     2: 119
                     3: 119
               default: 318
          }
     116: goto          12
     119: aload_0
     120: aload_2
     121: new           #104                // class Point
     124: dup
     125: iconst_m1
     126: iconst_0
     127: invokespecial #113                // Method Point."<init>":(II)V
     130: invokevirtual #222                // Method Point.plus:(LPoint;)LPoint;
     133: invokeinterface #206,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     138: checkcast     #138                // class Type
     141: dup
     142: ifnonnull     149
     145: pop
     146: getstatic     #209                // Field Type.NONE:LType;
     149: astore        4
     151: aload         4
     153: getstatic     #215                // Field Day14Kt$WhenMappings.$EnumSwitchMapping$0:[I
     156: swap
     157: invokevirtual #218                // Method Type.ordinal:()I
     160: iaload
     161: tableswitch   { // 1 to 3
                     1: 188
                     2: 204
                     3: 204
               default: 310
          }
     188: aload_2
     189: new           #104                // class Point
     192: dup
     193: iconst_m1
     194: iconst_0
     195: invokespecial #113                // Method Point."<init>":(II)V
     198: invokevirtual #203                // Method Point.plusAssign:(LPoint;)V
     201: goto          12
     204: aload_0
     205: aload_2
     206: new           #104                // class Point
     209: dup
     210: iconst_1
     211: iconst_0
     212: invokespecial #113                // Method Point."<init>":(II)V
     215: invokevirtual #222                // Method Point.plus:(LPoint;)LPoint;
     218: invokeinterface #206,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     223: checkcast     #138                // class Type
     226: dup
     227: ifnonnull     234
     230: pop
     231: getstatic     #209                // Field Type.NONE:LType;
     234: astore        5
     236: aload         5
     238: getstatic     #209                // Field Type.NONE:LType;
     241: if_acmpne     260
     244: aload_2
     245: new           #104                // class Point
     248: dup
     249: iconst_1
     250: iconst_0
     251: invokespecial #113                // Method Point."<init>":(II)V
     254: invokevirtual #203                // Method Point.plusAssign:(LPoint;)V
     257: goto          12
     260: aload_2
     261: new           #104                // class Point
     264: dup
     265: iconst_0
     266: iconst_m1
     267: invokespecial #113                // Method Point."<init>":(II)V
     270: invokevirtual #222                // Method Point.plus:(LPoint;)LPoint;
     273: astore        6
     275: aload_0
     276: aload         6
     278: getstatic     #225                // Field Type.SAND:LType;
     281: invokeinterface #146,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     286: pop
     287: aload         6
     289: invokevirtual #124                // Method Point.getX:()I
     292: sipush        500
     295: if_icmpne     308
     298: aload         6
     300: invokevirtual #130                // Method Point.getY:()I
     303: ifne          308
     306: iconst_0
     307: ireturn
     308: iconst_1
     309: ireturn
     310: new           #227                // class kotlin/NoWhenBranchMatchedException
     313: dup
     314: invokespecial #228                // Method kotlin/NoWhenBranchMatchedException."<init>":()V
     317: athrow
     318: new           #227                // class kotlin/NoWhenBranchMatchedException
     321: dup
     322: invokespecial #228                // Method kotlin/NoWhenBranchMatchedException."<init>":()V
     325: athrow

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #240                // Method main$parse:(Ljava/util/List;)Ljava/util/Map;
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: invokestatic  #242                // Method main$addSand:(Ljava/util/Map;)Z
      11: ifeq          20
      14: iinc          2, 1
      17: goto          7
      20: iload_2
      21: ireturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #240                // Method main$parse:(Ljava/util/List;)Ljava/util/Map;
       4: astore_1
       5: aload_1
       6: invokestatic  #199                // Method main$findMaxY:(Ljava/util/Map;)I
       9: istore_2
      10: iconst_0
      11: istore_3
      12: aload_1
      13: iload_2
      14: invokestatic  #245                // Method main$addSand2:(Ljava/util/Map;I)Z
      17: ifeq          26
      20: iinc          3, 1
      23: goto          12
      26: iload_3
      27: iconst_1
      28: iadd
      29: ireturn
}

Compiled from "Day14.kt"
public final class Day14Kt$WhenMappings {
  public static final int[] $EnumSwitchMapping$0;

  static {};
    Code:
       0: invokestatic  #14                 // Method Type.values:()[LType;
       3: arraylength
       4: newarray       int
       6: astore_0
       7: nop
       8: aload_0
       9: getstatic     #18                 // Field Type.NONE:LType;
      12: invokevirtual #22                 // Method Type.ordinal:()I
      15: iconst_1
      16: iastore
      17: goto          21
      20: astore_1
      21: nop
      22: aload_0
      23: getstatic     #25                 // Field Type.WALL:LType;
      26: invokevirtual #22                 // Method Type.ordinal:()I
      29: iconst_2
      30: iastore
      31: goto          35
      34: astore_1
      35: nop
      36: aload_0
      37: getstatic     #28                 // Field Type.SAND:LType;
      40: invokevirtual #22                 // Method Type.ordinal:()I
      43: iconst_3
      44: iastore
      45: goto          49
      48: astore_1
      49: aload_0
      50: putstatic     #32                 // Field $EnumSwitchMapping$0:[I
      53: return
    Exception table:
       from    to  target type
           7    17    20   Class java/lang/NoSuchFieldError
          21    31    34   Class java/lang/NoSuchFieldError
          35    45    48   Class java/lang/NoSuchFieldError
}


fun main() {

    fun part1(input: List<String>) =
        input
            .readRanges()
            .count { (first, second) ->
                first contains second || second contains first
            }

    fun part2(input: List<String>) =
        input
            .readRanges()
            .count { (first, second) ->
                first overlaps second
            }

    val input = readInput("inputs/Day04")
    println(part1(input))
    println(part2(input))
}

fun List<String>.readRanges() =
    this.map {
        it.split(",").map { s ->
            val (start, end) = s.split("-")
            start.toInt()..end.toInt()
        }
    }

infix fun IntRange.contains(second: IntRange) = this.first <= second.first && this.last >= second.last
infix fun IntRange.overlaps(second: IntRange) = (this intersect second).isNotEmpty()

Compiled from "Day04.kt"
public final class Day04Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String inputs/Day04
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)I
      10: istore_1
      11: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      14: iload_1
      15: invokevirtual #30                 // Method java/io/PrintStream.println:(I)V
      18: aload_0
      19: invokestatic  #33                 // Method main$part2:(Ljava/util/List;)I
      22: istore_1
      23: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      26: iload_1
      27: invokevirtual #30                 // Method java/io/PrintStream.println:(I)V
      30: return

  public static final java.util.List<java.util.List<kotlin.ranges.IntRange>> readRanges(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #41                 // String <this>
       3: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #49                 // class java/lang/Iterable
      10: astore_1
      11: iconst_0
      12: istore_2
      13: aload_1
      14: astore_3
      15: new           #51                 // class java/util/ArrayList
      18: dup
      19: aload_1
      20: bipush        10
      22: invokestatic  #57                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      25: invokespecial #60                 // Method java/util/ArrayList."<init>":(I)V
      28: checkcast     #62                 // class java/util/Collection
      31: astore        4
      33: iconst_0
      34: istore        5
      36: aload_3
      37: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        6
      44: aload         6
      46: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          283
      54: aload         6
      56: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        7
      63: aload         4
      65: aload         7
      67: checkcast     #78                 // class java/lang/String
      70: astore        8
      72: astore        23
      74: iconst_0
      75: istore        9
      77: aload         8
      79: checkcast     #80                 // class java/lang/CharSequence
      82: iconst_1
      83: anewarray     #78                 // class java/lang/String
      86: astore        10
      88: aload         10
      90: iconst_0
      91: ldc           #82                 // String ,
      93: aastore
      94: aload         10
      96: iconst_0
      97: iconst_0
      98: bipush        6
     100: aconst_null
     101: invokestatic  #88                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     104: checkcast     #49                 // class java/lang/Iterable
     107: astore        10
     109: iconst_0
     110: istore        11
     112: aload         10
     114: astore        12
     116: new           #51                 // class java/util/ArrayList
     119: dup
     120: aload         10
     122: bipush        10
     124: invokestatic  #57                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     127: invokespecial #60                 // Method java/util/ArrayList."<init>":(I)V
     130: checkcast     #62                 // class java/util/Collection
     133: astore        13
     135: iconst_0
     136: istore        14
     138: aload         12
     140: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     145: astore        15
     147: aload         15
     149: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     154: ifeq          264
     157: aload         15
     159: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     164: astore        16
     166: aload         13
     168: aload         16
     170: checkcast     #78                 // class java/lang/String
     173: astore        17
     175: astore        18
     177: iconst_0
     178: istore        19
     180: aload         17
     182: checkcast     #80                 // class java/lang/CharSequence
     185: iconst_1
     186: anewarray     #78                 // class java/lang/String
     189: astore        20
     191: aload         20
     193: iconst_0
     194: ldc           #90                 // String -
     196: aastore
     197: aload         20
     199: iconst_0
     200: iconst_0
     201: bipush        6
     203: aconst_null
     204: invokestatic  #88                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     207: astore        21
     209: aload         21
     211: iconst_0
     212: invokeinterface #96,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     217: checkcast     #78                 // class java/lang/String
     220: astore        20
     222: aload         21
     224: iconst_1
     225: invokeinterface #96,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     230: checkcast     #78                 // class java/lang/String
     233: astore        22
     235: new           #98                 // class kotlin/ranges/IntRange
     238: dup
     239: aload         20
     241: invokestatic  #104                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     244: aload         22
     246: invokestatic  #104                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     249: invokespecial #107                // Method kotlin/ranges/IntRange."<init>":(II)V
     252: aload         18
     254: swap
     255: invokeinterface #111,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     260: pop
     261: goto          147
     264: aload         13
     266: checkcast     #92                 // class java/util/List
     269: nop
     270: nop
     271: aload         23
     273: swap
     274: invokeinterface #111,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     279: pop
     280: goto          44
     283: aload         4
     285: checkcast     #92                 // class java/util/List
     288: nop
     289: areturn

  public static final boolean contains(kotlin.ranges.IntRange, kotlin.ranges.IntRange);
    Code:
       0: aload_0
       1: ldc           #41                 // String <this>
       3: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #133                // String second
       9: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: invokevirtual #137                // Method kotlin/ranges/IntRange.getFirst:()I
      16: aload_1
      17: invokevirtual #137                // Method kotlin/ranges/IntRange.getFirst:()I
      20: if_icmpgt     38
      23: aload_0
      24: invokevirtual #140                // Method kotlin/ranges/IntRange.getLast:()I
      27: aload_1
      28: invokevirtual #140                // Method kotlin/ranges/IntRange.getLast:()I
      31: if_icmplt     38
      34: iconst_1
      35: goto          39
      38: iconst_0
      39: ireturn

  public static final boolean overlaps(kotlin.ranges.IntRange, kotlin.ranges.IntRange);
    Code:
       0: aload_0
       1: ldc           #41                 // String <this>
       3: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #133                // String second
       9: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: checkcast     #49                 // class java/lang/Iterable
      16: aload_1
      17: checkcast     #49                 // class java/lang/Iterable
      20: invokestatic  #147                // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
      23: checkcast     #62                 // class java/util/Collection
      26: invokeinterface #150,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      31: ifne          38
      34: iconst_1
      35: goto          39
      38: iconst_0
      39: ireturn

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

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #159                // Method readRanges:(Ljava/util/List;)Ljava/util/List;
       4: checkcast     #49                 // class java/lang/Iterable
       7: astore_1
       8: nop
       9: iconst_0
      10: istore_2
      11: aload_1
      12: instanceof    #62                 // class java/util/Collection
      15: ifeq          34
      18: aload_1
      19: checkcast     #62                 // class java/util/Collection
      22: invokeinterface #150,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      27: ifeq          34
      30: iconst_0
      31: goto          141
      34: iconst_0
      35: istore_3
      36: aload_1
      37: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        4
      44: aload         4
      46: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          140
      54: aload         4
      56: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        5
      63: aload         5
      65: checkcast     #92                 // class java/util/List
      68: astore        6
      70: iconst_0
      71: istore        7
      73: aload         6
      75: iconst_0
      76: invokeinterface #96,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      81: checkcast     #98                 // class kotlin/ranges/IntRange
      84: astore        8
      86: aload         6
      88: iconst_1
      89: invokeinterface #96,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      94: checkcast     #98                 // class kotlin/ranges/IntRange
      97: astore        9
      99: aload         8
     101: aload         9
     103: invokestatic  #161                // Method contains:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z
     106: ifne          119
     109: aload         9
     111: aload         8
     113: invokestatic  #161                // Method contains:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z
     116: ifeq          123
     119: iconst_1
     120: goto          124
     123: iconst_0
     124: ifeq          44
     127: iinc          3, 1
     130: iload_3
     131: ifge          44
     134: invokestatic  #164                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     137: goto          44
     140: iload_3
     141: ireturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #159                // Method readRanges:(Ljava/util/List;)Ljava/util/List;
       4: checkcast     #49                 // class java/lang/Iterable
       7: astore_1
       8: nop
       9: iconst_0
      10: istore_2
      11: aload_1
      12: instanceof    #62                 // class java/util/Collection
      15: ifeq          34
      18: aload_1
      19: checkcast     #62                 // class java/util/Collection
      22: invokeinterface #150,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      27: ifeq          34
      30: iconst_0
      31: goto          123
      34: iconst_0
      35: istore_3
      36: aload_1
      37: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        4
      44: aload         4
      46: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          122
      54: aload         4
      56: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        5
      63: aload         5
      65: checkcast     #92                 // class java/util/List
      68: astore        6
      70: iconst_0
      71: istore        7
      73: aload         6
      75: iconst_0
      76: invokeinterface #96,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      81: checkcast     #98                 // class kotlin/ranges/IntRange
      84: astore        8
      86: aload         6
      88: iconst_1
      89: invokeinterface #96,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      94: checkcast     #98                 // class kotlin/ranges/IntRange
      97: astore        9
      99: aload         8
     101: aload         9
     103: invokestatic  #172                // Method overlaps:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z
     106: ifeq          44
     109: iinc          3, 1
     112: iload_3
     113: ifge          44
     116: invokestatic  #164                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     119: goto          44
     122: iload_3
     123: ireturn
}