package day7

import java.io.File

fun main(args: Array<String>) {
    p1(File("src/day7/input"))
    p2(File("src/day7/input"))
}

fun p1(file: File) {
    val programs = mutableListOf<String>()
    val subPrograms = mutableListOf<String>()

    file.forEachLine { line ->
        val parts = line.split(" ")

        val program = parts[0]
        programs.add(program)
        val weight = parts[1].trim('(', ')').toInt()

        if ("->" in parts) {
            parts.subList(3, parts.size)
                    .map { it -> it.trim(',') }
                    .forEach { s -> subPrograms.add(s) }
        }
    }

    programs.forEach { program ->
        if (!subPrograms.contains(program)) {
            println(program)
        }
    }
}

val programWeights = mutableMapOf<String, Int>()
val directSubs = mutableMapOf<String, List<String>>()
fun p2(file: File) {
    val programs = mutableListOf<String>()
    val subPrograms = mutableListOf<String>()

    file.forEachLine { line ->
        val parts = line.split(" ")

        val program = parts[0]
        programs.add(program)
        val weight = parts[1].trim('(', ')').toInt()
        programWeights.put(program, weight)

        if ("->" in parts) {
            val subs = parts.subList(3, parts.size)
                    .map { it -> it.trim(',') }
            subs.forEach { s -> subPrograms.add(s) }

            directSubs.put(program, subs)
        }
    }

    val programTotalWeights = mutableMapOf<String, Int>()
    for (p: String in programs) {
        if (directSubs.containsKey(p)) {
           programTotalWeights.put(p, getWeightOfProgramAndSubs(p))
        } else {
            programTotalWeights.put(p, programWeights[p]!!)
        }
    }

    for (p: String in programs.filter { directSubs.containsKey(it) }) {

        val weights = directSubs[p]!!.map { programTotalWeights[it]!! }
        if (weights.toSet().size != 1) {
            println(programTotalWeights[p])
            println(weights)
            directSubs[p]!!.forEach { t: String? -> print("${programWeights[t]} - ") }
            println()
            println(programWeights[p])
            println()
        }
    }
}

fun getWeightOfProgramAndSubs(name: String): Int {
    var weight = 0
    weight += programWeights[name]!! // start with weight of the program itself

    // recursively add weights of sub programs
    if (directSubs.containsKey(name)) {
        for (sub: String in directSubs[name]!!) {
            weight += getWeightOfProgramAndSubs(sub)
        }
    }

    return weight
}

Compiled from "day7.kt"
public final class day7.Day7Kt {
  private static final java.util.Map<java.lang.String, java.lang.Integer> programWeights;

  private static final java.util.Map<java.lang.String, java.util.List<java.lang.String>> directSubs;

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String args
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #17                 // class java/io/File
       9: dup
      10: ldc           #19                 // String src/day7/input
      12: invokespecial #23                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      15: invokestatic  #27                 // Method p1:(Ljava/io/File;)V
      18: new           #17                 // class java/io/File
      21: dup
      22: ldc           #19                 // String src/day7/input
      24: invokespecial #23                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      27: invokestatic  #30                 // Method p2:(Ljava/io/File;)V
      30: return

  public static final void p1(java.io.File);
    Code:
       0: aload_0
       1: ldc           #33                 // String file
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #35                 // class java/util/ArrayList
       9: dup
      10: invokespecial #38                 // Method java/util/ArrayList."<init>":()V
      13: checkcast     #40                 // class java/util/List
      16: astore_1
      17: new           #35                 // class java/util/ArrayList
      20: dup
      21: invokespecial #38                 // Method java/util/ArrayList."<init>":()V
      24: checkcast     #40                 // class java/util/List
      27: astore_2
      28: aload_0
      29: aconst_null
      30: aload_1
      31: aload_2
      32: invokedynamic #60,  0             // InvokeDynamic #0:invoke:(Ljava/util/List;Ljava/util/List;)Lkotlin/jvm/functions/Function1;
      37: iconst_1
      38: aconst_null
      39: invokestatic  #66                 // Method kotlin/io/FilesKt.forEachLine$default:(Ljava/io/File;Ljava/nio/charset/Charset;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
      42: aload_1
      43: checkcast     #68                 // class java/lang/Iterable
      46: astore_3
      47: iconst_0
      48: istore        4
      50: aload_3
      51: invokeinterface #72,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      56: astore        5
      58: aload         5
      60: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      65: ifeq          111
      68: aload         5
      70: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      75: astore        6
      77: aload         6
      79: checkcast     #84                 // class java/lang/String
      82: astore        7
      84: iconst_0
      85: istore        8
      87: aload_2
      88: aload         7
      90: invokeinterface #88,  2           // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
      95: ifne          106
      98: getstatic     #94                 // Field java/lang/System.out:Ljava/io/PrintStream;
     101: aload         7
     103: invokevirtual #100                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     106: nop
     107: nop
     108: goto          58
     111: nop
     112: return

  public static final java.util.Map<java.lang.String, java.lang.Integer> getProgramWeights();
    Code:
       0: getstatic     #120                // Field programWeights:Ljava/util/Map;
       3: areturn

  public static final java.util.Map<java.lang.String, java.util.List<java.lang.String>> getDirectSubs();
    Code:
       0: getstatic     #125                // Field directSubs:Ljava/util/Map;
       3: areturn

  public static final void p2(java.io.File);
    Code:
       0: aload_0
       1: ldc           #33                 // String file
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #35                 // class java/util/ArrayList
       9: dup
      10: invokespecial #38                 // Method java/util/ArrayList."<init>":()V
      13: checkcast     #40                 // class java/util/List
      16: astore_1
      17: new           #35                 // class java/util/ArrayList
      20: dup
      21: invokespecial #38                 // Method java/util/ArrayList."<init>":()V
      24: checkcast     #40                 // class java/util/List
      27: astore_2
      28: aload_0
      29: aconst_null
      30: aload_1
      31: aload_2
      32: invokedynamic #130,  0            // InvokeDynamic #1:invoke:(Ljava/util/List;Ljava/util/List;)Lkotlin/jvm/functions/Function1;
      37: iconst_1
      38: aconst_null
      39: invokestatic  #66                 // Method kotlin/io/FilesKt.forEachLine$default:(Ljava/io/File;Ljava/nio/charset/Charset;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
      42: new           #132                // class java/util/LinkedHashMap
      45: dup
      46: invokespecial #133                // Method java/util/LinkedHashMap."<init>":()V
      49: checkcast     #135                // class java/util/Map
      52: astore_3
      53: aload_1
      54: invokeinterface #136,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      59: astore        4
      61: aload         4
      63: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      68: ifeq          147
      71: aload         4
      73: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      78: checkcast     #84                 // class java/lang/String
      81: astore        5
      83: getstatic     #125                // Field directSubs:Ljava/util/Map;
      86: aload         5
      88: invokeinterface #139,  2          // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
      93: ifeq          118
      96: aload_3
      97: aload         5
      99: aload         5
     101: invokestatic  #143                // Method getWeightOfProgramAndSubs:(Ljava/lang/String;)I
     104: invokestatic  #149                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     107: invokeinterface #153,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     112: checkcast     #145                // class java/lang/Integer
     115: goto          143
     118: aload_3
     119: aload         5
     121: getstatic     #120                // Field programWeights:Ljava/util/Map;
     124: aload         5
     126: invokeinterface #156,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     131: dup
     132: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     135: invokeinterface #153,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     140: checkcast     #145                // class java/lang/Integer
     143: pop
     144: goto          61
     147: aload_1
     148: checkcast     #68                 // class java/lang/Iterable
     151: astore        5
     153: iconst_0
     154: istore        6
     156: aload         5
     158: astore        7
     160: new           #35                 // class java/util/ArrayList
     163: dup
     164: invokespecial #38                 // Method java/util/ArrayList."<init>":()V
     167: checkcast     #161                // class java/util/Collection
     170: astore        8
     172: iconst_0
     173: istore        9
     175: aload         7
     177: invokeinterface #72,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     182: astore        10
     184: aload         10
     186: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     191: ifeq          239
     194: aload         10
     196: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     201: astore        11
     203: aload         11
     205: checkcast     #84                 // class java/lang/String
     208: astore        12
     210: iconst_0
     211: istore        13
     213: getstatic     #125                // Field directSubs:Ljava/util/Map;
     216: aload         12
     218: invokeinterface #139,  2          // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
     223: ifeq          184
     226: aload         8
     228: aload         11
     230: invokeinterface #164,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     235: pop
     236: goto          184
     239: aload         8
     241: checkcast     #40                 // class java/util/List
     244: nop
     245: invokeinterface #136,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     250: astore        4
     252: aload         4
     254: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     259: ifeq          578
     262: aload         4
     264: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     269: checkcast     #84                 // class java/lang/String
     272: astore        5
     274: getstatic     #125                // Field directSubs:Ljava/util/Map;
     277: aload         5
     279: invokeinterface #156,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     284: dup
     285: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     288: checkcast     #68                 // class java/lang/Iterable
     291: astore        7
     293: iconst_0
     294: istore        8
     296: aload         7
     298: astore        9
     300: new           #35                 // class java/util/ArrayList
     303: dup
     304: aload         7
     306: bipush        10
     308: invokestatic  #170                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     311: invokespecial #173                // Method java/util/ArrayList."<init>":(I)V
     314: checkcast     #161                // class java/util/Collection
     317: astore        10
     319: iconst_0
     320: istore        11
     322: aload         9
     324: invokeinterface #72,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     329: astore        12
     331: aload         12
     333: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     338: ifeq          397
     341: aload         12
     343: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     348: astore        13
     350: aload         10
     352: aload         13
     354: checkcast     #84                 // class java/lang/String
     357: astore        14
     359: astore        16
     361: iconst_0
     362: istore        15
     364: aload_3
     365: aload         14
     367: invokeinterface #156,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     372: dup
     373: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     376: checkcast     #175                // class java/lang/Number
     379: invokevirtual #179                // Method java/lang/Number.intValue:()I
     382: invokestatic  #149                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     385: aload         16
     387: swap
     388: invokeinterface #164,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     393: pop
     394: goto          331
     397: aload         10
     399: checkcast     #40                 // class java/util/List
     402: nop
     403: astore        6
     405: aload         6
     407: checkcast     #68                 // class java/lang/Iterable
     410: invokestatic  #183                // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     413: invokeinterface #188,  1          // InterfaceMethod java/util/Set.size:()I
     418: iconst_1
     419: if_icmpeq     252
     422: aload_3
     423: aload         5
     425: invokeinterface #156,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     430: getstatic     #94                 // Field java/lang/System.out:Ljava/io/PrintStream;
     433: swap
     434: invokevirtual #100                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     437: getstatic     #94                 // Field java/lang/System.out:Ljava/io/PrintStream;
     440: aload         6
     442: invokevirtual #100                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     445: getstatic     #125                // Field directSubs:Ljava/util/Map;
     448: aload         5
     450: invokeinterface #156,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     455: dup
     456: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     459: checkcast     #68                 // class java/lang/Iterable
     462: astore        7
     464: iconst_0
     465: istore        8
     467: aload         7
     469: invokeinterface #72,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     474: astore        9
     476: aload         9
     478: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     483: ifeq          545
     486: aload         9
     488: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     493: astore        10
     495: aload         10
     497: checkcast     #84                 // class java/lang/String
     500: astore        11
     502: iconst_0
     503: istore        12
     505: new           #190                // class java/lang/StringBuilder
     508: dup
     509: invokespecial #191                // Method java/lang/StringBuilder."<init>":()V
     512: getstatic     #120                // Field programWeights:Ljava/util/Map;
     515: aload         11
     517: invokeinterface #156,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     522: invokevirtual #195                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     525: ldc           #197                // String  -
     527: invokevirtual #200                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     530: invokevirtual #204                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     533: getstatic     #94                 // Field java/lang/System.out:Ljava/io/PrintStream;
     536: swap
     537: invokevirtual #207                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     540: nop
     541: nop
     542: goto          476
     545: nop
     546: getstatic     #94                 // Field java/lang/System.out:Ljava/io/PrintStream;
     549: invokevirtual #209                // Method java/io/PrintStream.println:()V
     552: getstatic     #120                // Field programWeights:Ljava/util/Map;
     555: aload         5
     557: invokeinterface #156,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     562: getstatic     #94                 // Field java/lang/System.out:Ljava/io/PrintStream;
     565: swap
     566: invokevirtual #100                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     569: getstatic     #94                 // Field java/lang/System.out:Ljava/io/PrintStream;
     572: invokevirtual #209                // Method java/io/PrintStream.println:()V
     575: goto          252
     578: return

  public static final int getWeightOfProgramAndSubs(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #231                // String name
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_1
       8: iload_1
       9: getstatic     #120                // Field programWeights:Ljava/util/Map;
      12: aload_0
      13: invokeinterface #156,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      18: dup
      19: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      22: checkcast     #175                // class java/lang/Number
      25: invokevirtual #179                // Method java/lang/Number.intValue:()I
      28: iadd
      29: istore_1
      30: getstatic     #125                // Field directSubs:Ljava/util/Map;
      33: aload_0
      34: invokeinterface #139,  2          // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
      39: ifeq          93
      42: getstatic     #125                // Field directSubs:Ljava/util/Map;
      45: aload_0
      46: invokeinterface #156,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      51: dup
      52: invokestatic  #159                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      55: checkcast     #40                 // class java/util/List
      58: invokeinterface #136,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      63: astore_2
      64: aload_2
      65: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      70: ifeq          93
      73: aload_2
      74: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      79: checkcast     #84                 // class java/lang/String
      82: astore_3
      83: iload_1
      84: aload_3
      85: invokestatic  #143                // Method getWeightOfProgramAndSubs:(Ljava/lang/String;)I
      88: iadd
      89: istore_1
      90: goto          64
      93: iload_1
      94: ireturn

  private static final kotlin.Unit p1$lambda$2(java.util.List, java.util.List, java.lang.String);
    Code:
       0: aload_2
       1: ldc           #235                // String line
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: checkcast     #237                // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #84                 // class java/lang/String
      14: astore        4
      16: aload         4
      18: iconst_0
      19: ldc           #239                // String
      21: aastore
      22: aload         4
      24: iconst_0
      25: iconst_0
      26: bipush        6
      28: aconst_null
      29: invokestatic  #245                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      32: astore_3
      33: aload_3
      34: iconst_0
      35: invokeinterface #248,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      40: checkcast     #84                 // class java/lang/String
      43: astore        4
      45: aload_0
      46: aload         4
      48: invokeinterface #249,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      53: pop
      54: aload_3
      55: iconst_1
      56: invokeinterface #248,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      61: checkcast     #84                 // class java/lang/String
      64: iconst_2
      65: newarray       char
      67: astore        6
      69: aload         6
      71: iconst_0
      72: bipush        40
      74: castore
      75: aload         6
      77: iconst_1
      78: bipush        41
      80: castore
      81: aload         6
      83: invokestatic  #253                // Method kotlin/text/StringsKt.trim:(Ljava/lang/String;[C)Ljava/lang/String;
      86: invokestatic  #256                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      89: istore        5
      91: aload_3
      92: ldc_w         #258                // String ->
      95: invokeinterface #88,  2           // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     100: ifeq          290
     103: aload_3
     104: iconst_3
     105: aload_3
     106: invokeinterface #259,  1          // InterfaceMethod java/util/List.size:()I
     111: invokeinterface #263,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     116: checkcast     #68                 // class java/lang/Iterable
     119: astore        6
     121: nop
     122: iconst_0
     123: istore        7
     125: aload         6
     127: astore        8
     129: new           #35                 // class java/util/ArrayList
     132: dup
     133: aload         6
     135: bipush        10
     137: invokestatic  #170                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     140: invokespecial #173                // Method java/util/ArrayList."<init>":(I)V
     143: checkcast     #161                // class java/util/Collection
     146: astore        9
     148: iconst_0
     149: istore        10
     151: aload         8
     153: invokeinterface #72,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     158: astore        11
     160: aload         11
     162: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     167: ifeq          223
     170: aload         11
     172: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     177: astore        12
     179: aload         9
     181: aload         12
     183: checkcast     #84                 // class java/lang/String
     186: astore        13
     188: astore        16
     190: iconst_0
     191: istore        14
     193: aload         13
     195: iconst_1
     196: newarray       char
     198: astore        15
     200: aload         15
     202: iconst_0
     203: bipush        44
     205: castore
     206: aload         15
     208: invokestatic  #253                // Method kotlin/text/StringsKt.trim:(Ljava/lang/String;[C)Ljava/lang/String;
     211: aload         16
     213: swap
     214: invokeinterface #164,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     219: pop
     220: goto          160
     223: aload         9
     225: checkcast     #40                 // class java/util/List
     228: nop
     229: checkcast     #68                 // class java/lang/Iterable
     232: astore        6
     234: nop
     235: iconst_0
     236: istore        7
     238: aload         6
     240: invokeinterface #72,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     245: astore        8
     247: aload         8
     249: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     254: ifeq          289
     257: aload         8
     259: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     264: astore        9
     266: aload         9
     268: checkcast     #84                 // class java/lang/String
     271: astore        10
     273: iconst_0
     274: istore        11
     276: aload_1
     277: aload         10
     279: invokeinterface #249,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     284: pop
     285: nop
     286: goto          247
     289: nop
     290: getstatic     #269                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     293: areturn

  private static final kotlin.Unit p2$lambda$6(java.util.List, java.util.List, java.lang.String);
    Code:
       0: aload_2
       1: ldc           #235                // String line
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: checkcast     #237                // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #84                 // class java/lang/String
      14: astore        4
      16: aload         4
      18: iconst_0
      19: ldc           #239                // String
      21: aastore
      22: aload         4
      24: iconst_0
      25: iconst_0
      26: bipush        6
      28: aconst_null
      29: invokestatic  #245                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      32: astore_3
      33: aload_3
      34: iconst_0
      35: invokeinterface #248,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      40: checkcast     #84                 // class java/lang/String
      43: astore        4
      45: aload_0
      46: aload         4
      48: invokeinterface #249,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      53: pop
      54: aload_3
      55: iconst_1
      56: invokeinterface #248,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      61: checkcast     #84                 // class java/lang/String
      64: iconst_2
      65: newarray       char
      67: astore        6
      69: aload         6
      71: iconst_0
      72: bipush        40
      74: castore
      75: aload         6
      77: iconst_1
      78: bipush        41
      80: castore
      81: aload         6
      83: invokestatic  #253                // Method kotlin/text/StringsKt.trim:(Ljava/lang/String;[C)Ljava/lang/String;
      86: invokestatic  #256                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      89: istore        5
      91: getstatic     #120                // Field programWeights:Ljava/util/Map;
      94: aload         4
      96: iload         5
      98: invokestatic  #149                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     101: invokeinterface #153,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     106: pop
     107: aload_3
     108: ldc_w         #258                // String ->
     111: invokeinterface #88,  2           // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     116: ifeq          322
     119: aload_3
     120: iconst_3
     121: aload_3
     122: invokeinterface #259,  1          // InterfaceMethod java/util/List.size:()I
     127: invokeinterface #263,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     132: checkcast     #68                 // class java/lang/Iterable
     135: astore        7
     137: nop
     138: iconst_0
     139: istore        8
     141: aload         7
     143: astore        9
     145: new           #35                 // class java/util/ArrayList
     148: dup
     149: aload         7
     151: bipush        10
     153: invokestatic  #170                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     156: invokespecial #173                // Method java/util/ArrayList."<init>":(I)V
     159: checkcast     #161                // class java/util/Collection
     162: astore        10
     164: iconst_0
     165: istore        11
     167: aload         9
     169: invokeinterface #72,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     174: astore        12
     176: aload         12
     178: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     183: ifeq          239
     186: aload         12
     188: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     193: astore        13
     195: aload         10
     197: aload         13
     199: checkcast     #84                 // class java/lang/String
     202: astore        14
     204: astore        17
     206: iconst_0
     207: istore        15
     209: aload         14
     211: iconst_1
     212: newarray       char
     214: astore        16
     216: aload         16
     218: iconst_0
     219: bipush        44
     221: castore
     222: aload         16
     224: invokestatic  #253                // Method kotlin/text/StringsKt.trim:(Ljava/lang/String;[C)Ljava/lang/String;
     227: aload         17
     229: swap
     230: invokeinterface #164,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     235: pop
     236: goto          176
     239: aload         10
     241: checkcast     #40                 // class java/util/List
     244: nop
     245: astore        6
     247: aload         6
     249: checkcast     #68                 // class java/lang/Iterable
     252: astore        7
     254: iconst_0
     255: istore        8
     257: aload         7
     259: invokeinterface #72,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     264: astore        9
     266: aload         9
     268: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     273: ifeq          308
     276: aload         9
     278: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     283: astore        10
     285: aload         10
     287: checkcast     #84                 // class java/lang/String
     290: astore        11
     292: iconst_0
     293: istore        12
     295: aload_1
     296: aload         11
     298: invokeinterface #249,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     303: pop
     304: nop
     305: goto          266
     308: nop
     309: getstatic     #125                // Field directSubs:Ljava/util/Map;
     312: aload         4
     314: aload         6
     316: invokeinterface #153,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     321: pop
     322: getstatic     #269                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     325: areturn

  static {};
    Code:
       0: new           #132                // class java/util/LinkedHashMap
       3: dup
       4: invokespecial #133                // Method java/util/LinkedHashMap."<init>":()V
       7: checkcast     #135                // class java/util/Map
      10: putstatic     #120                // Field programWeights:Ljava/util/Map;
      13: new           #132                // class java/util/LinkedHashMap
      16: dup
      17: invokespecial #133                // Method java/util/LinkedHashMap."<init>":()V
      20: checkcast     #135                // class java/util/Map
      23: putstatic     #125                // Field directSubs:Ljava/util/Map;
      26: return
}


package day8

import java.io.File

fun main(args: Array<String>) {
    val lines = File("src/day8/input").readLines()
    p1(lines)
    p2(lines)
}

fun p1(lines: List<String>) {
    val values = mutableMapOf<String, Int>()

    for (line in lines) {
        values.put(line.split(" ")[0], 0)
    }

    for (line in lines) {
        val parts = line.split(" ")

        val subject = parts[0]
        val operator = parts[1]
        val n = parts[2].toInt()
        val condition = parts.subList(4, parts.size)

        if (checkCondition(condition, values)) {
            val currentValue = values[subject]!!

            if (operator == "inc") {
                values[subject] = currentValue + n
            } else if (operator == "dec") {
                values[subject] = currentValue - n
            }
        }
    }

    println(values.values.max())
}

fun p2(lines: List<String>) {
    val values = mutableMapOf<String, Int>()
    var max = 0;

    for (line in lines) {
        values.put(line.split(" ")[0], 0)
    }

    for (line in lines) {
        val parts = line.split(" ")

        val subject = parts[0]
        val operator = parts[1]
        val n = parts[2].toInt()
        val condition = parts.subList(4, parts.size)

        if (checkCondition(condition, values)) {
            val currentValue = values[subject]!!

            if (operator == "inc") {
                values[subject] = currentValue + n
            } else if (operator == "dec") {
                values[subject] = currentValue - n
            }
            if (values[subject]!! > max) {
                max = values[subject]!!
            }
        }
    }

    println(max)
}

fun checkCondition(condition: List<String>, values: Map<String, Int>): Boolean {
    val a = values[condition[0]]!!.toInt()
    val b = condition[2].toInt()

    return when (condition[1]) {
        "==" -> a == b
        "!=" -> a != b
        ">" -> a > b
        "<" -> a < b
        ">=" -> a >= b
        "<=" -> a <= b
        else -> false
    }
}

Compiled from "day8.kt"
public final class day8.Day8Kt {
  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String args
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #17                 // class java/io/File
       9: dup
      10: ldc           #19                 // String src/day8/input
      12: invokespecial #23                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      15: aconst_null
      16: iconst_1
      17: aconst_null
      18: invokestatic  #29                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      21: astore_1
      22: aload_1
      23: invokestatic  #33                 // Method p1:(Ljava/util/List;)V
      26: aload_1
      27: invokestatic  #36                 // Method p2:(Ljava/util/List;)V
      30: return

  public static final void p1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #41                 // String lines
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #43                 // class java/util/LinkedHashMap
       9: dup
      10: invokespecial #46                 // Method java/util/LinkedHashMap."<init>":()V
      13: checkcast     #48                 // class java/util/Map
      16: astore_1
      17: aload_0
      18: invokeinterface #54,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      23: astore_2
      24: aload_2
      25: invokeinterface #60,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      30: ifeq          89
      33: aload_2
      34: invokeinterface #64,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      39: checkcast     #66                 // class java/lang/String
      42: astore_3
      43: aload_1
      44: aload_3
      45: checkcast     #68                 // class java/lang/CharSequence
      48: iconst_1
      49: anewarray     #66                 // class java/lang/String
      52: astore        4
      54: aload         4
      56: iconst_0
      57: ldc           #70                 // String
      59: aastore
      60: aload         4
      62: iconst_0
      63: iconst_0
      64: bipush        6
      66: aconst_null
      67: invokestatic  #76                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      70: iconst_0
      71: invokeinterface #80,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      76: iconst_0
      77: invokestatic  #86                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      80: invokeinterface #90,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      85: pop
      86: goto          24
      89: aload_0
      90: invokeinterface #54,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      95: astore_2
      96: aload_2
      97: invokeinterface #60,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     102: ifeq          291
     105: aload_2
     106: invokeinterface #64,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     111: checkcast     #66                 // class java/lang/String
     114: astore_3
     115: aload_3
     116: checkcast     #68                 // class java/lang/CharSequence
     119: iconst_1
     120: anewarray     #66                 // class java/lang/String
     123: astore        5
     125: aload         5
     127: iconst_0
     128: ldc           #70                 // String
     130: aastore
     131: aload         5
     133: iconst_0
     134: iconst_0
     135: bipush        6
     137: aconst_null
     138: invokestatic  #76                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     141: astore        4
     143: aload         4
     145: iconst_0
     146: invokeinterface #80,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     151: checkcast     #66                 // class java/lang/String
     154: astore        5
     156: aload         4
     158: iconst_1
     159: invokeinterface #80,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     164: checkcast     #66                 // class java/lang/String
     167: astore        6
     169: aload         4
     171: iconst_2
     172: invokeinterface #80,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     177: checkcast     #66                 // class java/lang/String
     180: invokestatic  #94                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     183: istore        7
     185: aload         4
     187: iconst_4
     188: aload         4
     190: invokeinterface #98,  1           // InterfaceMethod java/util/List.size:()I
     195: invokeinterface #102,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     200: astore        8
     202: aload         8
     204: aload_1
     205: invokestatic  #106                // Method checkCondition:(Ljava/util/List;Ljava/util/Map;)Z
     208: ifeq          96
     211: aload_1
     212: aload         5
     214: invokeinterface #109,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     219: dup
     220: invokestatic  #113                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     223: checkcast     #115                // class java/lang/Number
     226: invokevirtual #118                // Method java/lang/Number.intValue:()I
     229: istore        9
     231: aload         6
     233: ldc           #120                // String inc
     235: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     238: ifeq          261
     241: aload_1
     242: aload         5
     244: iload         9
     246: iload         7
     248: iadd
     249: invokestatic  #86                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     252: invokeinterface #90,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     257: pop
     258: goto          96
     261: aload         6
     263: ldc           #126                // String dec
     265: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     268: ifeq          96
     271: aload_1
     272: aload         5
     274: iload         9
     276: iload         7
     278: isub
     279: invokestatic  #86                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     282: invokeinterface #90,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     287: pop
     288: goto          96
     291: aload_1
     292: invokeinterface #130,  1          // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
     297: checkcast     #132                // class java/lang/Iterable
     300: invokestatic  #138                // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     303: checkcast     #115                // class java/lang/Number
     306: invokevirtual #118                // Method java/lang/Number.intValue:()I
     309: istore_2
     310: getstatic     #144                // Field java/lang/System.out:Ljava/io/PrintStream;
     313: iload_2
     314: invokevirtual #150                // Method java/io/PrintStream.println:(I)V
     317: return

  public static final void p2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #41                 // String lines
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #43                 // class java/util/LinkedHashMap
       9: dup
      10: invokespecial #46                 // Method java/util/LinkedHashMap."<init>":()V
      13: checkcast     #48                 // class java/util/Map
      16: astore_1
      17: iconst_0
      18: istore_2
      19: aload_0
      20: invokeinterface #54,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      25: astore_3
      26: aload_3
      27: invokeinterface #60,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      32: ifeq          93
      35: aload_3
      36: invokeinterface #64,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      41: checkcast     #66                 // class java/lang/String
      44: astore        4
      46: aload_1
      47: aload         4
      49: checkcast     #68                 // class java/lang/CharSequence
      52: iconst_1
      53: anewarray     #66                 // class java/lang/String
      56: astore        5
      58: aload         5
      60: iconst_0
      61: ldc           #70                 // String
      63: aastore
      64: aload         5
      66: iconst_0
      67: iconst_0
      68: bipush        6
      70: aconst_null
      71: invokestatic  #76                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      74: iconst_0
      75: invokeinterface #80,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      80: iconst_0
      81: invokestatic  #86                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      84: invokeinterface #90,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      89: pop
      90: goto          26
      93: aload_0
      94: invokeinterface #54,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      99: astore_3
     100: aload_3
     101: invokeinterface #60,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     106: ifeq          338
     109: aload_3
     110: invokeinterface #64,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     115: checkcast     #66                 // class java/lang/String
     118: astore        4
     120: aload         4
     122: checkcast     #68                 // class java/lang/CharSequence
     125: iconst_1
     126: anewarray     #66                 // class java/lang/String
     129: astore        6
     131: aload         6
     133: iconst_0
     134: ldc           #70                 // String
     136: aastore
     137: aload         6
     139: iconst_0
     140: iconst_0
     141: bipush        6
     143: aconst_null
     144: invokestatic  #76                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     147: astore        5
     149: aload         5
     151: iconst_0
     152: invokeinterface #80,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     157: checkcast     #66                 // class java/lang/String
     160: astore        6
     162: aload         5
     164: iconst_1
     165: invokeinterface #80,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     170: checkcast     #66                 // class java/lang/String
     173: astore        7
     175: aload         5
     177: iconst_2
     178: invokeinterface #80,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     183: checkcast     #66                 // class java/lang/String
     186: invokestatic  #94                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     189: istore        8
     191: aload         5
     193: iconst_4
     194: aload         5
     196: invokeinterface #98,  1           // InterfaceMethod java/util/List.size:()I
     201: invokeinterface #102,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     206: astore        9
     208: aload         9
     210: aload_1
     211: invokestatic  #106                // Method checkCondition:(Ljava/util/List;Ljava/util/Map;)Z
     214: ifeq          100
     217: aload_1
     218: aload         6
     220: invokeinterface #109,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     225: dup
     226: invokestatic  #113                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     229: checkcast     #115                // class java/lang/Number
     232: invokevirtual #118                // Method java/lang/Number.intValue:()I
     235: istore        10
     237: aload         7
     239: ldc           #120                // String inc
     241: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     244: ifeq          267
     247: aload_1
     248: aload         6
     250: iload         10
     252: iload         8
     254: iadd
     255: invokestatic  #86                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     258: invokeinterface #90,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     263: pop
     264: goto          294
     267: aload         7
     269: ldc           #126                // String dec
     271: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     274: ifeq          294
     277: aload_1
     278: aload         6
     280: iload         10
     282: iload         8
     284: isub
     285: invokestatic  #86                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     288: invokeinterface #90,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     293: pop
     294: aload_1
     295: aload         6
     297: invokeinterface #109,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     302: dup
     303: invokestatic  #113                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     306: checkcast     #115                // class java/lang/Number
     309: invokevirtual #118                // Method java/lang/Number.intValue:()I
     312: iload_2
     313: if_icmple     100
     316: aload_1
     317: aload         6
     319: invokeinterface #109,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     324: dup
     325: invokestatic  #113                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     328: checkcast     #115                // class java/lang/Number
     331: invokevirtual #118                // Method java/lang/Number.intValue:()I
     334: istore_2
     335: goto          100
     338: getstatic     #144                // Field java/lang/System.out:Ljava/io/PrintStream;
     341: iload_2
     342: invokevirtual #150                // Method java/io/PrintStream.println:(I)V
     345: return

  public static final boolean checkCondition(java.util.List<java.lang.String>, java.util.Map<java.lang.String, java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #163                // String condition
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #164                // String values
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: aload_0
      14: iconst_0
      15: invokeinterface #80,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      20: invokeinterface #109,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      25: dup
      26: invokestatic  #113                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      29: checkcast     #115                // class java/lang/Number
      32: invokevirtual #118                // Method java/lang/Number.intValue:()I
      35: istore_2
      36: aload_0
      37: iconst_2
      38: invokeinterface #80,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      43: checkcast     #66                 // class java/lang/String
      46: invokestatic  #94                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      49: istore_3
      50: aload_0
      51: iconst_1
      52: invokeinterface #80,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      57: checkcast     #66                 // class java/lang/String
      60: astore        4
      62: aload         4
      64: invokevirtual #167                // Method java/lang/String.hashCode:()I
      67: lookupswitch  { // 6
                    60: 163
                    62: 176
                  1084: 150
                  1921: 137
                  1952: 124
                  1983: 189
               default: 280
          }
     124: aload         4
     126: ldc           #169                // String ==
     128: invokevirtual #173                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     131: ifne          202
     134: goto          280
     137: aload         4
     139: ldc           #175                // String <=
     141: invokevirtual #173                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     144: ifne          267
     147: goto          280
     150: aload         4
     152: ldc           #177                // String !=
     154: invokevirtual #173                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     157: ifne          215
     160: goto          280
     163: aload         4
     165: ldc           #179                // String <
     167: invokevirtual #173                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     170: ifne          241
     173: goto          280
     176: aload         4
     178: ldc           #181                // String >
     180: invokevirtual #173                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     183: ifne          228
     186: goto          280
     189: aload         4
     191: ldc           #183                // String >=
     193: invokevirtual #173                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     196: ifne          254
     199: goto          280
     202: iload_2
     203: iload_3
     204: if_icmpne     211
     207: iconst_1
     208: goto          281
     211: iconst_0
     212: goto          281
     215: iload_2
     216: iload_3
     217: if_icmpeq     224
     220: iconst_1
     221: goto          281
     224: iconst_0
     225: goto          281
     228: iload_2
     229: iload_3
     230: if_icmple     237
     233: iconst_1
     234: goto          281
     237: iconst_0
     238: goto          281
     241: iload_2
     242: iload_3
     243: if_icmpge     250
     246: iconst_1
     247: goto          281
     250: iconst_0
     251: goto          281
     254: iload_2
     255: iload_3
     256: if_icmplt     263
     259: iconst_1
     260: goto          281
     263: iconst_0
     264: goto          281
     267: iload_2
     268: iload_3
     269: if_icmpgt     276
     272: iconst_1
     273: goto          281
     276: iconst_0
     277: goto          281
     280: iconst_0
     281: ireturn
}


package leetcode

/**
 * # 1. Two Sum
 * [https://leetcode.com/problems/two-sum/](https://leetcode.com/problems/two-sum/)
 *
 * ### Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
 * ### You may assume that each input would have exactly one solution, and you may not use the same element twice.
 * ### You can return the answer in any order.
 *
 */
class TwoSum {

    /**
     * Brute Force
     */
    fun bruteForce(nums: IntArray, target: Int): IntArray? {
        for (i in nums.indices) {
            for (j in i + 1 until nums.size) {
                if (nums[j] == target - nums[i]) {
                    return intArrayOf(i, j)
                }
            }
        }
        // In case there is no solution, we'll just return null
        return null
    }

    /**
     * Two-pass Hash Table
     */
    fun twoPassHashTable(nums: IntArray, target: Int): IntArray? {
        val map: MutableMap<Int, Int> = HashMap()
        for (i in nums.indices) {
            map[nums[i]] = i
        }
        for (i in nums.indices) {
            val complement = target - nums[i]
            if (map.containsKey(complement) && map[complement] != i) {
                return intArrayOf(i, map[complement]!!)
            }
        }
        // In case there is no solution, we'll just return null
        return null
    }

    /**
     * One-pass Hash Table
     */
    fun onePassHashTable(nums: IntArray, target: Int): IntArray? {
        val map: MutableMap<Int, Int> = HashMap()
        for (i in nums.indices) {
            val complement = target - nums[i]
            if (map.containsKey(complement)) {
                return intArrayOf(map[complement]!!, i)
            }
            map[nums[i]] = i
        }
        // In case there is no solution, we'll just return null
        return null
    }

}

Compiled from "TwoSum.kt"
public final class leetcode.TwoSum {
  public leetcode.TwoSum();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int[] bruteForce(int[], int);
    Code:
       0: aload_1
       1: ldc           #16                 // String nums
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_3
       8: aload_1
       9: arraylength
      10: istore        4
      12: iload_3
      13: iload         4
      15: if_icmpge     77
      18: iload_3
      19: iconst_1
      20: iadd
      21: istore        5
      23: aload_1
      24: arraylength
      25: istore        6
      27: iload         5
      29: iload         6
      31: if_icmpge     71
      34: aload_1
      35: iload         5
      37: iaload
      38: iload_2
      39: aload_1
      40: iload_3
      41: iaload
      42: isub
      43: if_icmpne     65
      46: iconst_2
      47: newarray       int
      49: astore        7
      51: aload         7
      53: iconst_0
      54: iload_3
      55: iastore
      56: aload         7
      58: iconst_1
      59: iload         5
      61: iastore
      62: aload         7
      64: areturn
      65: iinc          5, 1
      68: goto          27
      71: iinc          3, 1
      74: goto          12
      77: aconst_null
      78: areturn

  public final int[] twoPassHashTable(int[], int);
    Code:
       0: aload_1
       1: ldc           #16                 // String nums
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #30                 // class java/util/HashMap
       9: dup
      10: invokespecial #31                 // Method java/util/HashMap."<init>":()V
      13: checkcast     #33                 // class java/util/Map
      16: astore_3
      17: iconst_0
      18: istore        4
      20: aload_1
      21: arraylength
      22: istore        5
      24: iload         4
      26: iload         5
      28: if_icmpge     60
      31: iload         4
      33: invokestatic  #39                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      36: astore        8
      38: aload_3
      39: aload_1
      40: iload         4
      42: iaload
      43: invokestatic  #39                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      46: aload         8
      48: invokeinterface #43,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      53: pop
      54: iinc          4, 1
      57: goto          24
      60: iconst_0
      61: istore        4
      63: aload_1
      64: arraylength
      65: istore        5
      67: iload         4
      69: iload         5
      71: if_icmpge     175
      74: iload_2
      75: aload_1
      76: iload         4
      78: iaload
      79: isub
      80: istore        6
      82: aload_3
      83: iload         6
      85: invokestatic  #39                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      88: invokeinterface #47,  2           // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
      93: ifeq          169
      96: aload_3
      97: iload         6
      99: invokestatic  #39                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     102: invokeinterface #51,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     107: checkcast     #35                 // class java/lang/Integer
     110: iload         4
     112: istore        7
     114: dup
     115: ifnonnull     122
     118: pop
     119: goto          130
     122: invokevirtual #55                 // Method java/lang/Integer.intValue:()I
     125: iload         7
     127: if_icmpeq     169
     130: iconst_2
     131: newarray       int
     133: astore        7
     135: aload         7
     137: iconst_0
     138: iload         4
     140: iastore
     141: aload         7
     143: iconst_1
     144: aload_3
     145: iload         6
     147: invokestatic  #39                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     150: invokeinterface #51,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     155: dup
     156: invokestatic  #59                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     159: checkcast     #61                 // class java/lang/Number
     162: invokevirtual #62                 // Method java/lang/Number.intValue:()I
     165: iastore
     166: aload         7
     168: areturn
     169: iinc          4, 1
     172: goto          67
     175: aconst_null
     176: areturn

  public final int[] onePassHashTable(int[], int);
    Code:
       0: aload_1
       1: ldc           #16                 // String nums
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #30                 // class java/util/HashMap
       9: dup
      10: invokespecial #31                 // Method java/util/HashMap."<init>":()V
      13: checkcast     #33                 // class java/util/Map
      16: astore_3
      17: iconst_0
      18: istore        4
      20: aload_1
      21: arraylength
      22: istore        5
      24: iload         4
      26: iload         5
      28: if_icmpge     121
      31: iload_2
      32: aload_1
      33: iload         4
      35: iaload
      36: isub
      37: istore        6
      39: aload_3
      40: iload         6
      42: invokestatic  #39                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      45: invokeinterface #47,  2           // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
      50: ifeq          92
      53: iconst_2
      54: newarray       int
      56: astore        7
      58: aload         7
      60: iconst_0
      61: aload_3
      62: iload         6
      64: invokestatic  #39                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      67: invokeinterface #51,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      72: dup
      73: invokestatic  #59                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      76: checkcast     #61                 // class java/lang/Number
      79: invokevirtual #62                 // Method java/lang/Number.intValue:()I
      82: iastore
      83: aload         7
      85: iconst_1
      86: iload         4
      88: iastore
      89: aload         7
      91: areturn
      92: iload         4
      94: invokestatic  #39                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      97: astore        8
      99: aload_3
     100: aload_1
     101: iload         4
     103: iaload
     104: invokestatic  #39                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     107: aload         8
     109: invokeinterface #43,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     114: pop
     115: iinc          4, 1
     118: goto          24
     121: aconst_null
     122: areturn
}


package leetcode

/**
 * # 62. Unique Paths
 * [https://leetcode.com/problems/unique-paths/](https://leetcode.com/problems/unique-paths/)
 *
 * ### A robot is located at the top-left corner of 'm x n' grid (marked 'Start' in the diagram below).
 * ### The robot can only move either down or right at any point in time.
 * ### The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).
 *
 * ### How many possible unique paths are there?
 *
 */
class UniquePaths {

    fun dynamicProgramming(m: Int, n: Int): Int {
        val grid: Array<IntArray> = Array(m) { IntArray(n) }

        for (i in m - 1 downTo 0) {
            for (j in n - 1 downTo 0) {
                if (i == m - 1 || j == n - 1) {
                    grid[i][j] = 1
                } else {
                    grid[i][j] = grid[i + 1][j] + grid[i][j + 1]
                }
            }
        }

        return grid[0][0];
    }

    fun recursive(m: Int, n: Int): Int {
        if (m == 1 || n == 1) {
            return 1
        }

        return recursive(m - 1, n) + recursive(m, n - 1)
    }
}

Compiled from "UniquePaths.kt"
public final class leetcode.UniquePaths {
  public leetcode.UniquePaths();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int dynamicProgramming(int, int);
    Code:
       0: iconst_0
       1: istore        4
       3: iload_1
       4: anewarray     #14                 // class "[I"
       7: astore        5
       9: iload         4
      11: iload_1
      12: if_icmpge     33
      15: iload         4
      17: istore        6
      19: aload         5
      21: iload         6
      23: iload_2
      24: newarray       int
      26: aastore
      27: iinc          4, 1
      30: goto          9
      33: aload         5
      35: astore_3
      36: iload_1
      37: iconst_1
      38: isub
      39: istore        4
      41: iconst_m1
      42: iload         4
      44: if_icmpge     123
      47: iload_2
      48: iconst_1
      49: isub
      50: istore        5
      52: iconst_m1
      53: iload         5
      55: if_icmpge     117
      58: iload         4
      60: iload_1
      61: iconst_1
      62: isub
      63: if_icmpeq     74
      66: iload         5
      68: iload_2
      69: iconst_1
      70: isub
      71: if_icmpne     85
      74: aload_3
      75: iload         4
      77: aaload
      78: iload         5
      80: iconst_1
      81: iastore
      82: goto          111
      85: aload_3
      86: iload         4
      88: aaload
      89: iload         5
      91: aload_3
      92: iload         4
      94: iconst_1
      95: iadd
      96: aaload
      97: iload         5
      99: iaload
     100: aload_3
     101: iload         4
     103: aaload
     104: iload         5
     106: iconst_1
     107: iadd
     108: iaload
     109: iadd
     110: iastore
     111: iinc          5, -1
     114: goto          52
     117: iinc          4, -1
     120: goto          41
     123: aload_3
     124: iconst_0
     125: aaload
     126: iconst_0
     127: iaload
     128: ireturn

  public final int recursive(int, int);
    Code:
       0: iload_1
       1: iconst_1
       2: if_icmpeq     10
       5: iload_2
       6: iconst_1
       7: if_icmpne     12
      10: iconst_1
      11: ireturn
      12: aload_0
      13: iload_1
      14: iconst_1
      15: isub
      16: iload_2
      17: invokevirtual #25                 // Method recursive:(II)I
      20: aload_0
      21: iload_1
      22: iload_2
      23: iconst_1
      24: isub
      25: invokevirtual #25                 // Method recursive:(II)I
      28: iadd
      29: ireturn
}


package leetcode

/**
 * # 441. Arranging Coins
 * [https://leetcode.com/problems/arranging-coins/](https://leetcode.com/problems/arranging-coins/)
 *
 * ### You have n coins and you want to build a staircase with these coins.
 * ### The staircase consists of k rows where the ith row has exactly i coins.
 * ### The last row of the staircase may be incomplete.
 * ### Given the integer n, return the number of complete rows of the staircase you will build.
 *
 * ### Constraints:
 *   1 <= n <= 2^31 - 1
 */
class ArrangingCoins {

    /**
     * Brute force solution: checking every step one by one while we have enough coins for step's capacity
     */
    fun bruteForce(n: Int): Int {
        var coins = n
        if (coins <= 1) {
            return coins
        }
        var completedSteps = 0
        var currentStep = 1
        while (currentStep <= coins) {
            completedSteps = currentStep
            coins -= currentStep
            currentStep++
        }
        return completedSteps
    }

    /**
     * Find the maximum K such that (K*(K+1))/2 <= N
     * Using Long type due to constraints
     */
    fun binarySearch(n: Int): Int {
        var left: Long = 0
        var right = n.toLong()
        var k: Long
        var curr: Long
        while (left <= right) {
            k = left + (right - left) / 2
            curr = k * (k + 1) / 2
            if (curr == n.toLong()) {
                return k.toInt()
            }
            if (n < curr) {
                right = k - 1
            } else {
                left = k + 1
            }
        }
        return right.toInt()
    }
}

Compiled from "ArrangingCoins.kt"
public final class leetcode.ArrangingCoins {
  public leetcode.ArrangingCoins();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int bruteForce(int);
    Code:
       0: iload_1
       1: istore_2
       2: iload_2
       3: iconst_1
       4: if_icmpgt     9
       7: iload_2
       8: ireturn
       9: iconst_0
      10: istore_3
      11: iconst_1
      12: istore        4
      14: iload         4
      16: iload_2
      17: if_icmpgt     34
      20: iload         4
      22: istore_3
      23: iload_2
      24: iload         4
      26: isub
      27: istore_2
      28: iinc          4, 1
      31: goto          14
      34: iload_3
      35: ireturn

  public final int binarySearch(int);
    Code:
       0: lconst_0
       1: lstore_2
       2: iload_1
       3: i2l
       4: lstore        4
       6: lconst_0
       7: lstore        6
       9: lconst_0
      10: lstore        8
      12: lload_2
      13: lload         4
      15: lcmp
      16: ifgt          79
      19: lload_2
      20: lload         4
      22: lload_2
      23: lsub
      24: iconst_2
      25: i2l
      26: ldiv
      27: ladd
      28: lstore        6
      30: lload         6
      32: lload         6
      34: lconst_1
      35: ladd
      36: lmul
      37: iconst_2
      38: i2l
      39: ldiv
      40: lstore        8
      42: lload         8
      44: iload_1
      45: i2l
      46: lcmp
      47: ifne          54
      50: lload         6
      52: l2i
      53: ireturn
      54: iload_1
      55: i2l
      56: lload         8
      58: lcmp
      59: ifge          71
      62: lload         6
      64: lconst_1
      65: lsub
      66: lstore        4
      68: goto          12
      71: lload         6
      73: lconst_1
      74: ladd
      75: lstore_2
      76: goto          12
      79: lload         4
      81: l2i
      82: ireturn
}


package adventofcode.day2

import java.io.File

/**
 *
 */
fun main(args: Array<String>) {
    val input = File(ClassLoader.getSystemResource("day-02-input.txt").file).readLines()

    // part 1
    val (twos, threes, checksum) = calculateChecksum(input)
    println("$twos x $threes = $checksum")

    // part 2
    val firstDiff = findCloseIds(input).first()
    val result = firstDiff.first.removeRange(firstDiff.indices.first()..firstDiff.indices.first())
    println("${result}")
}

private fun calculateChecksum(input: List<String>): Triple<Int, Int, Int> {
    val countedBoxIds = input.map { toLetterCount(it) }
    val twosCount = countedBoxIds.filter { it.countsForTwo() }.size
    val threesCount = countedBoxIds.filter { it.countsForThree() }.size

    return Triple(twosCount, threesCount, twosCount * threesCount)
}

private fun toLetterCount(boxId: String): BoxIdLetterCount {
    val letterCounts = boxId.toList()
        .groupingBy { it }
        .eachCount()
        .map { LetterCount(it.key, it.value) }

    return BoxIdLetterCount(boxId, letterCounts)
}

data class BoxIdLetterCount(val boxId: String, val letters: List<LetterCount>) {
    fun countsForTwo() = letters.find { it.count == 2 } != null
    fun countsForThree() = letters.find { it.count == 3 } != null
}

class LetterCount(val letter: Char, val count: Int) {

}

private fun findCloseIds(boxIds: List<String>): MutableList<Diff> {
    val boxIdsDifferentBy1 = mutableListOf<Diff>()

    for (first in boxIds) {
        for (second in boxIds) {
            val diff = first.diff(second)

            if (diff.indices.size == 1) {
                boxIdsDifferentBy1.add(diff)
            }
        }
    }

    return boxIdsDifferentBy1
}

fun String.diff(other: String): Diff {
    val indices = mutableListOf<Int>()
    for (i in 0 until Math.min(this.length, other.length)) {
        if (this[i] != other[i]) {
            indices.add(i)
        }
    }

    return Diff(this, other, indices)
}

data class Diff(val first:String, val second:String, val indices:List<Int>)

Compiled from "_Collections.kt"
public final class adventofcode.day2.Day2Kt$toLetterCount$$inlined$groupingBy$1 implements kotlin.collections.Grouping<java.lang.Character, java.lang.Character> {
  final java.lang.Iterable $this_groupingBy;

  public adventofcode.day2.Day2Kt$toLetterCount$$inlined$groupingBy$1(java.lang.Iterable);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #18                 // Field $this_groupingBy:Ljava/lang/Iterable;
       5: aload_0
       6: invokespecial #21                 // Method java/lang/Object."<init>":()V
       9: return

  public java.util.Iterator<java.lang.Character> sourceIterator();
    Code:
       0: aload_0
       1: getfield      #18                 // Field $this_groupingBy:Ljava/lang/Iterable;
       4: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
       9: areturn

  public java.lang.Character keyOf(java.lang.Character);
    Code:
       0: aload_1
       1: checkcast     #37                 // class java/lang/Character
       4: invokevirtual #41                 // Method java/lang/Character.charValue:()C
       7: istore_2
       8: iconst_0
       9: istore_3
      10: iload_2
      11: invokestatic  #45                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      14: areturn
}

Compiled from "Day2.kt"
public final class adventofcode.day2.Day2Kt {
  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String args
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #17                 // class java/io/File
       9: dup
      10: ldc           #19                 // String day-02-input.txt
      12: invokestatic  #25                 // Method java/lang/ClassLoader.getSystemResource:(Ljava/lang/String;)Ljava/net/URL;
      15: invokevirtual #31                 // Method java/net/URL.getFile:()Ljava/lang/String;
      18: invokespecial #35                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      21: aconst_null
      22: iconst_1
      23: aconst_null
      24: invokestatic  #41                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      27: astore_1
      28: aload_1
      29: invokestatic  #45                 // Method calculateChecksum:(Ljava/util/List;)Lkotlin/Triple;
      32: astore_2
      33: aload_2
      34: invokevirtual #51                 // Method kotlin/Triple.component1:()Ljava/lang/Object;
      37: checkcast     #53                 // class java/lang/Number
      40: invokevirtual #57                 // Method java/lang/Number.intValue:()I
      43: istore_3
      44: aload_2
      45: invokevirtual #60                 // Method kotlin/Triple.component2:()Ljava/lang/Object;
      48: checkcast     #53                 // class java/lang/Number
      51: invokevirtual #57                 // Method java/lang/Number.intValue:()I
      54: istore        4
      56: aload_2
      57: invokevirtual #63                 // Method kotlin/Triple.component3:()Ljava/lang/Object;
      60: checkcast     #53                 // class java/lang/Number
      63: invokevirtual #57                 // Method java/lang/Number.intValue:()I
      66: istore        5
      68: new           #65                 // class java/lang/StringBuilder
      71: dup
      72: invokespecial #68                 // Method java/lang/StringBuilder."<init>":()V
      75: iload_3
      76: invokevirtual #72                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      79: ldc           #74                 // String  x
      81: invokevirtual #77                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      84: iload         4
      86: invokevirtual #72                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      89: ldc           #79                 // String  =
      91: invokevirtual #77                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      94: iload         5
      96: invokevirtual #72                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      99: invokevirtual #82                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     102: getstatic     #88                 // Field java/lang/System.out:Ljava/io/PrintStream;
     105: swap
     106: invokevirtual #94                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     109: aload_1
     110: invokestatic  #98                 // Method findCloseIds:(Ljava/util/List;)Ljava/util/List;
     113: invokestatic  #104                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     116: checkcast     #106                // class adventofcode/day2/Diff
     119: astore        6
     121: aload         6
     123: invokevirtual #109                // Method adventofcode/day2/Diff.getFirst:()Ljava/lang/String;
     126: astore        8
     128: new           #111                // class kotlin/ranges/IntRange
     131: dup
     132: aload         6
     134: invokevirtual #115                // Method adventofcode/day2/Diff.getIndices:()Ljava/util/List;
     137: invokestatic  #104                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     140: checkcast     #53                 // class java/lang/Number
     143: invokevirtual #57                 // Method java/lang/Number.intValue:()I
     146: aload         6
     148: invokevirtual #115                // Method adventofcode/day2/Diff.getIndices:()Ljava/util/List;
     151: invokestatic  #104                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     154: checkcast     #53                 // class java/lang/Number
     157: invokevirtual #57                 // Method java/lang/Number.intValue:()I
     160: invokespecial #118                // Method kotlin/ranges/IntRange."<init>":(II)V
     163: astore        9
     165: aload         8
     167: checkcast     #120                // class java/lang/CharSequence
     170: aload         9
     172: invokestatic  #126                // Method kotlin/text/StringsKt.removeRange:(Ljava/lang/CharSequence;Lkotlin/ranges/IntRange;)Ljava/lang/CharSequence;
     175: invokevirtual #127                // Method java/lang/Object.toString:()Ljava/lang/String;
     178: astore        7
     180: aload         7
     182: invokestatic  #133                // Method java/lang/String.valueOf:(Ljava/lang/Object;)Ljava/lang/String;
     185: getstatic     #88                 // Field java/lang/System.out:Ljava/io/PrintStream;
     188: swap
     189: invokevirtual #94                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     192: return

  private static final kotlin.Triple<java.lang.Integer, java.lang.Integer, java.lang.Integer> calculateChecksum(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #147                // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: astore        4
      10: new           #149                // class java/util/ArrayList
      13: dup
      14: aload_2
      15: bipush        10
      17: invokestatic  #153                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      20: invokespecial #156                // Method java/util/ArrayList."<init>":(I)V
      23: checkcast     #158                // class java/util/Collection
      26: astore        5
      28: iconst_0
      29: istore        6
      31: aload         4
      33: invokeinterface #162,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      38: astore        7
      40: aload         7
      42: invokeinterface #168,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      47: ifeq          90
      50: aload         7
      52: invokeinterface #171,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      57: astore        8
      59: aload         5
      61: aload         8
      63: checkcast     #129                // class java/lang/String
      66: astore        9
      68: astore        13
      70: iconst_0
      71: istore        10
      73: aload         9
      75: invokestatic  #175                // Method toLetterCount:(Ljava/lang/String;)Ladventofcode/day2/BoxIdLetterCount;
      78: aload         13
      80: swap
      81: invokeinterface #179,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      86: pop
      87: goto          40
      90: aload         5
      92: checkcast     #181                // class java/util/List
      95: nop
      96: astore_1
      97: aload_1
      98: checkcast     #147                // class java/lang/Iterable
     101: astore_3
     102: iconst_0
     103: istore        4
     105: aload_3
     106: astore        5
     108: new           #149                // class java/util/ArrayList
     111: dup
     112: invokespecial #182                // Method java/util/ArrayList."<init>":()V
     115: checkcast     #158                // class java/util/Collection
     118: astore        6
     120: iconst_0
     121: istore        7
     123: aload         5
     125: invokeinterface #162,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     130: astore        8
     132: aload         8
     134: invokeinterface #168,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     139: ifeq          182
     142: aload         8
     144: invokeinterface #171,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     149: astore        9
     151: aload         9
     153: checkcast     #184                // class adventofcode/day2/BoxIdLetterCount
     156: astore        10
     158: iconst_0
     159: istore        11
     161: aload         10
     163: invokevirtual #187                // Method adventofcode/day2/BoxIdLetterCount.countsForTwo:()Z
     166: ifeq          132
     169: aload         6
     171: aload         9
     173: invokeinterface #179,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     178: pop
     179: goto          132
     182: aload         6
     184: checkcast     #181                // class java/util/List
     187: nop
     188: invokeinterface #190,  1          // InterfaceMethod java/util/List.size:()I
     193: istore_2
     194: aload_1
     195: checkcast     #147                // class java/lang/Iterable
     198: astore        4
     200: iconst_0
     201: istore        5
     203: aload         4
     205: astore        6
     207: new           #149                // class java/util/ArrayList
     210: dup
     211: invokespecial #182                // Method java/util/ArrayList."<init>":()V
     214: checkcast     #158                // class java/util/Collection
     217: astore        7
     219: iconst_0
     220: istore        8
     222: aload         6
     224: invokeinterface #162,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     229: astore        9
     231: aload         9
     233: invokeinterface #168,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     238: ifeq          281
     241: aload         9
     243: invokeinterface #171,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     248: astore        10
     250: aload         10
     252: checkcast     #184                // class adventofcode/day2/BoxIdLetterCount
     255: astore        11
     257: iconst_0
     258: istore        12
     260: aload         11
     262: invokevirtual #193                // Method adventofcode/day2/BoxIdLetterCount.countsForThree:()Z
     265: ifeq          231
     268: aload         7
     270: aload         10
     272: invokeinterface #179,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     277: pop
     278: goto          231
     281: aload         7
     283: checkcast     #181                // class java/util/List
     286: nop
     287: invokeinterface #190,  1          // InterfaceMethod java/util/List.size:()I
     292: istore_3
     293: new           #47                 // class kotlin/Triple
     296: dup
     297: iload_2
     298: invokestatic  #198                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     301: iload_3
     302: invokestatic  #198                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     305: iload_2
     306: iload_3
     307: imul
     308: invokestatic  #198                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     311: invokespecial #201                // Method kotlin/Triple."<init>":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
     314: areturn

  private static final adventofcode.day2.BoxIdLetterCount toLetterCount(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #120                // class java/lang/CharSequence
       4: invokestatic  #227                // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;
       7: checkcast     #147                // class java/lang/Iterable
      10: astore_2
      11: nop
      12: iconst_0
      13: istore_3
      14: new           #229                // class adventofcode/day2/Day2Kt$toLetterCount$$inlined$groupingBy$1
      17: dup
      18: aload_2
      19: invokespecial #232                // Method adventofcode/day2/Day2Kt$toLetterCount$$inlined$groupingBy$1."<init>":(Ljava/lang/Iterable;)V
      22: checkcast     #234                // class kotlin/collections/Grouping
      25: invokestatic  #240                // Method kotlin/collections/GroupingKt.eachCount:(Lkotlin/collections/Grouping;)Ljava/util/Map;
      28: astore_2
      29: nop
      30: iconst_0
      31: istore_3
      32: aload_2
      33: astore        4
      35: new           #149                // class java/util/ArrayList
      38: dup
      39: aload_2
      40: invokeinterface #243,  1          // InterfaceMethod java/util/Map.size:()I
      45: invokespecial #156                // Method java/util/ArrayList."<init>":(I)V
      48: checkcast     #158                // class java/util/Collection
      51: astore        5
      53: iconst_0
      54: istore        6
      56: aload         4
      58: invokeinterface #247,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
      63: invokeinterface #250,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
      68: astore        7
      70: aload         7
      72: invokeinterface #168,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      77: ifeq          148
      80: aload         7
      82: invokeinterface #171,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      87: checkcast     #252                // class java/util/Map$Entry
      90: astore        8
      92: aload         5
      94: aload         8
      96: astore        9
      98: astore        11
     100: iconst_0
     101: istore        10
     103: new           #254                // class adventofcode/day2/LetterCount
     106: dup
     107: aload         9
     109: invokeinterface #257,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     114: checkcast     #259                // class java/lang/Character
     117: invokevirtual #263                // Method java/lang/Character.charValue:()C
     120: aload         9
     122: invokeinterface #266,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     127: checkcast     #53                 // class java/lang/Number
     130: invokevirtual #57                 // Method java/lang/Number.intValue:()I
     133: invokespecial #269                // Method adventofcode/day2/LetterCount."<init>":(CI)V
     136: aload         11
     138: swap
     139: invokeinterface #179,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     144: pop
     145: goto          70
     148: aload         5
     150: checkcast     #181                // class java/util/List
     153: nop
     154: astore_1
     155: new           #184                // class adventofcode/day2/BoxIdLetterCount
     158: dup
     159: aload_0
     160: aload_1
     161: invokespecial #272                // Method adventofcode/day2/BoxIdLetterCount."<init>":(Ljava/lang/String;Ljava/util/List;)V
     164: areturn

  private static final java.util.List<adventofcode.day2.Diff> findCloseIds(java.util.List<java.lang.String>);
    Code:
       0: new           #149                // class java/util/ArrayList
       3: dup
       4: invokespecial #182                // Method java/util/ArrayList."<init>":()V
       7: checkcast     #181                // class java/util/List
      10: astore_1
      11: aload_0
      12: invokeinterface #281,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      17: astore_2
      18: aload_2
      19: invokeinterface #168,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      24: ifeq          101
      27: aload_2
      28: invokeinterface #171,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      33: checkcast     #129                // class java/lang/String
      36: astore_3
      37: aload_0
      38: invokeinterface #281,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      43: astore        4
      45: aload         4
      47: invokeinterface #168,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      52: ifeq          18
      55: aload         4
      57: invokeinterface #171,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      62: checkcast     #129                // class java/lang/String
      65: astore        5
      67: aload_3
      68: aload         5
      70: invokestatic  #285                // Method diff:(Ljava/lang/String;Ljava/lang/String;)Ladventofcode/day2/Diff;
      73: astore        6
      75: aload         6
      77: invokevirtual #115                // Method adventofcode/day2/Diff.getIndices:()Ljava/util/List;
      80: invokeinterface #190,  1          // InterfaceMethod java/util/List.size:()I
      85: iconst_1
      86: if_icmpne     45
      89: aload_1
      90: aload         6
      92: invokeinterface #286,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      97: pop
      98: goto          45
     101: aload_1
     102: areturn

  public static final adventofcode.day2.Diff diff(java.lang.String, java.lang.String);
    Code:
       0: aload_0
       1: ldc_w         #291                // String <this>
       4: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: ldc_w         #293                // String other
      11: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      14: new           #149                // class java/util/ArrayList
      17: dup
      18: invokespecial #182                // Method java/util/ArrayList."<init>":()V
      21: checkcast     #181                // class java/util/List
      24: astore_2
      25: iconst_0
      26: istore_3
      27: aload_0
      28: invokevirtual #296                // Method java/lang/String.length:()I
      31: aload_1
      32: invokevirtual #296                // Method java/lang/String.length:()I
      35: invokestatic  #302                // Method java/lang/Math.min:(II)I
      38: istore        4
      40: iload_3
      41: iload         4
      43: if_icmpge     76
      46: aload_0
      47: iload_3
      48: invokevirtual #306                // Method java/lang/String.charAt:(I)C
      51: aload_1
      52: iload_3
      53: invokevirtual #306                // Method java/lang/String.charAt:(I)C
      56: if_icmpeq     70
      59: aload_2
      60: iload_3
      61: invokestatic  #198                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      64: invokeinterface #286,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      69: pop
      70: iinc          3, 1
      73: goto          40
      76: new           #106                // class adventofcode/day2/Diff
      79: dup
      80: aload_0
      81: aload_1
      82: aload_2
      83: invokespecial #309                // Method adventofcode/day2/Diff."<init>":(Ljava/lang/String;Ljava/lang/String;Ljava/util/List;)V
      86: areturn
}