import java.io.File

fun main() {

    var directions: List<String> = File("Day13.txt").readLines()
    var pairs = directions.chunked(3).map { Pair(it[0], it[1])}
    var validIndexes: MutableList<Int> = mutableListOf()
    var allPackets: MutableList<Any> = mutableListOf()
    pairs.forEachIndexed { idx, it ->
        println("== Pair ${idx+1} ==")
        var left = parseList(it.first.substring(1, it.first.length - 1))
        allPackets.add(left)
        var right = parseList(it.second.substring(1, it.second.length - 1))
        allPackets.add(right)
        println("- Compare ${left.toString()} vs ${right.toString()}")
        if(compare(left, right, 0) == 1) {
            validIndexes.add(idx+1)
        }
        println("")
    }
    //Part 1
    println("Sum Of Valid Indexes Is: ${validIndexes.sum()}")

    //Part 2
    val comparator = Comparator { a: Any, b: Any ->
        return@Comparator compare(a as MutableList<Any>, b as MutableList<Any>, 0)
    }
    allPackets.sortWith(comparator)

    var pkt2Index: Int = 0
    var pkt6Index: Int = 0

    allPackets.reversed().forEachIndexed { idx, it ->
        println("${idx+1} - ${it.toString()}")
        if (it.toString() == "[[2]]") pkt2Index = idx + 1
        if (it.toString() == "[[6]]") pkt6Index = idx + 1
    }

    println("The Decoder Key is ${pkt2Index * pkt6Index}")
}

fun compare(left: MutableList<Any>, right: MutableList<Any>, level: Int): Int {

    left.forEachIndexed { idx, leftVal ->
        if (right.size < idx + 1) {
            println("Right (${right.toString()}) List Is Shorter (${right.size}) Than Left List, Stopping Checks - INVALID ❌❌❌")
            return -1
        }
        println("${"".padStart(level*2)}- Compare ${leftVal} vs ${right[idx]}")
        if (leftVal is Int && right[idx] is Int) {
            // both Values are ints, make sure that left is <= right to continue
            if (leftVal.toString().toInt() == right[idx].toString().toInt()) {
                return@forEachIndexed
            } else if (leftVal.toString().toInt() < right[idx].toString().toInt()) {
                println("LeftVal: ${leftVal} is < than RightVal: ${right[idx]} - VALID ✅✅✅")
                return 1
            } else {
                println("LeftVal: ${leftVal} is > than RightVal: ${right[idx]} - INVALID ❌❌❌")
                return -1
            }
        } else {
            var leftToCheck: MutableList<Any> = mutableListOf()
            if (leftVal is Int) {
                leftToCheck = mutableListOf(leftVal)
            } else if (leftVal is MutableList<*>) {
                leftToCheck = leftVal as MutableList<Any>
            }
            var rightToCheck: MutableList<Any> = mutableListOf()
            if (right[idx] is Int) {
                rightToCheck = mutableListOf(right[idx])
            } else if (right[idx] is MutableList<*>) {
                rightToCheck = right[idx] as MutableList<Any>
            }
            // The Right Side is a List, Convert the Left Side To A List and Compare
            var innerCheck = compare(leftToCheck, rightToCheck, level + 1)
            if (innerCheck == 0) {
                return@forEachIndexed
            } else {
                return innerCheck
            }
        }
    }

    // According to the Rules we shouldn't get here as our ultimate check??
    if(left.size < right.size) {
        println("Left List Is Smaller Than Right List, But All Items Are The Same - VALID ✅✅✅")
        return 1
    } else {
        return 0
    }
}

fun parseList(str: String): MutableList<Any> {
    //println("Parser Started for | ${str}")
    var newList: MutableList<Any> = mutableListOf()
    var idx: Int = 0
    while (idx < str.length) {
        //println("Idx ${idx.toString()} | Char ${str.get(idx).toString()}")
        if (str.get(idx) == '[') {
            var endBracketPos = getValidCloseBracket(str.substring(idx, str.length))
            //println("Found Valid Close Bracket | Start ${idx} | End ${endBracketPos}")
            newList.add(parseList(str.substring(idx+1, idx+endBracketPos)))
            idx = idx+endBracketPos + 1
        } else if (listOf(',',']').contains(str.get(idx))) {
            idx++
        }
        else {
            // println(str)
            //grab addl characters
            var tmpstr = str.get(idx).toString()
            // println("tmpstr ${tmpstr}")
            var tmpidx = idx
            // println("tmpidx ${tmpidx}")

            while (str.length > tmpidx+1 && !listOf('[',']',',').contains(str.get(tmpidx+1))) {
                //println("NextChar: ${str.get(tmpidx+1)}")
                tmpstr += str.get(tmpidx+1).toString()
                tmpidx++
            }
            newList.add(tmpstr.toInt())
            idx++
        }
    }
    return newList
}

fun getValidCloseBracket(str: String): Int {
    //println("Getting Close Bracket Position for ${str}")
    var brackets: MutableList<Char> = mutableListOf()
    str.toMutableList().forEachIndexed { idx, char ->
        if (char == '[') {
            brackets.add('[')
        } else if (char == ']') {
            if (brackets.last() == '[') brackets.removeLast()
            if (brackets.size == 0) { return idx }
        }
    }
    return -1
}

Compiled from "Day13.kt"
public final class Day13Kt {
  public static final void main();
    Code:
       0: new           #8                  // class java/io/File
       3: dup
       4: ldc           #10                 // String Day13.txt
       6: invokespecial #14                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #20                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      15: astore_0
      16: aload_0
      17: checkcast     #22                 // class java/lang/Iterable
      20: iconst_3
      21: invokestatic  #28                 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;
      24: checkcast     #22                 // class java/lang/Iterable
      27: astore_2
      28: iconst_0
      29: istore_3
      30: aload_2
      31: astore        4
      33: new           #30                 // class java/util/ArrayList
      36: dup
      37: aload_2
      38: bipush        10
      40: invokestatic  #34                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      43: invokespecial #37                 // Method java/util/ArrayList."<init>":(I)V
      46: checkcast     #39                 // class java/util/Collection
      49: astore        5
      51: iconst_0
      52: istore        6
      54: aload         4
      56: invokeinterface #43,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      61: astore        7
      63: aload         7
      65: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      70: ifeq          131
      73: aload         7
      75: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      80: astore        8
      82: aload         5
      84: aload         8
      86: checkcast     #55                 // class java/util/List
      89: astore        9
      91: astore        16
      93: iconst_0
      94: istore        10
      96: new           #57                 // class kotlin/Pair
      99: dup
     100: aload         9
     102: iconst_0
     103: invokeinterface #61,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     108: aload         9
     110: iconst_1
     111: invokeinterface #61,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     116: invokespecial #64                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     119: aload         16
     121: swap
     122: invokeinterface #68,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     127: pop
     128: goto          63
     131: aload         5
     133: checkcast     #55                 // class java/util/List
     136: nop
     137: astore_1
     138: aconst_null
     139: astore_2
     140: new           #30                 // class java/util/ArrayList
     143: dup
     144: invokespecial #70                 // Method java/util/ArrayList."<init>":()V
     147: checkcast     #55                 // class java/util/List
     150: astore_2
     151: aconst_null
     152: astore_3
     153: new           #30                 // class java/util/ArrayList
     156: dup
     157: invokespecial #70                 // Method java/util/ArrayList."<init>":()V
     160: checkcast     #55                 // class java/util/List
     163: astore_3
     164: aload_1
     165: checkcast     #22                 // class java/lang/Iterable
     168: astore        4
     170: iconst_0
     171: istore        5
     173: iconst_0
     174: istore        6
     176: aload         4
     178: invokeinterface #43,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     183: astore        7
     185: aload         7
     187: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     192: ifeq          434
     195: aload         7
     197: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     202: astore        8
     204: iload         6
     206: iinc          6, 1
     209: istore        9
     211: iload         9
     213: ifge          219
     216: invokestatic  #73                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     219: iload         9
     221: aload         8
     223: checkcast     #57                 // class kotlin/Pair
     226: astore        10
     228: istore        11
     230: iconst_0
     231: istore        12
     233: new           #75                 // class java/lang/StringBuilder
     236: dup
     237: invokespecial #76                 // Method java/lang/StringBuilder."<init>":()V
     240: ldc           #78                 // String == Pair
     242: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     245: iload         11
     247: iconst_1
     248: iadd
     249: invokevirtual #85                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     252: ldc           #87                 // String  ==
     254: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     257: invokevirtual #91                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     260: getstatic     #97                 // Field java/lang/System.out:Ljava/io/PrintStream;
     263: swap
     264: invokevirtual #103                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     267: aload         10
     269: invokevirtual #106                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     272: checkcast     #108                // class java/lang/String
     275: iconst_1
     276: aload         10
     278: invokevirtual #106                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     281: checkcast     #108                // class java/lang/String
     284: invokevirtual #112                // Method java/lang/String.length:()I
     287: iconst_1
     288: isub
     289: invokevirtual #116                // Method java/lang/String.substring:(II)Ljava/lang/String;
     292: dup
     293: ldc           #118                // String substring(...)
     295: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     298: invokestatic  #128                // Method parseList:(Ljava/lang/String;)Ljava/util/List;
     301: astore        13
     303: aload_3
     304: aload         13
     306: invokeinterface #129,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     311: pop
     312: aload         10
     314: invokevirtual #132                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     317: checkcast     #108                // class java/lang/String
     320: iconst_1
     321: aload         10
     323: invokevirtual #132                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     326: checkcast     #108                // class java/lang/String
     329: invokevirtual #112                // Method java/lang/String.length:()I
     332: iconst_1
     333: isub
     334: invokevirtual #116                // Method java/lang/String.substring:(II)Ljava/lang/String;
     337: dup
     338: ldc           #118                // String substring(...)
     340: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     343: invokestatic  #128                // Method parseList:(Ljava/lang/String;)Ljava/util/List;
     346: astore        14
     348: aload_3
     349: aload         14
     351: invokeinterface #129,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     356: pop
     357: new           #75                 // class java/lang/StringBuilder
     360: dup
     361: invokespecial #76                 // Method java/lang/StringBuilder."<init>":()V
     364: ldc           #134                // String - Compare
     366: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     369: aload         13
     371: invokevirtual #137                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     374: ldc           #139                // String  vs
     376: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     379: aload         14
     381: invokevirtual #137                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     384: invokevirtual #91                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     387: getstatic     #97                 // Field java/lang/System.out:Ljava/io/PrintStream;
     390: swap
     391: invokevirtual #103                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     394: aload         13
     396: aload         14
     398: iconst_0
     399: invokestatic  #143                // Method compare:(Ljava/util/List;Ljava/util/List;I)I
     402: iconst_1
     403: if_icmpne     420
     406: aload_2
     407: iload         11
     409: iconst_1
     410: iadd
     411: invokestatic  #149                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     414: invokeinterface #129,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     419: pop
     420: ldc           #151                // String
     422: getstatic     #97                 // Field java/lang/System.out:Ljava/io/PrintStream;
     425: swap
     426: invokevirtual #103                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     429: nop
     430: nop
     431: goto          185
     434: nop
     435: new           #75                 // class java/lang/StringBuilder
     438: dup
     439: invokespecial #76                 // Method java/lang/StringBuilder."<init>":()V
     442: ldc           #153                // String Sum Of Valid Indexes Is:
     444: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     447: aload_2
     448: checkcast     #22                 // class java/lang/Iterable
     451: invokestatic  #157                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     454: invokevirtual #85                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     457: invokevirtual #91                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     460: getstatic     #97                 // Field java/lang/System.out:Ljava/io/PrintStream;
     463: swap
     464: invokevirtual #103                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     467: invokedynamic #173,  0            // InvokeDynamic #0:compare:()Ljava/util/Comparator;
     472: astore        4
     474: aload_3
     475: aload         4
     477: invokestatic  #177                // Method kotlin/collections/CollectionsKt.sortWith:(Ljava/util/List;Ljava/util/Comparator;)V
     480: iconst_0
     481: istore        5
     483: iconst_0
     484: istore        6
     486: aload_3
     487: checkcast     #22                 // class java/lang/Iterable
     490: invokestatic  #181                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
     493: checkcast     #22                 // class java/lang/Iterable
     496: astore        7
     498: iconst_0
     499: istore        8
     501: iconst_0
     502: istore        9
     504: aload         7
     506: invokeinterface #43,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     511: astore        10
     513: aload         10
     515: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     520: ifeq          635
     523: aload         10
     525: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     530: astore        11
     532: iload         9
     534: iinc          9, 1
     537: istore        12
     539: iload         12
     541: ifge          547
     544: invokestatic  #73                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     547: iload         12
     549: aload         11
     551: astore        13
     553: istore        14
     555: iconst_0
     556: istore        15
     558: new           #75                 // class java/lang/StringBuilder
     561: dup
     562: invokespecial #76                 // Method java/lang/StringBuilder."<init>":()V
     565: iload         14
     567: iconst_1
     568: iadd
     569: invokevirtual #85                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     572: ldc           #183                // String  -
     574: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     577: aload         13
     579: invokevirtual #137                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     582: invokevirtual #91                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     585: getstatic     #97                 // Field java/lang/System.out:Ljava/io/PrintStream;
     588: swap
     589: invokevirtual #103                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     592: aload         13
     594: invokevirtual #184                // Method java/lang/Object.toString:()Ljava/lang/String;
     597: ldc           #186                // String [[2]]
     599: invokestatic  #190                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     602: ifeq          611
     605: iload         14
     607: iconst_1
     608: iadd
     609: istore        5
     611: aload         13
     613: invokevirtual #184                // Method java/lang/Object.toString:()Ljava/lang/String;
     616: ldc           #192                // String [[6]]
     618: invokestatic  #190                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     621: ifeq          630
     624: iload         14
     626: iconst_1
     627: iadd
     628: istore        6
     630: nop
     631: nop
     632: goto          513
     635: nop
     636: new           #75                 // class java/lang/StringBuilder
     639: dup
     640: invokespecial #76                 // Method java/lang/StringBuilder."<init>":()V
     643: ldc           #194                // String The Decoder Key is
     645: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     648: iload         5
     650: iload         6
     652: imul
     653: invokevirtual #85                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     656: invokevirtual #91                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     659: getstatic     #97                 // Field java/lang/System.out:Ljava/io/PrintStream;
     662: swap
     663: invokevirtual #103                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     666: return

  public static final int compare(java.util.List<java.lang.Object>, java.util.List<java.lang.Object>, int);
    Code:
       0: aload_0
       1: ldc           #230                // String left
       3: invokestatic  #233                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #234                // String right
       9: invokestatic  #233                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: checkcast     #22                 // class java/lang/Iterable
      16: astore_3
      17: iconst_0
      18: istore        4
      20: iconst_0
      21: istore        5
      23: aload_3
      24: invokeinterface #43,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      29: astore        6
      31: aload         6
      33: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      38: ifeq          577
      41: aload         6
      43: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      48: astore        7
      50: iload         5
      52: iinc          5, 1
      55: istore        8
      57: iload         8
      59: ifge          65
      62: invokestatic  #73                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      65: iload         8
      67: aload         7
      69: astore        9
      71: istore        10
      73: iconst_0
      74: istore        11
      76: aload_1
      77: invokeinterface #237,  1          // InterfaceMethod java/util/List.size:()I
      82: iload         10
      84: iconst_1
      85: iadd
      86: if_icmpge     136
      89: new           #75                 // class java/lang/StringBuilder
      92: dup
      93: invokespecial #76                 // Method java/lang/StringBuilder."<init>":()V
      96: ldc           #239                // String Right (
      98: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     101: aload_1
     102: invokevirtual #137                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     105: ldc           #241                // String ) List Is Shorter (
     107: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     110: aload_1
     111: invokeinterface #237,  1          // InterfaceMethod java/util/List.size:()I
     116: invokevirtual #85                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     119: ldc           #243                // String ) Than Left List, Stopping Checks - INVALID ❌❌❌
     121: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     124: invokevirtual #91                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     127: getstatic     #97                 // Field java/lang/System.out:Ljava/io/PrintStream;
     130: swap
     131: invokevirtual #103                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     134: iconst_m1
     135: ireturn
     136: new           #75                 // class java/lang/StringBuilder
     139: dup
     140: invokespecial #76                 // Method java/lang/StringBuilder."<init>":()V
     143: ldc           #151                // String
     145: iload_2
     146: iconst_2
     147: imul
     148: iconst_0
     149: iconst_2
     150: aconst_null
     151: invokestatic  #249                // Method kotlin/text/StringsKt.padStart$default:(Ljava/lang/String;ICILjava/lang/Object;)Ljava/lang/String;
     154: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     157: ldc           #134                // String - Compare
     159: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     162: aload         9
     164: invokevirtual #137                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     167: ldc           #139                // String  vs
     169: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     172: aload_1
     173: iload         10
     175: invokeinterface #61,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     180: invokevirtual #137                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     183: invokevirtual #91                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     186: getstatic     #97                 // Field java/lang/System.out:Ljava/io/PrintStream;
     189: swap
     190: invokevirtual #103                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     193: aload         9
     195: instanceof    #145                // class java/lang/Integer
     198: ifeq          398
     201: aload_1
     202: iload         10
     204: invokeinterface #61,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     209: instanceof    #145                // class java/lang/Integer
     212: ifeq          398
     215: aload         9
     217: checkcast     #251                // class java/lang/Number
     220: invokevirtual #254                // Method java/lang/Number.intValue:()I
     223: invokestatic  #257                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     226: invokestatic  #261                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     229: aload_1
     230: iload         10
     232: invokeinterface #61,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     237: invokevirtual #184                // Method java/lang/Object.toString:()Ljava/lang/String;
     240: invokestatic  #261                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     243: if_icmpne     249
     246: goto          573
     249: aload         9
     251: checkcast     #251                // class java/lang/Number
     254: invokevirtual #254                // Method java/lang/Number.intValue:()I
     257: invokestatic  #257                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     260: invokestatic  #261                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     263: aload_1
     264: iload         10
     266: invokeinterface #61,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     271: invokevirtual #184                // Method java/lang/Object.toString:()Ljava/lang/String;
     274: invokestatic  #261                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     277: if_icmpge     339
     280: new           #75                 // class java/lang/StringBuilder
     283: dup
     284: invokespecial #76                 // Method java/lang/StringBuilder."<init>":()V
     287: ldc_w         #263                // String LeftVal:
     290: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     293: aload         9
     295: checkcast     #251                // class java/lang/Number
     298: invokevirtual #254                // Method java/lang/Number.intValue:()I
     301: invokevirtual #85                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     304: ldc_w         #265                // String  is < than RightVal:
     307: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     310: aload_1
     311: iload         10
     313: invokeinterface #61,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     318: invokevirtual #137                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     321: ldc_w         #267                // String  - VALID ✅✅✅
     324: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     327: invokevirtual #91                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     330: getstatic     #97                 // Field java/lang/System.out:Ljava/io/PrintStream;
     333: swap
     334: invokevirtual #103                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     337: iconst_1
     338: ireturn
     339: new           #75                 // class java/lang/StringBuilder
     342: dup
     343: invokespecial #76                 // Method java/lang/StringBuilder."<init>":()V
     346: ldc_w         #263                // String LeftVal:
     349: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     352: aload         9
     354: checkcast     #251                // class java/lang/Number
     357: invokevirtual #254                // Method java/lang/Number.intValue:()I
     360: invokevirtual #85                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     363: ldc_w         #269                // String  is > than RightVal:
     366: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     369: aload_1
     370: iload         10
     372: invokeinterface #61,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     377: invokevirtual #137                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     380: ldc_w         #271                // String  - INVALID ❌❌❌
     383: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     386: invokevirtual #91                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     389: getstatic     #97                 // Field java/lang/System.out:Ljava/io/PrintStream;
     392: swap
     393: invokevirtual #103                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     396: iconst_m1
     397: ireturn
     398: new           #30                 // class java/util/ArrayList
     401: dup
     402: invokespecial #70                 // Method java/util/ArrayList."<init>":()V
     405: checkcast     #55                 // class java/util/List
     408: astore        12
     410: aload         9
     412: instanceof    #145                // class java/lang/Integer
     415: ifeq          440
     418: iconst_1
     419: anewarray     #4                  // class java/lang/Object
     422: astore        13
     424: aload         13
     426: iconst_0
     427: aload         9
     429: aastore
     430: aload         13
     432: invokestatic  #275                // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
     435: astore        12
     437: goto          462
     440: aload         9
     442: invokestatic  #280                // Method kotlin/jvm/internal/TypeIntrinsics.isMutableList:(Ljava/lang/Object;)Z
     445: ifeq          462
     448: aload         9
     450: dup
     451: ldc_w         #282                // String null cannot be cast to non-null type kotlin.collections.MutableList<kotlin.Any>
     454: invokestatic  #285                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V
     457: invokestatic  #289                // Method kotlin/jvm/internal/TypeIntrinsics.asMutableList:(Ljava/lang/Object;)Ljava/util/List;
     460: astore        12
     462: new           #30                 // class java/util/ArrayList
     465: dup
     466: invokespecial #70                 // Method java/util/ArrayList."<init>":()V
     469: checkcast     #55                 // class java/util/List
     472: astore        13
     474: aload_1
     475: iload         10
     477: invokeinterface #61,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     482: instanceof    #145                // class java/lang/Integer
     485: ifeq          516
     488: iconst_1
     489: anewarray     #4                  // class java/lang/Object
     492: astore        14
     494: aload         14
     496: iconst_0
     497: aload_1
     498: iload         10
     500: invokeinterface #61,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     505: aastore
     506: aload         14
     508: invokestatic  #275                // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
     511: astore        13
     513: goto          550
     516: aload_1
     517: iload         10
     519: invokeinterface #61,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     524: invokestatic  #280                // Method kotlin/jvm/internal/TypeIntrinsics.isMutableList:(Ljava/lang/Object;)Z
     527: ifeq          550
     530: aload_1
     531: iload         10
     533: invokeinterface #61,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     538: dup
     539: ldc_w         #282                // String null cannot be cast to non-null type kotlin.collections.MutableList<kotlin.Any>
     542: invokestatic  #285                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V
     545: invokestatic  #289                // Method kotlin/jvm/internal/TypeIntrinsics.asMutableList:(Ljava/lang/Object;)Ljava/util/List;
     548: astore        13
     550: aload         12
     552: aload         13
     554: iload_2
     555: iconst_1
     556: iadd
     557: invokestatic  #143                // Method compare:(Ljava/util/List;Ljava/util/List;I)I
     560: istore        14
     562: iload         14
     564: ifne          570
     567: goto          573
     570: iload         14
     572: ireturn
     573: nop
     574: goto          31
     577: nop
     578: aload_0
     579: invokeinterface #237,  1          // InterfaceMethod java/util/List.size:()I
     584: aload_1
     585: invokeinterface #237,  1          // InterfaceMethod java/util/List.size:()I
     590: if_icmpge     605
     593: ldc_w         #291                // String Left List Is Smaller Than Right List, But All Items Are The Same - VALID ✅✅✅
     596: getstatic     #97                 // Field java/lang/System.out:Ljava/io/PrintStream;
     599: swap
     600: invokevirtual #103                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     603: iconst_1
     604: ireturn
     605: iconst_0
     606: ireturn

  public static final java.util.List<java.lang.Object> parseList(java.lang.String);
    Code:
       0: aload_0
       1: ldc_w         #300                // String str
       4: invokestatic  #233                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: new           #30                 // class java/util/ArrayList
      10: dup
      11: invokespecial #70                 // Method java/util/ArrayList."<init>":()V
      14: checkcast     #55                 // class java/util/List
      17: astore_1
      18: iconst_0
      19: istore_2
      20: iload_2
      21: aload_0
      22: invokevirtual #112                // Method java/lang/String.length:()I
      25: if_icmpge     275
      28: aload_0
      29: iload_2
      30: invokevirtual #304                // Method java/lang/String.charAt:(I)C
      33: bipush        91
      35: if_icmpne     92
      38: aload_0
      39: iload_2
      40: aload_0
      41: invokevirtual #112                // Method java/lang/String.length:()I
      44: invokevirtual #116                // Method java/lang/String.substring:(II)Ljava/lang/String;
      47: dup
      48: ldc           #118                // String substring(...)
      50: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      53: invokestatic  #307                // Method getValidCloseBracket:(Ljava/lang/String;)I
      56: istore_3
      57: aload_1
      58: aload_0
      59: iload_2
      60: iconst_1
      61: iadd
      62: iload_2
      63: iload_3
      64: iadd
      65: invokevirtual #116                // Method java/lang/String.substring:(II)Ljava/lang/String;
      68: dup
      69: ldc           #118                // String substring(...)
      71: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      74: invokestatic  #128                // Method parseList:(Ljava/lang/String;)Ljava/util/List;
      77: invokeinterface #129,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      82: pop
      83: iload_2
      84: iload_3
      85: iadd
      86: iconst_1
      87: iadd
      88: istore_2
      89: goto          20
      92: iconst_2
      93: anewarray     #309                // class java/lang/Character
      96: astore_3
      97: aload_3
      98: iconst_0
      99: bipush        44
     101: invokestatic  #312                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     104: aastore
     105: aload_3
     106: iconst_1
     107: bipush        93
     109: invokestatic  #312                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     112: aastore
     113: aload_3
     114: invokestatic  #315                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     117: aload_0
     118: iload_2
     119: invokevirtual #304                // Method java/lang/String.charAt:(I)C
     122: invokestatic  #312                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     125: invokeinterface #318,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     130: ifeq          141
     133: iload_2
     134: iinc          2, 1
     137: pop
     138: goto          20
     141: aload_0
     142: iload_2
     143: invokevirtual #304                // Method java/lang/String.charAt:(I)C
     146: invokestatic  #321                // Method java/lang/String.valueOf:(C)Ljava/lang/String;
     149: astore_3
     150: iload_2
     151: istore        4
     153: aload_0
     154: invokevirtual #112                // Method java/lang/String.length:()I
     157: iload         4
     159: iconst_1
     160: iadd
     161: if_icmple     253
     164: iconst_3
     165: anewarray     #309                // class java/lang/Character
     168: astore        5
     170: aload         5
     172: iconst_0
     173: bipush        91
     175: invokestatic  #312                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     178: aastore
     179: aload         5
     181: iconst_1
     182: bipush        93
     184: invokestatic  #312                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     187: aastore
     188: aload         5
     190: iconst_2
     191: bipush        44
     193: invokestatic  #312                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     196: aastore
     197: aload         5
     199: invokestatic  #315                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     202: aload_0
     203: iload         4
     205: iconst_1
     206: iadd
     207: invokevirtual #304                // Method java/lang/String.charAt:(I)C
     210: invokestatic  #312                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     213: invokeinterface #318,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     218: ifne          253
     221: new           #75                 // class java/lang/StringBuilder
     224: dup
     225: invokespecial #76                 // Method java/lang/StringBuilder."<init>":()V
     228: aload_3
     229: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     232: aload_0
     233: iload         4
     235: iconst_1
     236: iadd
     237: invokevirtual #304                // Method java/lang/String.charAt:(I)C
     240: invokevirtual #324                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     243: invokevirtual #91                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     246: astore_3
     247: iinc          4, 1
     250: goto          153
     253: aload_1
     254: aload_3
     255: invokestatic  #261                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     258: invokestatic  #149                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     261: invokeinterface #129,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     266: pop
     267: iload_2
     268: iinc          2, 1
     271: pop
     272: goto          20
     275: aload_1
     276: areturn

  public static final int getValidCloseBracket(java.lang.String);
    Code:
       0: aload_0
       1: ldc_w         #300                // String str
       4: invokestatic  #233                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aconst_null
       8: astore_1
       9: new           #30                 // class java/util/ArrayList
      12: dup
      13: invokespecial #70                 // Method java/util/ArrayList."<init>":()V
      16: checkcast     #55                 // class java/util/List
      19: astore_1
      20: aload_0
      21: checkcast     #333                // class java/lang/CharSequence
      24: invokestatic  #337                // Method kotlin/text/StringsKt.toMutableList:(Ljava/lang/CharSequence;)Ljava/util/List;
      27: checkcast     #22                 // class java/lang/Iterable
      30: astore_2
      31: iconst_0
      32: istore_3
      33: iconst_0
      34: istore        4
      36: aload_2
      37: invokeinterface #43,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        5
      44: aload         5
      46: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          178
      54: aload         5
      56: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        6
      63: iload         4
      65: iinc          4, 1
      68: istore        7
      70: iload         7
      72: ifge          78
      75: invokestatic  #73                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      78: iload         7
      80: aload         6
      82: checkcast     #309                // class java/lang/Character
      85: invokevirtual #341                // Method java/lang/Character.charValue:()C
      88: istore        8
      90: istore        9
      92: iconst_0
      93: istore        10
      95: iload         8
      97: tableswitch   { // 91 to 93
                    91: 124
                    92: 173
                    93: 139
               default: 173
          }
     124: aload_1
     125: bipush        91
     127: invokestatic  #312                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     130: invokeinterface #129,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     135: pop
     136: goto          173
     139: aload_1
     140: invokestatic  #345                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     143: checkcast     #309                // class java/lang/Character
     146: invokevirtual #341                // Method java/lang/Character.charValue:()C
     149: bipush        91
     151: if_icmpne     161
     154: aload_1
     155: invokeinterface #348,  1          // InterfaceMethod java/util/List.removeLast:()Ljava/lang/Object;
     160: pop
     161: aload_1
     162: invokeinterface #237,  1          // InterfaceMethod java/util/List.size:()I
     167: ifne          173
     170: iload         9
     172: ireturn
     173: nop
     174: nop
     175: goto          44
     178: nop
     179: iconst_m1
     180: ireturn

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

  private static final int main$lambda$2(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: ldc_w         #359                // String a
       4: invokestatic  #233                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: ldc_w         #361                // String b
      11: invokestatic  #233                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      14: aload_0
      15: invokestatic  #289                // Method kotlin/jvm/internal/TypeIntrinsics.asMutableList:(Ljava/lang/Object;)Ljava/util/List;
      18: aload_1
      19: invokestatic  #289                // Method kotlin/jvm/internal/TypeIntrinsics.asMutableList:(Ljava/lang/Object;)Ljava/util/List;
      22: iconst_0
      23: invokestatic  #143                // Method compare:(Ljava/util/List;Ljava/util/List;I)I
      26: ireturn
}


import java.io.File

fun main() {

    // read the lines from the file
    var lines: List<String> = File("Day03.txt").readLines()
    // sum up the total of all priorities
    var total: Int = lines.map {
        // Find the priority by intersecting the two lists of items to get the common item
        // and then running our itemNumber function
        var priority: Int = it.substring(0, it.length / 2).toCharArray().toList()
                   .intersect(it.substring(it.length / 2).toCharArray().toList())
                   .elementAt(0).itemNumber()
        // Return the priority
        return@map priority
    }.toMutableList().sum()

    // Solution to Part 1
    println("The total is: " + total.toString())

    // Create an Int Array for the total number of groups of elves
    val groups = IntArray((lines.size / 3)) { it }
    // Sum up the total of the matching items across each group
    val sum = groups.map {
        // Figure out the base index for the group
        val base = it * 3
        // Find the priority by intersecting all three lists of items from the elves
        return@map lines[base].toCharArray().toList()
                   .intersect(lines[base + 1].toCharArray().toList())
                   .intersect(lines[base + 2].toCharArray().toList())
                   .elementAt(0).itemNumber()
    }.sum()

    // Solution to Part 2
    println("The total of the badge priorities is: " + sum.toString())
}

// This extension function finds the index of the Character inside the alphabet
fun Char.itemNumber(): Int {
    val items = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    return items.indexOf(this) + 1
}

Compiled from "Day03.kt"
public final class Day03Kt {
  public static final void main();
    Code:
       0: aconst_null
       1: astore_0
       2: new           #8                  // class java/io/File
       5: dup
       6: ldc           #10                 // String Day03.txt
       8: invokespecial #14                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      11: aconst_null
      12: iconst_1
      13: aconst_null
      14: invokestatic  #20                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      17: astore_0
      18: aload_0
      19: checkcast     #22                 // class java/lang/Iterable
      22: astore_2
      23: iconst_0
      24: istore_3
      25: aload_2
      26: astore        4
      28: new           #24                 // class java/util/ArrayList
      31: dup
      32: aload_2
      33: bipush        10
      35: invokestatic  #30                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      38: invokespecial #33                 // Method java/util/ArrayList."<init>":(I)V
      41: checkcast     #35                 // class java/util/Collection
      44: astore        5
      46: iconst_0
      47: istore        6
      49: aload         4
      51: invokeinterface #39,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      56: astore        7
      58: aload         7
      60: invokeinterface #45,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      65: ifeq          198
      68: aload         7
      70: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      75: astore        8
      77: aload         5
      79: aload         8
      81: checkcast     #51                 // class java/lang/String
      84: astore        9
      86: astore        15
      88: iconst_0
      89: istore        10
      91: nop
      92: aload         9
      94: iconst_0
      95: aload         9
      97: invokevirtual #55                 // Method java/lang/String.length:()I
     100: iconst_2
     101: idiv
     102: invokevirtual #59                 // Method java/lang/String.substring:(II)Ljava/lang/String;
     105: dup
     106: ldc           #61                 // String substring(...)
     108: invokestatic  #67                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     111: invokevirtual #71                 // Method java/lang/String.toCharArray:()[C
     114: dup
     115: ldc           #73                 // String toCharArray(...)
     117: invokestatic  #67                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     120: invokestatic  #79                 // Method kotlin/collections/ArraysKt.toList:([C)Ljava/util/List;
     123: checkcast     #22                 // class java/lang/Iterable
     126: nop
     127: aload         9
     129: aload         9
     131: invokevirtual #55                 // Method java/lang/String.length:()I
     134: iconst_2
     135: idiv
     136: invokevirtual #82                 // Method java/lang/String.substring:(I)Ljava/lang/String;
     139: dup
     140: ldc           #61                 // String substring(...)
     142: invokestatic  #67                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     145: invokevirtual #71                 // Method java/lang/String.toCharArray:()[C
     148: dup
     149: ldc           #73                 // String toCharArray(...)
     151: invokestatic  #67                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     154: invokestatic  #79                 // Method kotlin/collections/ArraysKt.toList:([C)Ljava/util/List;
     157: checkcast     #22                 // class java/lang/Iterable
     160: invokestatic  #86                 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
     163: checkcast     #22                 // class java/lang/Iterable
     166: iconst_0
     167: invokestatic  #90                 // Method kotlin/collections/CollectionsKt.elementAt:(Ljava/lang/Iterable;I)Ljava/lang/Object;
     170: checkcast     #92                 // class java/lang/Character
     173: invokevirtual #96                 // Method java/lang/Character.charValue:()C
     176: invokestatic  #100                // Method itemNumber:(C)I
     179: istore        11
     181: iload         11
     183: invokestatic  #106                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     186: aload         15
     188: swap
     189: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     194: pop
     195: goto          58
     198: aload         5
     200: checkcast     #112                // class java/util/List
     203: nop
     204: checkcast     #35                 // class java/util/Collection
     207: invokestatic  #116                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     210: checkcast     #22                 // class java/lang/Iterable
     213: invokestatic  #120                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     216: istore_1
     217: new           #122                // class java/lang/StringBuilder
     220: dup
     221: invokespecial #124                // Method java/lang/StringBuilder."<init>":()V
     224: ldc           #126                // String The total is:
     226: invokevirtual #130                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     229: iload_1
     230: invokevirtual #133                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     233: invokevirtual #137                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     236: getstatic     #143                // Field java/lang/System.out:Ljava/io/PrintStream;
     239: swap
     240: invokevirtual #149                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     243: iconst_0
     244: istore_3
     245: aload_0
     246: invokeinterface #152,  1          // InterfaceMethod java/util/List.size:()I
     251: iconst_3
     252: idiv
     253: istore        4
     255: iload         4
     257: newarray       int
     259: astore        5
     261: iload_3
     262: iload         4
     264: if_icmpge     283
     267: iload_3
     268: istore        6
     270: aload         5
     272: iload         6
     274: iload         6
     276: iastore
     277: iinc          3, 1
     280: goto          261
     283: aload         5
     285: astore_2
     286: aload_2
     287: astore        4
     289: iconst_0
     290: istore        5
     292: aload         4
     294: astore        6
     296: new           #24                 // class java/util/ArrayList
     299: dup
     300: aload         4
     302: arraylength
     303: invokespecial #33                 // Method java/util/ArrayList."<init>":(I)V
     306: checkcast     #35                 // class java/util/Collection
     309: astore        7
     311: iconst_0
     312: istore        8
     314: iconst_0
     315: istore        9
     317: aload         6
     319: arraylength
     320: istore        10
     322: iload         9
     324: iload         10
     326: if_icmpge     479
     329: aload         6
     331: iload         9
     333: iaload
     334: istore        11
     336: aload         7
     338: iload         11
     340: istore        12
     342: astore        15
     344: iconst_0
     345: istore        13
     347: iload         12
     349: iconst_3
     350: imul
     351: istore        14
     353: aload_0
     354: iload         14
     356: invokeinterface #156,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     361: checkcast     #51                 // class java/lang/String
     364: invokevirtual #71                 // Method java/lang/String.toCharArray:()[C
     367: dup
     368: ldc           #73                 // String toCharArray(...)
     370: invokestatic  #67                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     373: invokestatic  #79                 // Method kotlin/collections/ArraysKt.toList:([C)Ljava/util/List;
     376: checkcast     #22                 // class java/lang/Iterable
     379: aload_0
     380: iload         14
     382: iconst_1
     383: iadd
     384: invokeinterface #156,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     389: checkcast     #51                 // class java/lang/String
     392: invokevirtual #71                 // Method java/lang/String.toCharArray:()[C
     395: dup
     396: ldc           #73                 // String toCharArray(...)
     398: invokestatic  #67                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     401: invokestatic  #79                 // Method kotlin/collections/ArraysKt.toList:([C)Ljava/util/List;
     404: checkcast     #22                 // class java/lang/Iterable
     407: invokestatic  #86                 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
     410: checkcast     #22                 // class java/lang/Iterable
     413: aload_0
     414: iload         14
     416: iconst_2
     417: iadd
     418: invokeinterface #156,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     423: checkcast     #51                 // class java/lang/String
     426: invokevirtual #71                 // Method java/lang/String.toCharArray:()[C
     429: dup
     430: ldc           #73                 // String toCharArray(...)
     432: invokestatic  #67                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     435: invokestatic  #79                 // Method kotlin/collections/ArraysKt.toList:([C)Ljava/util/List;
     438: checkcast     #22                 // class java/lang/Iterable
     441: invokestatic  #86                 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
     444: checkcast     #22                 // class java/lang/Iterable
     447: iconst_0
     448: invokestatic  #90                 // Method kotlin/collections/CollectionsKt.elementAt:(Ljava/lang/Iterable;I)Ljava/lang/Object;
     451: checkcast     #92                 // class java/lang/Character
     454: invokevirtual #96                 // Method java/lang/Character.charValue:()C
     457: invokestatic  #100                // Method itemNumber:(C)I
     460: nop
     461: invokestatic  #106                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     464: aload         15
     466: swap
     467: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     472: pop
     473: iinc          9, 1
     476: goto          322
     479: aload         7
     481: checkcast     #112                // class java/util/List
     484: nop
     485: checkcast     #22                 // class java/lang/Iterable
     488: invokestatic  #120                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     491: istore_3
     492: new           #122                // class java/lang/StringBuilder
     495: dup
     496: invokespecial #124                // Method java/lang/StringBuilder."<init>":()V
     499: ldc           #158                // String The total of the badge priorities is:
     501: invokevirtual #130                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     504: iload_3
     505: invokevirtual #133                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     508: invokevirtual #137                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     511: getstatic     #143                // Field java/lang/System.out:Ljava/io/PrintStream;
     514: swap
     515: invokevirtual #149                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     518: return

  public static final int itemNumber(char);
    Code:
       0: ldc           #182                // String abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
       2: astore_1
       3: aload_1
       4: checkcast     #184                // class java/lang/CharSequence
       7: iload_0
       8: iconst_0
       9: iconst_0
      10: bipush        6
      12: aconst_null
      13: invokestatic  #190                // Method kotlin/text/StringsKt.indexOf$default:(Ljava/lang/CharSequence;CIZILjava/lang/Object;)I
      16: iconst_1
      17: iadd
      18: ireturn

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


import java.io.File

fun main() {

    // read the lines from the file
    var lines: List<String> = File("Day02.txt").readLines()
    // setup a new list of Games so we can calculate the outcome of each
    var games: MutableList<Game> = lines.map {
        var parts = it.split(" ")
        return@map Game(parts[0].translateRPS(), parts[1].translateRPS())
    }.toMutableList()

    // calculate the outcome of each game, and sum the scores
    println("The sum of the score of all games is: " + games.sumOf { it.score() }.toString())

    // setup a new list of Games so we can calculate the outcome of each based on the new rules in part 2
    var gamesNew: MutableList<Game> = lines.map {
        var parts = it.split(" ")
        var oppPick = parts[0].translateRPS()
        var myPick: String
        // Calculate a Loss
        if (parts[1] == "X") {
            myPick = when (oppPick) {
                "Rock" -> "Scissors"
                "Paper" -> "Rock"
                "Scissors" -> "Paper"
                else -> throw Exception ("Invalid Opponent Pick")
            }
        }
        // Calculate a Draw
        else if (parts[1] == "Y") {
            myPick = oppPick
        }
        // Calculate a Win
        else {
            myPick = when (oppPick) {
                "Rock" -> "Paper"
                "Paper" -> "Scissors"
                "Scissors" -> "Rock"
                else -> throw Exception ("Invalid Opponent Pick")
            }
        }
        return@map Game(parts[0].translateRPS(), myPick)

    }.toMutableList()

    // calculate the outcome of each game, and sum the scores
    println("The sum of the score of all games with the new rules is: " + gamesNew.sumOf { it.score() }.toString())
}

class Game(oppPick: String, yourPick: String) {
    var oppPick: String = oppPick
    var yourPick: String = yourPick
}

fun Game.score(): Int {
    var currScore: Int = when (this.yourPick) {
        "Rock" -> 1
        "Paper" -> 2
        "Scissors" -> 3
        else -> throw Exception("Invalid RPS")
    }

    if (this.oppPick == this.yourPick) {
        currScore += 3
    } else if (this.oppPick == "Rock" && this.yourPick == "Paper" ||
               this.oppPick == "Paper" && this.yourPick == "Scissors" ||
        this.oppPick == "Scissors" && this.yourPick == "Rock") {
        currScore += 6
    } else {
        currScore += 0
    }

    return currScore
}

fun String.translateRPS(): String {
    return when (this) {
        "A", "X" -> "Rock"
        "B", "Y" -> "Paper"
        "C", "Z" -> "Scissors"
        else -> throw Exception("Invalid RPS")
    }
}

Compiled from "Day02.kt"
public final class Day02Kt {
  public static final void main();
    Code:
       0: new           #8                  // class java/io/File
       3: dup
       4: ldc           #10                 // String Day02.txt
       6: invokespecial #14                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #20                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      15: astore_0
      16: aload_0
      17: checkcast     #22                 // class java/lang/Iterable
      20: astore_2
      21: iconst_0
      22: istore_3
      23: aload_2
      24: astore        4
      26: new           #24                 // class java/util/ArrayList
      29: dup
      30: aload_2
      31: bipush        10
      33: invokestatic  #30                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      36: invokespecial #33                 // Method java/util/ArrayList."<init>":(I)V
      39: checkcast     #35                 // class java/util/Collection
      42: astore        5
      44: iconst_0
      45: istore        6
      47: aload         4
      49: invokeinterface #39,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      54: astore        7
      56: aload         7
      58: invokeinterface #45,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      63: ifeq          165
      66: aload         7
      68: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      73: astore        8
      75: aload         5
      77: aload         8
      79: checkcast     #51                 // class java/lang/String
      82: astore        9
      84: astore        16
      86: iconst_0
      87: istore        10
      89: aload         9
      91: checkcast     #53                 // class java/lang/CharSequence
      94: iconst_1
      95: anewarray     #51                 // class java/lang/String
      98: astore        11
     100: aload         11
     102: iconst_0
     103: ldc           #55                 // String
     105: aastore
     106: aload         11
     108: iconst_0
     109: iconst_0
     110: bipush        6
     112: aconst_null
     113: invokestatic  #61                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     116: astore        12
     118: new           #63                 // class Game
     121: dup
     122: aload         12
     124: iconst_0
     125: invokeinterface #69,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     130: checkcast     #51                 // class java/lang/String
     133: invokestatic  #73                 // Method translateRPS:(Ljava/lang/String;)Ljava/lang/String;
     136: aload         12
     138: iconst_1
     139: invokeinterface #69,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     144: checkcast     #51                 // class java/lang/String
     147: invokestatic  #73                 // Method translateRPS:(Ljava/lang/String;)Ljava/lang/String;
     150: invokespecial #76                 // Method Game."<init>":(Ljava/lang/String;Ljava/lang/String;)V
     153: aload         16
     155: swap
     156: invokeinterface #80,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     161: pop
     162: goto          56
     165: aload         5
     167: checkcast     #65                 // class java/util/List
     170: nop
     171: checkcast     #35                 // class java/util/Collection
     174: invokestatic  #84                 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     177: astore_1
     178: new           #86                 // class java/lang/StringBuilder
     181: dup
     182: invokespecial #88                 // Method java/lang/StringBuilder."<init>":()V
     185: ldc           #90                 // String The sum of the score of all games is:
     187: invokevirtual #94                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     190: aload_1
     191: checkcast     #22                 // class java/lang/Iterable
     194: astore_2
     195: astore        16
     197: iconst_0
     198: istore_3
     199: aload_2
     200: invokeinterface #39,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     205: astore        4
     207: aload         4
     209: invokeinterface #45,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     214: ifeq          255
     217: aload         4
     219: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     224: astore        5
     226: iload_3
     227: aload         5
     229: checkcast     #63                 // class Game
     232: astore        6
     234: istore        17
     236: iconst_0
     237: istore        7
     239: aload         6
     241: invokestatic  #98                 // Method score:(LGame;)I
     244: istore        18
     246: iload         17
     248: iload         18
     250: iadd
     251: istore_3
     252: goto          207
     255: iload_3
     256: istore        17
     258: aload         16
     260: iload         17
     262: invokevirtual #101                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     265: invokevirtual #105                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     268: getstatic     #111                // Field java/lang/System.out:Ljava/io/PrintStream;
     271: swap
     272: invokevirtual #117                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     275: aload_0
     276: checkcast     #22                 // class java/lang/Iterable
     279: astore_3
     280: iconst_0
     281: istore        4
     283: aload_3
     284: astore        5
     286: new           #24                 // class java/util/ArrayList
     289: dup
     290: aload_3
     291: bipush        10
     293: invokestatic  #30                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     296: invokespecial #33                 // Method java/util/ArrayList."<init>":(I)V
     299: checkcast     #35                 // class java/util/Collection
     302: astore        6
     304: iconst_0
     305: istore        7
     307: aload         5
     309: invokeinterface #39,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     314: astore        8
     316: aload         8
     318: invokeinterface #45,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     323: ifeq          693
     326: aload         8
     328: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     333: astore        9
     335: aload         6
     337: aload         9
     339: checkcast     #51                 // class java/lang/String
     342: astore        10
     344: astore        16
     346: iconst_0
     347: istore        11
     349: aload         10
     351: checkcast     #53                 // class java/lang/CharSequence
     354: iconst_1
     355: anewarray     #51                 // class java/lang/String
     358: astore        12
     360: aload         12
     362: iconst_0
     363: ldc           #55                 // String
     365: aastore
     366: aload         12
     368: iconst_0
     369: iconst_0
     370: bipush        6
     372: aconst_null
     373: invokestatic  #61                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     376: astore        13
     378: aload         13
     380: iconst_0
     381: invokeinterface #69,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     386: checkcast     #51                 // class java/lang/String
     389: invokestatic  #73                 // Method translateRPS:(Ljava/lang/String;)Ljava/lang/String;
     392: astore        12
     394: aconst_null
     395: astore        14
     397: aload         13
     399: iconst_1
     400: invokeinterface #69,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     405: ldc           #119                // String X
     407: invokestatic  #125                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     410: ifeq          525
     413: aload         12
     415: astore        15
     417: aload         15
     419: invokevirtual #129                // Method java/lang/String.hashCode:()I
     422: lookupswitch  { // 3
            -591277001: 469
               2552709: 456
              76882284: 482
               default: 510
          }
     456: aload         15
     458: ldc           #131                // String Rock
     460: invokevirtual #134                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     463: ifne          495
     466: goto          510
     469: aload         15
     471: ldc           #136                // String Scissors
     473: invokevirtual #134                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     476: ifne          505
     479: goto          510
     482: aload         15
     484: ldc           #138                // String Paper
     486: invokevirtual #134                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     489: ifne          500
     492: goto          510
     495: ldc           #136                // String Scissors
     497: goto          520
     500: ldc           #131                // String Rock
     502: goto          520
     505: ldc           #138                // String Paper
     507: goto          520
     510: new           #140                // class java/lang/Exception
     513: dup
     514: ldc           #142                // String Invalid Opponent Pick
     516: invokespecial #143                // Method java/lang/Exception."<init>":(Ljava/lang/String;)V
     519: athrow
     520: astore        14
     522: goto          658
     525: aload         13
     527: iconst_1
     528: invokeinterface #69,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     533: ldc           #145                // String Y
     535: invokestatic  #125                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     538: ifeq          548
     541: aload         12
     543: astore        14
     545: goto          658
     548: aload         12
     550: astore        15
     552: aload         15
     554: invokevirtual #129                // Method java/lang/String.hashCode:()I
     557: lookupswitch  { // 3
            -591277001: 605
               2552709: 592
              76882284: 618
               default: 646
          }
     592: aload         15
     594: ldc           #131                // String Rock
     596: invokevirtual #134                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     599: ifne          631
     602: goto          646
     605: aload         15
     607: ldc           #136                // String Scissors
     609: invokevirtual #134                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     612: ifne          641
     615: goto          646
     618: aload         15
     620: ldc           #138                // String Paper
     622: invokevirtual #134                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     625: ifne          636
     628: goto          646
     631: ldc           #138                // String Paper
     633: goto          656
     636: ldc           #136                // String Scissors
     638: goto          656
     641: ldc           #131                // String Rock
     643: goto          656
     646: new           #140                // class java/lang/Exception
     649: dup
     650: ldc           #142                // String Invalid Opponent Pick
     652: invokespecial #143                // Method java/lang/Exception."<init>":(Ljava/lang/String;)V
     655: athrow
     656: astore        14
     658: new           #63                 // class Game
     661: dup
     662: aload         13
     664: iconst_0
     665: invokeinterface #69,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     670: checkcast     #51                 // class java/lang/String
     673: invokestatic  #73                 // Method translateRPS:(Ljava/lang/String;)Ljava/lang/String;
     676: aload         14
     678: invokespecial #76                 // Method Game."<init>":(Ljava/lang/String;Ljava/lang/String;)V
     681: aload         16
     683: swap
     684: invokeinterface #80,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     689: pop
     690: goto          316
     693: aload         6
     695: checkcast     #65                 // class java/util/List
     698: nop
     699: checkcast     #35                 // class java/util/Collection
     702: invokestatic  #84                 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     705: astore_2
     706: new           #86                 // class java/lang/StringBuilder
     709: dup
     710: invokespecial #88                 // Method java/lang/StringBuilder."<init>":()V
     713: ldc           #147                // String The sum of the score of all games with the new rules is:
     715: invokevirtual #94                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     718: aload_2
     719: checkcast     #22                 // class java/lang/Iterable
     722: astore_3
     723: astore        16
     725: iconst_0
     726: istore        4
     728: aload_3
     729: invokeinterface #39,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     734: astore        5
     736: aload         5
     738: invokeinterface #45,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     743: ifeq          786
     746: aload         5
     748: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     753: astore        6
     755: iload         4
     757: aload         6
     759: checkcast     #63                 // class Game
     762: astore        7
     764: istore        17
     766: iconst_0
     767: istore        8
     769: aload         7
     771: invokestatic  #98                 // Method score:(LGame;)I
     774: istore        18
     776: iload         17
     778: iload         18
     780: iadd
     781: istore        4
     783: goto          736
     786: iload         4
     788: istore        17
     790: aload         16
     792: iload         17
     794: invokevirtual #101                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     797: invokevirtual #105                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     800: getstatic     #111                // Field java/lang/System.out:Ljava/io/PrintStream;
     803: swap
     804: invokevirtual #117                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     807: return

  public static final int score(Game);
    Code:
       0: aload_0
       1: ldc           #174                // String <this>
       3: invokestatic  #178                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #181                // Method Game.getYourPick:()Ljava/lang/String;
      10: astore_2
      11: aload_2
      12: invokevirtual #129                // Method java/lang/String.hashCode:()I
      15: lookupswitch  { // 3
            -591277001: 60
               2552709: 48
              76882284: 72
               default: 96
          }
      48: aload_2
      49: ldc           #131                // String Rock
      51: invokevirtual #134                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      54: ifne          84
      57: goto          96
      60: aload_2
      61: ldc           #136                // String Scissors
      63: invokevirtual #134                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      66: ifne          92
      69: goto          96
      72: aload_2
      73: ldc           #138                // String Paper
      75: invokevirtual #134                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      78: ifne          88
      81: goto          96
      84: iconst_1
      85: goto          106
      88: iconst_2
      89: goto          106
      92: iconst_3
      93: goto          106
      96: new           #140                // class java/lang/Exception
      99: dup
     100: ldc           #183                // String Invalid RPS
     102: invokespecial #143                // Method java/lang/Exception."<init>":(Ljava/lang/String;)V
     105: athrow
     106: istore_1
     107: aload_0
     108: invokevirtual #186                // Method Game.getOppPick:()Ljava/lang/String;
     111: aload_0
     112: invokevirtual #181                // Method Game.getYourPick:()Ljava/lang/String;
     115: invokestatic  #125                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     118: ifeq          127
     121: iinc          1, 3
     124: goto          208
     127: aload_0
     128: invokevirtual #186                // Method Game.getOppPick:()Ljava/lang/String;
     131: ldc           #131                // String Rock
     133: invokestatic  #125                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     136: ifeq          151
     139: aload_0
     140: invokevirtual #181                // Method Game.getYourPick:()Ljava/lang/String;
     143: ldc           #138                // String Paper
     145: invokestatic  #125                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     148: ifne          199
     151: aload_0
     152: invokevirtual #186                // Method Game.getOppPick:()Ljava/lang/String;
     155: ldc           #138                // String Paper
     157: invokestatic  #125                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     160: ifeq          175
     163: aload_0
     164: invokevirtual #181                // Method Game.getYourPick:()Ljava/lang/String;
     167: ldc           #136                // String Scissors
     169: invokestatic  #125                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     172: ifne          199
     175: aload_0
     176: invokevirtual #186                // Method Game.getOppPick:()Ljava/lang/String;
     179: ldc           #136                // String Scissors
     181: invokestatic  #125                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     184: ifeq          205
     187: aload_0
     188: invokevirtual #181                // Method Game.getYourPick:()Ljava/lang/String;
     191: ldc           #131                // String Rock
     193: invokestatic  #125                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     196: ifeq          205
     199: iinc          1, 6
     202: goto          208
     205: iinc          1, 0
     208: iload_1
     209: ireturn

  public static final java.lang.String translateRPS(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #174                // String <this>
       3: invokestatic  #178                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: astore_1
       8: aload_1
       9: invokevirtual #129                // Method java/lang/String.hashCode:()I
      12: lookupswitch  { // 6
                    65: 72
                    66: 84
                    67: 96
                    88: 108
                    89: 120
                    90: 132
               default: 159
          }
      72: aload_1
      73: ldc           #190                // String A
      75: invokevirtual #134                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      78: ifne          144
      81: goto          159
      84: aload_1
      85: ldc           #192                // String B
      87: invokevirtual #134                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      90: ifne          149
      93: goto          159
      96: aload_1
      97: ldc           #194                // String C
      99: invokevirtual #134                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     102: ifne          154
     105: goto          159
     108: aload_1
     109: ldc           #119                // String X
     111: invokevirtual #134                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     114: ifne          144
     117: goto          159
     120: aload_1
     121: ldc           #145                // String Y
     123: invokevirtual #134                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     126: ifne          149
     129: goto          159
     132: aload_1
     133: ldc           #196                // String Z
     135: invokevirtual #134                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     138: ifne          154
     141: goto          159
     144: ldc           #131                // String Rock
     146: goto          169
     149: ldc           #138                // String Paper
     151: goto          169
     154: ldc           #136                // String Scissors
     156: goto          169
     159: new           #140                // class java/lang/Exception
     162: dup
     163: ldc           #183                // String Invalid RPS
     165: invokespecial #143                // Method java/lang/Exception."<init>":(Ljava/lang/String;)V
     168: athrow
     169: areturn

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