package lib

import java.util.*

// 約数のList
fun divisor(value: Long): List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from: Long, to: Long = from): List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j -> i % j != 0L }
    }
}

// 渡された値が素数か判定
fun isPrime(source: Int): Boolean {
    return prime(source.toLong()).any()
}

// 素因数分解
fun decom(value: Long): List<Long> {
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a: Long, b: Long): Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base: String, a: String, b: String): String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

/**
 * リストをスタックに変換する
 * @param list リスト
 * @return スタック
 */
fun listToStack(list: List<Int>): Stack<Int> {
    // スタック
    val stack = Stack<Int>()

    for (e in list) {
        stack.push(e)
    }

    return stack
}

/**
 * ユークリッドの互除法を用いて、最大公約数を導出する
 * @param list 最大公約数を求める対象となる数が格納されたリスト
 * @return 最大公約数
 */
fun gcd(list: List<Int>): Int {
    // 最大公約数を求める対象となる数が格納されたスタック
    val stack = listToStack(list)

    // ユークリッドの互除法を用いて、最大公約数を導出する
    // (最終的にスタック内に1つだけ数が残り、それが最大公約数となる)
    while (1 < stack.size) {
        // スタックから2つの数をpop
        val pops = (0 until 2).map {
            stack.pop()
        }

        // スタックからpopした2つの数のうち、小さい方の数のインデックス
        val minIndex = if (pops[1] < pops[0]) {
            1
        } else {
            0
        }

        // スタックからpopした2つの数のうち、小さい方の数をpush
        stack.push(pops[minIndex])

        // スタックからpopした2つの数の剰余
        val r = pops[(minIndex + 1) % 2] % pops[minIndex]

        // スタックからpopした2つの数に剰余があるならば、それをpush
        if (0 < r) {
            stack.push(r)
        }
    }

    // 最大公約数を返す
    return stack.pop()
}

/**
 * 最小公倍数を導出する
 * @param list 最小公倍数を求める対象となる数が格納されたリスト
 * @return 最小公倍数
 */
fun lcm(list: List<Int>): Int {
    // 最大公約数を求める対象となる数が格納されたスタック
    val stack = listToStack(list)

    // 最小公倍数を導出する
    // (最終的にスタック内に1つだけ数が残り、それが最小公倍数となる)
    while (1 < stack.size) {
        // スタックから2つの数をpop
        val pops = (0 until 2).map {
            stack.pop()
        }

        // スタックからpopした2つの数の最小公倍数をpush
        stack.push(pops[0] * pops[1] / gcd(pops))
    }

    // 最小公倍数を返す
    return stack.pop()
}

Compiled from "lib.kt"
public final class lib.LibKt {
  public static final java.util.List<java.lang.Long> divisor(long);
    Code:
       0: lload_0
       1: l2d
       2: invokestatic  #14                 // Method java/lang/Math.sqrt:(D)D
       5: d2l
       6: lstore_2
       7: new           #16                 // class kotlin/ranges/LongRange
      10: dup
      11: lconst_1
      12: lload_2
      13: invokespecial #20                 // Method kotlin/ranges/LongRange."<init>":(JJ)V
      16: checkcast     #22                 // class java/lang/Iterable
      19: astore        4
      21: nop
      22: iconst_0
      23: istore        5
      25: aload         4
      27: astore        6
      29: new           #24                 // class java/util/ArrayList
      32: dup
      33: invokespecial #27                 // Method java/util/ArrayList."<init>":()V
      36: checkcast     #29                 // class java/util/Collection
      39: astore        7
      41: iconst_0
      42: istore        8
      44: aload         6
      46: invokeinterface #33,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      51: astore        9
      53: aload         9
      55: invokeinterface #39,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      60: ifeq          115
      63: aload         9
      65: invokeinterface #43,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      70: astore        10
      72: aload         10
      74: checkcast     #45                 // class java/lang/Number
      77: invokevirtual #49                 // Method java/lang/Number.longValue:()J
      80: lstore        11
      82: iconst_0
      83: istore        13
      85: lload_0
      86: lload         11
      88: lrem
      89: lconst_0
      90: lcmp
      91: ifne          98
      94: iconst_1
      95: goto          99
      98: iconst_0
      99: ifeq          53
     102: aload         7
     104: aload         10
     106: invokeinterface #53,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     111: pop
     112: goto          53
     115: aload         7
     117: checkcast     #55                 // class java/util/List
     120: nop
     121: checkcast     #22                 // class java/lang/Iterable
     124: astore        4
     126: nop
     127: iconst_0
     128: istore        5
     130: aload         4
     132: astore        6
     134: new           #24                 // class java/util/ArrayList
     137: dup
     138: aload         4
     140: bipush        10
     142: invokestatic  #61                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     145: invokespecial #64                 // Method java/util/ArrayList."<init>":(I)V
     148: checkcast     #29                 // class java/util/Collection
     151: astore        7
     153: iconst_0
     154: istore        8
     156: aload         6
     158: invokeinterface #33,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     163: astore        9
     165: aload         9
     167: invokeinterface #39,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     172: ifeq          244
     175: aload         9
     177: invokeinterface #43,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     182: astore        10
     184: aload         7
     186: aload         10
     188: checkcast     #45                 // class java/lang/Number
     191: invokevirtual #49                 // Method java/lang/Number.longValue:()J
     194: lstore        11
     196: astore        15
     198: iconst_0
     199: istore        13
     201: iconst_2
     202: anewarray     #66                 // class java/lang/Long
     205: astore        14
     207: aload         14
     209: iconst_0
     210: lload         11
     212: invokestatic  #70                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     215: aastore
     216: aload         14
     218: iconst_1
     219: lload_0
     220: lload         11
     222: ldiv
     223: invokestatic  #70                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     226: aastore
     227: aload         14
     229: invokestatic  #74                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     232: aload         15
     234: swap
     235: invokeinterface #53,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     240: pop
     241: goto          165
     244: aload         7
     246: checkcast     #55                 // class java/util/List
     249: nop
     250: checkcast     #22                 // class java/lang/Iterable
     253: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     256: checkcast     #22                 // class java/lang/Iterable
     259: invokestatic  #81                 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
     262: areturn

  public static final java.util.List<java.lang.Long> prime(long, long);
    Code:
       0: new           #16                 // class kotlin/ranges/LongRange
       3: dup
       4: lload_0
       5: lload_2
       6: invokespecial #20                 // Method kotlin/ranges/LongRange."<init>":(JJ)V
       9: checkcast     #22                 // class java/lang/Iterable
      12: astore        4
      14: iconst_0
      15: istore        5
      17: aload         4
      19: astore        6
      21: new           #24                 // class java/util/ArrayList
      24: dup
      25: invokespecial #27                 // Method java/util/ArrayList."<init>":()V
      28: checkcast     #29                 // class java/util/Collection
      31: astore        7
      33: iconst_0
      34: istore        8
      36: aload         6
      38: invokeinterface #33,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      43: astore        9
      45: aload         9
      47: invokeinterface #39,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      52: ifeq          206
      55: aload         9
      57: invokeinterface #43,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      62: astore        10
      64: aload         10
      66: checkcast     #45                 // class java/lang/Number
      69: invokevirtual #49                 // Method java/lang/Number.longValue:()J
      72: lstore        11
      74: iconst_0
      75: istore        13
      77: lload         11
      79: l2d
      80: invokestatic  #14                 // Method java/lang/Math.sqrt:(D)D
      83: d2l
      84: lstore        14
      86: new           #16                 // class kotlin/ranges/LongRange
      89: dup
      90: iconst_2
      91: i2l
      92: lload         14
      94: invokespecial #20                 // Method kotlin/ranges/LongRange."<init>":(JJ)V
      97: checkcast     #22                 // class java/lang/Iterable
     100: astore        16
     102: iconst_0
     103: istore        17
     105: aload         16
     107: instanceof    #29                 // class java/util/Collection
     110: ifeq          130
     113: aload         16
     115: checkcast     #29                 // class java/util/Collection
     118: invokeinterface #108,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     123: ifeq          130
     126: iconst_1
     127: goto          189
     130: aload         16
     132: invokeinterface #33,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     137: astore        18
     139: aload         18
     141: invokeinterface #39,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     146: ifeq          188
     149: aload         18
     151: checkcast     #110                // class kotlin/collections/LongIterator
     154: invokevirtual #113                // Method kotlin/collections/LongIterator.nextLong:()J
     157: lstore        19
     159: lload         19
     161: lstore        21
     163: iconst_0
     164: istore        23
     166: lload         11
     168: lload         21
     170: lrem
     171: lconst_0
     172: lcmp
     173: ifeq          180
     176: iconst_1
     177: goto          181
     180: iconst_0
     181: ifne          139
     184: iconst_0
     185: goto          189
     188: iconst_1
     189: nop
     190: ifeq          45
     193: aload         7
     195: aload         10
     197: invokeinterface #53,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     202: pop
     203: goto          45
     206: aload         7
     208: checkcast     #55                 // class java/util/List
     211: nop
     212: areturn

  public static java.util.List prime$default(long, long, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_2
       3: iand
       4: ifeq          9
       7: lload_0
       8: lstore_2
       9: lload_0
      10: lload_2
      11: invokestatic  #126                // Method prime:(JJ)Ljava/util/List;
      14: areturn

  public static final boolean isPrime(int);
    Code:
       0: iload_0
       1: i2l
       2: lconst_0
       3: iconst_2
       4: aconst_null
       5: invokestatic  #130                // Method prime$default:(JJILjava/lang/Object;)Ljava/util/List;
       8: checkcast     #22                 // class java/lang/Iterable
      11: invokestatic  #134                // Method kotlin/collections/CollectionsKt.any:(Ljava/lang/Iterable;)Z
      14: ireturn

  public static final java.util.List<java.lang.Long> decom(long);
    Code:
       0: lload_0
       1: lconst_1
       2: lcmp
       3: ifne          14
       6: lconst_1
       7: invokestatic  #70                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      10: invokestatic  #139                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      13: areturn
      14: lload_0
      15: l2d
      16: invokestatic  #14                 // Method java/lang/Math.sqrt:(D)D
      19: d2l
      20: lstore_2
      21: ldc2_w        #140                // long 2l
      24: lload_2
      25: invokestatic  #126                // Method prime:(JJ)Ljava/util/List;
      28: checkcast     #22                 // class java/lang/Iterable
      31: astore        4
      33: iconst_0
      34: istore        5
      36: aload         4
      38: astore        6
      40: new           #24                 // class java/util/ArrayList
      43: dup
      44: invokespecial #27                 // Method java/util/ArrayList."<init>":()V
      47: checkcast     #29                 // class java/util/Collection
      50: astore        7
      52: iconst_0
      53: istore        8
      55: aload         6
      57: invokeinterface #33,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      62: astore        9
      64: aload         9
      66: invokeinterface #39,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      71: ifeq          126
      74: aload         9
      76: invokeinterface #43,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      81: astore        10
      83: aload         10
      85: checkcast     #45                 // class java/lang/Number
      88: invokevirtual #49                 // Method java/lang/Number.longValue:()J
      91: lstore        11
      93: iconst_0
      94: istore        13
      96: lload_0
      97: lload         11
      99: lrem
     100: lconst_0
     101: lcmp
     102: ifne          109
     105: iconst_1
     106: goto          110
     109: iconst_0
     110: ifeq          64
     113: aload         7
     115: aload         10
     117: invokeinterface #53,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     122: pop
     123: goto          64
     126: aload         7
     128: checkcast     #55                 // class java/util/List
     131: nop
     132: areturn

  public static final long gcd(long, long);
    Code:
       0: lload_0
       1: lload_2
       2: lrem
       3: lconst_0
       4: lcmp
       5: ifne          12
       8: lload_2
       9: goto          19
      12: lload_2
      13: lload_0
      14: lload_2
      15: lrem
      16: invokestatic  #146                // Method gcd:(JJ)J
      19: lreturn

  public static final java.lang.String swap(java.lang.String, java.lang.String, java.lang.String);
    Code:
       0: aload_0
       1: ldc           #152                // String base
       3: invokestatic  #158                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #159                // String a
       9: invokestatic  #158                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_2
      13: ldc           #160                // String b
      15: invokestatic  #158                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: aload_0
      19: checkcast     #162                // class java/lang/CharSequence
      22: astore_3
      23: iconst_0
      24: istore        4
      26: aload_3
      27: astore        5
      29: new           #24                 // class java/util/ArrayList
      32: dup
      33: aload_3
      34: invokeinterface #166,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      39: invokespecial #64                 // Method java/util/ArrayList."<init>":(I)V
      42: checkcast     #29                 // class java/util/Collection
      45: astore        6
      47: iconst_0
      48: istore        7
      50: iconst_0
      51: istore        8
      53: iload         8
      55: aload         5
      57: invokeinterface #166,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      62: if_icmpge     154
      65: aload         5
      67: iload         8
      69: invokeinterface #170,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
      74: istore        9
      76: aload         6
      78: iload         9
      80: istore        10
      82: astore        13
      84: iconst_0
      85: istore        11
      87: iload         10
      89: istore        12
      91: iload         12
      93: aload_1
      94: invokevirtual #176                // Method java/lang/String.toCharArray:()[C
      97: dup
      98: ldc           #178                // String toCharArray(...)
     100: invokestatic  #181                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     103: iconst_0
     104: caload
     105: if_icmpne     112
     108: aload_2
     109: goto          138
     112: iload         12
     114: aload_2
     115: invokevirtual #176                // Method java/lang/String.toCharArray:()[C
     118: dup
     119: ldc           #178                // String toCharArray(...)
     121: invokestatic  #181                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     124: iconst_0
     125: caload
     126: if_icmpne     133
     129: aload_1
     130: goto          138
     133: iload         10
     135: invokestatic  #184                // Method java/lang/String.valueOf:(C)Ljava/lang/String;
     138: nop
     139: aload         13
     141: swap
     142: invokeinterface #53,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     147: pop
     148: iinc          8, 1
     151: goto          53
     154: aload         6
     156: checkcast     #55                 // class java/util/List
     159: nop
     160: checkcast     #22                 // class java/lang/Iterable
     163: aconst_null
     164: aconst_null
     165: aconst_null
     166: iconst_0
     167: aconst_null
     168: aconst_null
     169: bipush        63
     171: aconst_null
     172: invokestatic  #188                // 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;
     175: areturn

  public static final java.util.Stack<java.lang.Integer> listToStack(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #197                // String list
       3: invokestatic  #158                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #199                // class java/util/Stack
       9: dup
      10: invokespecial #200                // Method java/util/Stack."<init>":()V
      13: astore_1
      14: aload_0
      15: invokeinterface #201,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      20: astore_2
      21: aload_2
      22: invokeinterface #39,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      27: ifeq          55
      30: aload_2
      31: invokeinterface #43,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      36: checkcast     #45                 // class java/lang/Number
      39: invokevirtual #204                // Method java/lang/Number.intValue:()I
      42: istore_3
      43: aload_1
      44: iload_3
      45: invokestatic  #209                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      48: invokevirtual #213                // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;
      51: pop
      52: goto          21
      55: aload_1
      56: areturn

  public static final int gcd(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #197                // String list
       3: invokestatic  #158                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #221                // Method listToStack:(Ljava/util/List;)Ljava/util/Stack;
      10: astore_1
      11: iconst_1
      12: aload_1
      13: invokevirtual #224                // Method java/util/Stack.size:()I
      16: if_icmpge     226
      19: iconst_0
      20: iconst_2
      21: invokestatic  #230                // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      24: checkcast     #22                 // class java/lang/Iterable
      27: astore_3
      28: iconst_0
      29: istore        4
      31: aload_3
      32: astore        5
      34: new           #24                 // class java/util/ArrayList
      37: dup
      38: aload_3
      39: bipush        10
      41: invokestatic  #61                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      44: invokespecial #64                 // Method java/util/ArrayList."<init>":(I)V
      47: checkcast     #29                 // class java/util/Collection
      50: astore        6
      52: iconst_0
      53: istore        7
      55: aload         5
      57: invokeinterface #33,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      62: astore        8
      64: aload         8
      66: invokeinterface #39,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      71: ifeq          114
      74: aload         8
      76: checkcast     #232                // class kotlin/collections/IntIterator
      79: invokevirtual #235                // Method kotlin/collections/IntIterator.nextInt:()I
      82: istore        9
      84: aload         6
      86: iload         9
      88: istore        10
      90: astore        12
      92: iconst_0
      93: istore        11
      95: aload_1
      96: invokevirtual #238                // Method java/util/Stack.pop:()Ljava/lang/Object;
      99: checkcast     #206                // class java/lang/Integer
     102: aload         12
     104: swap
     105: invokeinterface #53,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     110: pop
     111: goto          64
     114: aload         6
     116: checkcast     #55                 // class java/util/List
     119: nop
     120: astore_2
     121: aload_2
     122: iconst_1
     123: invokeinterface #242,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     128: checkcast     #45                 // class java/lang/Number
     131: invokevirtual #204                // Method java/lang/Number.intValue:()I
     134: aload_2
     135: iconst_0
     136: invokeinterface #242,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     141: checkcast     #45                 // class java/lang/Number
     144: invokevirtual #204                // Method java/lang/Number.intValue:()I
     147: if_icmpge     154
     150: iconst_1
     151: goto          155
     154: iconst_0
     155: istore_3
     156: aload_1
     157: aload_2
     158: iload_3
     159: invokeinterface #242,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     164: invokevirtual #213                // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;
     167: pop
     168: aload_2
     169: iload_3
     170: iconst_1
     171: iadd
     172: iconst_2
     173: irem
     174: invokeinterface #242,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     179: checkcast     #45                 // class java/lang/Number
     182: invokevirtual #204                // Method java/lang/Number.intValue:()I
     185: aload_2
     186: iload_3
     187: invokeinterface #242,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     192: dup
     193: ldc           #244                // String get(...)
     195: invokestatic  #181                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     198: checkcast     #45                 // class java/lang/Number
     201: invokevirtual #204                // Method java/lang/Number.intValue:()I
     204: irem
     205: istore        4
     207: iconst_0
     208: iload         4
     210: if_icmpge     11
     213: aload_1
     214: iload         4
     216: invokestatic  #209                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     219: invokevirtual #213                // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;
     222: pop
     223: goto          11
     226: aload_1
     227: invokevirtual #238                // Method java/util/Stack.pop:()Ljava/lang/Object;
     230: dup
     231: ldc           #246                // String pop(...)
     233: invokestatic  #181                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     236: checkcast     #45                 // class java/lang/Number
     239: invokevirtual #204                // Method java/lang/Number.intValue:()I
     242: ireturn

  public static final int lcm(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #197                // String list
       3: invokestatic  #158                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #221                // Method listToStack:(Ljava/util/List;)Ljava/util/Stack;
      10: astore_1
      11: iconst_1
      12: aload_1
      13: invokevirtual #224                // Method java/util/Stack.size:()I
      16: if_icmpge     170
      19: iconst_0
      20: iconst_2
      21: invokestatic  #230                // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      24: checkcast     #22                 // class java/lang/Iterable
      27: astore_3
      28: iconst_0
      29: istore        4
      31: aload_3
      32: astore        5
      34: new           #24                 // class java/util/ArrayList
      37: dup
      38: aload_3
      39: bipush        10
      41: invokestatic  #61                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      44: invokespecial #64                 // Method java/util/ArrayList."<init>":(I)V
      47: checkcast     #29                 // class java/util/Collection
      50: astore        6
      52: iconst_0
      53: istore        7
      55: aload         5
      57: invokeinterface #33,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      62: astore        8
      64: aload         8
      66: invokeinterface #39,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      71: ifeq          114
      74: aload         8
      76: checkcast     #232                // class kotlin/collections/IntIterator
      79: invokevirtual #235                // Method kotlin/collections/IntIterator.nextInt:()I
      82: istore        9
      84: aload         6
      86: iload         9
      88: istore        10
      90: astore        12
      92: iconst_0
      93: istore        11
      95: aload_1
      96: invokevirtual #238                // Method java/util/Stack.pop:()Ljava/lang/Object;
      99: checkcast     #206                // class java/lang/Integer
     102: aload         12
     104: swap
     105: invokeinterface #53,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     110: pop
     111: goto          64
     114: aload         6
     116: checkcast     #55                 // class java/util/List
     119: nop
     120: astore_2
     121: aload_1
     122: aload_2
     123: iconst_0
     124: invokeinterface #242,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     129: checkcast     #45                 // class java/lang/Number
     132: invokevirtual #204                // Method java/lang/Number.intValue:()I
     135: aload_2
     136: iconst_1
     137: invokeinterface #242,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     142: dup
     143: ldc           #244                // String get(...)
     145: invokestatic  #181                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     148: checkcast     #45                 // class java/lang/Number
     151: invokevirtual #204                // Method java/lang/Number.intValue:()I
     154: imul
     155: aload_2
     156: invokestatic  #253                // Method gcd:(Ljava/util/List;)I
     159: idiv
     160: invokestatic  #209                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     163: invokevirtual #213                // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;
     166: pop
     167: goto          11
     170: aload_1
     171: invokevirtual #238                // Method java/util/Stack.pop:()Ljava/lang/Object;
     174: dup
     175: ldc           #246                // String pop(...)
     177: invokestatic  #181                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     180: checkcast     #45                 // class java/lang/Number
     183: invokevirtual #204                // Method java/lang/Number.intValue:()I
     186: ireturn
}


package org.sollecitom.chassis.logger.core.implementation.datastructure

internal interface Trie {

    /**
     * Returns the word in the trie with the longest prefix in common to the given word.
     */
    fun searchLongestPrefixWord(word: String): String

    /**
     * Returns the longest prefix in the trie common to the word.
     */
    fun searchLongestPrefix(word: String): String

    /**
     * Returns if the word is in the trie.
     */
    fun search(word: String): Boolean

    /**
     * Returns if there is any word in the trie that starts with the given prefix.
     */
    fun searchWithPrefix(prefix: String): Boolean

    interface Mutable : Trie {

        /**
         * Inserts a word into the trie.
         */
        fun insert(word: String)
    }
}

internal fun trieOf(vararg words: String): Trie = TrieNodeTree().apply { words.forEach { insert(it) } }

internal fun mutableTrieOf(vararg words: String): Trie.Mutable = TrieNodeTree().apply { words.forEach { insert(it) } }
internal fun mutableTrieOf(words: Iterable<String>): Trie.Mutable = TrieNodeTree().apply { words.forEach { insert(it) } }

private class TrieNodeTree : Trie.Mutable {

    private val root: TrieNode = TrieNode()

    override fun insert(word: String) {

        var node: TrieNode = root
        for (element in word) {
            if (!node.containsKey(element)) {
                node.put(element, TrieNode())
            }
            node = node[element]!!
        }
        node.setEnd()
    }

    override fun searchLongestPrefixWord(word: String): String {

        var node = root
        val prefixes = mutableListOf<String>()
        val currentPrefix = StringBuilder()
        for (element in word) {
            if (node.containsKey(element)) {
                if (node.isEnd) {
                    prefixes += currentPrefix.toString()
                }
                currentPrefix.append(element)
                node = node[element]!!
            } else {
                if (node.isEnd) {
                    prefixes += currentPrefix.toString()
                }
                return prefixes.maxByOrNull(String::length) ?: ""
            }
        }
        return ""
    }

    override fun searchLongestPrefix(word: String): String {

        var node = root
        val currentPrefix = StringBuilder()
        for (element in word) {
            if (node.containsKey(element) && node.links.size == 1) {
                currentPrefix.append(element)
                node = node[element]!!
            } else {
                return currentPrefix.toString()
            }
        }
        return ""
    }

    override fun search(word: String): Boolean {
        val node = searchPrefix(word)
        return node != null && node.isEnd
    }

    override fun searchWithPrefix(prefix: String): Boolean {
        val node = searchPrefix(prefix)
        return node != null
    }

    private fun searchPrefix(word: String): TrieNode? {
        var node: TrieNode? = root
        for (element in word) {
            node = if (node!!.containsKey(element)) {
                node[element]
            } else {
                return null
            }
        }
        return node
    }
}

private class TrieNode private constructor(val links: MutableMap<Char, TrieNode> = mutableMapOf(), isEnd: Boolean = false) {

    constructor() : this(mutableMapOf(), false)

    var isEnd = isEnd
        private set

    fun containsKey(ch: Char): Boolean = links[ch] != null

    operator fun get(ch: Char): TrieNode? = links[ch]

    fun put(ch: Char, node: TrieNode) {
        links[ch] = node
    }

    fun setEnd() {
        isEnd = true
    }

    fun clone(): TrieNode = TrieNode(links.mapValues { it.value.clone() }.toMutableMap(), isEnd)
}

Compiled from "Trie.kt"
public interface org.sollecitom.chassis.logger.core.implementation.datastructure.Trie$Mutable extends org.sollecitom.chassis.logger.core.implementation.datastructure.Trie {
  public abstract void insert(java.lang.String);
}

Compiled from "Trie.kt"
public interface org.sollecitom.chassis.logger.core.implementation.datastructure.Trie {
  public abstract java.lang.String searchLongestPrefixWord(java.lang.String);

  public abstract java.lang.String searchLongestPrefix(java.lang.String);

  public abstract boolean search(java.lang.String);

  public abstract boolean searchWithPrefix(java.lang.String);
}

Compiled from "Trie.kt"
public final class org.sollecitom.chassis.logger.core.implementation.datastructure.TrieKt {
  public static final org.sollecitom.chassis.logger.core.implementation.datastructure.Trie trieOf(java.lang.String...);
    Code:
       0: aload_0
       1: ldc           #9                  // String words
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #17                 // class org/sollecitom/chassis/logger/core/implementation/datastructure/TrieNodeTree
       9: dup
      10: invokespecial #21                 // Method org/sollecitom/chassis/logger/core/implementation/datastructure/TrieNodeTree."<init>":()V
      13: astore_1
      14: aload_1
      15: astore_2
      16: iconst_0
      17: istore_3
      18: aload_0
      19: astore        4
      21: iconst_0
      22: istore        5
      24: iconst_0
      25: istore        6
      27: aload         4
      29: arraylength
      30: istore        7
      32: iload         6
      34: iload         7
      36: if_icmpge     66
      39: aload         4
      41: iload         6
      43: aaload
      44: astore        8
      46: aload         8
      48: astore        9
      50: iconst_0
      51: istore        10
      53: aload_2
      54: aload         9
      56: invokevirtual #25                 // Method org/sollecitom/chassis/logger/core/implementation/datastructure/TrieNodeTree.insert:(Ljava/lang/String;)V
      59: nop
      60: iinc          6, 1
      63: goto          32
      66: nop
      67: nop
      68: aload_1
      69: checkcast     #27                 // class org/sollecitom/chassis/logger/core/implementation/datastructure/Trie
      72: areturn

  public static final org.sollecitom.chassis.logger.core.implementation.datastructure.Trie$Mutable mutableTrieOf(java.lang.String...);
    Code:
       0: aload_0
       1: ldc           #9                  // String words
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #17                 // class org/sollecitom/chassis/logger/core/implementation/datastructure/TrieNodeTree
       9: dup
      10: invokespecial #21                 // Method org/sollecitom/chassis/logger/core/implementation/datastructure/TrieNodeTree."<init>":()V
      13: astore_1
      14: aload_1
      15: astore_2
      16: iconst_0
      17: istore_3
      18: aload_0
      19: astore        4
      21: iconst_0
      22: istore        5
      24: iconst_0
      25: istore        6
      27: aload         4
      29: arraylength
      30: istore        7
      32: iload         6
      34: iload         7
      36: if_icmpge     66
      39: aload         4
      41: iload         6
      43: aaload
      44: astore        8
      46: aload         8
      48: astore        9
      50: iconst_0
      51: istore        10
      53: aload_2
      54: aload         9
      56: invokevirtual #25                 // Method org/sollecitom/chassis/logger/core/implementation/datastructure/TrieNodeTree.insert:(Ljava/lang/String;)V
      59: nop
      60: iinc          6, 1
      63: goto          32
      66: nop
      67: nop
      68: aload_1
      69: checkcast     #45                 // class org/sollecitom/chassis/logger/core/implementation/datastructure/Trie$Mutable
      72: areturn

  public static final org.sollecitom.chassis.logger.core.implementation.datastructure.Trie$Mutable mutableTrieOf(java.lang.Iterable<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #9                  // String words
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #17                 // class org/sollecitom/chassis/logger/core/implementation/datastructure/TrieNodeTree
       9: dup
      10: invokespecial #21                 // Method org/sollecitom/chassis/logger/core/implementation/datastructure/TrieNodeTree."<init>":()V
      13: astore_1
      14: aload_1
      15: astore_2
      16: iconst_0
      17: istore_3
      18: aload_0
      19: astore        4
      21: iconst_0
      22: istore        5
      24: aload         4
      26: invokeinterface #56,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      31: astore        6
      33: aload         6
      35: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      40: ifeq          72
      43: aload         6
      45: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      50: astore        7
      52: aload         7
      54: checkcast     #68                 // class java/lang/String
      57: astore        8
      59: iconst_0
      60: istore        9
      62: aload_2
      63: aload         8
      65: invokevirtual #25                 // Method org/sollecitom/chassis/logger/core/implementation/datastructure/TrieNodeTree.insert:(Ljava/lang/String;)V
      68: nop
      69: goto          33
      72: nop
      73: nop
      74: aload_1
      75: checkcast     #45                 // class org/sollecitom/chassis/logger/core/implementation/datastructure/Trie$Mutable
      78: areturn
}


package day07

import java.io.File
import kotlin.math.abs
import kotlin.math.min

fun main() {
    println("Answer 1: " + minimumFuel(::constantCost))
    println("Answer 2: " + minimumFuel(::increasingCost))
}

fun minimumFuel(cost: (positions: List<Int>, position: Int) -> Int): Int {
    val positions = File("src/main/kotlin/day07/day07-input.txt").readText().split(",").map { it.toInt() }

    val min = positions.minOrNull()!!
    val max = positions.maxOrNull()!!

    return (min..max).fold(Int.MAX_VALUE) { minimum, position ->
        min(cost(positions, position), minimum)
    }
}

fun constantCost(positions: List<Int>, position: Int): Int =
    positions.sumOf { abs(it - position) }

fun increasingCost(positions: List<Int>, position: Int): Int =
    positions.sumOf {
        val distance = abs(it - position)
        (distance * (distance + 1)) shr 1  // sum of integers 1..N = N * (N - 1) / 2
    }

Compiled from "Day07.kt"
public final class day07.Day07Kt {
  public static final void main();
    Code:
       0: new           #8                  // class java/lang/StringBuilder
       3: dup
       4: invokespecial #11                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #13                 // String Answer 1:
       9: invokevirtual #17                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: getstatic     #23                 // Field day07/Day07Kt$main$1.INSTANCE:Lday07/Day07Kt$main$1;
      15: checkcast     #25                 // class kotlin/jvm/functions/Function2
      18: invokestatic  #29                 // Method minimumFuel:(Lkotlin/jvm/functions/Function2;)I
      21: invokevirtual #32                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      24: invokevirtual #36                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      27: getstatic     #42                 // Field java/lang/System.out:Ljava/io/PrintStream;
      30: swap
      31: invokevirtual #48                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      34: new           #8                  // class java/lang/StringBuilder
      37: dup
      38: invokespecial #11                 // Method java/lang/StringBuilder."<init>":()V
      41: ldc           #50                 // String Answer 2:
      43: invokevirtual #17                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      46: getstatic     #55                 // Field day07/Day07Kt$main$2.INSTANCE:Lday07/Day07Kt$main$2;
      49: checkcast     #25                 // class kotlin/jvm/functions/Function2
      52: invokestatic  #29                 // Method minimumFuel:(Lkotlin/jvm/functions/Function2;)I
      55: invokevirtual #32                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      58: invokevirtual #36                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      61: getstatic     #42                 // Field java/lang/System.out:Ljava/io/PrintStream;
      64: swap
      65: invokevirtual #48                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      68: return

  public static final int minimumFuel(kotlin.jvm.functions.Function2<? super java.util.List<java.lang.Integer>, ? super java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #59                 // String cost
       3: invokestatic  #65                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #67                 // class java/io/File
       9: dup
      10: ldc           #69                 // String src/main/kotlin/day07/day07-input.txt
      12: invokespecial #72                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      15: aconst_null
      16: iconst_1
      17: aconst_null
      18: invokestatic  #78                 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
      21: checkcast     #80                 // class java/lang/CharSequence
      24: iconst_1
      25: anewarray     #82                 // class java/lang/String
      28: astore_2
      29: aload_2
      30: iconst_0
      31: ldc           #84                 // String ,
      33: aastore
      34: aload_2
      35: iconst_0
      36: iconst_0
      37: bipush        6
      39: aconst_null
      40: invokestatic  #90                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      43: checkcast     #92                 // class java/lang/Iterable
      46: astore_2
      47: iconst_0
      48: istore_3
      49: aload_2
      50: astore        4
      52: new           #94                 // class java/util/ArrayList
      55: dup
      56: aload_2
      57: bipush        10
      59: invokestatic  #100                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      62: invokespecial #103                // Method java/util/ArrayList."<init>":(I)V
      65: checkcast     #105                // class java/util/Collection
      68: astore        5
      70: iconst_0
      71: istore        6
      73: aload         4
      75: invokeinterface #109,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      80: astore        7
      82: aload         7
      84: invokeinterface #115,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      89: ifeq          136
      92: aload         7
      94: invokeinterface #119,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      99: astore        8
     101: aload         5
     103: aload         8
     105: checkcast     #82                 // class java/lang/String
     108: astore        9
     110: astore        13
     112: iconst_0
     113: istore        10
     115: aload         9
     117: invokestatic  #125                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     120: nop
     121: invokestatic  #129                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     124: aload         13
     126: swap
     127: invokeinterface #133,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     132: pop
     133: goto          82
     136: aload         5
     138: checkcast     #135                // class java/util/List
     141: nop
     142: astore_1
     143: aload_1
     144: checkcast     #92                 // class java/lang/Iterable
     147: invokestatic  #139                // Method kotlin/collections/CollectionsKt.minOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     150: dup
     151: invokestatic  #142                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     154: checkcast     #144                // class java/lang/Number
     157: invokevirtual #148                // Method java/lang/Number.intValue:()I
     160: istore_2
     161: aload_1
     162: checkcast     #92                 // class java/lang/Iterable
     165: invokestatic  #151                // Method kotlin/collections/CollectionsKt.maxOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     168: dup
     169: invokestatic  #142                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     172: checkcast     #144                // class java/lang/Number
     175: invokevirtual #148                // Method java/lang/Number.intValue:()I
     178: istore_3
     179: new           #153                // class kotlin/ranges/IntRange
     182: dup
     183: iload_2
     184: iload_3
     185: invokespecial #156                // Method kotlin/ranges/IntRange."<init>":(II)V
     188: checkcast     #92                 // class java/lang/Iterable
     191: astore        4
     193: ldc           #157                // int 2147483647
     195: istore        5
     197: iconst_0
     198: istore        6
     200: iload         5
     202: istore        7
     204: aload         4
     206: invokeinterface #109,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     211: astore        8
     213: aload         8
     215: invokeinterface #115,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     220: ifeq          273
     223: aload         8
     225: checkcast     #159                // class kotlin/collections/IntIterator
     228: invokevirtual #162                // Method kotlin/collections/IntIterator.nextInt:()I
     231: istore        9
     233: iload         7
     235: iload         9
     237: istore        10
     239: istore        11
     241: iconst_0
     242: istore        12
     244: aload_0
     245: aload_1
     246: iload         10
     248: invokestatic  #129                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     251: invokeinterface #166,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     256: checkcast     #144                // class java/lang/Number
     259: invokevirtual #148                // Method java/lang/Number.intValue:()I
     262: iload         11
     264: invokestatic  #172                // Method java/lang/Math.min:(II)I
     267: nop
     268: istore        7
     270: goto          213
     273: iload         7
     275: ireturn

  public static final int constantCost(java.util.List<java.lang.Integer>, int);
    Code:
       0: aload_0
       1: ldc           #201                // String positions
       3: invokestatic  #65                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #92                 // class java/lang/Iterable
      10: astore_2
      11: iconst_0
      12: istore_3
      13: aload_2
      14: invokeinterface #109,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      19: astore        4
      21: aload         4
      23: invokeinterface #115,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      28: ifeq          75
      31: aload         4
      33: invokeinterface #119,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      38: astore        5
      40: iload_3
      41: aload         5
      43: checkcast     #144                // class java/lang/Number
      46: invokevirtual #148                // Method java/lang/Number.intValue:()I
      49: istore        6
      51: istore        8
      53: iconst_0
      54: istore        7
      56: iload         6
      58: iload_1
      59: isub
      60: invokestatic  #205                // Method java/lang/Math.abs:(I)I
      63: nop
      64: istore        9
      66: iload         8
      68: iload         9
      70: iadd
      71: istore_3
      72: goto          21
      75: iload_3
      76: ireturn

  public static final int increasingCost(java.util.List<java.lang.Integer>, int);
    Code:
       0: aload_0
       1: ldc           #201                // String positions
       3: invokestatic  #65                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #92                 // class java/lang/Iterable
      10: astore_2
      11: iconst_0
      12: istore_3
      13: aload_2
      14: invokeinterface #109,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      19: astore        4
      21: aload         4
      23: invokeinterface #115,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      28: ifeq          85
      31: aload         4
      33: invokeinterface #119,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      38: astore        5
      40: iload_3
      41: aload         5
      43: checkcast     #144                // class java/lang/Number
      46: invokevirtual #148                // Method java/lang/Number.intValue:()I
      49: istore        6
      51: istore        9
      53: iconst_0
      54: istore        7
      56: iload         6
      58: iload_1
      59: isub
      60: invokestatic  #205                // Method java/lang/Math.abs:(I)I
      63: istore        8
      65: iload         8
      67: iload         8
      69: iconst_1
      70: iadd
      71: imul
      72: iconst_1
      73: ishr
      74: istore        10
      76: iload         9
      78: iload         10
      80: iadd
      81: istore_3
      82: goto          21
      85: iload_3
      86: ireturn

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

Compiled from "Day07.kt"
final class day07.Day07Kt$main$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<java.util.List<? extends java.lang.Integer>, java.lang.Integer, java.lang.Integer> {
  public static final day07.Day07Kt$main$1 INSTANCE;

  day07.Day07Kt$main$1();
    Code:
       0: aload_0
       1: iconst_2
       2: ldc           #11                 // class day07/Day07Kt
       4: ldc           #13                 // String constantCost
       6: ldc           #15                 // String constantCost(Ljava/util/List;I)I
       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.Integer invoke(java.util.List<java.lang.Integer>, int);
    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_1
       7: iload_2
       8: invokestatic  #34                 // Method day07/Day07Kt.constantCost:(Ljava/util/List;I)I
      11: invokestatic  #40                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      14: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #46                 // class java/util/List
       5: aload_2
       6: checkcast     #48                 // class java/lang/Number
       9: invokevirtual #52                 // Method java/lang/Number.intValue:()I
      12: invokevirtual #54                 // Method invoke:(Ljava/util/List;I)Ljava/lang/Integer;
      15: areturn

  static {};
    Code:
       0: new           #2                  // class day07/Day07Kt$main$1
       3: dup
       4: invokespecial #59                 // Method "<init>":()V
       7: putstatic     #62                 // Field INSTANCE:Lday07/Day07Kt$main$1;
      10: return
}

Compiled from "Day07.kt"
final class day07.Day07Kt$main$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<java.util.List<? extends java.lang.Integer>, java.lang.Integer, java.lang.Integer> {
  public static final day07.Day07Kt$main$2 INSTANCE;

  day07.Day07Kt$main$2();
    Code:
       0: aload_0
       1: iconst_2
       2: ldc           #11                 // class day07/Day07Kt
       4: ldc           #13                 // String increasingCost
       6: ldc           #15                 // String increasingCost(Ljava/util/List;I)I
       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.Integer invoke(java.util.List<java.lang.Integer>, int);
    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_1
       7: iload_2
       8: invokestatic  #34                 // Method day07/Day07Kt.increasingCost:(Ljava/util/List;I)I
      11: invokestatic  #40                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      14: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #46                 // class java/util/List
       5: aload_2
       6: checkcast     #48                 // class java/lang/Number
       9: invokevirtual #52                 // Method java/lang/Number.intValue:()I
      12: invokevirtual #54                 // Method invoke:(Ljava/util/List;I)Ljava/lang/Integer;
      15: areturn

  static {};
    Code:
       0: new           #2                  // class day07/Day07Kt$main$2
       3: dup
       4: invokespecial #59                 // Method "<init>":()V
       7: putstatic     #62                 // Field INSTANCE:Lday07/Day07Kt$main$2;
      10: return
}


package day04

import java.io.File

fun main() {
    val lines = File("src/main/kotlin/day04/day04-input.txt").readLines().toMutableList()

    val numbers = lines.removeAt(0).split(",").map { it.toInt() }
    val boards = mutableListOf<Board>()

    while (lines.isNotEmpty()) {
        boards.add(parseBoard(lines))
    }

    part1(numbers.toMutableList(), boards.toMutableList())
    part2(numbers.toMutableList(), boards.toMutableList())
}

fun parseBoard(lines: MutableList<String>): Board {
    lines.removeFirst() // empty line

    val numbers = mutableListOf<Int>()

    repeat(5) {
        val row = lines.removeFirst().split(" ").filter { it.isNotEmpty() }.map { it.toInt() }
        numbers += row
    }

    return Board(numbers)
}

fun part1(numbers: MutableList<Int>, boards: List<Board>) {
    var drawn: Int
    var winner: Board?

    do {
        drawn = numbers.removeFirst()
        boards.forEach { it.mark(drawn) }
        winner = boards.find { it.wins() }
    } while (winner == null)

    println(winner.score() * drawn)
}

fun part2(numbers: MutableList<Int>, boards: MutableList<Board>) {
    var drawn: Int
    var lastWinner: Board? = null

    do {
        drawn = numbers.removeFirst()
        boards.forEach { it.mark(drawn) }
        val winners = boards.filter { it.wins() }
        if (winners.isNotEmpty()) {
            boards.removeAll(winners)
            lastWinner = winners.first()
        }
    } while (boards.isNotEmpty())

    println(lastWinner!!.score() * drawn)
}

class Board(numbers: List<Int>) {

    private val numbers = numbers.map { BoardNumber(it) }

    fun mark(number: Int) {
        numbers.find { it.value == number }?.mark()
    }

    fun wins(): Boolean = hasWinningRow() || hasWinningColumn()

    private fun hasWinningRow(): Boolean =
        numbers.chunked(5).any { row -> row.all { it.marked } }

    private fun hasWinningColumn(): Boolean =
        (0..4).any { col ->
            (0..4).all { row ->
                numbers[col + (row * 5)].marked
            }
        }

    fun score(): Int =
        numbers.filter { !it.marked }.sumOf { it.value }
}

class BoardNumber(val value: Int) {
    var marked = false

    fun mark() {
        marked = true
    }
}

Compiled from "Day04.kt"
public final class day04.Day04Kt {
  public static final void main();
    Code:
       0: new           #8                  // class java/io/File
       3: dup
       4: ldc           #10                 // String src/main/kotlin/day04/day04-input.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/util/Collection
      18: invokestatic  #28                 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
      21: astore_0
      22: aload_0
      23: iconst_0
      24: invokeinterface #34,  2           // InterfaceMethod java/util/List.remove:(I)Ljava/lang/Object;
      29: checkcast     #36                 // class java/lang/CharSequence
      32: iconst_1
      33: anewarray     #38                 // class java/lang/String
      36: astore_2
      37: aload_2
      38: iconst_0
      39: ldc           #40                 // String ,
      41: aastore
      42: aload_2
      43: iconst_0
      44: iconst_0
      45: bipush        6
      47: aconst_null
      48: invokestatic  #46                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      51: checkcast     #48                 // class java/lang/Iterable
      54: astore_2
      55: iconst_0
      56: istore_3
      57: aload_2
      58: astore        4
      60: new           #50                 // class java/util/ArrayList
      63: dup
      64: aload_2
      65: bipush        10
      67: invokestatic  #54                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      70: invokespecial #57                 // Method java/util/ArrayList."<init>":(I)V
      73: checkcast     #22                 // class java/util/Collection
      76: astore        5
      78: iconst_0
      79: istore        6
      81: aload         4
      83: invokeinterface #61,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      88: astore        7
      90: aload         7
      92: invokeinterface #67,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      97: ifeq          144
     100: aload         7
     102: invokeinterface #71,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     107: astore        8
     109: aload         5
     111: aload         8
     113: checkcast     #38                 // class java/lang/String
     116: astore        9
     118: astore        11
     120: iconst_0
     121: istore        10
     123: aload         9
     125: invokestatic  #77                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     128: nop
     129: invokestatic  #81                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     132: aload         11
     134: swap
     135: invokeinterface #85,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     140: pop
     141: goto          90
     144: aload         5
     146: checkcast     #30                 // class java/util/List
     149: nop
     150: astore_1
     151: new           #50                 // class java/util/ArrayList
     154: dup
     155: invokespecial #87                 // Method java/util/ArrayList."<init>":()V
     158: checkcast     #30                 // class java/util/List
     161: astore_2
     162: aload_0
     163: checkcast     #22                 // class java/util/Collection
     166: invokeinterface #90,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     171: ifne          178
     174: iconst_1
     175: goto          179
     178: iconst_0
     179: ifeq          196
     182: aload_2
     183: aload_0
     184: invokestatic  #94                 // Method parseBoard:(Ljava/util/List;)Lday04/Board;
     187: invokeinterface #95,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     192: pop
     193: goto          162
     196: aload_1
     197: checkcast     #22                 // class java/util/Collection
     200: invokestatic  #28                 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     203: aload_2
     204: checkcast     #22                 // class java/util/Collection
     207: invokestatic  #28                 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     210: invokestatic  #99                 // Method part1:(Ljava/util/List;Ljava/util/List;)V
     213: aload_1
     214: checkcast     #22                 // class java/util/Collection
     217: invokestatic  #28                 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     220: aload_2
     221: checkcast     #22                 // class java/util/Collection
     224: invokestatic  #28                 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     227: invokestatic  #102                // Method part2:(Ljava/util/List;Ljava/util/List;)V
     230: return

  public static final day04.Board parseBoard(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #122                // String lines
       3: invokestatic  #128                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokeinterface #131,  1          // InterfaceMethod java/util/List.removeFirst:()Ljava/lang/Object;
      12: pop
      13: new           #50                 // class java/util/ArrayList
      16: dup
      17: invokespecial #87                 // Method java/util/ArrayList."<init>":()V
      20: checkcast     #30                 // class java/util/List
      23: astore_1
      24: iconst_5
      25: istore_2
      26: iconst_0
      27: istore_3
      28: iload_3
      29: iload_2
      30: if_icmpge     308
      33: iload_3
      34: istore        4
      36: iconst_0
      37: istore        5
      39: aload_0
      40: invokeinterface #131,  1          // InterfaceMethod java/util/List.removeFirst:()Ljava/lang/Object;
      45: dup
      46: ldc           #133                // String removeFirst(...)
      48: invokestatic  #136                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      51: checkcast     #36                 // class java/lang/CharSequence
      54: iconst_1
      55: anewarray     #38                 // class java/lang/String
      58: astore        6
      60: aload         6
      62: iconst_0
      63: ldc           #138                // String
      65: aastore
      66: aload         6
      68: iconst_0
      69: iconst_0
      70: bipush        6
      72: aconst_null
      73: invokestatic  #46                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      76: checkcast     #48                 // class java/lang/Iterable
      79: astore        6
      81: iconst_0
      82: istore        7
      84: aload         6
      86: astore        8
      88: new           #50                 // class java/util/ArrayList
      91: dup
      92: invokespecial #87                 // Method java/util/ArrayList."<init>":()V
      95: checkcast     #22                 // class java/util/Collection
      98: astore        9
     100: iconst_0
     101: istore        10
     103: aload         8
     105: invokeinterface #61,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     110: astore        11
     112: aload         11
     114: invokeinterface #67,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     119: ifeq          176
     122: aload         11
     124: invokeinterface #71,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     129: astore        12
     131: aload         12
     133: checkcast     #38                 // class java/lang/String
     136: astore        13
     138: iconst_0
     139: istore        14
     141: aload         13
     143: checkcast     #36                 // class java/lang/CharSequence
     146: invokeinterface #142,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     151: ifle          158
     154: iconst_1
     155: goto          159
     158: iconst_0
     159: nop
     160: ifeq          112
     163: aload         9
     165: aload         12
     167: invokeinterface #85,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     172: pop
     173: goto          112
     176: aload         9
     178: checkcast     #30                 // class java/util/List
     181: nop
     182: checkcast     #48                 // class java/lang/Iterable
     185: astore        6
     187: nop
     188: iconst_0
     189: istore        7
     191: aload         6
     193: astore        8
     195: new           #50                 // class java/util/ArrayList
     198: dup
     199: aload         6
     201: bipush        10
     203: invokestatic  #54                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     206: invokespecial #57                 // Method java/util/ArrayList."<init>":(I)V
     209: checkcast     #22                 // class java/util/Collection
     212: astore        9
     214: iconst_0
     215: istore        10
     217: aload         8
     219: invokeinterface #61,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     224: astore        11
     226: aload         11
     228: invokeinterface #67,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     233: ifeq          280
     236: aload         11
     238: invokeinterface #71,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     243: astore        12
     245: aload         9
     247: aload         12
     249: checkcast     #38                 // class java/lang/String
     252: astore        13
     254: astore        15
     256: iconst_0
     257: istore        14
     259: aload         13
     261: invokestatic  #77                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     264: nop
     265: invokestatic  #81                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     268: aload         15
     270: swap
     271: invokeinterface #85,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     276: pop
     277: goto          226
     280: aload         9
     282: checkcast     #30                 // class java/util/List
     285: nop
     286: astore        16
     288: aload_1
     289: checkcast     #22                 // class java/util/Collection
     292: aload         16
     294: checkcast     #48                 // class java/lang/Iterable
     297: invokestatic  #146                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     300: pop
     301: nop
     302: iinc          3, 1
     305: goto          28
     308: new           #148                // class day04/Board
     311: dup
     312: aload_1
     313: invokespecial #151                // Method day04/Board."<init>":(Ljava/util/List;)V
     316: areturn

  public static final void part1(java.util.List<java.lang.Integer>, java.util.List<day04.Board>);
    Code:
       0: aload_0
       1: ldc           #162                // String numbers
       3: invokestatic  #128                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #163                // String boards
       9: invokestatic  #128                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iconst_0
      13: istore_2
      14: aconst_null
      15: astore_3
      16: aload_0
      17: invokeinterface #131,  1          // InterfaceMethod java/util/List.removeFirst:()Ljava/lang/Object;
      22: dup
      23: ldc           #133                // String removeFirst(...)
      25: invokestatic  #136                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      28: checkcast     #165                // class java/lang/Number
      31: invokevirtual #168                // Method java/lang/Number.intValue:()I
      34: istore_2
      35: aload_1
      36: checkcast     #48                 // class java/lang/Iterable
      39: astore        4
      41: iconst_0
      42: istore        5
      44: aload         4
      46: invokeinterface #61,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      51: astore        6
      53: aload         6
      55: invokeinterface #67,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      60: ifeq          92
      63: aload         6
      65: invokeinterface #71,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      70: astore        7
      72: aload         7
      74: checkcast     #148                // class day04/Board
      77: astore        8
      79: iconst_0
      80: istore        9
      82: aload         8
      84: iload_2
      85: invokevirtual #171                // Method day04/Board.mark:(I)V
      88: nop
      89: goto          53
      92: nop
      93: aload_1
      94: checkcast     #48                 // class java/lang/Iterable
      97: astore        5
      99: aload         5
     101: invokeinterface #61,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     106: astore        6
     108: aload         6
     110: invokeinterface #67,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     115: ifeq          150
     118: aload         6
     120: invokeinterface #71,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     125: astore        7
     127: aload         7
     129: checkcast     #148                // class day04/Board
     132: astore        8
     134: iconst_0
     135: istore        9
     137: aload         8
     139: invokevirtual #174                // Method day04/Board.wins:()Z
     142: ifeq          108
     145: aload         7
     147: goto          151
     150: aconst_null
     151: checkcast     #148                // class day04/Board
     154: astore_3
     155: aload_3
     156: ifnull        16
     159: aload_3
     160: invokevirtual #177                // Method day04/Board.score:()I
     163: iload_2
     164: imul
     165: istore        4
     167: getstatic     #183                // Field java/lang/System.out:Ljava/io/PrintStream;
     170: iload         4
     172: invokevirtual #188                // Method java/io/PrintStream.println:(I)V
     175: return

  public static final void part2(java.util.List<java.lang.Integer>, java.util.List<day04.Board>);
    Code:
       0: aload_0
       1: ldc           #162                // String numbers
       3: invokestatic  #128                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #163                // String boards
       9: invokestatic  #128                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iconst_0
      13: istore_2
      14: aconst_null
      15: astore_3
      16: aload_0
      17: invokeinterface #131,  1          // InterfaceMethod java/util/List.removeFirst:()Ljava/lang/Object;
      22: dup
      23: ldc           #133                // String removeFirst(...)
      25: invokestatic  #136                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      28: checkcast     #165                // class java/lang/Number
      31: invokevirtual #168                // Method java/lang/Number.intValue:()I
      34: istore_2
      35: aload_1
      36: checkcast     #48                 // class java/lang/Iterable
      39: astore        4
      41: iconst_0
      42: istore        5
      44: aload         4
      46: invokeinterface #61,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      51: astore        6
      53: aload         6
      55: invokeinterface #67,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      60: ifeq          92
      63: aload         6
      65: invokeinterface #71,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      70: astore        7
      72: aload         7
      74: checkcast     #148                // class day04/Board
      77: astore        8
      79: iconst_0
      80: istore        9
      82: aload         8
      84: iload_2
      85: invokevirtual #171                // Method day04/Board.mark:(I)V
      88: nop
      89: goto          53
      92: nop
      93: aload_1
      94: checkcast     #48                 // class java/lang/Iterable
      97: astore        5
      99: iconst_0
     100: istore        6
     102: aload         5
     104: astore        7
     106: new           #50                 // class java/util/ArrayList
     109: dup
     110: invokespecial #87                 // Method java/util/ArrayList."<init>":()V
     113: checkcast     #22                 // class java/util/Collection
     116: astore        8
     118: iconst_0
     119: istore        9
     121: aload         7
     123: invokeinterface #61,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     128: astore        10
     130: aload         10
     132: invokeinterface #67,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     137: ifeq          180
     140: aload         10
     142: invokeinterface #71,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     147: astore        11
     149: aload         11
     151: checkcast     #148                // class day04/Board
     154: astore        12
     156: iconst_0
     157: istore        13
     159: aload         12
     161: invokevirtual #174                // Method day04/Board.wins:()Z
     164: ifeq          130
     167: aload         8
     169: aload         11
     171: invokeinterface #85,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     176: pop
     177: goto          130
     180: aload         8
     182: checkcast     #30                 // class java/util/List
     185: nop
     186: astore        4
     188: aload         4
     190: checkcast     #22                 // class java/util/Collection
     193: invokeinterface #90,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     198: ifne          205
     201: iconst_1
     202: goto          206
     205: iconst_0
     206: ifeq          230
     209: aload_1
     210: aload         4
     212: checkcast     #22                 // class java/util/Collection
     215: invokeinterface #200,  2          // InterfaceMethod java/util/List.removeAll:(Ljava/util/Collection;)Z
     220: pop
     221: aload         4
     223: invokestatic  #204                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     226: checkcast     #148                // class day04/Board
     229: astore_3
     230: aload_1
     231: checkcast     #22                 // class java/util/Collection
     234: invokeinterface #90,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     239: ifne          246
     242: iconst_1
     243: goto          247
     246: iconst_0
     247: ifne          16
     250: aload_3
     251: dup
     252: invokestatic  #208                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     255: invokevirtual #177                // Method day04/Board.score:()I
     258: iload_2
     259: imul
     260: istore        4
     262: getstatic     #183                // Field java/lang/System.out:Ljava/io/PrintStream;
     265: iload         4
     267: invokevirtual #188                // Method java/io/PrintStream.println:(I)V
     270: return

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