package com.mayabot.nlp.algorithm

/**
 * Top K 最小值。
 */
class TopIntMinK(private val k: Int) {

    private val heap = FloatArray(k)
    private val idIndex = IntArray(k) { -1 }

    var size = 0

    fun push(id: Int, score: Float) {
        if (size < k) {
            heap[size] = score
            idIndex[size] = id
            size++

            if (size == k) {
                buildMinHeap()
            }
        } else {
            // 如果这个数据小于最大值，那么有资格进入
            if (score < heap[0]) {
                heap[0] = score
                idIndex[0] = id

                topify(0)
            }
        }
    }

    fun result(): ArrayList<Pair<Int, Float>> {
        val top = Math.min(k, size)
        val list = ArrayList<Pair<Int, Float>>(top)

        for (i in 0 until top) {
            list += idIndex[i] to heap[i]
        }

        list.sortBy { it.second }
        return list
    }

    private fun buildMinHeap() {
        for (i in k / 2 - 1 downTo 0) {
            topify(i)// 依次向上将当前子树最大堆化
        }
    }

    private fun topify(i: Int) {
        val l = 2 * i + 1
        val r = 2 * i + 2
        var max: Int

        if (l < k && heap[l] > heap[i])
            max = l
        else
            max = i

        if (r < k && heap[r] > heap[max]) {
            max = r
        }

        if (max == i || max >= k)
        // 如果largest等于i说明i是最大元素
        // largest超出heap范围说明不存在比i节点大的子女
            return

        swap(i, max)
        topify(max)
    }

    private fun swap(i: Int, j: Int) {
        val tmp = heap[i]
        heap[i] = heap[j]
        heap[j] = tmp

        val tmp2 = idIndex[i]
        idIndex[i] = idIndex[j]
        idIndex[j] = tmp2
    }
}

Compiled from "Comparisons.kt"
public final class com.mayabot.nlp.algorithm.TopIntMinK$result$$inlined$sortBy$1<T> implements java.util.Comparator {
  public com.mayabot.nlp.algorithm.TopIntMinK$result$$inlined$sortBy$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

  public final int compare(T, T);
    Code:
       0: aload_1
       1: checkcast     #23                 // class kotlin/Pair
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      12: checkcast     #29                 // class java/lang/Float
      15: checkcast     #31                 // class java/lang/Comparable
      18: aload_2
      19: checkcast     #23                 // class kotlin/Pair
      22: astore_3
      23: astore        5
      25: iconst_0
      26: istore        4
      28: aload_3
      29: invokevirtual #27                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      32: checkcast     #29                 // class java/lang/Float
      35: aload         5
      37: swap
      38: checkcast     #31                 // class java/lang/Comparable
      41: invokestatic  #37                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      44: ireturn
}

Compiled from "TopIntMinK.kt"
public final class com.mayabot.nlp.algorithm.TopIntMinK {
  private final int k;

  private final float[] heap;

  private final int[] idIndex;

  private int size;

  public com.mayabot.nlp.algorithm.TopIntMinK(int);
    Code:
       0: aload_0
       1: invokespecial #9                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: iload_1
       6: putfield      #13                 // Field k:I
       9: aload_0
      10: aload_0
      11: getfield      #13                 // Field k:I
      14: newarray       float
      16: putfield      #17                 // Field heap:[F
      19: aload_0
      20: iconst_0
      21: istore_2
      22: aload_0
      23: getfield      #13                 // Field k:I
      26: istore_3
      27: iload_3
      28: newarray       int
      30: astore        4
      32: astore        6
      34: iload_2
      35: iload_3
      36: if_icmpge     54
      39: iload_2
      40: istore        5
      42: aload         4
      44: iload         5
      46: iconst_m1
      47: iastore
      48: iinc          2, 1
      51: goto          34
      54: aload         6
      56: aload         4
      58: putfield      #21                 // Field idIndex:[I
      61: return

  public final int getSize();
    Code:
       0: aload_0
       1: getfield      #29                 // Field size:I
       4: ireturn

  public final void setSize(int);
    Code:
       0: aload_0
       1: iload_1
       2: putfield      #29                 // Field size:I
       5: return

  public final void push(int, float);
    Code:
       0: aload_0
       1: getfield      #29                 // Field size:I
       4: aload_0
       5: getfield      #13                 // Field k:I
       8: if_icmpge     61
      11: aload_0
      12: getfield      #17                 // Field heap:[F
      15: aload_0
      16: getfield      #29                 // Field size:I
      19: fload_2
      20: fastore
      21: aload_0
      22: getfield      #21                 // Field idIndex:[I
      25: aload_0
      26: getfield      #29                 // Field size:I
      29: iload_1
      30: iastore
      31: aload_0
      32: getfield      #29                 // Field size:I
      35: istore_3
      36: aload_0
      37: iload_3
      38: iconst_1
      39: iadd
      40: putfield      #29                 // Field size:I
      43: aload_0
      44: getfield      #29                 // Field size:I
      47: aload_0
      48: getfield      #13                 // Field k:I
      51: if_icmpne     91
      54: aload_0
      55: invokespecial #36                 // Method buildMinHeap:()V
      58: goto          91
      61: fload_2
      62: aload_0
      63: getfield      #17                 // Field heap:[F
      66: iconst_0
      67: faload
      68: fcmpg
      69: ifge          91
      72: aload_0
      73: getfield      #17                 // Field heap:[F
      76: iconst_0
      77: fload_2
      78: fastore
      79: aload_0
      80: getfield      #21                 // Field idIndex:[I
      83: iconst_0
      84: iload_1
      85: iastore
      86: aload_0
      87: iconst_0
      88: invokespecial #39                 // Method topify:(I)V
      91: return

  public final java.util.ArrayList<kotlin.Pair<java.lang.Integer, java.lang.Float>> result();
    Code:
       0: aload_0
       1: getfield      #13                 // Field k:I
       4: aload_0
       5: getfield      #29                 // Field size:I
       8: invokestatic  #52                 // Method java/lang/Math.min:(II)I
      11: istore_1
      12: new           #54                 // class java/util/ArrayList
      15: dup
      16: iload_1
      17: invokespecial #56                 // Method java/util/ArrayList."<init>":(I)V
      20: astore_2
      21: iconst_0
      22: istore_3
      23: iload_3
      24: iload_1
      25: if_icmpge     65
      28: aload_2
      29: checkcast     #58                 // class java/util/Collection
      32: aload_0
      33: getfield      #21                 // Field idIndex:[I
      36: iload_3
      37: iaload
      38: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      41: aload_0
      42: getfield      #17                 // Field heap:[F
      45: iload_3
      46: faload
      47: invokestatic  #69                 // Method java/lang/Float.valueOf:(F)Ljava/lang/Float;
      50: invokestatic  #75                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      53: invokeinterface #79,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      58: pop
      59: iinc          3, 1
      62: goto          23
      65: aload_2
      66: checkcast     #81                 // class java/util/List
      69: astore_3
      70: iconst_0
      71: istore        4
      73: aload_3
      74: invokeinterface #83,  1           // InterfaceMethod java/util/List.size:()I
      79: iconst_1
      80: if_icmple     97
      83: aload_3
      84: new           #85                 // class com/mayabot/nlp/algorithm/TopIntMinK$result$$inlined$sortBy$1
      87: dup
      88: invokespecial #86                 // Method com/mayabot/nlp/algorithm/TopIntMinK$result$$inlined$sortBy$1."<init>":()V
      91: checkcast     #88                 // class java/util/Comparator
      94: invokestatic  #94                 // Method kotlin/collections/CollectionsKt.sortWith:(Ljava/util/List;Ljava/util/Comparator;)V
      97: nop
      98: aload_2
      99: areturn

  private final void buildMinHeap();
    Code:
       0: aload_0
       1: getfield      #13                 // Field k:I
       4: iconst_2
       5: idiv
       6: iconst_1
       7: isub
       8: istore_1
       9: iconst_m1
      10: iload_1
      11: if_icmpge     25
      14: aload_0
      15: iload_1
      16: invokespecial #39                 // Method topify:(I)V
      19: iinc          1, -1
      22: goto          9
      25: return

  private final void topify(int);
    Code:
       0: iconst_2
       1: iload_1
       2: imul
       3: iconst_1
       4: iadd
       5: istore_2
       6: iconst_2
       7: iload_1
       8: imul
       9: iconst_2
      10: iadd
      11: istore_3
      12: iconst_0
      13: istore        4
      15: iload_2
      16: aload_0
      17: getfield      #13                 // Field k:I
      20: if_icmpge     45
      23: aload_0
      24: getfield      #17                 // Field heap:[F
      27: iload_2
      28: faload
      29: aload_0
      30: getfield      #17                 // Field heap:[F
      33: iload_1
      34: faload
      35: fcmpl
      36: ifle          45
      39: iload_2
      40: istore        4
      42: goto          48
      45: iload_1
      46: istore        4
      48: iload_3
      49: aload_0
      50: getfield      #13                 // Field k:I
      53: if_icmpge     76
      56: aload_0
      57: getfield      #17                 // Field heap:[F
      60: iload_3
      61: faload
      62: aload_0
      63: getfield      #17                 // Field heap:[F
      66: iload         4
      68: faload
      69: fcmpl
      70: ifle          76
      73: iload_3
      74: istore        4
      76: iload         4
      78: iload_1
      79: if_icmpeq     91
      82: iload         4
      84: aload_0
      85: getfield      #13                 // Field k:I
      88: if_icmplt     92
      91: return
      92: aload_0
      93: iload_1
      94: iload         4
      96: invokespecial #105                // Method swap:(II)V
      99: aload_0
     100: iload         4
     102: invokespecial #39                 // Method topify:(I)V
     105: return

  private final void swap(int, int);
    Code:
       0: aload_0
       1: getfield      #17                 // Field heap:[F
       4: iload_1
       5: faload
       6: fstore_3
       7: aload_0
       8: getfield      #17                 // Field heap:[F
      11: iload_1
      12: aload_0
      13: getfield      #17                 // Field heap:[F
      16: iload_2
      17: faload
      18: fastore
      19: aload_0
      20: getfield      #17                 // Field heap:[F
      23: iload_2
      24: fload_3
      25: fastore
      26: aload_0
      27: getfield      #21                 // Field idIndex:[I
      30: iload_1
      31: iaload
      32: istore        4
      34: aload_0
      35: getfield      #21                 // Field idIndex:[I
      38: iload_1
      39: aload_0
      40: getfield      #21                 // Field idIndex:[I
      43: iload_2
      44: iaload
      45: iastore
      46: aload_0
      47: getfield      #21                 // Field idIndex:[I
      50: iload_2
      51: iload         4
      53: iastore
      54: return
}


package com.mayabot.nlp.module.nwd

import kotlin.math.*

class IntCount {
    var value : Int = 1
}

/**
 * 词和词数量
 */
class WordCount(val word: String, val count: Int) : Comparable<WordCount> {
    override fun compareTo(other: WordCount): Int {
        return other.count.compareTo(count)
    }
}

data class NewWord(
    val word: String,
    val len: Int,
    val freq: Int,
    val docFreq: Int,
    /**
     * 互信息。内聚程度
     */
    val mi: Float,
    val avg_mi: Float,
    /**
     * 左右最低熵.和两侧的黏连程度
     */
    val entropy: Float,
    val le: Float,
    val re: Float,
    val idf: Float,
    val isBlock: Boolean
) {
    var score: Float = 0f

    /**
     * 内置打分公式
     */
    fun doScore() {
        var ac = abs(le - re)
        if (ac == 0.0f) {
            ac = 0.00000000001f
        }
        score = avg_mi + log2((le * exp(re) + re * exp(le)) / ac)
//        score = avg_mi + entropy + idf * 1.5f + len * freq / docFreq
        if (isBlock) score += 1000
    }
}

fun HashMap<Char, IntCount>.addTo(key: Char, count: Int) {
    this.getOrPut(key) {
        IntCount()
    }.value += count
}

class WordInfo(val word: String) {

    companion object {
        val empty = HashMap<Char, IntCount>()
        val emptySet = HashSet<Int>()
    }

    var count = 0
    var mi = 0f

    var mi_avg = 0f

    // 是否被双引号 书名号包围
    var isBlock = false

    var entropy = 0f

    var left = HashMap<Char, IntCount>(10)
    var right = HashMap<Char, IntCount>(10)

    var docSet = HashSet<Int>()

    var score = 0f

    var idf = 0f

    var doc = 0

    var le = 0f
    var re = 0f

//    var tfIdf =0f

    fun tfIdf(docCount: Double, ziCount: Double) {
        val doc = docSet.size + 1
        idf = log10(docCount / doc).toFloat()
//        tfIdf = (idf * (count/ziCount)).toFloat()
        docSet = emptySet
        this.doc = doc - 1
    }

    fun entropy() {

        var leftEntropy = 0f
        for (entry in left) {
            val p = entry.value.value / count.toFloat()
            leftEntropy -= (p * ln(p.toDouble())).toFloat()
        }

        var rightEntropy = 0f
        for (entry in right) {
            val p = entry.value.value / count.toFloat()
            rightEntropy -= (p * ln(p.toDouble())).toFloat()
        }

        le = leftEntropy
        re = rightEntropy

        entropy = min(leftEntropy, rightEntropy)

        left = empty
        right = empty
    }

}

Compiled from "ValueObjects.kt"
public final class com.mayabot.nlp.module.nwd.ValueObjectsKt {
  public static final void addTo(java.util.HashMap<java.lang.Character, com.mayabot.nlp.module.nwd.IntCount>, char, 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: aload_0
       7: checkcast     #18                 // class java/util/Map
      10: astore        4
      12: iload_1
      13: invokestatic  #24                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      16: astore        5
      18: iconst_0
      19: istore        6
      21: aload         4
      23: aload         5
      25: invokeinterface #28,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      30: astore        7
      32: aload         7
      34: ifnonnull     66
      37: iconst_0
      38: istore        8
      40: new           #30                 // class com/mayabot/nlp/module/nwd/IntCount
      43: dup
      44: invokespecial #34                 // Method com/mayabot/nlp/module/nwd/IntCount."<init>":()V
      47: astore        8
      49: aload         4
      51: aload         5
      53: aload         8
      55: invokeinterface #38,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      60: pop
      61: aload         8
      63: goto          68
      66: aload         7
      68: nop
      69: checkcast     #30                 // class com/mayabot/nlp/module/nwd/IntCount
      72: astore_3
      73: aload_3
      74: aload_3
      75: invokevirtual #42                 // Method com/mayabot/nlp/module/nwd/IntCount.getValue:()I
      78: iload_2
      79: iadd
      80: invokevirtual #46                 // Method com/mayabot/nlp/module/nwd/IntCount.setValue:(I)V
      83: return
}


package com.mayabot.nlp.fasttext.utils

import java.util.*
import kotlin.math.min

/**
 * 求最大Top K
 * 内部是小顶堆
 *
 * @author jimichan
 */
class TopMaxK<T>(private val k: Int=10 ) {

    private val heap: FloatArray = FloatArray(k)
    private val idIndex: MutableList<T?> = MutableList(k){null}
    var size = 0

    fun push(id: T, score: Float) {
        if (size < k) {
            heap[size] = score
            idIndex[size] = id
            size++
            if (size == k) {
                buildMinHeap()
            }
        } else { // 如果这个数据大于最下值，那么有资格进入
            if (score > heap[0]) {
                heap[0] = score
                idIndex[0] = id
                mintopify(0)
            }
        }
    }

    fun canPush(score: Float): Boolean {
        if (size < k) {
           return true
        } else { // 如果这个数据大于最下值，那么有资格进入
            if (score > heap[0]) {
                return true
            }
        }
        return false
    }

    fun result(): ArrayList<Pair<T, Float>> {
        val top = min(k, size)
        val list = ArrayList<Pair<T, Float>>(top)
        for (i in 0 until top) {
            val v = idIndex[i]
            val s = heap[i]
            if(v!=null){
                list += v to s
            }
        }
        list.sortByDescending { it.second }
        return list
    }

    private fun buildMinHeap() {
        for (i in k / 2 - 1 downTo 0) { // 依次向上将当前子树最大堆化
            mintopify(i)
        }
    }

    /**
     * 让heap数组符合堆特性
     *
     * @param i
     */
    private fun mintopify(i: Int) {
        val l = 2 * i + 1
        val r = 2 * i + 2
        var min = 0
        min = if (l < k && heap[l] < heap[i]) {
            l
        } else {
            i
        }
        if (r < k && heap[r] < heap[min]) {
            min = r
        }
        if (min == i || min >= k) {
            // 如果largest等于i说明i是最大元素
            // largest超出heap范围说明不存在比i节点大的子女
            return
        }
        swap(i, min)
        mintopify(min)
    }

    private fun swap(i: Int, j: Int) {
        val tmp = heap[i]
        heap[i] = heap[j]
        heap[j] = tmp
        val tmp2 = idIndex[i]
        idIndex[i] = idIndex[j]
        idIndex[j] = tmp2
    }

}

Compiled from "Comparisons.kt"
public final class com.mayabot.nlp.fasttext.utils.TopMaxK$result$$inlined$sortByDescending$1<T> implements java.util.Comparator {
  public com.mayabot.nlp.fasttext.utils.TopMaxK$result$$inlined$sortByDescending$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

  public final int compare(T, T);
    Code:
       0: aload_2
       1: checkcast     #23                 // class kotlin/Pair
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      12: checkcast     #29                 // class java/lang/Float
      15: checkcast     #31                 // class java/lang/Comparable
      18: aload_1
      19: checkcast     #23                 // class kotlin/Pair
      22: astore_3
      23: astore        5
      25: iconst_0
      26: istore        4
      28: aload_3
      29: invokevirtual #27                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      32: checkcast     #29                 // class java/lang/Float
      35: aload         5
      37: swap
      38: checkcast     #31                 // class java/lang/Comparable
      41: invokestatic  #37                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      44: ireturn
}

Compiled from "TopMaxK.kt"
public final class com.mayabot.nlp.fasttext.utils.TopMaxK<T> {
  private final int k;

  private final float[] heap;

  private final java.util.List<T> idIndex;

  private int size;

  public com.mayabot.nlp.fasttext.utils.TopMaxK(int);
    Code:
       0: aload_0
       1: invokespecial #10                 // Method java/lang/Object."<init>":()V
       4: aload_0
       5: iload_1
       6: putfield      #14                 // Field k:I
       9: aload_0
      10: aload_0
      11: getfield      #14                 // Field k:I
      14: newarray       float
      16: putfield      #18                 // Field heap:[F
      19: aload_0
      20: aload_0
      21: getfield      #14                 // Field k:I
      24: istore_2
      25: astore        8
      27: new           #20                 // class java/util/ArrayList
      30: dup
      31: iload_2
      32: invokespecial #22                 // Method java/util/ArrayList."<init>":(I)V
      35: astore_3
      36: iconst_0
      37: istore        4
      39: iload         4
      41: iload_2
      42: if_icmpge     73
      45: iload         4
      47: istore        5
      49: aload_3
      50: iload         5
      52: istore        6
      54: astore        9
      56: iconst_0
      57: istore        7
      59: aconst_null
      60: aload         9
      62: swap
      63: invokevirtual #26                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      66: pop
      67: iinc          4, 1
      70: goto          39
      73: aload_3
      74: checkcast     #28                 // class java/util/List
      77: aload         8
      79: swap
      80: putfield      #32                 // Field idIndex:Ljava/util/List;
      83: return

  public com.mayabot.nlp.fasttext.utils.TopMaxK(int, int, kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: iload_2
       1: iconst_1
       2: iand
       3: ifeq          9
       6: bipush        10
       8: istore_1
       9: aload_0
      10: iload_1
      11: invokespecial #38                 // Method "<init>":(I)V
      14: return

  public final int getSize();
    Code:
       0: aload_0
       1: getfield      #43                 // Field size:I
       4: ireturn

  public final void setSize(int);
    Code:
       0: aload_0
       1: iload_1
       2: putfield      #43                 // Field size:I
       5: return

  public final void push(T, float);
    Code:
       0: aload_0
       1: getfield      #43                 // Field size:I
       4: aload_0
       5: getfield      #14                 // Field k:I
       8: if_icmpge     66
      11: aload_0
      12: getfield      #18                 // Field heap:[F
      15: aload_0
      16: getfield      #43                 // Field size:I
      19: fload_2
      20: fastore
      21: aload_0
      22: getfield      #32                 // Field idIndex:Ljava/util/List;
      25: aload_0
      26: getfield      #43                 // Field size:I
      29: aload_1
      30: invokeinterface #52,  3           // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
      35: pop
      36: aload_0
      37: getfield      #43                 // Field size:I
      40: istore_3
      41: aload_0
      42: iload_3
      43: iconst_1
      44: iadd
      45: putfield      #43                 // Field size:I
      48: aload_0
      49: getfield      #43                 // Field size:I
      52: aload_0
      53: getfield      #14                 // Field k:I
      56: if_icmpne     101
      59: aload_0
      60: invokespecial #55                 // Method buildMinHeap:()V
      63: goto          101
      66: fload_2
      67: aload_0
      68: getfield      #18                 // Field heap:[F
      71: iconst_0
      72: faload
      73: fcmpl
      74: ifle          101
      77: aload_0
      78: getfield      #18                 // Field heap:[F
      81: iconst_0
      82: fload_2
      83: fastore
      84: aload_0
      85: getfield      #32                 // Field idIndex:Ljava/util/List;
      88: iconst_0
      89: aload_1
      90: invokeinterface #52,  3           // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
      95: pop
      96: aload_0
      97: iconst_0
      98: invokespecial #58                 // Method mintopify:(I)V
     101: return

  public final boolean canPush(float);
    Code:
       0: aload_0
       1: getfield      #43                 // Field size:I
       4: aload_0
       5: getfield      #14                 // Field k:I
       8: if_icmpge     13
      11: iconst_1
      12: ireturn
      13: fload_1
      14: aload_0
      15: getfield      #18                 // Field heap:[F
      18: iconst_0
      19: faload
      20: fcmpl
      21: ifle          26
      24: iconst_1
      25: ireturn
      26: iconst_0
      27: ireturn

  public final java.util.ArrayList<kotlin.Pair<T, java.lang.Float>> result();
    Code:
       0: aload_0
       1: getfield      #14                 // Field k:I
       4: aload_0
       5: getfield      #43                 // Field size:I
       8: invokestatic  #74                 // Method java/lang/Math.min:(II)I
      11: istore_1
      12: new           #20                 // class java/util/ArrayList
      15: dup
      16: iload_1
      17: invokespecial #22                 // Method java/util/ArrayList."<init>":(I)V
      20: astore_2
      21: iconst_0
      22: istore_3
      23: iload_3
      24: iload_1
      25: if_icmpge     79
      28: aload_0
      29: getfield      #32                 // Field idIndex:Ljava/util/List;
      32: iload_3
      33: invokeinterface #78,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      38: astore        4
      40: aload_0
      41: getfield      #18                 // Field heap:[F
      44: iload_3
      45: faload
      46: fstore        5
      48: aload         4
      50: ifnull        73
      53: aload_2
      54: checkcast     #80                 // class java/util/Collection
      57: aload         4
      59: fload         5
      61: invokestatic  #86                 // Method java/lang/Float.valueOf:(F)Ljava/lang/Float;
      64: invokestatic  #92                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      67: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      72: pop
      73: iinc          3, 1
      76: goto          23
      79: aload_2
      80: checkcast     #28                 // class java/util/List
      83: astore_3
      84: iconst_0
      85: istore        4
      87: aload_3
      88: invokeinterface #95,  1           // InterfaceMethod java/util/List.size:()I
      93: iconst_1
      94: if_icmple     111
      97: aload_3
      98: new           #97                 // class com/mayabot/nlp/fasttext/utils/TopMaxK$result$$inlined$sortByDescending$1
     101: dup
     102: invokespecial #98                 // Method com/mayabot/nlp/fasttext/utils/TopMaxK$result$$inlined$sortByDescending$1."<init>":()V
     105: checkcast     #100                // class java/util/Comparator
     108: invokestatic  #106                // Method kotlin/collections/CollectionsKt.sortWith:(Ljava/util/List;Ljava/util/Comparator;)V
     111: nop
     112: aload_2
     113: areturn

  private final void buildMinHeap();
    Code:
       0: aload_0
       1: getfield      #14                 // Field k:I
       4: iconst_2
       5: idiv
       6: iconst_1
       7: isub
       8: istore_1
       9: iconst_m1
      10: iload_1
      11: if_icmpge     25
      14: aload_0
      15: iload_1
      16: invokespecial #58                 // Method mintopify:(I)V
      19: iinc          1, -1
      22: goto          9
      25: return

  private final void mintopify(int);
    Code:
       0: iconst_2
       1: iload_1
       2: imul
       3: iconst_1
       4: iadd
       5: istore_2
       6: iconst_2
       7: iload_1
       8: imul
       9: iconst_2
      10: iadd
      11: istore_3
      12: iconst_0
      13: istore        4
      15: iload_2
      16: aload_0
      17: getfield      #14                 // Field k:I
      20: if_icmpge     43
      23: aload_0
      24: getfield      #18                 // Field heap:[F
      27: iload_2
      28: faload
      29: aload_0
      30: getfield      #18                 // Field heap:[F
      33: iload_1
      34: faload
      35: fcmpg
      36: ifge          43
      39: iload_2
      40: goto          44
      43: iload_1
      44: istore        4
      46: iload_3
      47: aload_0
      48: getfield      #14                 // Field k:I
      51: if_icmpge     74
      54: aload_0
      55: getfield      #18                 // Field heap:[F
      58: iload_3
      59: faload
      60: aload_0
      61: getfield      #18                 // Field heap:[F
      64: iload         4
      66: faload
      67: fcmpg
      68: ifge          74
      71: iload_3
      72: istore        4
      74: iload         4
      76: iload_1
      77: if_icmpeq     89
      80: iload         4
      82: aload_0
      83: getfield      #14                 // Field k:I
      86: if_icmplt     90
      89: return
      90: aload_0
      91: iload_1
      92: iload         4
      94: invokespecial #118                // Method swap:(II)V
      97: aload_0
      98: iload         4
     100: invokespecial #58                 // Method mintopify:(I)V
     103: return

  private final void swap(int, int);
    Code:
       0: aload_0
       1: getfield      #18                 // Field heap:[F
       4: iload_1
       5: faload
       6: fstore_3
       7: aload_0
       8: getfield      #18                 // Field heap:[F
      11: iload_1
      12: aload_0
      13: getfield      #18                 // Field heap:[F
      16: iload_2
      17: faload
      18: fastore
      19: aload_0
      20: getfield      #18                 // Field heap:[F
      23: iload_2
      24: fload_3
      25: fastore
      26: aload_0
      27: getfield      #32                 // Field idIndex:Ljava/util/List;
      30: iload_1
      31: invokeinterface #78,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      36: astore        4
      38: aload_0
      39: getfield      #32                 // Field idIndex:Ljava/util/List;
      42: iload_1
      43: aload_0
      44: getfield      #32                 // Field idIndex:Ljava/util/List;
      47: iload_2
      48: invokeinterface #78,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      53: invokeinterface #52,  3           // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
      58: pop
      59: aload_0
      60: getfield      #32                 // Field idIndex:Ljava/util/List;
      63: iload_2
      64: aload         4
      66: invokeinterface #52,  3           // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
      71: pop
      72: return

  public com.mayabot.nlp.fasttext.utils.TopMaxK();
    Code:
       0: aload_0
       1: iconst_0
       2: iconst_1
       3: aconst_null
       4: invokespecial #125                // Method "<init>":(IILkotlin/jvm/internal/DefaultConstructorMarker;)V
       7: return
}


package io.steinh.aoc.day06

class BoatRace(private val input: BoatRaceStats) {

    fun calculateWaysToBeatTheRecord(): Int {
        val possibleWins = buildList {
            input.timeToDistance.forEach { (time, distance) ->
                add(
                    buildList {
                        for (i in 1..time) {
                            if (((time - i).times(i)) > distance) {
                                add(i)
                            }
                        }
                    }
                )

            }
        }

        return possibleWins.map { it.size }.reduce { acc, next -> acc * next }
    }

    fun calculateForOneLargeRace(): Int {
        val longTime = input.timeToDistance.keys.map { it.toString() }.reduce { acc, next -> "$acc$next" }.toLong()
        val longDistance =
            input.timeToDistance.values.map { it.toString() }.reduce { acc, next -> "$acc$next" }.toLong()

        var count = 0

        for (i in 1..longTime) {
            if ((longTime - i).times(i) > longDistance) {
                count++
            }
        }

        return count
    }

}

data class BoatRaceStats(
    val timeToDistance: Map<Int, Int>
)

fun interpretStats(input: String): BoatRaceStats {
    val inputLines = input.split("\n")
    val times = "(\\d+)".toRegex().findAll(inputLines[0])
        .map {
            it.groupValues[0].toInt()
        }
        .toList()
    val distances = "(\\d+)".toRegex().findAll(inputLines[1])
        .map {
            it.groupValues[0].toInt()
        }
        .toList()

    return BoatRaceStats(
        timeToDistance = times.zip(distances) { t, d -> t to d }.toMap()
    )
}

fun main() {
    val input = {}.javaClass.classLoader?.getResource("day06/input.txt")?.readText()!!
    val boatRace = BoatRace(interpretStats(input))

    val partOneResult = boatRace.calculateWaysToBeatTheRecord()
    println("Result for day 06, part  I: $partOneResult")

    val partTwoResult = boatRace.calculateForOneLargeRace()
    println("Result for day 06, part II: $partTwoResult")
}

Compiled from "BoatRace.kt"
public final class io.steinh.aoc.day06.BoatRace {
  private final io.steinh.aoc.day06.BoatRaceStats input;

  public io.steinh.aoc.day06.BoatRace(io.steinh.aoc.day06.BoatRaceStats);
    Code:
       0: aload_1
       1: ldc           #9                  // String input
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #18                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_1
      12: putfield      #21                 // Field input:Lio/steinh/aoc/day06/BoatRaceStats;
      15: return

  public final int calculateWaysToBeatTheRecord();
    Code:
       0: invokestatic  #31                 // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;
       3: astore_2
       4: aload_2
       5: astore_3
       6: iconst_0
       7: istore        4
       9: aload_0
      10: getfield      #21                 // Field input:Lio/steinh/aoc/day06/BoatRaceStats;
      13: invokevirtual #37                 // Method io/steinh/aoc/day06/BoatRaceStats.getTimeToDistance:()Ljava/util/Map;
      16: astore        5
      18: iconst_0
      19: istore        6
      21: aload         5
      23: invokeinterface #43,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
      28: invokeinterface #49,  1           // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
      33: astore        7
      35: aload         7
      37: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      42: ifeq          177
      45: aload         7
      47: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      52: checkcast     #61                 // class java/util/Map$Entry
      55: astore        8
      57: aload         8
      59: astore        9
      61: iconst_0
      62: istore        10
      64: aload         9
      66: invokeinterface #64,  1           // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
      71: checkcast     #66                 // class java/lang/Number
      74: invokevirtual #69                 // Method java/lang/Number.intValue:()I
      77: istore        11
      79: aload         9
      81: invokeinterface #72,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
      86: checkcast     #66                 // class java/lang/Number
      89: invokevirtual #69                 // Method java/lang/Number.intValue:()I
      92: istore        12
      94: aload_3
      95: invokestatic  #31                 // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;
      98: astore        13
     100: aload         13
     102: astore        14
     104: astore        15
     106: iconst_0
     107: istore        16
     109: iconst_1
     110: istore        17
     112: iload         17
     114: iload         11
     116: if_icmpgt     158
     119: iload         11
     121: iload         17
     123: isub
     124: iload         17
     126: imul
     127: iload         12
     129: if_icmple     145
     132: aload         14
     134: iload         17
     136: invokestatic  #78                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     139: invokeinterface #84,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     144: pop
     145: iload         17
     147: iload         11
     149: if_icmpeq     158
     152: iinc          17, 1
     155: goto          119
     158: nop
     159: aload         15
     161: aload         13
     163: invokestatic  #88                 // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;
     166: invokeinterface #84,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     171: pop
     172: nop
     173: nop
     174: goto          35
     177: nop
     178: nop
     179: aload_2
     180: invokestatic  #88                 // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;
     183: astore_1
     184: aload_1
     185: checkcast     #90                 // class java/lang/Iterable
     188: astore_2
     189: iconst_0
     190: istore_3
     191: aload_2
     192: astore        4
     194: new           #92                 // class java/util/ArrayList
     197: dup
     198: aload_2
     199: bipush        10
     201: invokestatic  #96                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     204: invokespecial #99                 // Method java/util/ArrayList."<init>":(I)V
     207: checkcast     #101                // class java/util/Collection
     210: astore        5
     212: iconst_0
     213: istore        6
     215: aload         4
     217: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     222: astore        7
     224: aload         7
     226: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     231: ifeq          279
     234: aload         7
     236: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     241: astore        8
     243: aload         5
     245: aload         8
     247: checkcast     #80                 // class java/util/List
     250: astore        9
     252: astore        18
     254: iconst_0
     255: istore        10
     257: aload         9
     259: invokeinterface #105,  1          // InterfaceMethod java/util/List.size:()I
     264: invokestatic  #78                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     267: aload         18
     269: swap
     270: invokeinterface #106,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     275: pop
     276: goto          224
     279: aload         5
     281: checkcast     #80                 // class java/util/List
     284: nop
     285: checkcast     #90                 // class java/lang/Iterable
     288: astore_2
     289: nop
     290: iconst_0
     291: istore_3
     292: aload_2
     293: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     298: astore        4
     300: aload         4
     302: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     307: ifne          320
     310: new           #108                // class java/lang/UnsupportedOperationException
     313: dup
     314: ldc           #110                // String Empty collection can\'t be reduced.
     316: invokespecial #113                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     319: athrow
     320: aload         4
     322: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     327: astore        5
     329: aload         4
     331: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     336: ifeq          380
     339: aload         5
     341: aload         4
     343: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     348: checkcast     #66                 // class java/lang/Number
     351: invokevirtual #69                 // Method java/lang/Number.intValue:()I
     354: istore        6
     356: checkcast     #66                 // class java/lang/Number
     359: invokevirtual #69                 // Method java/lang/Number.intValue:()I
     362: istore        7
     364: iconst_0
     365: istore        8
     367: iload         7
     369: iload         6
     371: imul
     372: invokestatic  #78                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     375: astore        5
     377: goto          329
     380: aload         5
     382: checkcast     #66                 // class java/lang/Number
     385: invokevirtual #69                 // Method java/lang/Number.intValue:()I
     388: ireturn

  public final int calculateForOneLargeRace();
    Code:
       0: aload_0
       1: getfield      #21                 // Field input:Lio/steinh/aoc/day06/BoatRaceStats;
       4: invokevirtual #37                 // Method io/steinh/aoc/day06/BoatRaceStats.getTimeToDistance:()Ljava/util/Map;
       7: invokeinterface #151,  1          // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;
      12: checkcast     #90                 // class java/lang/Iterable
      15: astore_3
      16: iconst_0
      17: istore        4
      19: aload_3
      20: astore        5
      22: new           #92                 // class java/util/ArrayList
      25: dup
      26: aload_3
      27: bipush        10
      29: invokestatic  #96                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      32: invokespecial #99                 // Method java/util/ArrayList."<init>":(I)V
      35: checkcast     #101                // class java/util/Collection
      38: astore        6
      40: iconst_0
      41: istore        7
      43: aload         5
      45: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      50: astore        8
      52: aload         8
      54: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      59: ifeq          105
      62: aload         8
      64: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      69: astore        9
      71: aload         6
      73: aload         9
      75: checkcast     #66                 // class java/lang/Number
      78: invokevirtual #69                 // Method java/lang/Number.intValue:()I
      81: istore        10
      83: astore        14
      85: iconst_0
      86: istore        11
      88: iload         10
      90: invokestatic  #156                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
      93: aload         14
      95: swap
      96: invokeinterface #106,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     101: pop
     102: goto          52
     105: aload         6
     107: checkcast     #80                 // class java/util/List
     110: nop
     111: checkcast     #90                 // class java/lang/Iterable
     114: astore_3
     115: nop
     116: iconst_0
     117: istore        4
     119: aload_3
     120: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     125: astore        5
     127: aload         5
     129: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     134: ifne          147
     137: new           #108                // class java/lang/UnsupportedOperationException
     140: dup
     141: ldc           #110                // String Empty collection can\'t be reduced.
     143: invokespecial #113                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     146: athrow
     147: aload         5
     149: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     154: astore        6
     156: aload         5
     158: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     163: ifeq          213
     166: aload         6
     168: aload         5
     170: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     175: checkcast     #153                // class java/lang/String
     178: astore        7
     180: checkcast     #153                // class java/lang/String
     183: astore        8
     185: iconst_0
     186: istore        9
     188: new           #158                // class java/lang/StringBuilder
     191: dup
     192: invokespecial #159                // Method java/lang/StringBuilder."<init>":()V
     195: aload         8
     197: invokevirtual #163                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     200: aload         7
     202: invokevirtual #163                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     205: invokevirtual #167                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     208: astore        6
     210: goto          156
     213: aload         6
     215: checkcast     #153                // class java/lang/String
     218: invokestatic  #173                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     221: lstore_1
     222: aload_0
     223: getfield      #21                 // Field input:Lio/steinh/aoc/day06/BoatRaceStats;
     226: invokevirtual #37                 // Method io/steinh/aoc/day06/BoatRaceStats.getTimeToDistance:()Ljava/util/Map;
     229: invokeinterface #177,  1          // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
     234: checkcast     #90                 // class java/lang/Iterable
     237: astore        5
     239: iconst_0
     240: istore        6
     242: aload         5
     244: astore        7
     246: new           #92                 // class java/util/ArrayList
     249: dup
     250: aload         5
     252: bipush        10
     254: invokestatic  #96                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     257: invokespecial #99                 // Method java/util/ArrayList."<init>":(I)V
     260: checkcast     #101                // class java/util/Collection
     263: astore        8
     265: iconst_0
     266: istore        9
     268: aload         7
     270: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     275: astore        10
     277: aload         10
     279: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     284: ifeq          330
     287: aload         10
     289: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     294: astore        11
     296: aload         8
     298: aload         11
     300: checkcast     #66                 // class java/lang/Number
     303: invokevirtual #69                 // Method java/lang/Number.intValue:()I
     306: istore        12
     308: astore        14
     310: iconst_0
     311: istore        13
     313: iload         12
     315: invokestatic  #156                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     318: aload         14
     320: swap
     321: invokeinterface #106,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     326: pop
     327: goto          277
     330: aload         8
     332: checkcast     #80                 // class java/util/List
     335: nop
     336: checkcast     #90                 // class java/lang/Iterable
     339: astore        5
     341: nop
     342: iconst_0
     343: istore        6
     345: aload         5
     347: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     352: astore        7
     354: aload         7
     356: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     361: ifne          374
     364: new           #108                // class java/lang/UnsupportedOperationException
     367: dup
     368: ldc           #110                // String Empty collection can\'t be reduced.
     370: invokespecial #113                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     373: athrow
     374: aload         7
     376: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     381: astore        8
     383: aload         7
     385: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     390: ifeq          440
     393: aload         8
     395: aload         7
     397: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     402: checkcast     #153                // class java/lang/String
     405: astore        9
     407: checkcast     #153                // class java/lang/String
     410: astore        10
     412: iconst_0
     413: istore        11
     415: new           #158                // class java/lang/StringBuilder
     418: dup
     419: invokespecial #159                // Method java/lang/StringBuilder."<init>":()V
     422: aload         10
     424: invokevirtual #163                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     427: aload         9
     429: invokevirtual #163                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     432: invokevirtual #167                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     435: astore        8
     437: goto          383
     440: aload         8
     442: checkcast     #153                // class java/lang/String
     445: invokestatic  #173                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     448: lstore_3
     449: iconst_0
     450: istore        5
     452: lconst_1
     453: lstore        6
     455: lload         6
     457: lload_1
     458: lcmp
     459: ifgt          493
     462: lload_1
     463: lload         6
     465: lsub
     466: lload         6
     468: lmul
     469: lload_3
     470: lcmp
     471: ifle          477
     474: iinc          5, 1
     477: lload         6
     479: lload_1
     480: lcmp
     481: ifeq          493
     484: lload         6
     486: lconst_1
     487: ladd
     488: lstore        6
     490: goto          462
     493: iload         5
     495: ireturn
}

Compiled from "BoatRace.kt"
public final class io.steinh.aoc.day06.BoatRaceKt {
  public static final io.steinh.aoc.day06.BoatRaceStats interpretStats(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #9                  // String input
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #17                 // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #19                 // class java/lang/String
      14: astore_2
      15: aload_2
      16: iconst_0
      17: ldc           #21                 // String \n
      19: aastore
      20: aload_2
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #27                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: astore_1
      30: new           #29                 // class kotlin/text/Regex
      33: dup
      34: ldc           #31                 // String (\\d+)
      36: invokespecial #35                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      39: aload_1
      40: iconst_0
      41: invokeinterface #41,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      46: checkcast     #17                 // class java/lang/CharSequence
      49: iconst_0
      50: iconst_2
      51: aconst_null
      52: invokestatic  #45                 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;
      55: invokedynamic #65,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      60: invokestatic  #71                 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      63: invokestatic  #75                 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
      66: astore_2
      67: new           #29                 // class kotlin/text/Regex
      70: dup
      71: ldc           #31                 // String (\\d+)
      73: invokespecial #35                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      76: aload_1
      77: iconst_1
      78: invokeinterface #41,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      83: checkcast     #17                 // class java/lang/CharSequence
      86: iconst_0
      87: iconst_2
      88: aconst_null
      89: invokestatic  #45                 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;
      92: invokedynamic #80,  0             // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
      97: invokestatic  #71                 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     100: invokestatic  #75                 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
     103: astore_3
     104: aload_2
     105: checkcast     #82                 // class java/lang/Iterable
     108: astore        4
     110: iconst_0
     111: istore        5
     113: aload         4
     115: invokeinterface #86,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     120: astore        6
     122: aload_3
     123: checkcast     #82                 // class java/lang/Iterable
     126: invokeinterface #86,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     131: astore        7
     133: new           #88                 // class java/util/ArrayList
     136: dup
     137: aload         4
     139: bipush        10
     141: invokestatic  #94                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     144: aload_3
     145: checkcast     #82                 // class java/lang/Iterable
     148: bipush        10
     150: invokestatic  #94                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     153: invokestatic  #100                // Method java/lang/Math.min:(II)I
     156: invokespecial #103                // Method java/util/ArrayList."<init>":(I)V
     159: astore        8
     161: aload         6
     163: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     168: ifeq          241
     171: aload         7
     173: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     178: ifeq          241
     181: aload         8
     183: aload         6
     185: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     190: aload         7
     192: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     197: checkcast     #115                // class java/lang/Number
     200: invokevirtual #119                // Method java/lang/Number.intValue:()I
     203: istore        9
     205: checkcast     #115                // class java/lang/Number
     208: invokevirtual #119                // Method java/lang/Number.intValue:()I
     211: istore        10
     213: astore        12
     215: iconst_0
     216: istore        11
     218: iload         10
     220: invokestatic  #125                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     223: iload         9
     225: invokestatic  #125                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     228: invokestatic  #131                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     231: aload         12
     233: swap
     234: invokevirtual #135                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     237: pop
     238: goto          161
     241: aload         8
     243: checkcast     #37                 // class java/util/List
     246: checkcast     #82                 // class java/lang/Iterable
     249: invokestatic  #141                // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;
     252: astore        13
     254: new           #143                // class io/steinh/aoc/day06/BoatRaceStats
     257: dup
     258: aload         13
     260: invokespecial #146                // Method io/steinh/aoc/day06/BoatRaceStats."<init>":(Ljava/util/Map;)V
     263: areturn

  public static final void main();
    Code:
       0: invokedynamic #175,  0            // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function0;
       5: invokevirtual #179                // Method java/lang/Object.getClass:()Ljava/lang/Class;
       8: invokevirtual #185                // Method java/lang/Class.getClassLoader:()Ljava/lang/ClassLoader;
      11: dup
      12: ifnull        50
      15: ldc           #187                // String day06/input.txt
      17: invokevirtual #193                // Method java/lang/ClassLoader.getResource:(Ljava/lang/String;)Ljava/net/URL;
      20: dup
      21: ifnull        50
      24: astore_3
      25: getstatic     #199                // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      28: astore        4
      30: aload_3
      31: invokestatic  #205                // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B
      34: astore        5
      36: new           #19                 // class java/lang/String
      39: dup
      40: aload         5
      42: aload         4
      44: invokespecial #208                // Method java/lang/String."<init>":([BLjava/nio/charset/Charset;)V
      47: goto          52
      50: pop
      51: aconst_null
      52: dup
      53: invokestatic  #212                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      56: astore_0
      57: new           #214                // class io/steinh/aoc/day06/BoatRace
      60: dup
      61: aload_0
      62: invokestatic  #216                // Method interpretStats:(Ljava/lang/String;)Lio/steinh/aoc/day06/BoatRaceStats;
      65: invokespecial #219                // Method io/steinh/aoc/day06/BoatRace."<init>":(Lio/steinh/aoc/day06/BoatRaceStats;)V
      68: astore_1
      69: aload_1
      70: invokevirtual #222                // Method io/steinh/aoc/day06/BoatRace.calculateWaysToBeatTheRecord:()I
      73: istore_2
      74: new           #224                // class java/lang/StringBuilder
      77: dup
      78: invokespecial #226                // Method java/lang/StringBuilder."<init>":()V
      81: ldc           #228                // String Result for day 06, part  I:
      83: invokevirtual #232                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      86: iload_2
      87: invokevirtual #235                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      90: invokevirtual #239                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      93: getstatic     #245                // Field java/lang/System.out:Ljava/io/PrintStream;
      96: swap
      97: invokevirtual #250                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     100: aload_1
     101: invokevirtual #253                // Method io/steinh/aoc/day06/BoatRace.calculateForOneLargeRace:()I
     104: istore_3
     105: new           #224                // class java/lang/StringBuilder
     108: dup
     109: invokespecial #226                // Method java/lang/StringBuilder."<init>":()V
     112: ldc           #255                // String Result for day 06, part II:
     114: invokevirtual #232                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     117: iload_3
     118: invokevirtual #235                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     121: invokevirtual #239                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     124: getstatic     #245                // Field java/lang/System.out:Ljava/io/PrintStream;
     127: swap
     128: invokevirtual #250                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     131: return

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

  private static final int interpretStats$lambda$0(kotlin.text.MatchResult);
    Code:
       0: aload_0
       1: ldc_w         #266                // String it
       4: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokeinterface #272,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
      13: iconst_0
      14: invokeinterface #41,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      19: checkcast     #19                 // class java/lang/String
      22: invokestatic  #276                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      25: ireturn

  private static final int interpretStats$lambda$1(kotlin.text.MatchResult);
    Code:
       0: aload_0
       1: ldc_w         #266                // String it
       4: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokeinterface #272,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
      13: iconst_0
      14: invokeinterface #41,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      19: checkcast     #19                 // class java/lang/String
      22: invokestatic  #276                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      25: ireturn

  private static final kotlin.Unit main$lambda$3();
    Code:
       0: getstatic     #283                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
       3: areturn
}


package io.steinh.aoc.day01

class Trebuchet {

    fun String.replace(vararg pairs: Pair<String, String>): String =
        pairs.fold(this) { acc, (old, new) -> acc.replace(old, new, ignoreCase = true) }

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

        val transformedStrings = transform(input)

        return transformedStrings.sumOf {
            s -> "${ s.first { it.isDigit() }}${ s.last { it.isDigit() }}".toInt()
        }

    }

    private fun transform(input: List<String>): List<String> {
        val regex = Regex("^(one|two|three|four|five|six|seven|eight|nine)")
        return buildList {
            for (line in input) {
                var transformed = ""
                for (i in line.indices) {
                    if (line[i].isDigit()) {
                        transformed += line[i]
                    } else {
                        transformed += when (regex.find(line.substring(i))?.value) {
                            "one" -> "1"
                            "two" -> "2"
                            "three" -> "3"
                            "four" -> "4"
                            "five" -> "5"
                            "six" -> "6"
                            "seven" -> "7"
                            "eight" -> "8"
                            "nine" -> "9"
                            else -> ""
                        }

                    }
                }
                add(transformed)
            }
        }

    }

}

fun main() {
    val input = {}.javaClass.classLoader?.getResource("day01/input.txt")?.readText()?.lines()
    val trebuchet = Trebuchet()

    val sum = trebuchet.calibrate(input!!)

    print("Result 1: $sum")
}

Compiled from "Trebuchet.kt"
public final class io.steinh.aoc.day01.TrebuchetKt {
  public static final void main();
    Code:
       0: invokedynamic #25,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function0;
       5: invokevirtual #29                 // Method java/lang/Object.getClass:()Ljava/lang/Class;
       8: invokevirtual #35                 // Method java/lang/Class.getClassLoader:()Ljava/lang/ClassLoader;
      11: dup
      12: ifnull        56
      15: ldc           #37                 // String day01/input.txt
      17: invokevirtual #43                 // Method java/lang/ClassLoader.getResource:(Ljava/lang/String;)Ljava/net/URL;
      20: dup
      21: ifnull        56
      24: astore_3
      25: getstatic     #49                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      28: astore        4
      30: aload_3
      31: invokestatic  #55                 // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B
      34: astore        5
      36: new           #57                 // class java/lang/String
      39: dup
      40: aload         5
      42: aload         4
      44: invokespecial #61                 // Method java/lang/String."<init>":([BLjava/nio/charset/Charset;)V
      47: checkcast     #63                 // class java/lang/CharSequence
      50: invokestatic  #69                 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;
      53: goto          58
      56: pop
      57: aconst_null
      58: astore_0
      59: new           #71                 // class io/steinh/aoc/day01/Trebuchet
      62: dup
      63: invokespecial #73                 // Method io/steinh/aoc/day01/Trebuchet."<init>":()V
      66: astore_1
      67: aload_1
      68: aload_0
      69: dup
      70: invokestatic  #79                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      73: invokevirtual #83                 // Method io/steinh/aoc/day01/Trebuchet.calibrate:(Ljava/util/List;)I
      76: istore_2
      77: new           #85                 // class java/lang/StringBuilder
      80: dup
      81: invokespecial #86                 // Method java/lang/StringBuilder."<init>":()V
      84: ldc           #88                 // String Result 1:
      86: invokevirtual #92                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      89: iload_2
      90: invokevirtual #95                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      93: invokevirtual #99                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      96: getstatic     #105                // Field java/lang/System.out:Ljava/io/PrintStream;
      99: swap
     100: invokevirtual #110                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     103: return

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

  private static final kotlin.Unit main$lambda$0();
    Code:
       0: getstatic     #129                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
       3: areturn
}

Compiled from "Trebuchet.kt"
public final class io.steinh.aoc.day01.Trebuchet {
  public io.steinh.aoc.day01.Trebuchet();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final java.lang.String replace(java.lang.String, kotlin.Pair<java.lang.String, java.lang.String>...);
    Code:
       0: aload_1
       1: ldc           #16                 // String <this>
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #24                 // String pairs
       9: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_2
      13: astore_3
      14: iconst_0
      15: istore        4
      17: aload_1
      18: astore        5
      20: iconst_0
      21: istore        6
      23: aload_3
      24: arraylength
      25: istore        7
      27: iload         6
      29: iload         7
      31: if_icmpge     89
      34: aload_3
      35: iload         6
      37: aaload
      38: astore        8
      40: aload         5
      42: aload         8
      44: astore        9
      46: astore        10
      48: iconst_0
      49: istore        11
      51: aload         9
      53: invokevirtual #30                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
      56: checkcast     #32                 // class java/lang/String
      59: astore        12
      61: aload         9
      63: invokevirtual #35                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
      66: checkcast     #32                 // class java/lang/String
      69: astore        13
      71: aload         10
      73: aload         12
      75: aload         13
      77: iconst_1
      78: invokestatic  #40                 // Method kotlin/text/StringsKt.replace:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)Ljava/lang/String;
      81: astore        5
      83: iinc          6, 1
      86: goto          27
      89: aload         5
      91: areturn

  public final int calibrate(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #60                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: invokespecial #64                 // Method transform:(Ljava/util/List;)Ljava/util/List;
      11: astore_2
      12: aload_2
      13: checkcast     #66                 // class java/lang/Iterable
      16: astore_3
      17: iconst_0
      18: istore        4
      20: aload_3
      21: invokeinterface #70,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      26: astore        5
      28: aload         5
      30: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      35: ifeq          264
      38: aload         5
      40: invokeinterface #79,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      45: astore        6
      47: iload         4
      49: aload         6
      51: checkcast     #32                 // class java/lang/String
      54: astore        7
      56: istore        18
      58: iconst_0
      59: istore        8
      61: new           #81                 // class java/lang/StringBuilder
      64: dup
      65: invokespecial #82                 // Method java/lang/StringBuilder."<init>":()V
      68: aload         7
      70: checkcast     #84                 // class java/lang/CharSequence
      73: astore        9
      75: astore        10
      77: iconst_0
      78: istore        11
      80: iconst_0
      81: istore        12
      83: iload         12
      85: aload         9
      87: invokeinterface #88,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      92: if_icmpge     133
      95: aload         9
      97: iload         12
      99: invokeinterface #92,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     104: istore        13
     106: iload         13
     108: istore        14
     110: iconst_0
     111: istore        15
     113: iload         14
     115: invokestatic  #98                 // Method java/lang/Character.isDigit:(C)Z
     118: nop
     119: ifeq          127
     122: iload         13
     124: goto          143
     127: iinc          12, 1
     130: goto          83
     133: new           #100                // class java/util/NoSuchElementException
     136: dup
     137: ldc           #102                // String Char sequence contains no character matching the predicate.
     139: invokespecial #105                // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
     142: athrow
     143: istore        16
     145: aload         10
     147: iload         16
     149: invokevirtual #109                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     152: aload         7
     154: checkcast     #84                 // class java/lang/CharSequence
     157: astore        9
     159: astore        10
     161: iconst_0
     162: istore        11
     164: aload         9
     166: invokeinterface #88,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     171: iconst_m1
     172: iadd
     173: istore        12
     175: iconst_0
     176: iload         12
     178: if_icmpgt     226
     181: iload         12
     183: istore        13
     185: iinc          12, -1
     188: aload         9
     190: iload         13
     192: invokeinterface #92,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     197: istore        14
     199: iload         14
     201: istore        15
     203: iconst_0
     204: istore        17
     206: iload         15
     208: invokestatic  #98                 // Method java/lang/Character.isDigit:(C)Z
     211: nop
     212: ifeq          220
     215: iload         14
     217: goto          236
     220: iconst_0
     221: iload         12
     223: if_icmple     181
     226: new           #100                // class java/util/NoSuchElementException
     229: dup
     230: ldc           #102                // String Char sequence contains no character matching the predicate.
     232: invokespecial #105                // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
     235: athrow
     236: istore        16
     238: aload         10
     240: iload         16
     242: invokevirtual #109                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     245: invokevirtual #113                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     248: invokestatic  #119                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     251: nop
     252: istore        19
     254: iload         18
     256: iload         19
     258: iadd
     259: istore        4
     261: goto          28
     264: iload         4
     266: ireturn

  private final java.util.List<java.lang.String> transform(java.util.List<java.lang.String>);
    Code:
       0: new           #138                // class kotlin/text/Regex
       3: dup
       4: ldc           #140                // String ^(one|two|three|four|five|six|seven|eight|nine)
       6: invokespecial #141                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
       9: astore_2
      10: invokestatic  #147                // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;
      13: astore_3
      14: aload_3
      15: astore        4
      17: iconst_0
      18: istore        5
      20: aload_1
      21: invokeinterface #148,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      26: astore        6
      28: aload         6
      30: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      35: ifeq          455
      38: aload         6
      40: invokeinterface #79,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      45: checkcast     #32                 // class java/lang/String
      48: astore        7
      50: ldc           #150                // String
      52: astore        8
      54: iconst_0
      55: istore        9
      57: aload         7
      59: checkcast     #84                 // class java/lang/CharSequence
      62: invokeinterface #88,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      67: istore        10
      69: iload         9
      71: iload         10
      73: if_icmpge     442
      76: aload         7
      78: iload         9
      80: invokevirtual #151                // Method java/lang/String.charAt:(I)C
      83: invokestatic  #98                 // Method java/lang/Character.isDigit:(C)Z
      86: ifeq          119
      89: new           #81                 // class java/lang/StringBuilder
      92: dup
      93: invokespecial #82                 // Method java/lang/StringBuilder."<init>":()V
      96: aload         8
      98: invokevirtual #154                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     101: aload         7
     103: iload         9
     105: invokevirtual #151                // Method java/lang/String.charAt:(I)C
     108: invokevirtual #109                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     111: invokevirtual #113                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     114: astore        8
     116: goto          436
     119: new           #81                 // class java/lang/StringBuilder
     122: dup
     123: invokespecial #82                 // Method java/lang/StringBuilder."<init>":()V
     126: aload         8
     128: invokevirtual #154                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     131: aload_2
     132: aload         7
     134: iload         9
     136: invokevirtual #158                // Method java/lang/String.substring:(I)Ljava/lang/String;
     139: dup
     140: ldc           #160                // String substring(...)
     142: invokestatic  #163                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     145: checkcast     #84                 // class java/lang/CharSequence
     148: iconst_0
     149: iconst_2
     150: aconst_null
     151: invokestatic  #167                // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;
     154: dup
     155: ifnull        166
     158: invokeinterface #172,  1          // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;
     163: goto          168
     166: pop
     167: aconst_null
     168: astore        11
     170: aload         11
     172: ifnull        426
     175: aload         11
     177: invokevirtual #175                // Method java/lang/String.hashCode:()I
     180: lookupswitch  { // 9
                110182: 303
                113890: 277
                115276: 329
               3143346: 355
               3149094: 290
               3381426: 264
              96505999: 368
             109330445: 316
             110339486: 342
               default: 426
          }
     264: aload         11
     266: ldc           #177                // String nine
     268: invokevirtual #181                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     271: ifne          421
     274: goto          426
     277: aload         11
     279: ldc           #183                // String six
     281: invokevirtual #181                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     284: ifne          406
     287: goto          426
     290: aload         11
     292: ldc           #185                // String four
     294: invokevirtual #181                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     297: ifne          396
     300: goto          426
     303: aload         11
     305: ldc           #187                // String one
     307: invokevirtual #181                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     310: ifne          381
     313: goto          426
     316: aload         11
     318: ldc           #189                // String seven
     320: invokevirtual #181                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     323: ifne          411
     326: goto          426
     329: aload         11
     331: ldc           #191                // String two
     333: invokevirtual #181                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     336: ifne          386
     339: goto          426
     342: aload         11
     344: ldc           #193                // String three
     346: invokevirtual #181                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     349: ifne          391
     352: goto          426
     355: aload         11
     357: ldc           #195                // String five
     359: invokevirtual #181                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     362: ifne          401
     365: goto          426
     368: aload         11
     370: ldc           #197                // String eight
     372: invokevirtual #181                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     375: ifne          416
     378: goto          426
     381: ldc           #199                // String 1
     383: goto          428
     386: ldc           #201                // String 2
     388: goto          428
     391: ldc           #203                // String 3
     393: goto          428
     396: ldc           #205                // String 4
     398: goto          428
     401: ldc           #207                // String 5
     403: goto          428
     406: ldc           #209                // String 6
     408: goto          428
     411: ldc           #211                // String 7
     413: goto          428
     416: ldc           #213                // String 8
     418: goto          428
     421: ldc           #215                // String 9
     423: goto          428
     426: ldc           #150                // String
     428: invokevirtual #154                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     431: invokevirtual #113                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     434: astore        8
     436: iinc          9, 1
     439: goto          69
     442: aload         4
     444: aload         8
     446: invokeinterface #218,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     451: pop
     452: goto          28
     455: nop
     456: aload_3
     457: invokestatic  #221                // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;
     460: areturn
}