package day04

import java.io.File

fun main() {
    val data = parse("src/main/kotlin/day04/Day04.txt")

    val answer1 = part1(data)
    val answer2 = part2(data)

    println("🎄 Day 04 🎄")

    println()

    println("[Part 1]")
    println("Answer: $answer1")

    println()

    println("[Part 2]")
    println("Answer: $answer2")
}

private data class Range(
    val start: Int,
    val end: Int
)

private fun String.toRange(): Range =
    this.split("-")
        .map(String::toInt)
        .let { (start, end) -> Range(start, end) }

@Suppress("SameParameterValue")
private fun parse(path: String): List<Pair<Range, Range>> =
    File(path).useLines { lines -> lines
        .map { it.split(",").map(String::toRange) }
        .map { (lhs, rhs) -> lhs to rhs }
        .toList()
    }

private fun Range.contains(other: Range): Boolean =
    start <= other.start && other.end <= end

private fun Range.overlaps(other: Range): Boolean =
    contains(other)
        || (other.start <= start && start <= other.end)
        || (other.start <= end && end <= other.end)

private fun part1(data: List<Pair<Range, Range>>): Int =
    data.count { (a, b) -> a.contains(b) || b.contains(a) }

private fun part2(data: List<Pair<Range, Range>>): Int =
    data.count { (a, b) -> a.overlaps(b) || b.overlaps(a) }

Compiled from "Day04.kt"
public final class day04.Day04Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String src/main/kotlin/day04/Day04.txt
       2: invokestatic  #12                 // Method parse:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #16                 // Method part1:(Ljava/util/List;)I
      10: istore_1
      11: aload_0
      12: invokestatic  #19                 // Method part2:(Ljava/util/List;)I
      15: istore_2
      16: ldc           #21                 // String 🎄 Day 04 🎄
      18: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      21: swap
      22: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      25: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      28: invokevirtual #35                 // Method java/io/PrintStream.println:()V
      31: ldc           #37                 // String [Part 1]
      33: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      36: swap
      37: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      40: new           #39                 // class java/lang/StringBuilder
      43: dup
      44: invokespecial #42                 // Method java/lang/StringBuilder."<init>":()V
      47: ldc           #44                 // String Answer:
      49: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      52: iload_1
      53: invokevirtual #51                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      56: invokevirtual #55                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      59: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      62: swap
      63: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      66: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      69: invokevirtual #35                 // Method java/io/PrintStream.println:()V
      72: ldc           #57                 // String [Part 2]
      74: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      77: swap
      78: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      81: new           #39                 // class java/lang/StringBuilder
      84: dup
      85: invokespecial #42                 // Method java/lang/StringBuilder."<init>":()V
      88: ldc           #44                 // String Answer:
      90: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      93: iload_2
      94: invokevirtual #51                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      97: invokevirtual #55                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     100: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
     103: swap
     104: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     107: return

  private static final day04.Range toRange(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #66                 // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #68                 // class java/lang/String
       8: astore_1
       9: aload_1
      10: iconst_0
      11: ldc           #70                 // String -
      13: aastore
      14: aload_1
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #76                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: checkcast     #78                 // class java/lang/Iterable
      26: astore_1
      27: nop
      28: iconst_0
      29: istore_2
      30: aload_1
      31: astore_3
      32: new           #80                 // class java/util/ArrayList
      35: dup
      36: aload_1
      37: bipush        10
      39: invokestatic  #86                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      42: invokespecial #89                 // Method java/util/ArrayList."<init>":(I)V
      45: checkcast     #91                 // class java/util/Collection
      48: astore        4
      50: iconst_0
      51: istore        5
      53: aload_3
      54: invokeinterface #95,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      59: astore        6
      61: aload         6
      63: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      68: ifeq          115
      71: aload         6
      73: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      78: astore        7
      80: aload         4
      82: aload         7
      84: checkcast     #68                 // class java/lang/String
      87: astore        8
      89: astore        10
      91: iconst_0
      92: istore        9
      94: aload         8
      96: invokestatic  #111                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      99: nop
     100: invokestatic  #115                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     103: aload         10
     105: swap
     106: invokeinterface #119,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     111: pop
     112: goto          61
     115: aload         4
     117: checkcast     #121                // class java/util/List
     120: nop
     121: astore_2
     122: iconst_0
     123: istore_3
     124: aload_2
     125: iconst_0
     126: invokeinterface #125,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     131: checkcast     #127                // class java/lang/Number
     134: invokevirtual #131                // Method java/lang/Number.intValue:()I
     137: istore        4
     139: aload_2
     140: iconst_1
     141: invokeinterface #125,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     146: checkcast     #127                // class java/lang/Number
     149: invokevirtual #131                // Method java/lang/Number.intValue:()I
     152: istore        5
     154: new           #133                // class day04/Range
     157: dup
     158: iload         4
     160: iload         5
     162: invokespecial #136                // Method day04/Range."<init>":(II)V
     165: nop
     166: areturn

  private static final java.util.List<kotlin.Pair<day04.Range, day04.Range>> parse(java.lang.String);
    Code:
       0: new           #157                // class java/io/File
       3: dup
       4: aload_0
       5: invokespecial #160                // Method java/io/File."<init>":(Ljava/lang/String;)V
       8: astore_1
       9: getstatic     #166                // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      12: astore_2
      13: iconst_0
      14: istore_3
      15: aload_1
      16: astore        4
      18: sipush        8192
      21: istore        5
      23: aload         4
      25: astore        6
      27: new           #168                // class java/io/InputStreamReader
      30: dup
      31: new           #170                // class java/io/FileInputStream
      34: dup
      35: aload         6
      37: invokespecial #173                // Method java/io/FileInputStream."<init>":(Ljava/io/File;)V
      40: checkcast     #175                // class java/io/InputStream
      43: aload_2
      44: invokespecial #178                // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
      47: checkcast     #180                // class java/io/Reader
      50: astore        6
      52: aload         6
      54: instanceof    #182                // class java/io/BufferedReader
      57: ifeq          68
      60: aload         6
      62: checkcast     #182                // class java/io/BufferedReader
      65: goto          79
      68: new           #182                // class java/io/BufferedReader
      71: dup
      72: aload         6
      74: iload         5
      76: invokespecial #185                // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
      79: checkcast     #187                // class java/io/Closeable
      82: astore        4
      84: aconst_null
      85: astore        5
      87: nop
      88: aload         4
      90: checkcast     #182                // class java/io/BufferedReader
      93: astore        6
      95: iconst_0
      96: istore        7
      98: aload         6
     100: invokestatic  #193                // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;
     103: astore        8
     105: iconst_0
     106: istore        9
     108: aload         8
     110: invokedynamic #211,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     115: invokestatic  #217                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     118: invokedynamic #224,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
     123: invokestatic  #217                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     126: invokestatic  #228                // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
     129: astore        6
     131: aload         4
     133: aload         5
     135: invokestatic  #234                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     138: aload         6
     140: goto          164
     143: astore        7
     145: aload         7
     147: astore        5
     149: aload         7
     151: athrow
     152: astore        7
     154: aload         4
     156: aload         5
     158: invokestatic  #234                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     161: aload         7
     163: athrow
     164: nop
     165: areturn
    Exception table:
       from    to  target type
          87   131   143   Class java/lang/Throwable
          87   131   152   any
         143   152   152   any
         152   154   152   any

  private static final boolean contains(day04.Range, day04.Range);
    Code:
       0: aload_0
       1: invokevirtual #254                // Method day04/Range.getStart:()I
       4: aload_1
       5: invokevirtual #254                // Method day04/Range.getStart:()I
       8: if_icmpgt     26
      11: aload_1
      12: invokevirtual #257                // Method day04/Range.getEnd:()I
      15: aload_0
      16: invokevirtual #257                // Method day04/Range.getEnd:()I
      19: if_icmpgt     26
      22: iconst_1
      23: goto          27
      26: iconst_0
      27: ireturn

  private static final boolean overlaps(day04.Range, day04.Range);
    Code:
       0: aload_0
       1: aload_1
       2: invokestatic  #263                // Method contains:(Lday04/Range;Lday04/Range;)Z
       5: ifne          52
       8: aload_1
       9: invokevirtual #254                // Method day04/Range.getStart:()I
      12: aload_0
      13: invokevirtual #254                // Method day04/Range.getStart:()I
      16: if_icmpgt     30
      19: aload_0
      20: invokevirtual #254                // Method day04/Range.getStart:()I
      23: aload_1
      24: invokevirtual #257                // Method day04/Range.getEnd:()I
      27: if_icmple     52
      30: aload_1
      31: invokevirtual #254                // Method day04/Range.getStart:()I
      34: aload_0
      35: invokevirtual #257                // Method day04/Range.getEnd:()I
      38: if_icmpgt     56
      41: aload_0
      42: invokevirtual #257                // Method day04/Range.getEnd:()I
      45: aload_1
      46: invokevirtual #257                // Method day04/Range.getEnd:()I
      49: if_icmpgt     56
      52: iconst_1
      53: goto          57
      56: iconst_0
      57: ireturn

  private static final int part1(java.util.List<kotlin.Pair<day04.Range, day04.Range>>);
    Code:
       0: aload_0
       1: checkcast     #78                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: instanceof    #91                 // class java/util/Collection
      11: ifeq          30
      14: aload_1
      15: checkcast     #91                 // class java/util/Collection
      18: invokeinterface #268,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      23: ifeq          30
      26: iconst_0
      27: goto          131
      30: iconst_0
      31: istore_3
      32: aload_1
      33: invokeinterface #95,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      38: astore        4
      40: aload         4
      42: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      47: ifeq          130
      50: aload         4
      52: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      57: astore        5
      59: aload         5
      61: checkcast     #270                // class kotlin/Pair
      64: astore        6
      66: iconst_0
      67: istore        7
      69: aload         6
      71: invokevirtual #273                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      74: checkcast     #133                // class day04/Range
      77: astore        8
      79: aload         6
      81: invokevirtual #276                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      84: checkcast     #133                // class day04/Range
      87: astore        9
      89: aload         8
      91: aload         9
      93: invokestatic  #263                // Method contains:(Lday04/Range;Lday04/Range;)Z
      96: ifne          109
      99: aload         9
     101: aload         8
     103: invokestatic  #263                // Method contains:(Lday04/Range;Lday04/Range;)Z
     106: ifeq          113
     109: iconst_1
     110: goto          114
     113: iconst_0
     114: ifeq          40
     117: iinc          3, 1
     120: iload_3
     121: ifge          40
     124: invokestatic  #279                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     127: goto          40
     130: iload_3
     131: ireturn

  private static final int part2(java.util.List<kotlin.Pair<day04.Range, day04.Range>>);
    Code:
       0: aload_0
       1: checkcast     #78                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: instanceof    #91                 // class java/util/Collection
      11: ifeq          30
      14: aload_1
      15: checkcast     #91                 // class java/util/Collection
      18: invokeinterface #268,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      23: ifeq          30
      26: iconst_0
      27: goto          131
      30: iconst_0
      31: istore_3
      32: aload_1
      33: invokeinterface #95,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      38: astore        4
      40: aload         4
      42: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      47: ifeq          130
      50: aload         4
      52: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      57: astore        5
      59: aload         5
      61: checkcast     #270                // class kotlin/Pair
      64: astore        6
      66: iconst_0
      67: istore        7
      69: aload         6
      71: invokevirtual #273                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      74: checkcast     #133                // class day04/Range
      77: astore        8
      79: aload         6
      81: invokevirtual #276                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      84: checkcast     #133                // class day04/Range
      87: astore        9
      89: aload         8
      91: aload         9
      93: invokestatic  #288                // Method overlaps:(Lday04/Range;Lday04/Range;)Z
      96: ifne          109
      99: aload         9
     101: aload         8
     103: invokestatic  #288                // Method overlaps:(Lday04/Range;Lday04/Range;)Z
     106: ifeq          113
     109: iconst_1
     110: goto          114
     113: iconst_0
     114: ifeq          40
     117: iinc          3, 1
     120: iload_3
     121: ifge          40
     124: invokestatic  #279                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     127: goto          40
     130: iload_3
     131: ireturn

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

  private static final java.util.List parse$lambda$4$lambda$2(java.lang.String);
    Code:
       0: aload_0
       1: ldc_w         #296                // String it
       4: invokestatic  #302                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: checkcast     #66                 // class java/lang/CharSequence
      11: iconst_1
      12: anewarray     #68                 // class java/lang/String
      15: astore_1
      16: aload_1
      17: iconst_0
      18: ldc_w         #304                // String ,
      21: aastore
      22: aload_1
      23: iconst_0
      24: iconst_0
      25: bipush        6
      27: aconst_null
      28: invokestatic  #76                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      31: checkcast     #78                 // class java/lang/Iterable
      34: astore_1
      35: iconst_0
      36: istore_2
      37: aload_1
      38: astore_3
      39: new           #80                 // class java/util/ArrayList
      42: dup
      43: aload_1
      44: bipush        10
      46: invokestatic  #86                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      49: invokespecial #89                 // Method java/util/ArrayList."<init>":(I)V
      52: checkcast     #91                 // class java/util/Collection
      55: astore        4
      57: iconst_0
      58: istore        5
      60: aload_3
      61: invokeinterface #95,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      66: astore        6
      68: aload         6
      70: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      75: ifeq          118
      78: aload         6
      80: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      85: astore        7
      87: aload         4
      89: aload         7
      91: checkcast     #68                 // class java/lang/String
      94: astore        8
      96: astore        10
      98: iconst_0
      99: istore        9
     101: aload         8
     103: invokestatic  #306                // Method toRange:(Ljava/lang/String;)Lday04/Range;
     106: aload         10
     108: swap
     109: invokeinterface #119,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     114: pop
     115: goto          68
     118: aload         4
     120: checkcast     #121                // class java/util/List
     123: nop
     124: areturn

  private static final kotlin.Pair parse$lambda$4$lambda$3(java.util.List);
    Code:
       0: aload_0
       1: ldc_w         #309                // String <destruct>
       4: invokestatic  #302                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: iconst_0
       9: invokeinterface #125,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      14: checkcast     #133                // class day04/Range
      17: astore_1
      18: aload_0
      19: iconst_1
      20: invokeinterface #125,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      25: checkcast     #133                // class day04/Range
      28: astore_2
      29: aload_1
      30: aload_2
      31: invokestatic  #315                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      34: areturn
}


package day02

import java.io.File

fun main() {
    val data = parse("src/main/kotlin/day02/Day02.txt")

    val answer1 = part1(data)
    val answer2 = part2(data)

    println("🎄 Day 02 🎄")

    println()

    println("[Part 1]")
    println("Answer: $answer1")

    println()

    println("[Part 2]")
    println("Answer: $answer2")
}

private data class Rule(
    val points: Int,
    val beats: String,
    val loses: String,
)

private val rules = mapOf(
    "A" to Rule(points = 1, beats = "C", loses = "B"), // Rock
    "B" to Rule(points = 2, beats = "A", loses = "C"), // Paper
    "C" to Rule(points = 3, beats = "B", loses = "A"), // Scissors
)

private fun assignPoints(elf: String, you: String): Int = when {
    rules[you]?.beats == elf -> 6
    rules[elf]?.beats == you -> 0
    else -> 3
}

private fun playRound(elf: String, you: String): Int =
    rules[you]!!.points + assignPoints(elf, you)

@Suppress("SameParameterValue")
private fun parse(path: String): List<Pair<String, String>> =
    File(path).useLines { lines ->
        lines.map { it.split(" ").let { (a, b) -> a to b } }.toList()
    }

private fun part1(data: List<Pair<String, String>>): Int =
    data.sumOf { (elf, you) ->
        playRound(elf, when (you) {
            "X" -> "A"
            "Y" -> "B"
            "Z" -> "C"
            else -> throw IllegalArgumentException()
        })
    }

private fun part2(data: List<Pair<String, String>>): Int =
    data.sumOf { (elf, you) ->
        playRound(elf, when (you) {
            "X" -> rules[elf]!!.beats
            "Y" -> elf
            "Z" -> rules[elf]!!.loses
            else -> throw IllegalArgumentException()
        })
    }

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

  public static final void main();
    Code:
       0: ldc           #8                  // String src/main/kotlin/day02/Day02.txt
       2: invokestatic  #12                 // Method parse:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #16                 // Method part1:(Ljava/util/List;)I
      10: istore_1
      11: aload_0
      12: invokestatic  #19                 // Method part2:(Ljava/util/List;)I
      15: istore_2
      16: ldc           #21                 // String 🎄 Day 02 🎄
      18: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      21: swap
      22: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      25: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      28: invokevirtual #35                 // Method java/io/PrintStream.println:()V
      31: ldc           #37                 // String [Part 1]
      33: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      36: swap
      37: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      40: new           #39                 // class java/lang/StringBuilder
      43: dup
      44: invokespecial #42                 // Method java/lang/StringBuilder."<init>":()V
      47: ldc           #44                 // String Answer:
      49: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      52: iload_1
      53: invokevirtual #51                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      56: invokevirtual #55                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      59: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      62: swap
      63: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      66: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      69: invokevirtual #35                 // Method java/io/PrintStream.println:()V
      72: ldc           #57                 // String [Part 2]
      74: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      77: swap
      78: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      81: new           #39                 // class java/lang/StringBuilder
      84: dup
      85: invokespecial #42                 // Method java/lang/StringBuilder."<init>":()V
      88: ldc           #44                 // String Answer:
      90: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      93: iload_2
      94: invokevirtual #51                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      97: invokevirtual #55                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     100: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
     103: swap
     104: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     107: return

  private static final int assignPoints(java.lang.String, java.lang.String);
    Code:
       0: nop
       1: getstatic     #68                 // Field rules:Ljava/util/Map;
       4: aload_1
       5: invokeinterface #74,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      10: checkcast     #76                 // class day02/Rule
      13: dup
      14: ifnull        23
      17: invokevirtual #79                 // Method day02/Rule.getBeats:()Ljava/lang/String;
      20: goto          25
      23: pop
      24: aconst_null
      25: aload_0
      26: invokestatic  #85                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      29: ifeq          37
      32: bipush        6
      34: goto          73
      37: getstatic     #68                 // Field rules:Ljava/util/Map;
      40: aload_0
      41: invokeinterface #74,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      46: checkcast     #76                 // class day02/Rule
      49: dup
      50: ifnull        59
      53: invokevirtual #79                 // Method day02/Rule.getBeats:()Ljava/lang/String;
      56: goto          61
      59: pop
      60: aconst_null
      61: aload_1
      62: invokestatic  #85                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      65: ifeq          72
      68: iconst_0
      69: goto          73
      72: iconst_3
      73: ireturn

  private static final int playRound(java.lang.String, java.lang.String);
    Code:
       0: getstatic     #68                 // Field rules:Ljava/util/Map;
       3: aload_1
       4: invokeinterface #74,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
       9: dup
      10: invokestatic  #94                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      13: checkcast     #76                 // class day02/Rule
      16: invokevirtual #98                 // Method day02/Rule.getPoints:()I
      19: aload_0
      20: aload_1
      21: invokestatic  #100                // Method assignPoints:(Ljava/lang/String;Ljava/lang/String;)I
      24: iadd
      25: ireturn

  private static final java.util.List<kotlin.Pair<java.lang.String, java.lang.String>> parse(java.lang.String);
    Code:
       0: new           #105                // class java/io/File
       3: dup
       4: aload_0
       5: invokespecial #108                // Method java/io/File."<init>":(Ljava/lang/String;)V
       8: astore_1
       9: getstatic     #114                // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      12: astore_2
      13: iconst_0
      14: istore_3
      15: aload_1
      16: astore        4
      18: sipush        8192
      21: istore        5
      23: aload         4
      25: astore        6
      27: new           #116                // class java/io/InputStreamReader
      30: dup
      31: new           #118                // class java/io/FileInputStream
      34: dup
      35: aload         6
      37: invokespecial #121                // Method java/io/FileInputStream."<init>":(Ljava/io/File;)V
      40: checkcast     #123                // class java/io/InputStream
      43: aload_2
      44: invokespecial #126                // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
      47: checkcast     #128                // class java/io/Reader
      50: astore        6
      52: aload         6
      54: instanceof    #130                // class java/io/BufferedReader
      57: ifeq          68
      60: aload         6
      62: checkcast     #130                // class java/io/BufferedReader
      65: goto          79
      68: new           #130                // class java/io/BufferedReader
      71: dup
      72: aload         6
      74: iload         5
      76: invokespecial #133                // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
      79: checkcast     #135                // class java/io/Closeable
      82: astore        4
      84: aconst_null
      85: astore        5
      87: nop
      88: aload         4
      90: checkcast     #130                // class java/io/BufferedReader
      93: astore        6
      95: iconst_0
      96: istore        7
      98: aload         6
     100: invokestatic  #141                // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;
     103: astore        8
     105: iconst_0
     106: istore        9
     108: aload         8
     110: invokedynamic #159,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     115: invokestatic  #165                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     118: invokestatic  #169                // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
     121: astore        6
     123: aload         4
     125: aload         5
     127: invokestatic  #175                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     130: aload         6
     132: goto          156
     135: astore        7
     137: aload         7
     139: astore        5
     141: aload         7
     143: athrow
     144: astore        7
     146: aload         4
     148: aload         5
     150: invokestatic  #175                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     153: aload         7
     155: athrow
     156: nop
     157: areturn
    Exception table:
       from    to  target type
          87   123   135   Class java/lang/Throwable
          87   123   144   any
         135   144   144   any
         144   146   144   any

  private static final int part1(java.util.List<kotlin.Pair<java.lang.String, java.lang.String>>);
    Code:
       0: aload_0
       1: checkcast     #195                // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: invokeinterface #199,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      13: astore_3
      14: aload_3
      15: invokeinterface #205,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      20: ifeq          177
      23: aload_3
      24: invokeinterface #209,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      29: astore        4
      31: iload_2
      32: aload         4
      34: checkcast     #211                // class kotlin/Pair
      37: astore        5
      39: istore        10
      41: iconst_0
      42: istore        6
      44: aload         5
      46: invokevirtual #214                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      49: checkcast     #90                 // class java/lang/String
      52: astore        7
      54: aload         5
      56: invokevirtual #217                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      59: checkcast     #90                 // class java/lang/String
      62: astore        8
      64: aload         7
      66: aload         8
      68: astore        9
      70: aload         9
      72: invokevirtual #220                // Method java/lang/String.hashCode:()I
      75: tableswitch   { // 88 to 90
                    88: 100
                    89: 113
                    90: 126
               default: 154
          }
     100: aload         9
     102: ldc           #222                // String X
     104: invokevirtual #226                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     107: ifne          139
     110: goto          154
     113: aload         9
     115: ldc           #228                // String Y
     117: invokevirtual #226                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     120: ifne          144
     123: goto          154
     126: aload         9
     128: ldc           #230                // String Z
     130: invokevirtual #226                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     133: ifne          149
     136: goto          154
     139: ldc           #232                // String A
     141: goto          162
     144: ldc           #234                // String B
     146: goto          162
     149: ldc           #236                // String C
     151: goto          162
     154: new           #238                // class java/lang/IllegalArgumentException
     157: dup
     158: invokespecial #239                // Method java/lang/IllegalArgumentException."<init>":()V
     161: athrow
     162: invokestatic  #241                // Method playRound:(Ljava/lang/String;Ljava/lang/String;)I
     165: nop
     166: istore        11
     168: iload         10
     170: iload         11
     172: iadd
     173: istore_2
     174: goto          14
     177: iload_2
     178: ireturn

  private static final int part2(java.util.List<kotlin.Pair<java.lang.String, java.lang.String>>);
    Code:
       0: aload_0
       1: checkcast     #195                // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: invokeinterface #199,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      13: astore_3
      14: aload_3
      15: invokeinterface #205,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      20: ifeq          213
      23: aload_3
      24: invokeinterface #209,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      29: astore        4
      31: iload_2
      32: aload         4
      34: checkcast     #211                // class kotlin/Pair
      37: astore        5
      39: istore        10
      41: iconst_0
      42: istore        6
      44: aload         5
      46: invokevirtual #214                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      49: checkcast     #90                 // class java/lang/String
      52: astore        7
      54: aload         5
      56: invokevirtual #217                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      59: checkcast     #90                 // class java/lang/String
      62: astore        8
      64: aload         7
      66: aload         8
      68: astore        9
      70: aload         9
      72: invokevirtual #220                // Method java/lang/String.hashCode:()I
      75: tableswitch   { // 88 to 90
                    88: 100
                    89: 113
                    90: 126
               default: 190
          }
     100: aload         9
     102: ldc           #222                // String X
     104: invokevirtual #226                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     107: ifne          139
     110: goto          190
     113: aload         9
     115: ldc           #228                // String Y
     117: invokevirtual #226                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     120: ifne          162
     123: goto          190
     126: aload         9
     128: ldc           #230                // String Z
     130: invokevirtual #226                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     133: ifne          167
     136: goto          190
     139: getstatic     #68                 // Field rules:Ljava/util/Map;
     142: aload         7
     144: invokeinterface #74,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     149: dup
     150: invokestatic  #94                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     153: checkcast     #76                 // class day02/Rule
     156: invokevirtual #79                 // Method day02/Rule.getBeats:()Ljava/lang/String;
     159: goto          198
     162: aload         7
     164: goto          198
     167: getstatic     #68                 // Field rules:Ljava/util/Map;
     170: aload         7
     172: invokeinterface #74,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     177: dup
     178: invokestatic  #94                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     181: checkcast     #76                 // class day02/Rule
     184: invokevirtual #245                // Method day02/Rule.getLoses:()Ljava/lang/String;
     187: goto          198
     190: new           #238                // class java/lang/IllegalArgumentException
     193: dup
     194: invokespecial #239                // Method java/lang/IllegalArgumentException."<init>":()V
     197: athrow
     198: invokestatic  #241                // Method playRound:(Ljava/lang/String;Ljava/lang/String;)I
     201: nop
     202: istore        11
     204: iload         10
     206: iload         11
     208: iadd
     209: istore_2
     210: goto          14
     213: iload_2
     214: ireturn

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

  private static final kotlin.Pair parse$lambda$2$lambda$1(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #253                // String it
       3: invokestatic  #257                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #259                // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #90                 // class java/lang/String
      14: astore_1
      15: aload_1
      16: iconst_0
      17: ldc_w         #261                // String
      20: aastore
      21: aload_1
      22: iconst_0
      23: iconst_0
      24: bipush        6
      26: aconst_null
      27: invokestatic  #267                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      30: astore_2
      31: iconst_0
      32: istore_3
      33: aload_2
      34: iconst_0
      35: invokeinterface #270,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      40: checkcast     #90                 // class java/lang/String
      43: astore        4
      45: aload_2
      46: iconst_1
      47: invokeinterface #270,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      52: checkcast     #90                 // class java/lang/String
      55: astore        5
      57: aload         4
      59: aload         5
      61: invokestatic  #276                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      64: nop
      65: areturn

  static {};
    Code:
       0: iconst_3
       1: anewarray     #211                // class kotlin/Pair
       4: astore_0
       5: aload_0
       6: iconst_0
       7: ldc           #232                // String A
       9: new           #76                 // class day02/Rule
      12: dup
      13: iconst_1
      14: ldc           #236                // String C
      16: ldc           #234                // String B
      18: invokespecial #283                // Method day02/Rule."<init>":(ILjava/lang/String;Ljava/lang/String;)V
      21: invokestatic  #276                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      24: aastore
      25: aload_0
      26: iconst_1
      27: ldc           #234                // String B
      29: new           #76                 // class day02/Rule
      32: dup
      33: iconst_2
      34: ldc           #232                // String A
      36: ldc           #236                // String C
      38: invokespecial #283                // Method day02/Rule."<init>":(ILjava/lang/String;Ljava/lang/String;)V
      41: invokestatic  #276                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      44: aastore
      45: aload_0
      46: iconst_2
      47: ldc           #236                // String C
      49: new           #76                 // class day02/Rule
      52: dup
      53: iconst_3
      54: ldc           #234                // String B
      56: ldc           #232                // String A
      58: invokespecial #283                // Method day02/Rule."<init>":(ILjava/lang/String;Ljava/lang/String;)V
      61: invokestatic  #276                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      64: aastore
      65: aload_0
      66: invokestatic  #289                // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;
      69: putstatic     #68                 // Field rules:Ljava/util/Map;
      72: return
}


package day05

import java.io.File

fun main() {
    val data = parse("src/main/kotlin/day05/Day05.txt")

    val answer1 = part1(data)
    val answer2 = part2(data)

    println("🎄 Day 05 🎄")

    println()

    println("[Part 1]")
    println("Answer: $answer1")

    println()

    println("[Part 2]")
    println("Answer: $answer2")
}

private data class Move(
    val count: Int,
    val from: Int,
    val to: Int,
)

private data class Instructions(
    val stacks: List<List<Char>>,
    val moves: List<Move>,
)

@Suppress("SameParameterValue")
private fun parse(path: String): Instructions =
    File(path).readLines().let { lines ->
        val crates = lines
            .filter { it.contains('[') }
            .map { line -> line.chunked(4).map { it[1] } }

        val stackCount = crates[0].size
        val stacks = (0 until stackCount).map { i ->
            crates.asReversed()
                .map { it[i] }
                .filter { it.isLetter() }
        }

        val moves = lines
            .filter { it.startsWith("move") }
            .map { line ->
                val (count, from, to) = line
                    .split("""\D+""".toRegex())
                    .drop(1)
                    .map(String::toInt)

                Move(count, from - 1, to - 1)
            }

        Instructions(stacks, moves)
    }

private fun solve(instructions: Instructions, reverse: Boolean): String {
    val (_stacks, moves) = instructions
    val stacks = _stacks.map { it.toMutableList() }

    for ((count, source, target) in moves) {
        val crates = stacks[source].takeLast(count)
        stacks[target].addAll(if (reverse) crates.asReversed() else crates)
        repeat(count) {
            stacks[source].removeLast()
        }
    }

    return stacks
        .map(List<Char>::last)
        .joinToString(separator = "")
}

private fun part1(instructions: Instructions): String =
    solve(instructions, reverse = true)

private fun part2(instructions: Instructions): String =
    solve(instructions, reverse = false)

Compiled from "Day05.kt"
public final class day05.Day05Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String src/main/kotlin/day05/Day05.txt
       2: invokestatic  #12                 // Method parse:(Ljava/lang/String;)Lday05/Instructions;
       5: astore_0
       6: aload_0
       7: invokestatic  #16                 // Method part1:(Lday05/Instructions;)Ljava/lang/String;
      10: astore_1
      11: aload_0
      12: invokestatic  #19                 // Method part2:(Lday05/Instructions;)Ljava/lang/String;
      15: astore_2
      16: ldc           #21                 // String 🎄 Day 05 🎄
      18: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      21: swap
      22: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      25: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      28: invokevirtual #35                 // Method java/io/PrintStream.println:()V
      31: ldc           #37                 // String [Part 1]
      33: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      36: swap
      37: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      40: new           #39                 // class java/lang/StringBuilder
      43: dup
      44: invokespecial #42                 // Method java/lang/StringBuilder."<init>":()V
      47: ldc           #44                 // String Answer:
      49: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      52: aload_1
      53: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      56: invokevirtual #52                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      59: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      62: swap
      63: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      66: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      69: invokevirtual #35                 // Method java/io/PrintStream.println:()V
      72: ldc           #54                 // String [Part 2]
      74: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
      77: swap
      78: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      81: new           #39                 // class java/lang/StringBuilder
      84: dup
      85: invokespecial #42                 // Method java/lang/StringBuilder."<init>":()V
      88: ldc           #44                 // String Answer:
      90: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      93: aload_2
      94: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      97: invokevirtual #52                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     100: getstatic     #27                 // Field java/lang/System.out:Ljava/io/PrintStream;
     103: swap
     104: invokevirtual #33                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     107: return

  private static final day05.Instructions parse(java.lang.String);
    Code:
       0: new           #61                 // class java/io/File
       3: dup
       4: aload_0
       5: invokespecial #64                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       8: aconst_null
       9: iconst_1
      10: aconst_null
      11: invokestatic  #70                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      14: astore_1
      15: iconst_0
      16: istore_2
      17: aload_1
      18: checkcast     #72                 // class java/lang/Iterable
      21: astore_3
      22: nop
      23: iconst_0
      24: istore        4
      26: aload_3
      27: astore        5
      29: new           #74                 // class java/util/ArrayList
      32: dup
      33: invokespecial #75                 // Method java/util/ArrayList."<init>":()V
      36: checkcast     #77                 // class java/util/Collection
      39: astore        6
      41: iconst_0
      42: istore        7
      44: aload         5
      46: invokeinterface #81,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      51: astore        8
      53: aload         8
      55: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      60: ifeq          111
      63: aload         8
      65: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      70: astore        9
      72: aload         9
      74: checkcast     #93                 // class java/lang/String
      77: astore        10
      79: iconst_0
      80: istore        11
      82: aload         10
      84: checkcast     #95                 // class java/lang/CharSequence
      87: bipush        91
      89: iconst_0
      90: iconst_2
      91: aconst_null
      92: invokestatic  #101                // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;CZILjava/lang/Object;)Z
      95: ifeq          53
      98: aload         6
     100: aload         9
     102: invokeinterface #105,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     107: pop
     108: goto          53
     111: aload         6
     113: checkcast     #107                // class java/util/List
     116: nop
     117: checkcast     #72                 // class java/lang/Iterable
     120: astore_3
     121: nop
     122: iconst_0
     123: istore        4
     125: aload_3
     126: astore        5
     128: new           #74                 // class java/util/ArrayList
     131: dup
     132: aload_3
     133: bipush        10
     135: invokestatic  #113                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     138: invokespecial #116                // Method java/util/ArrayList."<init>":(I)V
     141: checkcast     #77                 // class java/util/Collection
     144: astore        6
     146: iconst_0
     147: istore        7
     149: aload         5
     151: invokeinterface #81,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     156: astore        8
     158: aload         8
     160: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     165: ifeq          316
     168: aload         8
     170: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     175: astore        9
     177: aload         6
     179: aload         9
     181: checkcast     #93                 // class java/lang/String
     184: astore        10
     186: astore        12
     188: iconst_0
     189: istore        11
     191: aload         10
     193: checkcast     #95                 // class java/lang/CharSequence
     196: iconst_4
     197: invokestatic  #120                // Method kotlin/text/StringsKt.chunked:(Ljava/lang/CharSequence;I)Ljava/util/List;
     200: checkcast     #72                 // class java/lang/Iterable
     203: astore        13
     205: iconst_0
     206: istore        14
     208: aload         13
     210: astore        15
     212: new           #74                 // class java/util/ArrayList
     215: dup
     216: aload         13
     218: bipush        10
     220: invokestatic  #113                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     223: invokespecial #116                // Method java/util/ArrayList."<init>":(I)V
     226: checkcast     #77                 // class java/util/Collection
     229: astore        16
     231: iconst_0
     232: istore        17
     234: aload         15
     236: invokeinterface #81,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     241: astore        18
     243: aload         18
     245: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     250: ifeq          297
     253: aload         18
     255: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     260: astore        19
     262: aload         16
     264: aload         19
     266: checkcast     #93                 // class java/lang/String
     269: astore        20
     271: astore        21
     273: iconst_0
     274: istore        22
     276: aload         20
     278: iconst_1
     279: invokevirtual #124                // Method java/lang/String.charAt:(I)C
     282: invokestatic  #130                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     285: aload         21
     287: swap
     288: invokeinterface #105,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     293: pop
     294: goto          243
     297: aload         16
     299: checkcast     #107                // class java/util/List
     302: nop
     303: nop
     304: aload         12
     306: swap
     307: invokeinterface #105,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     312: pop
     313: goto          158
     316: aload         6
     318: checkcast     #107                // class java/util/List
     321: nop
     322: astore        23
     324: aload         23
     326: iconst_0
     327: invokeinterface #134,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     332: checkcast     #107                // class java/util/List
     335: invokeinterface #138,  1          // InterfaceMethod java/util/List.size:()I
     340: istore_3
     341: iconst_0
     342: iload_3
     343: invokestatic  #144                // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     346: checkcast     #72                 // class java/lang/Iterable
     349: astore        5
     351: iconst_0
     352: istore        6
     354: aload         5
     356: astore        7
     358: new           #74                 // class java/util/ArrayList
     361: dup
     362: aload         5
     364: bipush        10
     366: invokestatic  #113                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     369: invokespecial #116                // Method java/util/ArrayList."<init>":(I)V
     372: checkcast     #77                 // class java/util/Collection
     375: astore        8
     377: iconst_0
     378: istore        9
     380: aload         7
     382: invokeinterface #81,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     387: astore        10
     389: aload         10
     391: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     396: ifeq          648
     399: aload         10
     401: checkcast     #146                // class kotlin/collections/IntIterator
     404: invokevirtual #149                // Method kotlin/collections/IntIterator.nextInt:()I
     407: istore        11
     409: aload         8
     411: iload         11
     413: istore        13
     415: astore        12
     417: iconst_0
     418: istore        14
     420: aload         23
     422: invokestatic  #153                // Method kotlin/collections/CollectionsKt.asReversed:(Ljava/util/List;)Ljava/util/List;
     425: checkcast     #72                 // class java/lang/Iterable
     428: astore        15
     430: nop
     431: iconst_0
     432: istore        16
     434: aload         15
     436: astore        17
     438: new           #74                 // class java/util/ArrayList
     441: dup
     442: aload         15
     444: bipush        10
     446: invokestatic  #113                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     449: invokespecial #116                // Method java/util/ArrayList."<init>":(I)V
     452: checkcast     #77                 // class java/util/Collection
     455: astore        18
     457: iconst_0
     458: istore        19
     460: aload         17
     462: invokeinterface #81,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     467: astore        20
     469: aload         20
     471: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     476: ifeq          532
     479: aload         20
     481: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     486: astore        21
     488: aload         18
     490: aload         21
     492: checkcast     #107                // class java/util/List
     495: astore        22
     497: astore        24
     499: iconst_0
     500: istore        25
     502: aload         22
     504: iload         13
     506: invokeinterface #134,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     511: checkcast     #126                // class java/lang/Character
     514: invokevirtual #157                // Method java/lang/Character.charValue:()C
     517: invokestatic  #130                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     520: aload         24
     522: swap
     523: invokeinterface #105,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     528: pop
     529: goto          469
     532: aload         18
     534: checkcast     #107                // class java/util/List
     537: nop
     538: checkcast     #72                 // class java/lang/Iterable
     541: astore        15
     543: nop
     544: iconst_0
     545: istore        16
     547: aload         15
     549: astore        17
     551: new           #74                 // class java/util/ArrayList
     554: dup
     555: invokespecial #75                 // Method java/util/ArrayList."<init>":()V
     558: checkcast     #77                 // class java/util/Collection
     561: astore        18
     563: iconst_0
     564: istore        19
     566: aload         17
     568: invokeinterface #81,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     573: astore        20
     575: aload         20
     577: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     582: ifeq          629
     585: aload         20
     587: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     592: astore        21
     594: aload         21
     596: checkcast     #126                // class java/lang/Character
     599: invokevirtual #157                // Method java/lang/Character.charValue:()C
     602: istore        22
     604: iconst_0
     605: istore        25
     607: iload         22
     609: invokestatic  #161                // Method java/lang/Character.isLetter:(C)Z
     612: nop
     613: ifeq          575
     616: aload         18
     618: aload         21
     620: invokeinterface #105,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     625: pop
     626: goto          575
     629: aload         18
     631: checkcast     #107                // class java/util/List
     634: nop
     635: nop
     636: aload         12
     638: swap
     639: invokeinterface #105,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     644: pop
     645: goto          389
     648: aload         8
     650: checkcast     #107                // class java/util/List
     653: nop
     654: astore        4
     656: aload_1
     657: checkcast     #72                 // class java/lang/Iterable
     660: astore        6
     662: nop
     663: iconst_0
     664: istore        7
     666: aload         6
     668: astore        8
     670: new           #74                 // class java/util/ArrayList
     673: dup
     674: invokespecial #75                 // Method java/util/ArrayList."<init>":()V
     677: checkcast     #77                 // class java/util/Collection
     680: astore        9
     682: iconst_0
     683: istore        10
     685: aload         8
     687: invokeinterface #81,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     692: astore        11
     694: aload         11
     696: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     701: ifeq          749
     704: aload         11
     706: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     711: astore        13
     713: aload         13
     715: checkcast     #93                 // class java/lang/String
     718: astore        14
     720: iconst_0
     721: istore        15
     723: aload         14
     725: ldc           #163                // String move
     727: iconst_0
     728: iconst_2
     729: aconst_null
     730: invokestatic  #167                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
     733: ifeq          694
     736: aload         9
     738: aload         13
     740: invokeinterface #105,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     745: pop
     746: goto          694
     749: aload         9
     751: checkcast     #107                // class java/util/List
     754: nop
     755: checkcast     #72                 // class java/lang/Iterable
     758: astore        6
     760: nop
     761: iconst_0
     762: istore        7
     764: aload         6
     766: astore        8
     768: new           #74                 // class java/util/ArrayList
     771: dup
     772: aload         6
     774: bipush        10
     776: invokestatic  #113                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     779: invokespecial #116                // Method java/util/ArrayList."<init>":(I)V
     782: checkcast     #77                 // class java/util/Collection
     785: astore        9
     787: iconst_0
     788: istore        10
     790: aload         8
     792: invokeinterface #81,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     797: astore        11
     799: aload         11
     801: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     806: ifeq          1052
     809: aload         11
     811: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     816: astore        13
     818: aload         9
     820: aload         13
     822: checkcast     #93                 // class java/lang/String
     825: astore        14
     827: astore        12
     829: iconst_0
     830: istore        15
     832: aload         14
     834: checkcast     #95                 // class java/lang/CharSequence
     837: astore        16
     839: new           #169                // class kotlin/text/Regex
     842: dup
     843: ldc           #171                // String \\D+
     845: invokespecial #172                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
     848: astore        17
     850: iconst_0
     851: istore        18
     853: aload         17
     855: aload         16
     857: iload         18
     859: invokevirtual #175                // Method kotlin/text/Regex.split:(Ljava/lang/CharSequence;I)Ljava/util/List;
     862: checkcast     #72                 // class java/lang/Iterable
     865: iconst_1
     866: invokestatic  #179                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     869: checkcast     #72                 // class java/lang/Iterable
     872: astore        16
     874: nop
     875: iconst_0
     876: istore        17
     878: aload         16
     880: astore        18
     882: new           #74                 // class java/util/ArrayList
     885: dup
     886: aload         16
     888: bipush        10
     890: invokestatic  #113                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     893: invokespecial #116                // Method java/util/ArrayList."<init>":(I)V
     896: checkcast     #77                 // class java/util/Collection
     899: astore        19
     901: iconst_0
     902: istore        20
     904: aload         18
     906: invokeinterface #81,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     911: astore        21
     913: aload         21
     915: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     920: ifeq          967
     923: aload         21
     925: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     930: astore        22
     932: aload         19
     934: aload         22
     936: checkcast     #93                 // class java/lang/String
     939: astore        24
     941: astore        25
     943: iconst_0
     944: istore        26
     946: aload         24
     948: invokestatic  #185                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     951: nop
     952: invokestatic  #188                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     955: aload         25
     957: swap
     958: invokeinterface #105,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     963: pop
     964: goto          913
     967: aload         19
     969: checkcast     #107                // class java/util/List
     972: nop
     973: astore        27
     975: aload         27
     977: iconst_0
     978: invokeinterface #134,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     983: checkcast     #190                // class java/lang/Number
     986: invokevirtual #193                // Method java/lang/Number.intValue:()I
     989: istore        16
     991: aload         27
     993: iconst_1
     994: invokeinterface #134,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     999: checkcast     #190                // class java/lang/Number
    1002: invokevirtual #193                // Method java/lang/Number.intValue:()I
    1005: istore        17
    1007: aload         27
    1009: iconst_2
    1010: invokeinterface #134,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1015: checkcast     #190                // class java/lang/Number
    1018: invokevirtual #193                // Method java/lang/Number.intValue:()I
    1021: istore        18
    1023: new           #195                // class day05/Move
    1026: dup
    1027: iload         16
    1029: iload         17
    1031: iconst_1
    1032: isub
    1033: iload         18
    1035: iconst_1
    1036: isub
    1037: invokespecial #198                // Method day05/Move."<init>":(III)V
    1040: aload         12
    1042: swap
    1043: invokeinterface #105,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
    1048: pop
    1049: goto          799
    1052: aload         9
    1054: checkcast     #107                // class java/util/List
    1057: nop
    1058: astore        5
    1060: new           #200                // class day05/Instructions
    1063: dup
    1064: aload         4
    1066: aload         5
    1068: invokespecial #203                // Method day05/Instructions."<init>":(Ljava/util/List;Ljava/util/List;)V
    1071: nop
    1072: areturn

  private static final java.lang.String solve(day05.Instructions, boolean);
    Code:
       0: aload_0
       1: invokevirtual #249                // Method day05/Instructions.component1:()Ljava/util/List;
       4: astore_2
       5: aload_0
       6: invokevirtual #252                // Method day05/Instructions.component2:()Ljava/util/List;
       9: astore_3
      10: aload_2
      11: checkcast     #72                 // class java/lang/Iterable
      14: astore        5
      16: iconst_0
      17: istore        6
      19: aload         5
      21: astore        7
      23: new           #74                 // class java/util/ArrayList
      26: dup
      27: aload         5
      29: bipush        10
      31: invokestatic  #113                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      34: invokespecial #116                // Method java/util/ArrayList."<init>":(I)V
      37: checkcast     #77                 // class java/util/Collection
      40: astore        8
      42: iconst_0
      43: istore        9
      45: aload         7
      47: invokeinterface #81,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      52: astore        10
      54: aload         10
      56: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      61: ifeq          107
      64: aload         10
      66: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      71: astore        11
      73: aload         8
      75: aload         11
      77: checkcast     #107                // class java/util/List
      80: astore        12
      82: astore        14
      84: iconst_0
      85: istore        13
      87: aload         12
      89: checkcast     #77                 // class java/util/Collection
      92: invokestatic  #256                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
      95: aload         14
      97: swap
      98: invokeinterface #105,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     103: pop
     104: goto          54
     107: aload         8
     109: checkcast     #107                // class java/util/List
     112: nop
     113: astore        4
     115: aload_3
     116: invokeinterface #257,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     121: astore        5
     123: aload         5
     125: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     130: ifeq          262
     133: aload         5
     135: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     140: checkcast     #195                // class day05/Move
     143: astore        6
     145: aload         6
     147: invokevirtual #259                // Method day05/Move.component1:()I
     150: istore        7
     152: aload         6
     154: invokevirtual #261                // Method day05/Move.component2:()I
     157: istore        8
     159: aload         6
     161: invokevirtual #264                // Method day05/Move.component3:()I
     164: istore        9
     166: aload         4
     168: iload         8
     170: invokeinterface #134,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     175: checkcast     #107                // class java/util/List
     178: iload         7
     180: invokestatic  #268                // Method kotlin/collections/CollectionsKt.takeLast:(Ljava/util/List;I)Ljava/util/List;
     183: astore        10
     185: aload         4
     187: iload         9
     189: invokeinterface #134,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     194: checkcast     #107                // class java/util/List
     197: iload_1
     198: ifeq          209
     201: aload         10
     203: invokestatic  #153                // Method kotlin/collections/CollectionsKt.asReversed:(Ljava/util/List;)Ljava/util/List;
     206: goto          211
     209: aload         10
     211: checkcast     #77                 // class java/util/Collection
     214: invokeinterface #272,  2          // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z
     219: pop
     220: iconst_0
     221: istore        11
     223: iload         11
     225: iload         7
     227: if_icmpge     123
     230: iload         11
     232: istore        12
     234: iconst_0
     235: istore        13
     237: aload         4
     239: iload         8
     241: invokeinterface #134,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     246: checkcast     #107                // class java/util/List
     249: invokeinterface #275,  1          // InterfaceMethod java/util/List.removeLast:()Ljava/lang/Object;
     254: pop
     255: nop
     256: iinc          11, 1
     259: goto          223
     262: aload         4
     264: checkcast     #72                 // class java/lang/Iterable
     267: astore        5
     269: nop
     270: iconst_0
     271: istore        6
     273: aload         5
     275: astore        7
     277: new           #74                 // class java/util/ArrayList
     280: dup
     281: aload         5
     283: bipush        10
     285: invokestatic  #113                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     288: invokespecial #116                // Method java/util/ArrayList."<init>":(I)V
     291: checkcast     #77                 // class java/util/Collection
     294: astore        8
     296: iconst_0
     297: istore        9
     299: aload         7
     301: invokeinterface #81,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     306: astore        10
     308: aload         10
     310: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     315: ifeq          367
     318: aload         10
     320: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     325: astore        11
     327: aload         8
     329: aload         11
     331: checkcast     #107                // class java/util/List
     334: astore        12
     336: astore        14
     338: iconst_0
     339: istore        13
     341: aload         12
     343: invokestatic  #279                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     346: checkcast     #126                // class java/lang/Character
     349: invokevirtual #157                // Method java/lang/Character.charValue:()C
     352: invokestatic  #130                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     355: aload         14
     357: swap
     358: invokeinterface #105,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     363: pop
     364: goto          308
     367: aload         8
     369: checkcast     #107                // class java/util/List
     372: nop
     373: checkcast     #72                 // class java/lang/Iterable
     376: ldc_w         #281                // String
     379: checkcast     #95                 // class java/lang/CharSequence
     382: aconst_null
     383: aconst_null
     384: iconst_0
     385: aconst_null
     386: aconst_null
     387: bipush        62
     389: aconst_null
     390: invokestatic  #285                // 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;
     393: areturn

  private static final java.lang.String part1(day05.Instructions);
    Code:
       0: aload_0
       1: iconst_1
       2: invokestatic  #296                // Method solve:(Lday05/Instructions;Z)Ljava/lang/String;
       5: areturn

  private static final java.lang.String part2(day05.Instructions);
    Code:
       0: aload_0
       1: iconst_0
       2: invokestatic  #296                // Method solve:(Lday05/Instructions;Z)Ljava/lang/String;
       5: areturn

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