fun main() {
    val testInput = readInput("Day13_test")
    check(part1(testInput) == 13)
    check(part2(testInput) == 140)

    val input = readInput("Day13")
    println(part1(input))
    println(part2(input))
}

private fun part1(input: List<String>): Int {
    return input.windowed(size = 2, step = 3)
        .map { list -> list.map { it.parseList() } }
        .mapIndexed { index, (first, second) ->
            if (checkOrder(first.values, second.values) == Order.RIGHT) index + 1 else 0
        }
        .sum()
}

private fun part2(input: List<String>): Int {
    val dividerPackets = listOf(
        "[[2]]".parseList(),
        "[[6]]".parseList(),
    )

    val originalPackets = input
        .filter { it.isNotEmpty() }
        .map(String::parseList)

    return (originalPackets + dividerPackets)
        .sortedWith(ListValueComparator)
        .mapIndexed { index, listValue ->
            if (listValue in dividerPackets) index + 1 else 1
        }
        .reduce { acc, value -> acc * value }
}

private object ListValueComparator : Comparator<ListValue> {
    override fun compare(left: ListValue, right: ListValue): Int =
        checkOrder(left.values, right.values).value
}

private fun String.parseList(
    fromIndex: Int = 0,
    finishedIndex: IntArray = intArrayOf(fromIndex)
): ListValue {
    check(this[fromIndex] == '[') { "This is not start of the list" }
    var current = fromIndex + 1

    val result = mutableListOf<Value>()
    while (current <= this.lastIndex) {
        when (this[current]) {
            ',' -> ++current
            ']' -> break
            '[' -> {
                val nested = this.parseList(current, finishedIndex)
                result.add(nested)
                current = finishedIndex[0] + 1
            }
            else -> {
                val to = this.indexOfAny(chars = charArrayOf(',', ']'), startIndex = current)

                val intValue = this.substring(current, to).toInt()
                result.add(IntValue(intValue))

                current = if (this[to] == ',') {
                    to + 1
                } else {
                    to
                }
            }
        }
    }

    finishedIndex[0] = current
    return ListValue(result)
}

private fun checkOrder(left: List<Value>, right: List<Value>): Order {
    for (i in left.indices) {
        if (i > right.lastIndex) {
            return Order.WRONG
        }

        val leftItem = left[i]
        val rightItem = right[i]

        if (leftItem is IntValue && rightItem is IntValue) {
            if (leftItem.value < rightItem.value) return Order.RIGHT
            if (leftItem.value > rightItem.value) return Order.WRONG
        } else {
            val result = checkOrder(
                left = if (leftItem is ListValue) leftItem.values else listOf(leftItem),
                right = if (rightItem is ListValue) rightItem.values else listOf(rightItem)
            )
            if (result != Order.UNKNOWN) return result
        }
    }

    return if (left.size < right.size) Order.RIGHT else Order.UNKNOWN
}

private sealed interface Value
private class IntValue(val value: Int) : Value
private class ListValue(val values: List<Value>) : Value

private enum class Order(val value: Int) {
    UNKNOWN(0), RIGHT(-1), WRONG(1)
}

Compiled from "Day13.kt"
public final class Day13Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day13_test
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method part1:(Ljava/util/List;)I
      10: bipush        13
      12: if_icmpne     19
      15: iconst_1
      16: goto          20
      19: iconst_0
      20: ifne          33
      23: new           #20                 // class java/lang/IllegalStateException
      26: dup
      27: ldc           #22                 // String Check failed.
      29: invokespecial #26                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      32: athrow
      33: aload_0
      34: invokestatic  #29                 // Method part2:(Ljava/util/List;)I
      37: sipush        140
      40: if_icmpne     47
      43: iconst_1
      44: goto          48
      47: iconst_0
      48: ifne          61
      51: new           #20                 // class java/lang/IllegalStateException
      54: dup
      55: ldc           #22                 // String Check failed.
      57: invokespecial #26                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      60: athrow
      61: ldc           #31                 // String Day13
      63: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      66: astore_1
      67: aload_1
      68: invokestatic  #18                 // Method part1:(Ljava/util/List;)I
      71: istore_2
      72: getstatic     #37                 // Field java/lang/System.out:Ljava/io/PrintStream;
      75: iload_2
      76: invokevirtual #43                 // Method java/io/PrintStream.println:(I)V
      79: aload_1
      80: invokestatic  #29                 // Method part2:(Ljava/util/List;)I
      83: istore_2
      84: getstatic     #37                 // Field java/lang/System.out:Ljava/io/PrintStream;
      87: iload_2
      88: invokevirtual #43                 // Method java/io/PrintStream.println:(I)V
      91: return

  private static final int part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #51                 // class java/lang/Iterable
       4: iconst_2
       5: iconst_3
       6: iconst_0
       7: iconst_4
       8: aconst_null
       9: invokestatic  #57                 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;
      12: checkcast     #51                 // class java/lang/Iterable
      15: astore_1
      16: nop
      17: iconst_0
      18: istore_2
      19: aload_1
      20: astore_3
      21: new           #59                 // class java/util/ArrayList
      24: dup
      25: aload_1
      26: bipush        10
      28: invokestatic  #63                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      31: invokespecial #65                 // Method java/util/ArrayList."<init>":(I)V
      34: checkcast     #67                 // class java/util/Collection
      37: astore        4
      39: iconst_0
      40: istore        5
      42: aload_3
      43: invokeinterface #71,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      48: astore        6
      50: aload         6
      52: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      57: ifeq          201
      60: aload         6
      62: invokeinterface #81,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      67: astore        7
      69: aload         4
      71: aload         7
      73: checkcast     #48                 // class java/util/List
      76: astore        8
      78: astore        20
      80: iconst_0
      81: istore        9
      83: aload         8
      85: checkcast     #51                 // class java/lang/Iterable
      88: astore        10
      90: iconst_0
      91: istore        11
      93: aload         10
      95: astore        12
      97: new           #59                 // class java/util/ArrayList
     100: dup
     101: aload         10
     103: bipush        10
     105: invokestatic  #63                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     108: invokespecial #65                 // Method java/util/ArrayList."<init>":(I)V
     111: checkcast     #67                 // class java/util/Collection
     114: astore        13
     116: iconst_0
     117: istore        14
     119: aload         12
     121: invokeinterface #71,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     126: astore        15
     128: aload         15
     130: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     135: ifeq          182
     138: aload         15
     140: invokeinterface #81,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     145: astore        16
     147: aload         13
     149: aload         16
     151: checkcast     #83                 // class java/lang/String
     154: astore        17
     156: astore        18
     158: iconst_0
     159: istore        19
     161: aload         17
     163: iconst_0
     164: aconst_null
     165: iconst_3
     166: aconst_null
     167: invokestatic  #87                 // Method parseList$default:(Ljava/lang/String;I[IILjava/lang/Object;)LListValue;
     170: aload         18
     172: swap
     173: invokeinterface #91,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     178: pop
     179: goto          128
     182: aload         13
     184: checkcast     #48                 // class java/util/List
     187: nop
     188: nop
     189: aload         20
     191: swap
     192: invokeinterface #91,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     197: pop
     198: goto          50
     201: aload         4
     203: checkcast     #48                 // class java/util/List
     206: nop
     207: checkcast     #51                 // class java/lang/Iterable
     210: astore_1
     211: nop
     212: iconst_0
     213: istore_2
     214: aload_1
     215: astore_3
     216: new           #59                 // class java/util/ArrayList
     219: dup
     220: aload_1
     221: bipush        10
     223: invokestatic  #63                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     226: invokespecial #65                 // Method java/util/ArrayList."<init>":(I)V
     229: checkcast     #67                 // class java/util/Collection
     232: astore        4
     234: iconst_0
     235: istore        5
     237: iconst_0
     238: istore        6
     240: aload_3
     241: invokeinterface #71,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     246: astore        7
     248: aload         7
     250: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     255: ifeq          368
     258: aload         7
     260: invokeinterface #81,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     265: astore        8
     267: aload         4
     269: iload         6
     271: iinc          6, 1
     274: istore        9
     276: iload         9
     278: ifge          284
     281: invokestatic  #94                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     284: iload         9
     286: aload         8
     288: checkcast     #48                 // class java/util/List
     291: astore        10
     293: istore        11
     295: astore        20
     297: iconst_0
     298: istore        12
     300: aload         10
     302: iconst_0
     303: invokeinterface #98,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     308: checkcast     #100                // class ListValue
     311: astore        13
     313: aload         10
     315: iconst_1
     316: invokeinterface #98,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     321: checkcast     #100                // class ListValue
     324: astore        14
     326: aload         13
     328: invokevirtual #104                // Method ListValue.getValues:()Ljava/util/List;
     331: aload         14
     333: invokevirtual #104                // Method ListValue.getValues:()Ljava/util/List;
     336: invokestatic  #108                // Method checkOrder:(Ljava/util/List;Ljava/util/List;)LOrder;
     339: getstatic     #114                // Field Order.RIGHT:LOrder;
     342: if_acmpne     352
     345: iload         11
     347: iconst_1
     348: iadd
     349: goto          353
     352: iconst_0
     353: invokestatic  #120                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     356: aload         20
     358: swap
     359: invokeinterface #91,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     364: pop
     365: goto          248
     368: aload         4
     370: checkcast     #48                 // class java/util/List
     373: nop
     374: checkcast     #51                 // class java/lang/Iterable
     377: invokestatic  #124                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     380: ireturn

  private static final int part2(java.util.List<java.lang.String>);
    Code:
       0: iconst_2
       1: anewarray     #100                // class ListValue
       4: astore_2
       5: aload_2
       6: iconst_0
       7: ldc           #151                // String [[2]]
       9: iconst_0
      10: aconst_null
      11: iconst_3
      12: aconst_null
      13: invokestatic  #87                 // Method parseList$default:(Ljava/lang/String;I[IILjava/lang/Object;)LListValue;
      16: aastore
      17: aload_2
      18: iconst_1
      19: ldc           #153                // String [[6]]
      21: iconst_0
      22: aconst_null
      23: iconst_3
      24: aconst_null
      25: invokestatic  #87                 // Method parseList$default:(Ljava/lang/String;I[IILjava/lang/Object;)LListValue;
      28: aastore
      29: aload_2
      30: invokestatic  #157                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      33: astore_1
      34: aload_0
      35: checkcast     #51                 // class java/lang/Iterable
      38: astore_3
      39: nop
      40: iconst_0
      41: istore        4
      43: aload_3
      44: astore        5
      46: new           #59                 // class java/util/ArrayList
      49: dup
      50: invokespecial #159                // Method java/util/ArrayList."<init>":()V
      53: checkcast     #67                 // class java/util/Collection
      56: astore        6
      58: iconst_0
      59: istore        7
      61: aload         5
      63: invokeinterface #71,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      68: astore        8
      70: aload         8
      72: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      77: ifeq          134
      80: aload         8
      82: invokeinterface #81,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      87: astore        9
      89: aload         9
      91: checkcast     #83                 // class java/lang/String
      94: astore        10
      96: iconst_0
      97: istore        11
      99: aload         10
     101: checkcast     #161                // class java/lang/CharSequence
     104: invokeinterface #165,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     109: ifle          116
     112: iconst_1
     113: goto          117
     116: iconst_0
     117: nop
     118: ifeq          70
     121: aload         6
     123: aload         9
     125: invokeinterface #91,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     130: pop
     131: goto          70
     134: aload         6
     136: checkcast     #48                 // class java/util/List
     139: nop
     140: checkcast     #51                 // class java/lang/Iterable
     143: astore_3
     144: nop
     145: iconst_0
     146: istore        4
     148: aload_3
     149: astore        5
     151: new           #59                 // class java/util/ArrayList
     154: dup
     155: aload_3
     156: bipush        10
     158: invokestatic  #63                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     161: invokespecial #65                 // Method java/util/ArrayList."<init>":(I)V
     164: checkcast     #67                 // class java/util/Collection
     167: astore        6
     169: iconst_0
     170: istore        7
     172: aload         5
     174: invokeinterface #71,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     179: astore        8
     181: aload         8
     183: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     188: ifeq          235
     191: aload         8
     193: invokeinterface #81,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     198: astore        9
     200: aload         6
     202: aload         9
     204: checkcast     #83                 // class java/lang/String
     207: astore        10
     209: astore        15
     211: iconst_0
     212: istore        11
     214: aload         10
     216: iconst_0
     217: aconst_null
     218: iconst_3
     219: aconst_null
     220: invokestatic  #87                 // Method parseList$default:(Ljava/lang/String;I[IILjava/lang/Object;)LListValue;
     223: aload         15
     225: swap
     226: invokeinterface #91,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     231: pop
     232: goto          181
     235: aload         6
     237: checkcast     #48                 // class java/util/List
     240: nop
     241: astore_2
     242: aload_2
     243: checkcast     #67                 // class java/util/Collection
     246: aload_1
     247: checkcast     #51                 // class java/lang/Iterable
     250: invokestatic  #169                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     253: checkcast     #51                 // class java/lang/Iterable
     256: getstatic     #175                // Field ListValueComparator.INSTANCE:LListValueComparator;
     259: checkcast     #177                // class java/util/Comparator
     262: invokestatic  #181                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
     265: checkcast     #51                 // class java/lang/Iterable
     268: astore_3
     269: nop
     270: iconst_0
     271: istore        4
     273: aload_3
     274: astore        5
     276: new           #59                 // class java/util/ArrayList
     279: dup
     280: aload_3
     281: bipush        10
     283: invokestatic  #63                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     286: invokespecial #65                 // Method java/util/ArrayList."<init>":(I)V
     289: checkcast     #67                 // class java/util/Collection
     292: astore        6
     294: iconst_0
     295: istore        7
     297: iconst_0
     298: istore        8
     300: aload         5
     302: invokeinterface #71,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     307: astore        9
     309: aload         9
     311: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     316: ifeq          395
     319: aload         9
     321: invokeinterface #81,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     326: astore        10
     328: aload         6
     330: iload         8
     332: iinc          8, 1
     335: istore        11
     337: iload         11
     339: ifge          345
     342: invokestatic  #94                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     345: iload         11
     347: aload         10
     349: checkcast     #100                // class ListValue
     352: astore        12
     354: istore        13
     356: astore        15
     358: iconst_0
     359: istore        14
     361: aload_1
     362: aload         12
     364: invokeinterface #184,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     369: ifeq          379
     372: iload         13
     374: iconst_1
     375: iadd
     376: goto          380
     379: iconst_1
     380: invokestatic  #120                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     383: aload         15
     385: swap
     386: invokeinterface #91,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     391: pop
     392: goto          309
     395: aload         6
     397: checkcast     #48                 // class java/util/List
     400: nop
     401: checkcast     #51                 // class java/lang/Iterable
     404: astore_3
     405: nop
     406: iconst_0
     407: istore        4
     409: aload_3
     410: invokeinterface #71,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     415: astore        5
     417: aload         5
     419: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     424: ifne          437
     427: new           #186                // class java/lang/UnsupportedOperationException
     430: dup
     431: ldc           #188                // String Empty collection can\'t be reduced.
     433: invokespecial #189                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     436: athrow
     437: aload         5
     439: invokeinterface #81,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     444: astore        6
     446: aload         5
     448: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     453: ifeq          497
     456: aload         6
     458: aload         5
     460: invokeinterface #81,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     465: checkcast     #191                // class java/lang/Number
     468: invokevirtual #194                // Method java/lang/Number.intValue:()I
     471: istore        7
     473: checkcast     #191                // class java/lang/Number
     476: invokevirtual #194                // Method java/lang/Number.intValue:()I
     479: istore        8
     481: iconst_0
     482: istore        9
     484: iload         8
     486: iload         7
     488: imul
     489: invokestatic  #120                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     492: astore        6
     494: goto          446
     497: aload         6
     499: checkcast     #191                // class java/lang/Number
     502: invokevirtual #194                // Method java/lang/Number.intValue:()I
     505: ireturn

  private static final ListValue parseList(java.lang.String, int, int[]);
    Code:
       0: aload_0
       1: iload_1
       2: invokevirtual #222                // Method java/lang/String.charAt:(I)C
       5: bipush        91
       7: if_icmpne     14
      10: iconst_1
      11: goto          15
      14: iconst_0
      15: ifne          38
      18: iconst_0
      19: istore        4
      21: ldc           #224                // String This is not start of the list
      23: astore        4
      25: new           #20                 // class java/lang/IllegalStateException
      28: dup
      29: aload         4
      31: invokevirtual #228                // Method java/lang/Object.toString:()Ljava/lang/String;
      34: invokespecial #26                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      37: athrow
      38: iload_1
      39: iconst_1
      40: iadd
      41: istore_3
      42: new           #59                 // class java/util/ArrayList
      45: dup
      46: invokespecial #159                // Method java/util/ArrayList."<init>":()V
      49: checkcast     #48                 // class java/util/List
      52: astore        4
      54: iload_3
      55: aload_0
      56: checkcast     #161                // class java/lang/CharSequence
      59: invokestatic  #234                // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I
      62: if_icmpgt     234
      65: aload_0
      66: iload_3
      67: invokevirtual #222                // Method java/lang/String.charAt:(I)C
      70: lookupswitch  { // 3
                    44: 104
                    91: 115
                    93: 112
               default: 142
          }
     104: iinc          3, 1
     107: iload_3
     108: pop
     109: goto          54
     112: goto          234
     115: aload_0
     116: iload_3
     117: aload_2
     118: invokestatic  #236                // Method parseList:(Ljava/lang/String;I[I)LListValue;
     121: astore        5
     123: aload         4
     125: aload         5
     127: invokeinterface #237,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     132: pop
     133: aload_2
     134: iconst_0
     135: iaload
     136: iconst_1
     137: iadd
     138: istore_3
     139: goto          54
     142: aload_0
     143: checkcast     #161                // class java/lang/CharSequence
     146: iconst_2
     147: newarray       char
     149: astore        6
     151: aload         6
     153: iconst_0
     154: bipush        44
     156: castore
     157: aload         6
     159: iconst_1
     160: bipush        93
     162: castore
     163: aload         6
     165: iload_3
     166: iconst_0
     167: iconst_4
     168: aconst_null
     169: invokestatic  #241                // Method kotlin/text/StringsKt.indexOfAny$default:(Ljava/lang/CharSequence;[CIZILjava/lang/Object;)I
     172: istore        5
     174: nop
     175: aload_0
     176: iload_3
     177: iload         5
     179: invokevirtual #245                // Method java/lang/String.substring:(II)Ljava/lang/String;
     182: dup
     183: ldc           #247                // String substring(...)
     185: invokestatic  #253                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     188: invokestatic  #257                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     191: istore        6
     193: aload         4
     195: new           #259                // class IntValue
     198: dup
     199: iload         6
     201: invokespecial #260                // Method IntValue."<init>":(I)V
     204: invokeinterface #237,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     209: pop
     210: aload_0
     211: iload         5
     213: invokevirtual #222                // Method java/lang/String.charAt:(I)C
     216: bipush        44
     218: if_icmpne     228
     221: iload         5
     223: iconst_1
     224: iadd
     225: goto          230
     228: iload         5
     230: istore_3
     231: goto          54
     234: aload_2
     235: iconst_0
     236: iload_3
     237: iastore
     238: new           #100                // class ListValue
     241: dup
     242: aload         4
     244: invokespecial #263                // Method ListValue."<init>":(Ljava/util/List;)V
     247: areturn

  static ListValue parseList$default(java.lang.String, int, int[], int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          8
       6: iconst_0
       7: istore_1
       8: iload_3
       9: iconst_2
      10: iand
      11: ifeq          27
      14: iconst_1
      15: newarray       int
      17: astore        5
      19: aload         5
      21: iconst_0
      22: iload_1
      23: iastore
      24: aload         5
      26: astore_2
      27: aload_0
      28: iload_1
      29: aload_2
      30: invokestatic  #236                // Method parseList:(Ljava/lang/String;I[I)LListValue;
      33: areturn

  private static final Order checkOrder(java.util.List<? extends Value>, java.util.List<? extends Value>);
    Code:
       0: iconst_0
       1: istore_2
       2: aload_0
       3: checkcast     #67                 // class java/util/Collection
       6: invokeinterface #276,  1          // InterfaceMethod java/util/Collection.size:()I
      11: istore_3
      12: iload_2
      13: iload_3
      14: if_icmpge     185
      17: iload_2
      18: aload_1
      19: invokestatic  #278                // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
      22: if_icmple     29
      25: getstatic     #281                // Field Order.WRONG:LOrder;
      28: areturn
      29: aload_0
      30: iload_2
      31: invokeinterface #98,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      36: checkcast     #283                // class Value
      39: astore        4
      41: aload_1
      42: iload_2
      43: invokeinterface #98,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      48: checkcast     #283                // class Value
      51: astore        5
      53: aload         4
      55: instanceof    #259                // class IntValue
      58: ifeq          115
      61: aload         5
      63: instanceof    #259                // class IntValue
      66: ifeq          115
      69: aload         4
      71: checkcast     #259                // class IntValue
      74: invokevirtual #286                // Method IntValue.getValue:()I
      77: aload         5
      79: checkcast     #259                // class IntValue
      82: invokevirtual #286                // Method IntValue.getValue:()I
      85: if_icmpge     92
      88: getstatic     #114                // Field Order.RIGHT:LOrder;
      91: areturn
      92: aload         4
      94: checkcast     #259                // class IntValue
      97: invokevirtual #286                // Method IntValue.getValue:()I
     100: aload         5
     102: checkcast     #259                // class IntValue
     105: invokevirtual #286                // Method IntValue.getValue:()I
     108: if_icmple     179
     111: getstatic     #281                // Field Order.WRONG:LOrder;
     114: areturn
     115: aload         4
     117: instanceof    #100                // class ListValue
     120: ifeq          134
     123: aload         4
     125: checkcast     #100                // class ListValue
     128: invokevirtual #104                // Method ListValue.getValues:()Ljava/util/List;
     131: goto          139
     134: aload         4
     136: invokestatic  #289                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     139: aload         5
     141: instanceof    #100                // class ListValue
     144: ifeq          158
     147: aload         5
     149: checkcast     #100                // class ListValue
     152: invokevirtual #104                // Method ListValue.getValues:()Ljava/util/List;
     155: goto          163
     158: aload         5
     160: invokestatic  #289                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     163: invokestatic  #108                // Method checkOrder:(Ljava/util/List;Ljava/util/List;)LOrder;
     166: astore        6
     168: aload         6
     170: getstatic     #292                // Field Order.UNKNOWN:LOrder;
     173: if_acmpeq     179
     176: aload         6
     178: areturn
     179: iinc          2, 1
     182: goto          12
     185: aload_0
     186: invokeinterface #293,  1          // InterfaceMethod java/util/List.size:()I
     191: aload_1
     192: invokeinterface #293,  1          // InterfaceMethod java/util/List.size:()I
     197: if_icmpge     206
     200: getstatic     #114                // Field Order.RIGHT:LOrder;
     203: goto          209
     206: getstatic     #292                // Field Order.UNKNOWN:LOrder;
     209: areturn

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

  public static final Order access$checkOrder(java.util.List, java.util.List);
    Code:
       0: aload_0
       1: aload_1
       2: invokestatic  #108                // Method checkOrder:(Ljava/util/List;Ljava/util/List;)LOrder;
       5: areturn
}


fun main() {
    val testInput = readInput("Day03_test")
    check(part1(testInput) == 157)
    check(part2(testInput) == 70)

    val input = readInput("Day03")
    println(part1(input))
    println(part2(input))
}

private fun part1(input: List<String>): Int {
    return input.sumOf(::calculatePriority)
}

private fun part2(input: List<String>): Int {
    return input
        .chunked(3) { group ->
            commonPriority(group[0], group[1], group[2])
        }
        .sum()
}

private fun calculatePriority(row: String): Int {
    val second = row.takeLast(row.length / 2).toSet()

    row.forEach { ch ->
        if (ch in second) {
            return ch.toPriority()
        }
    }

    error("Not found")
}

private fun commonPriority(first: String, second: String, third: String): Int {
    val secondSet = second.toSet()
    val thirdSet = third.toSet()

    first.forEach { ch ->
        if (ch in secondSet && ch in thirdSet) {
            return ch.toPriority()
        }
    }

    error("Not found")
}

private fun Char.toPriority(): Int {
    return if (this.isLowerCase()) {
        1 + code - 'a'.code
    } else {
        27 + code - 'A'.code
    }
}

Compiled from "Day03.kt"
public final class Day03Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day03_test
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method part1:(Ljava/util/List;)I
      10: sipush        157
      13: if_icmpne     20
      16: iconst_1
      17: goto          21
      20: iconst_0
      21: ifne          34
      24: new           #20                 // class java/lang/IllegalStateException
      27: dup
      28: ldc           #22                 // String Check failed.
      30: invokespecial #26                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      33: athrow
      34: aload_0
      35: invokestatic  #29                 // Method part2:(Ljava/util/List;)I
      38: bipush        70
      40: if_icmpne     47
      43: iconst_1
      44: goto          48
      47: iconst_0
      48: ifne          61
      51: new           #20                 // class java/lang/IllegalStateException
      54: dup
      55: ldc           #22                 // String Check failed.
      57: invokespecial #26                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      60: athrow
      61: ldc           #31                 // String Day03
      63: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      66: astore_1
      67: aload_1
      68: invokestatic  #18                 // Method part1:(Ljava/util/List;)I
      71: istore_2
      72: getstatic     #37                 // Field java/lang/System.out:Ljava/io/PrintStream;
      75: iload_2
      76: invokevirtual #43                 // Method java/io/PrintStream.println:(I)V
      79: aload_1
      80: invokestatic  #29                 // Method part2:(Ljava/util/List;)I
      83: istore_2
      84: getstatic     #37                 // Field java/lang/System.out:Ljava/io/PrintStream;
      87: iload_2
      88: invokevirtual #43                 // Method java/io/PrintStream.println:(I)V
      91: return

  private static final int part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #51                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: invokeinterface #55,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      13: astore_3
      14: aload_3
      15: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      20: ifeq          60
      23: aload_3
      24: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      29: astore        4
      31: iload_2
      32: aload         4
      34: checkcast     #67                 // class java/lang/String
      37: astore        5
      39: istore        7
      41: iconst_0
      42: istore        6
      44: aload         5
      46: invokestatic  #71                 // Method calculatePriority:(Ljava/lang/String;)I
      49: istore        8
      51: iload         7
      53: iload         8
      55: iadd
      56: istore_2
      57: goto          14
      60: iload_2
      61: ireturn

  private static final int part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #51                 // class java/lang/Iterable
       4: iconst_3
       5: invokedynamic #94,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      10: invokestatic  #100                // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;ILkotlin/jvm/functions/Function1;)Ljava/util/List;
      13: checkcast     #51                 // class java/lang/Iterable
      16: invokestatic  #104                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
      19: ireturn

  private static final int calculatePriority(java.lang.String);
    Code:
       0: aload_0
       1: aload_0
       2: invokevirtual #108                // Method java/lang/String.length:()I
       5: iconst_2
       6: idiv
       7: invokestatic  #114                // Method kotlin/text/StringsKt.takeLast:(Ljava/lang/String;I)Ljava/lang/String;
      10: checkcast     #116                // class java/lang/CharSequence
      13: invokestatic  #120                // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;
      16: astore_1
      17: aload_0
      18: checkcast     #116                // class java/lang/CharSequence
      21: astore_2
      22: iconst_0
      23: istore_3
      24: iconst_0
      25: istore        4
      27: iload         4
      29: aload_2
      30: invokeinterface #121,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      35: if_icmpge     83
      38: aload_2
      39: iload         4
      41: invokeinterface #125,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
      46: istore        5
      48: iload         5
      50: istore        6
      52: iconst_0
      53: istore        7
      55: aload_1
      56: iload         6
      58: invokestatic  #131                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      61: invokeinterface #137,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
      66: ifeq          75
      69: iload         6
      71: invokestatic  #141                // Method toPriority:(C)I
      74: ireturn
      75: nop
      76: nop
      77: iinc          4, 1
      80: goto          27
      83: nop
      84: new           #20                 // class java/lang/IllegalStateException
      87: dup
      88: ldc           #143                // String Not found
      90: invokevirtual #147                // Method java/lang/Object.toString:()Ljava/lang/String;
      93: invokespecial #26                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      96: athrow

  private static final int commonPriority(java.lang.String, java.lang.String, java.lang.String);
    Code:
       0: aload_1
       1: checkcast     #116                // class java/lang/CharSequence
       4: invokestatic  #120                // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;
       7: astore_3
       8: aload_2
       9: checkcast     #116                // class java/lang/CharSequence
      12: invokestatic  #120                // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;
      15: astore        4
      17: aload_0
      18: checkcast     #116                // class java/lang/CharSequence
      21: astore        5
      23: iconst_0
      24: istore        6
      26: iconst_0
      27: istore        7
      29: iload         7
      31: aload         5
      33: invokeinterface #121,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      38: if_icmpge     102
      41: aload         5
      43: iload         7
      45: invokeinterface #125,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
      50: istore        8
      52: iload         8
      54: istore        9
      56: iconst_0
      57: istore        10
      59: aload_3
      60: iload         9
      62: invokestatic  #131                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      65: invokeinterface #137,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
      70: ifeq          94
      73: aload         4
      75: iload         9
      77: invokestatic  #131                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      80: invokeinterface #137,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
      85: ifeq          94
      88: iload         9
      90: invokestatic  #141                // Method toPriority:(C)I
      93: ireturn
      94: nop
      95: nop
      96: iinc          7, 1
      99: goto          29
     102: nop
     103: new           #20                 // class java/lang/IllegalStateException
     106: dup
     107: ldc           #143                // String Not found
     109: invokevirtual #147                // Method java/lang/Object.toString:()Ljava/lang/String;
     112: invokespecial #26                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     115: athrow

  private static final int toPriority(char);
    Code:
       0: iload_0
       1: invokestatic  #168                // Method java/lang/Character.isLowerCase:(C)Z
       4: ifeq          16
       7: iconst_1
       8: iload_0
       9: iadd
      10: bipush        97
      12: isub
      13: goto          23
      16: bipush        27
      18: iload_0
      19: iadd
      20: bipush        65
      22: isub
      23: ireturn

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

  private static final int part2$lambda$0(java.util.List);
    Code:
       0: aload_0
       1: ldc           #176                // String group
       3: invokestatic  #182                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iconst_0
       8: invokeinterface #186,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      13: checkcast     #67                 // class java/lang/String
      16: aload_0
      17: iconst_1
      18: invokeinterface #186,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      23: checkcast     #67                 // class java/lang/String
      26: aload_0
      27: iconst_2
      28: invokeinterface #186,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      33: checkcast     #67                 // class java/lang/String
      36: invokestatic  #188                // Method commonPriority:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I
      39: ireturn
}


fun main() {
    val testInput = readInput("Day02_test")
    check(part1(testInput) == 15)
    check(part2(testInput) == 12)

    val input = readInput("Day02")
    println(part1(input))
    println(part2(input))
}

private fun part1(input: List<String>): Int {
    return input.sumOf(String::toScore)
}

private fun part2(input: List<String>): Int {
    return input
        .map(String::correctMove)
        .sumOf(String::toScore)
}

private val SCORES = mapOf(
    "AX" to 4,
    "AY" to 8,
    "AZ" to 3,
    "BX" to 1,
    "BY" to 5,
    "BZ" to 9,
    "CX" to 7,
    "CY" to 2,
    "CZ" to 6,
)

private fun String.toScore(): Int {
    return SCORES.getValue("${this[0]}${this[2]}")
}

private val CORRECTIONS = mapOf(
    "AX" to "A Z",
    "AY" to "A X",
    "AZ" to "A Y",
    "BX" to "B X",
    "BY" to "B Y",
    "BZ" to "B Z",
    "CX" to "C Y",
    "CY" to "C Z",
    "CZ" to "C X",
)

private fun String.correctMove(): String {
    return CORRECTIONS.getValue("${this[0]}${this[2]}")
}

Compiled from "Day02.kt"
public final class Day02Kt {
  private static final java.util.Map<java.lang.String, java.lang.Integer> SCORES;

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

  public static final void main();
    Code:
       0: ldc           #8                  // String Day02_test
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method part1:(Ljava/util/List;)I
      10: bipush        15
      12: if_icmpne     19
      15: iconst_1
      16: goto          20
      19: iconst_0
      20: ifne          33
      23: new           #20                 // class java/lang/IllegalStateException
      26: dup
      27: ldc           #22                 // String Check failed.
      29: invokespecial #26                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      32: athrow
      33: aload_0
      34: invokestatic  #29                 // Method part2:(Ljava/util/List;)I
      37: bipush        12
      39: if_icmpne     46
      42: iconst_1
      43: goto          47
      46: iconst_0
      47: ifne          60
      50: new           #20                 // class java/lang/IllegalStateException
      53: dup
      54: ldc           #22                 // String Check failed.
      56: invokespecial #26                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      59: athrow
      60: ldc           #31                 // String Day02
      62: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      65: astore_1
      66: aload_1
      67: invokestatic  #18                 // Method part1:(Ljava/util/List;)I
      70: istore_2
      71: getstatic     #37                 // Field java/lang/System.out:Ljava/io/PrintStream;
      74: iload_2
      75: invokevirtual #43                 // Method java/io/PrintStream.println:(I)V
      78: aload_1
      79: invokestatic  #29                 // Method part2:(Ljava/util/List;)I
      82: istore_2
      83: getstatic     #37                 // Field java/lang/System.out:Ljava/io/PrintStream;
      86: iload_2
      87: invokevirtual #43                 // Method java/io/PrintStream.println:(I)V
      90: return

  private static final int part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #51                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: invokeinterface #55,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      13: astore_3
      14: aload_3
      15: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      20: ifeq          60
      23: aload_3
      24: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      29: astore        4
      31: iload_2
      32: aload         4
      34: checkcast     #67                 // class java/lang/String
      37: astore        5
      39: istore        7
      41: iconst_0
      42: istore        6
      44: aload         5
      46: invokestatic  #71                 // Method toScore:(Ljava/lang/String;)I
      49: istore        8
      51: iload         7
      53: iload         8
      55: iadd
      56: istore_2
      57: goto          14
      60: iload_2
      61: ireturn

  private static final int part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #51                 // class java/lang/Iterable
       4: astore_1
       5: nop
       6: iconst_0
       7: istore_2
       8: aload_1
       9: astore_3
      10: new           #77                 // class java/util/ArrayList
      13: dup
      14: aload_1
      15: bipush        10
      17: invokestatic  #83                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      20: invokespecial #85                 // Method java/util/ArrayList."<init>":(I)V
      23: checkcast     #87                 // class java/util/Collection
      26: astore        4
      28: iconst_0
      29: istore        5
      31: aload_3
      32: invokeinterface #55,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        6
      39: aload         6
      41: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          89
      49: aload         6
      51: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        7
      58: aload         4
      60: aload         7
      62: checkcast     #67                 // class java/lang/String
      65: astore        8
      67: astore        10
      69: iconst_0
      70: istore        9
      72: aload         8
      74: invokestatic  #91                 // Method correctMove:(Ljava/lang/String;)Ljava/lang/String;
      77: aload         10
      79: swap
      80: invokeinterface #95,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      85: pop
      86: goto          39
      89: aload         4
      91: checkcast     #48                 // class java/util/List
      94: nop
      95: checkcast     #51                 // class java/lang/Iterable
      98: astore_1
      99: iconst_0
     100: istore_2
     101: aload_1
     102: invokeinterface #55,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     107: astore_3
     108: aload_3
     109: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     114: ifeq          154
     117: aload_3
     118: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     123: astore        4
     125: iload_2
     126: aload         4
     128: checkcast     #67                 // class java/lang/String
     131: astore        5
     133: istore        10
     135: iconst_0
     136: istore        6
     138: aload         5
     140: invokestatic  #71                 // Method toScore:(Ljava/lang/String;)I
     143: istore        11
     145: iload         10
     147: iload         11
     149: iadd
     150: istore_2
     151: goto          108
     154: iload_2
     155: ireturn

  private static final int toScore(java.lang.String);
    Code:
       0: getstatic     #110                // Field SCORES:Ljava/util/Map;
       3: new           #112                // class java/lang/StringBuilder
       6: dup
       7: invokespecial #114                // Method java/lang/StringBuilder."<init>":()V
      10: aload_0
      11: iconst_0
      12: invokevirtual #118                // Method java/lang/String.charAt:(I)C
      15: invokevirtual #122                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      18: aload_0
      19: iconst_2
      20: invokevirtual #118                // Method java/lang/String.charAt:(I)C
      23: invokevirtual #122                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      26: invokevirtual #126                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      29: invokestatic  #132                // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;
      32: checkcast     #134                // class java/lang/Number
      35: invokevirtual #138                // Method java/lang/Number.intValue:()I
      38: ireturn

  private static final java.lang.String correctMove(java.lang.String);
    Code:
       0: getstatic     #142                // Field CORRECTIONS:Ljava/util/Map;
       3: new           #112                // class java/lang/StringBuilder
       6: dup
       7: invokespecial #114                // Method java/lang/StringBuilder."<init>":()V
      10: aload_0
      11: iconst_0
      12: invokevirtual #118                // Method java/lang/String.charAt:(I)C
      15: invokevirtual #122                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      18: aload_0
      19: iconst_2
      20: invokevirtual #118                // Method java/lang/String.charAt:(I)C
      23: invokevirtual #122                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      26: invokevirtual #126                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      29: invokestatic  #132                // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;
      32: checkcast     #67                 // class java/lang/String
      35: areturn

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

  static {};
    Code:
       0: bipush        9
       2: anewarray     #151                // class kotlin/Pair
       5: astore_0
       6: aload_0
       7: iconst_0
       8: ldc           #153                // String AX
      10: iconst_4
      11: invokestatic  #159                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      14: invokestatic  #165                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      17: aastore
      18: aload_0
      19: iconst_1
      20: ldc           #167                // String AY
      22: bipush        8
      24: invokestatic  #159                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      27: invokestatic  #165                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      30: aastore
      31: aload_0
      32: iconst_2
      33: ldc           #169                // String AZ
      35: iconst_3
      36: invokestatic  #159                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      39: invokestatic  #165                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      42: aastore
      43: aload_0
      44: iconst_3
      45: ldc           #171                // String BX
      47: iconst_1
      48: invokestatic  #159                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      51: invokestatic  #165                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      54: aastore
      55: aload_0
      56: iconst_4
      57: ldc           #173                // String BY
      59: iconst_5
      60: invokestatic  #159                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      63: invokestatic  #165                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      66: aastore
      67: aload_0
      68: iconst_5
      69: ldc           #175                // String BZ
      71: bipush        9
      73: invokestatic  #159                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      76: invokestatic  #165                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      79: aastore
      80: aload_0
      81: bipush        6
      83: ldc           #177                // String CX
      85: bipush        7
      87: invokestatic  #159                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      90: invokestatic  #165                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      93: aastore
      94: aload_0
      95: bipush        7
      97: ldc           #179                // String CY
      99: iconst_2
     100: invokestatic  #159                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     103: invokestatic  #165                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     106: aastore
     107: aload_0
     108: bipush        8
     110: ldc           #181                // String CZ
     112: bipush        6
     114: invokestatic  #159                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     117: invokestatic  #165                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     120: aastore
     121: aload_0
     122: invokestatic  #185                // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;
     125: putstatic     #110                // Field SCORES:Ljava/util/Map;
     128: bipush        9
     130: anewarray     #151                // class kotlin/Pair
     133: astore_0
     134: aload_0
     135: iconst_0
     136: ldc           #153                // String AX
     138: ldc           #187                // String A Z
     140: invokestatic  #165                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     143: aastore
     144: aload_0
     145: iconst_1
     146: ldc           #167                // String AY
     148: ldc           #189                // String A X
     150: invokestatic  #165                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     153: aastore
     154: aload_0
     155: iconst_2
     156: ldc           #169                // String AZ
     158: ldc           #191                // String A Y
     160: invokestatic  #165                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     163: aastore
     164: aload_0
     165: iconst_3
     166: ldc           #171                // String BX
     168: ldc           #193                // String B X
     170: invokestatic  #165                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     173: aastore
     174: aload_0
     175: iconst_4
     176: ldc           #173                // String BY
     178: ldc           #195                // String B Y
     180: invokestatic  #165                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     183: aastore
     184: aload_0
     185: iconst_5
     186: ldc           #175                // String BZ
     188: ldc           #197                // String B Z
     190: invokestatic  #165                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     193: aastore
     194: aload_0
     195: bipush        6
     197: ldc           #177                // String CX
     199: ldc           #199                // String C Y
     201: invokestatic  #165                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     204: aastore
     205: aload_0
     206: bipush        7
     208: ldc           #179                // String CY
     210: ldc           #201                // String C Z
     212: invokestatic  #165                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     215: aastore
     216: aload_0
     217: bipush        8
     219: ldc           #181                // String CZ
     221: ldc           #203                // String C X
     223: invokestatic  #165                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     226: aastore
     227: aload_0
     228: invokestatic  #185                // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;
     231: putstatic     #142                // Field CORRECTIONS:Ljava/util/Map;
     234: return
}


import java.util.*

fun main() {
    val testInput = readInput("Day12_test")
    check(part1(testInput) == 31)
    check(part2(testInput) == 29)

    val input = readInput("Day12")
    println(part1(input))
    println(part2(input))

}

private fun part1(input: List<String>, ): Int = solve(input, startMarkers = setOf('S'))
private fun part2(input: List<String>, ): Int = solve(input, startMarkers = setOf('S', 'a'))

private fun solve(input: List<String>, startMarkers: Set<Char>): Int {
    val area = input.toMatrix()
    val starts = input.findAllChars(startMarkers)
    val end = input.findChar('E')
    val visited = mutableSetOf<IJ>()

    val queue = PriorityQueue<Item>()

    starts.forEach {
        queue.offer(Item(0, it))
    }

    while (queue.isNotEmpty()) {
        val (steps, ij) = queue.poll()

        if (ij in visited) {
            continue
        }

        if (ij == end) {
            return steps
        }

        val (i, j) = ij
        if (i > 0 && (area[i - 1][j] - area[i][j]) <= 1) {
            queue.offer(Item(steps + 1, IJ(i - 1, j)))
        }
        if (j > 0 && (area[i][j - 1] - area[i][j]) <= 1) {
            queue.offer(Item(steps + 1, IJ(i, j - 1)))
        }
        if (i < area.lastIndex && (area[i + 1][j] - area[i][j]) <= 1) {
            queue.offer(Item(steps + 1, IJ(i + 1, j)))
        }
        if (j < area[i].lastIndex && (area[i][j + 1] - area[i][j]) <= 1) {
            queue.offer(Item(steps + 1, IJ(i, j + 1)))
        }

        visited.add(ij)
    }

    error("Path not found")
}

private fun List<String>.toMatrix(): Matrix {
    return Array(this.size) { i ->
        IntArray(this[i].length) { j ->
            when (this[i][j]) {
                'S' -> 0
                'E' -> 'z'.code - 'a'.code
                else -> this[i][j].code - 'a'.code
            }
        }
    }
}

private fun List<String>.findChar(target: Char): IJ {
    this.forEachIndexed { i, row ->
        row.forEachIndexed { j, ch ->
            if (ch == target) {
                return IJ(i, j)
            }
        }
    }

    error("$target not found")
}

private fun List<String>.findAllChars(targets: Set<Char>): List<IJ> {
    val result = mutableListOf<IJ>()

    this.forEachIndexed { i, row ->
        row.forEachIndexed { j, ch ->
            if (ch in targets) {
                result.add(IJ(i, j))
            }
        }
    }

    return result
}

Compiled from "Day12.kt"
public final class Day12Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day12_test
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method part1:(Ljava/util/List;)I
      10: bipush        31
      12: if_icmpne     19
      15: iconst_1
      16: goto          20
      19: iconst_0
      20: ifne          33
      23: new           #20                 // class java/lang/IllegalStateException
      26: dup
      27: ldc           #22                 // String Check failed.
      29: invokespecial #26                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      32: athrow
      33: aload_0
      34: invokestatic  #29                 // Method part2:(Ljava/util/List;)I
      37: bipush        29
      39: if_icmpne     46
      42: iconst_1
      43: goto          47
      46: iconst_0
      47: ifne          60
      50: new           #20                 // class java/lang/IllegalStateException
      53: dup
      54: ldc           #22                 // String Check failed.
      56: invokespecial #26                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      59: athrow
      60: ldc           #31                 // String Day12
      62: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      65: astore_1
      66: aload_1
      67: invokestatic  #18                 // Method part1:(Ljava/util/List;)I
      70: istore_2
      71: getstatic     #37                 // Field java/lang/System.out:Ljava/io/PrintStream;
      74: iload_2
      75: invokevirtual #43                 // Method java/io/PrintStream.println:(I)V
      78: aload_1
      79: invokestatic  #29                 // Method part2:(Ljava/util/List;)I
      82: istore_2
      83: getstatic     #37                 // Field java/lang/System.out:Ljava/io/PrintStream;
      86: iload_2
      87: invokevirtual #43                 // Method java/io/PrintStream.println:(I)V
      90: return

  private static final int part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: bipush        83
       3: invokestatic  #55                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
       6: invokestatic  #61                 // Method kotlin/collections/SetsKt.setOf:(Ljava/lang/Object;)Ljava/util/Set;
       9: invokestatic  #65                 // Method solve:(Ljava/util/List;Ljava/util/Set;)I
      12: ireturn

  private static final int part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: iconst_2
       2: anewarray     #51                 // class java/lang/Character
       5: astore_1
       6: aload_1
       7: iconst_0
       8: bipush        83
      10: invokestatic  #55                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      13: aastore
      14: aload_1
      15: iconst_1
      16: bipush        97
      18: invokestatic  #55                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      21: aastore
      22: aload_1
      23: invokestatic  #68                 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;
      26: invokestatic  #65                 // Method solve:(Ljava/util/List;Ljava/util/Set;)I
      29: ireturn

  private static final int solve(java.util.List<java.lang.String>, java.util.Set<java.lang.Character>);
    Code:
       0: aload_0
       1: invokestatic  #73                 // Method toMatrix:(Ljava/util/List;)[[I
       4: astore_2
       5: aload_0
       6: aload_1
       7: invokestatic  #77                 // Method findAllChars:(Ljava/util/List;Ljava/util/Set;)Ljava/util/List;
      10: astore_3
      11: aload_0
      12: bipush        69
      14: invokestatic  #81                 // Method findChar:(Ljava/util/List;C)LIJ;
      17: astore        4
      19: new           #83                 // class java/util/LinkedHashSet
      22: dup
      23: invokespecial #85                 // Method java/util/LinkedHashSet."<init>":()V
      26: checkcast     #87                 // class java/util/Set
      29: astore        5
      31: new           #89                 // class java/util/PriorityQueue
      34: dup
      35: invokespecial #90                 // Method java/util/PriorityQueue."<init>":()V
      38: astore        6
      40: aload_3
      41: checkcast     #92                 // class java/lang/Iterable
      44: astore        7
      46: iconst_0
      47: istore        8
      49: aload         7
      51: invokeinterface #96,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      56: astore        9
      58: aload         9
      60: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      65: ifeq          108
      68: aload         9
      70: invokeinterface #106,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      75: astore        10
      77: aload         10
      79: checkcast     #108                // class IJ
      82: astore        11
      84: iconst_0
      85: istore        12
      87: aload         6
      89: new           #110                // class Item
      92: dup
      93: iconst_0
      94: aload         11
      96: invokespecial #113                // Method Item."<init>":(ILIJ;)V
      99: invokevirtual #117                // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z
     102: pop
     103: nop
     104: nop
     105: goto          58
     108: nop
     109: aload         6
     111: checkcast     #119                // class java/util/Collection
     114: invokeinterface #122,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     119: ifne          126
     122: iconst_1
     123: goto          127
     126: iconst_0
     127: ifeq          447
     130: aload         6
     132: invokevirtual #125                // Method java/util/PriorityQueue.poll:()Ljava/lang/Object;
     135: checkcast     #110                // class Item
     138: astore        7
     140: aload         7
     142: invokevirtual #129                // Method Item.component1:()I
     145: istore        8
     147: aload         7
     149: invokevirtual #133                // Method Item.component2:()LIJ;
     152: astore        9
     154: aload         5
     156: aload         9
     158: invokeinterface #136,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     163: ifeq          169
     166: goto          109
     169: aload         9
     171: aload         4
     173: invokestatic  #142                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     176: ifeq          182
     179: iload         8
     181: ireturn
     182: aload         9
     184: invokevirtual #143                // Method IJ.component1:()I
     187: istore        10
     189: aload         9
     191: invokevirtual #145                // Method IJ.component2:()I
     194: istore        11
     196: iload         10
     198: ifle          252
     201: aload_2
     202: iload         10
     204: iconst_1
     205: isub
     206: aaload
     207: iload         11
     209: iaload
     210: aload_2
     211: iload         10
     213: aaload
     214: iload         11
     216: iaload
     217: isub
     218: iconst_1
     219: if_icmpgt     252
     222: aload         6
     224: new           #110                // class Item
     227: dup
     228: iload         8
     230: iconst_1
     231: iadd
     232: new           #108                // class IJ
     235: dup
     236: iload         10
     238: iconst_1
     239: isub
     240: iload         11
     242: invokespecial #148                // Method IJ."<init>":(II)V
     245: invokespecial #113                // Method Item."<init>":(ILIJ;)V
     248: invokevirtual #117                // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z
     251: pop
     252: iload         11
     254: ifle          308
     257: aload_2
     258: iload         10
     260: aaload
     261: iload         11
     263: iconst_1
     264: isub
     265: iaload
     266: aload_2
     267: iload         10
     269: aaload
     270: iload         11
     272: iaload
     273: isub
     274: iconst_1
     275: if_icmpgt     308
     278: aload         6
     280: new           #110                // class Item
     283: dup
     284: iload         8
     286: iconst_1
     287: iadd
     288: new           #108                // class IJ
     291: dup
     292: iload         10
     294: iload         11
     296: iconst_1
     297: isub
     298: invokespecial #148                // Method IJ."<init>":(II)V
     301: invokespecial #113                // Method Item."<init>":(ILIJ;)V
     304: invokevirtual #117                // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z
     307: pop
     308: iload         10
     310: aload_2
     311: checkcast     #150                // class "[Ljava/lang/Object;"
     314: invokestatic  #156                // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I
     317: if_icmpge     371
     320: aload_2
     321: iload         10
     323: iconst_1
     324: iadd
     325: aaload
     326: iload         11
     328: iaload
     329: aload_2
     330: iload         10
     332: aaload
     333: iload         11
     335: iaload
     336: isub
     337: iconst_1
     338: if_icmpgt     371
     341: aload         6
     343: new           #110                // class Item
     346: dup
     347: iload         8
     349: iconst_1
     350: iadd
     351: new           #108                // class IJ
     354: dup
     355: iload         10
     357: iconst_1
     358: iadd
     359: iload         11
     361: invokespecial #148                // Method IJ."<init>":(II)V
     364: invokespecial #113                // Method Item."<init>":(ILIJ;)V
     367: invokevirtual #117                // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z
     370: pop
     371: iload         11
     373: aload_2
     374: iload         10
     376: aaload
     377: invokestatic  #159                // Method kotlin/collections/ArraysKt.getLastIndex:([I)I
     380: if_icmpge     434
     383: aload_2
     384: iload         10
     386: aaload
     387: iload         11
     389: iconst_1
     390: iadd
     391: iaload
     392: aload_2
     393: iload         10
     395: aaload
     396: iload         11
     398: iaload
     399: isub
     400: iconst_1
     401: if_icmpgt     434
     404: aload         6
     406: new           #110                // class Item
     409: dup
     410: iload         8
     412: iconst_1
     413: iadd
     414: new           #108                // class IJ
     417: dup
     418: iload         10
     420: iload         11
     422: iconst_1
     423: iadd
     424: invokespecial #148                // Method IJ."<init>":(II)V
     427: invokespecial #113                // Method Item."<init>":(ILIJ;)V
     430: invokevirtual #117                // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z
     433: pop
     434: aload         5
     436: aload         9
     438: invokeinterface #162,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     443: pop
     444: goto          109
     447: new           #20                 // class java/lang/IllegalStateException
     450: dup
     451: ldc           #164                // String Path not found
     453: invokevirtual #168                // Method java/lang/Object.toString:()Ljava/lang/String;
     456: invokespecial #26                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     459: athrow

  private static final int[][] toMatrix(java.util.List<java.lang.String>);
    Code:
       0: iconst_0
       1: istore_1
       2: aload_0
       3: invokeinterface #195,  1          // InterfaceMethod java/util/List.size:()I
       8: istore_2
       9: iload_2
      10: anewarray     #197                // class "[I"
      13: astore_3
      14: iload_1
      15: iload_2
      16: if_icmpge     160
      19: iload_1
      20: istore        4
      22: aload_3
      23: iload         4
      25: iconst_0
      26: istore        5
      28: aload_0
      29: iload         4
      31: invokeinterface #201,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      36: checkcast     #203                // class java/lang/String
      39: invokevirtual #206                // Method java/lang/String.length:()I
      42: istore        6
      44: iload         6
      46: newarray       int
      48: astore        7
      50: istore        10
      52: astore        9
      54: iload         5
      56: iload         6
      58: if_icmpge     147
      61: iload         5
      63: istore        8
      65: aload         7
      67: iload         8
      69: aload_0
      70: iload         4
      72: invokeinterface #201,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      77: checkcast     #203                // class java/lang/String
      80: iload         8
      82: invokevirtual #210                // Method java/lang/String.charAt:(I)C
      85: lookupswitch  { // 2
                    69: 116
                    83: 112
               default: 121
          }
     112: iconst_0
     113: goto          140
     116: bipush        25
     118: goto          140
     121: aload_0
     122: iload         4
     124: invokeinterface #201,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     129: checkcast     #203                // class java/lang/String
     132: iload         8
     134: invokevirtual #210                // Method java/lang/String.charAt:(I)C
     137: bipush        97
     139: isub
     140: iastore
     141: iinc          5, 1
     144: goto          54
     147: aload         9
     149: iload         10
     151: aload         7
     153: aastore
     154: iinc          1, 1
     157: goto          14
     160: aload_3
     161: areturn

  private static final IJ findChar(java.util.List<java.lang.String>, char);
    Code:
       0: aload_0
       1: checkcast     #92                 // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: iconst_0
       8: istore        4
      10: aload_2
      11: invokeinterface #96,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      16: astore        5
      18: aload         5
      20: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      25: ifeq          151
      28: aload         5
      30: invokeinterface #106,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      35: astore        6
      37: iload         4
      39: iinc          4, 1
      42: istore        7
      44: iload         7
      46: ifge          52
      49: invokestatic  #217                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      52: iload         7
      54: aload         6
      56: checkcast     #203                // class java/lang/String
      59: astore        8
      61: istore        9
      63: iconst_0
      64: istore        10
      66: aload         8
      68: checkcast     #219                // class java/lang/CharSequence
      71: astore        11
      73: iconst_0
      74: istore        12
      76: iconst_0
      77: istore        13
      79: iconst_0
      80: istore        14
      82: iload         14
      84: aload         11
      86: invokeinterface #220,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      91: if_icmpge     145
      94: aload         11
      96: iload         14
      98: invokeinterface #221,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     103: istore        15
     105: iload         13
     107: iinc          13, 1
     110: iload         15
     112: istore        16
     114: istore        17
     116: iconst_0
     117: istore        18
     119: iload         16
     121: iload_1
     122: if_icmpne     137
     125: new           #108                // class IJ
     128: dup
     129: iload         9
     131: iload         17
     133: invokespecial #148                // Method IJ."<init>":(II)V
     136: areturn
     137: nop
     138: nop
     139: iinc          14, 1
     142: goto          82
     145: nop
     146: nop
     147: nop
     148: goto          18
     151: nop
     152: new           #20                 // class java/lang/IllegalStateException
     155: dup
     156: new           #223                // class java/lang/StringBuilder
     159: dup
     160: invokespecial #224                // Method java/lang/StringBuilder."<init>":()V
     163: iload_1
     164: invokevirtual #228                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     167: ldc           #230                // String  not found
     169: invokevirtual #233                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     172: invokevirtual #234                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     175: invokevirtual #168                // Method java/lang/Object.toString:()Ljava/lang/String;
     178: invokespecial #26                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     181: athrow

  private static final java.util.List<IJ> findAllChars(java.util.List<java.lang.String>, java.util.Set<java.lang.Character>);
    Code:
       0: new           #250                // class java/util/ArrayList
       3: dup
       4: invokespecial #251                // Method java/util/ArrayList."<init>":()V
       7: checkcast     #48                 // class java/util/List
      10: astore_2
      11: aload_0
      12: checkcast     #92                 // class java/lang/Iterable
      15: astore_3
      16: iconst_0
      17: istore        4
      19: iconst_0
      20: istore        5
      22: aload_3
      23: invokeinterface #96,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      28: astore        6
      30: aload         6
      32: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      37: ifeq          177
      40: aload         6
      42: invokeinterface #106,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      47: astore        7
      49: iload         5
      51: iinc          5, 1
      54: istore        8
      56: iload         8
      58: ifge          64
      61: invokestatic  #217                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      64: iload         8
      66: aload         7
      68: checkcast     #203                // class java/lang/String
      71: astore        9
      73: istore        10
      75: iconst_0
      76: istore        11
      78: aload         9
      80: checkcast     #219                // class java/lang/CharSequence
      83: astore        12
      85: iconst_0
      86: istore        13
      88: iconst_0
      89: istore        14
      91: iconst_0
      92: istore        15
      94: iload         15
      96: aload         12
      98: invokeinterface #220,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     103: if_icmpge     171
     106: aload         12
     108: iload         15
     110: invokeinterface #221,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     115: istore        16
     117: iload         14
     119: iinc          14, 1
     122: iload         16
     124: istore        17
     126: istore        18
     128: iconst_0
     129: istore        19
     131: aload_1
     132: iload         17
     134: invokestatic  #55                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     137: invokeinterface #136,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     142: ifeq          163
     145: aload_2
     146: new           #108                // class IJ
     149: dup
     150: iload         10
     152: iload         18
     154: invokespecial #148                // Method IJ."<init>":(II)V
     157: invokeinterface #252,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     162: pop
     163: nop
     164: nop
     165: iinc          15, 1
     168: goto          94
     171: nop
     172: nop
     173: nop
     174: goto          30
     177: nop
     178: aload_2
     179: areturn

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