package puzzle10

import java.lang.IllegalStateException
import kotlin.system.measureTimeMillis

fun main() {

    val syntaxScorer = SyntaxScorer()
    val time = measureTimeMillis {
        println("Bad line scoring: ${syntaxScorer.fixBrokenLines()}")
        println("Incomplete line scoring: ${syntaxScorer.fixIncompleteLines()}")
    }

    println("time: $time")
}

sealed interface SyntaxCharacter{
    fun produceMatchingCharacter(): SyntaxCharacter
}

enum class OpeningSyntaxCharacter: SyntaxCharacter {
    Parenthesis,
    CurlyBracket,
    AngleBracket,
    SquareBracket;

    override fun produceMatchingCharacter(): ClosingSyntaxCharacter = when(this) {
        Parenthesis -> ClosingSyntaxCharacter.Parenthesis
        CurlyBracket -> ClosingSyntaxCharacter.CurlyBracket
        AngleBracket -> ClosingSyntaxCharacter.AngleBracket
        SquareBracket -> ClosingSyntaxCharacter.SquareBracket
    }
}

enum class ClosingSyntaxCharacter: SyntaxCharacter {
    Parenthesis,
    CurlyBracket,
    AngleBracket,
    SquareBracket;

    override fun produceMatchingCharacter(): OpeningSyntaxCharacter = when(this) {
        Parenthesis -> OpeningSyntaxCharacter.Parenthesis
        CurlyBracket -> OpeningSyntaxCharacter.CurlyBracket
        AngleBracket -> OpeningSyntaxCharacter.AngleBracket
        SquareBracket -> OpeningSyntaxCharacter.SquareBracket
    }

    fun toSyntaxErrorScore(): Int = when(this) {
        Parenthesis -> 3
        CurlyBracket -> 1197
        AngleBracket -> 25137
        SquareBracket -> 57
    }

    fun toAutocompleteScore(): Int = when(this) {
        Parenthesis -> 1
        CurlyBracket -> 3
        AngleBracket -> 4
        SquareBracket -> 2
    }
}

fun Char.toSyntaxCharacter():SyntaxCharacter = when(this){
    '(' -> OpeningSyntaxCharacter.Parenthesis
    '{' -> OpeningSyntaxCharacter.CurlyBracket
    '<' -> OpeningSyntaxCharacter.AngleBracket
    '[' -> OpeningSyntaxCharacter.SquareBracket

    ')' -> ClosingSyntaxCharacter.Parenthesis
    '}' -> ClosingSyntaxCharacter.CurlyBracket
    '>' -> ClosingSyntaxCharacter.AngleBracket
    ']' -> ClosingSyntaxCharacter.SquareBracket
    else -> { throw IllegalArgumentException("unknown opening Character") }
}

class SyntaxScorer {
    private val input = SyntaxScorer::class.java.getResource("/input/puzzle10.txt")
        ?.readText()
        ?.split("\n")
        ?.map {
            it.fold(mutableListOf()) { acc: MutableList<SyntaxCharacter>, c: Char ->
                acc.apply { add(c.toSyntaxCharacter()) }
            }.toList()
        }
        ?: listOf()

    fun fixBrokenLines(): Int {
       return input.fold(mutableListOf()) { acc: MutableList<LineProblem.SyntaxErrorProblem>, line: List<SyntaxCharacter> ->
            acc.apply {
                findProblemInLine(line)
                    .takeIf { it is LineProblem.SyntaxErrorProblem }
                    ?.also { add(it as LineProblem.SyntaxErrorProblem) }
            }
        }
           .sumOf { it.illegalClosingCharacter.toSyntaxErrorScore() }
    }

    fun fixIncompleteLines(): Long {
         val lineProblems = input.fold(mutableListOf()) { acc: MutableList<LineProblem.IncompleteLineProblem>, line: List<SyntaxCharacter> ->
            acc.apply {
                findProblemInLine(line)
                    .takeIf { it is LineProblem.IncompleteLineProblem }
                    ?.also { add(it as LineProblem.IncompleteLineProblem) }
            }
        }.toList()

        val result = lineProblems.map {
            it.orphanedOpeningCharacterList
                .reversed()
                .fold(0L) { acc: Long, openingSyntaxCharacter: OpeningSyntaxCharacter ->
                    acc * 5 + openingSyntaxCharacter.produceMatchingCharacter().toAutocompleteScore()
                }
        }
            .sortedBy { it }

        return result[result.size.floorDiv(2)]
    }

    private companion object {

        sealed class LineProblem{
            data class SyntaxErrorProblem(val illegalClosingCharacter: ClosingSyntaxCharacter): LineProblem()
            data class IncompleteLineProblem(val orphanedOpeningCharacterList: List<OpeningSyntaxCharacter>): LineProblem()
        }

        private fun findProblemInLine(line: List<SyntaxCharacter>): LineProblem {
            val openingCharacters = mutableListOf<OpeningSyntaxCharacter>()
            for (character in line){
                if (character is ClosingSyntaxCharacter) {
                    if (openingCharacters.isEmpty()){
                        return LineProblem.SyntaxErrorProblem(character)
                    } else if (openingCharacters.last().produceMatchingCharacter() != character) {
                        return LineProblem.SyntaxErrorProblem(character)
                    } else {
                        openingCharacters.removeLast()
                    }
                }
                else if (character is OpeningSyntaxCharacter) {
                    openingCharacters.add(character)
                }
                else {
                    throw IllegalStateException("character: $character is neither an opening nor a closing syntax char")
                }
            }
            return LineProblem.IncompleteLineProblem(openingCharacters.toList())
        }
    }
}

Compiled from "SyntaxScorer.kt"
public final class puzzle10.SyntaxScorer$Companion$LineProblem$IncompleteLineProblem extends puzzle10.SyntaxScorer$Companion$LineProblem {
  private final java.util.List<puzzle10.OpeningSyntaxCharacter> orphanedOpeningCharacterList;

  public puzzle10.SyntaxScorer$Companion$LineProblem$IncompleteLineProblem(java.util.List<? extends puzzle10.OpeningSyntaxCharacter>);
    Code:
       0: aload_1
       1: ldc           #10                 // String orphanedOpeningCharacterList
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aconst_null
       8: invokespecial #19                 // Method puzzle10/SyntaxScorer$Companion$LineProblem."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
      11: aload_0
      12: aload_1
      13: putfield      #22                 // Field orphanedOpeningCharacterList:Ljava/util/List;
      16: return

  public final java.util.List<puzzle10.OpeningSyntaxCharacter> getOrphanedOpeningCharacterList();
    Code:
       0: aload_0
       1: getfield      #22                 // Field orphanedOpeningCharacterList:Ljava/util/List;
       4: areturn

  public final java.util.List<puzzle10.OpeningSyntaxCharacter> component1();
    Code:
       0: aload_0
       1: getfield      #22                 // Field orphanedOpeningCharacterList:Ljava/util/List;
       4: areturn

  public final puzzle10.SyntaxScorer$Companion$LineProblem$IncompleteLineProblem copy(java.util.List<? extends puzzle10.OpeningSyntaxCharacter>);
    Code:
       0: aload_1
       1: ldc           #10                 // String orphanedOpeningCharacterList
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #2                  // class puzzle10/SyntaxScorer$Companion$LineProblem$IncompleteLineProblem
       9: dup
      10: aload_1
      11: invokespecial #33                 // Method "<init>":(Ljava/util/List;)V
      14: areturn

  public static puzzle10.SyntaxScorer$Companion$LineProblem$IncompleteLineProblem copy$default(puzzle10.SyntaxScorer$Companion$LineProblem$IncompleteLineProblem, java.util.List, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_1
       2: iand
       3: ifeq          11
       6: aload_0
       7: getfield      #22                 // Field orphanedOpeningCharacterList:Ljava/util/List;
      10: astore_1
      11: aload_0
      12: aload_1
      13: invokevirtual #37                 // Method copy:(Ljava/util/List;)Lpuzzle10/SyntaxScorer$Companion$LineProblem$IncompleteLineProblem;
      16: areturn

  public java.lang.String toString();
    Code:
       0: new           #41                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #44                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #46                 // String IncompleteLineProblem(orphanedOpeningCharacterList=
       9: invokevirtual #50                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #22                 // Field orphanedOpeningCharacterList:Ljava/util/List;
      16: invokevirtual #53                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      19: bipush        41
      21: invokevirtual #56                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      24: invokevirtual #58                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      27: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #22                 // Field orphanedOpeningCharacterList:Ljava/util/List;
       4: invokevirtual #64                 // Method java/lang/Object.hashCode:()I
       7: 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 puzzle10/SyntaxScorer$Companion$LineProblem$IncompleteLineProblem
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class puzzle10/SyntaxScorer$Companion$LineProblem$IncompleteLineProblem
      20: astore_2
      21: aload_0
      22: getfield      #22                 // Field orphanedOpeningCharacterList:Ljava/util/List;
      25: aload_2
      26: getfield      #22                 // Field orphanedOpeningCharacterList:Ljava/util/List;
      29: invokestatic  #71                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      32: ifne          37
      35: iconst_0
      36: ireturn
      37: iconst_1
      38: ireturn
}

Compiled from "SyntaxScorer.kt"
public final class puzzle10.SyntaxScorer {
  private static final puzzle10.SyntaxScorer$Companion Companion;

  private final java.util.List<java.util.List<puzzle10.SyntaxCharacter>> input;

  public puzzle10.SyntaxScorer();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: ldc           #2                  // class puzzle10/SyntaxScorer
       7: ldc           #10                 // String /input/puzzle10.txt
       9: invokevirtual #16                 // Method java/lang/Class.getResource:(Ljava/lang/String;)Ljava/net/URL;
      12: astore_1
      13: aload_1
      14: ifnull        276
      17: aload_1
      18: astore_2
      19: getstatic     #22                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      22: astore_3
      23: aload_2
      24: invokestatic  #28                 // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B
      27: astore        4
      29: new           #30                 // class java/lang/String
      32: dup
      33: aload         4
      35: aload_3
      36: invokespecial #33                 // Method java/lang/String."<init>":([BLjava/nio/charset/Charset;)V
      39: checkcast     #35                 // class java/lang/CharSequence
      42: iconst_1
      43: anewarray     #30                 // class java/lang/String
      46: astore_3
      47: aload_3
      48: iconst_0
      49: ldc           #37                 // String \n
      51: aastore
      52: aload_3
      53: iconst_0
      54: iconst_0
      55: bipush        6
      57: aconst_null
      58: invokestatic  #43                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      61: astore_2
      62: aload_2
      63: ifnull        276
      66: aload_2
      67: checkcast     #45                 // class java/lang/Iterable
      70: astore        4
      72: astore        25
      74: iconst_0
      75: istore        5
      77: aload         4
      79: astore        6
      81: new           #47                 // class java/util/ArrayList
      84: dup
      85: aload         4
      87: bipush        10
      89: invokestatic  #53                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      92: invokespecial #56                 // Method java/util/ArrayList."<init>":(I)V
      95: checkcast     #58                 // class java/util/Collection
      98: astore        7
     100: iconst_0
     101: istore        8
     103: aload         6
     105: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     110: astore        9
     112: aload         9
     114: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     119: ifeq          264
     122: aload         9
     124: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     129: astore        10
     131: aload         7
     133: aload         10
     135: checkcast     #30                 // class java/lang/String
     138: astore        11
     140: astore        26
     142: iconst_0
     143: istore        12
     145: aload         11
     147: checkcast     #35                 // class java/lang/CharSequence
     150: astore        13
     152: new           #47                 // class java/util/ArrayList
     155: dup
     156: invokespecial #73                 // Method java/util/ArrayList."<init>":()V
     159: checkcast     #75                 // class java/util/List
     162: astore        14
     164: nop
     165: iconst_0
     166: istore        15
     168: aload         14
     170: astore        16
     172: iconst_0
     173: istore        17
     175: iload         17
     177: aload         13
     179: invokeinterface #79,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     184: if_icmpge     244
     187: aload         13
     189: iload         17
     191: invokeinterface #83,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     196: istore        18
     198: aload         16
     200: iload         18
     202: istore        19
     204: astore        20
     206: iconst_0
     207: istore        21
     209: aload         20
     211: astore        22
     213: aload         22
     215: astore        23
     217: iconst_0
     218: istore        24
     220: aload         23
     222: iload         19
     224: invokestatic  #89                 // Method puzzle10/SyntaxScorerKt.toSyntaxCharacter:(C)Lpuzzle10/SyntaxCharacter;
     227: invokeinterface #93,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     232: pop
     233: aload         22
     235: nop
     236: astore        16
     238: iinc          17, 1
     241: goto          175
     244: aload         16
     246: checkcast     #45                 // class java/lang/Iterable
     249: invokestatic  #97                 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     252: aload         26
     254: swap
     255: invokeinterface #98,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     260: pop
     261: goto          112
     264: aload         7
     266: checkcast     #75                 // class java/util/List
     269: nop
     270: aload         25
     272: swap
     273: goto          279
     276: invokestatic  #102                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     279: putfield      #106                // Field input:Ljava/util/List;
     282: return

  public final int fixBrokenLines();
    Code:
       0: aload_0
       1: getfield      #106                // Field input:Ljava/util/List;
       4: checkcast     #45                 // class java/lang/Iterable
       7: astore_1
       8: new           #47                 // class java/util/ArrayList
      11: dup
      12: invokespecial #73                 // Method java/util/ArrayList."<init>":()V
      15: checkcast     #75                 // class java/util/List
      18: astore_2
      19: nop
      20: iconst_0
      21: istore_3
      22: aload_2
      23: astore        4
      25: aload_1
      26: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      31: astore        5
      33: aload         5
      35: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      40: ifeq          152
      43: aload         5
      45: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      50: astore        6
      52: aload         4
      54: aload         6
      56: checkcast     #75                 // class java/util/List
      59: astore        7
      61: astore        8
      63: iconst_0
      64: istore        9
      66: aload         8
      68: astore        10
      70: aload         10
      72: astore        11
      74: iconst_0
      75: istore        12
      77: getstatic     #142                // Field Companion:Lpuzzle10/SyntaxScorer$Companion;
      80: aload         7
      82: invokestatic  #148                // Method puzzle10/SyntaxScorer$Companion.access$findProblemInLine:(Lpuzzle10/SyntaxScorer$Companion;Ljava/util/List;)Lpuzzle10/SyntaxScorer$Companion$LineProblem;
      85: astore        13
      87: aload         13
      89: astore        14
      91: iconst_0
      92: istore        15
      94: aload         14
      96: instanceof    #150                // class puzzle10/SyntaxScorer$Companion$LineProblem$SyntaxErrorProblem
      99: ifeq          107
     102: aload         13
     104: goto          108
     107: aconst_null
     108: astore        16
     110: aload         16
     112: ifnull        142
     115: aload         16
     117: astore        13
     119: aload         13
     121: astore        14
     123: iconst_0
     124: istore        15
     126: aload         11
     128: aload         14
     130: checkcast     #150                // class puzzle10/SyntaxScorer$Companion$LineProblem$SyntaxErrorProblem
     133: invokeinterface #93,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     138: pop
     139: goto          143
     142: nop
     143: nop
     144: aload         10
     146: nop
     147: astore        4
     149: goto          33
     152: aload         4
     154: checkcast     #45                 // class java/lang/Iterable
     157: astore_1
     158: iconst_0
     159: istore_2
     160: aload_1
     161: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     166: astore_3
     167: aload_3
     168: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     173: ifeq          216
     176: aload_3
     177: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     182: astore        4
     184: iload_2
     185: aload         4
     187: checkcast     #150                // class puzzle10/SyntaxScorer$Companion$LineProblem$SyntaxErrorProblem
     190: astore        5
     192: istore        17
     194: iconst_0
     195: istore        6
     197: aload         5
     199: invokevirtual #154                // Method puzzle10/SyntaxScorer$Companion$LineProblem$SyntaxErrorProblem.getIllegalClosingCharacter:()Lpuzzle10/ClosingSyntaxCharacter;
     202: invokevirtual #159                // Method puzzle10/ClosingSyntaxCharacter.toSyntaxErrorScore:()I
     205: istore        18
     207: iload         17
     209: iload         18
     211: iadd
     212: istore_2
     213: goto          167
     216: iload_2
     217: ireturn

  public final long fixIncompleteLines();
    Code:
       0: aload_0
       1: getfield      #106                // Field input:Ljava/util/List;
       4: checkcast     #45                 // class java/lang/Iterable
       7: astore_2
       8: new           #47                 // class java/util/ArrayList
      11: dup
      12: invokespecial #73                 // Method java/util/ArrayList."<init>":()V
      15: checkcast     #75                 // class java/util/List
      18: astore_3
      19: nop
      20: iconst_0
      21: istore        4
      23: aload_3
      24: astore        5
      26: aload_2
      27: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      32: astore        6
      34: aload         6
      36: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      41: ifeq          153
      44: aload         6
      46: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      51: astore        7
      53: aload         5
      55: aload         7
      57: checkcast     #75                 // class java/util/List
      60: astore        8
      62: astore        9
      64: iconst_0
      65: istore        10
      67: aload         9
      69: astore        11
      71: aload         11
      73: astore        12
      75: iconst_0
      76: istore        13
      78: getstatic     #142                // Field Companion:Lpuzzle10/SyntaxScorer$Companion;
      81: aload         8
      83: invokestatic  #148                // Method puzzle10/SyntaxScorer$Companion.access$findProblemInLine:(Lpuzzle10/SyntaxScorer$Companion;Ljava/util/List;)Lpuzzle10/SyntaxScorer$Companion$LineProblem;
      86: astore        15
      88: aload         15
      90: astore        16
      92: iconst_0
      93: istore        18
      95: aload         16
      97: instanceof    #174                // class puzzle10/SyntaxScorer$Companion$LineProblem$IncompleteLineProblem
     100: ifeq          108
     103: aload         15
     105: goto          109
     108: aconst_null
     109: astore        19
     111: aload         19
     113: ifnull        143
     116: aload         19
     118: astore        15
     120: aload         15
     122: astore        16
     124: iconst_0
     125: istore        18
     127: aload         12
     129: aload         16
     131: checkcast     #174                // class puzzle10/SyntaxScorer$Companion$LineProblem$IncompleteLineProblem
     134: invokeinterface #93,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     139: pop
     140: goto          144
     143: nop
     144: nop
     145: aload         11
     147: nop
     148: astore        5
     150: goto          34
     153: aload         5
     155: checkcast     #45                 // class java/lang/Iterable
     158: invokestatic  #97                 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     161: astore_1
     162: aload_1
     163: checkcast     #45                 // class java/lang/Iterable
     166: astore_3
     167: iconst_0
     168: istore        4
     170: aload_3
     171: astore        5
     173: new           #47                 // class java/util/ArrayList
     176: dup
     177: aload_3
     178: bipush        10
     180: invokestatic  #53                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     183: invokespecial #56                 // Method java/util/ArrayList."<init>":(I)V
     186: checkcast     #58                 // class java/util/Collection
     189: astore        6
     191: iconst_0
     192: istore        7
     194: aload         5
     196: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     201: astore        8
     203: aload         8
     205: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     210: ifeq          342
     213: aload         8
     215: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     220: astore        9
     222: aload         6
     224: aload         9
     226: checkcast     #174                // class puzzle10/SyntaxScorer$Companion$LineProblem$IncompleteLineProblem
     229: astore        10
     231: astore        24
     233: iconst_0
     234: istore        11
     236: aload         10
     238: invokevirtual #177                // Method puzzle10/SyntaxScorer$Companion$LineProblem$IncompleteLineProblem.getOrphanedOpeningCharacterList:()Ljava/util/List;
     241: checkcast     #45                 // class java/lang/Iterable
     244: invokestatic  #180                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
     247: checkcast     #45                 // class java/lang/Iterable
     250: astore        12
     252: lconst_0
     253: lstore        13
     255: iconst_0
     256: istore        15
     258: lload         13
     260: lstore        16
     262: aload         12
     264: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     269: astore        18
     271: aload         18
     273: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     278: ifeq          324
     281: aload         18
     283: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     288: astore        19
     290: lload         16
     292: aload         19
     294: checkcast     #182                // class puzzle10/OpeningSyntaxCharacter
     297: astore        20
     299: lstore        21
     301: iconst_0
     302: istore        23
     304: lload         21
     306: iconst_5
     307: i2l
     308: lmul
     309: aload         20
     311: invokevirtual #185                // Method puzzle10/OpeningSyntaxCharacter.produceMatchingCharacter:()Lpuzzle10/ClosingSyntaxCharacter;
     314: invokevirtual #188                // Method puzzle10/ClosingSyntaxCharacter.toAutocompleteScore:()I
     317: i2l
     318: ladd
     319: lstore        16
     321: goto          271
     324: lload         16
     326: nop
     327: invokestatic  #194                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     330: aload         24
     332: swap
     333: invokeinterface #98,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     338: pop
     339: goto          203
     342: aload         6
     344: checkcast     #75                 // class java/util/List
     347: nop
     348: checkcast     #45                 // class java/lang/Iterable
     351: astore_3
     352: nop
     353: iconst_0
     354: istore        4
     356: aload_3
     357: new           #196                // class puzzle10/SyntaxScorer$fixIncompleteLines$$inlined$sortedBy$1
     360: dup
     361: invokespecial #197                // Method puzzle10/SyntaxScorer$fixIncompleteLines$$inlined$sortedBy$1."<init>":()V
     364: checkcast     #199                // class java/util/Comparator
     367: invokestatic  #203                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
     370: astore_2
     371: aload_2
     372: aload_2
     373: invokeinterface #206,  1          // InterfaceMethod java/util/List.size:()I
     378: istore_3
     379: iconst_2
     380: istore        4
     382: iload_3
     383: iload         4
     385: idiv
     386: istore        5
     388: iload_3
     389: iload         4
     391: ixor
     392: ifge          407
     395: iload         5
     397: iload         4
     399: imul
     400: iload_3
     401: if_icmpeq     407
     404: iinc          5, -1
     407: iload         5
     409: invokeinterface #210,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     414: checkcast     #212                // class java/lang/Number
     417: invokevirtual #215                // Method java/lang/Number.longValue:()J
     420: lreturn

  static {};
    Code:
       0: new           #144                // class puzzle10/SyntaxScorer$Companion
       3: dup
       4: aconst_null
       5: invokespecial #234                // Method puzzle10/SyntaxScorer$Companion."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: putstatic     #142                // Field Companion:Lpuzzle10/SyntaxScorer$Companion;
      11: return
}

Compiled from "SyntaxScorer.kt"
final class puzzle10.SyntaxScorer$Companion {
  private puzzle10.SyntaxScorer$Companion();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  private final puzzle10.SyntaxScorer$Companion$LineProblem findProblemInLine(java.util.List<? extends puzzle10.SyntaxCharacter>);
    Code:
       0: new           #15                 // class java/util/ArrayList
       3: dup
       4: invokespecial #16                 // Method java/util/ArrayList."<init>":()V
       7: checkcast     #18                 // class java/util/List
      10: astore_2
      11: aload_1
      12: invokeinterface #22,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      17: astore_3
      18: aload_3
      19: invokeinterface #28,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      24: ifeq          174
      27: aload_3
      28: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      33: checkcast     #34                 // class puzzle10/SyntaxCharacter
      36: astore        4
      38: aload         4
      40: instanceof    #36                 // class puzzle10/ClosingSyntaxCharacter
      43: ifeq          121
      46: aload_2
      47: invokeinterface #39,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      52: ifeq          71
      55: new           #41                 // class puzzle10/SyntaxScorer$Companion$LineProblem$SyntaxErrorProblem
      58: dup
      59: aload         4
      61: checkcast     #36                 // class puzzle10/ClosingSyntaxCharacter
      64: invokespecial #44                 // Method puzzle10/SyntaxScorer$Companion$LineProblem$SyntaxErrorProblem."<init>":(Lpuzzle10/ClosingSyntaxCharacter;)V
      67: checkcast     #46                 // class puzzle10/SyntaxScorer$Companion$LineProblem
      70: areturn
      71: aload_2
      72: invokestatic  #52                 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
      75: checkcast     #54                 // class puzzle10/OpeningSyntaxCharacter
      78: invokevirtual #58                 // Method puzzle10/OpeningSyntaxCharacter.produceMatchingCharacter:()Lpuzzle10/ClosingSyntaxCharacter;
      81: aload         4
      83: if_acmpeq     102
      86: new           #41                 // class puzzle10/SyntaxScorer$Companion$LineProblem$SyntaxErrorProblem
      89: dup
      90: aload         4
      92: checkcast     #36                 // class puzzle10/ClosingSyntaxCharacter
      95: invokespecial #44                 // Method puzzle10/SyntaxScorer$Companion$LineProblem$SyntaxErrorProblem."<init>":(Lpuzzle10/ClosingSyntaxCharacter;)V
      98: checkcast     #46                 // class puzzle10/SyntaxScorer$Companion$LineProblem
     101: areturn
     102: aload_2
     103: invokeinterface #61,  1           // InterfaceMethod java/util/List.removeLast:()Ljava/lang/Object;
     108: checkcast     #54                 // class puzzle10/OpeningSyntaxCharacter
     111: astore        5
     113: aload         5
     115: invokestatic  #67                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     118: goto          18
     121: aload         4
     123: instanceof    #54                 // class puzzle10/OpeningSyntaxCharacter
     126: ifeq          141
     129: aload_2
     130: aload         4
     132: invokeinterface #71,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     137: pop
     138: goto          18
     141: new           #73                 // class java/lang/IllegalStateException
     144: dup
     145: new           #75                 // class java/lang/StringBuilder
     148: dup
     149: invokespecial #76                 // Method java/lang/StringBuilder."<init>":()V
     152: ldc           #78                 // String character:
     154: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     157: aload         4
     159: invokevirtual #85                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     162: ldc           #87                 // String  is neither an opening nor a closing syntax char
     164: invokevirtual #82                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     167: invokevirtual #91                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     170: invokespecial #94                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     173: athrow
     174: new           #96                 // class puzzle10/SyntaxScorer$Companion$LineProblem$IncompleteLineProblem
     177: dup
     178: aload_2
     179: checkcast     #98                 // class java/lang/Iterable
     182: invokestatic  #102                // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     185: invokespecial #105                // Method puzzle10/SyntaxScorer$Companion$LineProblem$IncompleteLineProblem."<init>":(Ljava/util/List;)V
     188: checkcast     #46                 // class puzzle10/SyntaxScorer$Companion$LineProblem
     191: areturn

  public static final puzzle10.SyntaxScorer$Companion$LineProblem access$findProblemInLine(puzzle10.SyntaxScorer$Companion, java.util.List);
    Code:
       0: aload_0
       1: aload_1
       2: invokespecial #114                // Method findProblemInLine:(Ljava/util/List;)Lpuzzle10/SyntaxScorer$Companion$LineProblem;
       5: areturn

  public puzzle10.SyntaxScorer$Companion(kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: aload_0
       1: invokespecial #117                // Method "<init>":()V
       4: return
}

Compiled from "Comparisons.kt"
public final class puzzle10.SyntaxScorer$fixIncompleteLines$$inlined$sortedBy$1<T> implements java.util.Comparator {
  public puzzle10.SyntaxScorer$fixIncompleteLines$$inlined$sortedBy$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 java/lang/Number
       4: invokevirtual #27                 // Method java/lang/Number.longValue:()J
       7: lstore_3
       8: iconst_0
       9: istore        5
      11: lload_3
      12: invokestatic  #33                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      15: checkcast     #35                 // class java/lang/Comparable
      18: aload_2
      19: checkcast     #23                 // class java/lang/Number
      22: invokevirtual #27                 // Method java/lang/Number.longValue:()J
      25: lstore_3
      26: astore        6
      28: iconst_0
      29: istore        5
      31: lload_3
      32: invokestatic  #33                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      35: aload         6
      37: swap
      38: checkcast     #35                 // class java/lang/Comparable
      41: invokestatic  #41                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      44: ireturn
}

Compiled from "SyntaxScorer.kt"
public final class puzzle10.SyntaxScorerKt {
  public static final void main();
    Code:
       0: new           #8                  // class puzzle10/SyntaxScorer
       3: dup
       4: invokespecial #11                 // Method puzzle10/SyntaxScorer."<init>":()V
       7: astore_0
       8: iconst_0
       9: istore_3
      10: invokestatic  #17                 // Method java/lang/System.currentTimeMillis:()J
      13: lstore        4
      15: iconst_0
      16: istore        6
      18: new           #19                 // class java/lang/StringBuilder
      21: dup
      22: invokespecial #20                 // Method java/lang/StringBuilder."<init>":()V
      25: ldc           #22                 // String Bad line scoring:
      27: invokevirtual #26                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      30: aload_0
      31: invokevirtual #30                 // Method puzzle10/SyntaxScorer.fixBrokenLines:()I
      34: invokevirtual #33                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      37: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      40: getstatic     #41                 // Field java/lang/System.out:Ljava/io/PrintStream;
      43: swap
      44: invokevirtual #47                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      47: new           #19                 // class java/lang/StringBuilder
      50: dup
      51: invokespecial #20                 // Method java/lang/StringBuilder."<init>":()V
      54: ldc           #49                 // String Incomplete line scoring:
      56: invokevirtual #26                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      59: aload_0
      60: invokevirtual #52                 // Method puzzle10/SyntaxScorer.fixIncompleteLines:()J
      63: invokevirtual #55                 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
      66: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      69: getstatic     #41                 // Field java/lang/System.out:Ljava/io/PrintStream;
      72: swap
      73: invokevirtual #47                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      76: nop
      77: nop
      78: invokestatic  #17                 // Method java/lang/System.currentTimeMillis:()J
      81: lload         4
      83: lsub
      84: lstore_1
      85: new           #19                 // class java/lang/StringBuilder
      88: dup
      89: invokespecial #20                 // Method java/lang/StringBuilder."<init>":()V
      92: ldc           #57                 // String time:
      94: invokevirtual #26                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      97: lload_1
      98: invokevirtual #55                 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     101: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     104: getstatic     #41                 // Field java/lang/System.out:Ljava/io/PrintStream;
     107: swap
     108: invokevirtual #47                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     111: return

  public static final puzzle10.SyntaxCharacter toSyntaxCharacter(char);
    Code:
       0: iload_0
       1: lookupswitch  { // 8
                    40: 76
                    41: 112
                    60: 94
                    62: 130
                    91: 103
                    93: 139
                   123: 85
                   125: 121
               default: 148
          }
      76: getstatic     #74                 // Field puzzle10/OpeningSyntaxCharacter.Parenthesis:Lpuzzle10/OpeningSyntaxCharacter;
      79: checkcast     #76                 // class puzzle10/SyntaxCharacter
      82: goto          158
      85: getstatic     #79                 // Field puzzle10/OpeningSyntaxCharacter.CurlyBracket:Lpuzzle10/OpeningSyntaxCharacter;
      88: checkcast     #76                 // class puzzle10/SyntaxCharacter
      91: goto          158
      94: getstatic     #82                 // Field puzzle10/OpeningSyntaxCharacter.AngleBracket:Lpuzzle10/OpeningSyntaxCharacter;
      97: checkcast     #76                 // class puzzle10/SyntaxCharacter
     100: goto          158
     103: getstatic     #85                 // Field puzzle10/OpeningSyntaxCharacter.SquareBracket:Lpuzzle10/OpeningSyntaxCharacter;
     106: checkcast     #76                 // class puzzle10/SyntaxCharacter
     109: goto          158
     112: getstatic     #90                 // Field puzzle10/ClosingSyntaxCharacter.Parenthesis:Lpuzzle10/ClosingSyntaxCharacter;
     115: checkcast     #76                 // class puzzle10/SyntaxCharacter
     118: goto          158
     121: getstatic     #92                 // Field puzzle10/ClosingSyntaxCharacter.CurlyBracket:Lpuzzle10/ClosingSyntaxCharacter;
     124: checkcast     #76                 // class puzzle10/SyntaxCharacter
     127: goto          158
     130: getstatic     #94                 // Field puzzle10/ClosingSyntaxCharacter.AngleBracket:Lpuzzle10/ClosingSyntaxCharacter;
     133: checkcast     #76                 // class puzzle10/SyntaxCharacter
     136: goto          158
     139: getstatic     #96                 // Field puzzle10/ClosingSyntaxCharacter.SquareBracket:Lpuzzle10/ClosingSyntaxCharacter;
     142: checkcast     #76                 // class puzzle10/SyntaxCharacter
     145: goto          158
     148: new           #98                 // class java/lang/IllegalArgumentException
     151: dup
     152: ldc           #100                // String unknown opening Character
     154: invokespecial #103                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     157: athrow
     158: areturn

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

Compiled from "SyntaxScorer.kt"
public final class puzzle10.SyntaxScorer$Companion$LineProblem$SyntaxErrorProblem extends puzzle10.SyntaxScorer$Companion$LineProblem {
  private final puzzle10.ClosingSyntaxCharacter illegalClosingCharacter;

  public puzzle10.SyntaxScorer$Companion$LineProblem$SyntaxErrorProblem(puzzle10.ClosingSyntaxCharacter);
    Code:
       0: aload_1
       1: ldc           #9                  // String illegalClosingCharacter
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aconst_null
       8: invokespecial #18                 // Method puzzle10/SyntaxScorer$Companion$LineProblem."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
      11: aload_0
      12: aload_1
      13: putfield      #21                 // Field illegalClosingCharacter:Lpuzzle10/ClosingSyntaxCharacter;
      16: return

  public final puzzle10.ClosingSyntaxCharacter getIllegalClosingCharacter();
    Code:
       0: aload_0
       1: getfield      #21                 // Field illegalClosingCharacter:Lpuzzle10/ClosingSyntaxCharacter;
       4: areturn

  public final puzzle10.ClosingSyntaxCharacter component1();
    Code:
       0: aload_0
       1: getfield      #21                 // Field illegalClosingCharacter:Lpuzzle10/ClosingSyntaxCharacter;
       4: areturn

  public final puzzle10.SyntaxScorer$Companion$LineProblem$SyntaxErrorProblem copy(puzzle10.ClosingSyntaxCharacter);
    Code:
       0: aload_1
       1: ldc           #9                  // String illegalClosingCharacter
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #2                  // class puzzle10/SyntaxScorer$Companion$LineProblem$SyntaxErrorProblem
       9: dup
      10: aload_1
      11: invokespecial #30                 // Method "<init>":(Lpuzzle10/ClosingSyntaxCharacter;)V
      14: areturn

  public static puzzle10.SyntaxScorer$Companion$LineProblem$SyntaxErrorProblem copy$default(puzzle10.SyntaxScorer$Companion$LineProblem$SyntaxErrorProblem, puzzle10.ClosingSyntaxCharacter, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_1
       2: iand
       3: ifeq          11
       6: aload_0
       7: getfield      #21                 // Field illegalClosingCharacter:Lpuzzle10/ClosingSyntaxCharacter;
      10: astore_1
      11: aload_0
      12: aload_1
      13: invokevirtual #34                 // Method copy:(Lpuzzle10/ClosingSyntaxCharacter;)Lpuzzle10/SyntaxScorer$Companion$LineProblem$SyntaxErrorProblem;
      16: areturn

  public java.lang.String toString();
    Code:
       0: new           #38                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #41                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #43                 // String SyntaxErrorProblem(illegalClosingCharacter=
       9: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #21                 // Field illegalClosingCharacter:Lpuzzle10/ClosingSyntaxCharacter;
      16: invokevirtual #50                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      19: bipush        41
      21: invokevirtual #53                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      24: invokevirtual #55                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      27: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #21                 // Field illegalClosingCharacter:Lpuzzle10/ClosingSyntaxCharacter;
       4: invokevirtual #61                 // Method puzzle10/ClosingSyntaxCharacter.hashCode:()I
       7: 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 puzzle10/SyntaxScorer$Companion$LineProblem$SyntaxErrorProblem
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class puzzle10/SyntaxScorer$Companion$LineProblem$SyntaxErrorProblem
      20: astore_2
      21: aload_0
      22: getfield      #21                 // Field illegalClosingCharacter:Lpuzzle10/ClosingSyntaxCharacter;
      25: aload_2
      26: getfield      #21                 // Field illegalClosingCharacter:Lpuzzle10/ClosingSyntaxCharacter;
      29: if_acmpeq     34
      32: iconst_0
      33: ireturn
      34: iconst_1
      35: ireturn
}

Compiled from "SyntaxScorer.kt"
public abstract class puzzle10.SyntaxScorer$Companion$LineProblem {
  private puzzle10.SyntaxScorer$Companion$LineProblem();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public puzzle10.SyntaxScorer$Companion$LineProblem(kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: aload_0
       1: invokespecial #12                 // Method "<init>":()V
       4: return
}


package puzzle7

import kotlin.math.abs
import kotlin.math.floor
import kotlin.math.roundToInt
import kotlin.system.measureTimeMillis

fun main() {
    val whaleBuster = WhaleBuster()
    val time = measureTimeMillis {
        println("Minimal fuel consumption is: ${whaleBuster.findCrabAlignment()}")
        println("Total fuel consumption with cost increased by distance is: ${whaleBuster.findCrabAlignmentWithCostProblems()}")
    }

    println("Time: ${time}ms")
}

class WhaleBuster {
    private val input = WhaleBuster::class.java.getResource("/input/puzzle7.txt")
        ?.readText()
        ?.split(",")
        ?.map { it.toInt() }
        ?: listOf()

    fun findCrabAlignment(): Int {
        val distanceValues = (0..input.maxOf { it }).associateWith { position ->
            input.sumOf { crabPosition ->
                abs(crabPosition - position)
            }
        }
        println(distanceValues)
        val inputNumber = input.size
        val sortedInput = input.sorted()

        val median = if (inputNumber % 2 == 1) {
            sortedInput[floor(inputNumber / 2.0).toInt()]
        } else {
            (sortedInput[inputNumber / 2] + sortedInput[inputNumber / 2]) / 2
        }

        println("median is: $median")

        return sortedInput.sumOf { abs(it - median) }
    }

    fun findCrabAlignmentWithCostProblems(): Int {
        val distanceValues = (0..input.maxOf { it }).associateWith { position ->
            input.sumOf { crabPosition ->
                val distance = abs(crabPosition - position)
                (distance * (distance + 1) / 2.0).roundToInt()
            }
        }
        val optimalPosition = distanceValues.minByOrNull { it.value }
        println("Optimal Position is: $optimalPosition")
        return optimalPosition?.value ?: 0
    }
}

Compiled from "WhaleBuster.kt"
public final class puzzle7.WhaleBusterKt {
  public static final void main();
    Code:
       0: new           #8                  // class puzzle7/WhaleBuster
       3: dup
       4: invokespecial #11                 // Method puzzle7/WhaleBuster."<init>":()V
       7: astore_0
       8: iconst_0
       9: istore_3
      10: invokestatic  #17                 // Method java/lang/System.currentTimeMillis:()J
      13: lstore        4
      15: iconst_0
      16: istore        6
      18: new           #19                 // class java/lang/StringBuilder
      21: dup
      22: invokespecial #20                 // Method java/lang/StringBuilder."<init>":()V
      25: ldc           #22                 // String Minimal fuel consumption is:
      27: invokevirtual #26                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      30: aload_0
      31: invokevirtual #30                 // Method puzzle7/WhaleBuster.findCrabAlignment:()I
      34: invokevirtual #33                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      37: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      40: getstatic     #41                 // Field java/lang/System.out:Ljava/io/PrintStream;
      43: swap
      44: invokevirtual #47                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      47: new           #19                 // class java/lang/StringBuilder
      50: dup
      51: invokespecial #20                 // Method java/lang/StringBuilder."<init>":()V
      54: ldc           #49                 // String Total fuel consumption with cost increased by distance is:
      56: invokevirtual #26                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      59: aload_0
      60: invokevirtual #52                 // Method puzzle7/WhaleBuster.findCrabAlignmentWithCostProblems:()I
      63: invokevirtual #33                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      66: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      69: getstatic     #41                 // Field java/lang/System.out:Ljava/io/PrintStream;
      72: swap
      73: invokevirtual #47                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      76: nop
      77: nop
      78: invokestatic  #17                 // Method java/lang/System.currentTimeMillis:()J
      81: lload         4
      83: lsub
      84: lstore_1
      85: new           #19                 // class java/lang/StringBuilder
      88: dup
      89: invokespecial #20                 // Method java/lang/StringBuilder."<init>":()V
      92: ldc           #54                 // String Time:
      94: invokevirtual #26                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      97: lload_1
      98: invokevirtual #57                 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     101: ldc           #59                 // String ms
     103: invokevirtual #26                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     106: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     109: getstatic     #41                 // Field java/lang/System.out:Ljava/io/PrintStream;
     112: swap
     113: invokevirtual #47                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     116: return

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

Compiled from "WhaleBuster.kt"
public final class puzzle7.WhaleBuster {
  private final java.util.List<java.lang.Integer> input;

  public puzzle7.WhaleBuster();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: ldc           #2                  // class puzzle7/WhaleBuster
       7: ldc           #10                 // String /input/puzzle7.txt
       9: invokevirtual #16                 // Method java/lang/Class.getResource:(Ljava/lang/String;)Ljava/net/URL;
      12: astore_1
      13: aload_1
      14: ifnull        178
      17: aload_1
      18: astore_2
      19: getstatic     #22                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      22: astore_3
      23: aload_2
      24: invokestatic  #28                 // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B
      27: astore        4
      29: new           #30                 // class java/lang/String
      32: dup
      33: aload         4
      35: aload_3
      36: invokespecial #33                 // Method java/lang/String."<init>":([BLjava/nio/charset/Charset;)V
      39: checkcast     #35                 // class java/lang/CharSequence
      42: iconst_1
      43: anewarray     #30                 // class java/lang/String
      46: astore_3
      47: aload_3
      48: iconst_0
      49: ldc           #37                 // String ,
      51: aastore
      52: aload_3
      53: iconst_0
      54: iconst_0
      55: bipush        6
      57: aconst_null
      58: invokestatic  #43                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      61: astore_2
      62: aload_2
      63: ifnull        178
      66: aload_2
      67: checkcast     #45                 // class java/lang/Iterable
      70: astore        4
      72: astore        13
      74: iconst_0
      75: istore        5
      77: aload         4
      79: astore        6
      81: new           #47                 // class java/util/ArrayList
      84: dup
      85: aload         4
      87: bipush        10
      89: invokestatic  #53                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      92: invokespecial #56                 // Method java/util/ArrayList."<init>":(I)V
      95: checkcast     #58                 // class java/util/Collection
      98: astore        7
     100: iconst_0
     101: istore        8
     103: aload         6
     105: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     110: astore        9
     112: aload         9
     114: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     119: ifeq          166
     122: aload         9
     124: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     129: astore        10
     131: aload         7
     133: aload         10
     135: checkcast     #30                 // class java/lang/String
     138: astore        11
     140: astore        14
     142: iconst_0
     143: istore        12
     145: aload         11
     147: invokestatic  #78                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     150: nop
     151: invokestatic  #82                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     154: aload         14
     156: swap
     157: invokeinterface #86,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     162: pop
     163: goto          112
     166: aload         7
     168: checkcast     #88                 // class java/util/List
     171: nop
     172: aload         13
     174: swap
     175: goto          181
     178: invokestatic  #92                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     181: putfield      #96                 // Field input:Ljava/util/List;
     184: return

  public final int findCrabAlignment();
    Code:
       0: iconst_0
       1: aload_0
       2: getfield      #96                 // Field input:Ljava/util/List;
       5: checkcast     #45                 // class java/lang/Iterable
       8: astore_2
       9: istore        21
      11: aload_2
      12: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      17: astore_3
      18: aload_3
      19: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      24: ifne          35
      27: new           #119                // class java/util/NoSuchElementException
      30: dup
      31: invokespecial #120                // Method java/util/NoSuchElementException."<init>":()V
      34: athrow
      35: aload_3
      36: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      41: checkcast     #122                // class java/lang/Number
      44: invokevirtual #125                // Method java/lang/Number.intValue:()I
      47: istore        4
      49: iconst_0
      50: istore        5
      52: iload         4
      54: istore        4
      56: aload_3
      57: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      62: ifeq          100
      65: aload_3
      66: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      71: checkcast     #122                // class java/lang/Number
      74: invokevirtual #125                // Method java/lang/Number.intValue:()I
      77: istore        5
      79: iconst_0
      80: istore        6
      82: iload         5
      84: istore        5
      86: iload         4
      88: iload         5
      90: if_icmpge     56
      93: iload         5
      95: istore        4
      97: goto          56
     100: iload         4
     102: istore        22
     104: iload         21
     106: iload         22
     108: istore        23
     110: istore        24
     112: new           #127                // class kotlin/ranges/IntRange
     115: dup
     116: iload         24
     118: iload         23
     120: invokespecial #130                // Method kotlin/ranges/IntRange."<init>":(II)V
     123: checkcast     #45                 // class java/lang/Iterable
     126: astore_2
     127: iconst_0
     128: istore_3
     129: new           #132                // class java/util/LinkedHashMap
     132: dup
     133: aload_2
     134: bipush        10
     136: invokestatic  #53                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     139: invokestatic  #138                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
     142: bipush        16
     144: invokestatic  #144                // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I
     147: invokespecial #145                // Method java/util/LinkedHashMap."<init>":(I)V
     150: astore        4
     152: aload_2
     153: astore        5
     155: iconst_0
     156: istore        6
     158: aload         5
     160: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     165: astore        7
     167: aload         7
     169: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     174: ifeq          311
     177: aload         7
     179: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     184: astore        8
     186: aload         4
     188: checkcast     #147                // class java/util/Map
     191: aload         8
     193: aload         8
     195: checkcast     #122                // class java/lang/Number
     198: invokevirtual #125                // Method java/lang/Number.intValue:()I
     201: istore        9
     203: astore        20
     205: astore        19
     207: iconst_0
     208: istore        10
     210: aload_0
     211: getfield      #96                 // Field input:Ljava/util/List;
     214: checkcast     #45                 // class java/lang/Iterable
     217: astore        11
     219: iconst_0
     220: istore        12
     222: aload         11
     224: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     229: astore        13
     231: aload         13
     233: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     238: ifeq          288
     241: aload         13
     243: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     248: astore        14
     250: iload         12
     252: aload         14
     254: checkcast     #122                // class java/lang/Number
     257: invokevirtual #125                // Method java/lang/Number.intValue:()I
     260: istore        15
     262: istore        16
     264: iconst_0
     265: istore        17
     267: iload         15
     269: iload         9
     271: isub
     272: invokestatic  #152                // Method java/lang/Math.abs:(I)I
     275: nop
     276: istore        18
     278: iload         16
     280: iload         18
     282: iadd
     283: istore        12
     285: goto          231
     288: iload         12
     290: nop
     291: invokestatic  #82                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     294: astore        21
     296: aload         19
     298: aload         20
     300: aload         21
     302: invokeinterface #156,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     307: pop
     308: goto          167
     311: aload         4
     313: checkcast     #147                // class java/util/Map
     316: nop
     317: astore_1
     318: getstatic     #162                // Field java/lang/System.out:Ljava/io/PrintStream;
     321: aload_1
     322: invokevirtual #168                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     325: aload_0
     326: getfield      #96                 // Field input:Ljava/util/List;
     329: invokeinterface #171,  1          // InterfaceMethod java/util/List.size:()I
     334: istore_2
     335: aload_0
     336: getfield      #96                 // Field input:Ljava/util/List;
     339: checkcast     #45                 // class java/lang/Iterable
     342: invokestatic  #175                // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
     345: astore_3
     346: iload_2
     347: iconst_2
     348: irem
     349: iconst_1
     350: if_icmpne     378
     353: aload_3
     354: iload_2
     355: i2d
     356: ldc2_w        #176                // double 2.0d
     359: ddiv
     360: invokestatic  #181                // Method java/lang/Math.floor:(D)D
     363: d2i
     364: invokeinterface #185,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     369: checkcast     #122                // class java/lang/Number
     372: invokevirtual #125                // Method java/lang/Number.intValue:()I
     375: goto          411
     378: aload_3
     379: iload_2
     380: iconst_2
     381: idiv
     382: invokeinterface #185,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     387: checkcast     #122                // class java/lang/Number
     390: invokevirtual #125                // Method java/lang/Number.intValue:()I
     393: aload_3
     394: iload_2
     395: iconst_2
     396: idiv
     397: invokeinterface #185,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     402: checkcast     #122                // class java/lang/Number
     405: invokevirtual #125                // Method java/lang/Number.intValue:()I
     408: iadd
     409: iconst_2
     410: idiv
     411: istore        4
     413: new           #187                // class java/lang/StringBuilder
     416: dup
     417: invokespecial #188                // Method java/lang/StringBuilder."<init>":()V
     420: ldc           #190                // String median is:
     422: invokevirtual #194                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     425: iload         4
     427: invokevirtual #197                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     430: invokevirtual #201                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     433: getstatic     #162                // Field java/lang/System.out:Ljava/io/PrintStream;
     436: swap
     437: invokevirtual #168                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     440: aload_3
     441: checkcast     #45                 // class java/lang/Iterable
     444: astore        5
     446: iconst_0
     447: istore        6
     449: aload         5
     451: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     456: astore        7
     458: aload         7
     460: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     465: ifeq          515
     468: aload         7
     470: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     475: astore        8
     477: iload         6
     479: aload         8
     481: checkcast     #122                // class java/lang/Number
     484: invokevirtual #125                // Method java/lang/Number.intValue:()I
     487: istore        9
     489: istore        19
     491: iconst_0
     492: istore        10
     494: iload         9
     496: iload         4
     498: isub
     499: invokestatic  #152                // Method java/lang/Math.abs:(I)I
     502: nop
     503: istore        20
     505: iload         19
     507: iload         20
     509: iadd
     510: istore        6
     512: goto          458
     515: iload         6
     517: ireturn

  public final int findCrabAlignmentWithCostProblems();
    Code:
       0: iconst_0
       1: aload_0
       2: getfield      #96                 // Field input:Ljava/util/List;
       5: checkcast     #45                 // class java/lang/Iterable
       8: astore_2
       9: istore        22
      11: aload_2
      12: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      17: astore_3
      18: aload_3
      19: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      24: ifne          35
      27: new           #119                // class java/util/NoSuchElementException
      30: dup
      31: invokespecial #120                // Method java/util/NoSuchElementException."<init>":()V
      34: athrow
      35: aload_3
      36: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      41: checkcast     #122                // class java/lang/Number
      44: invokevirtual #125                // Method java/lang/Number.intValue:()I
      47: istore        4
      49: iconst_0
      50: istore        5
      52: iload         4
      54: istore        4
      56: aload_3
      57: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      62: ifeq          100
      65: aload_3
      66: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      71: checkcast     #122                // class java/lang/Number
      74: invokevirtual #125                // Method java/lang/Number.intValue:()I
      77: istore        5
      79: iconst_0
      80: istore        6
      82: iload         5
      84: istore        5
      86: iload         4
      88: iload         5
      90: if_icmpge     56
      93: iload         5
      95: istore        4
      97: goto          56
     100: iload         4
     102: istore        23
     104: iload         22
     106: iload         23
     108: istore        24
     110: istore        25
     112: new           #127                // class kotlin/ranges/IntRange
     115: dup
     116: iload         25
     118: iload         24
     120: invokespecial #130                // Method kotlin/ranges/IntRange."<init>":(II)V
     123: checkcast     #45                 // class java/lang/Iterable
     126: astore_2
     127: iconst_0
     128: istore_3
     129: new           #132                // class java/util/LinkedHashMap
     132: dup
     133: aload_2
     134: bipush        10
     136: invokestatic  #53                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     139: invokestatic  #138                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
     142: bipush        16
     144: invokestatic  #144                // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I
     147: invokespecial #145                // Method java/util/LinkedHashMap."<init>":(I)V
     150: astore        4
     152: aload_2
     153: astore        5
     155: iconst_0
     156: istore        6
     158: aload         5
     160: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     165: astore        7
     167: aload         7
     169: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     174: ifeq          327
     177: aload         7
     179: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     184: astore        8
     186: aload         4
     188: checkcast     #147                // class java/util/Map
     191: aload         8
     193: aload         8
     195: checkcast     #122                // class java/lang/Number
     198: invokevirtual #125                // Method java/lang/Number.intValue:()I
     201: istore        9
     203: astore        21
     205: astore        20
     207: iconst_0
     208: istore        10
     210: aload_0
     211: getfield      #96                 // Field input:Ljava/util/List;
     214: checkcast     #45                 // class java/lang/Iterable
     217: astore        11
     219: iconst_0
     220: istore        12
     222: aload         11
     224: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     229: astore        13
     231: aload         13
     233: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     238: ifeq          304
     241: aload         13
     243: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     248: astore        14
     250: iload         12
     252: aload         14
     254: checkcast     #122                // class java/lang/Number
     257: invokevirtual #125                // Method java/lang/Number.intValue:()I
     260: istore        15
     262: istore        16
     264: iconst_0
     265: istore        17
     267: iload         15
     269: iload         9
     271: isub
     272: invokestatic  #152                // Method java/lang/Math.abs:(I)I
     275: istore        18
     277: iload         18
     279: iload         18
     281: iconst_1
     282: iadd
     283: imul
     284: i2d
     285: ldc2_w        #176                // double 2.0d
     288: ddiv
     289: invokestatic  #226                // Method kotlin/math/MathKt.roundToInt:(D)I
     292: istore        19
     294: iload         16
     296: iload         19
     298: iadd
     299: istore        12
     301: goto          231
     304: iload         12
     306: nop
     307: invokestatic  #82                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     310: astore        22
     312: aload         20
     314: aload         21
     316: aload         22
     318: invokeinterface #156,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     323: pop
     324: goto          167
     327: aload         4
     329: checkcast     #147                // class java/util/Map
     332: nop
     333: astore_1
     334: aload_1
     335: invokeinterface #230,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     340: checkcast     #45                 // class java/lang/Iterable
     343: astore        4
     345: aload         4
     347: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     352: astore        5
     354: aload         5
     356: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     361: ifne          368
     364: aconst_null
     365: goto          478
     368: aload         5
     370: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     375: astore        6
     377: aload         5
     379: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     384: ifne          392
     387: aload         6
     389: goto          478
     392: aload         6
     394: checkcast     #232                // class java/util/Map$Entry
     397: astore        7
     399: iconst_0
     400: istore        8
     402: aload         7
     404: invokeinterface #235,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     409: checkcast     #122                // class java/lang/Number
     412: invokevirtual #125                // Method java/lang/Number.intValue:()I
     415: istore        7
     417: aload         5
     419: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     424: astore        8
     426: aload         8
     428: checkcast     #232                // class java/util/Map$Entry
     431: astore        9
     433: iconst_0
     434: istore        10
     436: aload         9
     438: invokeinterface #235,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     443: checkcast     #122                // class java/lang/Number
     446: invokevirtual #125                // Method java/lang/Number.intValue:()I
     449: istore        9
     451: iload         7
     453: iload         9
     455: if_icmple     466
     458: aload         8
     460: astore        6
     462: iload         9
     464: istore        7
     466: aload         5
     468: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     473: ifne          417
     476: aload         6
     478: checkcast     #232                // class java/util/Map$Entry
     481: astore_2
     482: new           #187                // class java/lang/StringBuilder
     485: dup
     486: invokespecial #188                // Method java/lang/StringBuilder."<init>":()V
     489: ldc           #237                // String Optimal Position is:
     491: invokevirtual #194                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     494: aload_2
     495: invokevirtual #240                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     498: invokevirtual #201                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     501: getstatic     #162                // Field java/lang/System.out:Ljava/io/PrintStream;
     504: swap
     505: invokevirtual #168                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     508: aload_2
     509: dup
     510: ifnull        527
     513: invokeinterface #235,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     518: checkcast     #122                // class java/lang/Number
     521: invokevirtual #125                // Method java/lang/Number.intValue:()I
     524: goto          529
     527: pop
     528: iconst_0
     529: ireturn
}