// Parte 1: Crea una lista “listaRandom” de 100 elementos compuesta de números aleatorios comprendidos entre el 0 y el 9.
// Imprime la lista por pantalla

// Parte 2: Crea una lista vacía “listaResultado” en cuya posición…
// Posición 0 se debe contar cuantos 0 hay en la listaRandom.
// Posición 1 se debe contar cuantos 1 hay en la listaRandom.
// etc. con todos los números.

fun main() {
    var listaRandom:ArrayList<Int> = listaRandom()
    imprimirListaRandom(listaRandom)

    var listaResultado:ArrayList<Int> = listaResultado(listaRandom)
    imprimirListaResultado(listaResultado)

    println()

    sumaListaResultado(listaResultado)
}

fun listaRandom() : ArrayList<Int> {
    var listaRandom:ArrayList<Int> = arrayListOf()
    repeat(100) {
        var numRandom:Int = (0..9).random()
        listaRandom.add(numRandom)
    }
    return listaRandom
}

fun imprimirListaRandom(listaRandom:ArrayList<Int>) {
    for (num in listaRandom)
        println(num)
}

fun listaResultado(listaRandom:ArrayList<Int>) : ArrayList<Int> {
    var listaResultado:ArrayList<Int> = arrayListOf(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
    for (num in listaRandom) {
        when(num) {
            0 -> listaResultado[0] = listaResultado[0] + 1
            1 -> listaResultado[1] = listaResultado[1] + 1
            2 -> listaResultado[2] = listaResultado[2] + 1
            3 -> listaResultado[3] = listaResultado[3] + 1
            4 -> listaResultado[4] = listaResultado[4] + 1
            5 -> listaResultado[5] = listaResultado[5] + 1
            6 -> listaResultado[6] = listaResultado[6] + 1
            7 -> listaResultado[7] = listaResultado[7] + 1
            8 -> listaResultado[8] = listaResultado[8] + 1
            9 -> listaResultado[9] = listaResultado[9] + 1
        }
    }

    return listaResultado
}

fun imprimirListaResultado(listaResultado:ArrayList<Int>) {
    listaResultado.forEachIndexed { index, i ->
        println("- El número $index aparece $i veces")
    }
}

fun sumaListaResultado(listaResultado:ArrayList<Int>) {
    var sumaTotal:Int = 0
    for (num in listaResultado) {
        sumaTotal = sumaTotal + num
    }

    println("Hay $sumaTotal números")
}

Compiled from "ejercicio4A.kt"
public final class Ejercicio4AKt {
  public static final void main();
    Code:
       0: invokestatic  #10                 // Method listaRandom:()Ljava/util/ArrayList;
       3: astore_0
       4: aload_0
       5: invokestatic  #14                 // Method imprimirListaRandom:(Ljava/util/ArrayList;)V
       8: aload_0
       9: invokestatic  #18                 // Method listaResultado:(Ljava/util/ArrayList;)Ljava/util/ArrayList;
      12: astore_1
      13: aload_1
      14: invokestatic  #21                 // Method imprimirListaResultado:(Ljava/util/ArrayList;)V
      17: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      20: invokevirtual #32                 // Method java/io/PrintStream.println:()V
      23: aload_1
      24: invokestatic  #35                 // Method sumaListaResultado:(Ljava/util/ArrayList;)V
      27: return

  public static final java.util.ArrayList<java.lang.Integer> listaRandom();
    Code:
       0: aconst_null
       1: astore_0
       2: new           #40                 // class java/util/ArrayList
       5: dup
       6: invokespecial #43                 // Method java/util/ArrayList."<init>":()V
       9: astore_0
      10: bipush        100
      12: istore_1
      13: iconst_0
      14: istore_2
      15: iload_2
      16: iload_1
      17: if_icmpge     63
      20: iload_2
      21: istore_3
      22: iconst_0
      23: istore        4
      25: new           #45                 // class kotlin/ranges/IntRange
      28: dup
      29: iconst_0
      30: bipush        9
      32: invokespecial #48                 // Method kotlin/ranges/IntRange."<init>":(II)V
      35: getstatic     #54                 // Field kotlin/random/Random.Default:Lkotlin/random/Random$Default;
      38: checkcast     #50                 // class kotlin/random/Random
      41: invokestatic  #60                 // Method kotlin/ranges/RangesKt.random:(Lkotlin/ranges/IntRange;Lkotlin/random/Random;)I
      44: istore        5
      46: aload_0
      47: iload         5
      49: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      52: invokevirtual #70                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      55: pop
      56: nop
      57: iinc          2, 1
      60: goto          15
      63: aload_0
      64: areturn

  public static final void imprimirListaRandom(java.util.ArrayList<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #77                 // String listaRandom
       3: invokestatic  #83                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #87                 // Method java/util/ArrayList.iterator:()Ljava/util/Iterator;
      10: dup
      11: ldc           #89                 // String iterator(...)
      13: invokestatic  #92                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      16: astore_1
      17: aload_1
      18: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      23: ifeq          55
      26: aload_1
      27: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      32: dup
      33: ldc           #104                // String next(...)
      35: invokestatic  #92                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      38: checkcast     #106                // class java/lang/Number
      41: invokevirtual #110                // Method java/lang/Number.intValue:()I
      44: istore_2
      45: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      48: iload_2
      49: invokevirtual #113                // Method java/io/PrintStream.println:(I)V
      52: goto          17
      55: return

  public static final java.util.ArrayList<java.lang.Integer> listaResultado(java.util.ArrayList<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #77                 // String listaRandom
       3: invokestatic  #83                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: bipush        10
       8: anewarray     #62                 // class java/lang/Integer
      11: astore_2
      12: aload_2
      13: iconst_0
      14: iconst_0
      15: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      18: aastore
      19: aload_2
      20: iconst_1
      21: iconst_0
      22: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      25: aastore
      26: aload_2
      27: iconst_2
      28: iconst_0
      29: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      32: aastore
      33: aload_2
      34: iconst_3
      35: iconst_0
      36: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      39: aastore
      40: aload_2
      41: iconst_4
      42: iconst_0
      43: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      46: aastore
      47: aload_2
      48: iconst_5
      49: iconst_0
      50: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      53: aastore
      54: aload_2
      55: bipush        6
      57: iconst_0
      58: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      61: aastore
      62: aload_2
      63: bipush        7
      65: iconst_0
      66: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      69: aastore
      70: aload_2
      71: bipush        8
      73: iconst_0
      74: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      77: aastore
      78: aload_2
      79: bipush        9
      81: iconst_0
      82: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      85: aastore
      86: aload_2
      87: invokestatic  #121                // Method kotlin/collections/CollectionsKt.arrayListOf:([Ljava/lang/Object;)Ljava/util/ArrayList;
      90: astore_1
      91: aload_0
      92: invokevirtual #87                 // Method java/util/ArrayList.iterator:()Ljava/util/Iterator;
      95: dup
      96: ldc           #89                 // String iterator(...)
      98: invokestatic  #92                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     101: astore_2
     102: aload_2
     103: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     108: ifeq          442
     111: aload_2
     112: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     117: dup
     118: ldc           #104                // String next(...)
     120: invokestatic  #92                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     123: checkcast     #106                // class java/lang/Number
     126: invokevirtual #110                // Method java/lang/Number.intValue:()I
     129: istore_3
     130: iload_3
     131: tableswitch   { // 0 to 9
                     0: 184
                     1: 209
                     2: 234
                     3: 259
                     4: 284
                     5: 309
                     6: 334
                     7: 361
                     8: 388
                     9: 415
               default: 439
          }
     184: aload_1
     185: iconst_0
     186: aload_1
     187: iconst_0
     188: invokevirtual #125                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     191: checkcast     #106                // class java/lang/Number
     194: invokevirtual #110                // Method java/lang/Number.intValue:()I
     197: iconst_1
     198: iadd
     199: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     202: invokevirtual #129                // Method java/util/ArrayList.set:(ILjava/lang/Object;)Ljava/lang/Object;
     205: pop
     206: goto          102
     209: aload_1
     210: iconst_1
     211: aload_1
     212: iconst_1
     213: invokevirtual #125                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     216: checkcast     #106                // class java/lang/Number
     219: invokevirtual #110                // Method java/lang/Number.intValue:()I
     222: iconst_1
     223: iadd
     224: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     227: invokevirtual #129                // Method java/util/ArrayList.set:(ILjava/lang/Object;)Ljava/lang/Object;
     230: pop
     231: goto          102
     234: aload_1
     235: iconst_2
     236: aload_1
     237: iconst_2
     238: invokevirtual #125                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     241: checkcast     #106                // class java/lang/Number
     244: invokevirtual #110                // Method java/lang/Number.intValue:()I
     247: iconst_1
     248: iadd
     249: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     252: invokevirtual #129                // Method java/util/ArrayList.set:(ILjava/lang/Object;)Ljava/lang/Object;
     255: pop
     256: goto          102
     259: aload_1
     260: iconst_3
     261: aload_1
     262: iconst_3
     263: invokevirtual #125                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     266: checkcast     #106                // class java/lang/Number
     269: invokevirtual #110                // Method java/lang/Number.intValue:()I
     272: iconst_1
     273: iadd
     274: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     277: invokevirtual #129                // Method java/util/ArrayList.set:(ILjava/lang/Object;)Ljava/lang/Object;
     280: pop
     281: goto          102
     284: aload_1
     285: iconst_4
     286: aload_1
     287: iconst_4
     288: invokevirtual #125                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     291: checkcast     #106                // class java/lang/Number
     294: invokevirtual #110                // Method java/lang/Number.intValue:()I
     297: iconst_1
     298: iadd
     299: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     302: invokevirtual #129                // Method java/util/ArrayList.set:(ILjava/lang/Object;)Ljava/lang/Object;
     305: pop
     306: goto          102
     309: aload_1
     310: iconst_5
     311: aload_1
     312: iconst_5
     313: invokevirtual #125                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     316: checkcast     #106                // class java/lang/Number
     319: invokevirtual #110                // Method java/lang/Number.intValue:()I
     322: iconst_1
     323: iadd
     324: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     327: invokevirtual #129                // Method java/util/ArrayList.set:(ILjava/lang/Object;)Ljava/lang/Object;
     330: pop
     331: goto          102
     334: aload_1
     335: bipush        6
     337: aload_1
     338: bipush        6
     340: invokevirtual #125                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     343: checkcast     #106                // class java/lang/Number
     346: invokevirtual #110                // Method java/lang/Number.intValue:()I
     349: iconst_1
     350: iadd
     351: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     354: invokevirtual #129                // Method java/util/ArrayList.set:(ILjava/lang/Object;)Ljava/lang/Object;
     357: pop
     358: goto          102
     361: aload_1
     362: bipush        7
     364: aload_1
     365: bipush        7
     367: invokevirtual #125                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     370: checkcast     #106                // class java/lang/Number
     373: invokevirtual #110                // Method java/lang/Number.intValue:()I
     376: iconst_1
     377: iadd
     378: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     381: invokevirtual #129                // Method java/util/ArrayList.set:(ILjava/lang/Object;)Ljava/lang/Object;
     384: pop
     385: goto          102
     388: aload_1
     389: bipush        8
     391: aload_1
     392: bipush        8
     394: invokevirtual #125                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     397: checkcast     #106                // class java/lang/Number
     400: invokevirtual #110                // Method java/lang/Number.intValue:()I
     403: iconst_1
     404: iadd
     405: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     408: invokevirtual #129                // Method java/util/ArrayList.set:(ILjava/lang/Object;)Ljava/lang/Object;
     411: pop
     412: goto          102
     415: aload_1
     416: bipush        9
     418: aload_1
     419: bipush        9
     421: invokevirtual #125                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     424: checkcast     #106                // class java/lang/Number
     427: invokevirtual #110                // Method java/lang/Number.intValue:()I
     430: iconst_1
     431: iadd
     432: invokestatic  #66                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     435: invokevirtual #129                // Method java/util/ArrayList.set:(ILjava/lang/Object;)Ljava/lang/Object;
     438: pop
     439: goto          102
     442: aload_1
     443: areturn

  public static final void imprimirListaResultado(java.util.ArrayList<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #130                // String listaResultado
       3: invokestatic  #83                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #132                // class java/lang/Iterable
      10: astore_1
      11: iconst_0
      12: istore_2
      13: iconst_0
      14: istore_3
      15: aload_1
      16: invokeinterface #133,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      21: astore        4
      23: aload         4
      25: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      30: ifeq          120
      33: aload         4
      35: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      40: astore        5
      42: iload_3
      43: iinc          3, 1
      46: istore        6
      48: iload         6
      50: ifge          56
      53: invokestatic  #136                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      56: iload         6
      58: aload         5
      60: checkcast     #106                // class java/lang/Number
      63: invokevirtual #110                // Method java/lang/Number.intValue:()I
      66: istore        7
      68: istore        8
      70: iconst_0
      71: istore        9
      73: new           #138                // class java/lang/StringBuilder
      76: dup
      77: invokespecial #139                // Method java/lang/StringBuilder."<init>":()V
      80: ldc           #141                // String - El número
      82: invokevirtual #145                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      85: iload         8
      87: invokevirtual #148                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      90: ldc           #150                // String  aparece
      92: invokevirtual #145                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      95: iload         7
      97: invokevirtual #148                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     100: ldc           #152                // String  veces
     102: invokevirtual #145                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     105: invokevirtual #156                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     108: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
     111: swap
     112: invokevirtual #159                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     115: nop
     116: nop
     117: goto          23
     120: nop
     121: return

  public static final void sumaListaResultado(java.util.ArrayList<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #130                // String listaResultado
       3: invokestatic  #83                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_1
       8: aload_0
       9: invokevirtual #87                 // Method java/util/ArrayList.iterator:()Ljava/util/Iterator;
      12: dup
      13: ldc           #89                 // String iterator(...)
      15: invokestatic  #92                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      18: astore_2
      19: aload_2
      20: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      25: ifeq          54
      28: aload_2
      29: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      34: dup
      35: ldc           #104                // String next(...)
      37: invokestatic  #92                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      40: checkcast     #106                // class java/lang/Number
      43: invokevirtual #110                // Method java/lang/Number.intValue:()I
      46: istore_3
      47: iload_1
      48: iload_3
      49: iadd
      50: istore_1
      51: goto          19
      54: new           #138                // class java/lang/StringBuilder
      57: dup
      58: invokespecial #139                // Method java/lang/StringBuilder."<init>":()V
      61: ldc           #169                // String Hay
      63: invokevirtual #145                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      66: iload_1
      67: invokevirtual #148                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      70: ldc           #171                // String  números
      72: invokevirtual #145                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      75: invokevirtual #156                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      78: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      81: swap
      82: invokevirtual #159                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      85: return

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


import java.io.File

fun main() {

    // assumes sorted
    fun List<Int>.fullyContains(innerList: List<Int>): Boolean {
        return this.first() <= innerList.first() && this.last() >= innerList.last()
    }

    // assumes sorted
    fun List<Int>.overlaps(otherList: List<Int>): Boolean {
        return (this.first() <= otherList.last() && this.last() >= otherList.first())
    }

    fun part1(filename: String): Int? {
        var count: Int = 0;
        File(filename).forEachLine {
            val ranges = it.split(",")
            val range1: List<Int> = ranges[0].split("-").map{ it.toInt() }
            val range2: List<Int> = ranges[1].split("-").map{ it.toInt() }
            if (range1.fullyContains(range2) || range2.fullyContains(range1)) {
                count += 1
            }
        }
        return count;
    }

    fun part2(filename: String): Int? {
        var count: Int = 0;
        File(filename).forEachLine {
            val ranges = it.split(",")
            val range1: List<Int> = ranges[0].split("-").map{ it.toInt() }
            val range2: List<Int> = ranges[1].split("-").map{ it.toInt() }
            if (range1.overlaps(range2)) {
                count += 1
            }
        }
        return count;
    }

    println("part 1: " + part1("input_day04.txt"))
    println("part 2: " + part2("input_day04.txt"))
}

Compiled from "Day04.kt"
public final class Day04Kt {
  public static final void main();
    Code:
       0: new           #8                  // class java/lang/StringBuilder
       3: dup
       4: invokespecial #11                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #13                 // String part 1:
       9: invokevirtual #17                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: ldc           #19                 // String input_day04.txt
      14: invokestatic  #23                 // Method main$part1:(Ljava/lang/String;)Ljava/lang/Integer;
      17: invokevirtual #26                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      20: invokevirtual #30                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      23: getstatic     #36                 // Field java/lang/System.out:Ljava/io/PrintStream;
      26: swap
      27: invokevirtual #42                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      30: new           #8                  // class java/lang/StringBuilder
      33: dup
      34: invokespecial #11                 // Method java/lang/StringBuilder."<init>":()V
      37: ldc           #44                 // String part 2:
      39: invokevirtual #17                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      42: ldc           #19                 // String input_day04.txt
      44: invokestatic  #47                 // Method main$part2:(Ljava/lang/String;)Ljava/lang/Integer;
      47: invokevirtual #26                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      50: invokevirtual #30                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      53: getstatic     #36                 // Field java/lang/System.out:Ljava/io/PrintStream;
      56: swap
      57: invokevirtual #42                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      60: return

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

  private static final boolean main$fullyContains(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: invokestatic  #61                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
       4: checkcast     #63                 // class java/lang/Number
       7: invokevirtual #67                 // Method java/lang/Number.intValue:()I
      10: aload_1
      11: invokestatic  #61                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      14: checkcast     #63                 // class java/lang/Number
      17: invokevirtual #67                 // Method java/lang/Number.intValue:()I
      20: if_icmpgt     50
      23: aload_0
      24: invokestatic  #70                 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
      27: checkcast     #63                 // class java/lang/Number
      30: invokevirtual #67                 // Method java/lang/Number.intValue:()I
      33: aload_1
      34: invokestatic  #70                 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
      37: checkcast     #63                 // class java/lang/Number
      40: invokevirtual #67                 // Method java/lang/Number.intValue:()I
      43: if_icmplt     50
      46: iconst_1
      47: goto          51
      50: iconst_0
      51: ireturn

  private static final boolean main$overlaps(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: invokestatic  #61                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
       4: checkcast     #63                 // class java/lang/Number
       7: invokevirtual #67                 // Method java/lang/Number.intValue:()I
      10: aload_1
      11: invokestatic  #70                 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
      14: checkcast     #63                 // class java/lang/Number
      17: invokevirtual #67                 // Method java/lang/Number.intValue:()I
      20: if_icmpgt     50
      23: aload_0
      24: invokestatic  #70                 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
      27: checkcast     #63                 // class java/lang/Number
      30: invokevirtual #67                 // Method java/lang/Number.intValue:()I
      33: aload_1
      34: invokestatic  #61                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      37: checkcast     #63                 // class java/lang/Number
      40: invokevirtual #67                 // Method java/lang/Number.intValue:()I
      43: if_icmplt     50
      46: iconst_1
      47: goto          51
      50: iconst_0
      51: ireturn

  private static final kotlin.Unit main$part1$lambda$2(kotlin.jvm.internal.Ref$IntRef, java.lang.String);
    Code:
       0: aload_1
       1: ldc           #80                 // String it
       3: invokestatic  #86                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #88                 // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #90                 // class java/lang/String
      14: astore_3
      15: aload_3
      16: iconst_0
      17: ldc           #92                 // String ,
      19: aastore
      20: aload_3
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #98                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: astore_2
      30: aload_2
      31: iconst_0
      32: invokeinterface #104,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      37: checkcast     #88                 // class java/lang/CharSequence
      40: iconst_1
      41: anewarray     #90                 // class java/lang/String
      44: astore        4
      46: aload         4
      48: iconst_0
      49: ldc           #106                // String -
      51: aastore
      52: aload         4
      54: iconst_0
      55: iconst_0
      56: bipush        6
      58: aconst_null
      59: invokestatic  #98                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      62: checkcast     #108                // class java/lang/Iterable
      65: astore        4
      67: iconst_0
      68: istore        5
      70: aload         4
      72: astore        6
      74: new           #110                // class java/util/ArrayList
      77: dup
      78: aload         4
      80: bipush        10
      82: invokestatic  #114                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      85: invokespecial #117                // Method java/util/ArrayList."<init>":(I)V
      88: checkcast     #119                // class java/util/Collection
      91: astore        7
      93: iconst_0
      94: istore        8
      96: aload         6
      98: invokeinterface #123,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     103: astore        9
     105: aload         9
     107: invokeinterface #129,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     112: ifeq          159
     115: aload         9
     117: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     122: astore        10
     124: aload         7
     126: aload         10
     128: checkcast     #90                 // class java/lang/String
     131: astore        11
     133: astore        14
     135: iconst_0
     136: istore        12
     138: aload         11
     140: invokestatic  #139                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     143: nop
     144: invokestatic  #143                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     147: aload         14
     149: swap
     150: invokeinterface #147,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     155: pop
     156: goto          105
     159: aload         7
     161: checkcast     #100                // class java/util/List
     164: nop
     165: astore_3
     166: aload_2
     167: iconst_1
     168: invokeinterface #104,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     173: checkcast     #88                 // class java/lang/CharSequence
     176: iconst_1
     177: anewarray     #90                 // class java/lang/String
     180: astore        5
     182: aload         5
     184: iconst_0
     185: ldc           #106                // String -
     187: aastore
     188: aload         5
     190: iconst_0
     191: iconst_0
     192: bipush        6
     194: aconst_null
     195: invokestatic  #98                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     198: checkcast     #108                // class java/lang/Iterable
     201: astore        5
     203: iconst_0
     204: istore        6
     206: aload         5
     208: astore        7
     210: new           #110                // class java/util/ArrayList
     213: dup
     214: aload         5
     216: bipush        10
     218: invokestatic  #114                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     221: invokespecial #117                // Method java/util/ArrayList."<init>":(I)V
     224: checkcast     #119                // class java/util/Collection
     227: astore        8
     229: iconst_0
     230: istore        9
     232: aload         7
     234: invokeinterface #123,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     239: astore        10
     241: aload         10
     243: invokeinterface #129,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     248: ifeq          295
     251: aload         10
     253: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     258: astore        11
     260: aload         8
     262: aload         11
     264: checkcast     #90                 // class java/lang/String
     267: astore        12
     269: astore        14
     271: iconst_0
     272: istore        13
     274: aload         12
     276: invokestatic  #139                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     279: nop
     280: invokestatic  #143                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     283: aload         14
     285: swap
     286: invokeinterface #147,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     291: pop
     292: goto          241
     295: aload         8
     297: checkcast     #100                // class java/util/List
     300: nop
     301: astore        4
     303: aload_3
     304: aload         4
     306: invokestatic  #149                // Method main$fullyContains:(Ljava/util/List;Ljava/util/List;)Z
     309: ifne          321
     312: aload         4
     314: aload_3
     315: invokestatic  #149                // Method main$fullyContains:(Ljava/util/List;Ljava/util/List;)Z
     318: ifeq          331
     321: aload_0
     322: aload_0
     323: getfield      #155                // Field kotlin/jvm/internal/Ref$IntRef.element:I
     326: iconst_1
     327: iadd
     328: putfield      #155                // Field kotlin/jvm/internal/Ref$IntRef.element:I
     331: getstatic     #161                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     334: areturn

  private static final java.lang.Integer main$part1(java.lang.String);
    Code:
       0: new           #151                // class kotlin/jvm/internal/Ref$IntRef
       3: dup
       4: invokespecial #180                // Method kotlin/jvm/internal/Ref$IntRef."<init>":()V
       7: astore_1
       8: new           #182                // class java/io/File
      11: dup
      12: aload_0
      13: invokespecial #185                // Method java/io/File."<init>":(Ljava/lang/String;)V
      16: aconst_null
      17: aload_1
      18: invokedynamic #203,  0            // InvokeDynamic #0:invoke:(Lkotlin/jvm/internal/Ref$IntRef;)Lkotlin/jvm/functions/Function1;
      23: iconst_1
      24: aconst_null
      25: invokestatic  #209                // Method kotlin/io/FilesKt.forEachLine$default:(Ljava/io/File;Ljava/nio/charset/Charset;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
      28: aload_1
      29: getfield      #155                // Field kotlin/jvm/internal/Ref$IntRef.element:I
      32: invokestatic  #143                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      35: areturn

  private static final kotlin.Unit main$part2$lambda$5(kotlin.jvm.internal.Ref$IntRef, java.lang.String);
    Code:
       0: aload_1
       1: ldc           #80                 // String it
       3: invokestatic  #86                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #88                 // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #90                 // class java/lang/String
      14: astore_3
      15: aload_3
      16: iconst_0
      17: ldc           #92                 // String ,
      19: aastore
      20: aload_3
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #98                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: astore_2
      30: aload_2
      31: iconst_0
      32: invokeinterface #104,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      37: checkcast     #88                 // class java/lang/CharSequence
      40: iconst_1
      41: anewarray     #90                 // class java/lang/String
      44: astore        4
      46: aload         4
      48: iconst_0
      49: ldc           #106                // String -
      51: aastore
      52: aload         4
      54: iconst_0
      55: iconst_0
      56: bipush        6
      58: aconst_null
      59: invokestatic  #98                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      62: checkcast     #108                // class java/lang/Iterable
      65: astore        4
      67: iconst_0
      68: istore        5
      70: aload         4
      72: astore        6
      74: new           #110                // class java/util/ArrayList
      77: dup
      78: aload         4
      80: bipush        10
      82: invokestatic  #114                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      85: invokespecial #117                // Method java/util/ArrayList."<init>":(I)V
      88: checkcast     #119                // class java/util/Collection
      91: astore        7
      93: iconst_0
      94: istore        8
      96: aload         6
      98: invokeinterface #123,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     103: astore        9
     105: aload         9
     107: invokeinterface #129,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     112: ifeq          159
     115: aload         9
     117: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     122: astore        10
     124: aload         7
     126: aload         10
     128: checkcast     #90                 // class java/lang/String
     131: astore        11
     133: astore        14
     135: iconst_0
     136: istore        12
     138: aload         11
     140: invokestatic  #139                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     143: nop
     144: invokestatic  #143                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     147: aload         14
     149: swap
     150: invokeinterface #147,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     155: pop
     156: goto          105
     159: aload         7
     161: checkcast     #100                // class java/util/List
     164: nop
     165: astore_3
     166: aload_2
     167: iconst_1
     168: invokeinterface #104,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     173: checkcast     #88                 // class java/lang/CharSequence
     176: iconst_1
     177: anewarray     #90                 // class java/lang/String
     180: astore        5
     182: aload         5
     184: iconst_0
     185: ldc           #106                // String -
     187: aastore
     188: aload         5
     190: iconst_0
     191: iconst_0
     192: bipush        6
     194: aconst_null
     195: invokestatic  #98                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     198: checkcast     #108                // class java/lang/Iterable
     201: astore        5
     203: iconst_0
     204: istore        6
     206: aload         5
     208: astore        7
     210: new           #110                // class java/util/ArrayList
     213: dup
     214: aload         5
     216: bipush        10
     218: invokestatic  #114                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     221: invokespecial #117                // Method java/util/ArrayList."<init>":(I)V
     224: checkcast     #119                // class java/util/Collection
     227: astore        8
     229: iconst_0
     230: istore        9
     232: aload         7
     234: invokeinterface #123,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     239: astore        10
     241: aload         10
     243: invokeinterface #129,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     248: ifeq          295
     251: aload         10
     253: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     258: astore        11
     260: aload         8
     262: aload         11
     264: checkcast     #90                 // class java/lang/String
     267: astore        12
     269: astore        14
     271: iconst_0
     272: istore        13
     274: aload         12
     276: invokestatic  #139                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     279: nop
     280: invokestatic  #143                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     283: aload         14
     285: swap
     286: invokeinterface #147,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     291: pop
     292: goto          241
     295: aload         8
     297: checkcast     #100                // class java/util/List
     300: nop
     301: astore        4
     303: aload_3
     304: aload         4
     306: invokestatic  #214                // Method main$overlaps:(Ljava/util/List;Ljava/util/List;)Z
     309: ifeq          322
     312: aload_0
     313: aload_0
     314: getfield      #155                // Field kotlin/jvm/internal/Ref$IntRef.element:I
     317: iconst_1
     318: iadd
     319: putfield      #155                // Field kotlin/jvm/internal/Ref$IntRef.element:I
     322: getstatic     #161                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     325: areturn

  private static final java.lang.Integer main$part2(java.lang.String);
    Code:
       0: new           #151                // class kotlin/jvm/internal/Ref$IntRef
       3: dup
       4: invokespecial #180                // Method kotlin/jvm/internal/Ref$IntRef."<init>":()V
       7: astore_1
       8: new           #182                // class java/io/File
      11: dup
      12: aload_0
      13: invokespecial #185                // Method java/io/File."<init>":(Ljava/lang/String;)V
      16: aconst_null
      17: aload_1
      18: invokedynamic #220,  0            // InvokeDynamic #1:invoke:(Lkotlin/jvm/internal/Ref$IntRef;)Lkotlin/jvm/functions/Function1;
      23: iconst_1
      24: aconst_null
      25: invokestatic  #209                // Method kotlin/io/FilesKt.forEachLine$default:(Ljava/io/File;Ljava/nio/charset/Charset;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
      28: aload_1
      29: getfield      #155                // Field kotlin/jvm/internal/Ref$IntRef.element:I
      32: invokestatic  #143                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      35: areturn
}


import java.io.File

fun main() {

    var stacks: ArrayList<ArrayList<String?>> = ArrayList()
    var instructions: ArrayList<List<Int>> = ArrayList()

    fun initializeStackLine(row: List<String?>) {
        row.forEachIndexed { index, value ->
            if (stacks.size <= index) {
                stacks.add(ArrayList<String?>())
            }
            if (value != null) stacks[index].add(value);
        }
    }

    fun initalizeStacksAndInstructions(filename: String) {
        stacks = ArrayList()
        instructions = ArrayList()
        val elementRegex: Regex = "[A-Z]".toRegex()
        val movesRegex: Regex = """\d+""".toRegex()
        File(filename).forEachLine {
            if (it.contains("[")) {
                val elements = it.chunked(4).map{ elementRegex.find(it)?.value }
                initializeStackLine(elements)
            } else if (it.contains("move")) {
                instructions.add(movesRegex.findAll(it).map{ it.value.toInt() }.toList())
            }
        }

    }

    fun part1(filename: String): String  {
        initalizeStacksAndInstructions(filename)
        instructions.forEach {
            val nTimes = it[0]
            val fromStackNum = it[1] - 1
            val toStackNum = it[2] - 1
            repeat(nTimes) {
                val fromStack = stacks[fromStackNum]
                val moveVal = fromStack.removeAt(0)
                stacks[toStackNum].add(0, moveVal)
            }
        }
        return stacks.map{ if (it.size > 0) it[0] else "" }.joinToString(separator="")
    }

    fun part2(filename: String): String  {
        initalizeStacksAndInstructions(filename)
        instructions.forEach {
            val nTimes = it[0]
            val fromStackNum = it[1] - 1
            val toStackNum = it[2] - 1
            var removeFrom: Int = nTimes - 1;
            repeat(nTimes) {
                val fromStack = stacks[fromStackNum]
                val moveVal = fromStack.removeAt(removeFrom)
                stacks[toStackNum].add(0, moveVal)
                removeFrom -= 1
            }
        }
        return stacks.map{ if (it.size > 0) it[0] else "" }.joinToString(separator="")
    }

    println("part 1: " + part1("input_day05.txt"))
    println("part 2: " + part2("input_day05.txt"))
}

Compiled from "Day05.kt"
public final class Day05Kt {
  public static final void main();
    Code:
       0: new           #8                  // class kotlin/jvm/internal/Ref$ObjectRef
       3: dup
       4: invokespecial #11                 // Method kotlin/jvm/internal/Ref$ObjectRef."<init>":()V
       7: astore_0
       8: aload_0
       9: new           #13                 // class java/util/ArrayList
      12: dup
      13: invokespecial #14                 // Method java/util/ArrayList."<init>":()V
      16: putfield      #18                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      19: new           #8                  // class kotlin/jvm/internal/Ref$ObjectRef
      22: dup
      23: invokespecial #11                 // Method kotlin/jvm/internal/Ref$ObjectRef."<init>":()V
      26: astore_1
      27: aload_1
      28: new           #13                 // class java/util/ArrayList
      31: dup
      32: invokespecial #14                 // Method java/util/ArrayList."<init>":()V
      35: putfield      #18                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      38: new           #20                 // class java/lang/StringBuilder
      41: dup
      42: invokespecial #21                 // Method java/lang/StringBuilder."<init>":()V
      45: ldc           #23                 // String part 1:
      47: invokevirtual #27                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      50: aload_1
      51: aload_0
      52: ldc           #29                 // String input_day05.txt
      54: invokestatic  #33                 // Method main$part1:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;)Ljava/lang/String;
      57: invokevirtual #27                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      60: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      63: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      66: swap
      67: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      70: new           #20                 // class java/lang/StringBuilder
      73: dup
      74: invokespecial #21                 // Method java/lang/StringBuilder."<init>":()V
      77: ldc           #51                 // String part 2:
      79: invokevirtual #27                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      82: aload_1
      83: aload_0
      84: ldc           #29                 // String input_day05.txt
      86: invokestatic  #54                 // Method main$part2:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;)Ljava/lang/String;
      89: invokevirtual #27                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      92: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      95: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      98: swap
      99: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     102: return

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

  private static final void main$initializeStackLine(kotlin.jvm.internal.Ref$ObjectRef<java.util.ArrayList<java.util.ArrayList<java.lang.String>>>, java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: checkcast     #67                 // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: iconst_0
       8: istore        4
      10: aload_2
      11: invokeinterface #71,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      16: astore        5
      18: aload         5
      20: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      25: ifeq          130
      28: aload         5
      30: invokeinterface #81,  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  #86                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      52: iload         7
      54: aload         6
      56: checkcast     #88                 // class java/lang/String
      59: astore        8
      61: istore        9
      63: iconst_0
      64: istore        10
      66: aload_0
      67: getfield      #18                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      70: checkcast     #13                 // class java/util/ArrayList
      73: invokevirtual #92                 // Method java/util/ArrayList.size:()I
      76: iload         9
      78: if_icmpgt     99
      81: aload_0
      82: getfield      #18                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      85: checkcast     #13                 // class java/util/ArrayList
      88: new           #13                 // class java/util/ArrayList
      91: dup
      92: invokespecial #14                 // Method java/util/ArrayList."<init>":()V
      95: invokevirtual #96                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      98: pop
      99: aload         8
     101: ifnull        125
     104: aload_0
     105: getfield      #18                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     108: checkcast     #13                 // class java/util/ArrayList
     111: iload         9
     113: invokevirtual #100                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     116: checkcast     #13                 // class java/util/ArrayList
     119: aload         8
     121: invokevirtual #96                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     124: pop
     125: nop
     126: nop
     127: goto          18
     130: nop
     131: return

  private static final int main$initalizeStacksAndInstructions$lambda$3$lambda$2(kotlin.text.MatchResult);
    Code:
       0: aload_0
       1: ldc           #118                // String it
       3: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokeinterface #129,  1          // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;
      12: invokestatic  #135                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      15: ireturn

  private static final kotlin.Unit main$initalizeStacksAndInstructions$lambda$3(kotlin.jvm.internal.Ref$ObjectRef, kotlin.text.Regex, kotlin.text.Regex, kotlin.jvm.internal.Ref$ObjectRef, java.lang.String);
    Code:
       0: aload         4
       2: ldc           #118                // String it
       4: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload         4
       9: checkcast     #140                // class java/lang/CharSequence
      12: ldc           #142                // String [
      14: checkcast     #140                // class java/lang/CharSequence
      17: iconst_0
      18: iconst_2
      19: aconst_null
      20: invokestatic  #148                // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z
      23: ifeq          166
      26: aload         4
      28: checkcast     #140                // class java/lang/CharSequence
      31: iconst_4
      32: invokestatic  #152                // Method kotlin/text/StringsKt.chunked:(Ljava/lang/CharSequence;I)Ljava/util/List;
      35: checkcast     #67                 // class java/lang/Iterable
      38: astore        6
      40: iconst_0
      41: istore        7
      43: aload         6
      45: astore        8
      47: new           #13                 // class java/util/ArrayList
      50: dup
      51: aload         6
      53: bipush        10
      55: invokestatic  #156                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      58: invokespecial #159                // Method java/util/ArrayList."<init>":(I)V
      61: checkcast     #161                // class java/util/Collection
      64: astore        9
      66: iconst_0
      67: istore        10
      69: aload         8
      71: invokeinterface #71,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      76: astore        11
      78: aload         11
      80: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      85: ifeq          149
      88: aload         11
      90: invokeinterface #81,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      95: astore        12
      97: aload         9
      99: aload         12
     101: checkcast     #88                 // class java/lang/String
     104: astore        13
     106: astore        15
     108: iconst_0
     109: istore        14
     111: aload_2
     112: aload         13
     114: checkcast     #140                // class java/lang/CharSequence
     117: iconst_0
     118: iconst_2
     119: aconst_null
     120: invokestatic  #167                // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;
     123: dup
     124: ifnull        135
     127: invokeinterface #129,  1          // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;
     132: goto          137
     135: pop
     136: aconst_null
     137: aload         15
     139: swap
     140: invokeinterface #168,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     145: pop
     146: goto          78
     149: aload         9
     151: checkcast     #114                // class java/util/List
     154: nop
     155: astore        5
     157: aload_3
     158: aload         5
     160: invokestatic  #170                // Method main$initializeStackLine:(Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/util/List;)V
     163: goto          219
     166: aload         4
     168: checkcast     #140                // class java/lang/CharSequence
     171: ldc           #172                // String move
     173: checkcast     #140                // class java/lang/CharSequence
     176: iconst_0
     177: iconst_2
     178: aconst_null
     179: invokestatic  #148                // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z
     182: ifeq          219
     185: aload_0
     186: getfield      #18                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     189: checkcast     #13                 // class java/util/ArrayList
     192: aload_1
     193: aload         4
     195: checkcast     #140                // class java/lang/CharSequence
     198: iconst_0
     199: iconst_2
     200: aconst_null
     201: invokestatic  #176                // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;
     204: invokedynamic #194,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     209: invokestatic  #200                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     212: invokestatic  #204                // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
     215: invokevirtual #96                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     218: pop
     219: getstatic     #210                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     222: areturn

  private static final void main$initalizeStacksAndInstructions(kotlin.jvm.internal.Ref$ObjectRef<java.util.ArrayList<java.util.ArrayList<java.lang.String>>>, kotlin.jvm.internal.Ref$ObjectRef<java.util.ArrayList<java.util.List<java.lang.Integer>>>, java.lang.String);
    Code:
       0: aload_0
       1: new           #13                 // class java/util/ArrayList
       4: dup
       5: invokespecial #14                 // Method java/util/ArrayList."<init>":()V
       8: putfield      #18                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      11: aload_1
      12: new           #13                 // class java/util/ArrayList
      15: dup
      16: invokespecial #14                 // Method java/util/ArrayList."<init>":()V
      19: putfield      #18                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      22: new           #163                // class kotlin/text/Regex
      25: dup
      26: ldc           #229                // String [A-Z]
      28: invokespecial #232                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      31: astore_3
      32: new           #163                // class kotlin/text/Regex
      35: dup
      36: ldc           #234                // String \\d+
      38: invokespecial #232                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      41: astore        4
      43: new           #236                // class java/io/File
      46: dup
      47: aload_2
      48: invokespecial #237                // Method java/io/File."<init>":(Ljava/lang/String;)V
      51: aconst_null
      52: aload_1
      53: aload         4
      55: aload_3
      56: aload_0
      57: invokedynamic #245,  0            // InvokeDynamic #1:invoke:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/text/Regex;Lkotlin/text/Regex;Lkotlin/jvm/internal/Ref$ObjectRef;)Lkotlin/jvm/functions/Function1;
      62: iconst_1
      63: aconst_null
      64: invokestatic  #251                // Method kotlin/io/FilesKt.forEachLine$default:(Ljava/io/File;Ljava/nio/charset/Charset;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
      67: return

  private static final java.lang.String main$part1(kotlin.jvm.internal.Ref$ObjectRef<java.util.ArrayList<java.util.List<java.lang.Integer>>>, kotlin.jvm.internal.Ref$ObjectRef<java.util.ArrayList<java.util.ArrayList<java.lang.String>>>, java.lang.String);
    Code:
       0: aload_1
       1: aload_0
       2: aload_2
       3: invokestatic  #257                // Method main$initalizeStacksAndInstructions:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;)V
       6: aload_0
       7: getfield      #18                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      10: checkcast     #67                 // class java/lang/Iterable
      13: astore_3
      14: iconst_0
      15: istore        4
      17: aload_3
      18: invokeinterface #71,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      23: astore        5
      25: aload         5
      27: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      32: ifeq          191
      35: aload         5
      37: invokeinterface #81,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      42: astore        6
      44: aload         6
      46: checkcast     #114                // class java/util/List
      49: astore        7
      51: iconst_0
      52: istore        8
      54: aload         7
      56: iconst_0
      57: invokeinterface #258,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      62: checkcast     #260                // class java/lang/Number
      65: invokevirtual #263                // Method java/lang/Number.intValue:()I
      68: istore        9
      70: aload         7
      72: iconst_1
      73: invokeinterface #258,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      78: checkcast     #260                // class java/lang/Number
      81: invokevirtual #263                // Method java/lang/Number.intValue:()I
      84: iconst_1
      85: isub
      86: istore        10
      88: aload         7
      90: iconst_2
      91: invokeinterface #258,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      96: checkcast     #260                // class java/lang/Number
      99: invokevirtual #263                // Method java/lang/Number.intValue:()I
     102: iconst_1
     103: isub
     104: istore        11
     106: iconst_0
     107: istore        12
     109: iload         12
     111: iload         9
     113: if_icmpge     186
     116: iload         12
     118: istore        13
     120: iconst_0
     121: istore        14
     123: aload_1
     124: getfield      #18                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     127: checkcast     #13                 // class java/util/ArrayList
     130: iload         10
     132: invokevirtual #100                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     135: dup
     136: ldc_w         #265                // String get(...)
     139: invokestatic  #268                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     142: checkcast     #13                 // class java/util/ArrayList
     145: astore        15
     147: aload         15
     149: iconst_0
     150: invokevirtual #271                // Method java/util/ArrayList.remove:(I)Ljava/lang/Object;
     153: checkcast     #88                 // class java/lang/String
     156: astore        16
     158: aload_1
     159: getfield      #18                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     162: checkcast     #13                 // class java/util/ArrayList
     165: iload         11
     167: invokevirtual #100                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     170: checkcast     #13                 // class java/util/ArrayList
     173: iconst_0
     174: aload         16
     176: invokevirtual #274                // Method java/util/ArrayList.add:(ILjava/lang/Object;)V
     179: nop
     180: iinc          12, 1
     183: goto          109
     186: nop
     187: nop
     188: goto          25
     191: nop
     192: aload_1
     193: getfield      #18                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     196: checkcast     #67                 // class java/lang/Iterable
     199: astore_3
     200: iconst_0
     201: istore        4
     203: aload_3
     204: astore        5
     206: new           #13                 // class java/util/ArrayList
     209: dup
     210: aload_3
     211: bipush        10
     213: invokestatic  #156                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     216: invokespecial #159                // Method java/util/ArrayList."<init>":(I)V
     219: checkcast     #161                // class java/util/Collection
     222: astore        6
     224: iconst_0
     225: istore        7
     227: aload         5
     229: invokeinterface #71,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     234: astore        8
     236: aload         8
     238: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     243: ifeq          304
     246: aload         8
     248: invokeinterface #81,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     253: astore        9
     255: aload         6
     257: aload         9
     259: checkcast     #13                 // class java/util/ArrayList
     262: astore        10
     264: astore        17
     266: iconst_0
     267: istore        11
     269: aload         10
     271: invokevirtual #92                 // Method java/util/ArrayList.size:()I
     274: ifle          289
     277: aload         10
     279: iconst_0
     280: invokevirtual #100                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     283: checkcast     #88                 // class java/lang/String
     286: goto          292
     289: ldc_w         #276                // String
     292: aload         17
     294: swap
     295: invokeinterface #168,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     300: pop
     301: goto          236
     304: aload         6
     306: checkcast     #114                // class java/util/List
     309: nop
     310: checkcast     #67                 // class java/lang/Iterable
     313: ldc_w         #276                // String
     316: checkcast     #140                // class java/lang/CharSequence
     319: aconst_null
     320: aconst_null
     321: iconst_0
     322: aconst_null
     323: aconst_null
     324: bipush        62
     326: aconst_null
     327: invokestatic  #280                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
     330: areturn

  private static final java.lang.String main$part2(kotlin.jvm.internal.Ref$ObjectRef<java.util.ArrayList<java.util.List<java.lang.Integer>>>, kotlin.jvm.internal.Ref$ObjectRef<java.util.ArrayList<java.util.ArrayList<java.lang.String>>>, java.lang.String);
    Code:
       0: aload_1
       1: aload_0
       2: aload_2
       3: invokestatic  #257                // Method main$initalizeStacksAndInstructions:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;Ljava/lang/String;)V
       6: aload_0
       7: getfield      #18                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      10: checkcast     #67                 // class java/lang/Iterable
      13: astore_3
      14: iconst_0
      15: istore        4
      17: aload_3
      18: invokeinterface #71,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      23: astore        5
      25: aload         5
      27: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      32: ifeq          207
      35: aload         5
      37: invokeinterface #81,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      42: astore        6
      44: aload         6
      46: checkcast     #114                // class java/util/List
      49: astore        7
      51: iconst_0
      52: istore        8
      54: aload         7
      56: iconst_0
      57: invokeinterface #258,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      62: checkcast     #260                // class java/lang/Number
      65: invokevirtual #263                // Method java/lang/Number.intValue:()I
      68: istore        9
      70: aload         7
      72: iconst_1
      73: invokeinterface #258,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      78: checkcast     #260                // class java/lang/Number
      81: invokevirtual #263                // Method java/lang/Number.intValue:()I
      84: iconst_1
      85: isub
      86: istore        10
      88: aload         7
      90: iconst_2
      91: invokeinterface #258,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      96: checkcast     #260                // class java/lang/Number
      99: invokevirtual #263                // Method java/lang/Number.intValue:()I
     102: iconst_1
     103: isub
     104: istore        11
     106: iconst_0
     107: istore        12
     109: iload         9
     111: iconst_1
     112: isub
     113: istore        12
     115: iconst_0
     116: istore        13
     118: iload         13
     120: iload         9
     122: if_icmpge     202
     125: iload         13
     127: istore        14
     129: iconst_0
     130: istore        15
     132: aload_1
     133: getfield      #18                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     136: checkcast     #13                 // class java/util/ArrayList
     139: iload         10
     141: invokevirtual #100                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     144: dup
     145: ldc_w         #265                // String get(...)
     148: invokestatic  #268                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     151: checkcast     #13                 // class java/util/ArrayList
     154: astore        16
     156: aload         16
     158: iload         12
     160: invokevirtual #271                // Method java/util/ArrayList.remove:(I)Ljava/lang/Object;
     163: checkcast     #88                 // class java/lang/String
     166: astore        17
     168: aload_1
     169: getfield      #18                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     172: checkcast     #13                 // class java/util/ArrayList
     175: iload         11
     177: invokevirtual #100                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     180: checkcast     #13                 // class java/util/ArrayList
     183: iconst_0
     184: aload         17
     186: invokevirtual #274                // Method java/util/ArrayList.add:(ILjava/lang/Object;)V
     189: iload         12
     191: iconst_1
     192: isub
     193: istore        12
     195: nop
     196: iinc          13, 1
     199: goto          118
     202: nop
     203: nop
     204: goto          25
     207: nop
     208: aload_1
     209: getfield      #18                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     212: checkcast     #67                 // class java/lang/Iterable
     215: astore_3
     216: iconst_0
     217: istore        4
     219: aload_3
     220: astore        5
     222: new           #13                 // class java/util/ArrayList
     225: dup
     226: aload_3
     227: bipush        10
     229: invokestatic  #156                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     232: invokespecial #159                // Method java/util/ArrayList."<init>":(I)V
     235: checkcast     #161                // class java/util/Collection
     238: astore        6
     240: iconst_0
     241: istore        7
     243: aload         5
     245: invokeinterface #71,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     250: astore        8
     252: aload         8
     254: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     259: ifeq          320
     262: aload         8
     264: invokeinterface #81,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     269: astore        9
     271: aload         6
     273: aload         9
     275: checkcast     #13                 // class java/util/ArrayList
     278: astore        10
     280: astore        18
     282: iconst_0
     283: istore        11
     285: aload         10
     287: invokevirtual #92                 // Method java/util/ArrayList.size:()I
     290: ifle          305
     293: aload         10
     295: iconst_0
     296: invokevirtual #100                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     299: checkcast     #88                 // class java/lang/String
     302: goto          308
     305: ldc_w         #276                // String
     308: aload         18
     310: swap
     311: invokeinterface #168,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     316: pop
     317: goto          252
     320: aload         6
     322: checkcast     #114                // class java/util/List
     325: nop
     326: checkcast     #67                 // class java/lang/Iterable
     329: ldc_w         #276                // String
     332: checkcast     #140                // class java/lang/CharSequence
     335: aconst_null
     336: aconst_null
     337: iconst_0
     338: aconst_null
     339: aconst_null
     340: bipush        62
     342: aconst_null
     343: invokestatic  #280                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
     346: areturn
}


import java.io.File

fun main() {

    val letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

    fun mispackedCharacter(contents: String): String {
        val compartmentAContents: CharArray = contents.substring(0, contents.length/2).toCharArray()
        val compartmentBContents: CharArray = contents.substring(contents.length/2).toCharArray()
        return compartmentAContents.intersect(compartmentBContents.asIterable()).first().toString()
    }

    fun commonCharacter(str1: String, str2: String, str3: String): String {
        return str1.toCharArray().intersect(
                str2.toCharArray().asIterable()
            ).intersect(
                str3.toCharArray().asIterable()
            ).first().toString()
    }

    fun part1(filename: String): Int? {
        var priorityTotal: Int = 0;
        File(filename).forEachLine {
            val char: String = mispackedCharacter(it)
            priorityTotal += letters.indexOf(char) + 1
        }
        return priorityTotal;
    }

    fun part2(filename: String): Int? {
        var priorityTotal: Int = 0;
        var threesie: ArrayList<String> = ArrayList();
        File(filename).forEachLine {
            threesie.add(it)
            if (threesie.size == 3) {
                val char: String = commonCharacter(threesie[0], threesie[1], threesie[2])
                priorityTotal += letters.indexOf(char) + 1
                threesie = ArrayList()
            }
        }
        return priorityTotal;
    }

    println("part 1: " + part1("input_day03.txt"))
    println("part 2: " + part2("input_day03.txt"))
}

Compiled from "Day03.kt"
public final class Day03Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
       2: astore_0
       3: new           #10                 // class java/lang/StringBuilder
       6: dup
       7: invokespecial #13                 // Method java/lang/StringBuilder."<init>":()V
      10: ldc           #15                 // String part 1:
      12: invokevirtual #19                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      15: aload_0
      16: ldc           #21                 // String input_day03.txt
      18: invokestatic  #25                 // Method main$part1:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Integer;
      21: invokevirtual #28                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      24: invokevirtual #32                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      27: getstatic     #38                 // Field java/lang/System.out:Ljava/io/PrintStream;
      30: swap
      31: invokevirtual #44                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      34: new           #10                 // class java/lang/StringBuilder
      37: dup
      38: invokespecial #13                 // Method java/lang/StringBuilder."<init>":()V
      41: ldc           #46                 // String part 2:
      43: invokevirtual #19                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      46: aload_0
      47: ldc           #21                 // String input_day03.txt
      49: invokestatic  #49                 // Method main$part2:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Integer;
      52: invokevirtual #28                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      55: invokevirtual #32                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      58: getstatic     #38                 // Field java/lang/System.out:Ljava/io/PrintStream;
      61: swap
      62: invokevirtual #44                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      65: return

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

  private static final java.lang.String main$mispackedCharacter(java.lang.String);
    Code:
       0: nop
       1: aload_0
       2: iconst_0
       3: aload_0
       4: invokevirtual #64                 // Method java/lang/String.length:()I
       7: iconst_2
       8: idiv
       9: invokevirtual #68                 // Method java/lang/String.substring:(II)Ljava/lang/String;
      12: dup
      13: ldc           #70                 // String substring(...)
      15: invokestatic  #76                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      18: invokevirtual #80                 // Method java/lang/String.toCharArray:()[C
      21: dup
      22: ldc           #82                 // String toCharArray(...)
      24: invokestatic  #76                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      27: astore_1
      28: nop
      29: aload_0
      30: aload_0
      31: invokevirtual #64                 // Method java/lang/String.length:()I
      34: iconst_2
      35: idiv
      36: invokevirtual #85                 // Method java/lang/String.substring:(I)Ljava/lang/String;
      39: dup
      40: ldc           #70                 // String substring(...)
      42: invokestatic  #76                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      45: invokevirtual #80                 // Method java/lang/String.toCharArray:()[C
      48: dup
      49: ldc           #82                 // String toCharArray(...)
      51: invokestatic  #76                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      54: astore_2
      55: aload_1
      56: aload_2
      57: invokestatic  #91                 // Method kotlin/collections/ArraysKt.asIterable:([C)Ljava/lang/Iterable;
      60: invokestatic  #95                 // Method kotlin/collections/ArraysKt.intersect:([CLjava/lang/Iterable;)Ljava/util/Set;
      63: checkcast     #97                 // class java/lang/Iterable
      66: invokestatic  #103                // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;
      69: checkcast     #105                // class java/lang/Character
      72: invokevirtual #109                // Method java/lang/Character.charValue:()C
      75: invokestatic  #113                // Method java/lang/String.valueOf:(C)Ljava/lang/String;
      78: areturn

  private static final java.lang.String main$commonCharacter(java.lang.String, java.lang.String, java.lang.String);
    Code:
       0: aload_0
       1: invokevirtual #80                 // Method java/lang/String.toCharArray:()[C
       4: dup
       5: ldc           #82                 // String toCharArray(...)
       7: invokestatic  #76                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      10: aload_1
      11: invokevirtual #80                 // Method java/lang/String.toCharArray:()[C
      14: dup
      15: ldc           #82                 // String toCharArray(...)
      17: invokestatic  #76                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      20: invokestatic  #91                 // Method kotlin/collections/ArraysKt.asIterable:([C)Ljava/lang/Iterable;
      23: invokestatic  #95                 // Method kotlin/collections/ArraysKt.intersect:([CLjava/lang/Iterable;)Ljava/util/Set;
      26: checkcast     #97                 // class java/lang/Iterable
      29: aload_2
      30: invokevirtual #80                 // Method java/lang/String.toCharArray:()[C
      33: dup
      34: ldc           #82                 // String toCharArray(...)
      36: invokestatic  #76                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      39: invokestatic  #91                 // Method kotlin/collections/ArraysKt.asIterable:([C)Ljava/lang/Iterable;
      42: invokestatic  #122                // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
      45: checkcast     #97                 // class java/lang/Iterable
      48: invokestatic  #103                // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;
      51: checkcast     #105                // class java/lang/Character
      54: invokevirtual #109                // Method java/lang/Character.charValue:()C
      57: invokestatic  #113                // Method java/lang/String.valueOf:(C)Ljava/lang/String;
      60: areturn

  private static final kotlin.Unit main$part1$lambda$0(kotlin.jvm.internal.Ref$IntRef, java.lang.String, java.lang.String);
    Code:
       0: aload_2
       1: ldc           #129                // String it
       3: invokestatic  #132                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: invokestatic  #134                // Method main$mispackedCharacter:(Ljava/lang/String;)Ljava/lang/String;
      10: astore_3
      11: aload_0
      12: aload_0
      13: getfield      #140                // Field kotlin/jvm/internal/Ref$IntRef.element:I
      16: aload_1
      17: checkcast     #142                // class java/lang/CharSequence
      20: aload_3
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #148                // Method kotlin/text/StringsKt.indexOf$default:(Ljava/lang/CharSequence;Ljava/lang/String;IZILjava/lang/Object;)I
      29: iconst_1
      30: iadd
      31: iadd
      32: putfield      #140                // Field kotlin/jvm/internal/Ref$IntRef.element:I
      35: getstatic     #154                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      38: areturn

  private static final java.lang.Integer main$part1(java.lang.String, java.lang.String);
    Code:
       0: new           #136                // class kotlin/jvm/internal/Ref$IntRef
       3: dup
       4: invokespecial #159                // Method kotlin/jvm/internal/Ref$IntRef."<init>":()V
       7: astore_2
       8: new           #161                // class java/io/File
      11: dup
      12: aload_1
      13: invokespecial #164                // Method java/io/File."<init>":(Ljava/lang/String;)V
      16: aconst_null
      17: aload_2
      18: aload_0
      19: invokedynamic #182,  0            // InvokeDynamic #0:invoke:(Lkotlin/jvm/internal/Ref$IntRef;Ljava/lang/String;)Lkotlin/jvm/functions/Function1;
      24: iconst_1
      25: aconst_null
      26: invokestatic  #188                // Method kotlin/io/FilesKt.forEachLine$default:(Ljava/io/File;Ljava/nio/charset/Charset;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
      29: aload_2
      30: getfield      #140                // Field kotlin/jvm/internal/Ref$IntRef.element:I
      33: invokestatic  #193                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      36: areturn

  private static final kotlin.Unit main$part2$lambda$1(kotlin.jvm.internal.Ref$ObjectRef, kotlin.jvm.internal.Ref$IntRef, java.lang.String, java.lang.String);
    Code:
       0: aload_3
       1: ldc           #129                // String it
       3: invokestatic  #132                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: getfield      #202                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      10: checkcast     #204                // class java/util/ArrayList
      13: aload_3
      14: invokevirtual #208                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      17: pop
      18: aload_0
      19: getfield      #202                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      22: checkcast     #204                // class java/util/ArrayList
      25: invokevirtual #211                // Method java/util/ArrayList.size:()I
      28: iconst_3
      29: if_icmpne     133
      32: aload_0
      33: getfield      #202                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      36: checkcast     #204                // class java/util/ArrayList
      39: iconst_0
      40: invokevirtual #215                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
      43: dup
      44: ldc           #217                // String get(...)
      46: invokestatic  #76                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      49: checkcast     #60                 // class java/lang/String
      52: aload_0
      53: getfield      #202                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      56: checkcast     #204                // class java/util/ArrayList
      59: iconst_1
      60: invokevirtual #215                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
      63: dup
      64: ldc           #217                // String get(...)
      66: invokestatic  #76                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      69: checkcast     #60                 // class java/lang/String
      72: aload_0
      73: getfield      #202                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      76: checkcast     #204                // class java/util/ArrayList
      79: iconst_2
      80: invokevirtual #215                // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
      83: dup
      84: ldc           #217                // String get(...)
      86: invokestatic  #76                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      89: checkcast     #60                 // class java/lang/String
      92: invokestatic  #219                // Method main$commonCharacter:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
      95: astore        4
      97: aload_1
      98: aload_1
      99: getfield      #140                // Field kotlin/jvm/internal/Ref$IntRef.element:I
     102: aload_2
     103: checkcast     #142                // class java/lang/CharSequence
     106: aload         4
     108: iconst_0
     109: iconst_0
     110: bipush        6
     112: aconst_null
     113: invokestatic  #148                // Method kotlin/text/StringsKt.indexOf$default:(Ljava/lang/CharSequence;Ljava/lang/String;IZILjava/lang/Object;)I
     116: iconst_1
     117: iadd
     118: iadd
     119: putfield      #140                // Field kotlin/jvm/internal/Ref$IntRef.element:I
     122: aload_0
     123: new           #204                // class java/util/ArrayList
     126: dup
     127: invokespecial #220                // Method java/util/ArrayList."<init>":()V
     130: putfield      #202                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     133: getstatic     #154                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     136: areturn

  private static final java.lang.Integer main$part2(java.lang.String, java.lang.String);
    Code:
       0: new           #136                // class kotlin/jvm/internal/Ref$IntRef
       3: dup
       4: invokespecial #159                // Method kotlin/jvm/internal/Ref$IntRef."<init>":()V
       7: astore_2
       8: new           #199                // class kotlin/jvm/internal/Ref$ObjectRef
      11: dup
      12: invokespecial #223                // Method kotlin/jvm/internal/Ref$ObjectRef."<init>":()V
      15: astore_3
      16: aload_3
      17: new           #204                // class java/util/ArrayList
      20: dup
      21: invokespecial #220                // Method java/util/ArrayList."<init>":()V
      24: putfield      #202                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      27: new           #161                // class java/io/File
      30: dup
      31: aload_1
      32: invokespecial #164                // Method java/io/File."<init>":(Ljava/lang/String;)V
      35: aconst_null
      36: aload_3
      37: aload_2
      38: aload_0
      39: invokedynamic #229,  0            // InvokeDynamic #1:invoke:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$IntRef;Ljava/lang/String;)Lkotlin/jvm/functions/Function1;
      44: iconst_1
      45: aconst_null
      46: invokestatic  #188                // Method kotlin/io/FilesKt.forEachLine$default:(Ljava/io/File;Ljava/nio/charset/Charset;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
      49: aload_2
      50: getfield      #140                // Field kotlin/jvm/internal/Ref$IntRef.element:I
      53: invokestatic  #193                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      56: areturn
}