package days

import java.nio.file.Files
import java.nio.file.Paths

fun createMapOfSizes(shellOuput: String): Map<List<String>, Int> = shellOuput
    .replaceFirst("\$ ", "")
    .split("\n\$ ")
    .map {
        when {
            it.startsWith("cd") -> "cd" to listOf(it.replaceFirst("cd ", ""))
            else -> "ls" to it.replaceFirst("ls\n", "").split("\n")
        }
    }
    .let { it.scan(listOf<String>()) { acc, (command, dirOrStdout) ->
            when(command) {
                "cd" -> when {
                    dirOrStdout.first() == ".." -> acc.dropLast(1)
                    else -> acc + dirOrStdout.first()
                }
                else -> acc
            }
        }.zip(it)
    }
    .filter { (_, command) -> command.first != "cd" }
    .map { (path, command) -> path to command.second }
    .reversed()
    .fold(mutableMapOf()) { map, (path, ls) ->
        map[path] = ls.sumOf {
            when {
                it.startsWith("dir ") -> map[path + it.replace("dir ", "")]!!
                else -> it.split(" ")[0].toInt()
            }
        }
        map
    }

fun day7part1() = createMapOfSizes(Files.readString(Paths.get("input/07.txt")))
    .values
    .filter { it <= 100000 }
    .sum()

fun day7part2() = createMapOfSizes(Files.readString(Paths.get("input/07.txt")))
    .let { it[listOf("/")]!! to it.values  }
    .let { (used, values) -> values.sorted().first { 70000000 - 30000000 - used + it > 0 } }

Compiled from "day07.kt"
public final class days.Day07Kt {
  public static final java.util.Map<java.util.List<java.lang.String>, java.lang.Integer> createMapOfSizes(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #10                 // String shellOuput
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: ldc           #18                 // String $
       9: ldc           #20                 // String
      11: iconst_0
      12: iconst_4
      13: aconst_null
      14: invokestatic  #26                 // Method kotlin/text/StringsKt.replaceFirst$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
      17: checkcast     #28                 // class java/lang/CharSequence
      20: iconst_1
      21: anewarray     #30                 // class java/lang/String
      24: astore_1
      25: aload_1
      26: iconst_0
      27: ldc           #32                 // String \n$
      29: aastore
      30: aload_1
      31: iconst_0
      32: iconst_0
      33: bipush        6
      35: aconst_null
      36: invokestatic  #36                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      39: checkcast     #38                 // class java/lang/Iterable
      42: astore_1
      43: nop
      44: iconst_0
      45: istore_2
      46: aload_1
      47: astore_3
      48: new           #40                 // class java/util/ArrayList
      51: dup
      52: aload_1
      53: bipush        10
      55: invokestatic  #46                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      58: invokespecial #50                 // Method java/util/ArrayList."<init>":(I)V
      61: checkcast     #52                 // class java/util/Collection
      64: astore        4
      66: iconst_0
      67: istore        5
      69: aload_3
      70: invokeinterface #56,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      75: astore        6
      77: aload         6
      79: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      84: ifeq          202
      87: aload         6
      89: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      94: astore        7
      96: aload         4
      98: aload         7
     100: checkcast     #30                 // class java/lang/String
     103: astore        8
     105: astore        22
     107: iconst_0
     108: istore        9
     110: nop
     111: aload         8
     113: ldc           #68                 // String cd
     115: iconst_0
     116: iconst_2
     117: aconst_null
     118: invokestatic  #72                 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
     121: ifeq          147
     124: ldc           #68                 // String cd
     126: aload         8
     128: ldc           #74                 // String cd
     130: ldc           #20                 // String
     132: iconst_0
     133: iconst_4
     134: aconst_null
     135: invokestatic  #26                 // Method kotlin/text/StringsKt.replaceFirst$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
     138: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     141: invokestatic  #84                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     144: goto          189
     147: ldc           #86                 // String ls
     149: aload         8
     151: ldc           #88                 // String ls\n
     153: ldc           #20                 // String
     155: iconst_0
     156: iconst_4
     157: aconst_null
     158: invokestatic  #26                 // Method kotlin/text/StringsKt.replaceFirst$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
     161: checkcast     #28                 // class java/lang/CharSequence
     164: iconst_1
     165: anewarray     #30                 // class java/lang/String
     168: astore        10
     170: aload         10
     172: iconst_0
     173: ldc           #90                 // String \n
     175: aastore
     176: aload         10
     178: iconst_0
     179: iconst_0
     180: bipush        6
     182: aconst_null
     183: invokestatic  #36                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     186: invokestatic  #84                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     189: nop
     190: aload         22
     192: swap
     193: invokeinterface #94,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     198: pop
     199: goto          77
     202: aload         4
     204: checkcast     #96                 // class java/util/List
     207: nop
     208: astore_2
     209: iconst_0
     210: istore_3
     211: aload_2
     212: checkcast     #38                 // class java/lang/Iterable
     215: astore        4
     217: invokestatic  #100                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     220: astore        5
     222: nop
     223: iconst_0
     224: istore        6
     226: aload         4
     228: astore        7
     230: iconst_0
     231: istore        8
     233: aload         7
     235: bipush        9
     237: invokestatic  #46                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     240: istore        9
     242: iload         9
     244: ifne          255
     247: aload         5
     249: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     252: goto          422
     255: new           #40                 // class java/util/ArrayList
     258: dup
     259: iload         9
     261: iconst_1
     262: iadd
     263: invokespecial #50                 // Method java/util/ArrayList."<init>":(I)V
     266: astore        10
     268: aload         10
     270: astore        11
     272: iconst_0
     273: istore        12
     275: aload         11
     277: aload         5
     279: invokevirtual #101                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     282: pop
     283: aload         10
     285: astore        13
     287: aload         5
     289: astore        10
     291: aload         7
     293: invokeinterface #56,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     298: astore        11
     300: aload         11
     302: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     307: ifeq          417
     310: aload         11
     312: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     317: astore        12
     319: aload         10
     321: aload         12
     323: checkcast     #103                // class kotlin/Pair
     326: astore        14
     328: astore        15
     330: iconst_0
     331: istore        16
     333: aload         14
     335: invokevirtual #106                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     338: checkcast     #30                 // class java/lang/String
     341: astore        17
     343: aload         14
     345: invokevirtual #109                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     348: checkcast     #96                 // class java/util/List
     351: astore        18
     353: aload         17
     355: ldc           #68                 // String cd
     357: invokestatic  #113                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     360: ifeq          401
     363: aload         18
     365: invokestatic  #117                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     368: ldc           #119                // String ..
     370: invokestatic  #113                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     373: ifeq          385
     376: aload         15
     378: iconst_1
     379: invokestatic  #123                // Method kotlin/collections/CollectionsKt.dropLast:(Ljava/util/List;I)Ljava/util/List;
     382: goto          403
     385: aload         15
     387: checkcast     #52                 // class java/util/Collection
     390: aload         18
     392: invokestatic  #117                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     395: invokestatic  #127                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     398: goto          403
     401: aload         15
     403: nop
     404: astore        10
     406: aload         13
     408: aload         10
     410: invokevirtual #101                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     413: pop
     414: goto          300
     417: aload         13
     419: checkcast     #96                 // class java/util/List
     422: nop
     423: checkcast     #38                 // class java/lang/Iterable
     426: aload_2
     427: checkcast     #38                 // class java/lang/Iterable
     430: invokestatic  #131                // Method kotlin/collections/CollectionsKt.zip:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;
     433: checkcast     #38                 // class java/lang/Iterable
     436: astore_1
     437: nop
     438: iconst_0
     439: istore_2
     440: aload_1
     441: astore_3
     442: new           #40                 // class java/util/ArrayList
     445: dup
     446: invokespecial #134                // Method java/util/ArrayList."<init>":()V
     449: checkcast     #52                 // class java/util/Collection
     452: astore        4
     454: iconst_0
     455: istore        5
     457: aload_3
     458: invokeinterface #56,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     463: astore        6
     465: aload         6
     467: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     472: ifeq          538
     475: aload         6
     477: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     482: astore        7
     484: aload         7
     486: checkcast     #103                // class kotlin/Pair
     489: astore        8
     491: iconst_0
     492: istore        9
     494: aload         8
     496: invokevirtual #109                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     499: checkcast     #103                // class kotlin/Pair
     502: astore        10
     504: aload         10
     506: invokevirtual #137                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     509: ldc           #68                 // String cd
     511: invokestatic  #113                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     514: ifne          521
     517: iconst_1
     518: goto          522
     521: iconst_0
     522: ifeq          465
     525: aload         4
     527: aload         7
     529: invokeinterface #94,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     534: pop
     535: goto          465
     538: aload         4
     540: checkcast     #96                 // class java/util/List
     543: nop
     544: checkcast     #38                 // class java/lang/Iterable
     547: astore_1
     548: nop
     549: iconst_0
     550: istore_2
     551: aload_1
     552: astore_3
     553: new           #40                 // class java/util/ArrayList
     556: dup
     557: aload_1
     558: bipush        10
     560: invokestatic  #46                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     563: invokespecial #50                 // Method java/util/ArrayList."<init>":(I)V
     566: checkcast     #52                 // class java/util/Collection
     569: astore        4
     571: iconst_0
     572: istore        5
     574: aload_3
     575: invokeinterface #56,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     580: astore        6
     582: aload         6
     584: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     589: ifeq          657
     592: aload         6
     594: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     599: astore        7
     601: aload         4
     603: aload         7
     605: checkcast     #103                // class kotlin/Pair
     608: astore        8
     610: astore        22
     612: iconst_0
     613: istore        9
     615: aload         8
     617: invokevirtual #106                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     620: checkcast     #96                 // class java/util/List
     623: astore        10
     625: aload         8
     627: invokevirtual #109                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     630: checkcast     #103                // class kotlin/Pair
     633: astore        11
     635: aload         10
     637: aload         11
     639: invokevirtual #140                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     642: invokestatic  #84                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     645: aload         22
     647: swap
     648: invokeinterface #94,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     653: pop
     654: goto          582
     657: aload         4
     659: checkcast     #96                 // class java/util/List
     662: nop
     663: checkcast     #38                 // class java/lang/Iterable
     666: invokestatic  #144                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
     669: checkcast     #38                 // class java/lang/Iterable
     672: astore_1
     673: new           #146                // class java/util/LinkedHashMap
     676: dup
     677: invokespecial #147                // Method java/util/LinkedHashMap."<init>":()V
     680: checkcast     #149                // class java/util/Map
     683: astore_2
     684: nop
     685: iconst_0
     686: istore_3
     687: aload_2
     688: astore        4
     690: aload_1
     691: invokeinterface #56,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     696: astore        5
     698: aload         5
     700: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     705: ifeq          939
     708: aload         5
     710: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     715: astore        6
     717: aload         4
     719: aload         6
     721: checkcast     #103                // class kotlin/Pair
     724: astore        7
     726: astore        8
     728: iconst_0
     729: istore        9
     731: aload         7
     733: invokevirtual #106                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     736: checkcast     #96                 // class java/util/List
     739: astore        10
     741: aload         7
     743: invokevirtual #109                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     746: checkcast     #96                 // class java/util/List
     749: astore        11
     751: aload         8
     753: astore        12
     755: aload         11
     757: checkcast     #38                 // class java/lang/Iterable
     760: astore        13
     762: iconst_0
     763: istore        14
     765: aload         13
     767: invokeinterface #56,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     772: astore        15
     774: aload         15
     776: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     781: ifeq          913
     784: aload         15
     786: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     791: astore        16
     793: iload         14
     795: aload         16
     797: checkcast     #30                 // class java/lang/String
     800: astore        17
     802: istore        18
     804: iconst_0
     805: istore        19
     807: nop
     808: aload         17
     810: ldc           #151                // String dir
     812: iconst_0
     813: iconst_2
     814: aconst_null
     815: invokestatic  #72                 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
     818: ifeq          861
     821: aload         8
     823: aload         10
     825: checkcast     #52                 // class java/util/Collection
     828: aload         17
     830: ldc           #151                // String dir
     832: ldc           #20                 // String
     834: iconst_0
     835: iconst_4
     836: aconst_null
     837: invokestatic  #154                // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
     840: invokestatic  #127                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     843: invokeinterface #158,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     848: dup
     849: invokestatic  #162                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     852: checkcast     #164                // class java/lang/Number
     855: invokevirtual #168                // Method java/lang/Number.intValue:()I
     858: goto          900
     861: aload         17
     863: checkcast     #28                 // class java/lang/CharSequence
     866: iconst_1
     867: anewarray     #30                 // class java/lang/String
     870: astore        20
     872: aload         20
     874: iconst_0
     875: ldc           #170                // String
     877: aastore
     878: aload         20
     880: iconst_0
     881: iconst_0
     882: bipush        6
     884: aconst_null
     885: invokestatic  #36                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     888: iconst_0
     889: invokeinterface #173,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     894: checkcast     #30                 // class java/lang/String
     897: invokestatic  #179                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     900: nop
     901: istore        21
     903: iload         18
     905: iload         21
     907: iadd
     908: istore        14
     910: goto          774
     913: iload         14
     915: invokestatic  #183                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     918: astore        13
     920: aload         12
     922: aload         10
     924: aload         13
     926: invokeinterface #187,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     931: pop
     932: aload         8
     934: astore        4
     936: goto          698
     939: aload         4
     941: areturn

  public static final int day7part1();
    Code:
       0: ldc           #237                // String input/07.txt
       2: iconst_0
       3: anewarray     #30                 // class java/lang/String
       6: invokestatic  #242                // Method java/nio/file/Paths.get:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;
       9: invokestatic  #248                // Method java/nio/file/Files.readString:(Ljava/nio/file/Path;)Ljava/lang/String;
      12: dup
      13: ldc           #250                // String readString(...)
      15: invokestatic  #253                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      18: invokestatic  #255                // Method createMapOfSizes:(Ljava/lang/String;)Ljava/util/Map;
      21: invokeinterface #259,  1          // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
      26: checkcast     #38                 // class java/lang/Iterable
      29: astore_0
      30: nop
      31: iconst_0
      32: istore_1
      33: aload_0
      34: astore_2
      35: new           #40                 // class java/util/ArrayList
      38: dup
      39: invokespecial #134                // Method java/util/ArrayList."<init>":()V
      42: checkcast     #52                 // class java/util/Collection
      45: astore_3
      46: iconst_0
      47: istore        4
      49: aload_2
      50: invokeinterface #56,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      55: astore        5
      57: aload         5
      59: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      64: ifeq          117
      67: aload         5
      69: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      74: astore        6
      76: aload         6
      78: checkcast     #164                // class java/lang/Number
      81: invokevirtual #168                // Method java/lang/Number.intValue:()I
      84: istore        7
      86: iconst_0
      87: istore        8
      89: iload         7
      91: ldc_w         #260                // int 100000
      94: if_icmpgt     101
      97: iconst_1
      98: goto          102
     101: iconst_0
     102: ifeq          57
     105: aload_3
     106: aload         6
     108: invokeinterface #94,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     113: pop
     114: goto          57
     117: aload_3
     118: checkcast     #96                 // class java/util/List
     121: nop
     122: checkcast     #38                 // class java/lang/Iterable
     125: invokestatic  #264                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     128: ireturn

  public static final int day7part2();
    Code:
       0: ldc           #237                // String input/07.txt
       2: iconst_0
       3: anewarray     #30                 // class java/lang/String
       6: invokestatic  #242                // Method java/nio/file/Paths.get:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;
       9: invokestatic  #248                // Method java/nio/file/Files.readString:(Ljava/nio/file/Path;)Ljava/lang/String;
      12: dup
      13: ldc           #250                // String readString(...)
      15: invokestatic  #253                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      18: invokestatic  #255                // Method createMapOfSizes:(Ljava/lang/String;)Ljava/util/Map;
      21: astore_0
      22: iconst_0
      23: istore_1
      24: aload_0
      25: ldc_w         #268                // String /
      28: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      31: invokeinterface #158,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      36: dup
      37: invokestatic  #162                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      40: aload_0
      41: invokeinterface #259,  1          // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
      46: invokestatic  #84                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      49: nop
      50: astore_0
      51: iconst_0
      52: istore_1
      53: aload_0
      54: invokevirtual #106                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      57: checkcast     #164                // class java/lang/Number
      60: invokevirtual #168                // Method java/lang/Number.intValue:()I
      63: istore_2
      64: aload_0
      65: invokevirtual #109                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      68: checkcast     #52                 // class java/util/Collection
      71: astore_3
      72: aload_3
      73: checkcast     #38                 // class java/lang/Iterable
      76: invokestatic  #271                // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
      79: checkcast     #38                 // class java/lang/Iterable
      82: astore        4
      84: iconst_0
      85: istore        5
      87: aload         4
      89: invokeinterface #56,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      94: astore        6
      96: aload         6
      98: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     103: ifeq          152
     106: aload         6
     108: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     113: astore        7
     115: aload         7
     117: checkcast     #164                // class java/lang/Number
     120: invokevirtual #168                // Method java/lang/Number.intValue:()I
     123: istore        8
     125: iconst_0
     126: istore        9
     128: ldc_w         #272                // int 40000000
     131: iload_2
     132: isub
     133: iload         8
     135: iadd
     136: ifle          143
     139: iconst_1
     140: goto          144
     143: iconst_0
     144: ifeq          96
     147: aload         7
     149: goto          163
     152: new           #274                // class java/util/NoSuchElementException
     155: dup
     156: ldc_w         #276                // String Collection contains no element matching the predicate.
     159: invokespecial #279                // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
     162: athrow
     163: checkcast     #164                // class java/lang/Number
     166: invokevirtual #168                // Method java/lang/Number.intValue:()I
     169: nop
     170: nop
     171: ireturn
}


package days

import java.nio.file.Files
import java.nio.file.Paths
import kotlin.streams.asSequence

sealed interface Option
object Rock : Option
object Paper : Option
object Scissors : Option

fun String.parseOption() = when (this) {
    "A", "X" -> Rock
    "B", "Y" -> Paper
    "C", "Z" -> Scissors
    else -> throw IllegalArgumentException(this)
}

fun Pair<Option, Option>.matchPoints() = when(this) {
    Pair(Scissors, Rock), Pair(Rock, Paper), Pair(Paper, Scissors) -> 6
    else -> when (this.first) {
        this.second -> 3
        else -> 0
    }
}

fun Option.selectionPoints() = when(this) {
    Rock -> 1
    Paper -> 2
    Scissors -> 3
}

fun day2Part1() = Files.lines(Paths.get("input/02.txt")).asSequence()
    .map { it.split(" ") }
    .map { it[0].parseOption() to it[1].parseOption() }
    .map { it.matchPoints() + it.second.selectionPoints() }
    .sum()

sealed interface Result
object Win: Result
object Draw: Result
object Lose: Result

fun String.parseResult() = when (this) {
    "X" -> Lose
    "Y" -> Draw
    "Z" -> Win
    else -> throw IllegalArgumentException(this)
}

fun neededFor(result: Result, option: Option) = when (result) {
    Lose -> when (option) {
        Rock -> Scissors
        Paper -> Rock
        Scissors -> Paper
    }
    Draw -> option
    Win -> when (option) {
        Rock -> Paper
        Paper -> Scissors
        Scissors -> Rock
    }
}

fun day2part2() = Files.lines(Paths.get("input/02.txt")).asSequence()
    .map { it.split(" ") }
    .map { it[0].parseOption() to it[1].parseResult() }
    .map { (option, result) -> option to neededFor(result, option) }
    .map { it.matchPoints() + it.second.selectionPoints() }
    .sum()

Compiled from "day02.kt"
public final class days.Day02Kt {
  public static final days.Option parseOption(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #9                  // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: astore_1
       8: aload_1
       9: invokevirtual #21                 // Method java/lang/String.hashCode:()I
      12: lookupswitch  { // 6
                    65: 72
                    66: 84
                    67: 96
                    88: 108
                    89: 120
                    90: 132
               default: 171
          }
      72: aload_1
      73: ldc           #23                 // String A
      75: invokevirtual #27                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      78: ifne          144
      81: goto          171
      84: aload_1
      85: ldc           #29                 // String B
      87: invokevirtual #27                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      90: ifne          153
      93: goto          171
      96: aload_1
      97: ldc           #31                 // String C
      99: invokevirtual #27                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     102: ifne          162
     105: goto          171
     108: aload_1
     109: ldc           #33                 // String X
     111: invokevirtual #27                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     114: ifne          144
     117: goto          171
     120: aload_1
     121: ldc           #35                 // String Y
     123: invokevirtual #27                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     126: ifne          153
     129: goto          171
     132: aload_1
     133: ldc           #37                 // String Z
     135: invokevirtual #27                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     138: ifne          162
     141: goto          171
     144: getstatic     #43                 // Field days/Rock.INSTANCE:Ldays/Rock;
     147: checkcast     #45                 // class days/Option
     150: goto          180
     153: getstatic     #50                 // Field days/Paper.INSTANCE:Ldays/Paper;
     156: checkcast     #45                 // class days/Option
     159: goto          180
     162: getstatic     #55                 // Field days/Scissors.INSTANCE:Ldays/Scissors;
     165: checkcast     #45                 // class days/Option
     168: goto          180
     171: new           #57                 // class java/lang/IllegalArgumentException
     174: dup
     175: aload_0
     176: invokespecial #61                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     179: athrow
     180: areturn

  public static final int matchPoints(kotlin.Pair<? extends days.Option, ? extends days.Option>);
    Code:
       0: aload_0
       1: ldc           #9                  // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: astore_1
       8: aload_1
       9: new           #68                 // class kotlin/Pair
      12: dup
      13: getstatic     #55                 // Field days/Scissors.INSTANCE:Ldays/Scissors;
      16: getstatic     #43                 // Field days/Rock.INSTANCE:Ldays/Rock;
      19: invokespecial #71                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      22: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      25: ifne          68
      28: aload_1
      29: new           #68                 // class kotlin/Pair
      32: dup
      33: getstatic     #43                 // Field days/Rock.INSTANCE:Ldays/Rock;
      36: getstatic     #50                 // Field days/Paper.INSTANCE:Ldays/Paper;
      39: invokespecial #71                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      42: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      45: ifne          68
      48: aload_1
      49: new           #68                 // class kotlin/Pair
      52: dup
      53: getstatic     #50                 // Field days/Paper.INSTANCE:Ldays/Paper;
      56: getstatic     #55                 // Field days/Scissors.INSTANCE:Ldays/Scissors;
      59: invokespecial #71                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      62: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      65: ifeq          73
      68: bipush        6
      70: goto          95
      73: aload_0
      74: invokevirtual #79                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      77: checkcast     #45                 // class days/Option
      80: aload_0
      81: invokevirtual #82                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      84: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      87: ifeq          94
      90: iconst_3
      91: goto          95
      94: iconst_0
      95: ireturn

  public static final int selectionPoints(days.Option);
    Code:
       0: aload_0
       1: ldc           #9                  // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: astore_1
       8: aload_1
       9: getstatic     #43                 // Field days/Rock.INSTANCE:Ldays/Rock;
      12: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      15: ifeq          22
      18: iconst_1
      19: goto          58
      22: aload_1
      23: getstatic     #50                 // Field days/Paper.INSTANCE:Ldays/Paper;
      26: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      29: ifeq          36
      32: iconst_2
      33: goto          58
      36: aload_1
      37: getstatic     #55                 // Field days/Scissors.INSTANCE:Ldays/Scissors;
      40: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      43: ifeq          50
      46: iconst_3
      47: goto          58
      50: new           #88                 // class kotlin/NoWhenBranchMatchedException
      53: dup
      54: invokespecial #91                 // Method kotlin/NoWhenBranchMatchedException."<init>":()V
      57: athrow
      58: ireturn

  public static final int day2Part1();
    Code:
       0: ldc           #96                 // String input/02.txt
       2: iconst_0
       3: anewarray     #17                 // class java/lang/String
       6: invokestatic  #102                // Method java/nio/file/Paths.get:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;
       9: invokestatic  #108                // Method java/nio/file/Files.lines:(Ljava/nio/file/Path;)Ljava/util/stream/Stream;
      12: dup
      13: ldc           #110                // String lines(...)
      15: invokestatic  #113                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      18: invokestatic  #119                // Method kotlin/streams/jdk8/StreamsKt.asSequence:(Ljava/util/stream/Stream;)Lkotlin/sequences/Sequence;
      21: invokedynamic #138,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      26: invokestatic  #144                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      29: invokedynamic #151,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
      34: invokestatic  #144                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      37: invokedynamic #158,  0            // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;
      42: invokestatic  #144                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      45: invokestatic  #162                // Method kotlin/sequences/SequencesKt.sumOfInt:(Lkotlin/sequences/Sequence;)I
      48: ireturn

  public static final days.Result parseResult(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #9                  // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: astore_1
       8: aload_1
       9: invokevirtual #21                 // Method java/lang/String.hashCode:()I
      12: tableswitch   { // 88 to 90
                    88: 40
                    89: 52
                    90: 64
               default: 103
          }
      40: aload_1
      41: ldc           #33                 // String X
      43: invokevirtual #27                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      46: ifne          76
      49: goto          103
      52: aload_1
      53: ldc           #35                 // String Y
      55: invokevirtual #27                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      58: ifne          85
      61: goto          103
      64: aload_1
      65: ldc           #37                 // String Z
      67: invokevirtual #27                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      70: ifne          94
      73: goto          103
      76: getstatic     #169                // Field days/Lose.INSTANCE:Ldays/Lose;
      79: checkcast     #171                // class days/Result
      82: goto          112
      85: getstatic     #176                // Field days/Draw.INSTANCE:Ldays/Draw;
      88: checkcast     #171                // class days/Result
      91: goto          112
      94: getstatic     #181                // Field days/Win.INSTANCE:Ldays/Win;
      97: checkcast     #171                // class days/Result
     100: goto          112
     103: new           #57                 // class java/lang/IllegalArgumentException
     106: dup
     107: aload_0
     108: invokespecial #61                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     111: athrow
     112: areturn

  public static final days.Option neededFor(days.Result, days.Option);
    Code:
       0: aload_0
       1: ldc           #186                // String result
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #188                // String option
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: astore_2
      14: aload_2
      15: getstatic     #169                // Field days/Lose.INSTANCE:Ldays/Lose;
      18: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      21: ifeq          91
      24: aload_1
      25: astore_3
      26: aload_3
      27: getstatic     #43                 // Field days/Rock.INSTANCE:Ldays/Rock;
      30: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      33: ifeq          45
      36: getstatic     #55                 // Field days/Scissors.INSTANCE:Ldays/Scissors;
      39: checkcast     #45                 // class days/Option
      42: goto          190
      45: aload_3
      46: getstatic     #50                 // Field days/Paper.INSTANCE:Ldays/Paper;
      49: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      52: ifeq          64
      55: getstatic     #43                 // Field days/Rock.INSTANCE:Ldays/Rock;
      58: checkcast     #45                 // class days/Option
      61: goto          190
      64: aload_3
      65: getstatic     #55                 // Field days/Scissors.INSTANCE:Ldays/Scissors;
      68: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      71: ifeq          83
      74: getstatic     #50                 // Field days/Paper.INSTANCE:Ldays/Paper;
      77: checkcast     #45                 // class days/Option
      80: goto          190
      83: new           #88                 // class kotlin/NoWhenBranchMatchedException
      86: dup
      87: invokespecial #91                 // Method kotlin/NoWhenBranchMatchedException."<init>":()V
      90: athrow
      91: aload_2
      92: getstatic     #176                // Field days/Draw.INSTANCE:Ldays/Draw;
      95: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      98: ifeq          105
     101: aload_1
     102: goto          190
     105: aload_2
     106: getstatic     #181                // Field days/Win.INSTANCE:Ldays/Win;
     109: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     112: ifeq          182
     115: aload_1
     116: astore_3
     117: aload_3
     118: getstatic     #43                 // Field days/Rock.INSTANCE:Ldays/Rock;
     121: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     124: ifeq          136
     127: getstatic     #50                 // Field days/Paper.INSTANCE:Ldays/Paper;
     130: checkcast     #45                 // class days/Option
     133: goto          190
     136: aload_3
     137: getstatic     #50                 // Field days/Paper.INSTANCE:Ldays/Paper;
     140: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     143: ifeq          155
     146: getstatic     #55                 // Field days/Scissors.INSTANCE:Ldays/Scissors;
     149: checkcast     #45                 // class days/Option
     152: goto          190
     155: aload_3
     156: getstatic     #55                 // Field days/Scissors.INSTANCE:Ldays/Scissors;
     159: invokestatic  #75                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     162: ifeq          174
     165: getstatic     #43                 // Field days/Rock.INSTANCE:Ldays/Rock;
     168: checkcast     #45                 // class days/Option
     171: goto          190
     174: new           #88                 // class kotlin/NoWhenBranchMatchedException
     177: dup
     178: invokespecial #91                 // Method kotlin/NoWhenBranchMatchedException."<init>":()V
     181: athrow
     182: new           #88                 // class kotlin/NoWhenBranchMatchedException
     185: dup
     186: invokespecial #91                 // Method kotlin/NoWhenBranchMatchedException."<init>":()V
     189: athrow
     190: areturn

  public static final int day2part2();
    Code:
       0: ldc           #96                 // String input/02.txt
       2: iconst_0
       3: anewarray     #17                 // class java/lang/String
       6: invokestatic  #102                // Method java/nio/file/Paths.get:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;
       9: invokestatic  #108                // Method java/nio/file/Files.lines:(Ljava/nio/file/Path;)Ljava/util/stream/Stream;
      12: dup
      13: ldc           #110                // String lines(...)
      15: invokestatic  #113                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      18: invokestatic  #119                // Method kotlin/streams/jdk8/StreamsKt.asSequence:(Ljava/util/stream/Stream;)Lkotlin/sequences/Sequence;
      21: invokedynamic #195,  0            // InvokeDynamic #3:invoke:()Lkotlin/jvm/functions/Function1;
      26: invokestatic  #144                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      29: invokedynamic #200,  0            // InvokeDynamic #4:invoke:()Lkotlin/jvm/functions/Function1;
      34: invokestatic  #144                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      37: invokedynamic #207,  0            // InvokeDynamic #5:invoke:()Lkotlin/jvm/functions/Function1;
      42: invokestatic  #144                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      45: invokedynamic #212,  0            // InvokeDynamic #6:invoke:()Lkotlin/jvm/functions/Function1;
      50: invokestatic  #144                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      53: invokestatic  #162                // Method kotlin/sequences/SequencesKt.sumOfInt:(Lkotlin/sequences/Sequence;)I
      56: ireturn

  private static final java.util.List day2Part1$lambda$0(java.lang.String);
    Code:
       0: aload_0
       1: invokestatic  #216                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       4: aload_0
       5: checkcast     #218                // class java/lang/CharSequence
       8: iconst_1
       9: anewarray     #17                 // class java/lang/String
      12: astore_1
      13: aload_1
      14: iconst_0
      15: ldc           #220                // String
      17: aastore
      18: aload_1
      19: iconst_0
      20: iconst_0
      21: bipush        6
      23: aconst_null
      24: invokestatic  #226                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      27: areturn

  private static final kotlin.Pair day2Part1$lambda$1(java.util.List);
    Code:
       0: aload_0
       1: ldc           #228                // String it
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iconst_0
       8: invokeinterface #233,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      13: checkcast     #17                 // class java/lang/String
      16: invokestatic  #235                // Method parseOption:(Ljava/lang/String;)Ldays/Option;
      19: aload_0
      20: iconst_1
      21: invokeinterface #233,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      26: checkcast     #17                 // class java/lang/String
      29: invokestatic  #235                // Method parseOption:(Ljava/lang/String;)Ldays/Option;
      32: invokestatic  #241                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      35: areturn

  private static final int day2Part1$lambda$2(kotlin.Pair);
    Code:
       0: aload_0
       1: ldc           #228                // String it
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #244                // Method matchPoints:(Lkotlin/Pair;)I
      10: aload_0
      11: invokevirtual #82                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      14: checkcast     #45                 // class days/Option
      17: invokestatic  #246                // Method selectionPoints:(Ldays/Option;)I
      20: iadd
      21: ireturn

  private static final java.util.List day2part2$lambda$3(java.lang.String);
    Code:
       0: aload_0
       1: invokestatic  #216                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       4: aload_0
       5: checkcast     #218                // class java/lang/CharSequence
       8: iconst_1
       9: anewarray     #17                 // class java/lang/String
      12: astore_1
      13: aload_1
      14: iconst_0
      15: ldc           #220                // String
      17: aastore
      18: aload_1
      19: iconst_0
      20: iconst_0
      21: bipush        6
      23: aconst_null
      24: invokestatic  #226                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      27: areturn

  private static final kotlin.Pair day2part2$lambda$4(java.util.List);
    Code:
       0: aload_0
       1: ldc           #228                // String it
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iconst_0
       8: invokeinterface #233,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      13: checkcast     #17                 // class java/lang/String
      16: invokestatic  #235                // Method parseOption:(Ljava/lang/String;)Ldays/Option;
      19: aload_0
      20: iconst_1
      21: invokeinterface #233,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      26: checkcast     #17                 // class java/lang/String
      29: invokestatic  #248                // Method parseResult:(Ljava/lang/String;)Ldays/Result;
      32: invokestatic  #241                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      35: areturn

  private static final kotlin.Pair day2part2$lambda$5(kotlin.Pair);
    Code:
       0: aload_0
       1: ldc           #250                // String <destruct>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #253                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      10: checkcast     #45                 // class days/Option
      13: astore_1
      14: aload_0
      15: invokevirtual #256                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      18: checkcast     #171                // class days/Result
      21: astore_2
      22: aload_1
      23: aload_2
      24: aload_1
      25: invokestatic  #258                // Method neededFor:(Ldays/Result;Ldays/Option;)Ldays/Option;
      28: invokestatic  #241                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      31: areturn

  private static final int day2part2$lambda$6(kotlin.Pair);
    Code:
       0: aload_0
       1: ldc           #228                // String it
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #244                // Method matchPoints:(Lkotlin/Pair;)I
      10: aload_0
      11: invokevirtual #82                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      14: checkcast     #45                 // class days/Option
      17: invokestatic  #246                // Method selectionPoints:(Ldays/Option;)I
      20: iadd
      21: ireturn
}


package days

import java.io.File
import kotlin.math.abs
import kotlin.math.max

fun Pair<Int, Int>.moveHead(cmd: Char) = when (cmd) {
    'U' -> this.first to this.second + 1
    'R' -> this.first + 1 to this.second
    'D' -> this.first to this.second - 1
    'L' -> this.first - 1 to this.second
    else -> throw IllegalArgumentException()
}

fun Pair<Int, Int>.moveTail(head: Pair<Int, Int>) = when {
    this.isTouching(head) -> this
    this.second == head.second -> when {
        head.first < this.first -> this.first - 1 to this.second
        else -> this.first + 1 to this.second
    }
    this.first == head.first -> when {
        head.second < this.second -> this.first to this.second - 1
        else -> this.first to this.second + 1
    }
    else -> when {
        head.second < this.second -> when {
            head.first < this.first -> this.first - 1 to this.second - 1
            else -> this.first + 1 to this.second - 1
        }
        else -> when {
            head.first < this.first -> this.first - 1 to this.second + 1
            else -> this.first + 1 to this.second + 1
        }
    }
}

fun Pair<Int, Int>.isTouching(point: Pair<Int, Int>) = max(abs(point.first - this.first), abs(point.second - this.second)) <= 1

fun tailPositions(commands: List<String>, knotsSize: Int) = commands
    .map { it.split(" ") }
    .map { it[0].repeat(it[1].toInt()) }
    .flatMap { it.toList() }
    .scan(List(knotsSize) { 0 to 0 }) { knots, cmd ->
        knots.drop(1).fold(listOf(knots.first().moveHead(cmd))) { acc, knot ->
            acc + knot.moveTail(acc.last())
        }
    }
    .map { it.last() }
    .toSet()
    .size

fun day9part1() = tailPositions(File("input/09.txt").readLines(), 2)

fun day9part2() = tailPositions(File("input/09.txt").readLines(), 10)

Compiled from "day09.kt"
public final class days.Day09Kt {
  public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> moveHead(kotlin.Pair<java.lang.Integer, java.lang.Integer>, char);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iload_1
       7: lookupswitch  { // 4
                    68: 98
                    76: 123
                    82: 73
                    85: 48
               default: 148
          }
      48: aload_0
      49: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      52: aload_0
      53: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      56: checkcast     #27                 // class java/lang/Number
      59: invokevirtual #31                 // Method java/lang/Number.intValue:()I
      62: iconst_1
      63: iadd
      64: invokestatic  #37                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      67: invokestatic  #43                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      70: goto          156
      73: aload_0
      74: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      77: checkcast     #27                 // class java/lang/Number
      80: invokevirtual #31                 // Method java/lang/Number.intValue:()I
      83: iconst_1
      84: iadd
      85: invokestatic  #37                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      88: aload_0
      89: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      92: invokestatic  #43                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      95: goto          156
      98: aload_0
      99: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     102: aload_0
     103: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     106: checkcast     #27                 // class java/lang/Number
     109: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     112: iconst_1
     113: isub
     114: invokestatic  #37                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     117: invokestatic  #43                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     120: goto          156
     123: aload_0
     124: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     127: checkcast     #27                 // class java/lang/Number
     130: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     133: iconst_1
     134: isub
     135: invokestatic  #37                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     138: aload_0
     139: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     142: invokestatic  #43                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     145: goto          156
     148: new           #45                 // class java/lang/IllegalArgumentException
     151: dup
     152: invokespecial #49                 // Method java/lang/IllegalArgumentException."<init>":()V
     155: athrow
     156: areturn

  public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> moveTail(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #58                 // String head
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: nop
      13: aload_0
      14: aload_1
      15: invokestatic  #62                 // Method isTouching:(Lkotlin/Pair;Lkotlin/Pair;)Z
      18: ifeq          25
      21: aload_0
      22: goto          429
      25: aload_0
      26: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      29: checkcast     #27                 // class java/lang/Number
      32: invokevirtual #31                 // Method java/lang/Number.intValue:()I
      35: aload_1
      36: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      39: checkcast     #27                 // class java/lang/Number
      42: invokevirtual #31                 // Method java/lang/Number.intValue:()I
      45: if_icmpne     121
      48: aload_1
      49: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      52: checkcast     #27                 // class java/lang/Number
      55: invokevirtual #31                 // Method java/lang/Number.intValue:()I
      58: aload_0
      59: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      62: checkcast     #27                 // class java/lang/Number
      65: invokevirtual #31                 // Method java/lang/Number.intValue:()I
      68: if_icmpge     96
      71: aload_0
      72: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      75: checkcast     #27                 // class java/lang/Number
      78: invokevirtual #31                 // Method java/lang/Number.intValue:()I
      81: iconst_1
      82: isub
      83: invokestatic  #37                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      86: aload_0
      87: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      90: invokestatic  #43                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      93: goto          429
      96: aload_0
      97: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     100: checkcast     #27                 // class java/lang/Number
     103: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     106: iconst_1
     107: iadd
     108: invokestatic  #37                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     111: aload_0
     112: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     115: invokestatic  #43                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     118: goto          429
     121: aload_0
     122: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     125: checkcast     #27                 // class java/lang/Number
     128: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     131: aload_1
     132: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     135: checkcast     #27                 // class java/lang/Number
     138: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     141: if_icmpne     217
     144: aload_1
     145: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     148: checkcast     #27                 // class java/lang/Number
     151: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     154: aload_0
     155: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     158: checkcast     #27                 // class java/lang/Number
     161: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     164: if_icmpge     192
     167: aload_0
     168: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     171: aload_0
     172: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     175: checkcast     #27                 // class java/lang/Number
     178: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     181: iconst_1
     182: isub
     183: invokestatic  #37                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     186: invokestatic  #43                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     189: goto          429
     192: aload_0
     193: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     196: aload_0
     197: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     200: checkcast     #27                 // class java/lang/Number
     203: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     206: iconst_1
     207: iadd
     208: invokestatic  #37                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     211: invokestatic  #43                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     214: goto          429
     217: nop
     218: aload_1
     219: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     222: checkcast     #27                 // class java/lang/Number
     225: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     228: aload_0
     229: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     232: checkcast     #27                 // class java/lang/Number
     235: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     238: if_icmpge     336
     241: aload_1
     242: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     245: checkcast     #27                 // class java/lang/Number
     248: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     251: aload_0
     252: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     255: checkcast     #27                 // class java/lang/Number
     258: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     261: if_icmpge     300
     264: aload_0
     265: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     268: checkcast     #27                 // class java/lang/Number
     271: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     274: iconst_1
     275: isub
     276: invokestatic  #37                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     279: aload_0
     280: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     283: checkcast     #27                 // class java/lang/Number
     286: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     289: iconst_1
     290: isub
     291: invokestatic  #37                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     294: invokestatic  #43                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     297: goto          429
     300: aload_0
     301: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     304: checkcast     #27                 // class java/lang/Number
     307: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     310: iconst_1
     311: iadd
     312: invokestatic  #37                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     315: aload_0
     316: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     319: checkcast     #27                 // class java/lang/Number
     322: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     325: iconst_1
     326: isub
     327: invokestatic  #37                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     330: invokestatic  #43                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     333: goto          429
     336: nop
     337: aload_1
     338: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     341: checkcast     #27                 // class java/lang/Number
     344: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     347: aload_0
     348: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     351: checkcast     #27                 // class java/lang/Number
     354: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     357: if_icmpge     396
     360: aload_0
     361: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     364: checkcast     #27                 // class java/lang/Number
     367: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     370: iconst_1
     371: isub
     372: invokestatic  #37                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     375: aload_0
     376: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     379: checkcast     #27                 // class java/lang/Number
     382: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     385: iconst_1
     386: iadd
     387: invokestatic  #37                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     390: invokestatic  #43                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     393: goto          429
     396: aload_0
     397: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     400: checkcast     #27                 // class java/lang/Number
     403: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     406: iconst_1
     407: iadd
     408: invokestatic  #37                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     411: aload_0
     412: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     415: checkcast     #27                 // class java/lang/Number
     418: invokevirtual #31                 // Method java/lang/Number.intValue:()I
     421: iconst_1
     422: iadd
     423: invokestatic  #37                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     426: invokestatic  #43                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     429: areturn

  public static final boolean isTouching(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #66                 // String point
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      16: checkcast     #27                 // class java/lang/Number
      19: invokevirtual #31                 // Method java/lang/Number.intValue:()I
      22: aload_0
      23: invokevirtual #22                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      26: checkcast     #27                 // class java/lang/Number
      29: invokevirtual #31                 // Method java/lang/Number.intValue:()I
      32: isub
      33: invokestatic  #72                 // Method java/lang/Math.abs:(I)I
      36: aload_1
      37: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      40: checkcast     #27                 // class java/lang/Number
      43: invokevirtual #31                 // Method java/lang/Number.intValue:()I
      46: aload_0
      47: invokevirtual #25                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      50: checkcast     #27                 // class java/lang/Number
      53: invokevirtual #31                 // Method java/lang/Number.intValue:()I
      56: isub
      57: invokestatic  #72                 // Method java/lang/Math.abs:(I)I
      60: invokestatic  #76                 // Method java/lang/Math.max:(II)I
      63: iconst_1
      64: if_icmpgt     71
      67: iconst_1
      68: goto          72
      71: iconst_0
      72: ireturn

  public static final int tailPositions(java.util.List<java.lang.String>, int);
    Code:
       0: aload_0
       1: ldc           #82                 // String commands
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #84                 // class java/lang/Iterable
      10: astore_2
      11: nop
      12: iconst_0
      13: istore_3
      14: aload_2
      15: astore        4
      17: new           #86                 // class java/util/ArrayList
      20: dup
      21: aload_2
      22: bipush        10
      24: invokestatic  #92                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      27: invokespecial #95                 // Method java/util/ArrayList."<init>":(I)V
      30: checkcast     #97                 // class java/util/Collection
      33: astore        5
      35: iconst_0
      36: istore        6
      38: aload         4
      40: invokeinterface #101,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      45: astore        7
      47: aload         7
      49: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      54: ifeq          119
      57: aload         7
      59: invokeinterface #110,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      64: astore        8
      66: aload         5
      68: aload         8
      70: checkcast     #112                // class java/lang/String
      73: astore        9
      75: astore        24
      77: iconst_0
      78: istore        10
      80: aload         9
      82: checkcast     #114                // class java/lang/CharSequence
      85: iconst_1
      86: anewarray     #112                // class java/lang/String
      89: astore        11
      91: aload         11
      93: iconst_0
      94: ldc           #116                // String
      96: aastore
      97: aload         11
      99: iconst_0
     100: iconst_0
     101: bipush        6
     103: aconst_null
     104: invokestatic  #122                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     107: aload         24
     109: swap
     110: invokeinterface #126,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     115: pop
     116: goto          47
     119: aload         5
     121: checkcast     #128                // class java/util/List
     124: nop
     125: checkcast     #84                 // class java/lang/Iterable
     128: astore_2
     129: nop
     130: iconst_0
     131: istore_3
     132: aload_2
     133: astore        4
     135: new           #86                 // class java/util/ArrayList
     138: dup
     139: aload_2
     140: bipush        10
     142: invokestatic  #92                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     145: invokespecial #95                 // Method java/util/ArrayList."<init>":(I)V
     148: checkcast     #97                 // class java/util/Collection
     151: astore        5
     153: iconst_0
     154: istore        6
     156: aload         4
     158: invokeinterface #101,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     163: astore        7
     165: aload         7
     167: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     172: ifeq          238
     175: aload         7
     177: invokeinterface #110,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     182: astore        8
     184: aload         5
     186: aload         8
     188: checkcast     #128                // class java/util/List
     191: astore        9
     193: astore        24
     195: iconst_0
     196: istore        10
     198: aload         9
     200: iconst_0
     201: invokeinterface #132,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     206: checkcast     #114                // class java/lang/CharSequence
     209: aload         9
     211: iconst_1
     212: invokeinterface #132,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     217: checkcast     #112                // class java/lang/String
     220: invokestatic  #136                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     223: invokestatic  #140                // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;
     226: aload         24
     228: swap
     229: invokeinterface #126,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     234: pop
     235: goto          165
     238: aload         5
     240: checkcast     #128                // class java/util/List
     243: nop
     244: checkcast     #84                 // class java/lang/Iterable
     247: astore_2
     248: nop
     249: iconst_0
     250: istore_3
     251: aload_2
     252: astore        4
     254: new           #86                 // class java/util/ArrayList
     257: dup
     258: invokespecial #141                // Method java/util/ArrayList."<init>":()V
     261: checkcast     #97                 // class java/util/Collection
     264: astore        5
     266: iconst_0
     267: istore        6
     269: aload         4
     271: invokeinterface #101,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     276: astore        7
     278: aload         7
     280: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     285: ifeq          331
     288: aload         7
     290: invokeinterface #110,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     295: astore        8
     297: aload         8
     299: checkcast     #112                // class java/lang/String
     302: astore        9
     304: iconst_0
     305: istore        10
     307: aload         9
     309: checkcast     #114                // class java/lang/CharSequence
     312: invokestatic  #145                // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;
     315: checkcast     #84                 // class java/lang/Iterable
     318: astore        9
     320: aload         5
     322: aload         9
     324: invokestatic  #149                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     327: pop
     328: goto          278
     331: aload         5
     333: checkcast     #128                // class java/util/List
     336: nop
     337: checkcast     #84                 // class java/lang/Iterable
     340: astore_2
     341: new           #86                 // class java/util/ArrayList
     344: dup
     345: iload_1
     346: invokespecial #95                 // Method java/util/ArrayList."<init>":(I)V
     349: astore_3
     350: iconst_0
     351: istore        4
     353: iload         4
     355: iload_1
     356: if_icmpge     397
     359: iload         4
     361: istore        5
     363: aload_3
     364: iload         5
     366: istore        6
     368: astore        24
     370: iconst_0
     371: istore        7
     373: iconst_0
     374: invokestatic  #37                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     377: iconst_0
     378: invokestatic  #37                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     381: invokestatic  #43                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     384: aload         24
     386: swap
     387: invokevirtual #150                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     390: pop
     391: iinc          4, 1
     394: goto          353
     397: aload_3
     398: checkcast     #128                // class java/util/List
     401: astore_3
     402: nop
     403: iconst_0
     404: istore        4
     406: aload_2
     407: astore        5
     409: iconst_0
     410: istore        6
     412: aload         5
     414: bipush        9
     416: invokestatic  #92                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     419: istore        7
     421: iload         7
     423: ifne          433
     426: aload_3
     427: invokestatic  #154                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     430: goto          640
     433: new           #86                 // class java/util/ArrayList
     436: dup
     437: iload         7
     439: iconst_1
     440: iadd
     441: invokespecial #95                 // Method java/util/ArrayList."<init>":(I)V
     444: astore        8
     446: aload         8
     448: astore        9
     450: iconst_0
     451: istore        10
     453: aload         9
     455: aload_3
     456: invokevirtual #150                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     459: pop
     460: aload         8
     462: astore        11
     464: aload_3
     465: astore        8
     467: aload         5
     469: invokeinterface #101,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     474: astore        9
     476: aload         9
     478: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     483: ifeq          635
     486: aload         9
     488: invokeinterface #110,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     493: astore        10
     495: aload         8
     497: aload         10
     499: checkcast     #156                // class java/lang/Character
     502: invokevirtual #160                // Method java/lang/Character.charValue:()C
     505: istore        12
     507: astore        13
     509: iconst_0
     510: istore        14
     512: aload         13
     514: checkcast     #84                 // class java/lang/Iterable
     517: iconst_1
     518: invokestatic  #164                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     521: checkcast     #84                 // class java/lang/Iterable
     524: astore        15
     526: aload         13
     528: invokestatic  #168                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     531: checkcast     #18                 // class kotlin/Pair
     534: iload         12
     536: invokestatic  #170                // Method moveHead:(Lkotlin/Pair;C)Lkotlin/Pair;
     539: invokestatic  #154                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     542: astore        16
     544: iconst_0
     545: istore        17
     547: aload         16
     549: astore        18
     551: aload         15
     553: invokeinterface #101,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     558: astore        19
     560: aload         19
     562: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     567: ifeq          619
     570: aload         19
     572: invokeinterface #110,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     577: astore        20
     579: aload         18
     581: aload         20
     583: checkcast     #18                 // class kotlin/Pair
     586: astore        21
     588: astore        22
     590: iconst_0
     591: istore        23
     593: aload         22
     595: checkcast     #97                 // class java/util/Collection
     598: aload         21
     600: aload         22
     602: invokestatic  #173                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     605: checkcast     #18                 // class kotlin/Pair
     608: invokestatic  #175                // Method moveTail:(Lkotlin/Pair;Lkotlin/Pair;)Lkotlin/Pair;
     611: invokestatic  #179                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     614: astore        18
     616: goto          560
     619: aload         18
     621: nop
     622: astore        8
     624: aload         11
     626: aload         8
     628: invokevirtual #150                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     631: pop
     632: goto          476
     635: aload         11
     637: checkcast     #128                // class java/util/List
     640: nop
     641: checkcast     #84                 // class java/lang/Iterable
     644: astore_2
     645: nop
     646: iconst_0
     647: istore_3
     648: aload_2
     649: astore        4
     651: new           #86                 // class java/util/ArrayList
     654: dup
     655: aload_2
     656: bipush        10
     658: invokestatic  #92                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     661: invokespecial #95                 // Method java/util/ArrayList."<init>":(I)V
     664: checkcast     #97                 // class java/util/Collection
     667: astore        5
     669: iconst_0
     670: istore        6
     672: aload         4
     674: invokeinterface #101,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     679: astore        7
     681: aload         7
     683: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     688: ifeq          734
     691: aload         7
     693: invokeinterface #110,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     698: astore        8
     700: aload         5
     702: aload         8
     704: checkcast     #128                // class java/util/List
     707: astore        9
     709: astore        24
     711: iconst_0
     712: istore        10
     714: aload         9
     716: invokestatic  #173                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     719: checkcast     #18                 // class kotlin/Pair
     722: aload         24
     724: swap
     725: invokeinterface #126,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     730: pop
     731: goto          681
     734: aload         5
     736: checkcast     #128                // class java/util/List
     739: nop
     740: checkcast     #84                 // class java/lang/Iterable
     743: invokestatic  #183                // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     746: invokeinterface #188,  1          // InterfaceMethod java/util/Set.size:()I
     751: ireturn

  public static final int day9part1();
    Code:
       0: new           #236                // class java/io/File
       3: dup
       4: ldc           #238                // String input/09.txt
       6: invokespecial #241                // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #247                // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      15: iconst_2
      16: invokestatic  #249                // Method tailPositions:(Ljava/util/List;I)I
      19: ireturn

  public static final int day9part2();
    Code:
       0: new           #236                // class java/io/File
       3: dup
       4: ldc           #238                // String input/09.txt
       6: invokespecial #241                // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #247                // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      15: bipush        10
      17: invokestatic  #249                // Method tailPositions:(Ljava/util/List;I)I
      20: ireturn
}