package d08

import java.io.File

fun main() {

    fun part1(input: List<String>) {
        var trees = 0
        val visited = mutableMapOf<Int, Char>()

        for (i in input.indices) {
            for (j in input[0].indices) {
                if (i == 0 || i == input.size - 1 || j == 0 || j == input[0].length - 1) {
                    if (i == 0) visited[j] = input[i][j]
                    trees++
                } else {
                    val tree = input[i][j]
                    val left = input[i].substring(0, j)
                    val right = input[i].substring(j + 1)

                    if (tree > visited[j]!!) {
                        trees++
                        visited[j] = tree
                    } else if (tree > left.max() || tree > right.max() || tree > input.drop(i + 1).maxOf { it[j] }) {
                        trees++
                    }
                }
            }
        }
        println(trees)
    }

    fun part2(input: List<String>) {
        var score = 0

        for (i in input.indices) {
            for (j in input[0].indices) {
                if (!(i == 0 || i == input.size - 1 || j == 0 || j == input[0].length - 1)) {
                    val tree = input[i][j]
                    val left = input[i].substring(0, j).reversed().toList()
                    val right = input[i].substring(j + 1).toList()
                    val up = input.subList(0, i).reversed().map { it[j] }
                    val down = input.drop(i + 1).map { it[j] }

                    val paths = arrayOf(up, down, left, right)

                    val tmp = paths.map {
                        var count = 0
                        for (t in it) {
                            count++
                            if (tree <= t) break
                        }
                        count
                    }.reduce(Int::times)

                    if (tmp > score) score = tmp
                }
            }
        }
        println(score)
    }

    val input = File("src/d08/input").readLines()

    part1(input)
    part2(input)
}

Compiled from "Main.kt"
public final class d08.MainKt {
  public static final void main();
    Code:
       0: new           #8                  // class java/io/File
       3: dup
       4: ldc           #10                 // String src/d08/input
       6: invokespecial #14                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #20                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      15: astore_0
      16: aload_0
      17: invokestatic  #24                 // Method main$part1:(Ljava/util/List;)V
      20: aload_0
      21: invokestatic  #27                 // Method main$part2:(Ljava/util/List;)V
      24: return

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

  private static final void main$part1(java.util.List<java.lang.String>);
    Code:
       0: iconst_0
       1: istore_1
       2: new           #37                 // class java/util/LinkedHashMap
       5: dup
       6: invokespecial #39                 // Method java/util/LinkedHashMap."<init>":()V
       9: checkcast     #41                 // class java/util/Map
      12: astore_2
      13: iconst_0
      14: istore_3
      15: aload_0
      16: checkcast     #43                 // class java/util/Collection
      19: invokeinterface #47,  1           // InterfaceMethod java/util/Collection.size:()I
      24: istore        4
      26: iload_3
      27: iload         4
      29: if_icmpge     448
      32: iconst_0
      33: istore        5
      35: aload_0
      36: iconst_0
      37: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      42: checkcast     #55                 // class java/lang/CharSequence
      45: invokeinterface #58,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      50: istore        6
      52: iload         5
      54: iload         6
      56: if_icmpge     442
      59: iload_3
      60: ifeq          100
      63: iload_3
      64: aload_0
      65: invokeinterface #59,  1           // InterfaceMethod java/util/List.size:()I
      70: iconst_1
      71: isub
      72: if_icmpeq     100
      75: iload         5
      77: ifeq          100
      80: iload         5
      82: aload_0
      83: iconst_0
      84: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      89: checkcast     #61                 // class java/lang/String
      92: invokevirtual #62                 // Method java/lang/String.length:()I
      95: iconst_1
      96: isub
      97: if_icmpne     143
     100: iload_3
     101: ifne          135
     104: iload         5
     106: invokestatic  #68                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     109: aload_2
     110: swap
     111: aload_0
     112: iload_3
     113: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     118: checkcast     #61                 // class java/lang/String
     121: iload         5
     123: invokevirtual #72                 // Method java/lang/String.charAt:(I)C
     126: invokestatic  #77                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     129: invokeinterface #81,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     134: pop
     135: iload_1
     136: iinc          1, 1
     139: pop
     140: goto          436
     143: aload_0
     144: iload_3
     145: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     150: checkcast     #61                 // class java/lang/String
     153: iload         5
     155: invokevirtual #72                 // Method java/lang/String.charAt:(I)C
     158: istore        7
     160: aload_0
     161: iload_3
     162: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     167: checkcast     #61                 // class java/lang/String
     170: iconst_0
     171: iload         5
     173: invokevirtual #85                 // Method java/lang/String.substring:(II)Ljava/lang/String;
     176: dup
     177: ldc           #87                 // String substring(...)
     179: invokestatic  #93                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     182: astore        8
     184: aload_0
     185: iload_3
     186: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     191: checkcast     #61                 // class java/lang/String
     194: iload         5
     196: iconst_1
     197: iadd
     198: invokevirtual #96                 // Method java/lang/String.substring:(I)Ljava/lang/String;
     201: dup
     202: ldc           #87                 // String substring(...)
     204: invokestatic  #93                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     207: astore        9
     209: iload         7
     211: aload_2
     212: iload         5
     214: invokestatic  #68                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     217: invokeinterface #99,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     222: dup
     223: invokestatic  #103                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     226: checkcast     #74                 // class java/lang/Character
     229: invokevirtual #107                // Method java/lang/Character.charValue:()C
     232: invokestatic  #111                // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
     235: ifle          269
     238: iinc          1, 1
     241: iload         5
     243: invokestatic  #68                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     246: astore        11
     248: iload         7
     250: invokestatic  #77                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     253: astore        12
     255: aload_2
     256: aload         11
     258: aload         12
     260: invokeinterface #81,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     265: pop
     266: goto          436
     269: iload         7
     271: aload         8
     273: checkcast     #55                 // class java/lang/CharSequence
     276: invokestatic  #117                // Method kotlin/text/StringsKt.maxOrThrow:(Ljava/lang/CharSequence;)C
     279: invokestatic  #111                // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
     282: ifgt          433
     285: iload         7
     287: aload         9
     289: checkcast     #55                 // class java/lang/CharSequence
     292: invokestatic  #117                // Method kotlin/text/StringsKt.maxOrThrow:(Ljava/lang/CharSequence;)C
     295: invokestatic  #111                // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
     298: ifgt          433
     301: iload         7
     303: aload_0
     304: checkcast     #119                // class java/lang/Iterable
     307: iload_3
     308: iconst_1
     309: iadd
     310: invokestatic  #125                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     313: checkcast     #119                // class java/lang/Iterable
     316: astore        10
     318: istore        15
     320: aload         10
     322: invokeinterface #129,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     327: astore        11
     329: aload         11
     331: invokeinterface #135,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     336: ifne          347
     339: new           #137                // class java/util/NoSuchElementException
     342: dup
     343: invokespecial #138                // Method java/util/NoSuchElementException."<init>":()V
     346: athrow
     347: aload         11
     349: invokeinterface #142,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     354: checkcast     #61                 // class java/lang/String
     357: astore        12
     359: iconst_0
     360: istore        13
     362: aload         12
     364: iload         5
     366: invokevirtual #72                 // Method java/lang/String.charAt:(I)C
     369: istore        12
     371: aload         11
     373: invokeinterface #135,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     378: ifeq          419
     381: aload         11
     383: invokeinterface #142,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     388: checkcast     #61                 // class java/lang/String
     391: astore        13
     393: iconst_0
     394: istore        14
     396: aload         13
     398: iload         5
     400: invokevirtual #72                 // Method java/lang/String.charAt:(I)C
     403: istore        13
     405: iload         12
     407: iload         13
     409: if_icmpge     371
     412: iload         13
     414: istore        12
     416: goto          371
     419: iload         12
     421: istore        16
     423: iload         15
     425: iload         16
     427: invokestatic  #111                // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
     430: ifle          436
     433: iinc          1, 1
     436: iinc          5, 1
     439: goto          52
     442: iinc          3, 1
     445: goto          26
     448: getstatic     #148                // Field java/lang/System.out:Ljava/io/PrintStream;
     451: iload_1
     452: invokevirtual #154                // Method java/io/PrintStream.println:(I)V
     455: return

  private static final void main$part2(java.util.List<java.lang.String>);
    Code:
       0: iconst_0
       1: istore_1
       2: iconst_0
       3: istore_2
       4: aload_0
       5: checkcast     #43                 // class java/util/Collection
       8: invokeinterface #47,  1           // InterfaceMethod java/util/Collection.size:()I
      13: istore_3
      14: iload_2
      15: iload_3
      16: if_icmpge     715
      19: iconst_0
      20: istore        4
      22: aload_0
      23: iconst_0
      24: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      29: checkcast     #55                 // class java/lang/CharSequence
      32: invokeinterface #58,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      37: istore        5
      39: iload         4
      41: iload         5
      43: if_icmpge     709
      46: iload_2
      47: ifeq          703
      50: iload_2
      51: aload_0
      52: invokeinterface #59,  1           // InterfaceMethod java/util/List.size:()I
      57: iconst_1
      58: isub
      59: if_icmpeq     703
      62: iload         4
      64: ifeq          703
      67: iload         4
      69: aload_0
      70: iconst_0
      71: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      76: checkcast     #61                 // class java/lang/String
      79: invokevirtual #62                 // Method java/lang/String.length:()I
      82: iconst_1
      83: isub
      84: if_icmpeq     703
      87: aload_0
      88: iload_2
      89: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      94: checkcast     #61                 // class java/lang/String
      97: iload         4
      99: invokevirtual #72                 // Method java/lang/String.charAt:(I)C
     102: istore        6
     104: nop
     105: aload_0
     106: iload_2
     107: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     112: checkcast     #61                 // class java/lang/String
     115: iconst_0
     116: iload         4
     118: invokevirtual #85                 // Method java/lang/String.substring:(II)Ljava/lang/String;
     121: dup
     122: ldc           #87                 // String substring(...)
     124: invokestatic  #93                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     127: checkcast     #55                 // class java/lang/CharSequence
     130: invokestatic  #171                // Method kotlin/text/StringsKt.reversed:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     133: invokevirtual #175                // Method java/lang/Object.toString:()Ljava/lang/String;
     136: checkcast     #55                 // class java/lang/CharSequence
     139: invokestatic  #179                // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;
     142: astore        7
     144: aload_0
     145: iload_2
     146: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     151: checkcast     #61                 // class java/lang/String
     154: iload         4
     156: iconst_1
     157: iadd
     158: invokevirtual #96                 // Method java/lang/String.substring:(I)Ljava/lang/String;
     161: dup
     162: ldc           #87                 // String substring(...)
     164: invokestatic  #93                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     167: checkcast     #55                 // class java/lang/CharSequence
     170: invokestatic  #179                // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;
     173: astore        8
     175: aload_0
     176: iconst_0
     177: iload_2
     178: invokeinterface #183,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     183: checkcast     #119                // class java/lang/Iterable
     186: invokestatic  #186                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
     189: checkcast     #119                // class java/lang/Iterable
     192: astore        10
     194: iconst_0
     195: istore        11
     197: aload         10
     199: astore        12
     201: new           #188                // class java/util/ArrayList
     204: dup
     205: aload         10
     207: bipush        10
     209: invokestatic  #192                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     212: invokespecial #194                // Method java/util/ArrayList."<init>":(I)V
     215: checkcast     #43                 // class java/util/Collection
     218: astore        13
     220: iconst_0
     221: istore        14
     223: aload         12
     225: invokeinterface #129,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     230: astore        15
     232: aload         15
     234: invokeinterface #135,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     239: ifeq          287
     242: aload         15
     244: invokeinterface #142,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     249: astore        16
     251: aload         13
     253: aload         16
     255: checkcast     #61                 // class java/lang/String
     258: astore        17
     260: astore        26
     262: iconst_0
     263: istore        18
     265: aload         17
     267: iload         4
     269: invokevirtual #72                 // Method java/lang/String.charAt:(I)C
     272: invokestatic  #77                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     275: aload         26
     277: swap
     278: invokeinterface #198,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     283: pop
     284: goto          232
     287: aload         13
     289: checkcast     #49                 // class java/util/List
     292: nop
     293: astore        9
     295: aload_0
     296: checkcast     #119                // class java/lang/Iterable
     299: iload_2
     300: iconst_1
     301: iadd
     302: invokestatic  #125                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     305: checkcast     #119                // class java/lang/Iterable
     308: astore        11
     310: iconst_0
     311: istore        12
     313: aload         11
     315: astore        13
     317: new           #188                // class java/util/ArrayList
     320: dup
     321: aload         11
     323: bipush        10
     325: invokestatic  #192                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     328: invokespecial #194                // Method java/util/ArrayList."<init>":(I)V
     331: checkcast     #43                 // class java/util/Collection
     334: astore        14
     336: iconst_0
     337: istore        15
     339: aload         13
     341: invokeinterface #129,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     346: astore        16
     348: aload         16
     350: invokeinterface #135,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     355: ifeq          403
     358: aload         16
     360: invokeinterface #142,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     365: astore        17
     367: aload         14
     369: aload         17
     371: checkcast     #61                 // class java/lang/String
     374: astore        18
     376: astore        26
     378: iconst_0
     379: istore        19
     381: aload         18
     383: iload         4
     385: invokevirtual #72                 // Method java/lang/String.charAt:(I)C
     388: invokestatic  #77                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     391: aload         26
     393: swap
     394: invokeinterface #198,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     399: pop
     400: goto          348
     403: aload         14
     405: checkcast     #49                 // class java/util/List
     408: nop
     409: astore        10
     411: iconst_4
     412: anewarray     #49                 // class java/util/List
     415: astore        12
     417: aload         12
     419: iconst_0
     420: aload         9
     422: aastore
     423: aload         12
     425: iconst_1
     426: aload         10
     428: aastore
     429: aload         12
     431: iconst_2
     432: aload         7
     434: aastore
     435: aload         12
     437: iconst_3
     438: aload         8
     440: aastore
     441: aload         12
     443: astore        11
     445: aload         11
     447: astore        13
     449: iconst_0
     450: istore        14
     452: aload         13
     454: astore        15
     456: new           #188                // class java/util/ArrayList
     459: dup
     460: aload         13
     462: arraylength
     463: invokespecial #194                // Method java/util/ArrayList."<init>":(I)V
     466: checkcast     #43                 // class java/util/Collection
     469: astore        16
     471: iconst_0
     472: istore        17
     474: iconst_0
     475: istore        18
     477: aload         15
     479: arraylength
     480: istore        19
     482: iload         18
     484: iload         19
     486: if_icmpge     580
     489: aload         15
     491: iload         18
     493: aaload
     494: astore        20
     496: aload         16
     498: aload         20
     500: astore        21
     502: astore        26
     504: iconst_0
     505: istore        22
     507: iconst_0
     508: istore        23
     510: aload         21
     512: invokeinterface #199,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     517: astore        24
     519: aload         24
     521: invokeinterface #135,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     526: ifeq          560
     529: aload         24
     531: invokeinterface #142,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     536: checkcast     #74                 // class java/lang/Character
     539: invokevirtual #107                // Method java/lang/Character.charValue:()C
     542: istore        25
     544: iinc          23, 1
     547: iload         6
     549: iload         25
     551: invokestatic  #111                // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
     554: ifgt          519
     557: goto          560
     560: iload         23
     562: invokestatic  #68                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     565: aload         26
     567: swap
     568: invokeinterface #198,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     573: pop
     574: iinc          18, 1
     577: goto          482
     580: aload         16
     582: checkcast     #49                 // class java/util/List
     585: nop
     586: checkcast     #119                // class java/lang/Iterable
     589: astore        13
     591: nop
     592: iconst_0
     593: istore        14
     595: aload         13
     597: invokeinterface #129,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     602: astore        15
     604: aload         15
     606: invokeinterface #135,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     611: ifne          624
     614: new           #201                // class java/lang/UnsupportedOperationException
     617: dup
     618: ldc           #203                // String Empty collection can\'t be reduced.
     620: invokespecial #204                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     623: athrow
     624: aload         15
     626: invokeinterface #142,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     631: astore        16
     633: aload         15
     635: invokeinterface #135,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     640: ifeq          684
     643: aload         16
     645: aload         15
     647: invokeinterface #142,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     652: checkcast     #206                // class java/lang/Number
     655: invokevirtual #209                // Method java/lang/Number.intValue:()I
     658: istore        17
     660: checkcast     #206                // class java/lang/Number
     663: invokevirtual #209                // Method java/lang/Number.intValue:()I
     666: istore        18
     668: iconst_0
     669: istore        19
     671: iload         18
     673: iload         17
     675: imul
     676: invokestatic  #68                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     679: astore        16
     681: goto          633
     684: aload         16
     686: checkcast     #206                // class java/lang/Number
     689: invokevirtual #209                // Method java/lang/Number.intValue:()I
     692: istore        12
     694: iload         12
     696: iload_1
     697: if_icmple     703
     700: iload         12
     702: istore_1
     703: iinc          4, 1
     706: goto          39
     709: iinc          2, 1
     712: goto          14
     715: getstatic     #148                // Field java/lang/System.out:Ljava/io/PrintStream;
     718: iload_1
     719: invokevirtual #154                // Method java/io/PrintStream.println:(I)V
     722: return
}


package d05

import java.io.File
import java.util.LinkedList

fun main() {

    fun part1(input: List<String>) {
        val (a, b) = input.partition { !Regex("""move \d+ from \d+ to \d+""").matches(it) }
        val crates = mutableMapOf<Int, LinkedList<Char>>()

        a.forEach { line ->
            line.forEachIndexed { i, c ->
                if (c.isLetter()) {
                    val n = (i / 4) + 1
                    crates.getOrPut(n) { LinkedList<Char>() }.addLast(c)
                }
            }
        }

        b.forEach {
            val (n, src, dst) = Regex("""move (\d+) from (\d+) to (\d+)""").find(it)!!.destructured
            (0 until n.toInt()).forEach { _ ->
                val tmp = crates[src.toInt()]!!.removeFirst()
                crates[dst.toInt()]!!.addFirst(tmp)
            }
        }

        crates.toSortedMap().forEach { print(it.value.peekFirst()) }
        print('\n')
    }

    fun part2(input: List<String>) {
        val (a, b) = input.partition { !Regex("""move \d+ from \d+ to \d+""").matches(it) }
        val crates = mutableMapOf<Int, LinkedList<Char>>()

        a.forEach { line ->
            line.forEachIndexed { i, c ->
                if (c.isLetter()) {
                    val n = (i / 4) + 1
                    crates.getOrPut(n) { LinkedList<Char>() }.addLast(c)
                }
            }
        }

        b.forEach {
            val (n, src, dst) = Regex("""move (\d+) from (\d+) to (\d+)""").find(it)!!.destructured
            val crane = LinkedList<Char>()

            (0 until n.toInt()).forEach { _ ->
                val tmp = crates[src.toInt()]!!.removeFirst()
                crane.addFirst(tmp)
            }

            crane.forEach { c -> crates[dst.toInt()]!!.addFirst(c) }
        }

        crates.toSortedMap().forEach { print(it.value.peekFirst()) }
        print('\n')
    }

    val input = File("src/d05/input").readLines()

    part1(input)
    part2(input)
}

Compiled from "Main.kt"
public final class d05.MainKt {
  public static final void main();
    Code:
       0: new           #8                  // class java/io/File
       3: dup
       4: ldc           #10                 // String src/d05/input
       6: invokespecial #14                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #20                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      15: astore_0
      16: aload_0
      17: invokestatic  #24                 // Method main$part1:(Ljava/util/List;)V
      20: aload_0
      21: invokestatic  #27                 // Method main$part2:(Ljava/util/List;)V
      24: return

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

  private static final void main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #37                 // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: new           #39                 // class java/util/ArrayList
      10: dup
      11: invokespecial #41                 // Method java/util/ArrayList."<init>":()V
      14: astore        4
      16: new           #39                 // class java/util/ArrayList
      19: dup
      20: invokespecial #41                 // Method java/util/ArrayList."<init>":()V
      23: astore        5
      25: aload_2
      26: invokeinterface #45,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      31: astore        6
      33: aload         6
      35: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      40: ifeq          111
      43: aload         6
      45: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      50: astore        7
      52: aload         7
      54: checkcast     #57                 // class java/lang/String
      57: astore        8
      59: iconst_0
      60: istore        9
      62: new           #59                 // class kotlin/text/Regex
      65: dup
      66: ldc           #61                 // String move \\d+ from \\d+ to \\d+
      68: invokespecial #62                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      71: aload         8
      73: checkcast     #64                 // class java/lang/CharSequence
      76: invokevirtual #68                 // Method kotlin/text/Regex.matches:(Ljava/lang/CharSequence;)Z
      79: ifne          86
      82: iconst_1
      83: goto          87
      86: iconst_0
      87: ifeq          100
      90: aload         4
      92: aload         7
      94: invokevirtual #72                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      97: goto          107
     100: aload         5
     102: aload         7
     104: invokevirtual #72                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     107: pop
     108: goto          33
     111: new           #74                 // class kotlin/Pair
     114: dup
     115: aload         4
     117: aload         5
     119: invokespecial #77                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     122: astore_1
     123: aload_1
     124: invokevirtual #80                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     127: checkcast     #82                 // class java/util/List
     130: astore_2
     131: aload_1
     132: invokevirtual #85                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     135: checkcast     #82                 // class java/util/List
     138: astore_3
     139: new           #87                 // class java/util/LinkedHashMap
     142: dup
     143: invokespecial #88                 // Method java/util/LinkedHashMap."<init>":()V
     146: checkcast     #90                 // class java/util/Map
     149: astore        4
     151: aload_2
     152: checkcast     #37                 // class java/lang/Iterable
     155: astore        5
     157: iconst_0
     158: istore        6
     160: aload         5
     162: invokeinterface #45,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     167: astore        7
     169: aload         7
     171: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     176: ifeq          354
     179: aload         7
     181: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     186: astore        8
     188: aload         8
     190: checkcast     #57                 // class java/lang/String
     193: astore        9
     195: iconst_0
     196: istore        10
     198: aload         9
     200: checkcast     #64                 // class java/lang/CharSequence
     203: astore        11
     205: iconst_0
     206: istore        12
     208: iconst_0
     209: istore        13
     211: iconst_0
     212: istore        14
     214: iload         14
     216: aload         11
     218: invokeinterface #94,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     223: if_icmpge     348
     226: aload         11
     228: iload         14
     230: invokeinterface #98,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     235: istore        15
     237: iload         13
     239: iinc          13, 1
     242: iload         15
     244: istore        16
     246: istore        17
     248: iconst_0
     249: istore        18
     251: iload         16
     253: invokestatic  #104                // Method java/lang/Character.isLetter:(C)Z
     256: ifeq          340
     259: iload         17
     261: iconst_4
     262: idiv
     263: iconst_1
     264: iadd
     265: istore        19
     267: aload         4
     269: astore        20
     271: iload         19
     273: invokestatic  #110                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     276: astore        21
     278: iconst_0
     279: istore        22
     281: aload         20
     283: aload         21
     285: invokeinterface #114,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     290: astore        23
     292: aload         23
     294: ifnonnull     326
     297: iconst_0
     298: istore        24
     300: new           #116                // class java/util/LinkedList
     303: dup
     304: invokespecial #117                // Method java/util/LinkedList."<init>":()V
     307: astore        24
     309: aload         20
     311: aload         21
     313: aload         24
     315: invokeinterface #121,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     320: pop
     321: aload         24
     323: goto          328
     326: aload         23
     328: nop
     329: checkcast     #116                // class java/util/LinkedList
     332: iload         16
     334: invokestatic  #124                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     337: invokevirtual #128                // Method java/util/LinkedList.addLast:(Ljava/lang/Object;)V
     340: nop
     341: nop
     342: iinc          14, 1
     345: goto          214
     348: nop
     349: nop
     350: nop
     351: goto          169
     354: nop
     355: aload_3
     356: checkcast     #37                 // class java/lang/Iterable
     359: astore        5
     361: iconst_0
     362: istore        6
     364: aload         5
     366: invokeinterface #45,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     371: astore        7
     373: aload         7
     375: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     380: ifeq          625
     383: aload         7
     385: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     390: astore        8
     392: aload         8
     394: checkcast     #57                 // class java/lang/String
     397: astore        9
     399: iconst_0
     400: istore        10
     402: new           #59                 // class kotlin/text/Regex
     405: dup
     406: ldc           #130                // String move (\\d+) from (\\d+) to (\\d+)
     408: invokespecial #62                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
     411: aload         9
     413: checkcast     #64                 // class java/lang/CharSequence
     416: iconst_0
     417: iconst_2
     418: aconst_null
     419: invokestatic  #134                // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;
     422: dup
     423: invokestatic  #139                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     426: invokeinterface #145,  1          // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;
     431: astore        11
     433: aload         11
     435: invokevirtual #151                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     438: invokeinterface #155,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     443: iconst_1
     444: invokeinterface #158,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     449: checkcast     #57                 // class java/lang/String
     452: astore        12
     454: aload         11
     456: invokevirtual #151                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     459: invokeinterface #155,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     464: iconst_2
     465: invokeinterface #158,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     470: checkcast     #57                 // class java/lang/String
     473: astore        13
     475: aload         11
     477: invokevirtual #151                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     480: invokeinterface #155,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     485: iconst_3
     486: invokeinterface #158,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     491: checkcast     #57                 // class java/lang/String
     494: astore        14
     496: iconst_0
     497: aload         12
     499: invokestatic  #162                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     502: invokestatic  #168                // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     505: checkcast     #37                 // class java/lang/Iterable
     508: astore        15
     510: iconst_0
     511: istore        16
     513: aload         15
     515: invokeinterface #45,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     520: astore        17
     522: aload         17
     524: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     529: ifeq          619
     532: aload         17
     534: checkcast     #170                // class kotlin/collections/IntIterator
     537: invokevirtual #173                // Method kotlin/collections/IntIterator.nextInt:()I
     540: istore        18
     542: iconst_0
     543: istore        19
     545: aload         4
     547: aload         13
     549: invokestatic  #162                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     552: invokestatic  #110                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     555: invokeinterface #114,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     560: dup
     561: invokestatic  #139                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     564: checkcast     #116                // class java/util/LinkedList
     567: invokevirtual #176                // Method java/util/LinkedList.removeFirst:()Ljava/lang/Object;
     570: dup
     571: ldc           #178                // String removeFirst(...)
     573: invokestatic  #182                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     576: checkcast     #100                // class java/lang/Character
     579: invokevirtual #186                // Method java/lang/Character.charValue:()C
     582: istore        20
     584: aload         4
     586: aload         14
     588: invokestatic  #162                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     591: invokestatic  #110                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     594: invokeinterface #114,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     599: dup
     600: invokestatic  #139                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     603: checkcast     #116                // class java/util/LinkedList
     606: iload         20
     608: invokestatic  #124                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     611: invokevirtual #189                // Method java/util/LinkedList.addFirst:(Ljava/lang/Object;)V
     614: nop
     615: nop
     616: goto          522
     619: nop
     620: nop
     621: nop
     622: goto          373
     625: nop
     626: aload         4
     628: invokestatic  #195                // Method kotlin/collections/MapsKt.toSortedMap:(Ljava/util/Map;)Ljava/util/SortedMap;
     631: checkcast     #90                 // class java/util/Map
     634: astore        5
     636: iconst_0
     637: istore        6
     639: aload         5
     641: invokeinterface #199,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     646: invokeinterface #202,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     651: astore        7
     653: aload         7
     655: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     660: ifeq          722
     663: aload         7
     665: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     670: checkcast     #204                // class java/util/Map$Entry
     673: astore        8
     675: aload         8
     677: astore        9
     679: iconst_0
     680: istore        10
     682: aload         9
     684: invokeinterface #207,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     689: checkcast     #116                // class java/util/LinkedList
     692: invokevirtual #210                // Method java/util/LinkedList.peekFirst:()Ljava/lang/Object;
     695: dup
     696: ldc           #212                // String peekFirst(...)
     698: invokestatic  #182                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     701: checkcast     #100                // class java/lang/Character
     704: invokevirtual #186                // Method java/lang/Character.charValue:()C
     707: istore        11
     709: getstatic     #218                // Field java/lang/System.out:Ljava/io/PrintStream;
     712: iload         11
     714: invokevirtual #224                // Method java/io/PrintStream.print:(C)V
     717: nop
     718: nop
     719: goto          653
     722: nop
     723: bipush        10
     725: istore        5
     727: getstatic     #218                // Field java/lang/System.out:Ljava/io/PrintStream;
     730: iload         5
     732: invokevirtual #224                // Method java/io/PrintStream.print:(C)V
     735: return

  private static final void main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #37                 // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: new           #39                 // class java/util/ArrayList
      10: dup
      11: invokespecial #41                 // Method java/util/ArrayList."<init>":()V
      14: astore        4
      16: new           #39                 // class java/util/ArrayList
      19: dup
      20: invokespecial #41                 // Method java/util/ArrayList."<init>":()V
      23: astore        5
      25: aload_2
      26: invokeinterface #45,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      31: astore        6
      33: aload         6
      35: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      40: ifeq          111
      43: aload         6
      45: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      50: astore        7
      52: aload         7
      54: checkcast     #57                 // class java/lang/String
      57: astore        8
      59: iconst_0
      60: istore        9
      62: new           #59                 // class kotlin/text/Regex
      65: dup
      66: ldc           #61                 // String move \\d+ from \\d+ to \\d+
      68: invokespecial #62                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      71: aload         8
      73: checkcast     #64                 // class java/lang/CharSequence
      76: invokevirtual #68                 // Method kotlin/text/Regex.matches:(Ljava/lang/CharSequence;)Z
      79: ifne          86
      82: iconst_1
      83: goto          87
      86: iconst_0
      87: ifeq          100
      90: aload         4
      92: aload         7
      94: invokevirtual #72                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      97: goto          107
     100: aload         5
     102: aload         7
     104: invokevirtual #72                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     107: pop
     108: goto          33
     111: new           #74                 // class kotlin/Pair
     114: dup
     115: aload         4
     117: aload         5
     119: invokespecial #77                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     122: astore_1
     123: aload_1
     124: invokevirtual #80                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     127: checkcast     #82                 // class java/util/List
     130: astore_2
     131: aload_1
     132: invokevirtual #85                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     135: checkcast     #82                 // class java/util/List
     138: astore_3
     139: new           #87                 // class java/util/LinkedHashMap
     142: dup
     143: invokespecial #88                 // Method java/util/LinkedHashMap."<init>":()V
     146: checkcast     #90                 // class java/util/Map
     149: astore        4
     151: aload_2
     152: checkcast     #37                 // class java/lang/Iterable
     155: astore        5
     157: iconst_0
     158: istore        6
     160: aload         5
     162: invokeinterface #45,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     167: astore        7
     169: aload         7
     171: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     176: ifeq          354
     179: aload         7
     181: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     186: astore        8
     188: aload         8
     190: checkcast     #57                 // class java/lang/String
     193: astore        9
     195: iconst_0
     196: istore        10
     198: aload         9
     200: checkcast     #64                 // class java/lang/CharSequence
     203: astore        11
     205: iconst_0
     206: istore        12
     208: iconst_0
     209: istore        13
     211: iconst_0
     212: istore        14
     214: iload         14
     216: aload         11
     218: invokeinterface #94,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     223: if_icmpge     348
     226: aload         11
     228: iload         14
     230: invokeinterface #98,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     235: istore        15
     237: iload         13
     239: iinc          13, 1
     242: iload         15
     244: istore        16
     246: istore        17
     248: iconst_0
     249: istore        18
     251: iload         16
     253: invokestatic  #104                // Method java/lang/Character.isLetter:(C)Z
     256: ifeq          340
     259: iload         17
     261: iconst_4
     262: idiv
     263: iconst_1
     264: iadd
     265: istore        19
     267: aload         4
     269: astore        20
     271: iload         19
     273: invokestatic  #110                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     276: astore        21
     278: iconst_0
     279: istore        22
     281: aload         20
     283: aload         21
     285: invokeinterface #114,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     290: astore        23
     292: aload         23
     294: ifnonnull     326
     297: iconst_0
     298: istore        24
     300: new           #116                // class java/util/LinkedList
     303: dup
     304: invokespecial #117                // Method java/util/LinkedList."<init>":()V
     307: astore        24
     309: aload         20
     311: aload         21
     313: aload         24
     315: invokeinterface #121,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     320: pop
     321: aload         24
     323: goto          328
     326: aload         23
     328: nop
     329: checkcast     #116                // class java/util/LinkedList
     332: iload         16
     334: invokestatic  #124                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     337: invokevirtual #128                // Method java/util/LinkedList.addLast:(Ljava/lang/Object;)V
     340: nop
     341: nop
     342: iinc          14, 1
     345: goto          214
     348: nop
     349: nop
     350: nop
     351: goto          169
     354: nop
     355: aload_3
     356: checkcast     #37                 // class java/lang/Iterable
     359: astore        5
     361: iconst_0
     362: istore        6
     364: aload         5
     366: invokeinterface #45,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     371: astore        7
     373: aload         7
     375: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     380: ifeq          700
     383: aload         7
     385: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     390: astore        8
     392: aload         8
     394: checkcast     #57                 // class java/lang/String
     397: astore        9
     399: iconst_0
     400: istore        10
     402: new           #59                 // class kotlin/text/Regex
     405: dup
     406: ldc           #130                // String move (\\d+) from (\\d+) to (\\d+)
     408: invokespecial #62                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
     411: aload         9
     413: checkcast     #64                 // class java/lang/CharSequence
     416: iconst_0
     417: iconst_2
     418: aconst_null
     419: invokestatic  #134                // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;
     422: dup
     423: invokestatic  #139                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     426: invokeinterface #145,  1          // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;
     431: astore        11
     433: aload         11
     435: invokevirtual #151                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     438: invokeinterface #155,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     443: iconst_1
     444: invokeinterface #158,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     449: checkcast     #57                 // class java/lang/String
     452: astore        12
     454: aload         11
     456: invokevirtual #151                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     459: invokeinterface #155,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     464: iconst_2
     465: invokeinterface #158,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     470: checkcast     #57                 // class java/lang/String
     473: astore        13
     475: aload         11
     477: invokevirtual #151                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     480: invokeinterface #155,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     485: iconst_3
     486: invokeinterface #158,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     491: checkcast     #57                 // class java/lang/String
     494: astore        14
     496: new           #116                // class java/util/LinkedList
     499: dup
     500: invokespecial #117                // Method java/util/LinkedList."<init>":()V
     503: astore        15
     505: iconst_0
     506: aload         12
     508: invokestatic  #162                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     511: invokestatic  #168                // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     514: checkcast     #37                 // class java/lang/Iterable
     517: astore        16
     519: iconst_0
     520: istore        17
     522: aload         16
     524: invokeinterface #45,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     529: astore        18
     531: aload         18
     533: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     538: ifeq          608
     541: aload         18
     543: checkcast     #170                // class kotlin/collections/IntIterator
     546: invokevirtual #173                // Method kotlin/collections/IntIterator.nextInt:()I
     549: istore        19
     551: iconst_0
     552: istore        20
     554: aload         4
     556: aload         13
     558: invokestatic  #162                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     561: invokestatic  #110                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     564: invokeinterface #114,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     569: dup
     570: invokestatic  #139                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     573: checkcast     #116                // class java/util/LinkedList
     576: invokevirtual #176                // Method java/util/LinkedList.removeFirst:()Ljava/lang/Object;
     579: dup
     580: ldc           #178                // String removeFirst(...)
     582: invokestatic  #182                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     585: checkcast     #100                // class java/lang/Character
     588: invokevirtual #186                // Method java/lang/Character.charValue:()C
     591: istore        21
     593: aload         15
     595: iload         21
     597: invokestatic  #124                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     600: invokevirtual #189                // Method java/util/LinkedList.addFirst:(Ljava/lang/Object;)V
     603: nop
     604: nop
     605: goto          531
     608: nop
     609: aload         15
     611: checkcast     #37                 // class java/lang/Iterable
     614: astore        16
     616: iconst_0
     617: istore        17
     619: aload         16
     621: invokeinterface #45,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     626: astore        18
     628: aload         18
     630: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     635: ifeq          694
     638: aload         18
     640: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     645: astore        19
     647: aload         19
     649: checkcast     #100                // class java/lang/Character
     652: invokevirtual #186                // Method java/lang/Character.charValue:()C
     655: istore        22
     657: iconst_0
     658: istore        20
     660: aload         4
     662: aload         14
     664: invokestatic  #162                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     667: invokestatic  #110                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     670: invokeinterface #114,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     675: dup
     676: invokestatic  #139                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     679: checkcast     #116                // class java/util/LinkedList
     682: iload         22
     684: invokestatic  #124                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     687: invokevirtual #189                // Method java/util/LinkedList.addFirst:(Ljava/lang/Object;)V
     690: nop
     691: goto          628
     694: nop
     695: nop
     696: nop
     697: goto          373
     700: nop
     701: aload         4
     703: invokestatic  #195                // Method kotlin/collections/MapsKt.toSortedMap:(Ljava/util/Map;)Ljava/util/SortedMap;
     706: checkcast     #90                 // class java/util/Map
     709: astore        5
     711: iconst_0
     712: istore        6
     714: aload         5
     716: invokeinterface #199,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     721: invokeinterface #202,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     726: astore        7
     728: aload         7
     730: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     735: ifeq          797
     738: aload         7
     740: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     745: checkcast     #204                // class java/util/Map$Entry
     748: astore        8
     750: aload         8
     752: astore        9
     754: iconst_0
     755: istore        10
     757: aload         9
     759: invokeinterface #207,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     764: checkcast     #116                // class java/util/LinkedList
     767: invokevirtual #210                // Method java/util/LinkedList.peekFirst:()Ljava/lang/Object;
     770: dup
     771: ldc           #212                // String peekFirst(...)
     773: invokestatic  #182                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     776: checkcast     #100                // class java/lang/Character
     779: invokevirtual #186                // Method java/lang/Character.charValue:()C
     782: istore        11
     784: getstatic     #218                // Field java/lang/System.out:Ljava/io/PrintStream;
     787: iload         11
     789: invokevirtual #224                // Method java/io/PrintStream.print:(C)V
     792: nop
     793: nop
     794: goto          728
     797: nop
     798: bipush        10
     800: istore        5
     802: getstatic     #218                // Field java/lang/System.out:Ljava/io/PrintStream;
     805: iload         5
     807: invokevirtual #224                // Method java/io/PrintStream.print:(C)V
     810: return
}


package pl.klemba.aoc.day4

import java.io.File
import kotlin.math.pow

fun main() {
  // ----- PART 1 -----
  File(inputPath)
    .readLines()
    .sumOf { card -> getNumberOfPointsForCard(card) }
    .let { println(it) }

  // ----- PART 2 -----
  val cardList = File(inputPath)
    .readLines()

  val amountOfScratchCards = IntArray(cardList.size) { 1 }

  cardList
    .foldIndexed(amountOfScratchCards) { index, acc, card -> calculateNumberOfCards(card, acc, index) }
    .sum()
    .let { println(it) }
}

fun getNumberOfPointsForCard(card: String): Int {
  val amountOfMatchingNumbers = getNumberOfMatchingNumbers(card)
  return if (amountOfMatchingNumbers == 1) 1 else 2.0.pow(amountOfMatchingNumbers - 1).toInt()
}

fun getNumberOfMatchingNumbers(card: String): Int {
  val winningNumbers = getWinningNumbers(card)
  val numbersYouHave = getNumbersYouHave(card)
  return winningNumbers.intersect(numbersYouHave.toSet()).size
}

fun getWinningNumbers(card: String): List<Int> =
  winningNumbersRegex.find(card)
    ?.value
    ?.removeRange(0, 2)
    ?.trim()
    ?.split("  ", " ")
    ?.map { it.toInt() }
    ?: throw IllegalStateException("No winning numbers found!")

fun getNumbersYouHave(card: String): List<Int> =
  numbersYouHaveRegex.find(card)
    ?.value
    ?.removeRange(0, 2)
    ?.trim()
    ?.split("  ", " ")
    ?.map { it.toInt() }
    ?: throw IllegalStateException("No your numbers found!")

fun calculateNumberOfCards(card: String, acc: IntArray, index: Int): IntArray {
  val numberOfPoints = getNumberOfMatchingNumbers(card)
  val numberOfCards = acc[index]
  repeat(numberOfPoints) { i ->
    acc[index + i + 1] += numberOfCards
  }
  return acc
}

private val winningNumbersRegex = Regex(""": +\d+(?: +\d+)+""")
private val numbersYouHaveRegex = Regex("""\| +\d+(?: +\d+)+""")

private const val inputPath = "src/main/kotlin/pl/klemba/aoc/day4/input.txt"

Compiled from "Main.kt"
public final class pl.klemba.aoc.day4.MainKt {
  private static final kotlin.text.Regex winningNumbersRegex;

  private static final kotlin.text.Regex numbersYouHaveRegex;

  private static final java.lang.String inputPath;

  public static final void main();
    Code:
       0: new           #8                  // class java/io/File
       3: dup
       4: ldc           #10                 // String src/main/kotlin/pl/klemba/aoc/day4/input.txt
       6: invokespecial #14                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #20                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      15: checkcast     #22                 // class java/lang/Iterable
      18: astore_0
      19: iconst_0
      20: istore_1
      21: aload_0
      22: invokeinterface #26,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      27: astore_2
      28: aload_2
      29: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      34: ifeq          72
      37: aload_2
      38: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      43: astore_3
      44: iload_1
      45: aload_3
      46: checkcast     #38                 // class java/lang/String
      49: astore        4
      51: istore        13
      53: iconst_0
      54: istore        5
      56: aload         4
      58: invokestatic  #42                 // Method getNumberOfPointsForCard:(Ljava/lang/String;)I
      61: istore        14
      63: iload         13
      65: iload         14
      67: iadd
      68: istore_1
      69: goto          28
      72: iload_1
      73: istore_1
      74: iconst_0
      75: istore_2
      76: getstatic     #48                 // Field java/lang/System.out:Ljava/io/PrintStream;
      79: iload_1
      80: invokevirtual #54                 // Method java/io/PrintStream.println:(I)V
      83: nop
      84: nop
      85: new           #8                  // class java/io/File
      88: dup
      89: ldc           #10                 // String src/main/kotlin/pl/klemba/aoc/day4/input.txt
      91: invokespecial #14                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      94: aconst_null
      95: iconst_1
      96: aconst_null
      97: invokestatic  #20                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
     100: astore_0
     101: iconst_0
     102: istore_2
     103: aload_0
     104: invokeinterface #60,  1           // InterfaceMethod java/util/List.size:()I
     109: istore_3
     110: iload_3
     111: newarray       int
     113: astore        4
     115: iload_2
     116: iload_3
     117: if_icmpge     135
     120: iload_2
     121: istore        5
     123: aload         4
     125: iload         5
     127: iconst_1
     128: iastore
     129: iinc          2, 1
     132: goto          115
     135: aload         4
     137: astore_1
     138: aload_0
     139: checkcast     #22                 // class java/lang/Iterable
     142: astore_2
     143: nop
     144: iconst_0
     145: istore_3
     146: iconst_0
     147: istore        4
     149: aload_1
     150: astore        5
     152: aload_2
     153: invokeinterface #26,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     158: astore        6
     160: aload         6
     162: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     167: ifeq          226
     170: aload         6
     172: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     177: astore        7
     179: iload         4
     181: iinc          4, 1
     184: istore        8
     186: iload         8
     188: ifge          194
     191: invokestatic  #65                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     194: iload         8
     196: aload         5
     198: aload         7
     200: checkcast     #38                 // class java/lang/String
     203: astore        9
     205: astore        10
     207: istore        11
     209: iconst_0
     210: istore        12
     212: aload         9
     214: aload         10
     216: iload         11
     218: invokestatic  #69                 // Method calculateNumberOfCards:(Ljava/lang/String;[II)[I
     221: astore        5
     223: goto          160
     226: aload         5
     228: invokestatic  #75                 // Method kotlin/collections/ArraysKt.sum:([I)I
     231: istore_3
     232: iconst_0
     233: istore        4
     235: getstatic     #48                 // Field java/lang/System.out:Ljava/io/PrintStream;
     238: iload_3
     239: invokevirtual #54                 // Method java/io/PrintStream.println:(I)V
     242: nop
     243: nop
     244: return

  public static final int getNumberOfPointsForCard(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #99                 // String card
       3: invokestatic  #105                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #108                // Method getNumberOfMatchingNumbers:(Ljava/lang/String;)I
      10: istore_1
      11: iload_1
      12: iconst_1
      13: if_icmpne     20
      16: iconst_1
      17: goto          31
      20: ldc2_w        #109                // double 2.0d
      23: iload_1
      24: iconst_1
      25: isub
      26: i2d
      27: invokestatic  #116                // Method java/lang/Math.pow:(DD)D
      30: d2i
      31: ireturn

  public static final int getNumberOfMatchingNumbers(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #99                 // String card
       3: invokestatic  #105                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #121                // Method getWinningNumbers:(Ljava/lang/String;)Ljava/util/List;
      10: astore_1
      11: aload_0
      12: invokestatic  #124                // Method getNumbersYouHave:(Ljava/lang/String;)Ljava/util/List;
      15: astore_2
      16: aload_1
      17: checkcast     #22                 // class java/lang/Iterable
      20: aload_2
      21: checkcast     #22                 // class java/lang/Iterable
      24: invokestatic  #128                // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
      27: checkcast     #22                 // class java/lang/Iterable
      30: invokestatic  #132                // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
      33: invokeinterface #135,  1          // InterfaceMethod java/util/Set.size:()I
      38: ireturn

  public static final java.util.List<java.lang.Integer> getWinningNumbers(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #99                 // String card
       3: invokestatic  #105                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: getstatic     #142                // Field winningNumbersRegex:Lkotlin/text/Regex;
       9: aload_0
      10: checkcast     #144                // class java/lang/CharSequence
      13: iconst_0
      14: iconst_2
      15: aconst_null
      16: invokestatic  #150                // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;
      19: astore_1
      20: aload_1
      21: ifnull        231
      24: aload_1
      25: invokeinterface #156,  1          // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;
      30: astore_2
      31: aload_2
      32: ifnull        231
      35: aload_2
      36: astore        4
      38: iconst_0
      39: istore        5
      41: iconst_2
      42: istore        6
      44: aload         4
      46: checkcast     #144                // class java/lang/CharSequence
      49: iload         5
      51: iload         6
      53: invokestatic  #162                // Method kotlin/text/StringsKt.removeRange:(Ljava/lang/CharSequence;II)Ljava/lang/CharSequence;
      56: invokevirtual #165                // Method java/lang/Object.toString:()Ljava/lang/String;
      59: astore_3
      60: aload_3
      61: ifnull        231
      64: nop
      65: aload_3
      66: checkcast     #144                // class java/lang/CharSequence
      69: invokestatic  #169                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      72: invokevirtual #165                // Method java/lang/Object.toString:()Ljava/lang/String;
      75: astore        4
      77: aload         4
      79: ifnull        231
      82: aload         4
      84: checkcast     #144                // class java/lang/CharSequence
      87: iconst_2
      88: anewarray     #38                 // class java/lang/String
      91: astore        6
      93: aload         6
      95: iconst_0
      96: ldc           #171                // String
      98: aastore
      99: aload         6
     101: iconst_1
     102: ldc           #173                // String
     104: aastore
     105: aload         6
     107: iconst_0
     108: iconst_0
     109: bipush        6
     111: aconst_null
     112: invokestatic  #177                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     115: astore        5
     117: aload         5
     119: ifnull        231
     122: aload         5
     124: checkcast     #22                 // class java/lang/Iterable
     127: astore        7
     129: nop
     130: iconst_0
     131: istore        8
     133: aload         7
     135: astore        9
     137: new           #179                // class java/util/ArrayList
     140: dup
     141: aload         7
     143: bipush        10
     145: invokestatic  #183                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     148: invokespecial #185                // Method java/util/ArrayList."<init>":(I)V
     151: checkcast     #187                // class java/util/Collection
     154: astore        10
     156: iconst_0
     157: istore        11
     159: aload         9
     161: invokeinterface #26,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     166: astore        12
     168: aload         12
     170: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     175: ifeq          222
     178: aload         12
     180: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     185: astore        13
     187: aload         10
     189: aload         13
     191: checkcast     #38                 // class java/lang/String
     194: astore        14
     196: astore        16
     198: iconst_0
     199: istore        15
     201: aload         14
     203: invokestatic  #192                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     206: nop
     207: invokestatic  #196                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     210: aload         16
     212: swap
     213: invokeinterface #200,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     218: pop
     219: goto          168
     222: aload         10
     224: checkcast     #56                 // class java/util/List
     227: nop
     228: goto          241
     231: new           #202                // class java/lang/IllegalStateException
     234: dup
     235: ldc           #204                // String No winning numbers found!
     237: invokespecial #205                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     240: athrow
     241: areturn

  public static final java.util.List<java.lang.Integer> getNumbersYouHave(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #99                 // String card
       3: invokestatic  #105                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: getstatic     #218                // Field numbersYouHaveRegex:Lkotlin/text/Regex;
       9: aload_0
      10: checkcast     #144                // class java/lang/CharSequence
      13: iconst_0
      14: iconst_2
      15: aconst_null
      16: invokestatic  #150                // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;
      19: astore_1
      20: aload_1
      21: ifnull        231
      24: aload_1
      25: invokeinterface #156,  1          // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;
      30: astore_2
      31: aload_2
      32: ifnull        231
      35: aload_2
      36: astore        4
      38: iconst_0
      39: istore        5
      41: iconst_2
      42: istore        6
      44: aload         4
      46: checkcast     #144                // class java/lang/CharSequence
      49: iload         5
      51: iload         6
      53: invokestatic  #162                // Method kotlin/text/StringsKt.removeRange:(Ljava/lang/CharSequence;II)Ljava/lang/CharSequence;
      56: invokevirtual #165                // Method java/lang/Object.toString:()Ljava/lang/String;
      59: astore_3
      60: aload_3
      61: ifnull        231
      64: nop
      65: aload_3
      66: checkcast     #144                // class java/lang/CharSequence
      69: invokestatic  #169                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      72: invokevirtual #165                // Method java/lang/Object.toString:()Ljava/lang/String;
      75: astore        4
      77: aload         4
      79: ifnull        231
      82: aload         4
      84: checkcast     #144                // class java/lang/CharSequence
      87: iconst_2
      88: anewarray     #38                 // class java/lang/String
      91: astore        6
      93: aload         6
      95: iconst_0
      96: ldc           #171                // String
      98: aastore
      99: aload         6
     101: iconst_1
     102: ldc           #173                // String
     104: aastore
     105: aload         6
     107: iconst_0
     108: iconst_0
     109: bipush        6
     111: aconst_null
     112: invokestatic  #177                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     115: astore        5
     117: aload         5
     119: ifnull        231
     122: aload         5
     124: checkcast     #22                 // class java/lang/Iterable
     127: astore        7
     129: nop
     130: iconst_0
     131: istore        8
     133: aload         7
     135: astore        9
     137: new           #179                // class java/util/ArrayList
     140: dup
     141: aload         7
     143: bipush        10
     145: invokestatic  #183                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     148: invokespecial #185                // Method java/util/ArrayList."<init>":(I)V
     151: checkcast     #187                // class java/util/Collection
     154: astore        10
     156: iconst_0
     157: istore        11
     159: aload         9
     161: invokeinterface #26,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     166: astore        12
     168: aload         12
     170: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     175: ifeq          222
     178: aload         12
     180: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     185: astore        13
     187: aload         10
     189: aload         13
     191: checkcast     #38                 // class java/lang/String
     194: astore        14
     196: astore        16
     198: iconst_0
     199: istore        15
     201: aload         14
     203: invokestatic  #192                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     206: nop
     207: invokestatic  #196                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     210: aload         16
     212: swap
     213: invokeinterface #200,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     218: pop
     219: goto          168
     222: aload         10
     224: checkcast     #56                 // class java/util/List
     227: nop
     228: goto          241
     231: new           #202                // class java/lang/IllegalStateException
     234: dup
     235: ldc           #220                // String No your numbers found!
     237: invokespecial #205                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     240: athrow
     241: areturn

  public static final int[] calculateNumberOfCards(java.lang.String, int[], int);
    Code:
       0: aload_0
       1: ldc           #99                 // String card
       3: invokestatic  #105                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #222                // String acc
       9: invokestatic  #105                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: invokestatic  #108                // Method getNumberOfMatchingNumbers:(Ljava/lang/String;)I
      16: istore_3
      17: aload_1
      18: iload_2
      19: iaload
      20: istore        4
      22: iconst_0
      23: istore        5
      25: iload         5
      27: iload_3
      28: if_icmpge     64
      31: iload         5
      33: istore        6
      35: iconst_0
      36: istore        7
      38: iload_2
      39: iload         6
      41: iadd
      42: iconst_1
      43: iadd
      44: istore        8
      46: aload_1
      47: iload         8
      49: aload_1
      50: iload         8
      52: iaload
      53: iload         4
      55: iadd
      56: iastore
      57: nop
      58: iinc          5, 1
      61: goto          25
      64: aload_1
      65: areturn

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

  static {};
    Code:
       0: new           #146                // class kotlin/text/Regex
       3: dup
       4: ldc           #233                // String : +\\d+(?: +\\d+)+
       6: invokespecial #234                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
       9: putstatic     #142                // Field winningNumbersRegex:Lkotlin/text/Regex;
      12: new           #146                // class kotlin/text/Regex
      15: dup
      16: ldc           #236                // String \\| +\\d+(?: +\\d+)+
      18: invokespecial #234                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      21: putstatic     #218                // Field numbersYouHaveRegex:Lkotlin/text/Regex;
      24: return
}