package dev.kosmx.aoc23.springs

import java.io.File
import java.math.BigInteger
import javax.swing.Spring

fun <T> Collection<T>.subsets(k: Int): Sequence<Collection<T>> = sequence {
    if (k > size) throw IllegalArgumentException("k must be smaller than the superset size")
    if (k == size) yield(this@subsets)
    else if (k > 0) {
        subsets(k, this@subsets)
    } else {
        yield(emptyList()) // if request is 0 size subset(s), there is one and always one
    }
}

private suspend fun <T> SequenceScope<Collection<T>>.subsets(k: Int, set: Collection<T>, subset: Collection<T> = emptyList()) {
    if (k == 1) {
        yieldAll(set.map { subset + it })
    } else {
        set.forEachIndexed { index, t ->
            subsets(k - 1, set.drop(index + 1), subset + t)
        }
    }
}

// memoized solver
private class Variations(val rules: List<Int>, val springs: String) {
    private val memory: MutableMap<Pair<Int, Int>, BigInteger> = mutableMapOf()

    val variation: Int = springs.length - rules.sum() - rules.size + 1

    val offset = List(rules.size) { index ->
        rules.take(index).sum() + index
    }.toIntArray()

    init {
        assert(offset.last() + rules.last() + variation == springs.length) // sanity check
    }

    // This should be not simply recursive, but as recursive as possible.
    // That's how memoization became powerful
    fun getVariations(rulePos: Int = 0, startPos: Int = 0): BigInteger {
        assert(rulePos < rules.size)
        return memory.getOrPut(rulePos to startPos) {
            // step1: check if pos 0 is valid
            val offs = offset[rulePos]
            val zeroValid = (0 ..< rules[rulePos]).all {i ->
                springs[offs + startPos + i] != '.'
            }
                    && (rulePos + 1 == rules.size || springs[offs + startPos + rules[rulePos]] != '#')
                    && (rulePos != 0 || springs.substring(0 ..< startPos).all { it != '#' })

            val size = if (zeroValid) {
                if (rulePos == rules.size - 1) {
                    val remainingValid = (offs + startPos + rules[rulePos]..< springs.length).all { i ->
                        springs[i] != '#'
                    }
                    if (remainingValid) BigInteger.ONE else BigInteger.ZERO
                } else {
                    getVariations(rulePos + 1, startPos)
                }
            } else BigInteger.ZERO

            size + (if (startPos < variation && springs[offs + startPos] != '#' ) getVariations(rulePos, startPos + 1) else BigInteger.ZERO)
        }
    }
}

fun main() {
    val games = File("springs.txt").readLines().filter { it.isNotBlank() }.map { it }

    val p = Regex("#+")

    val sums = games.map { game ->
        var variations = 0
        val (springs, rules) = game.split(" ").let {
            it[0].let { s ->
                List(5) {s}.joinToString("?")
            } to it[1].let { s ->
                val tmp = s.split(",").map { i -> i.toInt() }
                (0 ..< 5).flatMap { tmp }
            }
        }

        val v = Variations(rules, springs)
        val variation = v.getVariations()

        /* //
        val check = run {
            val totalWrong = rules.sum()

            val missing = totalWrong - springs.count { it == '#' }
            val options = springs.mapIndexedNotNull { index, c -> if (c == '?') index else null }
            for (subset in options.subsets(missing)) {
                val newSprings = springs.toCharArray()
                for (index in subset) {
                    newSprings[index] = '#'
                }
                val matches = p.findAll(newSprings.joinToString("")).map { it.value.length }.toList()
                if (matches == rules) {
                    variations++
                }

            }
            variations
        }
        assert(check.toLong() == variation) // */

        variation
    }
    println("Part1: $sums\nsum is ${sums.sum()}")
}

private fun Collection<BigInteger>.sum(): BigInteger = fold(BigInteger.ZERO) { acc, i -> acc + i}

Compiled from "Sets.kt"
final class dev.kosmx.aoc23.springs.SetsKt$subsets$2<T> extends kotlin.coroutines.jvm.internal.ContinuationImpl {
  java.lang.Object L$0;

  java.lang.Object L$1;

  java.lang.Object L$2;

  java.lang.Object L$3;

  int I$0;

  int I$1;

  java.lang.Object result;

  int label;

  dev.kosmx.aoc23.springs.SetsKt$subsets$2(kotlin.coroutines.Continuation<? super dev.kosmx.aoc23.springs.SetsKt$subsets$2>);
    Code:
       0: aload_0
       1: aload_1
       2: invokespecial #37                 // Method kotlin/coroutines/jvm/internal/ContinuationImpl."<init>":(Lkotlin/coroutines/Continuation;)V
       5: return

  public final java.lang.Object invokeSuspend(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #48                 // Field result:Ljava/lang/Object;
       5: aload_0
       6: aload_0
       7: getfield      #51                 // Field label:I
      10: ldc           #52                 // int -2147483648
      12: ior
      13: putfield      #51                 // Field label:I
      16: aconst_null
      17: iconst_0
      18: aconst_null
      19: aconst_null
      20: aload_0
      21: checkcast     #54                 // class kotlin/coroutines/Continuation
      24: invokestatic  #60                 // Method dev/kosmx/aoc23/springs/SetsKt.access$subsets:(Lkotlin/sequences/SequenceScope;ILjava/util/Collection;Ljava/util/Collection;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
      27: areturn
}

Compiled from "Sets.kt"
final class dev.kosmx.aoc23.springs.SetsKt$subsets$1 extends kotlin.coroutines.jvm.internal.RestrictedSuspendLambda implements kotlin.jvm.functions.Function2<kotlin.sequences.SequenceScope<? super java.util.Collection<? extends T>>, kotlin.coroutines.Continuation<? super kotlin.Unit>, java.lang.Object> {
  int label;

  private java.lang.Object L$0;

  final int $k;

  final java.util.Collection<T> $this_subsets;

  dev.kosmx.aoc23.springs.SetsKt$subsets$1(int, java.util.Collection<? extends T>, kotlin.coroutines.Continuation<? super dev.kosmx.aoc23.springs.SetsKt$subsets$1>);
    Code:
       0: aload_0
       1: iload_1
       2: putfield      #14                 // Field $k:I
       5: aload_0
       6: aload_2
       7: putfield      #18                 // Field $this_subsets:Ljava/util/Collection;
      10: aload_0
      11: iconst_2
      12: aload_3
      13: invokespecial #21                 // Method kotlin/coroutines/jvm/internal/RestrictedSuspendLambda."<init>":(ILkotlin/coroutines/Continuation;)V
      16: return

  public final java.lang.Object invokeSuspend(java.lang.Object);
    Code:
       0: invokestatic  #47                 // Method kotlin/coroutines/intrinsics/IntrinsicsKt.getCOROUTINE_SUSPENDED:()Ljava/lang/Object;
       3: astore_3
       4: aload_0
       5: getfield      #50                 // Field label:I
       8: tableswitch   { // 0 to 3
                     0: 40
                     1: 118
                     2: 165
                     3: 197
               default: 207
          }
      40: aload_1
      41: invokestatic  #56                 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V
      44: aload_0
      45: getfield      #60                 // Field L$0:Ljava/lang/Object;
      48: checkcast     #62                 // class kotlin/sequences/SequenceScope
      51: astore_2
      52: aload_0
      53: getfield      #14                 // Field $k:I
      56: aload_0
      57: getfield      #18                 // Field $this_subsets:Ljava/util/Collection;
      60: invokeinterface #68,  1           // InterfaceMethod java/util/Collection.size:()I
      65: if_icmple     78
      68: new           #70                 // class java/lang/IllegalArgumentException
      71: dup
      72: ldc           #72                 // String k must be smaller than the superset size
      74: invokespecial #75                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      77: athrow
      78: aload_0
      79: getfield      #14                 // Field $k:I
      82: aload_0
      83: getfield      #18                 // Field $this_subsets:Ljava/util/Collection;
      86: invokeinterface #68,  1           // InterfaceMethod java/util/Collection.size:()I
      91: if_icmpne     127
      94: aload_2
      95: aload_0
      96: getfield      #18                 // Field $this_subsets:Ljava/util/Collection;
      99: aload_0
     100: checkcast     #77                 // class kotlin/coroutines/Continuation
     103: aload_0
     104: iconst_1
     105: putfield      #50                 // Field label:I
     108: invokevirtual #81                 // Method kotlin/sequences/SequenceScope.yield:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
     111: dup
     112: aload_3
     113: if_acmpne     123
     116: aload_3
     117: areturn
     118: aload_1
     119: invokestatic  #56                 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V
     122: aload_1
     123: pop
     124: goto          203
     127: aload_0
     128: getfield      #14                 // Field $k:I
     131: ifle          174
     134: aload_2
     135: aload_0
     136: getfield      #14                 // Field $k:I
     139: aload_0
     140: getfield      #18                 // Field $this_subsets:Ljava/util/Collection;
     143: aconst_null
     144: aload_0
     145: checkcast     #77                 // class kotlin/coroutines/Continuation
     148: iconst_4
     149: aconst_null
     150: aload_0
     151: iconst_2
     152: putfield      #50                 // Field label:I
     155: invokestatic  #87                 // Method dev/kosmx/aoc23/springs/SetsKt.subsets$default:(Lkotlin/sequences/SequenceScope;ILjava/util/Collection;Ljava/util/Collection;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
     158: dup
     159: aload_3
     160: if_acmpne     170
     163: aload_3
     164: areturn
     165: aload_1
     166: invokestatic  #56                 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V
     169: aload_1
     170: pop
     171: goto          203
     174: aload_2
     175: invokestatic  #93                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     178: aload_0
     179: checkcast     #77                 // class kotlin/coroutines/Continuation
     182: aload_0
     183: iconst_3
     184: putfield      #50                 // Field label:I
     187: invokevirtual #81                 // Method kotlin/sequences/SequenceScope.yield:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
     190: dup
     191: aload_3
     192: if_acmpne     202
     195: aload_3
     196: areturn
     197: aload_1
     198: invokestatic  #56                 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V
     201: aload_1
     202: pop
     203: getstatic     #99                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     206: areturn
     207: new           #101                // class java/lang/IllegalStateException
     210: dup
     211: ldc           #103                // String call to \'resume\' before \'invoke\' with coroutine
     213: invokespecial #104                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     216: athrow

  public final kotlin.coroutines.Continuation<kotlin.Unit> create(java.lang.Object, kotlin.coroutines.Continuation<?>);
    Code:
       0: new           #2                  // class dev/kosmx/aoc23/springs/SetsKt$subsets$1
       3: dup
       4: aload_0
       5: getfield      #14                 // Field $k:I
       8: aload_0
       9: getfield      #18                 // Field $this_subsets:Ljava/util/Collection;
      12: aload_2
      13: invokespecial #114                // Method "<init>":(ILjava/util/Collection;Lkotlin/coroutines/Continuation;)V
      16: astore_3
      17: aload_3
      18: aload_1
      19: putfield      #60                 // Field L$0:Ljava/lang/Object;
      22: aload_3
      23: checkcast     #77                 // class kotlin/coroutines/Continuation
      26: areturn

  public final java.lang.Object invoke(kotlin.sequences.SequenceScope<? super java.util.Collection<? extends T>>, kotlin.coroutines.Continuation<? super kotlin.Unit>);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokevirtual #120                // Method create:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Lkotlin/coroutines/Continuation;
       6: checkcast     #2                  // class dev/kosmx/aoc23/springs/SetsKt$subsets$1
       9: getstatic     #99                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      12: invokevirtual #122                // Method invokeSuspend:(Ljava/lang/Object;)Ljava/lang/Object;
      15: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #62                 // class kotlin/sequences/SequenceScope
       5: aload_2
       6: checkcast     #77                 // class kotlin/coroutines/Continuation
       9: invokevirtual #127                // Method invoke:(Lkotlin/sequences/SequenceScope;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
      12: areturn
}

Compiled from "Sets.kt"
public final class dev.kosmx.aoc23.springs.SetsKt {
  public static final <T> kotlin.sequences.Sequence<java.util.Collection<T>> subsets(java.util.Collection<? extends T>, int);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #18                 // class dev/kosmx/aoc23/springs/SetsKt$subsets$1
       9: dup
      10: iload_1
      11: aload_0
      12: aconst_null
      13: invokespecial #22                 // Method dev/kosmx/aoc23/springs/SetsKt$subsets$1."<init>":(ILjava/util/Collection;Lkotlin/coroutines/Continuation;)V
      16: checkcast     #24                 // class kotlin/jvm/functions/Function2
      19: invokestatic  #30                 // Method kotlin/sequences/SequencesKt.sequence:(Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;
      22: areturn

  private static final <T> java.lang.Object subsets(kotlin.sequences.SequenceScope<? super java.util.Collection<? extends T>>, int, java.util.Collection<? extends T>, java.util.Collection<? extends T>, kotlin.coroutines.Continuation<? super kotlin.Unit>);
    Code:
       0: aload         4
       2: instanceof    #38                 // class dev/kosmx/aoc23/springs/SetsKt$subsets$2
       5: ifeq          41
       8: aload         4
      10: checkcast     #38                 // class dev/kosmx/aoc23/springs/SetsKt$subsets$2
      13: astore        17
      15: aload         17
      17: getfield      #41                 // Field dev/kosmx/aoc23/springs/SetsKt$subsets$2.label:I
      20: ldc           #42                 // int -2147483648
      22: iand
      23: ifeq          41
      26: aload         17
      28: dup
      29: getfield      #41                 // Field dev/kosmx/aoc23/springs/SetsKt$subsets$2.label:I
      32: ldc           #42                 // int -2147483648
      34: isub
      35: putfield      #41                 // Field dev/kosmx/aoc23/springs/SetsKt$subsets$2.label:I
      38: goto          52
      41: new           #38                 // class dev/kosmx/aoc23/springs/SetsKt$subsets$2
      44: dup
      45: aload         4
      47: invokespecial #45                 // Method dev/kosmx/aoc23/springs/SetsKt$subsets$2."<init>":(Lkotlin/coroutines/Continuation;)V
      50: astore        17
      52: aload         17
      54: getfield      #49                 // Field dev/kosmx/aoc23/springs/SetsKt$subsets$2.result:Ljava/lang/Object;
      57: astore        16
      59: invokestatic  #55                 // Method kotlin/coroutines/intrinsics/IntrinsicsKt.getCOROUTINE_SUSPENDED:()Ljava/lang/Object;
      62: astore        18
      64: aload         17
      66: getfield      #41                 // Field dev/kosmx/aoc23/springs/SetsKt$subsets$2.label:I
      69: tableswitch   { // 0 to 2
                     0: 96
                     1: 233
                     2: 396
               default: 468
          }
      96: aload         16
      98: invokestatic  #61                 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V
     101: iload_1
     102: iconst_1
     103: if_icmpne     245
     106: aload_0
     107: aload_2
     108: checkcast     #63                 // class java/lang/Iterable
     111: astore        5
     113: astore        14
     115: iconst_0
     116: istore        6
     118: aload         5
     120: astore        7
     122: new           #65                 // class java/util/ArrayList
     125: dup
     126: aload         5
     128: bipush        10
     130: invokestatic  #71                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     133: invokespecial #74                 // Method java/util/ArrayList."<init>":(I)V
     136: checkcast     #76                 // class java/util/Collection
     139: astore        8
     141: iconst_0
     142: istore        9
     144: aload         7
     146: invokeinterface #80,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     151: astore        10
     153: aload         10
     155: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     160: ifeq          201
     163: aload         10
     165: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     170: astore        11
     172: aload         8
     174: aload         11
     176: astore        12
     178: astore        15
     180: iconst_0
     181: istore        13
     183: aload_3
     184: aload         12
     186: invokestatic  #93                 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     189: aload         15
     191: swap
     192: invokeinterface #97,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     197: pop
     198: goto          153
     201: aload         8
     203: checkcast     #99                 // class java/util/List
     206: nop
     207: aload         14
     209: swap
     210: checkcast     #63                 // class java/lang/Iterable
     213: aload         17
     215: aload         17
     217: iconst_1
     218: putfield      #41                 // Field dev/kosmx/aoc23/springs/SetsKt$subsets$2.label:I
     221: invokevirtual #105                // Method kotlin/sequences/SequenceScope.yieldAll:(Ljava/lang/Iterable;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
     224: dup
     225: aload         18
     227: if_acmpne     240
     230: aload         18
     232: areturn
     233: aload         16
     235: invokestatic  #61                 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V
     238: aload         16
     240: pop
     241: getstatic     #111                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     244: areturn
     245: aload_2
     246: checkcast     #63                 // class java/lang/Iterable
     249: astore        5
     251: iconst_0
     252: istore        6
     254: iconst_0
     255: istore        7
     257: aload         5
     259: invokeinterface #80,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     264: astore        8
     266: aload         8
     268: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     273: ifeq          463
     276: aload         8
     278: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     283: astore        9
     285: iload         7
     287: iinc          7, 1
     290: istore        10
     292: iload         10
     294: ifge          300
     297: invokestatic  #115                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     300: iload         10
     302: aload         9
     304: astore        11
     306: istore        12
     308: iconst_0
     309: istore        13
     311: aload_0
     312: iload_1
     313: iconst_1
     314: isub
     315: aload_2
     316: checkcast     #63                 // class java/lang/Iterable
     319: iload         12
     321: iconst_1
     322: iadd
     323: invokestatic  #119                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     326: checkcast     #76                 // class java/util/Collection
     329: aload_3
     330: aload         11
     332: invokestatic  #93                 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     335: checkcast     #76                 // class java/util/Collection
     338: aload         17
     340: aload         17
     342: aload_0
     343: putfield      #122                // Field dev/kosmx/aoc23/springs/SetsKt$subsets$2.L$0:Ljava/lang/Object;
     346: aload         17
     348: aload_2
     349: putfield      #125                // Field dev/kosmx/aoc23/springs/SetsKt$subsets$2.L$1:Ljava/lang/Object;
     352: aload         17
     354: aload_3
     355: putfield      #128                // Field dev/kosmx/aoc23/springs/SetsKt$subsets$2.L$2:Ljava/lang/Object;
     358: aload         17
     360: aload         8
     362: putfield      #131                // Field dev/kosmx/aoc23/springs/SetsKt$subsets$2.L$3:Ljava/lang/Object;
     365: aload         17
     367: iload_1
     368: putfield      #134                // Field dev/kosmx/aoc23/springs/SetsKt$subsets$2.I$0:I
     371: aload         17
     373: iload         7
     375: putfield      #137                // Field dev/kosmx/aoc23/springs/SetsKt$subsets$2.I$1:I
     378: aload         17
     380: iconst_2
     381: putfield      #41                 // Field dev/kosmx/aoc23/springs/SetsKt$subsets$2.label:I
     384: invokestatic  #139                // Method subsets:(Lkotlin/sequences/SequenceScope;ILjava/util/Collection;Ljava/util/Collection;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
     387: dup
     388: aload         18
     390: if_acmpne     459
     393: aload         18
     395: areturn
     396: iconst_0
     397: istore        6
     399: iconst_0
     400: istore        13
     402: aload         17
     404: getfield      #137                // Field dev/kosmx/aoc23/springs/SetsKt$subsets$2.I$1:I
     407: istore        7
     409: aload         17
     411: getfield      #134                // Field dev/kosmx/aoc23/springs/SetsKt$subsets$2.I$0:I
     414: istore_1
     415: aload         17
     417: getfield      #131                // Field dev/kosmx/aoc23/springs/SetsKt$subsets$2.L$3:Ljava/lang/Object;
     420: checkcast     #82                 // class java/util/Iterator
     423: astore        8
     425: aload         17
     427: getfield      #128                // Field dev/kosmx/aoc23/springs/SetsKt$subsets$2.L$2:Ljava/lang/Object;
     430: checkcast     #76                 // class java/util/Collection
     433: astore_3
     434: aload         17
     436: getfield      #125                // Field dev/kosmx/aoc23/springs/SetsKt$subsets$2.L$1:Ljava/lang/Object;
     439: checkcast     #76                 // class java/util/Collection
     442: astore_2
     443: aload         17
     445: getfield      #122                // Field dev/kosmx/aoc23/springs/SetsKt$subsets$2.L$0:Ljava/lang/Object;
     448: checkcast     #101                // class kotlin/sequences/SequenceScope
     451: astore_0
     452: aload         16
     454: invokestatic  #61                 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V
     457: aload         16
     459: pop
     460: goto          266
     463: nop
     464: getstatic     #111                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     467: areturn
     468: new           #141                // class java/lang/IllegalStateException
     471: dup
     472: ldc           #143                // String call to \'resume\' before \'invoke\' with coroutine
     474: invokespecial #146                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     477: athrow

  static java.lang.Object subsets$default(kotlin.sequences.SequenceScope, int, java.util.Collection, java.util.Collection, kotlin.coroutines.Continuation, int, java.lang.Object);
    Code:
       0: iload         5
       2: iconst_4
       3: iand
       4: ifeq          14
       7: invokestatic  #177                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      10: checkcast     #76                 // class java/util/Collection
      13: astore_3
      14: aload_0
      15: iload_1
      16: aload_2
      17: aload_3
      18: aload         4
      20: invokestatic  #139                // Method subsets:(Lkotlin/sequences/SequenceScope;ILjava/util/Collection;Ljava/util/Collection;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
      23: areturn

  public static final void main();
    Code:
       0: new           #180                // class java/io/File
       3: dup
       4: ldc           #182                // String springs.txt
       6: invokespecial #183                // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #189                // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      15: checkcast     #63                 // class java/lang/Iterable
      18: astore_1
      19: iconst_0
      20: istore_2
      21: aload_1
      22: astore_3
      23: new           #65                 // class java/util/ArrayList
      26: dup
      27: invokespecial #191                // Method java/util/ArrayList."<init>":()V
      30: checkcast     #76                 // class java/util/Collection
      33: astore        4
      35: iconst_0
      36: istore        5
      38: aload_3
      39: invokeinterface #80,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      44: astore        6
      46: aload         6
      48: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      53: ifeq          108
      56: aload         6
      58: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: astore        7
      65: aload         7
      67: checkcast     #193                // class java/lang/String
      70: astore        8
      72: iconst_0
      73: istore        9
      75: aload         8
      77: checkcast     #195                // class java/lang/CharSequence
      80: invokestatic  #201                // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z
      83: ifne          90
      86: iconst_1
      87: goto          91
      90: iconst_0
      91: nop
      92: ifeq          46
      95: aload         4
      97: aload         7
      99: invokeinterface #97,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     104: pop
     105: goto          46
     108: aload         4
     110: checkcast     #99                 // class java/util/List
     113: nop
     114: checkcast     #63                 // class java/lang/Iterable
     117: astore_1
     118: nop
     119: iconst_0
     120: istore_2
     121: aload_1
     122: astore_3
     123: new           #65                 // class java/util/ArrayList
     126: dup
     127: aload_1
     128: bipush        10
     130: invokestatic  #71                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     133: invokespecial #74                 // Method java/util/ArrayList."<init>":(I)V
     136: checkcast     #76                 // class java/util/Collection
     139: astore        4
     141: iconst_0
     142: istore        5
     144: aload_3
     145: invokeinterface #80,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     150: astore        6
     152: aload         6
     154: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     159: ifeq          199
     162: aload         6
     164: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     169: astore        7
     171: aload         4
     173: aload         7
     175: checkcast     #193                // class java/lang/String
     178: astore        8
     180: astore        31
     182: iconst_0
     183: istore        9
     185: aload         8
     187: aload         31
     189: swap
     190: invokeinterface #97,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     195: pop
     196: goto          152
     199: aload         4
     201: checkcast     #99                 // class java/util/List
     204: nop
     205: astore_0
     206: new           #203                // class kotlin/text/Regex
     209: dup
     210: ldc           #205                // String #+
     212: invokespecial #206                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
     215: astore_1
     216: aload_0
     217: checkcast     #63                 // class java/lang/Iterable
     220: astore_3
     221: iconst_0
     222: istore        4
     224: aload_3
     225: astore        5
     227: new           #65                 // class java/util/ArrayList
     230: dup
     231: aload_3
     232: bipush        10
     234: invokestatic  #71                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     237: invokespecial #74                 // Method java/util/ArrayList."<init>":(I)V
     240: checkcast     #76                 // class java/util/Collection
     243: astore        6
     245: iconst_0
     246: istore        7
     248: aload         5
     250: invokeinterface #80,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     255: astore        8
     257: aload         8
     259: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     264: ifeq          732
     267: aload         8
     269: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     274: astore        9
     276: aload         6
     278: aload         9
     280: checkcast     #193                // class java/lang/String
     283: astore        10
     285: astore        31
     287: iconst_0
     288: istore        11
     290: iconst_0
     291: istore        12
     293: aload         10
     295: checkcast     #195                // class java/lang/CharSequence
     298: iconst_1
     299: anewarray     #193                // class java/lang/String
     302: astore        13
     304: aload         13
     306: iconst_0
     307: ldc           #208                // String
     309: aastore
     310: aload         13
     312: iconst_0
     313: iconst_0
     314: bipush        6
     316: aconst_null
     317: invokestatic  #212                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     320: astore        14
     322: iconst_0
     323: istore        15
     325: aload         14
     327: iconst_0
     328: invokeinterface #216,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     333: checkcast     #193                // class java/lang/String
     336: astore        16
     338: iconst_0
     339: istore        17
     341: iconst_5
     342: istore        18
     344: new           #65                 // class java/util/ArrayList
     347: dup
     348: iload         18
     350: invokespecial #74                 // Method java/util/ArrayList."<init>":(I)V
     353: astore        19
     355: iconst_0
     356: istore        20
     358: iload         20
     360: iload         18
     362: if_icmpge     395
     365: iload         20
     367: istore        21
     369: aload         19
     371: iload         21
     373: istore        22
     375: astore        23
     377: iconst_0
     378: istore        24
     380: aload         16
     382: aload         23
     384: swap
     385: invokevirtual #217                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     388: pop
     389: iinc          20, 1
     392: goto          358
     395: aload         19
     397: checkcast     #99                 // class java/util/List
     400: checkcast     #63                 // class java/lang/Iterable
     403: ldc           #219                // String ?
     405: checkcast     #195                // class java/lang/CharSequence
     408: aconst_null
     409: aconst_null
     410: iconst_0
     411: aconst_null
     412: aconst_null
     413: bipush        62
     415: aconst_null
     416: invokestatic  #223                // 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;
     419: nop
     420: aload         14
     422: iconst_1
     423: invokeinterface #216,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     428: checkcast     #193                // class java/lang/String
     431: astore        16
     433: astore        25
     435: iconst_0
     436: istore        17
     438: aload         16
     440: checkcast     #195                // class java/lang/CharSequence
     443: iconst_1
     444: anewarray     #193                // class java/lang/String
     447: astore        18
     449: aload         18
     451: iconst_0
     452: ldc           #225                // String ,
     454: aastore
     455: aload         18
     457: iconst_0
     458: iconst_0
     459: bipush        6
     461: aconst_null
     462: invokestatic  #212                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     465: checkcast     #63                 // class java/lang/Iterable
     468: astore        18
     470: iconst_0
     471: istore        19
     473: aload         18
     475: astore        20
     477: new           #65                 // class java/util/ArrayList
     480: dup
     481: aload         18
     483: bipush        10
     485: invokestatic  #71                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     488: invokespecial #74                 // Method java/util/ArrayList."<init>":(I)V
     491: checkcast     #76                 // class java/util/Collection
     494: astore        21
     496: iconst_0
     497: istore        22
     499: aload         20
     501: invokeinterface #80,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     506: astore        23
     508: aload         23
     510: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     515: ifeq          562
     518: aload         23
     520: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     525: astore        24
     527: aload         21
     529: aload         24
     531: checkcast     #193                // class java/lang/String
     534: astore        26
     536: astore        27
     538: iconst_0
     539: istore        28
     541: aload         26
     543: invokestatic  #231                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     546: nop
     547: invokestatic  #235                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     550: aload         27
     552: swap
     553: invokeinterface #97,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     558: pop
     559: goto          508
     562: aload         21
     564: checkcast     #99                 // class java/util/List
     567: nop
     568: astore        29
     570: iconst_0
     571: iconst_5
     572: invokestatic  #241                // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     575: checkcast     #63                 // class java/lang/Iterable
     578: astore        18
     580: iconst_0
     581: istore        19
     583: aload         18
     585: astore        20
     587: new           #65                 // class java/util/ArrayList
     590: dup
     591: invokespecial #191                // Method java/util/ArrayList."<init>":()V
     594: checkcast     #76                 // class java/util/Collection
     597: astore        21
     599: iconst_0
     600: istore        22
     602: aload         20
     604: invokeinterface #80,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     609: astore        23
     611: aload         23
     613: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     618: ifeq          656
     621: aload         23
     623: checkcast     #243                // class kotlin/collections/IntIterator
     626: invokevirtual #247                // Method kotlin/collections/IntIterator.nextInt:()I
     629: istore        24
     631: iload         24
     633: istore        26
     635: iconst_0
     636: istore        28
     638: aload         29
     640: checkcast     #63                 // class java/lang/Iterable
     643: astore        26
     645: aload         21
     647: aload         26
     649: invokestatic  #251                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     652: pop
     653: goto          611
     656: aload         21
     658: checkcast     #99                 // class java/util/List
     661: nop
     662: nop
     663: aload         25
     665: swap
     666: nop
     667: invokestatic  #257                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     670: nop
     671: nop
     672: astore        30
     674: aload         30
     676: invokevirtual #262                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     679: checkcast     #193                // class java/lang/String
     682: astore        13
     684: aload         30
     686: invokevirtual #265                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     689: checkcast     #99                 // class java/util/List
     692: astore        14
     694: new           #267                // class dev/kosmx/aoc23/springs/Variations
     697: dup
     698: aload         14
     700: aload         13
     702: invokespecial #270                // Method dev/kosmx/aoc23/springs/Variations."<init>":(Ljava/util/List;Ljava/lang/String;)V
     705: astore        15
     707: aload         15
     709: iconst_0
     710: iconst_0
     711: iconst_3
     712: aconst_null
     713: invokestatic  #274                // Method dev/kosmx/aoc23/springs/Variations.getVariations$default:(Ldev/kosmx/aoc23/springs/Variations;IIILjava/lang/Object;)Ljava/math/BigInteger;
     716: astore        16
     718: aload         16
     720: aload         31
     722: swap
     723: invokeinterface #97,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     728: pop
     729: goto          257
     732: aload         6
     734: checkcast     #99                 // class java/util/List
     737: nop
     738: astore_2
     739: new           #276                // class java/lang/StringBuilder
     742: dup
     743: invokespecial #277                // Method java/lang/StringBuilder."<init>":()V
     746: ldc_w         #279                // String Part1:
     749: invokevirtual #283                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     752: aload_2
     753: invokevirtual #286                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     756: ldc_w         #288                // String \nsum is
     759: invokevirtual #283                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     762: aload_2
     763: checkcast     #76                 // class java/util/Collection
     766: invokestatic  #292                // Method sum:(Ljava/util/Collection;)Ljava/math/BigInteger;
     769: invokevirtual #286                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     772: invokevirtual #296                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     775: getstatic     #302                // Field java/lang/System.out:Ljava/io/PrintStream;
     778: swap
     779: invokevirtual #307                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     782: return

  private static final java.math.BigInteger sum(java.util.Collection<? extends java.math.BigInteger>);
    Code:
       0: aload_0
       1: checkcast     #63                 // class java/lang/Iterable
       4: astore_1
       5: getstatic     #351                // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;
       8: astore_2
       9: iconst_0
      10: istore_3
      11: aload_2
      12: astore        4
      14: aload_1
      15: invokeinterface #80,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      20: astore        5
      22: aload         5
      24: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      29: ifeq          80
      32: aload         5
      34: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      39: astore        6
      41: aload         4
      43: aload         6
      45: checkcast     #348                // class java/math/BigInteger
      48: astore        7
      50: astore        8
      52: iconst_0
      53: istore        9
      55: aload         8
      57: invokestatic  #354                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      60: aload         8
      62: aload         7
      64: invokevirtual #357                // Method java/math/BigInteger.add:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
      67: dup
      68: ldc_w         #359                // String add(...)
      71: invokestatic  #362                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      74: nop
      75: astore        4
      77: goto          22
      80: aload         4
      82: dup
      83: ldc_w         #364                // String fold(...)
      86: invokestatic  #362                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      89: areturn

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

  public static final java.lang.Object access$subsets(kotlin.sequences.SequenceScope, int, java.util.Collection, java.util.Collection, kotlin.coroutines.Continuation);
    Code:
       0: aload_0
       1: iload_1
       2: aload_2
       3: aload_3
       4: aload         4
       6: invokestatic  #139                // Method subsets:(Lkotlin/sequences/SequenceScope;ILjava/util/Collection;Ljava/util/Collection;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
       9: areturn
}


package dev.kosmx.aoc23.cubes

import java.io.File
import kotlin.math.max

fun main() {
    val games = File("cubes.txt").readLines().map { Game.of(it) }
    println(games)

    games.sumOf { game ->
        val r = game.rounds.fold(Round()) { acc, round ->
            Round(max(acc.red, round.red), max(acc.green, round.green), max(acc.blue, round.blue))
        }
        r.red * r.green * r.blue
    }
        .let { println(it) }
}

data class Round(val red: Int = 0, val green: Int = 0, val blue: Int = 0)

data class Game(
    val gameId: Int,
    val rounds: List<Round>,
) {
    companion object {
        private val linePattern = Regex("^Game (?<gameid>\\d+): (?<rounds>.+)\$")
        private val redPattern = Regex("((?<num>\\d+) red)")
        private val greenPattern = Regex("((?<num>\\d+) green)")
        private val bluePattern = Regex("((?<num>\\d+) blue)")
        fun of(line: String): Game {
            val match = linePattern.find(line)!!
            val gameId = match.groups["gameid"]!!.value.toInt()
            val rounds = match.groups["rounds"]!!.value.split(";").map {
                Round(
                    red = redPattern.find(it)?.groups?.get("num")?.value?.toInt() ?: 0,
                    green = greenPattern.find(it)?.groups?.get("num")?.value?.toInt() ?: 0,
                    blue = bluePattern.find(it)?.groups?.get("num")?.value?.toInt() ?: 0,
                )
            }
            return Game(gameId, rounds)
        }
    }
}

Compiled from "Cubes.kt"
public final class dev.kosmx.aoc23.cubes.CubesKt {
  public static final void main();
    Code:
       0: new           #8                  // class java/io/File
       3: dup
       4: ldc           #10                 // String cubes.txt
       6: invokespecial #14                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #20                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      15: checkcast     #22                 // class java/lang/Iterable
      18: astore_1
      19: iconst_0
      20: istore_2
      21: aload_1
      22: astore_3
      23: new           #24                 // class java/util/ArrayList
      26: dup
      27: aload_1
      28: bipush        10
      30: invokestatic  #30                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      33: invokespecial #33                 // Method java/util/ArrayList."<init>":(I)V
      36: checkcast     #35                 // class java/util/Collection
      39: astore        4
      41: iconst_0
      42: istore        5
      44: aload_3
      45: invokeinterface #39,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      50: astore        6
      52: aload         6
      54: invokeinterface #45,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      59: ifeq          105
      62: aload         6
      64: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      69: astore        7
      71: aload         4
      73: aload         7
      75: checkcast     #51                 // class java/lang/String
      78: astore        8
      80: astore        17
      82: iconst_0
      83: istore        9
      85: getstatic     #57                 // Field dev/kosmx/aoc23/cubes/Game.Companion:Ldev/kosmx/aoc23/cubes/Game$Companion;
      88: aload         8
      90: invokevirtual #63                 // Method dev/kosmx/aoc23/cubes/Game$Companion.of:(Ljava/lang/String;)Ldev/kosmx/aoc23/cubes/Game;
      93: aload         17
      95: swap
      96: invokeinterface #67,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     101: pop
     102: goto          52
     105: aload         4
     107: checkcast     #69                 // class java/util/List
     110: nop
     111: astore_0
     112: getstatic     #75                 // Field java/lang/System.out:Ljava/io/PrintStream;
     115: aload_0
     116: invokevirtual #81                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     119: aload_0
     120: checkcast     #22                 // class java/lang/Iterable
     123: astore_1
     124: iconst_0
     125: istore_2
     126: aload_1
     127: invokeinterface #39,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     132: astore_3
     133: aload_3
     134: invokeinterface #45,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     139: ifeq          320
     142: aload_3
     143: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     148: astore        4
     150: iload_2
     151: aload         4
     153: checkcast     #53                 // class dev/kosmx/aoc23/cubes/Game
     156: astore        5
     158: istore        17
     160: iconst_0
     161: istore        6
     163: aload         5
     165: invokevirtual #85                 // Method dev/kosmx/aoc23/cubes/Game.getRounds:()Ljava/util/List;
     168: checkcast     #22                 // class java/lang/Iterable
     171: astore        7
     173: new           #87                 // class dev/kosmx/aoc23/cubes/Round
     176: dup
     177: iconst_0
     178: iconst_0
     179: iconst_0
     180: bipush        7
     182: aconst_null
     183: invokespecial #90                 // Method dev/kosmx/aoc23/cubes/Round."<init>":(IIIILkotlin/jvm/internal/DefaultConstructorMarker;)V
     186: astore        8
     188: iconst_0
     189: istore        9
     191: aload         8
     193: astore        10
     195: aload         7
     197: invokeinterface #39,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     202: astore        11
     204: aload         11
     206: invokeinterface #45,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     211: ifeq          288
     214: aload         11
     216: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     221: astore        12
     223: aload         10
     225: aload         12
     227: checkcast     #87                 // class dev/kosmx/aoc23/cubes/Round
     230: astore        13
     232: astore        14
     234: iconst_0
     235: istore        15
     237: new           #87                 // class dev/kosmx/aoc23/cubes/Round
     240: dup
     241: aload         14
     243: invokevirtual #94                 // Method dev/kosmx/aoc23/cubes/Round.getRed:()I
     246: aload         13
     248: invokevirtual #94                 // Method dev/kosmx/aoc23/cubes/Round.getRed:()I
     251: invokestatic  #100                // Method java/lang/Math.max:(II)I
     254: aload         14
     256: invokevirtual #103                // Method dev/kosmx/aoc23/cubes/Round.getGreen:()I
     259: aload         13
     261: invokevirtual #103                // Method dev/kosmx/aoc23/cubes/Round.getGreen:()I
     264: invokestatic  #100                // Method java/lang/Math.max:(II)I
     267: aload         14
     269: invokevirtual #106                // Method dev/kosmx/aoc23/cubes/Round.getBlue:()I
     272: aload         13
     274: invokevirtual #106                // Method dev/kosmx/aoc23/cubes/Round.getBlue:()I
     277: invokestatic  #100                // Method java/lang/Math.max:(II)I
     280: invokespecial #109                // Method dev/kosmx/aoc23/cubes/Round."<init>":(III)V
     283: astore        10
     285: goto          204
     288: aload         10
     290: astore        16
     292: aload         16
     294: invokevirtual #94                 // Method dev/kosmx/aoc23/cubes/Round.getRed:()I
     297: aload         16
     299: invokevirtual #103                // Method dev/kosmx/aoc23/cubes/Round.getGreen:()I
     302: imul
     303: aload         16
     305: invokevirtual #106                // Method dev/kosmx/aoc23/cubes/Round.getBlue:()I
     308: imul
     309: istore        18
     311: iload         17
     313: iload         18
     315: iadd
     316: istore_2
     317: goto          133
     320: iload_2
     321: istore_2
     322: iconst_0
     323: istore_3
     324: getstatic     #75                 // Field java/lang/System.out:Ljava/io/PrintStream;
     327: iload_2
     328: invokevirtual #111                // Method java/io/PrintStream.println:(I)V
     331: nop
     332: nop
     333: return

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