package day04

import fullyContains
import overlapsWith
import readInput

fun part1(input: List<String>): Int = input.solve(IntRange::fullyContains)

fun part2(input: List<String>): Int = input.solve(IntRange::overlapsWith)

val regex by lazy { """(\d+)-(\d+),(\d+)-(\d+)""".toRegex() }

fun main() {
    val input = readInput("main/day04/Day04")
    println(part1(input))
    println(part2(input))
}

private fun List<String>.solve(check: IntRange.(IntRange) -> Boolean) =
    map { it.toRangesPairs() }.count { it.first.check(it.second) }

fun String.toRangesPairs(): Pair<IntRange, IntRange> {
    return regex.matchEntire(this)?.destructured?.let { (a, b, c, d) ->
        a.toInt()..b.toInt() to c.toInt()..d.toInt()
    } ?: error("invalid line")
}

Compiled from "day04.kt"
public final class day04.Day04Kt {
  private static final kotlin.Lazy regex$delegate;

  public static final int part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #10                 // String input
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: getstatic     #22                 // Field day04/Day04Kt$part1$1.INSTANCE:Lday04/Day04Kt$part1$1;
      10: checkcast     #24                 // class kotlin/jvm/functions/Function2
      13: invokestatic  #28                 // Method solve:(Ljava/util/List;Lkotlin/jvm/functions/Function2;)I
      16: ireturn

  public static final int part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #10                 // String input
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: getstatic     #35                 // Field day04/Day04Kt$part2$1.INSTANCE:Lday04/Day04Kt$part2$1;
      10: checkcast     #24                 // class kotlin/jvm/functions/Function2
      13: invokestatic  #28                 // Method solve:(Ljava/util/List;Lkotlin/jvm/functions/Function2;)I
      16: ireturn

  public static final kotlin.text.Regex getRegex();
    Code:
       0: getstatic     #41                 // Field regex$delegate:Lkotlin/Lazy;
       3: astore_0
       4: aload_0
       5: invokeinterface #47,  1           // InterfaceMethod kotlin/Lazy.getValue:()Ljava/lang/Object;
      10: checkcast     #49                 // class kotlin/text/Regex
      13: areturn

  public static final void main();
    Code:
       0: ldc           #53                 // String main/day04/Day04
       2: invokestatic  #59                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #61                 // Method part1:(Ljava/util/List;)I
      10: istore_1
      11: getstatic     #67                 // Field java/lang/System.out:Ljava/io/PrintStream;
      14: iload_1
      15: invokevirtual #73                 // Method java/io/PrintStream.println:(I)V
      18: aload_0
      19: invokestatic  #75                 // Method part2:(Ljava/util/List;)I
      22: istore_1
      23: getstatic     #67                 // Field java/lang/System.out:Ljava/io/PrintStream;
      26: iload_1
      27: invokevirtual #73                 // Method java/io/PrintStream.println:(I)V
      30: return

  private static final int solve(java.util.List<java.lang.String>, kotlin.jvm.functions.Function2<? super kotlin.ranges.IntRange, ? super kotlin.ranges.IntRange, java.lang.Boolean>);
    Code:
       0: aload_0
       1: checkcast     #78                 // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: astore        4
      10: new           #80                 // class java/util/ArrayList
      13: dup
      14: aload_2
      15: bipush        10
      17: invokestatic  #86                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      20: invokespecial #89                 // Method java/util/ArrayList."<init>":(I)V
      23: checkcast     #91                 // class java/util/Collection
      26: astore        5
      28: iconst_0
      29: istore        6
      31: aload         4
      33: invokeinterface #95,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      38: astore        7
      40: aload         7
      42: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      47: ifeq          90
      50: aload         7
      52: invokeinterface #104,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      57: astore        8
      59: aload         5
      61: aload         8
      63: checkcast     #106                // class java/lang/String
      66: astore        9
      68: astore        11
      70: iconst_0
      71: istore        10
      73: aload         9
      75: invokestatic  #110                // Method toRangesPairs:(Ljava/lang/String;)Lkotlin/Pair;
      78: aload         11
      80: swap
      81: invokeinterface #114,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      86: pop
      87: goto          40
      90: aload         5
      92: checkcast     #116                // class java/util/List
      95: nop
      96: checkcast     #78                 // class java/lang/Iterable
      99: astore_2
     100: nop
     101: iconst_0
     102: istore_3
     103: aload_2
     104: instanceof    #91                 // class java/util/Collection
     107: ifeq          126
     110: aload_2
     111: checkcast     #91                 // class java/util/Collection
     114: invokeinterface #119,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     119: ifeq          126
     122: iconst_0
     123: goto          207
     126: iconst_0
     127: istore        4
     129: aload_2
     130: invokeinterface #95,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     135: astore        5
     137: aload         5
     139: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     144: ifeq          205
     147: aload         5
     149: invokeinterface #104,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     154: astore        6
     156: aload         6
     158: checkcast     #121                // class kotlin/Pair
     161: astore        7
     163: iconst_0
     164: istore        8
     166: aload_1
     167: aload         7
     169: invokevirtual #124                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     172: aload         7
     174: invokevirtual #127                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     177: invokeinterface #131,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     182: checkcast     #133                // class java/lang/Boolean
     185: invokevirtual #136                // Method java/lang/Boolean.booleanValue:()Z
     188: ifeq          137
     191: iinc          4, 1
     194: iload         4
     196: ifge          137
     199: invokestatic  #139                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     202: goto          137
     205: iload         4
     207: ireturn

  public static final kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange> toRangesPairs(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #164                // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: invokestatic  #166                // Method getRegex:()Lkotlin/text/Regex;
       9: aload_0
      10: checkcast     #168                // class java/lang/CharSequence
      13: invokevirtual #172                // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;
      16: dup
      17: ifnull        152
      20: invokeinterface #178,  1          // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;
      25: dup
      26: ifnull        152
      29: astore_1
      30: iconst_0
      31: istore_2
      32: aload_1
      33: invokevirtual #184                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
      36: invokeinterface #188,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
      41: iconst_1
      42: invokeinterface #192,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      47: checkcast     #106                // class java/lang/String
      50: astore_3
      51: aload_1
      52: invokevirtual #184                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
      55: invokeinterface #188,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
      60: iconst_2
      61: invokeinterface #192,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      66: checkcast     #106                // class java/lang/String
      69: astore        4
      71: aload_1
      72: invokevirtual #184                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
      75: invokeinterface #188,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
      80: iconst_3
      81: invokeinterface #192,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      86: checkcast     #106                // class java/lang/String
      89: astore        5
      91: aload_1
      92: invokevirtual #184                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
      95: invokeinterface #188,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     100: iconst_4
     101: invokeinterface #192,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     106: checkcast     #106                // class java/lang/String
     109: astore        6
     111: new           #194                // class kotlin/ranges/IntRange
     114: dup
     115: aload_3
     116: invokestatic  #200                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     119: aload         4
     121: invokestatic  #200                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     124: invokespecial #203                // Method kotlin/ranges/IntRange."<init>":(II)V
     127: new           #194                // class kotlin/ranges/IntRange
     130: dup
     131: aload         5
     133: invokestatic  #200                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     136: aload         6
     138: invokestatic  #200                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     141: invokespecial #203                // Method kotlin/ranges/IntRange."<init>":(II)V
     144: invokestatic  #209                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     147: nop
     148: dup
     149: ifnonnull     166
     152: pop
     153: new           #211                // class java/lang/IllegalStateException
     156: dup
     157: ldc           #213                // String invalid line
     159: invokevirtual #217                // Method java/lang/Object.toString:()Ljava/lang/String;
     162: invokespecial #220                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     165: athrow
     166: areturn

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

  private static final kotlin.text.Regex regex_delegate$lambda$0();
    Code:
       0: new           #49                 // class kotlin/text/Regex
       3: dup
       4: ldc           #234                // String (\\d+)-(\\d+),(\\d+)-(\\d+)
       6: invokespecial #235                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
       9: areturn

  static {};
    Code:
       0: invokedynamic #251,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function0;
       5: invokestatic  #257                // Method kotlin/LazyKt.lazy:(Lkotlin/jvm/functions/Function0;)Lkotlin/Lazy;
       8: putstatic     #41                 // Field regex$delegate:Lkotlin/Lazy;
      11: return
}

Compiled from "day04.kt"
final class day04.Day04Kt$part1$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<kotlin.ranges.IntRange, kotlin.ranges.IntRange, java.lang.Boolean> {
  public static final day04.Day04Kt$part1$1 INSTANCE;

  day04.Day04Kt$part1$1();
    Code:
       0: aload_0
       1: iconst_2
       2: ldc           #11                 // class UtilsKt
       4: ldc           #13                 // String fullyContains
       6: ldc           #15                 // String fullyContains(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z
       8: iconst_1
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final java.lang.Boolean invoke(kotlin.ranges.IntRange, kotlin.ranges.IntRange);
    Code:
       0: aload_1
       1: ldc           #24                 // String p0
       3: invokestatic  #30                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #32                 // String p1
       9: invokestatic  #30                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: aload_2
      14: invokestatic  #35                 // Method UtilsKt.fullyContains:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z
      17: invokestatic  #41                 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
      20: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #45                 // class kotlin/ranges/IntRange
       5: aload_2
       6: checkcast     #45                 // class kotlin/ranges/IntRange
       9: invokevirtual #47                 // Method invoke:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Ljava/lang/Boolean;
      12: areturn

  static {};
    Code:
       0: new           #2                  // class day04/Day04Kt$part1$1
       3: dup
       4: invokespecial #52                 // Method "<init>":()V
       7: putstatic     #55                 // Field INSTANCE:Lday04/Day04Kt$part1$1;
      10: return
}

Compiled from "day04.kt"
final class day04.Day04Kt$part2$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<kotlin.ranges.IntRange, kotlin.ranges.IntRange, java.lang.Boolean> {
  public static final day04.Day04Kt$part2$1 INSTANCE;

  day04.Day04Kt$part2$1();
    Code:
       0: aload_0
       1: iconst_2
       2: ldc           #11                 // class UtilsKt
       4: ldc           #13                 // String overlapsWith
       6: ldc           #15                 // String overlapsWith(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z
       8: iconst_1
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final java.lang.Boolean invoke(kotlin.ranges.IntRange, kotlin.ranges.IntRange);
    Code:
       0: aload_1
       1: ldc           #24                 // String p0
       3: invokestatic  #30                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #32                 // String p1
       9: invokestatic  #30                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: aload_2
      14: invokestatic  #35                 // Method UtilsKt.overlapsWith:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z
      17: invokestatic  #41                 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
      20: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #45                 // class kotlin/ranges/IntRange
       5: aload_2
       6: checkcast     #45                 // class kotlin/ranges/IntRange
       9: invokevirtual #47                 // Method invoke:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Ljava/lang/Boolean;
      12: areturn

  static {};
    Code:
       0: new           #2                  // class day04/Day04Kt$part2$1
       3: dup
       4: invokespecial #52                 // Method "<init>":()V
       7: putstatic     #55                 // Field INSTANCE:Lday04/Day04Kt$part2$1;
      10: return
}


package day02

import readInput
import reverse
import second

const val ROCK = "A"
const val PAPER = "B"
const val SCISSORS = "C"

const val ROCK_ = "X"
const val PAPER_ = "Y"
const val SCISSORS_ = "Z"

const val LOSE = "X"
const val DRAW = "Y"
const val WIN = "Z"

fun part1(input: List<String>): Int {

    return input.toPairs().sumOf {
        when (it) {
            ROCK to ROCK_ -> 1 + 3
            ROCK to PAPER_ -> 2 + 6
            ROCK to SCISSORS_ -> 3 + 0
            PAPER to ROCK_ -> 1 + 0
            PAPER to PAPER_ -> 2 + 3
            PAPER to SCISSORS_ -> 3 + 6
            SCISSORS to ROCK_ -> 1 + 6
            SCISSORS to PAPER_ -> 2 + 0
            SCISSORS to SCISSORS_ -> 3 + 3

            else -> error("invalid pair")
        }.toInt()
    }
}

fun part2(input: List<String>): Int {
    return input.toPairs().sumOf {
        when (it.reverse()) {
            LOSE to ROCK -> 0 + 3
            DRAW to ROCK -> 3 + 1
            WIN to ROCK -> 6 + 2
            LOSE to PAPER -> 0 + 1
            DRAW to PAPER -> 3 + 2
            WIN to PAPER -> 6 + 3
            LOSE to SCISSORS -> 0 + 2
            DRAW to SCISSORS -> 3 + 3
            WIN to SCISSORS -> 6 + 1

            else -> error("invalid pair")
        }.toInt()
    }
}

fun main() {
    val input = readInput("main/day02/Day02")
    println(part1(input))
    println(part2(input))
}

fun List<String>.toPairs() = map {
    it.split(" ").let { pair ->
        pair.first() to pair.second()
    }
}

Compiled from "day02.kt"
public final class day02.Day02Kt {
  public static final java.lang.String ROCK;

  public static final java.lang.String PAPER;

  public static final java.lang.String SCISSORS;

  public static final java.lang.String ROCK_;

  public static final java.lang.String PAPER_;

  public static final java.lang.String SCISSORS_;

  public static final java.lang.String LOSE;

  public static final java.lang.String DRAW;

  public static final java.lang.String WIN;

  public static final int part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #10                 // String input
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #20                 // Method toPairs:(Ljava/util/List;)Ljava/util/List;
      10: checkcast     #22                 // class java/lang/Iterable
      13: astore_1
      14: iconst_0
      15: istore_2
      16: aload_1
      17: invokeinterface #26,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      22: astore_3
      23: aload_3
      24: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      29: ifeq          257
      32: aload_3
      33: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      38: astore        4
      40: iload_2
      41: aload         4
      43: checkcast     #38                 // class kotlin/Pair
      46: astore        5
      48: istore        8
      50: iconst_0
      51: istore        6
      53: aload         5
      55: astore        7
      57: aload         7
      59: ldc           #40                 // String A
      61: ldc           #42                 // String X
      63: invokestatic  #48                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      66: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      69: ifeq          76
      72: iconst_4
      73: goto          245
      76: aload         7
      78: ldc           #40                 // String A
      80: ldc           #54                 // String Y
      82: invokestatic  #48                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      85: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      88: ifeq          96
      91: bipush        8
      93: goto          245
      96: aload         7
      98: ldc           #40                 // String A
     100: ldc           #56                 // String Z
     102: invokestatic  #48                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     105: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     108: ifeq          115
     111: iconst_3
     112: goto          245
     115: aload         7
     117: ldc           #58                 // String B
     119: ldc           #42                 // String X
     121: invokestatic  #48                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     124: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     127: ifeq          134
     130: iconst_1
     131: goto          245
     134: aload         7
     136: ldc           #58                 // String B
     138: ldc           #54                 // String Y
     140: invokestatic  #48                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     143: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     146: ifeq          153
     149: iconst_5
     150: goto          245
     153: aload         7
     155: ldc           #58                 // String B
     157: ldc           #56                 // String Z
     159: invokestatic  #48                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     162: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     165: ifeq          173
     168: bipush        9
     170: goto          245
     173: aload         7
     175: ldc           #60                 // String C
     177: ldc           #42                 // String X
     179: invokestatic  #48                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     182: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     185: ifeq          193
     188: bipush        7
     190: goto          245
     193: aload         7
     195: ldc           #60                 // String C
     197: ldc           #54                 // String Y
     199: invokestatic  #48                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     202: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     205: ifeq          212
     208: iconst_2
     209: goto          245
     212: aload         7
     214: ldc           #60                 // String C
     216: ldc           #56                 // String Z
     218: invokestatic  #48                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     221: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     224: ifeq          232
     227: bipush        6
     229: goto          245
     232: new           #62                 // class java/lang/IllegalStateException
     235: dup
     236: ldc           #64                 // String invalid pair
     238: invokevirtual #68                 // Method java/lang/Object.toString:()Ljava/lang/String;
     241: invokespecial #72                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     244: athrow
     245: nop
     246: istore        9
     248: iload         8
     250: iload         9
     252: iadd
     253: istore_2
     254: goto          23
     257: iload_2
     258: ireturn

  public static final int part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #10                 // String input
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #20                 // Method toPairs:(Ljava/util/List;)Ljava/util/List;
      10: checkcast     #22                 // class java/lang/Iterable
      13: astore_1
      14: iconst_0
      15: istore_2
      16: aload_1
      17: invokeinterface #26,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      22: astore_3
      23: aload_3
      24: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      29: ifeq          260
      32: aload_3
      33: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      38: astore        4
      40: iload_2
      41: aload         4
      43: checkcast     #38                 // class kotlin/Pair
      46: astore        5
      48: istore        8
      50: iconst_0
      51: istore        6
      53: aload         5
      55: invokestatic  #86                 // Method UtilsKt.reverse:(Lkotlin/Pair;)Lkotlin/Pair;
      58: astore        7
      60: aload         7
      62: ldc           #42                 // String X
      64: ldc           #40                 // String A
      66: invokestatic  #48                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      69: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      72: ifeq          79
      75: iconst_3
      76: goto          248
      79: aload         7
      81: ldc           #54                 // String Y
      83: ldc           #40                 // String A
      85: invokestatic  #48                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      88: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      91: ifeq          98
      94: iconst_4
      95: goto          248
      98: aload         7
     100: ldc           #56                 // String Z
     102: ldc           #40                 // String A
     104: invokestatic  #48                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     107: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     110: ifeq          118
     113: bipush        8
     115: goto          248
     118: aload         7
     120: ldc           #42                 // String X
     122: ldc           #58                 // String B
     124: invokestatic  #48                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     127: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     130: ifeq          137
     133: iconst_1
     134: goto          248
     137: aload         7
     139: ldc           #54                 // String Y
     141: ldc           #58                 // String B
     143: invokestatic  #48                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     146: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     149: ifeq          156
     152: iconst_5
     153: goto          248
     156: aload         7
     158: ldc           #56                 // String Z
     160: ldc           #58                 // String B
     162: invokestatic  #48                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     165: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     168: ifeq          176
     171: bipush        9
     173: goto          248
     176: aload         7
     178: ldc           #42                 // String X
     180: ldc           #60                 // String C
     182: invokestatic  #48                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     185: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     188: ifeq          195
     191: iconst_2
     192: goto          248
     195: aload         7
     197: ldc           #54                 // String Y
     199: ldc           #60                 // String C
     201: invokestatic  #48                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     204: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     207: ifeq          215
     210: bipush        6
     212: goto          248
     215: aload         7
     217: ldc           #56                 // String Z
     219: ldc           #60                 // String C
     221: invokestatic  #48                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     224: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     227: ifeq          235
     230: bipush        7
     232: goto          248
     235: new           #62                 // class java/lang/IllegalStateException
     238: dup
     239: ldc           #64                 // String invalid pair
     241: invokevirtual #68                 // Method java/lang/Object.toString:()Ljava/lang/String;
     244: invokespecial #72                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     247: athrow
     248: nop
     249: istore        9
     251: iload         8
     253: iload         9
     255: iadd
     256: istore_2
     257: goto          23
     260: iload_2
     261: ireturn

  public static final void main();
    Code:
       0: ldc           #91                 // String main/day02/Day02
       2: invokestatic  #95                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #97                 // Method part1:(Ljava/util/List;)I
      10: istore_1
      11: getstatic     #103                // Field java/lang/System.out:Ljava/io/PrintStream;
      14: iload_1
      15: invokevirtual #109                // Method java/io/PrintStream.println:(I)V
      18: aload_0
      19: invokestatic  #111                // Method part2:(Ljava/util/List;)I
      22: istore_1
      23: getstatic     #103                // Field java/lang/System.out:Ljava/io/PrintStream;
      26: iload_1
      27: invokevirtual #109                // Method java/io/PrintStream.println:(I)V
      30: return

  public static final java.util.List<kotlin.Pair<java.lang.String, java.lang.String>> toPairs(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #114                // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #22                 // class java/lang/Iterable
      10: astore_1
      11: iconst_0
      12: istore_2
      13: aload_1
      14: astore_3
      15: new           #116                // class java/util/ArrayList
      18: dup
      19: aload_1
      20: bipush        10
      22: invokestatic  #122                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      25: invokespecial #124                // Method java/util/ArrayList."<init>":(I)V
      28: checkcast     #126                // class java/util/Collection
      31: astore        4
      33: iconst_0
      34: istore        5
      36: aload_3
      37: invokeinterface #26,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        6
      44: aload         6
      46: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          136
      54: aload         6
      56: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        7
      63: aload         4
      65: aload         7
      67: checkcast     #128                // class java/lang/String
      70: astore        8
      72: astore        13
      74: iconst_0
      75: istore        9
      77: aload         8
      79: checkcast     #130                // class java/lang/CharSequence
      82: iconst_1
      83: anewarray     #128                // class java/lang/String
      86: astore        10
      88: aload         10
      90: iconst_0
      91: ldc           #132                // String
      93: aastore
      94: aload         10
      96: iconst_0
      97: iconst_0
      98: bipush        6
     100: aconst_null
     101: invokestatic  #138                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     104: astore        11
     106: iconst_0
     107: istore        12
     109: aload         11
     111: invokestatic  #142                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     114: aload         11
     116: invokestatic  #145                // Method UtilsKt.second:(Ljava/util/List;)Ljava/lang/Object;
     119: invokestatic  #48                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     122: nop
     123: nop
     124: aload         13
     126: swap
     127: invokeinterface #149,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     132: pop
     133: goto          44
     136: aload         4
     138: checkcast     #79                 // class java/util/List
     141: nop
     142: areturn

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


package day05

import java.util.*
import readInput

val stackIndices = listOf(1, 5, 9, 13, 17, 21, 25, 29, 33)
var stacks: List<Stack<Char>> = emptyList()
var moves: List<Move> = emptyList()

val regex by lazy { """move (\d+) from (\d) to (\d)""".toRegex() }

fun main() {
    val input = readInput("main/day05/Day05")

    println(part1(input))
    println(part2(input))
}

fun part1(input: List<String>): String {

    input.parse()
    rearrange(::movingSingleCrate)

    return message()
}

fun part2(input: List<String>): String {

    input.parse()
    rearrange(::movingPartialStack)

    return message()
}

private fun List<String>.parse(numOfRows: Int = 8, numOfStacks: Int = 9) {
    stacks = take(numOfRows).parseToStacks(numOfStacks)
    moves = drop(numOfRows + 2).parseMoves()
}

private fun rearrange(move: (Move, List<Stack<Char>>) -> Unit) {
    moves.forEach {
        move(it, stacks)
    }
}

private fun movingSingleCrate(move: Move, stacks: List<Stack<Char>>) {
    repeat(move.numberOfCrates) { _ ->
        stacks[move.to - 1].push(stacks[move.from - 1].pop())
    }
}

private fun movingPartialStack(move: Move, stacks: List<Stack<Char>>) {
    val tmp = mutableListOf<Char>()
    repeat(move.numberOfCrates) { _ ->
        tmp.add(stacks[move.from - 1].pop())
    }
    tmp.reversed().forEach { c ->
        stacks[move.to - 1].push(c)
    }
}

private fun message() = stacks.map {
    it.pop()
}.joinToString("")

fun List<String>.parseMoves(): List<Move> {
    return this.map {
        regex.matchEntire(it)?.destructured?.let { (count, from, to) ->
            Move(from.toInt(), to.toInt(), count.toInt())
        } ?: error("")
    }
}

fun List<String>.parseToStacks(numOfStacks: Int): List<Stack<Char>> {
    val result = mutableListOf<Stack<Char>>()
    repeat(numOfStacks) { result.add(Stack()) }
    this.reversed().forEach { s ->
        s.forEachIndexed { index, c ->
            if (index in stackIndices) {
                if (c != ' ') result[(index / 4)].push(c)
            }
        }
    }
    return result
}

data class Move(val from: Int, val to: Int, val numberOfCrates: Int)

Compiled from "day05.kt"
public final class day05.Day05Kt {
  private static final java.util.List<java.lang.Integer> stackIndices;

  private static java.util.List<? extends java.util.Stack<java.lang.Character>> stacks;

  private static java.util.List<day05.Move> moves;

  private static final kotlin.Lazy regex$delegate;

  public static final java.util.List<java.lang.Integer> getStackIndices();
    Code:
       0: getstatic     #12                 // Field stackIndices:Ljava/util/List;
       3: areturn

  public static final java.util.List<java.util.Stack<java.lang.Character>> getStacks();
    Code:
       0: getstatic     #17                 // Field stacks:Ljava/util/List;
       3: areturn

  public static final void setStacks(java.util.List<? extends java.util.Stack<java.lang.Character>>);
    Code:
       0: aload_0
       1: ldc           #22                 // String <set-?>
       3: invokestatic  #28                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: putstatic     #17                 // Field stacks:Ljava/util/List;
      10: return

  public static final java.util.List<day05.Move> getMoves();
    Code:
       0: getstatic     #33                 // Field moves:Ljava/util/List;
       3: areturn

  public static final void setMoves(java.util.List<day05.Move>);
    Code:
       0: aload_0
       1: ldc           #22                 // String <set-?>
       3: invokestatic  #28                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: putstatic     #33                 // Field moves:Ljava/util/List;
      10: return

  public static final kotlin.text.Regex getRegex();
    Code:
       0: getstatic     #41                 // Field regex$delegate:Lkotlin/Lazy;
       3: astore_0
       4: aload_0
       5: invokeinterface #47,  1           // InterfaceMethod kotlin/Lazy.getValue:()Ljava/lang/Object;
      10: checkcast     #49                 // class kotlin/text/Regex
      13: areturn

  public static final void main();
    Code:
       0: ldc           #53                 // String main/day05/Day05
       2: invokestatic  #59                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #63                 // Method part1:(Ljava/util/List;)Ljava/lang/String;
      10: getstatic     #69                 // Field java/lang/System.out:Ljava/io/PrintStream;
      13: swap
      14: invokevirtual #75                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      17: aload_0
      18: invokestatic  #78                 // Method part2:(Ljava/util/List;)Ljava/lang/String;
      21: getstatic     #69                 // Field java/lang/System.out:Ljava/io/PrintStream;
      24: swap
      25: invokevirtual #75                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      28: return

  public static final java.lang.String part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #81                 // String input
       3: invokestatic  #28                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iconst_0
       8: iconst_0
       9: iconst_3
      10: aconst_null
      11: invokestatic  #85                 // Method parse$default:(Ljava/util/List;IIILjava/lang/Object;)V
      14: getstatic     #91                 // Field day05/Day05Kt$part1$1.INSTANCE:Lday05/Day05Kt$part1$1;
      17: checkcast     #93                 // class kotlin/jvm/functions/Function2
      20: invokestatic  #97                 // Method rearrange:(Lkotlin/jvm/functions/Function2;)V
      23: invokestatic  #101                // Method message:()Ljava/lang/String;
      26: areturn

  public static final java.lang.String part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #81                 // String input
       3: invokestatic  #28                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iconst_0
       8: iconst_0
       9: iconst_3
      10: aconst_null
      11: invokestatic  #85                 // Method parse$default:(Ljava/util/List;IIILjava/lang/Object;)V
      14: getstatic     #106                // Field day05/Day05Kt$part2$1.INSTANCE:Lday05/Day05Kt$part2$1;
      17: checkcast     #93                 // class kotlin/jvm/functions/Function2
      20: invokestatic  #97                 // Method rearrange:(Lkotlin/jvm/functions/Function2;)V
      23: invokestatic  #101                // Method message:()Ljava/lang/String;
      26: areturn

  private static final void parse(java.util.List<java.lang.String>, int, int);
    Code:
       0: aload_0
       1: checkcast     #111                // class java/lang/Iterable
       4: iload_1
       5: invokestatic  #117                // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
       8: iload_2
       9: invokestatic  #121                // Method parseToStacks:(Ljava/util/List;I)Ljava/util/List;
      12: putstatic     #17                 // Field stacks:Ljava/util/List;
      15: aload_0
      16: checkcast     #111                // class java/lang/Iterable
      19: iload_1
      20: iconst_2
      21: iadd
      22: invokestatic  #124                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
      25: invokestatic  #128                // Method parseMoves:(Ljava/util/List;)Ljava/util/List;
      28: putstatic     #33                 // Field moves:Ljava/util/List;
      31: return

  static void parse$default(java.util.List, int, int, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          9
       6: bipush        8
       8: istore_1
       9: iload_3
      10: iconst_2
      11: iand
      12: ifeq          18
      15: bipush        9
      17: istore_2
      18: aload_0
      19: iload_1
      20: iload_2
      21: invokestatic  #134                // Method parse:(Ljava/util/List;II)V
      24: return

  private static final void rearrange(kotlin.jvm.functions.Function2<? super day05.Move, ? super java.util.List<? extends java.util.Stack<java.lang.Character>>, kotlin.Unit>);
    Code:
       0: getstatic     #33                 // Field moves:Ljava/util/List;
       3: checkcast     #111                // class java/lang/Iterable
       6: astore_1
       7: iconst_0
       8: istore_2
       9: aload_1
      10: invokeinterface #139,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      15: astore_3
      16: aload_3
      17: invokeinterface #145,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      22: ifeq          60
      25: aload_3
      26: invokeinterface #148,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      31: astore        4
      33: aload         4
      35: checkcast     #150                // class day05/Move
      38: astore        5
      40: iconst_0
      41: istore        6
      43: aload_0
      44: aload         5
      46: getstatic     #17                 // Field stacks:Ljava/util/List;
      49: invokeinterface #154,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      54: pop
      55: nop
      56: nop
      57: goto          16
      60: nop
      61: return

  private static final void movingSingleCrate(day05.Move, java.util.List<? extends java.util.Stack<java.lang.Character>>);
    Code:
       0: aload_0
       1: invokevirtual #171                // Method day05/Move.getNumberOfCrates:()I
       4: istore_2
       5: iconst_0
       6: istore_3
       7: iload_3
       8: iload_2
       9: if_icmpge     59
      12: iconst_0
      13: istore        4
      15: aload_1
      16: aload_0
      17: invokevirtual #174                // Method day05/Move.getTo:()I
      20: iconst_1
      21: isub
      22: invokeinterface #180,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      27: checkcast     #182                // class java/util/Stack
      30: aload_1
      31: aload_0
      32: invokevirtual #185                // Method day05/Move.getFrom:()I
      35: iconst_1
      36: isub
      37: invokeinterface #180,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      42: checkcast     #182                // class java/util/Stack
      45: invokevirtual #188                // Method java/util/Stack.pop:()Ljava/lang/Object;
      48: invokevirtual #192                // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;
      51: pop
      52: nop
      53: iinc          3, 1
      56: goto          7
      59: return

  private static final void movingPartialStack(day05.Move, java.util.List<? extends java.util.Stack<java.lang.Character>>);
    Code:
       0: new           #196                // class java/util/ArrayList
       3: dup
       4: invokespecial #199                // Method java/util/ArrayList."<init>":()V
       7: checkcast     #176                // class java/util/List
      10: astore_2
      11: aload_0
      12: invokevirtual #171                // Method day05/Move.getNumberOfCrates:()I
      15: istore_3
      16: iconst_0
      17: istore        4
      19: iload         4
      21: iload_3
      22: if_icmpge     66
      25: iconst_0
      26: istore        6
      28: aload_2
      29: aload_1
      30: aload_0
      31: invokevirtual #185                // Method day05/Move.getFrom:()I
      34: iconst_1
      35: isub
      36: invokeinterface #180,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      41: checkcast     #182                // class java/util/Stack
      44: invokevirtual #188                // Method java/util/Stack.pop:()Ljava/lang/Object;
      47: dup
      48: ldc           #201                // String pop(...)
      50: invokestatic  #204                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      53: invokeinterface #208,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      58: pop
      59: nop
      60: iinc          4, 1
      63: goto          19
      66: aload_2
      67: checkcast     #111                // class java/lang/Iterable
      70: invokestatic  #212                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
      73: checkcast     #111                // class java/lang/Iterable
      76: astore_3
      77: iconst_0
      78: istore        4
      80: aload_3
      81: invokeinterface #139,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      86: astore        5
      88: aload         5
      90: invokeinterface #145,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      95: ifeq          149
      98: aload         5
     100: invokeinterface #148,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     105: astore        6
     107: aload         6
     109: checkcast     #214                // class java/lang/Character
     112: invokevirtual #218                // Method java/lang/Character.charValue:()C
     115: istore        7
     117: iconst_0
     118: istore        8
     120: aload_1
     121: aload_0
     122: invokevirtual #174                // Method day05/Move.getTo:()I
     125: iconst_1
     126: isub
     127: invokeinterface #180,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     132: checkcast     #182                // class java/util/Stack
     135: iload         7
     137: invokestatic  #222                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     140: invokevirtual #192                // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;
     143: pop
     144: nop
     145: nop
     146: goto          88
     149: nop
     150: return

  private static final java.lang.String message();
    Code:
       0: getstatic     #17                 // Field stacks:Ljava/util/List;
       3: checkcast     #111                // class java/lang/Iterable
       6: astore_0
       7: iconst_0
       8: istore_1
       9: aload_0
      10: astore_2
      11: new           #196                // class java/util/ArrayList
      14: dup
      15: aload_0
      16: bipush        10
      18: invokestatic  #231                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #234                // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #236                // class java/util/Collection
      27: astore_3
      28: iconst_0
      29: istore        4
      31: aload_2
      32: invokeinterface #139,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        5
      39: aload         5
      41: invokeinterface #145,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          91
      49: aload         5
      51: invokeinterface #148,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        6
      58: aload_3
      59: aload         6
      61: checkcast     #182                // class java/util/Stack
      64: astore        7
      66: astore        9
      68: iconst_0
      69: istore        8
      71: aload         7
      73: invokevirtual #188                // Method java/util/Stack.pop:()Ljava/lang/Object;
      76: checkcast     #214                // class java/lang/Character
      79: aload         9
      81: swap
      82: invokeinterface #237,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      87: pop
      88: goto          39
      91: aload_3
      92: checkcast     #176                // class java/util/List
      95: nop
      96: checkcast     #111                // class java/lang/Iterable
      99: ldc           #239                // String
     101: checkcast     #241                // class java/lang/CharSequence
     104: aconst_null
     105: aconst_null
     106: iconst_0
     107: aconst_null
     108: aconst_null
     109: bipush        62
     111: aconst_null
     112: invokestatic  #245                // 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;
     115: areturn

  public static final java.util.List<day05.Move> parseMoves(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc_w         #257                // String <this>
       4: invokestatic  #28                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: checkcast     #111                // class java/lang/Iterable
      11: astore_1
      12: iconst_0
      13: istore_2
      14: aload_1
      15: astore_3
      16: new           #196                // class java/util/ArrayList
      19: dup
      20: aload_1
      21: bipush        10
      23: invokestatic  #231                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      26: invokespecial #234                // Method java/util/ArrayList."<init>":(I)V
      29: checkcast     #236                // class java/util/Collection
      32: astore        4
      34: iconst_0
      35: istore        5
      37: aload_3
      38: invokeinterface #139,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      43: astore        6
      45: aload         6
      47: invokeinterface #145,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      52: ifeq          222
      55: aload         6
      57: invokeinterface #148,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      62: astore        7
      64: aload         4
      66: aload         7
      68: checkcast     #259                // class java/lang/String
      71: astore        8
      73: astore        15
      75: iconst_0
      76: istore        9
      78: invokestatic  #261                // Method getRegex:()Lkotlin/text/Regex;
      81: aload         8
      83: checkcast     #241                // class java/lang/CharSequence
      86: invokevirtual #265                // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;
      89: dup
      90: ifnull        196
      93: invokeinterface #271,  1          // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;
      98: dup
      99: ifnull        196
     102: astore        10
     104: iconst_0
     105: istore        11
     107: aload         10
     109: invokevirtual #277                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     112: invokeinterface #280,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     117: iconst_1
     118: invokeinterface #180,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     123: checkcast     #259                // class java/lang/String
     126: astore        12
     128: aload         10
     130: invokevirtual #277                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     133: invokeinterface #280,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     138: iconst_2
     139: invokeinterface #180,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     144: checkcast     #259                // class java/lang/String
     147: astore        13
     149: aload         10
     151: invokevirtual #277                // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     154: invokeinterface #280,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     159: iconst_3
     160: invokeinterface #180,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     165: checkcast     #259                // class java/lang/String
     168: astore        14
     170: new           #150                // class day05/Move
     173: dup
     174: aload         13
     176: invokestatic  #286                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     179: aload         14
     181: invokestatic  #286                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     184: aload         12
     186: invokestatic  #286                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     189: invokespecial #289                // Method day05/Move."<init>":(III)V
     192: nop
     193: goto          210
     196: pop
     197: new           #291                // class java/lang/IllegalStateException
     200: dup
     201: ldc           #239                // String
     203: invokevirtual #294                // Method java/lang/Object.toString:()Ljava/lang/String;
     206: invokespecial #297                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     209: athrow
     210: aload         15
     212: swap
     213: invokeinterface #237,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     218: pop
     219: goto          45
     222: aload         4
     224: checkcast     #176                // class java/util/List
     227: nop
     228: areturn

  public static final java.util.List<java.util.Stack<java.lang.Character>> parseToStacks(java.util.List<java.lang.String>, int);
    Code:
       0: aload_0
       1: ldc_w         #257                // String <this>
       4: invokestatic  #28                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: new           #196                // class java/util/ArrayList
      10: dup
      11: invokespecial #199                // Method java/util/ArrayList."<init>":()V
      14: checkcast     #176                // class java/util/List
      17: astore_2
      18: iconst_0
      19: istore_3
      20: iload_3
      21: iload_1
      22: if_icmpge     51
      25: iload_3
      26: istore        4
      28: iconst_0
      29: istore        5
      31: aload_2
      32: new           #182                // class java/util/Stack
      35: dup
      36: invokespecial #306                // Method java/util/Stack."<init>":()V
      39: invokeinterface #208,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      44: pop
      45: iinc          3, 1
      48: goto          20
      51: aload_0
      52: checkcast     #111                // class java/lang/Iterable
      55: invokestatic  #212                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
      58: checkcast     #111                // class java/lang/Iterable
      61: astore_3
      62: iconst_0
      63: istore        4
      65: aload_3
      66: invokeinterface #139,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      71: astore        5
      73: aload         5
      75: invokeinterface #145,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      80: ifeq          214
      83: aload         5
      85: invokeinterface #148,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      90: astore        6
      92: aload         6
      94: checkcast     #259                // class java/lang/String
      97: astore        7
      99: iconst_0
     100: istore        8
     102: aload         7
     104: checkcast     #241                // class java/lang/CharSequence
     107: astore        9
     109: iconst_0
     110: istore        10
     112: iconst_0
     113: istore        11
     115: iconst_0
     116: istore        12
     118: iload         12
     120: aload         9
     122: invokeinterface #309,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     127: if_icmpge     208
     130: aload         9
     132: iload         12
     134: invokeinterface #313,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     139: istore        13
     141: iload         11
     143: iinc          11, 1
     146: iload         13
     148: istore        14
     150: istore        15
     152: iconst_0
     153: istore        16
     155: getstatic     #12                 // Field stackIndices:Ljava/util/List;
     158: iload         15
     160: invokestatic  #316                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     163: invokeinterface #319,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     168: ifeq          200
     171: iload         14
     173: bipush        32
     175: if_icmpeq     200
     178: aload_2
     179: iload         15
     181: iconst_4
     182: idiv
     183: invokeinterface #180,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     188: checkcast     #182                // class java/util/Stack
     191: iload         14
     193: invokestatic  #222                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     196: invokevirtual #192                // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;
     199: pop
     200: nop
     201: nop
     202: iinc          12, 1
     205: goto          118
     208: nop
     209: nop
     210: nop
     211: goto          73
     214: nop
     215: aload_2
     216: areturn

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

  private static final kotlin.text.Regex regex_delegate$lambda$0();
    Code:
       0: new           #49                 // class kotlin/text/Regex
       3: dup
       4: ldc_w         #339                // String move (\\d+) from (\\d) to (\\d)
       7: invokespecial #340                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      10: areturn

  public static final void access$movingSingleCrate(day05.Move, java.util.List);
    Code:
       0: aload_0
       1: aload_1
       2: invokestatic  #343                // Method movingSingleCrate:(Lday05/Move;Ljava/util/List;)V
       5: return

  public static final void access$movingPartialStack(day05.Move, java.util.List);
    Code:
       0: aload_0
       1: aload_1
       2: invokestatic  #346                // Method movingPartialStack:(Lday05/Move;Ljava/util/List;)V
       5: return

  static {};
    Code:
       0: bipush        9
       2: anewarray     #282                // class java/lang/Integer
       5: astore_0
       6: aload_0
       7: iconst_0
       8: iconst_1
       9: invokestatic  #316                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      12: aastore
      13: aload_0
      14: iconst_1
      15: iconst_5
      16: invokestatic  #316                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      19: aastore
      20: aload_0
      21: iconst_2
      22: bipush        9
      24: invokestatic  #316                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      27: aastore
      28: aload_0
      29: iconst_3
      30: bipush        13
      32: invokestatic  #316                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      35: aastore
      36: aload_0
      37: iconst_4
      38: bipush        17
      40: invokestatic  #316                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      43: aastore
      44: aload_0
      45: iconst_5
      46: bipush        21
      48: invokestatic  #316                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      51: aastore
      52: aload_0
      53: bipush        6
      55: bipush        25
      57: invokestatic  #316                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      60: aastore
      61: aload_0
      62: bipush        7
      64: bipush        29
      66: invokestatic  #316                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      69: aastore
      70: aload_0
      71: bipush        8
      73: bipush        33
      75: invokestatic  #316                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      78: aastore
      79: aload_0
      80: invokestatic  #351                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      83: putstatic     #12                 // Field stackIndices:Ljava/util/List;
      86: invokestatic  #354                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      89: putstatic     #17                 // Field stacks:Ljava/util/List;
      92: invokestatic  #354                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      95: putstatic     #33                 // Field moves:Ljava/util/List;
      98: invokedynamic #369,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function0;
     103: invokestatic  #375                // Method kotlin/LazyKt.lazy:(Lkotlin/jvm/functions/Function0;)Lkotlin/Lazy;
     106: putstatic     #41                 // Field regex$delegate:Lkotlin/Lazy;
     109: return
}

Compiled from "day05.kt"
final class day05.Day05Kt$part2$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<day05.Move, java.util.List<? extends java.util.Stack<java.lang.Character>>, kotlin.Unit> {
  public static final day05.Day05Kt$part2$1 INSTANCE;

  day05.Day05Kt$part2$1();
    Code:
       0: aload_0
       1: iconst_2
       2: ldc           #11                 // class day05/Day05Kt
       4: ldc           #13                 // String movingPartialStack
       6: ldc           #15                 // String movingPartialStack(Lday05/Move;Ljava/util/List;)V
       8: iconst_1
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final void invoke(day05.Move, java.util.List<? extends java.util.Stack<java.lang.Character>>);
    Code:
       0: aload_1
       1: ldc           #25                 // String p0
       3: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #33                 // String p1
       9: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: aload_2
      14: invokestatic  #36                 // Method day05/Day05Kt.access$movingPartialStack:(Lday05/Move;Ljava/util/List;)V
      17: return

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #41                 // class day05/Move
       5: aload_2
       6: checkcast     #43                 // class java/util/List
       9: invokevirtual #45                 // Method invoke:(Lday05/Move;Ljava/util/List;)V
      12: getstatic     #51                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      15: areturn

  static {};
    Code:
       0: new           #2                  // class day05/Day05Kt$part2$1
       3: dup
       4: invokespecial #56                 // Method "<init>":()V
       7: putstatic     #58                 // Field INSTANCE:Lday05/Day05Kt$part2$1;
      10: return
}

Compiled from "day05.kt"
final class day05.Day05Kt$part1$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<day05.Move, java.util.List<? extends java.util.Stack<java.lang.Character>>, kotlin.Unit> {
  public static final day05.Day05Kt$part1$1 INSTANCE;

  day05.Day05Kt$part1$1();
    Code:
       0: aload_0
       1: iconst_2
       2: ldc           #11                 // class day05/Day05Kt
       4: ldc           #13                 // String movingSingleCrate
       6: ldc           #15                 // String movingSingleCrate(Lday05/Move;Ljava/util/List;)V
       8: iconst_1
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final void invoke(day05.Move, java.util.List<? extends java.util.Stack<java.lang.Character>>);
    Code:
       0: aload_1
       1: ldc           #25                 // String p0
       3: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #33                 // String p1
       9: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: aload_2
      14: invokestatic  #36                 // Method day05/Day05Kt.access$movingSingleCrate:(Lday05/Move;Ljava/util/List;)V
      17: return

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #41                 // class day05/Move
       5: aload_2
       6: checkcast     #43                 // class java/util/List
       9: invokevirtual #45                 // Method invoke:(Lday05/Move;Ljava/util/List;)V
      12: getstatic     #51                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      15: areturn

  static {};
    Code:
       0: new           #2                  // class day05/Day05Kt$part1$1
       3: dup
       4: invokespecial #56                 // Method "<init>":()V
       7: putstatic     #58                 // Field INSTANCE:Lday05/Day05Kt$part1$1;
      10: return
}


package day18

import readInput

fun main() {
    val input = readInput("main/day18/Day18")
    println(part1(input))
    println(part2(input))
}

fun part1(input: List<String>): Int = input.toCubes().surfaceArea()

fun part2(input: List<String>): Int = exteriorSurfaceArea(input.toCubes())

private fun List<String>.toCubes() = map { line ->
    val (x, y, z) = line.split(",")
    Cube(x.toInt(), y.toInt(), z.toInt())
}

private fun List<Cube>.surfaceArea(): Int = sumOf { it.neighbours().filter { c -> c !in this }.size }

private fun exteriorSurfaceArea(cubes: List<Cube>): Int {
    val minX = cubes.minOf { it.x } - 1
    val maxX = cubes.maxOf { it.x } + 1
    val minY = cubes.minOf { it.y } - 1
    val maxY = cubes.maxOf { it.y } + 1
    val minZ = cubes.minOf { it.z } - 1
    val maxZ = cubes.maxOf { it.z } + 1

    val surface = mutableSetOf<Cube>()
    val queue = mutableListOf(Cube(minX, minY, minZ))
    while (queue.isNotEmpty()) {
        val current = queue.removeLast()
        if (current in cubes) continue
        val (x, y, z) = current
        if (x !in minX..maxX || y !in minY..maxY || z !in minZ..maxZ) continue
        if (surface.add(current)) queue.addAll(current.neighbours())
    }
    return cubes.sumOf { it.neighbours().filter { c -> c in surface }.size }
}

data class Cube(val x: Int, val y: Int, val z: Int) {
    fun neighbours() = listOf(
        Cube(x + 1, y, z), Cube(x - 1, y, z),
        Cube(x, y + 1, z), Cube(x, y - 1, z),
        Cube(x, y, z + 1), Cube(x, y, z - 1)
    )
}

Compiled from "day18.kt"
public final class day18.Day18Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String main/day18/Day18
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method part1:(Ljava/util/List;)I
      10: istore_1
      11: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      14: iload_1
      15: invokevirtual #30                 // Method java/io/PrintStream.println:(I)V
      18: aload_0
      19: invokestatic  #33                 // Method part2:(Ljava/util/List;)I
      22: istore_1
      23: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      26: iload_1
      27: invokevirtual #30                 // Method java/io/PrintStream.println:(I)V
      30: return

  public static final int part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #38                 // String input
       3: invokestatic  #44                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #48                 // Method toCubes:(Ljava/util/List;)Ljava/util/List;
      10: invokestatic  #51                 // Method surfaceArea:(Ljava/util/List;)I
      13: ireturn

  public static final int part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #38                 // String input
       3: invokestatic  #44                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #48                 // Method toCubes:(Ljava/util/List;)Ljava/util/List;
      10: invokestatic  #54                 // Method exteriorSurfaceArea:(Ljava/util/List;)I
      13: ireturn

  private static final java.util.List<day18.Cube> toCubes(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #57                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: astore_3
       9: new           #59                 // class java/util/ArrayList
      12: dup
      13: aload_1
      14: bipush        10
      16: invokestatic  #65                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      19: invokespecial #68                 // Method java/util/ArrayList."<init>":(I)V
      22: checkcast     #70                 // class java/util/Collection
      25: astore        4
      27: iconst_0
      28: istore        5
      30: aload_3
      31: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      36: astore        6
      38: aload         6
      40: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      45: ifeq          173
      48: aload         6
      50: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      55: astore        7
      57: aload         4
      59: aload         7
      61: checkcast     #86                 // class java/lang/String
      64: astore        8
      66: astore        14
      68: iconst_0
      69: istore        9
      71: aload         8
      73: checkcast     #88                 // class java/lang/CharSequence
      76: iconst_1
      77: anewarray     #86                 // class java/lang/String
      80: astore        10
      82: aload         10
      84: iconst_0
      85: ldc           #90                 // String ,
      87: aastore
      88: aload         10
      90: iconst_0
      91: iconst_0
      92: bipush        6
      94: aconst_null
      95: invokestatic  #96                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      98: astore        11
     100: aload         11
     102: iconst_0
     103: invokeinterface #102,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     108: checkcast     #86                 // class java/lang/String
     111: astore        10
     113: aload         11
     115: iconst_1
     116: invokeinterface #102,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     121: checkcast     #86                 // class java/lang/String
     124: astore        12
     126: aload         11
     128: iconst_2
     129: invokeinterface #102,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     134: checkcast     #86                 // class java/lang/String
     137: astore        13
     139: new           #104                // class day18/Cube
     142: dup
     143: aload         10
     145: invokestatic  #110                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     148: aload         12
     150: invokestatic  #110                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     153: aload         13
     155: invokestatic  #110                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     158: invokespecial #113                // Method day18/Cube."<init>":(III)V
     161: aload         14
     163: swap
     164: invokeinterface #117,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     169: pop
     170: goto          38
     173: aload         4
     175: checkcast     #98                 // class java/util/List
     178: nop
     179: areturn

  private static final int surfaceArea(java.util.List<day18.Cube>);
    Code:
       0: aload_0
       1: checkcast     #57                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      13: astore_3
      14: aload_3
      15: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      20: ifeq          168
      23: aload_3
      24: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      29: astore        4
      31: iload_2
      32: aload         4
      34: checkcast     #104                // class day18/Cube
      37: astore        5
      39: istore        16
      41: iconst_0
      42: istore        6
      44: aload         5
      46: invokevirtual #139                // Method day18/Cube.neighbours:()Ljava/util/List;
      49: checkcast     #57                 // class java/lang/Iterable
      52: astore        7
      54: iconst_0
      55: istore        8
      57: aload         7
      59: astore        9
      61: new           #59                 // class java/util/ArrayList
      64: dup
      65: invokespecial #141                // Method java/util/ArrayList."<init>":()V
      68: checkcast     #70                 // class java/util/Collection
      71: astore        10
      73: iconst_0
      74: istore        11
      76: aload         9
      78: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      83: astore        12
      85: aload         12
      87: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      92: ifeq          146
      95: aload         12
      97: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     102: astore        13
     104: aload         13
     106: checkcast     #104                // class day18/Cube
     109: astore        14
     111: iconst_0
     112: istore        15
     114: aload_0
     115: aload         14
     117: invokeinterface #144,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     122: ifne          129
     125: iconst_1
     126: goto          130
     129: iconst_0
     130: ifeq          85
     133: aload         10
     135: aload         13
     137: invokeinterface #117,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     142: pop
     143: goto          85
     146: aload         10
     148: checkcast     #98                 // class java/util/List
     151: nop
     152: invokeinterface #148,  1          // InterfaceMethod java/util/List.size:()I
     157: istore        17
     159: iload         16
     161: iload         17
     163: iadd
     164: istore_2
     165: goto          14
     168: iload_2
     169: ireturn

  private static final int exteriorSurfaceArea(java.util.List<day18.Cube>);
    Code:
       0: aload_0
       1: checkcast     #57                 // class java/lang/Iterable
       4: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
       9: astore_3
      10: aload_3
      11: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      16: ifne          27
      19: new           #161                // class java/util/NoSuchElementException
      22: dup
      23: invokespecial #162                // Method java/util/NoSuchElementException."<init>":()V
      26: athrow
      27: aload_3
      28: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      33: checkcast     #104                // class day18/Cube
      36: astore        4
      38: iconst_0
      39: istore        5
      41: aload         4
      43: invokevirtual #165                // Method day18/Cube.getX:()I
      46: istore        4
      48: aload_3
      49: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      54: ifeq          92
      57: aload_3
      58: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: checkcast     #104                // class day18/Cube
      66: astore        5
      68: iconst_0
      69: istore        6
      71: aload         5
      73: invokevirtual #165                // Method day18/Cube.getX:()I
      76: istore        5
      78: iload         4
      80: iload         5
      82: if_icmple     48
      85: iload         5
      87: istore        4
      89: goto          48
      92: iload         4
      94: iconst_1
      95: isub
      96: istore_1
      97: aload_0
      98: checkcast     #57                 // class java/lang/Iterable
     101: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     106: astore        4
     108: aload         4
     110: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     115: ifne          126
     118: new           #161                // class java/util/NoSuchElementException
     121: dup
     122: invokespecial #162                // Method java/util/NoSuchElementException."<init>":()V
     125: athrow
     126: aload         4
     128: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     133: checkcast     #104                // class day18/Cube
     136: astore        5
     138: iconst_0
     139: istore        6
     141: aload         5
     143: invokevirtual #165                // Method day18/Cube.getX:()I
     146: istore        5
     148: aload         4
     150: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     155: ifeq          194
     158: aload         4
     160: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     165: checkcast     #104                // class day18/Cube
     168: astore        6
     170: iconst_0
     171: istore        7
     173: aload         6
     175: invokevirtual #165                // Method day18/Cube.getX:()I
     178: istore        6
     180: iload         5
     182: iload         6
     184: if_icmpge     148
     187: iload         6
     189: istore        5
     191: goto          148
     194: iload         5
     196: iconst_1
     197: iadd
     198: istore_2
     199: aload_0
     200: checkcast     #57                 // class java/lang/Iterable
     203: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     208: astore        5
     210: aload         5
     212: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     217: ifne          228
     220: new           #161                // class java/util/NoSuchElementException
     223: dup
     224: invokespecial #162                // Method java/util/NoSuchElementException."<init>":()V
     227: athrow
     228: aload         5
     230: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     235: checkcast     #104                // class day18/Cube
     238: astore        6
     240: iconst_0
     241: istore        7
     243: aload         6
     245: invokevirtual #168                // Method day18/Cube.getY:()I
     248: istore        6
     250: aload         5
     252: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     257: ifeq          296
     260: aload         5
     262: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     267: checkcast     #104                // class day18/Cube
     270: astore        7
     272: iconst_0
     273: istore        8
     275: aload         7
     277: invokevirtual #168                // Method day18/Cube.getY:()I
     280: istore        7
     282: iload         6
     284: iload         7
     286: if_icmple     250
     289: iload         7
     291: istore        6
     293: goto          250
     296: iload         6
     298: iconst_1
     299: isub
     300: istore_3
     301: aload_0
     302: checkcast     #57                 // class java/lang/Iterable
     305: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     310: astore        6
     312: aload         6
     314: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     319: ifne          330
     322: new           #161                // class java/util/NoSuchElementException
     325: dup
     326: invokespecial #162                // Method java/util/NoSuchElementException."<init>":()V
     329: athrow
     330: aload         6
     332: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     337: checkcast     #104                // class day18/Cube
     340: astore        7
     342: iconst_0
     343: istore        8
     345: aload         7
     347: invokevirtual #168                // Method day18/Cube.getY:()I
     350: istore        7
     352: aload         6
     354: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     359: ifeq          398
     362: aload         6
     364: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     369: checkcast     #104                // class day18/Cube
     372: astore        8
     374: iconst_0
     375: istore        9
     377: aload         8
     379: invokevirtual #168                // Method day18/Cube.getY:()I
     382: istore        8
     384: iload         7
     386: iload         8
     388: if_icmpge     352
     391: iload         8
     393: istore        7
     395: goto          352
     398: iload         7
     400: iconst_1
     401: iadd
     402: istore        4
     404: aload_0
     405: checkcast     #57                 // class java/lang/Iterable
     408: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     413: astore        7
     415: aload         7
     417: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     422: ifne          433
     425: new           #161                // class java/util/NoSuchElementException
     428: dup
     429: invokespecial #162                // Method java/util/NoSuchElementException."<init>":()V
     432: athrow
     433: aload         7
     435: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     440: checkcast     #104                // class day18/Cube
     443: astore        8
     445: iconst_0
     446: istore        9
     448: aload         8
     450: invokevirtual #171                // Method day18/Cube.getZ:()I
     453: istore        8
     455: aload         7
     457: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     462: ifeq          501
     465: aload         7
     467: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     472: checkcast     #104                // class day18/Cube
     475: astore        9
     477: iconst_0
     478: istore        10
     480: aload         9
     482: invokevirtual #171                // Method day18/Cube.getZ:()I
     485: istore        9
     487: iload         8
     489: iload         9
     491: if_icmple     455
     494: iload         9
     496: istore        8
     498: goto          455
     501: iload         8
     503: iconst_1
     504: isub
     505: istore        5
     507: aload_0
     508: checkcast     #57                 // class java/lang/Iterable
     511: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     516: astore        8
     518: aload         8
     520: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     525: ifne          536
     528: new           #161                // class java/util/NoSuchElementException
     531: dup
     532: invokespecial #162                // Method java/util/NoSuchElementException."<init>":()V
     535: athrow
     536: aload         8
     538: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     543: checkcast     #104                // class day18/Cube
     546: astore        9
     548: iconst_0
     549: istore        10
     551: aload         9
     553: invokevirtual #171                // Method day18/Cube.getZ:()I
     556: istore        9
     558: aload         8
     560: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     565: ifeq          604
     568: aload         8
     570: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     575: checkcast     #104                // class day18/Cube
     578: astore        10
     580: iconst_0
     581: istore        11
     583: aload         10
     585: invokevirtual #171                // Method day18/Cube.getZ:()I
     588: istore        10
     590: iload         9
     592: iload         10
     594: if_icmpge     558
     597: iload         10
     599: istore        9
     601: goto          558
     604: iload         9
     606: iconst_1
     607: iadd
     608: istore        6
     610: new           #173                // class java/util/LinkedHashSet
     613: dup
     614: invokespecial #174                // Method java/util/LinkedHashSet."<init>":()V
     617: checkcast     #176                // class java/util/Set
     620: astore        7
     622: iconst_1
     623: anewarray     #104                // class day18/Cube
     626: astore        9
     628: aload         9
     630: iconst_0
     631: new           #104                // class day18/Cube
     634: dup
     635: iload_1
     636: iload_3
     637: iload         5
     639: invokespecial #113                // Method day18/Cube."<init>":(III)V
     642: aastore
     643: aload         9
     645: invokestatic  #180                // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
     648: astore        8
     650: aload         8
     652: checkcast     #70                 // class java/util/Collection
     655: invokeinterface #183,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     660: ifne          667
     663: iconst_1
     664: goto          668
     667: iconst_0
     668: ifeq          830
     671: aload         8
     673: invokeinterface #186,  1          // InterfaceMethod java/util/List.removeLast:()Ljava/lang/Object;
     678: dup
     679: ldc           #188                // String removeLast(...)
     681: invokestatic  #191                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     684: checkcast     #104                // class day18/Cube
     687: astore        9
     689: aload_0
     690: aload         9
     692: invokeinterface #144,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     697: ifne          650
     700: aload         9
     702: invokevirtual #194                // Method day18/Cube.component1:()I
     705: istore        10
     707: aload         9
     709: invokevirtual #197                // Method day18/Cube.component2:()I
     712: istore        11
     714: aload         9
     716: invokevirtual #200                // Method day18/Cube.component3:()I
     719: istore        12
     721: iload_1
     722: iload         10
     724: if_icmpgt     741
     727: iload         10
     729: iload_2
     730: if_icmpgt     737
     733: iconst_1
     734: goto          742
     737: iconst_0
     738: goto          742
     741: iconst_0
     742: ifeq          650
     745: iload_3
     746: iload         11
     748: if_icmpgt     766
     751: iload         11
     753: iload         4
     755: if_icmpgt     762
     758: iconst_1
     759: goto          767
     762: iconst_0
     763: goto          767
     766: iconst_0
     767: ifeq          650
     770: iload         5
     772: iload         12
     774: if_icmpgt     792
     777: iload         12
     779: iload         6
     781: if_icmpgt     788
     784: iconst_1
     785: goto          793
     788: iconst_0
     789: goto          793
     792: iconst_0
     793: ifne          799
     796: goto          650
     799: aload         7
     801: aload         9
     803: invokeinterface #201,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     808: ifeq          650
     811: aload         8
     813: aload         9
     815: invokevirtual #139                // Method day18/Cube.neighbours:()Ljava/util/List;
     818: checkcast     #70                 // class java/util/Collection
     821: invokeinterface #205,  2          // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z
     826: pop
     827: goto          650
     830: aload_0
     831: checkcast     #57                 // class java/lang/Iterable
     834: astore        9
     836: iconst_0
     837: istore        10
     839: aload         9
     841: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     846: astore        11
     848: aload         11
     850: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     855: ifeq          999
     858: aload         11
     860: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     865: astore        12
     867: iload         10
     869: aload         12
     871: checkcast     #104                // class day18/Cube
     874: astore        13
     876: istore        24
     878: iconst_0
     879: istore        14
     881: aload         13
     883: invokevirtual #139                // Method day18/Cube.neighbours:()Ljava/util/List;
     886: checkcast     #57                 // class java/lang/Iterable
     889: astore        15
     891: iconst_0
     892: istore        16
     894: aload         15
     896: astore        17
     898: new           #59                 // class java/util/ArrayList
     901: dup
     902: invokespecial #141                // Method java/util/ArrayList."<init>":()V
     905: checkcast     #70                 // class java/util/Collection
     908: astore        18
     910: iconst_0
     911: istore        19
     913: aload         17
     915: invokeinterface #74,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     920: astore        20
     922: aload         20
     924: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     929: ifeq          976
     932: aload         20
     934: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     939: astore        21
     941: aload         21
     943: checkcast     #104                // class day18/Cube
     946: astore        22
     948: iconst_0
     949: istore        23
     951: aload         7
     953: aload         22
     955: invokeinterface #206,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     960: ifeq          922
     963: aload         18
     965: aload         21
     967: invokeinterface #117,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     972: pop
     973: goto          922
     976: aload         18
     978: checkcast     #98                 // class java/util/List
     981: nop
     982: invokeinterface #148,  1          // InterfaceMethod java/util/List.size:()I
     987: istore        25
     989: iload         24
     991: iload         25
     993: iadd
     994: istore        10
     996: goto          848
     999: iload         10
    1001: ireturn

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