package day5

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

data class Point(val x: Int, val y: Int)

fun main(args: Array<String>) {
    val diagram = HashMap<Point, Int>()
    File("input.txt").readLines().forEach { line ->
        val (start, end) = line
            .split("->")
            .map { pair ->
                val (x, y) = pair.trim()
                    .split(',')
                    .map { num -> num.toInt() }
                Point(x, y)
            }
        println("Got $start $end")

        val yRange = if (start.y <= end.y) start.y .. end.y else start.y downTo end.y
        val xRange = if (start.x <= end.x) start.x..end.x else start.x downTo end.x

        if (start.x == end.x) {
            println("Check vertical")
            for (i in yRange) {
                val point = Point(start.x, i)
                val intersects = (diagram[point] ?: 0) + 1
                diagram[point] = intersects
                println("$point $intersects")
            }
        } else if (start.y == end.y) {
            println("Check horizontal")
            for (i in xRange) {
                val point = Point(i, start.y)
                val intersects = (diagram[point] ?: 0) + 1
                diagram[point] = intersects
                println("$point $intersects")
            }
        } else if ((start.x - end.x).absoluteValue == (start.y - end.y).absoluteValue) {
            println("Check diagonal $start $end")
            xRange.zip(yRange).forEach {
                val point = Point(it.first, it.second)
                val intersects = (diagram[point] ?: 0) + 1
                diagram[point] = intersects
                println("$point $intersects")
            }
        } else {
            println("Skip $start $end")
        }

    }

    println(diagram.filter { it.value >= 2 }.size)
}

Compiled from "Main.kt"
public final class day5.MainKt {
  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String args
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #17                 // class java/util/HashMap
       9: dup
      10: invokespecial #21                 // Method java/util/HashMap."<init>":()V
      13: astore_1
      14: new           #23                 // class java/io/File
      17: dup
      18: ldc           #25                 // String input.txt
      20: invokespecial #28                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      23: aconst_null
      24: iconst_1
      25: aconst_null
      26: invokestatic  #34                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      29: checkcast     #36                 // class java/lang/Iterable
      32: astore_2
      33: iconst_0
      34: istore_3
      35: aload_2
      36: invokeinterface #40,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      41: astore        4
      43: aload         4
      45: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifeq          1188
      53: aload         4
      55: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      60: astore        5
      62: aload         5
      64: checkcast     #52                 // class java/lang/String
      67: astore        6
      69: iconst_0
      70: istore        7
      72: aload         6
      74: checkcast     #54                 // class java/lang/CharSequence
      77: iconst_1
      78: anewarray     #52                 // class java/lang/String
      81: astore        8
      83: aload         8
      85: iconst_0
      86: ldc           #56                 // String ->
      88: aastore
      89: aload         8
      91: iconst_0
      92: iconst_0
      93: bipush        6
      95: aconst_null
      96: invokestatic  #62                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      99: checkcast     #36                 // class java/lang/Iterable
     102: astore        8
     104: nop
     105: iconst_0
     106: istore        9
     108: aload         8
     110: astore        10
     112: new           #64                 // class java/util/ArrayList
     115: dup
     116: aload         8
     118: bipush        10
     120: invokestatic  #70                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     123: invokespecial #73                 // Method java/util/ArrayList."<init>":(I)V
     126: checkcast     #75                 // class java/util/Collection
     129: astore        11
     131: iconst_0
     132: istore        12
     134: aload         10
     136: invokeinterface #40,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     141: astore        13
     143: aload         13
     145: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     150: ifeq          372
     153: aload         13
     155: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     160: astore        14
     162: aload         11
     164: aload         14
     166: checkcast     #52                 // class java/lang/String
     169: astore        15
     171: astore        16
     173: iconst_0
     174: istore        17
     176: aload         15
     178: checkcast     #54                 // class java/lang/CharSequence
     181: invokestatic  #79                 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     184: invokevirtual #83                 // Method java/lang/Object.toString:()Ljava/lang/String;
     187: checkcast     #54                 // class java/lang/CharSequence
     190: iconst_1
     191: newarray       char
     193: astore        18
     195: aload         18
     197: iconst_0
     198: bipush        44
     200: castore
     201: aload         18
     203: iconst_0
     204: iconst_0
     205: bipush        6
     207: aconst_null
     208: invokestatic  #86                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;
     211: checkcast     #36                 // class java/lang/Iterable
     214: astore        18
     216: nop
     217: iconst_0
     218: istore        19
     220: aload         18
     222: astore        20
     224: new           #64                 // class java/util/ArrayList
     227: dup
     228: aload         18
     230: bipush        10
     232: invokestatic  #70                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     235: invokespecial #73                 // Method java/util/ArrayList."<init>":(I)V
     238: checkcast     #75                 // class java/util/Collection
     241: astore        21
     243: iconst_0
     244: istore        22
     246: aload         20
     248: invokeinterface #40,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     253: astore        23
     255: aload         23
     257: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     262: ifeq          309
     265: aload         23
     267: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     272: astore        24
     274: aload         21
     276: aload         24
     278: checkcast     #52                 // class java/lang/String
     281: astore        25
     283: astore        26
     285: iconst_0
     286: istore        27
     288: aload         25
     290: invokestatic  #92                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     293: nop
     294: invokestatic  #96                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     297: aload         26
     299: swap
     300: invokeinterface #100,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     305: pop
     306: goto          255
     309: aload         21
     311: checkcast     #102                // class java/util/List
     314: nop
     315: astore        28
     317: aload         28
     319: iconst_0
     320: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     325: checkcast     #108                // class java/lang/Number
     328: invokevirtual #112                // Method java/lang/Number.intValue:()I
     331: istore        18
     333: aload         28
     335: iconst_1
     336: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     341: checkcast     #108                // class java/lang/Number
     344: invokevirtual #112                // Method java/lang/Number.intValue:()I
     347: istore        19
     349: new           #114                // class day5/Point
     352: dup
     353: iload         18
     355: iload         19
     357: invokespecial #117                // Method day5/Point."<init>":(II)V
     360: aload         16
     362: swap
     363: invokeinterface #100,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     368: pop
     369: goto          143
     372: aload         11
     374: checkcast     #102                // class java/util/List
     377: nop
     378: astore        29
     380: aload         29
     382: iconst_0
     383: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     388: checkcast     #114                // class day5/Point
     391: astore        8
     393: aload         29
     395: iconst_1
     396: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     401: checkcast     #114                // class day5/Point
     404: astore        9
     406: new           #119                // class java/lang/StringBuilder
     409: dup
     410: invokespecial #120                // Method java/lang/StringBuilder."<init>":()V
     413: ldc           #122                // String Got
     415: invokevirtual #126                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     418: aload         8
     420: invokevirtual #129                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     423: bipush        32
     425: invokevirtual #132                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     428: aload         9
     430: invokevirtual #129                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     433: invokevirtual #133                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     436: getstatic     #139                // Field java/lang/System.out:Ljava/io/PrintStream;
     439: swap
     440: invokevirtual #145                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     443: aload         8
     445: invokevirtual #148                // Method day5/Point.getY:()I
     448: aload         9
     450: invokevirtual #148                // Method day5/Point.getY:()I
     453: if_icmpgt     479
     456: new           #150                // class kotlin/ranges/IntRange
     459: dup
     460: aload         8
     462: invokevirtual #148                // Method day5/Point.getY:()I
     465: aload         9
     467: invokevirtual #148                // Method day5/Point.getY:()I
     470: invokespecial #151                // Method kotlin/ranges/IntRange."<init>":(II)V
     473: checkcast     #153                // class kotlin/ranges/IntProgression
     476: goto          492
     479: aload         8
     481: invokevirtual #148                // Method day5/Point.getY:()I
     484: aload         9
     486: invokevirtual #148                // Method day5/Point.getY:()I
     489: invokestatic  #159                // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;
     492: astore        10
     494: aload         8
     496: invokevirtual #162                // Method day5/Point.getX:()I
     499: aload         9
     501: invokevirtual #162                // Method day5/Point.getX:()I
     504: if_icmpgt     530
     507: new           #150                // class kotlin/ranges/IntRange
     510: dup
     511: aload         8
     513: invokevirtual #162                // Method day5/Point.getX:()I
     516: aload         9
     518: invokevirtual #162                // Method day5/Point.getX:()I
     521: invokespecial #151                // Method kotlin/ranges/IntRange."<init>":(II)V
     524: checkcast     #153                // class kotlin/ranges/IntProgression
     527: goto          543
     530: aload         8
     532: invokevirtual #162                // Method day5/Point.getX:()I
     535: aload         9
     537: invokevirtual #162                // Method day5/Point.getX:()I
     540: invokestatic  #159                // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;
     543: astore        11
     545: aload         8
     547: invokevirtual #162                // Method day5/Point.getX:()I
     550: aload         9
     552: invokevirtual #162                // Method day5/Point.getX:()I
     555: if_icmpne     723
     558: ldc           #164                // String Check vertical
     560: getstatic     #139                // Field java/lang/System.out:Ljava/io/PrintStream;
     563: swap
     564: invokevirtual #145                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     567: aload         10
     569: invokevirtual #167                // Method kotlin/ranges/IntProgression.getFirst:()I
     572: istore        12
     574: aload         10
     576: invokevirtual #170                // Method kotlin/ranges/IntProgression.getLast:()I
     579: istore        13
     581: aload         10
     583: invokevirtual #173                // Method kotlin/ranges/IntProgression.getStep:()I
     586: istore        14
     588: iload         14
     590: ifle          600
     593: iload         12
     595: iload         13
     597: if_icmple     612
     600: iload         14
     602: ifge          1183
     605: iload         13
     607: iload         12
     609: if_icmpgt     1183
     612: new           #114                // class day5/Point
     615: dup
     616: aload         8
     618: invokevirtual #162                // Method day5/Point.getX:()I
     621: iload         12
     623: invokespecial #117                // Method day5/Point."<init>":(II)V
     626: astore        15
     628: aload_1
     629: aload         15
     631: invokevirtual #176                // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
     634: checkcast     #88                 // class java/lang/Integer
     637: dup
     638: ifnull        647
     641: invokevirtual #177                // Method java/lang/Integer.intValue:()I
     644: goto          649
     647: pop
     648: iconst_0
     649: iconst_1
     650: iadd
     651: istore        17
     653: iload         17
     655: invokestatic  #96                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     658: astore        19
     660: aload_1
     661: checkcast     #179                // class java/util/Map
     664: aload         15
     666: aload         19
     668: invokeinterface #183,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     673: pop
     674: new           #119                // class java/lang/StringBuilder
     677: dup
     678: invokespecial #120                // Method java/lang/StringBuilder."<init>":()V
     681: aload         15
     683: invokevirtual #129                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     686: bipush        32
     688: invokevirtual #132                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     691: iload         17
     693: invokevirtual #186                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     696: invokevirtual #133                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     699: getstatic     #139                // Field java/lang/System.out:Ljava/io/PrintStream;
     702: swap
     703: invokevirtual #145                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     706: iload         12
     708: iload         13
     710: if_icmpeq     1183
     713: iload         12
     715: iload         14
     717: iadd
     718: istore        12
     720: goto          612
     723: aload         8
     725: invokevirtual #148                // Method day5/Point.getY:()I
     728: aload         9
     730: invokevirtual #148                // Method day5/Point.getY:()I
     733: if_icmpne     901
     736: ldc           #188                // String Check horizontal
     738: getstatic     #139                // Field java/lang/System.out:Ljava/io/PrintStream;
     741: swap
     742: invokevirtual #145                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     745: aload         11
     747: invokevirtual #167                // Method kotlin/ranges/IntProgression.getFirst:()I
     750: istore        12
     752: aload         11
     754: invokevirtual #170                // Method kotlin/ranges/IntProgression.getLast:()I
     757: istore        13
     759: aload         11
     761: invokevirtual #173                // Method kotlin/ranges/IntProgression.getStep:()I
     764: istore        14
     766: iload         14
     768: ifle          778
     771: iload         12
     773: iload         13
     775: if_icmple     790
     778: iload         14
     780: ifge          1183
     783: iload         13
     785: iload         12
     787: if_icmpgt     1183
     790: new           #114                // class day5/Point
     793: dup
     794: iload         12
     796: aload         8
     798: invokevirtual #148                // Method day5/Point.getY:()I
     801: invokespecial #117                // Method day5/Point."<init>":(II)V
     804: astore        15
     806: aload_1
     807: aload         15
     809: invokevirtual #176                // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
     812: checkcast     #88                 // class java/lang/Integer
     815: dup
     816: ifnull        825
     819: invokevirtual #177                // Method java/lang/Integer.intValue:()I
     822: goto          827
     825: pop
     826: iconst_0
     827: iconst_1
     828: iadd
     829: istore        17
     831: iload         17
     833: invokestatic  #96                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     836: astore        19
     838: aload_1
     839: checkcast     #179                // class java/util/Map
     842: aload         15
     844: aload         19
     846: invokeinterface #183,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     851: pop
     852: new           #119                // class java/lang/StringBuilder
     855: dup
     856: invokespecial #120                // Method java/lang/StringBuilder."<init>":()V
     859: aload         15
     861: invokevirtual #129                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     864: bipush        32
     866: invokevirtual #132                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     869: iload         17
     871: invokevirtual #186                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     874: invokevirtual #133                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     877: getstatic     #139                // Field java/lang/System.out:Ljava/io/PrintStream;
     880: swap
     881: invokevirtual #145                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     884: iload         12
     886: iload         13
     888: if_icmpeq     1183
     891: iload         12
     893: iload         14
     895: iadd
     896: istore        12
     898: goto          790
     901: aload         8
     903: invokevirtual #162                // Method day5/Point.getX:()I
     906: aload         9
     908: invokevirtual #162                // Method day5/Point.getX:()I
     911: isub
     912: invokestatic  #194                // Method java/lang/Math.abs:(I)I
     915: aload         8
     917: invokevirtual #148                // Method day5/Point.getY:()I
     920: aload         9
     922: invokevirtual #148                // Method day5/Point.getY:()I
     925: isub
     926: invokestatic  #194                // Method java/lang/Math.abs:(I)I
     929: if_icmpne     1146
     932: new           #119                // class java/lang/StringBuilder
     935: dup
     936: invokespecial #120                // Method java/lang/StringBuilder."<init>":()V
     939: ldc           #196                // String Check diagonal
     941: invokevirtual #126                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     944: aload         8
     946: invokevirtual #129                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     949: bipush        32
     951: invokevirtual #132                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     954: aload         9
     956: invokevirtual #129                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     959: invokevirtual #133                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     962: getstatic     #139                // Field java/lang/System.out:Ljava/io/PrintStream;
     965: swap
     966: invokevirtual #145                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     969: aload         11
     971: checkcast     #36                 // class java/lang/Iterable
     974: aload         10
     976: checkcast     #36                 // class java/lang/Iterable
     979: invokestatic  #200                // Method kotlin/collections/CollectionsKt.zip:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;
     982: checkcast     #36                 // class java/lang/Iterable
     985: astore        12
     987: iconst_0
     988: istore        13
     990: aload         12
     992: invokeinterface #40,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     997: astore        14
     999: aload         14
    1001: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1006: ifeq          1142
    1009: aload         14
    1011: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1016: astore        15
    1018: aload         15
    1020: checkcast     #202                // class kotlin/Pair
    1023: astore        17
    1025: iconst_0
    1026: istore        18
    1028: new           #114                // class day5/Point
    1031: dup
    1032: aload         17
    1034: invokevirtual #204                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
    1037: checkcast     #108                // class java/lang/Number
    1040: invokevirtual #112                // Method java/lang/Number.intValue:()I
    1043: aload         17
    1045: invokevirtual #207                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
    1048: checkcast     #108                // class java/lang/Number
    1051: invokevirtual #112                // Method java/lang/Number.intValue:()I
    1054: invokespecial #117                // Method day5/Point."<init>":(II)V
    1057: astore        19
    1059: aload_1
    1060: aload         19
    1062: invokevirtual #176                // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
    1065: checkcast     #88                 // class java/lang/Integer
    1068: dup
    1069: ifnull        1078
    1072: invokevirtual #177                // Method java/lang/Integer.intValue:()I
    1075: goto          1080
    1078: pop
    1079: iconst_0
    1080: iconst_1
    1081: iadd
    1082: istore        20
    1084: iload         20
    1086: invokestatic  #96                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1089: astore        21
    1091: aload_1
    1092: checkcast     #179                // class java/util/Map
    1095: aload         19
    1097: aload         21
    1099: invokeinterface #183,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    1104: pop
    1105: new           #119                // class java/lang/StringBuilder
    1108: dup
    1109: invokespecial #120                // Method java/lang/StringBuilder."<init>":()V
    1112: aload         19
    1114: invokevirtual #129                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
    1117: bipush        32
    1119: invokevirtual #132                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
    1122: iload         20
    1124: invokevirtual #186                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
    1127: invokevirtual #133                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
    1130: getstatic     #139                // Field java/lang/System.out:Ljava/io/PrintStream;
    1133: swap
    1134: invokevirtual #145                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
    1137: nop
    1138: nop
    1139: goto          999
    1142: nop
    1143: goto          1183
    1146: new           #119                // class java/lang/StringBuilder
    1149: dup
    1150: invokespecial #120                // Method java/lang/StringBuilder."<init>":()V
    1153: ldc           #209                // String Skip
    1155: invokevirtual #126                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
    1158: aload         8
    1160: invokevirtual #129                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
    1163: bipush        32
    1165: invokevirtual #132                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
    1168: aload         9
    1170: invokevirtual #129                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
    1173: invokevirtual #133                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
    1176: getstatic     #139                // Field java/lang/System.out:Ljava/io/PrintStream;
    1179: swap
    1180: invokevirtual #145                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
    1183: nop
    1184: nop
    1185: goto          43
    1188: nop
    1189: aload_1
    1190: checkcast     #179                // class java/util/Map
    1193: astore_2
    1194: iconst_0
    1195: istore_3
    1196: aload_2
    1197: astore        4
    1199: new           #211                // class java/util/LinkedHashMap
    1202: dup
    1203: invokespecial #212                // Method java/util/LinkedHashMap."<init>":()V
    1206: checkcast     #179                // class java/util/Map
    1209: astore        5
    1211: iconst_0
    1212: istore        6
    1214: aload         4
    1216: invokeinterface #216,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
    1221: invokeinterface #219,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
    1226: astore        7
    1228: aload         7
    1230: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1235: ifeq          1307
    1238: aload         7
    1240: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1245: checkcast     #221                // class java/util/Map$Entry
    1248: astore        8
    1250: aload         8
    1252: astore        9
    1254: iconst_0
    1255: istore        10
    1257: aload         9
    1259: invokeinterface #224,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
    1264: checkcast     #108                // class java/lang/Number
    1267: invokevirtual #112                // Method java/lang/Number.intValue:()I
    1270: iconst_2
    1271: if_icmplt     1278
    1274: iconst_1
    1275: goto          1279
    1278: iconst_0
    1279: ifeq          1228
    1282: aload         5
    1284: aload         8
    1286: invokeinterface #227,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
    1291: aload         8
    1293: invokeinterface #224,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
    1298: invokeinterface #183,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    1303: pop
    1304: goto          1228
    1307: aload         5
    1309: nop
    1310: invokeinterface #230,  1          // InterfaceMethod java/util/Map.size:()I
    1315: istore_2
    1316: getstatic     #139                // Field java/lang/System.out:Ljava/io/PrintStream;
    1319: iload_2
    1320: invokevirtual #232                // Method java/io/PrintStream.println:(I)V
    1323: return
}


package arrays

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

fun main() {

    printDirContent(File("/Users/emix/go/src/practicalalgo"))

}

fun printDirContent(dir: File, tabsCount: Int = 0, ignoreHidden: Boolean = true) {
    require(dir.exists()) { "$dir must exist" }
    require(dir.isDirectory) { "$dir must be directory" }

    val tabs = StringBuilder()
    repeat(tabsCount) { tabs.append("\t") }

    val dirOutput = StringBuilder()
    dirOutput.append(tabs).append(dir.name).append("/")

    println(dirOutput.toString())

    for (file in dir.listFiles()) {
        if (ignoreHidden && file.name.startsWith(".")) continue

        if (file.isDirectory) {
            printDirContent(file, tabsCount + 1, ignoreHidden)
        } else {
            val fileOutput = StringBuilder()
            fileOutput.append("\t").append(tabs).append(file.name)

            println(fileOutput.toString())
        }
    }
}

fun <T> binarySearch(list: List<Comparable<in T>>, value: T): Int {
    var lowIdx = 0
    var highIdx = list.size - 1

    while (lowIdx <= highIdx) {
        val midIdx = lowIdx + (highIdx - lowIdx) / 2
        when {
            list[midIdx] == value -> return midIdx
            list[midIdx] < value -> lowIdx = midIdx + 1
            list[midIdx] > value -> highIdx = midIdx - 1
        }
    }
    return -(lowIdx + 1)
}

fun <T> binarySearchRecursive(list: List<Comparable<in T>>, value: T, lowIdx: Int = 0, highIdx: Int = list.size - 1): Int {
    val notFound = -(lowIdx + 1)
    if (lowIdx > highIdx) {
        return notFound
    }
    val midIdx = lowIdx + (highIdx - lowIdx) / 2
    return when {
        list[midIdx] == value -> midIdx
        list[midIdx] < value -> binarySearchRecursive(list, value, midIdx + 1, highIdx)
        list[midIdx] > value -> binarySearchRecursive(list, value, lowIdx, midIdx - 1)
        else -> notFound
    }
}

fun <T> binarySearchLowestIndex(list: List<Comparable<in T>>, value: T): Int {
    var lowIdx = -1
    var highIdx = list.size
    while (lowIdx + 1 < highIdx) {
        val midIdx = (lowIdx + highIdx) ushr 1 // shifting but to right is same as dividing by 2
        if (list[midIdx] >= value) {
            highIdx = midIdx
        } else {
            lowIdx = midIdx
        }
    }
    return when (value) {
        list[highIdx] -> highIdx
        else -> -(highIdx + 1)
    }
}

fun average(numbers: List<Int>): Int {
    var sum = 0
    for (n in numbers) {
        sum += n
    }
    return sum / numbers.size
}

fun max(numbers: List<Int>): Int {
    var max = Int.MIN_VALUE
    for (n in numbers) {
        if (n > max) {
            max = n
        }
    }
    return max
}

fun idxOf(value: Int, list: List<Int>): Int {

    for ((idx, element) in list.withIndex()) {
        if (element == value) return idx
    }
    return -1
}

Compiled from "Experiment.kt"
public final class arrays.ExperimentKt {
  public static final void main();
    Code:
       0: new           #8                  // class java/io/File
       3: dup
       4: ldc           #10                 // String /Users/emix/go/src/practicalalgo
       6: invokespecial #14                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: iconst_0
      10: iconst_0
      11: bipush        6
      13: aconst_null
      14: invokestatic  #18                 // Method printDirContent$default:(Ljava/io/File;IZILjava/lang/Object;)V
      17: return

  public static final void printDirContent(java.io.File, int, boolean);
    Code:
       0: aload_0
       1: ldc           #23                 // String dir
       3: invokestatic  #29                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #33                 // Method java/io/File.exists:()Z
      10: ifne          50
      13: iconst_0
      14: istore        4
      16: new           #35                 // class java/lang/StringBuilder
      19: dup
      20: invokespecial #37                 // Method java/lang/StringBuilder."<init>":()V
      23: aload_0
      24: invokevirtual #41                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      27: ldc           #43                 // String  must exist
      29: invokevirtual #46                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      32: invokevirtual #50                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      35: astore        4
      37: new           #52                 // class java/lang/IllegalArgumentException
      40: dup
      41: aload         4
      43: invokevirtual #53                 // Method java/lang/Object.toString:()Ljava/lang/String;
      46: invokespecial #54                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      49: athrow
      50: aload_0
      51: invokevirtual #57                 // Method java/io/File.isDirectory:()Z
      54: ifne          94
      57: iconst_0
      58: istore        4
      60: new           #35                 // class java/lang/StringBuilder
      63: dup
      64: invokespecial #37                 // Method java/lang/StringBuilder."<init>":()V
      67: aload_0
      68: invokevirtual #41                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      71: ldc           #59                 // String  must be directory
      73: invokevirtual #46                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      76: invokevirtual #50                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      79: astore        4
      81: new           #52                 // class java/lang/IllegalArgumentException
      84: dup
      85: aload         4
      87: invokevirtual #53                 // Method java/lang/Object.toString:()Ljava/lang/String;
      90: invokespecial #54                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      93: athrow
      94: new           #35                 // class java/lang/StringBuilder
      97: dup
      98: invokespecial #37                 // Method java/lang/StringBuilder."<init>":()V
     101: astore_3
     102: iconst_0
     103: istore        4
     105: iload         4
     107: iload_1
     108: if_icmpge     131
     111: iload         4
     113: istore        5
     115: iconst_0
     116: istore        6
     118: aload_3
     119: ldc           #61                 // String \t
     121: invokevirtual #46                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     124: pop
     125: iinc          4, 1
     128: goto          105
     131: new           #35                 // class java/lang/StringBuilder
     134: dup
     135: invokespecial #37                 // Method java/lang/StringBuilder."<init>":()V
     138: astore        4
     140: aload         4
     142: aload_3
     143: checkcast     #63                 // class java/lang/CharSequence
     146: invokevirtual #66                 // Method java/lang/StringBuilder.append:(Ljava/lang/CharSequence;)Ljava/lang/StringBuilder;
     149: aload_0
     150: invokevirtual #69                 // Method java/io/File.getName:()Ljava/lang/String;
     153: invokevirtual #46                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     156: ldc           #71                 // String /
     158: invokevirtual #46                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     161: pop
     162: aload         4
     164: invokevirtual #50                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     167: getstatic     #77                 // Field java/lang/System.out:Ljava/io/PrintStream;
     170: swap
     171: invokevirtual #83                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     174: aload_0
     175: invokevirtual #87                 // Method java/io/File.listFiles:()[Ljava/io/File;
     178: invokestatic  #93                 // Method kotlin/jvm/internal/ArrayIteratorKt.iterator:([Ljava/lang/Object;)Ljava/util/Iterator;
     181: astore        5
     183: aload         5
     185: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     190: ifeq          303
     193: aload         5
     195: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     200: checkcast     #8                  // class java/io/File
     203: astore        6
     205: iload_2
     206: ifeq          231
     209: aload         6
     211: invokevirtual #69                 // Method java/io/File.getName:()Ljava/lang/String;
     214: dup
     215: ldc           #104                // String getName(...)
     217: invokestatic  #107                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     220: ldc           #109                // String .
     222: iconst_0
     223: iconst_2
     224: aconst_null
     225: invokestatic  #115                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
     228: ifne          183
     231: aload         6
     233: invokevirtual #57                 // Method java/io/File.isDirectory:()Z
     236: ifeq          256
     239: aload         6
     241: invokestatic  #118                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     244: aload         6
     246: iload_1
     247: iconst_1
     248: iadd
     249: iload_2
     250: invokestatic  #120                // Method printDirContent:(Ljava/io/File;IZ)V
     253: goto          183
     256: new           #35                 // class java/lang/StringBuilder
     259: dup
     260: invokespecial #37                 // Method java/lang/StringBuilder."<init>":()V
     263: astore        7
     265: aload         7
     267: ldc           #61                 // String \t
     269: invokevirtual #46                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     272: aload_3
     273: checkcast     #63                 // class java/lang/CharSequence
     276: invokevirtual #66                 // Method java/lang/StringBuilder.append:(Ljava/lang/CharSequence;)Ljava/lang/StringBuilder;
     279: aload         6
     281: invokevirtual #69                 // Method java/io/File.getName:()Ljava/lang/String;
     284: invokevirtual #46                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     287: pop
     288: aload         7
     290: invokevirtual #50                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     293: getstatic     #77                 // Field java/lang/System.out:Ljava/io/PrintStream;
     296: swap
     297: invokevirtual #83                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     300: goto          183
     303: return

  public static void printDirContent$default(java.io.File, int, boolean, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_2
       2: iand
       3: ifeq          8
       6: iconst_0
       7: istore_1
       8: iload_3
       9: iconst_4
      10: iand
      11: ifeq          16
      14: iconst_1
      15: istore_2
      16: aload_0
      17: iload_1
      18: iload_2
      19: invokestatic  #120                // Method printDirContent:(Ljava/io/File;IZ)V
      22: return

  public static final <T> int binarySearch(java.util.List<? extends java.lang.Comparable<? super T>>, T);
    Code:
       0: aload_0
       1: ldc           #139                // String list
       3: invokestatic  #29                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_2
       8: aload_0
       9: invokeinterface #145,  1          // InterfaceMethod java/util/List.size:()I
      14: iconst_1
      15: isub
      16: istore_3
      17: iload_2
      18: iload_3
      19: if_icmpgt     106
      22: iload_2
      23: iload_3
      24: iload_2
      25: isub
      26: iconst_2
      27: idiv
      28: iadd
      29: istore        4
      31: nop
      32: aload_0
      33: iload         4
      35: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      40: aload_1
      41: invokestatic  #153                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      44: ifeq          50
      47: iload         4
      49: ireturn
      50: aload_0
      51: iload         4
      53: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      58: checkcast     #155                // class java/lang/Comparable
      61: aload_1
      62: invokeinterface #159,  2          // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I
      67: ifge          78
      70: iload         4
      72: iconst_1
      73: iadd
      74: istore_2
      75: goto          17
      78: aload_0
      79: iload         4
      81: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      86: checkcast     #155                // class java/lang/Comparable
      89: aload_1
      90: invokeinterface #159,  2          // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I
      95: ifle          17
      98: iload         4
     100: iconst_1
     101: isub
     102: istore_3
     103: goto          17
     106: iload_2
     107: iconst_1
     108: iadd
     109: ineg
     110: ireturn

  public static final <T> int binarySearchRecursive(java.util.List<? extends java.lang.Comparable<? super T>>, T, int, int);
    Code:
       0: aload_0
       1: ldc           #139                // String list
       3: invokestatic  #29                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iload_2
       7: iconst_1
       8: iadd
       9: ineg
      10: istore        4
      12: iload_2
      13: iload_3
      14: if_icmple     20
      17: iload         4
      19: ireturn
      20: iload_2
      21: iload_3
      22: iload_2
      23: isub
      24: iconst_2
      25: idiv
      26: iadd
      27: istore        5
      29: nop
      30: aload_0
      31: iload         5
      33: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      38: aload_1
      39: invokestatic  #153                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      42: ifeq          50
      45: iload         5
      47: goto          118
      50: aload_0
      51: iload         5
      53: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      58: checkcast     #155                // class java/lang/Comparable
      61: aload_1
      62: invokeinterface #159,  2          // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I
      67: ifge          83
      70: aload_0
      71: aload_1
      72: iload         5
      74: iconst_1
      75: iadd
      76: iload_3
      77: invokestatic  #170                // Method binarySearchRecursive:(Ljava/util/List;Ljava/lang/Object;II)I
      80: goto          118
      83: aload_0
      84: iload         5
      86: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      91: checkcast     #155                // class java/lang/Comparable
      94: aload_1
      95: invokeinterface #159,  2          // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I
     100: ifle          116
     103: aload_0
     104: aload_1
     105: iload_2
     106: iload         5
     108: iconst_1
     109: isub
     110: invokestatic  #170                // Method binarySearchRecursive:(Ljava/util/List;Ljava/lang/Object;II)I
     113: goto          118
     116: iload         4
     118: ireturn

  public static int binarySearchRecursive$default(java.util.List, java.lang.Object, int, int, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_4
       3: iand
       4: ifeq          9
       7: iconst_0
       8: istore_2
       9: iload         4
      11: bipush        8
      13: iand
      14: ifeq          26
      17: aload_0
      18: invokeinterface #145,  1          // InterfaceMethod java/util/List.size:()I
      23: iconst_1
      24: isub
      25: istore_3
      26: aload_0
      27: aload_1
      28: iload_2
      29: iload_3
      30: invokestatic  #170                // Method binarySearchRecursive:(Ljava/util/List;Ljava/lang/Object;II)I
      33: ireturn

  public static final <T> int binarySearchLowestIndex(java.util.List<? extends java.lang.Comparable<? super T>>, T);
    Code:
       0: aload_0
       1: ldc           #139                // String list
       3: invokestatic  #29                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_m1
       7: istore_2
       8: aload_0
       9: invokeinterface #145,  1          // InterfaceMethod java/util/List.size:()I
      14: istore_3
      15: iload_2
      16: iconst_1
      17: iadd
      18: iload_3
      19: if_icmpge     61
      22: iload_2
      23: iload_3
      24: iadd
      25: iconst_1
      26: iushr
      27: istore        4
      29: aload_0
      30: iload         4
      32: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      37: checkcast     #155                // class java/lang/Comparable
      40: aload_1
      41: invokeinterface #159,  2          // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I
      46: iflt          55
      49: iload         4
      51: istore_3
      52: goto          15
      55: iload         4
      57: istore_2
      58: goto          15
      61: aload_1
      62: aload_0
      63: iload_3
      64: invokeinterface #149,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      69: invokestatic  #153                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      72: ifeq          79
      75: iload_3
      76: goto          83
      79: iload_3
      80: iconst_1
      81: iadd
      82: ineg
      83: ireturn

  public static final int average(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #179                // String numbers
       3: invokestatic  #29                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_1
       8: aload_0
       9: invokeinterface #182,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      14: astore_2
      15: aload_2
      16: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      21: ifeq          44
      24: aload_2
      25: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      30: checkcast     #184                // class java/lang/Number
      33: invokevirtual #187                // Method java/lang/Number.intValue:()I
      36: istore_3
      37: iload_1
      38: iload_3
      39: iadd
      40: istore_1
      41: goto          15
      44: iload_1
      45: aload_0
      46: invokeinterface #145,  1          // InterfaceMethod java/util/List.size:()I
      51: idiv
      52: ireturn

  public static final int max(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #179                // String numbers
       3: invokestatic  #29                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: ldc           #191                // int -2147483648
       8: istore_1
       9: aload_0
      10: invokeinterface #182,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      15: astore_2
      16: aload_2
      17: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      22: ifeq          48
      25: aload_2
      26: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      31: checkcast     #184                // class java/lang/Number
      34: invokevirtual #187                // Method java/lang/Number.intValue:()I
      37: istore_3
      38: iload_3
      39: iload_1
      40: if_icmple     16
      43: iload_3
      44: istore_1
      45: goto          16
      48: iload_1
      49: ireturn

  public static final int idxOf(int, java.util.List<java.lang.Integer>);
    Code:
       0: aload_1
       1: ldc           #139                // String list
       3: invokestatic  #29                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #196                // class java/lang/Iterable
      10: invokeinterface #197,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      15: astore_2
      16: iconst_0
      17: istore_3
      18: aload_2
      19: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      24: ifeq          57
      27: iload_3
      28: istore        4
      30: iload_3
      31: iconst_1
      32: iadd
      33: istore_3
      34: aload_2
      35: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      40: checkcast     #184                // class java/lang/Number
      43: invokevirtual #187                // Method java/lang/Number.intValue:()I
      46: istore        5
      48: iload         5
      50: iload_0
      51: if_icmpne     18
      54: iload         4
      56: ireturn
      57: iconst_m1
      58: ireturn

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


package day01

import java.io.File

data class Sweet(val calories: Int)
data class Elf(val sweets: List<Sweet>) {
    fun getCaloriesSum(): Int {
        return sweets.sumOf { it.calories }
    }
}

fun parseInput(input: String): List<Elf> {
    return input.split("\n\n")
        .map { elf ->
            val sweets = elf.split("\n")
                .map { it.toInt() }
                .map { Sweet(it) }
                .toList()
            Elf(sweets)
        }
}

fun getCaloriesOfTopNElves(elves: List<Elf>, n: Int): Int {
    val elvesSortedByCalories = elves
        .sortedByDescending { it.getCaloriesSum() }

    return elvesSortedByCalories
        .take(n)
        .sumOf { it.getCaloriesSum() }
}

fun part1(input: String): Int {
    val elves = parseInput(input)

    return getCaloriesOfTopNElves(elves, 1)
}

fun part2(input: String): Int {
    val elves = parseInput(input)

    return getCaloriesOfTopNElves(elves, 3)
}

fun main() {
    // test if implementation meets criteria from the description, like:
    val testInput = File("src/day01/Day01_test.txt").readText()
    check(part1(testInput) == 24000)

    val input = File("src/day01/Day01.txt").readText()

    println("Result Part 1: %s".format(part1(input)))
    println("Result Part 2: %s".format(part2(input)))
}

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

  public final int compare(T, T);
    Code:
       0: aload_2
       1: checkcast     #23                 // class day01/Elf
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method day01/Elf.getCaloriesSum:()I
      12: invokestatic  #33                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      15: checkcast     #35                 // class java/lang/Comparable
      18: aload_1
      19: checkcast     #23                 // class day01/Elf
      22: astore_3
      23: astore        5
      25: iconst_0
      26: istore        4
      28: aload_3
      29: invokevirtual #27                 // Method day01/Elf.getCaloriesSum:()I
      32: invokestatic  #33                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      35: aload         5
      37: swap
      38: checkcast     #35                 // class java/lang/Comparable
      41: invokestatic  #41                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      44: ireturn
}

Compiled from "Day01.kt"
public final class day01.Day01Kt {
  public static final java.util.List<day01.Elf> parseInput(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #10                 // String input
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #18                 // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #20                 // class java/lang/String
      14: astore_1
      15: aload_1
      16: iconst_0
      17: ldc           #22                 // String \n\n
      19: aastore
      20: aload_1
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #28                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: checkcast     #30                 // class java/lang/Iterable
      32: astore_1
      33: nop
      34: iconst_0
      35: istore_2
      36: aload_1
      37: astore_3
      38: new           #32                 // class java/util/ArrayList
      41: dup
      42: aload_1
      43: bipush        10
      45: invokestatic  #38                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      48: invokespecial #42                 // Method java/util/ArrayList."<init>":(I)V
      51: checkcast     #44                 // class java/util/Collection
      54: astore        4
      56: iconst_0
      57: istore        5
      59: aload_3
      60: invokeinterface #48,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      65: astore        6
      67: aload         6
      69: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      74: ifeq          367
      77: aload         6
      79: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      84: astore        7
      86: aload         4
      88: aload         7
      90: checkcast     #20                 // class java/lang/String
      93: astore        8
      95: astore        21
      97: iconst_0
      98: istore        9
     100: aload         8
     102: checkcast     #18                 // class java/lang/CharSequence
     105: iconst_1
     106: anewarray     #20                 // class java/lang/String
     109: astore        10
     111: aload         10
     113: iconst_0
     114: ldc           #60                 // String \n
     116: aastore
     117: aload         10
     119: iconst_0
     120: iconst_0
     121: bipush        6
     123: aconst_null
     124: invokestatic  #28                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     127: checkcast     #30                 // class java/lang/Iterable
     130: astore        10
     132: nop
     133: iconst_0
     134: istore        11
     136: aload         10
     138: astore        12
     140: new           #32                 // class java/util/ArrayList
     143: dup
     144: aload         10
     146: bipush        10
     148: invokestatic  #38                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     151: invokespecial #42                 // Method java/util/ArrayList."<init>":(I)V
     154: checkcast     #44                 // class java/util/Collection
     157: astore        13
     159: iconst_0
     160: istore        14
     162: aload         12
     164: invokeinterface #48,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     169: astore        15
     171: aload         15
     173: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     178: ifeq          225
     181: aload         15
     183: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     188: astore        16
     190: aload         13
     192: aload         16
     194: checkcast     #20                 // class java/lang/String
     197: astore        17
     199: astore        18
     201: iconst_0
     202: istore        19
     204: aload         17
     206: invokestatic  #66                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     209: nop
     210: invokestatic  #70                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     213: aload         18
     215: swap
     216: invokeinterface #74,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     221: pop
     222: goto          171
     225: aload         13
     227: checkcast     #76                 // class java/util/List
     230: nop
     231: checkcast     #30                 // class java/lang/Iterable
     234: astore        10
     236: nop
     237: iconst_0
     238: istore        11
     240: aload         10
     242: astore        12
     244: new           #32                 // class java/util/ArrayList
     247: dup
     248: aload         10
     250: bipush        10
     252: invokestatic  #38                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     255: invokespecial #42                 // Method java/util/ArrayList."<init>":(I)V
     258: checkcast     #44                 // class java/util/Collection
     261: astore        13
     263: iconst_0
     264: istore        14
     266: aload         12
     268: invokeinterface #48,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     273: astore        15
     275: aload         15
     277: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     282: ifeq          332
     285: aload         15
     287: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     292: astore        16
     294: aload         13
     296: aload         16
     298: checkcast     #78                 // class java/lang/Number
     301: invokevirtual #82                 // Method java/lang/Number.intValue:()I
     304: istore        17
     306: astore        18
     308: iconst_0
     309: istore        19
     311: new           #84                 // class day01/Sweet
     314: dup
     315: iload         17
     317: invokespecial #85                 // Method day01/Sweet."<init>":(I)V
     320: aload         18
     322: swap
     323: invokeinterface #74,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     328: pop
     329: goto          275
     332: aload         13
     334: checkcast     #76                 // class java/util/List
     337: nop
     338: checkcast     #30                 // class java/lang/Iterable
     341: invokestatic  #89                 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     344: astore        20
     346: new           #91                 // class day01/Elf
     349: dup
     350: aload         20
     352: invokespecial #94                 // Method day01/Elf."<init>":(Ljava/util/List;)V
     355: aload         21
     357: swap
     358: invokeinterface #74,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     363: pop
     364: goto          67
     367: aload         4
     369: checkcast     #76                 // class java/util/List
     372: nop
     373: areturn

  public static final int getCaloriesOfTopNElves(java.util.List<day01.Elf>, int);
    Code:
       0: aload_0
       1: ldc           #117                // String elves
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #30                 // class java/lang/Iterable
      10: astore_3
      11: nop
      12: iconst_0
      13: istore        4
      15: aload_3
      16: new           #119                // class day01/Day01Kt$getCaloriesOfTopNElves$$inlined$sortedByDescending$1
      19: dup
      20: invokespecial #122                // Method day01/Day01Kt$getCaloriesOfTopNElves$$inlined$sortedByDescending$1."<init>":()V
      23: checkcast     #124                // class java/util/Comparator
      26: invokestatic  #128                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
      29: astore_2
      30: aload_2
      31: checkcast     #30                 // class java/lang/Iterable
      34: iload_1
      35: invokestatic  #132                // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
      38: checkcast     #30                 // class java/lang/Iterable
      41: astore_3
      42: iconst_0
      43: istore        4
      45: aload_3
      46: invokeinterface #48,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      51: astore        5
      53: aload         5
      55: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      60: ifeq          103
      63: aload         5
      65: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      70: astore        6
      72: iload         4
      74: aload         6
      76: checkcast     #91                 // class day01/Elf
      79: astore        7
      81: istore        9
      83: iconst_0
      84: istore        8
      86: aload         7
      88: invokevirtual #135                // Method day01/Elf.getCaloriesSum:()I
      91: istore        10
      93: iload         9
      95: iload         10
      97: iadd
      98: istore        4
     100: goto          53
     103: iload         4
     105: ireturn

  public static final int part1(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #10                 // String input
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #144                // Method parseInput:(Ljava/lang/String;)Ljava/util/List;
      10: astore_1
      11: aload_1
      12: iconst_1
      13: invokestatic  #146                // Method getCaloriesOfTopNElves:(Ljava/util/List;I)I
      16: ireturn

  public static final int part2(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #10                 // String input
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #144                // Method parseInput:(Ljava/lang/String;)Ljava/util/List;
      10: astore_1
      11: aload_1
      12: iconst_3
      13: invokestatic  #146                // Method getCaloriesOfTopNElves:(Ljava/util/List;I)I
      16: ireturn

  public static final void main();
    Code:
       0: new           #150                // class java/io/File
       3: dup
       4: ldc           #152                // String src/day01/Day01_test.txt
       6: invokespecial #155                // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #161                // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
      15: astore_0
      16: aload_0
      17: invokestatic  #163                // Method part1:(Ljava/lang/String;)I
      20: sipush        24000
      23: if_icmpne     30
      26: iconst_1
      27: goto          31
      30: iconst_0
      31: ifne          44
      34: new           #165                // class java/lang/IllegalStateException
      37: dup
      38: ldc           #167                // String Check failed.
      40: invokespecial #168                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      43: athrow
      44: new           #150                // class java/io/File
      47: dup
      48: ldc           #170                // String src/day01/Day01.txt
      50: invokespecial #155                // Method java/io/File."<init>":(Ljava/lang/String;)V
      53: aconst_null
      54: iconst_1
      55: aconst_null
      56: invokestatic  #161                // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
      59: astore_1
      60: ldc           #172                // String Result Part 1: %s
      62: astore_2
      63: iconst_1
      64: anewarray     #4                  // class java/lang/Object
      67: astore_3
      68: aload_3
      69: iconst_0
      70: aload_1
      71: invokestatic  #163                // Method part1:(Ljava/lang/String;)I
      74: invokestatic  #70                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      77: aastore
      78: aload_3
      79: astore_3
      80: aload_2
      81: aload_3
      82: aload_3
      83: arraylength
      84: invokestatic  #178                // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;
      87: invokestatic  #182                // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
      90: dup
      91: ldc           #184                // String format(...)
      93: invokestatic  #187                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      96: astore_2
      97: getstatic     #193                // Field java/lang/System.out:Ljava/io/PrintStream;
     100: aload_2
     101: invokevirtual #199                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     104: ldc           #201                // String Result Part 2: %s
     106: astore_2
     107: iconst_1
     108: anewarray     #4                  // class java/lang/Object
     111: astore_3
     112: aload_3
     113: iconst_0
     114: aload_1
     115: invokestatic  #203                // Method part2:(Ljava/lang/String;)I
     118: invokestatic  #70                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     121: aastore
     122: aload_3
     123: astore_3
     124: aload_2
     125: aload_3
     126: aload_3
     127: arraylength
     128: invokestatic  #178                // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;
     131: invokestatic  #182                // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
     134: dup
     135: ldc           #184                // String format(...)
     137: invokestatic  #187                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     140: astore_2
     141: getstatic     #193                // Field java/lang/System.out:Ljava/io/PrintStream;
     144: aload_2
     145: invokevirtual #199                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     148: return

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


package day02

import java.io.File
import java.lang.IllegalArgumentException

enum class Move(val score: Int) {
    ROCK(1), PAPER(2), SCISSORS(3);

    companion object {
        fun fromShortcode(shortcode: String): Move {
            return when (shortcode) {
                "A", "X" -> ROCK
                "B", "Y" -> PAPER
                "C", "Z" -> SCISSORS
                else -> throw IllegalArgumentException("Ungültiger Code %s".format(shortcode))
            }
        }
    }
}

enum class RoundOutcome(val score: Int) {
    WIN(6), DRAW(3), LOOSE(0);

    companion object {
        fun fromShortcode(shortcode: String): RoundOutcome {
            return when (shortcode) {
                "X" -> LOOSE
                "Y" -> DRAW
                "Z" -> WIN
                else -> throw IllegalArgumentException("Ungültiger Code %s".format(shortcode))
            }
        }
    }
}

class Game(private val gameRounds: List<GameRound>) {
    fun getScore(): Int {
        return gameRounds.sumOf { it.getScore() }
    }
}

class GameRound(private val yourMove: Move, private val opponentMove: Move) {
    constructor(opponentMove: Move, expectedOutcome: RoundOutcome) : this(
        calculateYourOption(
            opponentMove,
            expectedOutcome
        ), opponentMove
    )

    fun getScore(): Int {
        return calculateOutcome().score + yourMove.score
    }

    companion object {
        fun calculateYourOption(opponentMove: Move, expectedOutcome: RoundOutcome): Move {
            return when (expectedOutcome) {
                RoundOutcome.WIN -> {
                    when (opponentMove) {
                        Move.ROCK -> Move.PAPER
                        Move.PAPER -> Move.SCISSORS
                        Move.SCISSORS -> Move.ROCK
                    }
                }

                RoundOutcome.DRAW -> opponentMove
                RoundOutcome.LOOSE -> {
                    when (opponentMove) {
                        Move.ROCK -> Move.SCISSORS
                        Move.PAPER -> Move.ROCK
                        Move.SCISSORS -> Move.PAPER
                    }
                }
            }
        }
    }

    private fun calculateOutcome(): RoundOutcome {
        return when (yourMove) {
            Move.ROCK -> {
                when (opponentMove) {
                    Move.ROCK -> RoundOutcome.DRAW
                    Move.PAPER -> RoundOutcome.LOOSE
                    Move.SCISSORS -> RoundOutcome.WIN
                }
            }

            Move.PAPER -> {
                when (opponentMove) {
                    Move.ROCK -> RoundOutcome.WIN
                    Move.PAPER -> RoundOutcome.DRAW
                    Move.SCISSORS -> RoundOutcome.LOOSE
                }
            }

            Move.SCISSORS -> {
                when (opponentMove) {
                    Move.ROCK -> RoundOutcome.LOOSE
                    Move.PAPER -> RoundOutcome.WIN
                    Move.SCISSORS -> RoundOutcome.DRAW
                }
            }
        }
    }
}

fun parseInputPart1(input: String): Game {
    val gameRounds = input.split("\n")
        .map { gameround: String ->
            val selectedOptions = gameround.split(" ")
            val opponentMove = Move.fromShortcode(selectedOptions[0])
            val yourMove = Move.fromShortcode(selectedOptions[1])
            return@map GameRound(yourMove, opponentMove)
        }
    return Game(gameRounds)
}

fun parseInputPart2(input: String): Game {
    val gameRounds = input.split("\n")
        .map { gameround: String ->
            val shortcodes = gameround.split(" ")
            val opponentMove = Move.fromShortcode(shortcodes[0])
            val expectedOutcome = RoundOutcome.fromShortcode(shortcodes[1])
            return@map GameRound(opponentMove, expectedOutcome)
        }
    return Game(gameRounds)
}

fun part1(input: String): Int {
    val game = parseInputPart1(input)
    return game.getScore()
}

fun part2(input: String): Int {
    val game = parseInputPart2(input)
    return game.getScore()
}

fun main() {
    // test if implementation meets criteria from the description, like:
    val testInput = File("src/day02/Day02_test.txt").readText()
    check(part1(testInput) == 15)
    check(part2(testInput) == 12)

    val input = File("src/day02/Day02.txt").readText()

    println("Result Part 1: %s".format(part1(input)))
    println("Result Part 2: %s".format(part2(input)))
}

Compiled from "Day02.kt"
public final class day02.Day02Kt {
  public static final day02.Game parseInputPart1(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #9                  // String input
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #17                 // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #19                 // class java/lang/String
      14: astore_2
      15: aload_2
      16: iconst_0
      17: ldc           #21                 // String \n
      19: aastore
      20: aload_2
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #27                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: checkcast     #29                 // class java/lang/Iterable
      32: astore_2
      33: nop
      34: iconst_0
      35: istore_3
      36: aload_2
      37: astore        4
      39: new           #31                 // class java/util/ArrayList
      42: dup
      43: aload_2
      44: bipush        10
      46: invokestatic  #37                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      49: invokespecial #41                 // Method java/util/ArrayList."<init>":(I)V
      52: checkcast     #43                 // class java/util/Collection
      55: astore        5
      57: iconst_0
      58: istore        6
      60: aload         4
      62: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      67: astore        7
      69: aload         7
      71: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      76: ifeq          192
      79: aload         7
      81: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      86: astore        8
      88: aload         5
      90: aload         8
      92: checkcast     #19                 // class java/lang/String
      95: astore        9
      97: astore        14
      99: iconst_0
     100: istore        10
     102: aload         9
     104: checkcast     #17                 // class java/lang/CharSequence
     107: iconst_1
     108: anewarray     #19                 // class java/lang/String
     111: astore        11
     113: aload         11
     115: iconst_0
     116: ldc           #59                 // String
     118: aastore
     119: aload         11
     121: iconst_0
     122: iconst_0
     123: bipush        6
     125: aconst_null
     126: invokestatic  #27                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     129: astore        12
     131: getstatic     #65                 // Field day02/Move.Companion:Lday02/Move$Companion;
     134: aload         12
     136: iconst_0
     137: invokeinterface #71,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     142: checkcast     #19                 // class java/lang/String
     145: invokevirtual #77                 // Method day02/Move$Companion.fromShortcode:(Ljava/lang/String;)Lday02/Move;
     148: astore        11
     150: getstatic     #65                 // Field day02/Move.Companion:Lday02/Move$Companion;
     153: aload         12
     155: iconst_1
     156: invokeinterface #71,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     161: checkcast     #19                 // class java/lang/String
     164: invokevirtual #77                 // Method day02/Move$Companion.fromShortcode:(Ljava/lang/String;)Lday02/Move;
     167: astore        13
     169: new           #79                 // class day02/GameRound
     172: dup
     173: aload         13
     175: aload         11
     177: invokespecial #82                 // Method day02/GameRound."<init>":(Lday02/Move;Lday02/Move;)V
     180: aload         14
     182: swap
     183: invokeinterface #86,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     188: pop
     189: goto          69
     192: aload         5
     194: checkcast     #67                 // class java/util/List
     197: nop
     198: astore_1
     199: new           #88                 // class day02/Game
     202: dup
     203: aload_1
     204: invokespecial #91                 // Method day02/Game."<init>":(Ljava/util/List;)V
     207: areturn

  public static final day02.Game parseInputPart2(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #9                  // String input
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #17                 // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #19                 // class java/lang/String
      14: astore_2
      15: aload_2
      16: iconst_0
      17: ldc           #21                 // String \n
      19: aastore
      20: aload_2
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #27                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: checkcast     #29                 // class java/lang/Iterable
      32: astore_2
      33: nop
      34: iconst_0
      35: istore_3
      36: aload_2
      37: astore        4
      39: new           #31                 // class java/util/ArrayList
      42: dup
      43: aload_2
      44: bipush        10
      46: invokestatic  #37                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      49: invokespecial #41                 // Method java/util/ArrayList."<init>":(I)V
      52: checkcast     #43                 // class java/util/Collection
      55: astore        5
      57: iconst_0
      58: istore        6
      60: aload         4
      62: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      67: astore        7
      69: aload         7
      71: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      76: ifeq          192
      79: aload         7
      81: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      86: astore        8
      88: aload         5
      90: aload         8
      92: checkcast     #19                 // class java/lang/String
      95: astore        9
      97: astore        14
      99: iconst_0
     100: istore        10
     102: aload         9
     104: checkcast     #17                 // class java/lang/CharSequence
     107: iconst_1
     108: anewarray     #19                 // class java/lang/String
     111: astore        11
     113: aload         11
     115: iconst_0
     116: ldc           #59                 // String
     118: aastore
     119: aload         11
     121: iconst_0
     122: iconst_0
     123: bipush        6
     125: aconst_null
     126: invokestatic  #27                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     129: astore        12
     131: getstatic     #65                 // Field day02/Move.Companion:Lday02/Move$Companion;
     134: aload         12
     136: iconst_0
     137: invokeinterface #71,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     142: checkcast     #19                 // class java/lang/String
     145: invokevirtual #77                 // Method day02/Move$Companion.fromShortcode:(Ljava/lang/String;)Lday02/Move;
     148: astore        11
     150: getstatic     #116                // Field day02/RoundOutcome.Companion:Lday02/RoundOutcome$Companion;
     153: aload         12
     155: iconst_1
     156: invokeinterface #71,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     161: checkcast     #19                 // class java/lang/String
     164: invokevirtual #121                // Method day02/RoundOutcome$Companion.fromShortcode:(Ljava/lang/String;)Lday02/RoundOutcome;
     167: astore        13
     169: new           #79                 // class day02/GameRound
     172: dup
     173: aload         11
     175: aload         13
     177: invokespecial #124                // Method day02/GameRound."<init>":(Lday02/Move;Lday02/RoundOutcome;)V
     180: aload         14
     182: swap
     183: invokeinterface #86,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     188: pop
     189: goto          69
     192: aload         5
     194: checkcast     #67                 // class java/util/List
     197: nop
     198: astore_1
     199: new           #88                 // class day02/Game
     202: dup
     203: aload_1
     204: invokespecial #91                 // Method day02/Game."<init>":(Ljava/util/List;)V
     207: areturn

  public static final int part1(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #9                  // String input
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #132                // Method parseInputPart1:(Ljava/lang/String;)Lday02/Game;
      10: astore_1
      11: aload_1
      12: invokevirtual #136                // Method day02/Game.getScore:()I
      15: ireturn

  public static final int part2(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #9                  // String input
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #141                // Method parseInputPart2:(Ljava/lang/String;)Lday02/Game;
      10: astore_1
      11: aload_1
      12: invokevirtual #136                // Method day02/Game.getScore:()I
      15: ireturn

  public static final void main();
    Code:
       0: new           #145                // class java/io/File
       3: dup
       4: ldc           #147                // String src/day02/Day02_test.txt
       6: invokespecial #150                // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #156                // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
      15: astore_0
      16: aload_0
      17: invokestatic  #158                // Method part1:(Ljava/lang/String;)I
      20: bipush        15
      22: if_icmpne     29
      25: iconst_1
      26: goto          30
      29: iconst_0
      30: ifne          43
      33: new           #160                // class java/lang/IllegalStateException
      36: dup
      37: ldc           #162                // String Check failed.
      39: invokespecial #163                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      42: athrow
      43: aload_0
      44: invokestatic  #165                // Method part2:(Ljava/lang/String;)I
      47: bipush        12
      49: if_icmpne     56
      52: iconst_1
      53: goto          57
      56: iconst_0
      57: ifne          70
      60: new           #160                // class java/lang/IllegalStateException
      63: dup
      64: ldc           #162                // String Check failed.
      66: invokespecial #163                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      69: athrow
      70: new           #145                // class java/io/File
      73: dup
      74: ldc           #167                // String src/day02/Day02.txt
      76: invokespecial #150                // Method java/io/File."<init>":(Ljava/lang/String;)V
      79: aconst_null
      80: iconst_1
      81: aconst_null
      82: invokestatic  #156                // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
      85: astore_1
      86: ldc           #169                // String Result Part 1: %s
      88: astore_2
      89: iconst_1
      90: anewarray     #4                  // class java/lang/Object
      93: astore_3
      94: aload_3
      95: iconst_0
      96: aload_1
      97: invokestatic  #158                // Method part1:(Ljava/lang/String;)I
     100: invokestatic  #175                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     103: aastore
     104: aload_3
     105: astore_3
     106: aload_2
     107: aload_3
     108: aload_3
     109: arraylength
     110: invokestatic  #181                // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;
     113: invokestatic  #185                // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
     116: dup
     117: ldc           #187                // String format(...)
     119: invokestatic  #190                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     122: astore_2
     123: getstatic     #196                // Field java/lang/System.out:Ljava/io/PrintStream;
     126: aload_2
     127: invokevirtual #202                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     130: ldc           #204                // String Result Part 2: %s
     132: astore_2
     133: iconst_1
     134: anewarray     #4                  // class java/lang/Object
     137: astore_3
     138: aload_3
     139: iconst_0
     140: aload_1
     141: invokestatic  #165                // Method part2:(Ljava/lang/String;)I
     144: invokestatic  #175                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     147: aastore
     148: aload_3
     149: astore_3
     150: aload_2
     151: aload_3
     152: aload_3
     153: arraylength
     154: invokestatic  #181                // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;
     157: invokestatic  #185                // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
     160: dup
     161: ldc           #187                // String format(...)
     163: invokestatic  #190                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     166: astore_2
     167: getstatic     #196                // Field java/lang/System.out:Ljava/io/PrintStream;
     170: aload_2
     171: invokevirtual #202                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     174: return

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