package bio.relatives.common.utils

import kotlin.math.pow
import kotlin.math.roundToInt
import kotlin.math.sqrt

/**
 * Based on the provided [values] calculates the median value.
 * @author Created by <NAME> on 28.01.2021
 */
fun <T : Number> calculateMedianVale(values: List<T>): Double =
    with(values.map { it.toDouble() }.sorted()) {
        val middle = size / 2
        return@with when {
            size % 2 != 0 -> get(middle)
            isNotEmpty() -> (get(middle) - get(middle - 1)) / 2.0
            else -> 0.0
        }
    }

/**
 * For provided [values] array calculates the root mean square value.
 */
fun <T : Number> calculateRootMeanSquare(values: List<T>): Double {
    values.ifEmpty { return 0.0 }

    val squareSum = values.map { it.toDouble().pow(2) }.sum()
    return sqrt(squareSum / values.size)
}

/**
 * Returns the average quality value of the [values] list.
 */
fun <T : Number> calculateAverageQuality(values: List<T>): Double {
    return values.map { it.toDouble() }.sum() / values.size
}

/**
 * Takes a map, where key is some arithmetic value, and value is its calculation error,
 * and calculates the relative error rate of addition of all this values.
 */
fun <T : Number> calculateAdditionRelativeErrorRate(valueToError: Map<T, T>): Double {
    return valueToError.map { it.value.toDouble() }.sum() /
            valueToError.map { it.key.toDouble() }.sum()
}

/**
 * Rounds a [valueToRound] to [placesNum] decimal places
 */
fun round(valueToRound: Double, placesNum: Byte): Double =
        (valueToRound * 10.0.pow(placesNum.toDouble())).roundToInt() / 10.0.pow(placesNum.toDouble())

Compiled from "MathUtils.kt"
public final class bio.relatives.common.utils.MathUtilsKt {
  public static final <T extends java.lang.Number> double calculateMedianVale(java.util.List<? extends T>);
    Code:
       0: aload_0
       1: ldc           #10                 // String values
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #18                 // class java/lang/Iterable
      10: astore_1
      11: iconst_0
      12: istore_2
      13: aload_1
      14: astore_3
      15: new           #20                 // class java/util/ArrayList
      18: dup
      19: aload_1
      20: bipush        10
      22: invokestatic  #26                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      25: invokespecial #30                 // Method java/util/ArrayList."<init>":(I)V
      28: checkcast     #32                 // class java/util/Collection
      31: astore        4
      33: iconst_0
      34: istore        5
      36: aload_3
      37: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        6
      44: aload         6
      46: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          97
      54: aload         6
      56: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        7
      63: aload         4
      65: aload         7
      67: checkcast     #48                 // class java/lang/Number
      70: astore        8
      72: astore        10
      74: iconst_0
      75: istore        9
      77: aload         8
      79: invokevirtual #52                 // Method java/lang/Number.doubleValue:()D
      82: invokestatic  #58                 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
      85: aload         10
      87: swap
      88: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      93: pop
      94: goto          44
      97: aload         4
      99: checkcast     #64                 // class java/util/List
     102: nop
     103: checkcast     #18                 // class java/lang/Iterable
     106: invokestatic  #68                 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
     109: astore_2
     110: iconst_0
     111: istore_3
     112: aload_2
     113: invokeinterface #72,  1           // InterfaceMethod java/util/List.size:()I
     118: iconst_2
     119: idiv
     120: istore        4
     122: nop
     123: aload_2
     124: invokeinterface #72,  1           // InterfaceMethod java/util/List.size:()I
     129: iconst_2
     130: irem
     131: ifeq          151
     134: aload_2
     135: iload         4
     137: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     142: checkcast     #48                 // class java/lang/Number
     145: invokevirtual #52                 // Method java/lang/Number.doubleValue:()D
     148: goto          210
     151: aload_2
     152: checkcast     #32                 // class java/util/Collection
     155: invokeinterface #79,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     160: ifne          167
     163: iconst_1
     164: goto          168
     167: iconst_0
     168: ifeq          209
     171: aload_2
     172: iload         4
     174: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     179: checkcast     #48                 // class java/lang/Number
     182: invokevirtual #52                 // Method java/lang/Number.doubleValue:()D
     185: aload_2
     186: iload         4
     188: iconst_1
     189: isub
     190: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     195: checkcast     #48                 // class java/lang/Number
     198: invokevirtual #52                 // Method java/lang/Number.doubleValue:()D
     201: dsub
     202: ldc2_w        #80                 // double 2.0d
     205: ddiv
     206: goto          210
     209: dconst_0
     210: nop
     211: nop
     212: dreturn

  public static final <T extends java.lang.Number> double calculateRootMeanSquare(java.util.List<? extends T>);
    Code:
       0: aload_0
       1: ldc           #10                 // String values
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #32                 // class java/util/Collection
      10: astore_1
      11: aload_1
      12: invokeinterface #79,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
      17: ifeq          24
      20: iconst_0
      21: istore_2
      22: dconst_0
      23: dreturn
      24: aload_0
      25: checkcast     #18                 // class java/lang/Iterable
      28: astore_3
      29: iconst_0
      30: istore        4
      32: aload_3
      33: astore        5
      35: new           #20                 // class java/util/ArrayList
      38: dup
      39: aload_3
      40: bipush        10
      42: invokestatic  #26                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      45: invokespecial #30                 // Method java/util/ArrayList."<init>":(I)V
      48: checkcast     #32                 // class java/util/Collection
      51: astore        6
      53: iconst_0
      54: istore        7
      56: aload         5
      58: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      63: astore        8
      65: aload         8
      67: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      72: ifeq          124
      75: aload         8
      77: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      82: astore        9
      84: aload         6
      86: aload         9
      88: checkcast     #48                 // class java/lang/Number
      91: astore        10
      93: astore        12
      95: iconst_0
      96: istore        11
      98: aload         10
     100: invokevirtual #52                 // Method java/lang/Number.doubleValue:()D
     103: iconst_2
     104: i2d
     105: invokestatic  #105                // Method java/lang/Math.pow:(DD)D
     108: nop
     109: invokestatic  #58                 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     112: aload         12
     114: swap
     115: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     120: pop
     121: goto          65
     124: aload         6
     126: checkcast     #64                 // class java/util/List
     129: nop
     130: checkcast     #18                 // class java/lang/Iterable
     133: invokestatic  #109                // Method kotlin/collections/CollectionsKt.sumOfDouble:(Ljava/lang/Iterable;)D
     136: dstore_1
     137: dload_1
     138: aload_0
     139: invokeinterface #72,  1           // InterfaceMethod java/util/List.size:()I
     144: i2d
     145: ddiv
     146: invokestatic  #113                // Method java/lang/Math.sqrt:(D)D
     149: dreturn

  public static final <T extends java.lang.Number> double calculateAverageQuality(java.util.List<? extends T>);
    Code:
       0: aload_0
       1: ldc           #10                 // String values
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #18                 // class java/lang/Iterable
      10: astore_1
      11: iconst_0
      12: istore_2
      13: aload_1
      14: astore_3
      15: new           #20                 // class java/util/ArrayList
      18: dup
      19: aload_1
      20: bipush        10
      22: invokestatic  #26                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      25: invokespecial #30                 // Method java/util/ArrayList."<init>":(I)V
      28: checkcast     #32                 // class java/util/Collection
      31: astore        4
      33: iconst_0
      34: istore        5
      36: aload_3
      37: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        6
      44: aload         6
      46: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          97
      54: aload         6
      56: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        7
      63: aload         4
      65: aload         7
      67: checkcast     #48                 // class java/lang/Number
      70: astore        8
      72: astore        10
      74: iconst_0
      75: istore        9
      77: aload         8
      79: invokevirtual #52                 // Method java/lang/Number.doubleValue:()D
      82: invokestatic  #58                 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
      85: aload         10
      87: swap
      88: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      93: pop
      94: goto          44
      97: aload         4
      99: checkcast     #64                 // class java/util/List
     102: nop
     103: checkcast     #18                 // class java/lang/Iterable
     106: invokestatic  #109                // Method kotlin/collections/CollectionsKt.sumOfDouble:(Ljava/lang/Iterable;)D
     109: aload_0
     110: invokeinterface #72,  1           // InterfaceMethod java/util/List.size:()I
     115: i2d
     116: ddiv
     117: dreturn

  public static final <T extends java.lang.Number> double calculateAdditionRelativeErrorRate(java.util.Map<T, ? extends T>);
    Code:
       0: aload_0
       1: ldc           #124                // String valueToError
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: astore_1
       8: iconst_0
       9: istore_2
      10: aload_1
      11: astore_3
      12: new           #20                 // class java/util/ArrayList
      15: dup
      16: aload_1
      17: invokeinterface #127,  1          // InterfaceMethod java/util/Map.size:()I
      22: invokespecial #30                 // Method java/util/ArrayList."<init>":(I)V
      25: checkcast     #32                 // class java/util/Collection
      28: astore        4
      30: iconst_0
      31: istore        5
      33: aload_3
      34: invokeinterface #131,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
      39: invokeinterface #134,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
      44: astore        6
      46: aload         6
      48: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      53: ifeq          107
      56: aload         6
      58: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: checkcast     #136                // class java/util/Map$Entry
      66: astore        7
      68: aload         4
      70: aload         7
      72: astore        8
      74: astore        10
      76: iconst_0
      77: istore        9
      79: aload         8
      81: invokeinterface #139,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
      86: checkcast     #48                 // class java/lang/Number
      89: invokevirtual #52                 // Method java/lang/Number.doubleValue:()D
      92: invokestatic  #58                 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
      95: aload         10
      97: swap
      98: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     103: pop
     104: goto          46
     107: aload         4
     109: checkcast     #64                 // class java/util/List
     112: nop
     113: checkcast     #18                 // class java/lang/Iterable
     116: invokestatic  #109                // Method kotlin/collections/CollectionsKt.sumOfDouble:(Ljava/lang/Iterable;)D
     119: aload_0
     120: astore_1
     121: dstore        10
     123: iconst_0
     124: istore_2
     125: aload_1
     126: astore_3
     127: new           #20                 // class java/util/ArrayList
     130: dup
     131: aload_1
     132: invokeinterface #127,  1          // InterfaceMethod java/util/Map.size:()I
     137: invokespecial #30                 // Method java/util/ArrayList."<init>":(I)V
     140: checkcast     #32                 // class java/util/Collection
     143: astore        4
     145: iconst_0
     146: istore        5
     148: aload_3
     149: invokeinterface #131,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     154: invokeinterface #134,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     159: astore        6
     161: aload         6
     163: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     168: ifeq          222
     171: aload         6
     173: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     178: checkcast     #136                // class java/util/Map$Entry
     181: astore        7
     183: aload         4
     185: aload         7
     187: astore        8
     189: astore        12
     191: iconst_0
     192: istore        9
     194: aload         8
     196: invokeinterface #142,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     201: checkcast     #48                 // class java/lang/Number
     204: invokevirtual #52                 // Method java/lang/Number.doubleValue:()D
     207: invokestatic  #58                 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     210: aload         12
     212: swap
     213: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     218: pop
     219: goto          161
     222: aload         4
     224: checkcast     #64                 // class java/util/List
     227: nop
     228: astore        12
     230: dload         10
     232: aload         12
     234: checkcast     #18                 // class java/lang/Iterable
     237: invokestatic  #109                // Method kotlin/collections/CollectionsKt.sumOfDouble:(Ljava/lang/Iterable;)D
     240: ddiv
     241: dreturn

  public static final double round(double, byte);
    Code:
       0: dload_0
       1: ldc2_w        #149                // double 10.0d
       4: iload_2
       5: i2d
       6: invokestatic  #105                // Method java/lang/Math.pow:(DD)D
       9: dmul
      10: invokestatic  #156                // Method kotlin/math/MathKt.roundToInt:(D)I
      13: i2d
      14: ldc2_w        #149                // double 10.0d
      17: iload_2
      18: i2d
      19: invokestatic  #105                // Method java/lang/Math.pow:(DD)D
      22: ddiv
      23: dreturn
}


package com.alexjlockwood.beesandbombs.demos.utils

import kotlin.math.pow
import kotlin.math.sqrt

const val PI = Math.PI.toFloat()
const val TWO_PI = 2 * PI
const val HALF_PI = PI / 2

/**
 * Calculates the cartesian distance between two points.
 */
fun dist(x1: Float, y1: Float, x2: Float, y2: Float): Float {
    return sqrt(((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)))
}

/**
 * Calculates a number between two numbers at a specific increment.
 */
fun lerp(a: Float, b: Float, t: Float): Float {
    return a + (b - a) * t
}

/**
 * Re-maps a number from one range to another.
 */
fun map(value: Float, start1: Float, stop1: Float, start2: Float, stop2: Float): Float {
    return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1))
}

/**
 * Converts the angle measured in radians to an approximately equivalent angle measured in degrees.
 */
fun Float.toDegrees(): Float {
    return Math.toDegrees(toDouble()).toFloat()
}

fun ease(p: Float): Float {
    return 3 * p * p - 2 * p * p * p
}

fun ease(p: Float, g: Float): Float {
    return if (p < 0.5f) {
        0.5f * (2 * p).pow(g)
    } else {
        1 - 0.5f * (2 * (1 - p)).pow(g)
    }
}

Compiled from "MathUtils.kt"
public final class com.alexjlockwood.beesandbombs.demos.utils.MathUtilsKt {
  public static final float PI;

  public static final float TWO_PI;

  public static final float HALF_PI;

  public static final float dist(float, float, float, float);
    Code:
       0: fload_2
       1: fload_0
       2: fsub
       3: fload_2
       4: fload_0
       5: fsub
       6: fmul
       7: fload_3
       8: fload_1
       9: fsub
      10: fload_3
      11: fload_1
      12: fsub
      13: fmul
      14: fadd
      15: f2d
      16: invokestatic  #12                 // Method java/lang/Math.sqrt:(D)D
      19: d2f
      20: freturn

  public static final float lerp(float, float, float);
    Code:
       0: fload_0
       1: fload_1
       2: fload_0
       3: fsub
       4: fload_2
       5: fmul
       6: fadd
       7: freturn

  public static final float map(float, float, float, float, float);
    Code:
       0: fload_3
       1: fload         4
       3: fload_3
       4: fsub
       5: fload_0
       6: fload_1
       7: fsub
       8: fload_2
       9: fload_1
      10: fsub
      11: fdiv
      12: fmul
      13: fadd
      14: freturn

  public static final float toDegrees(float);
    Code:
       0: fload_0
       1: f2d
       2: invokestatic  #33                 // Method java/lang/Math.toDegrees:(D)D
       5: d2f
       6: freturn

  public static final float ease(float);
    Code:
       0: iconst_3
       1: i2f
       2: fload_0
       3: fmul
       4: fload_0
       5: fmul
       6: iconst_2
       7: i2f
       8: fload_0
       9: fmul
      10: fload_0
      11: fmul
      12: fload_0
      13: fmul
      14: fsub
      15: freturn

  public static final float ease(float, float);
    Code:
       0: fload_0
       1: ldc           #38                 // float 0.5f
       3: fcmpg
       4: ifge          24
       7: ldc           #38                 // float 0.5f
       9: iconst_2
      10: i2f
      11: fload_0
      12: fmul
      13: f2d
      14: fload_1
      15: f2d
      16: invokestatic  #42                 // Method java/lang/Math.pow:(DD)D
      19: d2f
      20: fmul
      21: goto          44
      24: iconst_1
      25: i2f
      26: ldc           #38                 // float 0.5f
      28: iconst_2
      29: i2f
      30: iconst_1
      31: i2f
      32: fload_0
      33: fsub
      34: fmul
      35: f2d
      36: fload_1
      37: f2d
      38: invokestatic  #42                 // Method java/lang/Math.pow:(DD)D
      41: d2f
      42: fmul
      43: fsub
      44: freturn
}


package io.franmosteiro.aoc2020

/**
 * Advent of Code 2020 - Day 8: Handheld Halting -
 * Problem Description: http://adventofcode.com/2020/day/8
 */
class Day08(input: List<String>) {

    private val orders: List<Order> = input.map {
        val (name, offset) = it.split("\\s".toRegex())
        Order(name, offset.toInt())
    }

    fun resolvePartOne(): Int {
        val (position, accumulator) =  Program().run(orders)
        return accumulator
    }

    fun resolvePartTwo(): Int {
        orders.forEachIndexed { i, order ->
            when (order.name) {
                "jmp" -> orders.toMutableList().also { orders -> orders[i] = Order("nop", order.offset) }
                "nop" -> orders.toMutableList().also { orders -> orders[i] = Order("jmp", order.offset) }
                else -> null
            }?.let {
                val (position, accumulator) = Program().run(it)
                if (position == orders.size) {
                    return accumulator
                }
            }
        }
        return -1
    }

    data class Program(
            var position: Int = 0,
            var accumulator: Int = 0,
            var executedOrdersPositions: MutableSet<Int> = mutableSetOf()) {

        fun run(orders: List<Order>): Pair<Int, Int> {
            while (true) {

                if (position in executedOrdersPositions || position >= orders.size) {
                    return position to accumulator
                }

                executedOrdersPositions.add(position)

                val currentOrder = orders[position]

                when (currentOrder.name) {
                    "jmp" -> position += currentOrder.offset
                    "nop" -> position++
                    "acc" -> {
                        accumulator += currentOrder.offset
                        position++
                    }
                }
            }
        }
    }

    data class Order(
            val name: String,
            val offset: Int,
    )
}

Compiled from "Day08.kt"
public final class io.franmosteiro.aoc2020.Day08 {
  private final java.util.List<io.franmosteiro.aoc2020.Day08$Order> orders;

  public io.franmosteiro.aoc2020.Day08(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #10                 // String input
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #19                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_1
      12: checkcast     #21                 // class java/lang/Iterable
      15: astore_2
      16: astore        15
      18: iconst_0
      19: istore_3
      20: aload_2
      21: astore        4
      23: new           #23                 // class java/util/ArrayList
      26: dup
      27: aload_2
      28: bipush        10
      30: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      33: invokespecial #32                 // Method java/util/ArrayList."<init>":(I)V
      36: checkcast     #34                 // class java/util/Collection
      39: astore        5
      41: iconst_0
      42: istore        6
      44: aload         4
      46: invokeinterface #38,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      51: astore        7
      53: aload         7
      55: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      60: ifeq          170
      63: aload         7
      65: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      70: astore        8
      72: aload         5
      74: aload         8
      76: checkcast     #50                 // class java/lang/String
      79: astore        9
      81: astore        16
      83: iconst_0
      84: istore        10
      86: aload         9
      88: checkcast     #52                 // class java/lang/CharSequence
      91: astore        11
      93: new           #54                 // class kotlin/text/Regex
      96: dup
      97: ldc           #56                 // String \\s
      99: invokespecial #59                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
     102: astore        12
     104: iconst_0
     105: istore        13
     107: aload         12
     109: aload         11
     111: iload         13
     113: invokevirtual #63                 // Method kotlin/text/Regex.split:(Ljava/lang/CharSequence;I)Ljava/util/List;
     116: astore        14
     118: aload         14
     120: iconst_0
     121: invokeinterface #69,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     126: checkcast     #50                 // class java/lang/String
     129: astore        11
     131: aload         14
     133: iconst_1
     134: invokeinterface #69,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     139: checkcast     #50                 // class java/lang/String
     142: astore        12
     144: new           #71                 // class io/franmosteiro/aoc2020/Day08$Order
     147: dup
     148: aload         11
     150: aload         12
     152: invokestatic  #77                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     155: invokespecial #80                 // Method io/franmosteiro/aoc2020/Day08$Order."<init>":(Ljava/lang/String;I)V
     158: aload         16
     160: swap
     161: invokeinterface #84,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     166: pop
     167: goto          53
     170: aload         5
     172: checkcast     #65                 // class java/util/List
     175: nop
     176: aload         15
     178: swap
     179: putfield      #88                 // Field orders:Ljava/util/List;
     182: return

  public final int resolvePartOne();
    Code:
       0: new           #109                // class io/franmosteiro/aoc2020/Day08$Program
       3: dup
       4: iconst_0
       5: iconst_0
       6: aconst_null
       7: bipush        7
       9: aconst_null
      10: invokespecial #112                // Method io/franmosteiro/aoc2020/Day08$Program."<init>":(IILjava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
      13: aload_0
      14: getfield      #88                 // Field orders:Ljava/util/List;
      17: invokevirtual #116                // Method io/franmosteiro/aoc2020/Day08$Program.run:(Ljava/util/List;)Lkotlin/Pair;
      20: astore_1
      21: aload_1
      22: invokevirtual #121                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      25: checkcast     #123                // class java/lang/Number
      28: invokevirtual #126                // Method java/lang/Number.intValue:()I
      31: istore_2
      32: aload_1
      33: invokevirtual #129                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      36: checkcast     #123                // class java/lang/Number
      39: invokevirtual #126                // Method java/lang/Number.intValue:()I
      42: istore_3
      43: iload_3
      44: ireturn

  public final int resolvePartTwo();
    Code:
       0: aload_0
       1: getfield      #88                 // Field orders:Ljava/util/List;
       4: checkcast     #21                 // class java/lang/Iterable
       7: astore_1
       8: iconst_0
       9: istore_2
      10: iconst_0
      11: istore_3
      12: aload_1
      13: invokeinterface #38,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      18: astore        4
      20: aload         4
      22: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      27: ifeq          278
      30: aload         4
      32: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      37: astore        5
      39: iload_3
      40: iinc          3, 1
      43: istore        6
      45: iload         6
      47: ifge          53
      50: invokestatic  #135                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      53: iload         6
      55: aload         5
      57: checkcast     #71                 // class io/franmosteiro/aoc2020/Day08$Order
      60: astore        7
      62: istore        8
      64: iconst_0
      65: istore        9
      67: aload         7
      69: invokevirtual #139                // Method io/franmosteiro/aoc2020/Day08$Order.getName:()Ljava/lang/String;
      72: astore        10
      74: aload         10
      76: ldc           #141                // String jmp
      78: invokestatic  #145                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      81: ifeq          132
      84: aload_0
      85: getfield      #88                 // Field orders:Ljava/util/List;
      88: checkcast     #34                 // class java/util/Collection
      91: invokestatic  #149                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
      94: astore        11
      96: aload         11
      98: astore        12
     100: iconst_0
     101: istore        13
     103: aload         12
     105: iload         8
     107: new           #71                 // class io/franmosteiro/aoc2020/Day08$Order
     110: dup
     111: ldc           #151                // String nop
     113: aload         7
     115: invokevirtual #154                // Method io/franmosteiro/aoc2020/Day08$Order.getOffset:()I
     118: invokespecial #80                 // Method io/franmosteiro/aoc2020/Day08$Order."<init>":(Ljava/lang/String;I)V
     121: invokeinterface #158,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     126: pop
     127: aload         11
     129: goto          191
     132: aload         10
     134: ldc           #151                // String nop
     136: invokestatic  #145                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     139: ifeq          190
     142: aload_0
     143: getfield      #88                 // Field orders:Ljava/util/List;
     146: checkcast     #34                 // class java/util/Collection
     149: invokestatic  #149                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     152: astore        11
     154: aload         11
     156: astore        12
     158: iconst_0
     159: istore        13
     161: aload         12
     163: iload         8
     165: new           #71                 // class io/franmosteiro/aoc2020/Day08$Order
     168: dup
     169: ldc           #141                // String jmp
     171: aload         7
     173: invokevirtual #154                // Method io/franmosteiro/aoc2020/Day08$Order.getOffset:()I
     176: invokespecial #80                 // Method io/franmosteiro/aoc2020/Day08$Order."<init>":(Ljava/lang/String;I)V
     179: invokeinterface #158,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     184: pop
     185: aload         11
     187: goto          191
     190: aconst_null
     191: astore        14
     193: aload         14
     195: ifnull        272
     198: aload         14
     200: astore        11
     202: iconst_0
     203: istore        12
     205: new           #109                // class io/franmosteiro/aoc2020/Day08$Program
     208: dup
     209: iconst_0
     210: iconst_0
     211: aconst_null
     212: bipush        7
     214: aconst_null
     215: invokespecial #112                // Method io/franmosteiro/aoc2020/Day08$Program."<init>":(IILjava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
     218: aload         11
     220: invokevirtual #116                // Method io/franmosteiro/aoc2020/Day08$Program.run:(Ljava/util/List;)Lkotlin/Pair;
     223: astore        13
     225: aload         13
     227: invokevirtual #121                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     230: checkcast     #123                // class java/lang/Number
     233: invokevirtual #126                // Method java/lang/Number.intValue:()I
     236: istore        15
     238: aload         13
     240: invokevirtual #129                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     243: checkcast     #123                // class java/lang/Number
     246: invokevirtual #126                // Method java/lang/Number.intValue:()I
     249: istore        16
     251: iload         15
     253: aload_0
     254: getfield      #88                 // Field orders:Ljava/util/List;
     257: invokeinterface #161,  1          // InterfaceMethod java/util/List.size:()I
     262: if_icmpne     268
     265: iload         16
     267: ireturn
     268: nop
     269: goto          273
     272: nop
     273: nop
     274: nop
     275: goto          20
     278: nop
     279: iconst_m1
     280: ireturn
}

Compiled from "Day08.kt"
public final class io.franmosteiro.aoc2020.Day08$Program {
  private int position;

  private int accumulator;

  private java.util.Set<java.lang.Integer> executedOrdersPositions;

  public io.franmosteiro.aoc2020.Day08$Program(int, int, java.util.Set<java.lang.Integer>);
    Code:
       0: aload_3
       1: ldc           #10                 // String executedOrdersPositions
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #19                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: iload_1
      12: putfield      #23                 // Field position:I
      15: aload_0
      16: iload_2
      17: putfield      #26                 // Field accumulator:I
      20: aload_0
      21: aload_3
      22: putfield      #29                 // Field executedOrdersPositions:Ljava/util/Set;
      25: return

  public io.franmosteiro.aoc2020.Day08$Program(int, int, java.util.Set, int, kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: iload         4
       2: iconst_1
       3: iand
       4: ifeq          9
       7: iconst_0
       8: istore_1
       9: iload         4
      11: iconst_2
      12: iand
      13: ifeq          18
      16: iconst_0
      17: istore_2
      18: iload         4
      20: iconst_4
      21: iand
      22: ifeq          36
      25: new           #34                 // class java/util/LinkedHashSet
      28: dup
      29: invokespecial #35                 // Method java/util/LinkedHashSet."<init>":()V
      32: checkcast     #37                 // class java/util/Set
      35: astore_3
      36: aload_0
      37: iload_1
      38: iload_2
      39: aload_3
      40: invokespecial #39                 // Method "<init>":(IILjava/util/Set;)V
      43: return

  public final int getPosition();
    Code:
       0: aload_0
       1: getfield      #23                 // Field position:I
       4: ireturn

  public final void setPosition(int);
    Code:
       0: aload_0
       1: iload_1
       2: putfield      #23                 // Field position:I
       5: return

  public final int getAccumulator();
    Code:
       0: aload_0
       1: getfield      #26                 // Field accumulator:I
       4: ireturn

  public final void setAccumulator(int);
    Code:
       0: aload_0
       1: iload_1
       2: putfield      #26                 // Field accumulator:I
       5: return

  public final java.util.Set<java.lang.Integer> getExecutedOrdersPositions();
    Code:
       0: aload_0
       1: getfield      #29                 // Field executedOrdersPositions:Ljava/util/Set;
       4: areturn

  public final void setExecutedOrdersPositions(java.util.Set<java.lang.Integer>);
    Code:
       0: aload_1
       1: ldc           #53                 // String <set-?>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: putfield      #29                 // Field executedOrdersPositions:Ljava/util/Set;
      11: return

  public final kotlin.Pair<java.lang.Integer, java.lang.Integer> run(java.util.List<io.franmosteiro.aoc2020.Day08$Order>);
    Code:
       0: aload_1
       1: ldc           #58                 // String orders
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: nop
       7: aload_0
       8: getfield      #29                 // Field executedOrdersPositions:Ljava/util/Set;
      11: aload_0
      12: getfield      #23                 // Field position:I
      15: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      18: invokeinterface #68,  2           // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
      23: ifne          39
      26: aload_0
      27: getfield      #23                 // Field position:I
      30: aload_1
      31: invokeinterface #73,  1           // InterfaceMethod java/util/List.size:()I
      36: if_icmplt     57
      39: aload_0
      40: getfield      #23                 // Field position:I
      43: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      46: aload_0
      47: getfield      #26                 // Field accumulator:I
      50: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      53: invokestatic  #79                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      56: areturn
      57: aload_0
      58: getfield      #29                 // Field executedOrdersPositions:Ljava/util/Set;
      61: aload_0
      62: getfield      #23                 // Field position:I
      65: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      68: invokeinterface #82,  2           // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
      73: pop
      74: aload_1
      75: aload_0
      76: getfield      #23                 // Field position:I
      79: invokeinterface #86,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      84: checkcast     #88                 // class io/franmosteiro/aoc2020/Day08$Order
      87: astore_2
      88: aload_2
      89: invokevirtual #92                 // Method io/franmosteiro/aoc2020/Day08$Order.getName:()Ljava/lang/String;
      92: astore_3
      93: aload_3
      94: invokevirtual #97                 // Method java/lang/String.hashCode:()I
      97: lookupswitch  { // 3
                 96385: 132
                105357: 144
                109263: 156
               default: 228
          }
     132: aload_3
     133: ldc           #99                 // String acc
     135: invokevirtual #102                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     138: ifne          201
     141: goto          6
     144: aload_3
     145: ldc           #104                // String jmp
     147: invokevirtual #102                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     150: ifne          168
     153: goto          6
     156: aload_3
     157: ldc           #106                // String nop
     159: invokevirtual #102                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     162: ifne          184
     165: goto          6
     168: aload_0
     169: aload_0
     170: getfield      #23                 // Field position:I
     173: aload_2
     174: invokevirtual #109                // Method io/franmosteiro/aoc2020/Day08$Order.getOffset:()I
     177: iadd
     178: putfield      #23                 // Field position:I
     181: goto          6
     184: aload_0
     185: getfield      #23                 // Field position:I
     188: istore        4
     190: aload_0
     191: iload         4
     193: iconst_1
     194: iadd
     195: putfield      #23                 // Field position:I
     198: goto          6
     201: aload_0
     202: aload_0
     203: getfield      #26                 // Field accumulator:I
     206: aload_2
     207: invokevirtual #109                // Method io/franmosteiro/aoc2020/Day08$Order.getOffset:()I
     210: iadd
     211: putfield      #26                 // Field accumulator:I
     214: aload_0
     215: getfield      #23                 // Field position:I
     218: istore        4
     220: aload_0
     221: iload         4
     223: iconst_1
     224: iadd
     225: putfield      #23                 // Field position:I
     228: goto          6

  public final int component1();
    Code:
       0: aload_0
       1: getfield      #23                 // Field position:I
       4: ireturn

  public final int component2();
    Code:
       0: aload_0
       1: getfield      #26                 // Field accumulator:I
       4: ireturn

  public final java.util.Set<java.lang.Integer> component3();
    Code:
       0: aload_0
       1: getfield      #29                 // Field executedOrdersPositions:Ljava/util/Set;
       4: areturn

  public final io.franmosteiro.aoc2020.Day08$Program copy(int, int, java.util.Set<java.lang.Integer>);
    Code:
       0: aload_3
       1: ldc           #10                 // String executedOrdersPositions
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #2                  // class io/franmosteiro/aoc2020/Day08$Program
       9: dup
      10: iload_1
      11: iload_2
      12: aload_3
      13: invokespecial #39                 // Method "<init>":(IILjava/util/Set;)V
      16: areturn

  public static io.franmosteiro.aoc2020.Day08$Program copy$default(io.franmosteiro.aoc2020.Day08$Program, int, int, java.util.Set, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #23                 // Field position:I
      11: istore_1
      12: iload         4
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #26                 // Field accumulator:I
      23: istore_2
      24: iload         4
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #29                 // Field executedOrdersPositions:Ljava/util/Set;
      35: astore_3
      36: aload_0
      37: iload_1
      38: iload_2
      39: aload_3
      40: invokevirtual #122                // Method copy:(IILjava/util/Set;)Lio/franmosteiro/aoc2020/Day08$Program;
      43: areturn

  public java.lang.String toString();
    Code:
       0: new           #125                // class java/lang/StringBuilder
       3: dup
       4: invokespecial #126                // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #128                // String Program(position=
       9: invokevirtual #132                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #23                 // Field position:I
      16: invokevirtual #135                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #137                // String , accumulator=
      21: invokevirtual #132                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #26                 // Field accumulator:I
      28: invokevirtual #135                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: ldc           #139                // String , executedOrdersPositions=
      33: invokevirtual #132                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: aload_0
      37: getfield      #29                 // Field executedOrdersPositions:Ljava/util/Set;
      40: invokevirtual #142                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      43: bipush        41
      45: invokevirtual #145                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      48: invokevirtual #147                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      51: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #23                 // Field position:I
       4: invokestatic  #150                // Method java/lang/Integer.hashCode:(I)I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #26                 // Field accumulator:I
      16: invokestatic  #150                // Method java/lang/Integer.hashCode:(I)I
      19: iadd
      20: istore_1
      21: iload_1
      22: bipush        31
      24: imul
      25: aload_0
      26: getfield      #29                 // Field executedOrdersPositions:Ljava/util/Set;
      29: invokevirtual #151                // Method java/lang/Object.hashCode:()I
      32: iadd
      33: istore_1
      34: iload_1
      35: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class io/franmosteiro/aoc2020/Day08$Program
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class io/franmosteiro/aoc2020/Day08$Program
      20: astore_2
      21: aload_0
      22: getfield      #23                 // Field position:I
      25: aload_2
      26: getfield      #23                 // Field position:I
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #26                 // Field accumulator:I
      38: aload_2
      39: getfield      #26                 // Field accumulator:I
      42: if_icmpeq     47
      45: iconst_0
      46: ireturn
      47: aload_0
      48: getfield      #29                 // Field executedOrdersPositions:Ljava/util/Set;
      51: aload_2
      52: getfield      #29                 // Field executedOrdersPositions:Ljava/util/Set;
      55: invokestatic  #157                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      58: ifne          63
      61: iconst_0
      62: ireturn
      63: iconst_1
      64: ireturn

  public io.franmosteiro.aoc2020.Day08$Program();
    Code:
       0: aload_0
       1: iconst_0
       2: iconst_0
       3: aconst_null
       4: bipush        7
       6: aconst_null
       7: invokespecial #161                // Method "<init>":(IILjava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
      10: return
}

Compiled from "Day08.kt"
public final class io.franmosteiro.aoc2020.Day08$Order {
  private final java.lang.String name;

  private final int offset;

  public io.franmosteiro.aoc2020.Day08$Order(java.lang.String, int);
    Code:
       0: aload_1
       1: ldc           #9                  // String name
       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 name:Ljava/lang/String;
      15: aload_0
      16: iload_2
      17: putfield      #25                 // Field offset:I
      20: return

  public final java.lang.String getName();
    Code:
       0: aload_0
       1: getfield      #21                 // Field name:Ljava/lang/String;
       4: areturn

  public final int getOffset();
    Code:
       0: aload_0
       1: getfield      #25                 // Field offset:I
       4: ireturn

  public final java.lang.String component1();
    Code:
       0: aload_0
       1: getfield      #21                 // Field name:Ljava/lang/String;
       4: areturn

  public final int component2();
    Code:
       0: aload_0
       1: getfield      #25                 // Field offset:I
       4: ireturn

  public final io.franmosteiro.aoc2020.Day08$Order copy(java.lang.String, int);
    Code:
       0: aload_1
       1: ldc           #9                  // String name
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #2                  // class io/franmosteiro/aoc2020/Day08$Order
       9: dup
      10: aload_1
      11: iload_2
      12: invokespecial #37                 // Method "<init>":(Ljava/lang/String;I)V
      15: areturn

  public static io.franmosteiro.aoc2020.Day08$Order copy$default(io.franmosteiro.aoc2020.Day08$Order, java.lang.String, int, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          11
       6: aload_0
       7: getfield      #21                 // Field name:Ljava/lang/String;
      10: astore_1
      11: iload_3
      12: iconst_2
      13: iand
      14: ifeq          22
      17: aload_0
      18: getfield      #25                 // Field offset:I
      21: istore_2
      22: aload_0
      23: aload_1
      24: iload_2
      25: invokevirtual #41                 // Method copy:(Ljava/lang/String;I)Lio/franmosteiro/aoc2020/Day08$Order;
      28: areturn

  public java.lang.String toString();
    Code:
       0: new           #44                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #45                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #47                 // String Order(name=
       9: invokevirtual #51                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #21                 // Field name:Ljava/lang/String;
      16: invokevirtual #51                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      19: ldc           #53                 // String , offset=
      21: invokevirtual #51                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #25                 // Field offset:I
      28: invokevirtual #56                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: bipush        41
      33: invokevirtual #59                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      36: invokevirtual #61                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      39: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #21                 // Field name:Ljava/lang/String;
       4: invokevirtual #66                 // Method java/lang/String.hashCode:()I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #25                 // Field offset:I
      16: invokestatic  #71                 // Method java/lang/Integer.hashCode:(I)I
      19: iadd
      20: istore_1
      21: iload_1
      22: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class io/franmosteiro/aoc2020/Day08$Order
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class io/franmosteiro/aoc2020/Day08$Order
      20: astore_2
      21: aload_0
      22: getfield      #21                 // Field name:Ljava/lang/String;
      25: aload_2
      26: getfield      #21                 // Field name:Ljava/lang/String;
      29: invokestatic  #79                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      32: ifne          37
      35: iconst_0
      36: ireturn
      37: aload_0
      38: getfield      #25                 // Field offset:I
      41: aload_2
      42: getfield      #25                 // Field offset:I
      45: if_icmpeq     50
      48: iconst_0
      49: ireturn
      50: iconst_1
      51: ireturn
}


package io.franmosteiro.aoc2020

/**
 * Advent of Code 2020 - Day 9: Encoding Error -
 * Problem Description: http://adventofcode.com/2020/day/9
 */
class Day09(input: List<String>) {

    private val seriesOfNumbers = input.map{ it.toLong() }
    private var invalidNumber = -1
    private val requiredSum: Long = 1398413738

    fun resolvePartOne(preambleBatchSize: Int = 5): Int =
            seriesOfNumbers.windowed(preambleBatchSize + 1, 1)
                .first { !it.isValid() }
                .last()
                .also { invalidNumber = it.toInt() }.toInt()

    fun resolvePartTwo(): Int {
        val slice = contiguousRangeSlice(seriesOfNumbers)
        return (slice.minOrNull()!! + slice.maxOrNull()!!).toInt()
    }

    private fun List<Long>.isValid(): Boolean =
            any { itNumber -> ((last() - itNumber) in this) && (last() != itNumber) && ((last() - itNumber) != itNumber) }

    private fun contiguousRangeSlice(seriesOfNumbers: List<Long>): List<Long> {
        var acc = 0L
        var first = 0
        var second = 0
        while( second < seriesOfNumbers.size) {
            if(acc == requiredSum) {
                return seriesOfNumbers.slice(first..second)
            }
            if(acc > requiredSum) {
                acc -= seriesOfNumbers[first++]
                continue
            }
            acc += seriesOfNumbers[second++]
        }
        error("No slice equal to $requiredSum")
    }
}

Compiled from "Day09.kt"
public final class io.franmosteiro.aoc2020.Day09 {
  private final java.util.List<java.lang.Long> seriesOfNumbers;

  private int invalidNumber;

  private final long requiredSum;

  public io.franmosteiro.aoc2020.Day09(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #10                 // String input
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #19                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_1
      12: checkcast     #21                 // class java/lang/Iterable
      15: astore_2
      16: astore        11
      18: iconst_0
      19: istore_3
      20: aload_2
      21: astore        4
      23: new           #23                 // class java/util/ArrayList
      26: dup
      27: aload_2
      28: bipush        10
      30: invokestatic  #29                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      33: invokespecial #32                 // Method java/util/ArrayList."<init>":(I)V
      36: checkcast     #34                 // class java/util/Collection
      39: astore        5
      41: iconst_0
      42: istore        6
      44: aload         4
      46: invokeinterface #38,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      51: astore        7
      53: aload         7
      55: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      60: ifeq          107
      63: aload         7
      65: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      70: astore        8
      72: aload         5
      74: aload         8
      76: checkcast     #50                 // class java/lang/String
      79: astore        9
      81: astore        12
      83: iconst_0
      84: istore        10
      86: aload         9
      88: invokestatic  #56                 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
      91: nop
      92: invokestatic  #60                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      95: aload         12
      97: swap
      98: invokeinterface #64,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     103: pop
     104: goto          53
     107: aload         5
     109: checkcast     #66                 // class java/util/List
     112: nop
     113: aload         11
     115: swap
     116: putfield      #70                 // Field seriesOfNumbers:Ljava/util/List;
     119: aload_0
     120: iconst_m1
     121: putfield      #74                 // Field invalidNumber:I
     124: aload_0
     125: ldc2_w        #75                 // long 1398413738l
     128: putfield      #80                 // Field requiredSum:J
     131: return

  public final int resolvePartOne(int);
    Code:
       0: aload_0
       1: getfield      #70                 // Field seriesOfNumbers:Ljava/util/List;
       4: checkcast     #21                 // class java/lang/Iterable
       7: iload_1
       8: iconst_1
       9: iadd
      10: iconst_1
      11: iconst_0
      12: iconst_4
      13: aconst_null
      14: invokestatic  #100                // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;
      17: checkcast     #21                 // class java/lang/Iterable
      20: astore_2
      21: nop
      22: iconst_0
      23: istore_3
      24: aload_2
      25: invokeinterface #38,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      30: astore        4
      32: aload         4
      34: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      39: ifeq          83
      42: aload         4
      44: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      49: astore        5
      51: aload         5
      53: checkcast     #66                 // class java/util/List
      56: astore        6
      58: iconst_0
      59: istore        7
      61: aload_0
      62: aload         6
      64: invokespecial #104                // Method isValid:(Ljava/util/List;)Z
      67: ifne          74
      70: iconst_1
      71: goto          75
      74: iconst_0
      75: ifeq          32
      78: aload         5
      80: goto          93
      83: new           #106                // class java/util/NoSuchElementException
      86: dup
      87: ldc           #108                // String Collection contains no element matching the predicate.
      89: invokespecial #111                // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
      92: athrow
      93: checkcast     #66                 // class java/util/List
      96: invokestatic  #115                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
      99: astore_2
     100: aload_2
     101: checkcast     #117                // class java/lang/Number
     104: invokevirtual #121                // Method java/lang/Number.longValue:()J
     107: lstore_3
     108: iconst_0
     109: istore        5
     111: aload_0
     112: lload_3
     113: l2i
     114: putfield      #74                 // Field invalidNumber:I
     117: aload_2
     118: checkcast     #117                // class java/lang/Number
     121: invokevirtual #121                // Method java/lang/Number.longValue:()J
     124: l2i
     125: ireturn

  public static int resolvePartOne$default(io.franmosteiro.aoc2020.Day09, int, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_1
       2: iand
       3: ifeq          8
       6: iconst_5
       7: istore_1
       8: aload_0
       9: iload_1
      10: invokevirtual #131                // Method resolvePartOne:(I)I
      13: ireturn

  public final int resolvePartTwo();
    Code:
       0: aload_0
       1: aload_0
       2: getfield      #70                 // Field seriesOfNumbers:Ljava/util/List;
       5: invokespecial #137                // Method contiguousRangeSlice:(Ljava/util/List;)Ljava/util/List;
       8: astore_1
       9: aload_1
      10: checkcast     #21                 // class java/lang/Iterable
      13: invokestatic  #141                // Method kotlin/collections/CollectionsKt.minOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
      16: dup
      17: invokestatic  #145                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      20: checkcast     #117                // class java/lang/Number
      23: invokevirtual #121                // Method java/lang/Number.longValue:()J
      26: aload_1
      27: checkcast     #21                 // class java/lang/Iterable
      30: invokestatic  #148                // Method kotlin/collections/CollectionsKt.maxOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
      33: dup
      34: invokestatic  #145                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      37: checkcast     #117                // class java/lang/Number
      40: invokevirtual #121                // Method java/lang/Number.longValue:()J
      43: ladd
      44: l2i
      45: ireturn

  private final boolean isValid(java.util.List<java.lang.Long>);
    Code:
       0: aload_1
       1: checkcast     #21                 // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: instanceof    #34                 // class java/util/Collection
      11: ifeq          30
      14: aload_2
      15: checkcast     #34                 // class java/util/Collection
      18: invokeinterface #153,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      23: ifeq          30
      26: iconst_0
      27: goto          143
      30: aload_2
      31: invokeinterface #38,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      36: astore        4
      38: aload         4
      40: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      45: ifeq          142
      48: aload         4
      50: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      55: astore        5
      57: aload         5
      59: checkcast     #117                // class java/lang/Number
      62: invokevirtual #121                // Method java/lang/Number.longValue:()J
      65: lstore        6
      67: iconst_0
      68: istore        8
      70: aload_1
      71: aload_1
      72: invokestatic  #115                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
      75: checkcast     #117                // class java/lang/Number
      78: invokevirtual #121                // Method java/lang/Number.longValue:()J
      81: lload         6
      83: lsub
      84: invokestatic  #60                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      87: invokeinterface #156,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
      92: ifeq          134
      95: aload_1
      96: invokestatic  #115                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
      99: checkcast     #117                // class java/lang/Number
     102: invokevirtual #121                // Method java/lang/Number.longValue:()J
     105: lload         6
     107: lcmp
     108: ifeq          134
     111: aload_1
     112: invokestatic  #115                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     115: checkcast     #117                // class java/lang/Number
     118: invokevirtual #121                // Method java/lang/Number.longValue:()J
     121: lload         6
     123: lsub
     124: lload         6
     126: lcmp
     127: ifeq          134
     130: iconst_1
     131: goto          135
     134: iconst_0
     135: ifeq          38
     138: iconst_1
     139: goto          143
     142: iconst_0
     143: ireturn

  private final java.util.List<java.lang.Long> contiguousRangeSlice(java.util.List<java.lang.Long>);
    Code:
       0: lconst_0
       1: lstore_2
       2: iconst_0
       3: istore        4
       5: iconst_0
       6: istore        5
       8: iload         5
      10: aload_1
      11: invokeinterface #165,  1          // InterfaceMethod java/util/List.size:()I
      16: if_icmpge     99
      19: lload_2
      20: aload_0
      21: getfield      #80                 // Field requiredSum:J
      24: lcmp
      25: ifne          44
      28: aload_1
      29: new           #167                // class kotlin/ranges/IntRange
      32: dup
      33: iload         4
      35: iload         5
      37: invokespecial #170                // Method kotlin/ranges/IntRange."<init>":(II)V
      40: invokestatic  #173                // Method kotlin/collections/CollectionsKt.slice:(Ljava/util/List;Lkotlin/ranges/IntRange;)Ljava/util/List;
      43: areturn
      44: lload_2
      45: aload_0
      46: getfield      #80                 // Field requiredSum:J
      49: lcmp
      50: ifle          76
      53: lload_2
      54: aload_1
      55: iload         4
      57: iinc          4, 1
      60: invokeinterface #177,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      65: checkcast     #117                // class java/lang/Number
      68: invokevirtual #121                // Method java/lang/Number.longValue:()J
      71: lsub
      72: lstore_2
      73: goto          8
      76: lload_2
      77: aload_1
      78: iload         5
      80: iinc          5, 1
      83: invokeinterface #177,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      88: checkcast     #117                // class java/lang/Number
      91: invokevirtual #121                // Method java/lang/Number.longValue:()J
      94: ladd
      95: lstore_2
      96: goto          8
      99: new           #179                // class java/lang/IllegalStateException
     102: dup
     103: new           #181                // class java/lang/StringBuilder
     106: dup
     107: invokespecial #182                // Method java/lang/StringBuilder."<init>":()V
     110: ldc           #184                // String No slice equal to
     112: invokevirtual #188                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     115: aload_0
     116: getfield      #80                 // Field requiredSum:J
     119: invokevirtual #191                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     122: invokevirtual #195                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     125: invokevirtual #196                // Method java/lang/Object.toString:()Ljava/lang/String;
     128: invokespecial #197                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     131: athrow
}