package day02

import java.io.File

data class Instruction(val command: String, val value: Int)

fun main() {
    val instructions = parseInput()
    val part1 = solvePart1(instructions)
    val part2 = solvePart2(instructions)
    println(part1)
    println(part2)
}

fun parseInput(): List<Instruction> {
    return File("../../input/02.txt")
        .readLines()
        .map { it.split(" ") }
        .map { Instruction(it[0], it[1].toInt()) }
}

fun solvePart1(instructions: List<Instruction>): Int {
    var horizontal = 0
    var depth = 0

    instructions.forEach {
        val (command, value) = it
        when (command) {
            "forward" -> horizontal += value
            "down" -> depth += value
            "up" -> depth -= value
        }
    }

    return horizontal * depth
}

fun solvePart2(instructions: List<Instruction>): Int {
    var aim = 0
    var horizontal = 0
    var depth = 0

    instructions.forEach {
        val (command, value) = it
        when (command) {
            "forward" -> {
                horizontal += value
                depth += aim * value
            }
            "down" -> aim += value
            "up" -> aim -= value
        }
    }

    return horizontal * depth
}

Compiled from "deep.kt"
public final class day02.DeepKt {
  public static final void main();
    Code:
       0: invokestatic  #10                 // Method parseInput:()Ljava/util/List;
       3: astore_0
       4: aload_0
       5: invokestatic  #14                 // Method solvePart1:(Ljava/util/List;)I
       8: istore_1
       9: aload_0
      10: invokestatic  #17                 // Method solvePart2:(Ljava/util/List;)I
      13: istore_2
      14: getstatic     #23                 // Field java/lang/System.out:Ljava/io/PrintStream;
      17: iload_1
      18: invokevirtual #29                 // Method java/io/PrintStream.println:(I)V
      21: getstatic     #23                 // Field java/lang/System.out:Ljava/io/PrintStream;
      24: iload_2
      25: invokevirtual #29                 // Method java/io/PrintStream.println:(I)V
      28: return

  public static final java.util.List<day02.Instruction> parseInput();
    Code:
       0: new           #38                 // class java/io/File
       3: dup
       4: ldc           #40                 // String ../../input/02.txt
       6: invokespecial #44                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #50                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      15: checkcast     #52                 // class java/lang/Iterable
      18: astore_0
      19: nop
      20: iconst_0
      21: istore_1
      22: aload_0
      23: astore_2
      24: new           #54                 // class java/util/ArrayList
      27: dup
      28: aload_0
      29: bipush        10
      31: invokestatic  #60                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      34: invokespecial #62                 // Method java/util/ArrayList."<init>":(I)V
      37: checkcast     #64                 // class java/util/Collection
      40: astore_3
      41: iconst_0
      42: istore        4
      44: aload_2
      45: invokeinterface #68,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      50: astore        5
      52: aload         5
      54: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      59: ifeq          123
      62: aload         5
      64: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      69: astore        6
      71: aload_3
      72: aload         6
      74: checkcast     #80                 // class java/lang/String
      77: astore        7
      79: astore        10
      81: iconst_0
      82: istore        8
      84: aload         7
      86: checkcast     #82                 // class java/lang/CharSequence
      89: iconst_1
      90: anewarray     #80                 // class java/lang/String
      93: astore        9
      95: aload         9
      97: iconst_0
      98: ldc           #84                 // String
     100: aastore
     101: aload         9
     103: iconst_0
     104: iconst_0
     105: bipush        6
     107: aconst_null
     108: invokestatic  #90                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     111: aload         10
     113: swap
     114: invokeinterface #94,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     119: pop
     120: goto          52
     123: aload_3
     124: checkcast     #96                 // class java/util/List
     127: nop
     128: checkcast     #52                 // class java/lang/Iterable
     131: astore_0
     132: nop
     133: iconst_0
     134: istore_1
     135: aload_0
     136: astore_2
     137: new           #54                 // class java/util/ArrayList
     140: dup
     141: aload_0
     142: bipush        10
     144: invokestatic  #60                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     147: invokespecial #62                 // Method java/util/ArrayList."<init>":(I)V
     150: checkcast     #64                 // class java/util/Collection
     153: astore_3
     154: iconst_0
     155: istore        4
     157: aload_2
     158: invokeinterface #68,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     163: astore        5
     165: aload         5
     167: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     172: ifeq          241
     175: aload         5
     177: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     182: astore        6
     184: aload_3
     185: aload         6
     187: checkcast     #96                 // class java/util/List
     190: astore        7
     192: astore        10
     194: iconst_0
     195: istore        8
     197: new           #98                 // class day02/Instruction
     200: dup
     201: aload         7
     203: iconst_0
     204: invokeinterface #102,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     209: checkcast     #80                 // class java/lang/String
     212: aload         7
     214: iconst_1
     215: invokeinterface #102,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     220: checkcast     #80                 // class java/lang/String
     223: invokestatic  #108                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     226: invokespecial #111                // Method day02/Instruction."<init>":(Ljava/lang/String;I)V
     229: aload         10
     231: swap
     232: invokeinterface #94,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     237: pop
     238: goto          165
     241: aload_3
     242: checkcast     #96                 // class java/util/List
     245: nop
     246: areturn

  public static final int solvePart1(java.util.List<day02.Instruction>);
    Code:
       0: aload_0
       1: ldc           #126                // String instructions
       3: invokestatic  #132                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_1
       8: iconst_0
       9: istore_2
      10: aload_0
      11: checkcast     #52                 // class java/lang/Iterable
      14: astore_3
      15: iconst_0
      16: istore        4
      18: aload_3
      19: invokeinterface #68,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      24: astore        5
      26: aload         5
      28: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      33: ifeq          177
      36: aload         5
      38: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      43: astore        6
      45: aload         6
      47: checkcast     #98                 // class day02/Instruction
      50: astore        7
      52: iconst_0
      53: istore        8
      55: aload         7
      57: invokevirtual #136                // Method day02/Instruction.component1:()Ljava/lang/String;
      60: astore        9
      62: aload         7
      64: invokevirtual #140                // Method day02/Instruction.component2:()I
      67: istore        10
      69: aload         9
      71: astore        11
      73: aload         11
      75: invokevirtual #143                // Method java/lang/String.hashCode:()I
      78: lookupswitch  { // 3
            -677145915: 112
                  3739: 125
               3089570: 138
               default: 172
          }
     112: aload         11
     114: ldc           #145                // String forward
     116: invokevirtual #148                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     119: ifne          151
     122: goto          172
     125: aload         11
     127: ldc           #150                // String up
     129: invokevirtual #148                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     132: ifne          167
     135: goto          172
     138: aload         11
     140: ldc           #152                // String down
     142: invokevirtual #148                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     145: ifne          159
     148: goto          172
     151: iload_1
     152: iload         10
     154: iadd
     155: istore_1
     156: goto          172
     159: iload_2
     160: iload         10
     162: iadd
     163: istore_2
     164: goto          172
     167: iload_2
     168: iload         10
     170: isub
     171: istore_2
     172: nop
     173: nop
     174: goto          26
     177: nop
     178: iload_1
     179: iload_2
     180: imul
     181: ireturn

  public static final int solvePart2(java.util.List<day02.Instruction>);
    Code:
       0: aload_0
       1: ldc           #126                // String instructions
       3: invokestatic  #132                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_1
       8: iconst_0
       9: istore_2
      10: iconst_0
      11: istore_3
      12: aload_0
      13: checkcast     #52                 // class java/lang/Iterable
      16: astore        4
      18: iconst_0
      19: istore        5
      21: aload         4
      23: invokeinterface #68,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      28: astore        6
      30: aload         6
      32: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      37: ifeq          188
      40: aload         6
      42: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      47: astore        7
      49: aload         7
      51: checkcast     #98                 // class day02/Instruction
      54: astore        8
      56: iconst_0
      57: istore        9
      59: aload         8
      61: invokevirtual #136                // Method day02/Instruction.component1:()Ljava/lang/String;
      64: astore        10
      66: aload         8
      68: invokevirtual #140                // Method day02/Instruction.component2:()I
      71: istore        11
      73: aload         10
      75: astore        12
      77: aload         12
      79: invokevirtual #143                // Method java/lang/String.hashCode:()I
      82: lookupswitch  { // 3
            -677145915: 116
                  3739: 129
               3089570: 142
               default: 183
          }
     116: aload         12
     118: ldc           #145                // String forward
     120: invokevirtual #148                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     123: ifne          155
     126: goto          183
     129: aload         12
     131: ldc           #150                // String up
     133: invokevirtual #148                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     136: ifne          178
     139: goto          183
     142: aload         12
     144: ldc           #152                // String down
     146: invokevirtual #148                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     149: ifne          170
     152: goto          183
     155: iload_2
     156: iload         11
     158: iadd
     159: istore_2
     160: iload_3
     161: iload_1
     162: iload         11
     164: imul
     165: iadd
     166: istore_3
     167: goto          183
     170: iload_1
     171: iload         11
     173: iadd
     174: istore_1
     175: goto          183
     178: iload_1
     179: iload         11
     181: isub
     182: istore_1
     183: nop
     184: nop
     185: goto          30
     188: nop
     189: iload_2
     190: iload_3
     191: imul
     192: ireturn

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


package utils

interface Graph {
    interface Vertex
    interface Edge<T : Vertex> {
        val a: T
        val b: T
    }
}

abstract class AlgorithmAStar<V : Graph.Vertex, E : Graph.Edge<V>>(
    private val edges: List<E>
) : Graph {
    private val V.neighbors: List<V>
        get() = edges
            .asSequence()
            .filter { it.a == this || it.b == this }
            .map { listOf(it.a, it.b) }
            .flatten()
            .filterNot { it == this }
            .distinct()
            .toList()

    private val E.cost: Double
        get() = costToMoveThrough(this)

    private fun findRoute(from: V, to: V): E? {
        return edges.find {
            (it.a == from && it.b == to) || (it.a == to && it.b == from)
        }
    }

    private fun findRouteOrElseCreateIt(from: V, to: V): E {
        return findRoute(from, to) ?: createEdge(from, to)
    }

    private fun generatePath(currentPos: V, cameFrom: Map<V, V>): List<V> {
        val path = mutableListOf(currentPos)
        var current = currentPos

        while (cameFrom.containsKey(current)) {
            current = cameFrom.getValue(current)
            path.add(0, current)
        }
        return path.toList()
    }

    abstract fun costToMoveThrough(edge: E): Double
    abstract fun createEdge(from: V, to: V): E

    fun findPath(begin: V, end: V): Pair<List<V>, Double> {
        val cameFrom = mutableMapOf<V, V>()

        val openVertices = mutableSetOf(begin)
        val closedVertices = mutableSetOf<V>()

        val costFromStart = mutableMapOf(begin to 0.0)

        val estimatedRoute = findRouteOrElseCreateIt(from = begin, to = end)
        val estimatedTotalCost = mutableMapOf(begin to estimatedRoute.cost)

        while (openVertices.isNotEmpty()) {
            val currentPos = openVertices.minByOrNull { estimatedTotalCost.getValue(it) }!!

            // Check if we have reached the finish
            if (currentPos == end) {
                // Backtrack to generate the most efficient path
                val path = generatePath(currentPos, cameFrom)

                // First Route to finish will be optimum route
                return Pair(path, estimatedTotalCost.getValue(end))
            }

            // Mark the current vertex as closed
            openVertices.remove(currentPos)
            closedVertices.add(currentPos)

            (currentPos.neighbors - closedVertices).forEach { neighbour ->
                val routeCost = findRouteOrElseCreateIt(from = currentPos, to = neighbour).cost
                val cost: Double = costFromStart.getValue(currentPos) + routeCost

                if (cost < costFromStart.getOrDefault(neighbour, Double.MAX_VALUE)) {
                    if (!openVertices.contains(neighbour)) {
                        openVertices.add(neighbour)
                    }

                    cameFrom[neighbour] = currentPos
                    costFromStart[neighbour] = cost

                    val estimatedRemainingRouteCost = findRouteOrElseCreateIt(from = neighbour, to = end).cost
                    estimatedTotalCost[neighbour] = cost + estimatedRemainingRouteCost
                }
            }
        }

        throw IllegalArgumentException("No Path from Start $begin to Finish $end")
    }
}

Compiled from "AlgorithmAStar.kt"
public abstract class utils.AlgorithmAStar<V extends utils.Graph$Vertex, E extends utils.Graph$Edge<V>> implements utils.Graph {
  private final java.util.List<E> edges;

  public utils.AlgorithmAStar(java.util.List<? extends E>);
    Code:
       0: aload_1
       1: ldc           #13                 // String edges
       3: invokestatic  #19                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #22                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_1
      12: putfield      #25                 // Field edges:Ljava/util/List;
      15: return

  private final java.util.List<V> getNeighbors(V);
    Code:
       0: aload_0
       1: getfield      #25                 // Field edges:Ljava/util/List;
       4: checkcast     #32                 // class java/lang/Iterable
       7: invokestatic  #38                 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;
      10: aload_1
      11: invokedynamic #58,  0             // InvokeDynamic #0:invoke:(Lutils/Graph$Vertex;)Lkotlin/jvm/functions/Function1;
      16: invokestatic  #64                 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      19: invokedynamic #73,  0             // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
      24: invokestatic  #76                 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      27: invokestatic  #80                 // Method kotlin/sequences/SequencesKt.flattenSequenceOfIterable:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
      30: aload_1
      31: invokedynamic #88,  0             // InvokeDynamic #2:invoke:(Lutils/Graph$Vertex;)Lkotlin/jvm/functions/Function1;
      36: invokestatic  #91                 // Method kotlin/sequences/SequencesKt.filterNot:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      39: invokestatic  #94                 // Method kotlin/sequences/SequencesKt.distinct:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
      42: invokestatic  #98                 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
      45: areturn

  private final double getCost(E);
    Code:
       0: aload_0
       1: aload_1
       2: invokevirtual #106                // Method costToMoveThrough:(Lutils/Graph$Edge;)D
       5: dreturn

  private final E findRoute(V, V);
    Code:
       0: aload_0
       1: getfield      #25                 // Field edges:Ljava/util/List;
       4: checkcast     #32                 // class java/lang/Iterable
       7: astore_3
       8: aload_3
       9: invokeinterface #115,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      14: astore        4
      16: aload         4
      18: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      23: ifeq          114
      26: aload         4
      28: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      33: astore        5
      35: aload         5
      37: checkcast     #127                // class utils/Graph$Edge
      40: astore        6
      42: iconst_0
      43: istore        7
      45: aload         6
      47: invokeinterface #131,  1          // InterfaceMethod utils/Graph$Edge.getA:()Lutils/Graph$Vertex;
      52: aload_1
      53: invokestatic  #135                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      56: ifeq          73
      59: aload         6
      61: invokeinterface #138,  1          // InterfaceMethod utils/Graph$Edge.getB:()Lutils/Graph$Vertex;
      66: aload_2
      67: invokestatic  #135                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      70: ifne          101
      73: aload         6
      75: invokeinterface #131,  1          // InterfaceMethod utils/Graph$Edge.getA:()Lutils/Graph$Vertex;
      80: aload_2
      81: invokestatic  #135                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      84: ifeq          105
      87: aload         6
      89: invokeinterface #138,  1          // InterfaceMethod utils/Graph$Edge.getB:()Lutils/Graph$Vertex;
      94: aload_1
      95: invokestatic  #135                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      98: ifeq          105
     101: iconst_1
     102: goto          106
     105: iconst_0
     106: ifeq          16
     109: aload         5
     111: goto          115
     114: aconst_null
     115: checkcast     #127                // class utils/Graph$Edge
     118: areturn

  private final E findRouteOrElseCreateIt(V, V);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokespecial #146                // Method findRoute:(Lutils/Graph$Vertex;Lutils/Graph$Vertex;)Lutils/Graph$Edge;
       6: dup
       7: ifnonnull     17
      10: pop
      11: aload_0
      12: aload_1
      13: aload_2
      14: invokevirtual #149                // Method createEdge:(Lutils/Graph$Vertex;Lutils/Graph$Vertex;)Lutils/Graph$Edge;
      17: areturn

  private final java.util.List<V> generatePath(V, java.util.Map<V, ? extends V>);
    Code:
       0: iconst_1
       1: anewarray     #154                // class utils/Graph$Vertex
       4: astore        4
       6: aload         4
       8: iconst_0
       9: aload_1
      10: aastore
      11: aload         4
      13: invokestatic  #158                // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
      16: astore_3
      17: aload_1
      18: astore        4
      20: aload_2
      21: aload         4
      23: invokeinterface #164,  2          // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
      28: ifeq          54
      31: aload_2
      32: aload         4
      34: invokestatic  #170                // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;
      37: checkcast     #154                // class utils/Graph$Vertex
      40: astore        4
      42: aload_3
      43: iconst_0
      44: aload         4
      46: invokeinterface #176,  3          // InterfaceMethod java/util/List.add:(ILjava/lang/Object;)V
      51: goto          20
      54: aload_3
      55: checkcast     #32                 // class java/lang/Iterable
      58: invokestatic  #179                // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
      61: areturn

  public abstract double costToMoveThrough(E);

  public abstract E createEdge(V, V);

  public final kotlin.Pair<java.util.List<V>, java.lang.Double> findPath(V, V);
    Code:
       0: aload_1
       1: ldc           #189                // String begin
       3: invokestatic  #19                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #191                // String end
       9: invokestatic  #19                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: new           #193                // class java/util/LinkedHashMap
      15: dup
      16: invokespecial #194                // Method java/util/LinkedHashMap."<init>":()V
      19: checkcast     #160                // class java/util/Map
      22: astore_3
      23: iconst_1
      24: anewarray     #154                // class utils/Graph$Vertex
      27: astore        5
      29: aload         5
      31: iconst_0
      32: aload_1
      33: aastore
      34: aload         5
      36: invokestatic  #200                // Method kotlin/collections/SetsKt.mutableSetOf:([Ljava/lang/Object;)Ljava/util/Set;
      39: astore        4
      41: new           #202                // class java/util/LinkedHashSet
      44: dup
      45: invokespecial #203                // Method java/util/LinkedHashSet."<init>":()V
      48: checkcast     #205                // class java/util/Set
      51: astore        5
      53: iconst_1
      54: anewarray     #207                // class kotlin/Pair
      57: astore        7
      59: aload         7
      61: iconst_0
      62: aload_1
      63: dconst_0
      64: invokestatic  #213                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
      67: invokestatic  #218                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      70: aastore
      71: aload         7
      73: invokestatic  #222                // Method kotlin/collections/MapsKt.mutableMapOf:([Lkotlin/Pair;)Ljava/util/Map;
      76: astore        6
      78: aload_0
      79: aload_1
      80: aload_2
      81: invokespecial #224                // Method findRouteOrElseCreateIt:(Lutils/Graph$Vertex;Lutils/Graph$Vertex;)Lutils/Graph$Edge;
      84: astore        7
      86: iconst_1
      87: anewarray     #207                // class kotlin/Pair
      90: astore        9
      92: aload         9
      94: iconst_0
      95: aload_1
      96: aload_0
      97: aload         7
      99: invokespecial #226                // Method getCost:(Lutils/Graph$Edge;)D
     102: invokestatic  #213                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     105: invokestatic  #218                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     108: aastore
     109: aload         9
     111: invokestatic  #222                // Method kotlin/collections/MapsKt.mutableMapOf:([Lkotlin/Pair;)Ljava/util/Map;
     114: astore        8
     116: aload         4
     118: checkcast     #228                // class java/util/Collection
     121: invokeinterface #231,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     126: ifne          133
     129: iconst_1
     130: goto          134
     133: iconst_0
     134: ifeq          560
     137: aload         4
     139: checkcast     #32                 // class java/lang/Iterable
     142: astore        10
     144: iconst_0
     145: istore        11
     147: aload         10
     149: invokeinterface #115,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     154: astore        12
     156: aload         12
     158: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     163: ifne          170
     166: aconst_null
     167: goto          283
     170: aload         12
     172: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     177: astore        13
     179: aload         12
     181: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     186: ifne          194
     189: aload         13
     191: goto          283
     194: aload         13
     196: checkcast     #154                // class utils/Graph$Vertex
     199: astore        14
     201: iconst_0
     202: istore        16
     204: aload         8
     206: aload         14
     208: invokestatic  #170                // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;
     211: checkcast     #233                // class java/lang/Number
     214: invokevirtual #237                // Method java/lang/Number.doubleValue:()D
     217: dstore        14
     219: aload         12
     221: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     226: astore        16
     228: aload         16
     230: checkcast     #154                // class utils/Graph$Vertex
     233: astore        17
     235: iconst_0
     236: istore        19
     238: aload         8
     240: aload         17
     242: invokestatic  #170                // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;
     245: checkcast     #233                // class java/lang/Number
     248: invokevirtual #237                // Method java/lang/Number.doubleValue:()D
     251: dstore        17
     253: dload         14
     255: dload         17
     257: invokestatic  #241                // Method java/lang/Double.compare:(DD)I
     260: ifle          271
     263: aload         16
     265: astore        13
     267: dload         17
     269: dstore        14
     271: aload         12
     273: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     278: ifne          219
     281: aload         13
     283: dup
     284: invokestatic  #245                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     287: checkcast     #154                // class utils/Graph$Vertex
     290: astore        9
     292: aload         9
     294: aload_2
     295: invokestatic  #135                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     298: ifeq          326
     301: aload_0
     302: aload         9
     304: aload_3
     305: invokespecial #247                // Method generatePath:(Lutils/Graph$Vertex;Ljava/util/Map;)Ljava/util/List;
     308: astore        10
     310: new           #207                // class kotlin/Pair
     313: dup
     314: aload         10
     316: aload         8
     318: aload_2
     319: invokestatic  #170                // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;
     322: invokespecial #250                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     325: areturn
     326: aload         4
     328: aload         9
     330: invokeinterface #253,  2          // InterfaceMethod java/util/Set.remove:(Ljava/lang/Object;)Z
     335: pop
     336: aload         5
     338: aload         9
     340: invokeinterface #255,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     345: pop
     346: aload_0
     347: aload         9
     349: invokespecial #257                // Method getNeighbors:(Lutils/Graph$Vertex;)Ljava/util/List;
     352: checkcast     #32                 // class java/lang/Iterable
     355: aload         5
     357: checkcast     #32                 // class java/lang/Iterable
     360: invokestatic  #261                // Method kotlin/collections/CollectionsKt.minus:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;
     363: checkcast     #32                 // class java/lang/Iterable
     366: astore        10
     368: iconst_0
     369: istore        11
     371: aload         10
     373: invokeinterface #115,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     378: astore        12
     380: aload         12
     382: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     387: ifeq          556
     390: aload         12
     392: invokeinterface #125,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     397: astore        13
     399: aload         13
     401: checkcast     #154                // class utils/Graph$Vertex
     404: astore        14
     406: iconst_0
     407: istore        16
     409: aload_0
     410: aload_0
     411: aload         9
     413: aload         14
     415: invokespecial #224                // Method findRouteOrElseCreateIt:(Lutils/Graph$Vertex;Lutils/Graph$Vertex;)Lutils/Graph$Edge;
     418: invokespecial #226                // Method getCost:(Lutils/Graph$Edge;)D
     421: dstore        17
     423: aload         6
     425: aload         9
     427: invokestatic  #170                // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;
     430: checkcast     #233                // class java/lang/Number
     433: invokevirtual #237                // Method java/lang/Number.doubleValue:()D
     436: dload         17
     438: dadd
     439: dstore        20
     441: dload         20
     443: aload         6
     445: aload         14
     447: ldc2_w        #262                // double 1.7976931348623157E308d
     450: invokestatic  #213                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     453: invokeinterface #267,  3          // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     458: checkcast     #233                // class java/lang/Number
     461: invokevirtual #237                // Method java/lang/Number.doubleValue:()D
     464: dcmpg
     465: ifge          551
     468: aload         4
     470: aload         14
     472: invokeinterface #270,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     477: ifne          490
     480: aload         4
     482: aload         14
     484: invokeinterface #255,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     489: pop
     490: aload_3
     491: aload         14
     493: aload         9
     495: invokeinterface #273,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     500: pop
     501: dload         20
     503: invokestatic  #213                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     506: astore        22
     508: aload         6
     510: aload         14
     512: aload         22
     514: invokeinterface #273,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     519: pop
     520: aload_0
     521: aload_0
     522: aload         14
     524: aload_2
     525: invokespecial #224                // Method findRouteOrElseCreateIt:(Lutils/Graph$Vertex;Lutils/Graph$Vertex;)Lutils/Graph$Edge;
     528: invokespecial #226                // Method getCost:(Lutils/Graph$Edge;)D
     531: dstore        23
     533: aload         8
     535: aload         14
     537: dload         20
     539: dload         23
     541: dadd
     542: invokestatic  #213                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     545: invokeinterface #273,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     550: pop
     551: nop
     552: nop
     553: goto          380
     556: nop
     557: goto          116
     560: new           #275                // class java/lang/IllegalArgumentException
     563: dup
     564: new           #277                // class java/lang/StringBuilder
     567: dup
     568: invokespecial #278                // Method java/lang/StringBuilder."<init>":()V
     571: ldc_w         #280                // String No Path from Start
     574: invokevirtual #284                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     577: aload_1
     578: invokevirtual #287                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     581: ldc_w         #289                // String  to Finish
     584: invokevirtual #284                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     587: aload_2
     588: invokevirtual #287                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     591: invokevirtual #293                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     594: invokespecial #296                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     597: athrow

  private static final boolean _get_neighbors_$lambda$0(utils.Graph$Vertex, utils.Graph$Edge);
    Code:
       0: aload_1
       1: ldc_w         #323                // String it
       4: invokestatic  #19                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: invokeinterface #131,  1          // InterfaceMethod utils/Graph$Edge.getA:()Lutils/Graph$Vertex;
      13: aload_0
      14: invokestatic  #135                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      17: ifne          33
      20: aload_1
      21: invokeinterface #138,  1          // InterfaceMethod utils/Graph$Edge.getB:()Lutils/Graph$Vertex;
      26: aload_0
      27: invokestatic  #135                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      30: ifeq          37
      33: iconst_1
      34: goto          38
      37: iconst_0
      38: ireturn

  private static final java.util.List _get_neighbors_$lambda$1(utils.Graph$Edge);
    Code:
       0: aload_0
       1: ldc_w         #323                // String it
       4: invokestatic  #19                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: iconst_2
       8: anewarray     #154                // class utils/Graph$Vertex
      11: astore_1
      12: aload_1
      13: iconst_0
      14: aload_0
      15: invokeinterface #131,  1          // InterfaceMethod utils/Graph$Edge.getA:()Lutils/Graph$Vertex;
      20: aastore
      21: aload_1
      22: iconst_1
      23: aload_0
      24: invokeinterface #138,  1          // InterfaceMethod utils/Graph$Edge.getB:()Lutils/Graph$Vertex;
      29: aastore
      30: aload_1
      31: invokestatic  #327                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      34: areturn

  private static final boolean _get_neighbors_$lambda$2(utils.Graph$Vertex, utils.Graph$Vertex);
    Code:
       0: aload_1
       1: ldc_w         #323                // String it
       4: invokestatic  #19                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: aload_0
       9: invokestatic  #135                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      12: ireturn
}


package icfp2019

import java.io.File
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths

fun main() {
  val workingDir: Path = Paths.get("")

  val solutions = mutableListOf<Solution>()
  readZipFile(File("problems.zip"))
      .filter { it.file.isFile }
      .forEach {
        val problem = parseDesc(it)
        val solution = solve(problem)
        encodeSolution(solution, workingDir)
      }

  writeZip(workingDir, solutions)
}

fun writeZip(workingDir: Path, solutions: MutableList<Solution>) {
  TODO("not implemented")
}

fun readZipFile(file: File): List<ProblemDescription> {
  TODO("not implemented")
}

enum class Boosters {
  B, F, L, X
}

data class Point(val x: Int, val y: Int)
data class Node(val point: Point, val isObstacle: Boolean, val booster: Boosters)

data class ProblemId(val id: Int)
data class ProblemDescription(val problemId: ProblemId, val file: File)
data class Problem(val problemId: ProblemId, val startingPosition: Point, val map: Array<Array<Node>>)

/*
Task:
 1. Open Zip file
 2. parse a problem at a time: prob_NNN.desc
 3. solve problem
 4. encode solution
 5. output to file prob_NNN.sol (use checker to validate?) https://icfpcontest2019.github.io/solution_checker/
 6. add solution to another zip (script/program)
 */

fun parseDesc(file: ProblemDescription): Problem {
  // Read lines
  /*
  1. Read lines
  2. Parse map
  Grammar:
    x,y: Nat
              point ::= (x,y)
                map ::= repSep(point,”,”)
        BoosterCode ::= B|F|L|X
    boosterLocation ::= BoosterCode point
          obstacles ::= repSep(map,”; ”)
           boosters ::= repSep(boosterLocation,”; ”)
               task ::= map # point # obstacles # boosters
   */
  return Problem(ProblemId(0), Point(0, 0), arrayOf())
}

/*
A solution for a task
  prob-NNN.desc
is a sequence of actions encoded as a single-line text file named
  prob-NNN.sol
for the corresponding numberNNN.
The actions are encoded as follows:
  action ::=
      W(move up)
      | S(move down)
      | A(move left)
      | D(move right)
      | Z(do nothing)
      | E(turn manipulators 90°clockwise)
      | Q(turn manipulators 90°counterclockwise)
      | B(dx,dy)(attach a new manipulator with relative coordinates(dx,dy))
      | F(attach fast wheels)
      | L(start using a drill)

  solution ::= rep(action)

  A solution isvalid, if it does not force the worker-wrapper to go through the walls and obstacles
  (unless it uses a drill), respects the rules of using boosters, and, upon finishing,
  leaves all reachablesquares of the map wrapped.
 */

enum class Actions {
  W, S, A, D, Z, E, Q, B, F, L
}

data class Solution(val problemId: ProblemId, val actions: List<Actions>)

fun solve(problem: Problem): Solution {
  return Solution(problem.problemId, listOf())
}

fun encodeSolution(solution: Solution, directory: Path): File {
  val file = Files.createFile(directory.resolve("prob-${solution.problemId.id}.sol"))
  // TODO
  return file.toFile()
}

Compiled from "app.kt"
public final class icfp2019.AppKt {
  public static final void main();
    Code:
       0: ldc           #8                  // String
       2: iconst_0
       3: anewarray     #10                 // class java/lang/String
       6: invokestatic  #16                 // Method java/nio/file/Paths.get:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;
       9: dup
      10: ldc           #18                 // String get(...)
      12: invokestatic  #24                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      15: astore_0
      16: new           #26                 // class java/util/ArrayList
      19: dup
      20: invokespecial #29                 // Method java/util/ArrayList."<init>":()V
      23: checkcast     #31                 // class java/util/List
      26: astore_1
      27: new           #33                 // class java/io/File
      30: dup
      31: ldc           #35                 // String problems.zip
      33: invokespecial #38                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      36: invokestatic  #42                 // Method readZipFile:(Ljava/io/File;)Ljava/util/List;
      39: checkcast     #44                 // class java/lang/Iterable
      42: astore_2
      43: nop
      44: iconst_0
      45: istore_3
      46: aload_2
      47: astore        4
      49: new           #26                 // class java/util/ArrayList
      52: dup
      53: invokespecial #29                 // Method java/util/ArrayList."<init>":()V
      56: checkcast     #46                 // class java/util/Collection
      59: astore        5
      61: iconst_0
      62: istore        6
      64: aload         4
      66: invokeinterface #50,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      71: astore        7
      73: aload         7
      75: invokeinterface #56,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      80: ifeq          126
      83: aload         7
      85: invokeinterface #60,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      90: astore        8
      92: aload         8
      94: checkcast     #62                 // class icfp2019/ProblemDescription
      97: astore        9
      99: iconst_0
     100: istore        10
     102: aload         9
     104: invokevirtual #66                 // Method icfp2019/ProblemDescription.getFile:()Ljava/io/File;
     107: invokevirtual #69                 // Method java/io/File.isFile:()Z
     110: ifeq          73
     113: aload         5
     115: aload         8
     117: invokeinterface #73,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     122: pop
     123: goto          73
     126: aload         5
     128: checkcast     #31                 // class java/util/List
     131: nop
     132: checkcast     #44                 // class java/lang/Iterable
     135: astore_2
     136: nop
     137: iconst_0
     138: istore_3
     139: aload_2
     140: invokeinterface #50,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     145: astore        4
     147: aload         4
     149: invokeinterface #56,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     154: ifeq          202
     157: aload         4
     159: invokeinterface #60,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     164: astore        5
     166: aload         5
     168: checkcast     #62                 // class icfp2019/ProblemDescription
     171: astore        6
     173: iconst_0
     174: istore        7
     176: aload         6
     178: invokestatic  #77                 // Method parseDesc:(Licfp2019/ProblemDescription;)Licfp2019/Problem;
     181: astore        8
     183: aload         8
     185: invokestatic  #81                 // Method solve:(Licfp2019/Problem;)Licfp2019/Solution;
     188: astore        9
     190: aload         9
     192: aload_0
     193: invokestatic  #85                 // Method encodeSolution:(Licfp2019/Solution;Ljava/nio/file/Path;)Ljava/io/File;
     196: pop
     197: nop
     198: nop
     199: goto          147
     202: nop
     203: aload_0
     204: aload_1
     205: invokestatic  #89                 // Method writeZip:(Ljava/nio/file/Path;Ljava/util/List;)V
     208: return

  public static final void writeZip(java.nio.file.Path, java.util.List<icfp2019.Solution>);
    Code:
       0: aload_0
       1: ldc           #119                // String workingDir
       3: invokestatic  #122                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #123                // String solutions
       9: invokestatic  #122                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: ldc           #125                // String not implemented
      14: astore_2
      15: new           #127                // class kotlin/NotImplementedError
      18: dup
      19: new           #129                // class java/lang/StringBuilder
      22: dup
      23: invokespecial #130                // Method java/lang/StringBuilder."<init>":()V
      26: ldc           #132                // String An operation is not implemented:
      28: invokevirtual #136                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      31: aload_2
      32: invokevirtual #136                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      35: invokevirtual #140                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      38: invokespecial #141                // Method kotlin/NotImplementedError."<init>":(Ljava/lang/String;)V
      41: athrow

  public static final java.util.List<icfp2019.ProblemDescription> readZipFile(java.io.File);
    Code:
       0: aload_0
       1: ldc           #144                // String file
       3: invokestatic  #122                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: ldc           #125                // String not implemented
       8: astore_1
       9: new           #127                // class kotlin/NotImplementedError
      12: dup
      13: new           #129                // class java/lang/StringBuilder
      16: dup
      17: invokespecial #130                // Method java/lang/StringBuilder."<init>":()V
      20: ldc           #132                // String An operation is not implemented:
      22: invokevirtual #136                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      25: aload_1
      26: invokevirtual #136                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      29: invokevirtual #140                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      32: invokespecial #141                // Method kotlin/NotImplementedError."<init>":(Ljava/lang/String;)V
      35: athrow

  public static final icfp2019.Problem parseDesc(icfp2019.ProblemDescription);
    Code:
       0: aload_0
       1: ldc           #144                // String file
       3: invokestatic  #122                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #147                // class icfp2019/Problem
       9: dup
      10: new           #149                // class icfp2019/ProblemId
      13: dup
      14: iconst_0
      15: invokespecial #152                // Method icfp2019/ProblemId."<init>":(I)V
      18: new           #154                // class icfp2019/Point
      21: dup
      22: iconst_0
      23: iconst_0
      24: invokespecial #157                // Method icfp2019/Point."<init>":(II)V
      27: iconst_0
      28: anewarray     #159                // class "[Licfp2019/Node;"
      31: invokespecial #162                // Method icfp2019/Problem."<init>":(Licfp2019/ProblemId;Licfp2019/Point;[[Licfp2019/Node;)V
      34: areturn

  public static final icfp2019.Solution solve(icfp2019.Problem);
    Code:
       0: aload_0
       1: ldc           #163                // String problem
       3: invokestatic  #122                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #165                // class icfp2019/Solution
       9: dup
      10: aload_0
      11: invokevirtual #169                // Method icfp2019/Problem.getProblemId:()Licfp2019/ProblemId;
      14: invokestatic  #175                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      17: invokespecial #178                // Method icfp2019/Solution."<init>":(Licfp2019/ProblemId;Ljava/util/List;)V
      20: areturn

  public static final java.io.File encodeSolution(icfp2019.Solution, java.nio.file.Path);
    Code:
       0: aload_0
       1: ldc           #179                // String solution
       3: invokestatic  #122                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #181                // String directory
       9: invokestatic  #122                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: new           #129                // class java/lang/StringBuilder
      16: dup
      17: invokespecial #130                // Method java/lang/StringBuilder."<init>":()V
      20: ldc           #183                // String prob-
      22: invokevirtual #136                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      25: aload_0
      26: invokevirtual #184                // Method icfp2019/Solution.getProblemId:()Licfp2019/ProblemId;
      29: invokevirtual #188                // Method icfp2019/ProblemId.getId:()I
      32: invokevirtual #191                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      35: ldc           #193                // String .sol
      37: invokevirtual #136                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      40: invokevirtual #140                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      43: invokeinterface #197,  2          // InterfaceMethod java/nio/file/Path.resolve:(Ljava/lang/String;)Ljava/nio/file/Path;
      48: iconst_0
      49: anewarray     #199                // class java/nio/file/attribute/FileAttribute
      52: invokestatic  #205                // Method java/nio/file/Files.createFile:(Ljava/nio/file/Path;[Ljava/nio/file/attribute/FileAttribute;)Ljava/nio/file/Path;
      55: astore_2
      56: aload_2
      57: invokeinterface #208,  1          // InterfaceMethod java/nio/file/Path.toFile:()Ljava/io/File;
      62: dup
      63: ldc           #210                // String toFile(...)
      65: invokestatic  #24                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      68: areturn

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


package solver

import java.lang.RuntimeException
import kotlin.math.abs

interface ExpressionItem

enum class Operator : ExpressionItem {
    ADD { override fun apply(a1: Double, a2: Double) = a1 + a2 },
    MINUS { override fun apply(a1: Double, a2: Double) = a1 - a2 },
    TIMES { override fun apply(a1: Double, a2: Double) = a1 * a2 },
    DIVIDE { override fun apply(a1: Double, a2: Double) = a1 / a2 };

    abstract fun apply(a1: Double, a2: Double): Double
}

data class Scalar(
    val value: Double
): ExpressionItem

fun evalPrefixExpression(expression: List<ExpressionItem>): Double {
    var index = 0
    fun evalNext(): Double {
        return when (val current = expression[index++]) {
            is Scalar -> current.value
            is Operator -> current.apply(evalNext(), evalNext())
            else -> throw RuntimeException("Unexpected type: $current")
        }
    }
    return evalNext()
}

fun solve(values: List<Double>, target: Double): List<ExpressionItem>? {
    fun recur(expressionSoFar: List<ExpressionItem>, remainingComponents: List<Double>): List<ExpressionItem>? {
        if (remainingComponents.isEmpty()) {
            return if (abs(evalPrefixExpression(expressionSoFar) - target) < 0.001) {
                expressionSoFar
            } else {
                null
            }
        }
        val numbersSoFar = expressionSoFar.filterIsInstance<Scalar>().count()
        val operatorsSoFar = expressionSoFar.filterIsInstance<Operator>().count()
        // Try out all operators if operator can be added
        if (operatorsSoFar < values.size - 1) {
            for (op in Operator.values()) {
                val result = recur(expressionSoFar + op, remainingComponents)
                if (result != null) {
                    return result
                }
            }
        }
        // Try out all operators if number can be added
        if (numbersSoFar < operatorsSoFar || (numbersSoFar == operatorsSoFar && remainingComponents.size == 1)) {
            for (number in remainingComponents) {
                val result = recur(
                    expressionSoFar + Scalar(number),
                    remainingComponents - number
                )
                if (result != null) {
                    return result
                }
            }
        }
        return null
    }
    return recur(listOf(), values)
}

Compiled from "model.kt"
public final class solver.ModelKt {
  public static final double evalPrefixExpression(java.util.List<? extends solver.ExpressionItem>);
    Code:
       0: aload_0
       1: ldc           #10                 // String expression
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #18                 // class kotlin/jvm/internal/Ref$IntRef
       9: dup
      10: invokespecial #22                 // Method kotlin/jvm/internal/Ref$IntRef."<init>":()V
      13: astore_1
      14: aload_0
      15: aload_1
      16: invokestatic  #26                 // Method evalPrefixExpression$evalNext:(Ljava/util/List;Lkotlin/jvm/internal/Ref$IntRef;)D
      19: dreturn

  public static final java.util.List<solver.ExpressionItem> solve(java.util.List<java.lang.Double>, double);
    Code:
       0: aload_0
       1: ldc           #35                 // String values
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: dload_1
       7: aload_0
       8: invokestatic  #41                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      11: aload_0
      12: invokestatic  #45                 // Method solve$recur:(DLjava/util/List;Ljava/util/List;Ljava/util/List;)Ljava/util/List;
      15: areturn

  private static final double evalPrefixExpression$evalNext(java.util.List<? extends solver.ExpressionItem>, kotlin.jvm.internal.Ref$IntRef);
    Code:
       0: aload_0
       1: aload_1
       2: getfield      #52                 // Field kotlin/jvm/internal/Ref$IntRef.element:I
       5: istore_3
       6: aload_1
       7: iload_3
       8: iconst_1
       9: iadd
      10: putfield      #52                 // Field kotlin/jvm/internal/Ref$IntRef.element:I
      13: iload_3
      14: invokeinterface #58,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      19: checkcast     #60                 // class solver/ExpressionItem
      22: astore_2
      23: aload_2
      24: instanceof    #62                 // class solver/Scalar
      27: ifeq          40
      30: aload_2
      31: checkcast     #62                 // class solver/Scalar
      34: invokevirtual #66                 // Method solver/Scalar.getValue:()D
      37: goto          94
      40: aload_2
      41: instanceof    #68                 // class solver/Operator
      44: ifeq          67
      47: aload_2
      48: checkcast     #68                 // class solver/Operator
      51: aload_0
      52: aload_1
      53: invokestatic  #26                 // Method evalPrefixExpression$evalNext:(Ljava/util/List;Lkotlin/jvm/internal/Ref$IntRef;)D
      56: aload_0
      57: aload_1
      58: invokestatic  #26                 // Method evalPrefixExpression$evalNext:(Ljava/util/List;Lkotlin/jvm/internal/Ref$IntRef;)D
      61: invokevirtual #72                 // Method solver/Operator.apply:(DD)D
      64: goto          94
      67: new           #74                 // class java/lang/RuntimeException
      70: dup
      71: new           #76                 // class java/lang/StringBuilder
      74: dup
      75: invokespecial #77                 // Method java/lang/StringBuilder."<init>":()V
      78: ldc           #79                 // String Unexpected type:
      80: invokevirtual #83                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      83: aload_2
      84: invokevirtual #86                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      87: invokevirtual #90                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      90: invokespecial #93                 // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V
      93: athrow
      94: dreturn

  private static final java.util.List<solver.ExpressionItem> solve$recur(double, java.util.List<java.lang.Double>, java.util.List<? extends solver.ExpressionItem>, java.util.List<java.lang.Double>);
    Code:
       0: aload         4
       2: invokeinterface #101,  1          // InterfaceMethod java/util/List.isEmpty:()Z
       7: ifeq          32
      10: aload_3
      11: invokestatic  #103                // Method evalPrefixExpression:(Ljava/util/List;)D
      14: dload_0
      15: dsub
      16: invokestatic  #109                // Method java/lang/Math.abs:(D)D
      19: ldc2_w        #110                // double 0.001d
      22: dcmpg
      23: ifge          30
      26: aload_3
      27: goto          31
      30: aconst_null
      31: areturn
      32: aload_3
      33: checkcast     #113                // class java/lang/Iterable
      36: astore        6
      38: iconst_0
      39: istore        7
      41: aload         6
      43: astore        8
      45: new           #115                // class java/util/ArrayList
      48: dup
      49: invokespecial #116                // Method java/util/ArrayList."<init>":()V
      52: checkcast     #118                // class java/util/Collection
      55: astore        9
      57: iconst_0
      58: istore        10
      60: aload         8
      62: invokeinterface #122,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      67: astore        11
      69: aload         11
      71: invokeinterface #127,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      76: ifeq          109
      79: aload         11
      81: invokeinterface #131,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      86: astore        12
      88: aload         12
      90: instanceof    #62                 // class solver/Scalar
      93: ifeq          69
      96: aload         9
      98: aload         12
     100: invokeinterface #135,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     105: pop
     106: goto          69
     109: aload         9
     111: checkcast     #54                 // class java/util/List
     114: nop
     115: checkcast     #118                // class java/util/Collection
     118: invokeinterface #139,  1          // InterfaceMethod java/util/Collection.size:()I
     123: istore        5
     125: aload_3
     126: checkcast     #113                // class java/lang/Iterable
     129: astore        7
     131: iconst_0
     132: istore        8
     134: aload         7
     136: astore        9
     138: new           #115                // class java/util/ArrayList
     141: dup
     142: invokespecial #116                // Method java/util/ArrayList."<init>":()V
     145: checkcast     #118                // class java/util/Collection
     148: astore        10
     150: iconst_0
     151: istore        11
     153: aload         9
     155: invokeinterface #122,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     160: astore        12
     162: aload         12
     164: invokeinterface #127,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     169: ifeq          202
     172: aload         12
     174: invokeinterface #131,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     179: astore        13
     181: aload         13
     183: instanceof    #68                 // class solver/Operator
     186: ifeq          162
     189: aload         10
     191: aload         13
     193: invokeinterface #135,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     198: pop
     199: goto          162
     202: aload         10
     204: checkcast     #54                 // class java/util/List
     207: nop
     208: checkcast     #118                // class java/util/Collection
     211: invokeinterface #139,  1          // InterfaceMethod java/util/Collection.size:()I
     216: istore        6
     218: iload         6
     220: aload_2
     221: invokeinterface #140,  1          // InterfaceMethod java/util/List.size:()I
     226: iconst_1
     227: isub
     228: if_icmpge     290
     231: invokestatic  #143                // Method solver/Operator.values:()[Lsolver/Operator;
     234: astore        7
     236: iconst_0
     237: istore        8
     239: aload         7
     241: arraylength
     242: istore        9
     244: iload         8
     246: iload         9
     248: if_icmpge     290
     251: aload         7
     253: iload         8
     255: aaload
     256: astore        10
     258: dload_0
     259: aload_2
     260: aload_3
     261: checkcast     #118                // class java/util/Collection
     264: aload         10
     266: invokestatic  #147                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     269: aload         4
     271: invokestatic  #45                 // Method solve$recur:(DLjava/util/List;Ljava/util/List;Ljava/util/List;)Ljava/util/List;
     274: astore        11
     276: aload         11
     278: ifnull        284
     281: aload         11
     283: areturn
     284: iinc          8, 1
     287: goto          244
     290: iload         5
     292: iload         6
     294: if_icmplt     315
     297: iload         5
     299: iload         6
     301: if_icmpne     393
     304: aload         4
     306: invokeinterface #140,  1          // InterfaceMethod java/util/List.size:()I
     311: iconst_1
     312: if_icmpne     393
     315: aload         4
     317: invokeinterface #148,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     322: astore        7
     324: aload         7
     326: invokeinterface #127,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     331: ifeq          393
     334: aload         7
     336: invokeinterface #131,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     341: checkcast     #150                // class java/lang/Number
     344: invokevirtual #153                // Method java/lang/Number.doubleValue:()D
     347: dstore        8
     349: dload_0
     350: aload_2
     351: aload_3
     352: checkcast     #118                // class java/util/Collection
     355: new           #62                 // class solver/Scalar
     358: dup
     359: dload         8
     361: invokespecial #156                // Method solver/Scalar."<init>":(D)V
     364: invokestatic  #147                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     367: aload         4
     369: checkcast     #113                // class java/lang/Iterable
     372: dload         8
     374: invokestatic  #162                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     377: invokestatic  #166                // Method kotlin/collections/CollectionsKt.minus:(Ljava/lang/Iterable;Ljava/lang/Object;)Ljava/util/List;
     380: invokestatic  #45                 // Method solve$recur:(DLjava/util/List;Ljava/util/List;Ljava/util/List;)Ljava/util/List;
     383: astore        10
     385: aload         10
     387: ifnull        324
     390: aload         10
     392: areturn
     393: aconst_null
     394: areturn
}


package com.example.firstapp.lesson

import java.lang.Exception

/**
 *@author: hairly owl
 *@time:2021/10/13 21:22
 *@version: 1.00
 *@description: 一次四则运算计算机器
 */

fun main() {
    while(true){
        println("==========请输入你的表达式==========")
        //接受控制台输入数据
        val input:String? = readLine() //判空的校验
        try {
            input?.let {
                val res = calculate(it)
                println("${input} = ${res}")
                println("是否继续使用(y/n)")
                val cmd = readLine()
                cmd?.let{
                    if(it.equals("n")){
                        System.exit(-1) //强制退出程序
                    }else{
                        //继续使用

                    }
                }
            }
        }catch (ex:Exception){
            ex.printStackTrace() //打印异常
        }
    }
}

//四则运算函数
fun calculate(input: String): String {
    if(input.contains("+")){ //加法
        //数据处理
        val nums = input.trim().split("+") //去掉空格 分割操作符左右
        return operate(nums[0].toDouble(),nums[1].toDouble(),"+").toString()

    }else if (input.contains("-")){ //减法
        val nums = input.trim().split("-")
        return operate(nums[0].toDouble(),nums[1].toDouble(),"-").toString()

    }else if (input.contains("*")){ //减法
        val nums = input.trim().split("*")
        return operate(nums[0].toDouble(),nums[1].toDouble(),"*").toString()

    }else if (input.contains("/")){ //减法
        val nums = input.trim().split("/")
        return operate(nums[0].toDouble(),nums[1].toDouble(),"/").toString()
    }else{
        return "error: 您输入的表达式有误"
    }
}

//计算函数
fun operate(num1: Double, num2: Double, operator: String): Double {
    return when(operator){ //kotlin中的when代替 java中的switch-case
        "+" -> num1 + num2
        "-" -> num1 - num2
        "*" -> num1 * num2
        "/" -> num1 / num2
        else -> 0.0
    }
}

Compiled from "Caculator.kt"
public final class com.example.firstapp.lesson.CaculatorKt {
  public static final void main();
    Code:
       0: nop
       1: ldc           #10                 // String ==========请输入你的表达式==========
       3: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
       6: swap
       7: invokevirtual #22                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      10: invokestatic  #28                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
      13: astore_0
      14: nop
      15: aload_0
      16: dup
      17: ifnull        112
      20: astore_2
      21: iconst_0
      22: istore_3
      23: aload_2
      24: invokestatic  #32                 // Method calculate:(Ljava/lang/String;)Ljava/lang/String;
      27: astore        4
      29: new           #34                 // class java/lang/StringBuilder
      32: dup
      33: invokespecial #37                 // Method java/lang/StringBuilder."<init>":()V
      36: aload_0
      37: invokevirtual #41                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      40: ldc           #43                 // String  =
      42: invokevirtual #41                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      45: aload         4
      47: invokevirtual #41                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      50: invokevirtual #46                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      53: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
      56: swap
      57: invokevirtual #22                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      60: ldc           #48                 // String 是否继续使用(y/n)
      62: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
      65: swap
      66: invokevirtual #22                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      69: invokestatic  #28                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
      72: astore        5
      74: aload         5
      76: dup
      77: ifnull        106
      80: astore        6
      82: iconst_0
      83: istore        7
      85: aload         6
      87: ldc           #50                 // String n
      89: invokevirtual #56                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      92: ifeq          99
      95: iconst_m1
      96: invokestatic  #60                 // Method java/lang/System.exit:(I)V
      99: nop
     100: getstatic     #66                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     103: goto          108
     106: pop
     107: aconst_null
     108: nop
     109: goto          114
     112: pop
     113: aconst_null
     114: astore_1
     115: goto          0
     118: astore_2
     119: aload_2
     120: invokevirtual #69                 // Method java/lang/Exception.printStackTrace:()V
     123: getstatic     #66                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     126: astore_1
     127: goto          0
    Exception table:
       from    to  target type
          14   115   118   Class java/lang/Exception

  public static final java.lang.String calculate(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #81                 // String input
       3: invokestatic  #87                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #89                 // class java/lang/CharSequence
      10: ldc           #91                 // String +
      12: checkcast     #89                 // class java/lang/CharSequence
      15: iconst_0
      16: iconst_2
      17: aconst_null
      18: invokestatic  #97                 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z
      21: ifeq          92
      24: aload_0
      25: checkcast     #89                 // class java/lang/CharSequence
      28: invokestatic  #101                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      31: invokevirtual #102                // Method java/lang/Object.toString:()Ljava/lang/String;
      34: checkcast     #89                 // class java/lang/CharSequence
      37: iconst_1
      38: anewarray     #52                 // class java/lang/String
      41: astore_2
      42: aload_2
      43: iconst_0
      44: ldc           #91                 // String +
      46: aastore
      47: aload_2
      48: iconst_0
      49: iconst_0
      50: bipush        6
      52: aconst_null
      53: invokestatic  #106                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      56: astore_1
      57: aload_1
      58: iconst_0
      59: invokeinterface #112,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      64: checkcast     #52                 // class java/lang/String
      67: invokestatic  #118                // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D
      70: aload_1
      71: iconst_1
      72: invokeinterface #112,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      77: checkcast     #52                 // class java/lang/String
      80: invokestatic  #118                // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D
      83: ldc           #91                 // String +
      85: invokestatic  #122                // Method operate:(DDLjava/lang/String;)D
      88: invokestatic  #126                // Method java/lang/String.valueOf:(D)Ljava/lang/String;
      91: areturn
      92: aload_0
      93: checkcast     #89                 // class java/lang/CharSequence
      96: ldc           #128                // String -
      98: checkcast     #89                 // class java/lang/CharSequence
     101: iconst_0
     102: iconst_2
     103: aconst_null
     104: invokestatic  #97                 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z
     107: ifeq          178
     110: aload_0
     111: checkcast     #89                 // class java/lang/CharSequence
     114: invokestatic  #101                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     117: invokevirtual #102                // Method java/lang/Object.toString:()Ljava/lang/String;
     120: checkcast     #89                 // class java/lang/CharSequence
     123: iconst_1
     124: anewarray     #52                 // class java/lang/String
     127: astore_2
     128: aload_2
     129: iconst_0
     130: ldc           #128                // String -
     132: aastore
     133: aload_2
     134: iconst_0
     135: iconst_0
     136: bipush        6
     138: aconst_null
     139: invokestatic  #106                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     142: astore_1
     143: aload_1
     144: iconst_0
     145: invokeinterface #112,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     150: checkcast     #52                 // class java/lang/String
     153: invokestatic  #118                // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D
     156: aload_1
     157: iconst_1
     158: invokeinterface #112,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     163: checkcast     #52                 // class java/lang/String
     166: invokestatic  #118                // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D
     169: ldc           #128                // String -
     171: invokestatic  #122                // Method operate:(DDLjava/lang/String;)D
     174: invokestatic  #126                // Method java/lang/String.valueOf:(D)Ljava/lang/String;
     177: areturn
     178: aload_0
     179: checkcast     #89                 // class java/lang/CharSequence
     182: ldc           #130                // String *
     184: checkcast     #89                 // class java/lang/CharSequence
     187: iconst_0
     188: iconst_2
     189: aconst_null
     190: invokestatic  #97                 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z
     193: ifeq          264
     196: aload_0
     197: checkcast     #89                 // class java/lang/CharSequence
     200: invokestatic  #101                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     203: invokevirtual #102                // Method java/lang/Object.toString:()Ljava/lang/String;
     206: checkcast     #89                 // class java/lang/CharSequence
     209: iconst_1
     210: anewarray     #52                 // class java/lang/String
     213: astore_2
     214: aload_2
     215: iconst_0
     216: ldc           #130                // String *
     218: aastore
     219: aload_2
     220: iconst_0
     221: iconst_0
     222: bipush        6
     224: aconst_null
     225: invokestatic  #106                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     228: astore_1
     229: aload_1
     230: iconst_0
     231: invokeinterface #112,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     236: checkcast     #52                 // class java/lang/String
     239: invokestatic  #118                // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D
     242: aload_1
     243: iconst_1
     244: invokeinterface #112,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     249: checkcast     #52                 // class java/lang/String
     252: invokestatic  #118                // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D
     255: ldc           #130                // String *
     257: invokestatic  #122                // Method operate:(DDLjava/lang/String;)D
     260: invokestatic  #126                // Method java/lang/String.valueOf:(D)Ljava/lang/String;
     263: areturn
     264: aload_0
     265: checkcast     #89                 // class java/lang/CharSequence
     268: ldc           #132                // String /
     270: checkcast     #89                 // class java/lang/CharSequence
     273: iconst_0
     274: iconst_2
     275: aconst_null
     276: invokestatic  #97                 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z
     279: ifeq          350
     282: aload_0
     283: checkcast     #89                 // class java/lang/CharSequence
     286: invokestatic  #101                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     289: invokevirtual #102                // Method java/lang/Object.toString:()Ljava/lang/String;
     292: checkcast     #89                 // class java/lang/CharSequence
     295: iconst_1
     296: anewarray     #52                 // class java/lang/String
     299: astore_2
     300: aload_2
     301: iconst_0
     302: ldc           #132                // String /
     304: aastore
     305: aload_2
     306: iconst_0
     307: iconst_0
     308: bipush        6
     310: aconst_null
     311: invokestatic  #106                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     314: astore_1
     315: aload_1
     316: iconst_0
     317: invokeinterface #112,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     322: checkcast     #52                 // class java/lang/String
     325: invokestatic  #118                // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D
     328: aload_1
     329: iconst_1
     330: invokeinterface #112,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     335: checkcast     #52                 // class java/lang/String
     338: invokestatic  #118                // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D
     341: ldc           #132                // String /
     343: invokestatic  #122                // Method operate:(DDLjava/lang/String;)D
     346: invokestatic  #126                // Method java/lang/String.valueOf:(D)Ljava/lang/String;
     349: areturn
     350: ldc           #134                // String error: 您输入的表达式有误
     352: areturn

  public static final double operate(double, double, java.lang.String);
    Code:
       0: aload         4
       2: ldc           #138                // String operator
       4: invokestatic  #87                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload         4
       9: astore        5
      11: aload         5
      13: invokevirtual #142                // Method java/lang/String.hashCode:()I
      16: tableswitch   { // 42 to 47
                    42: 56
                    43: 69
                    44: 132
                    45: 82
                    46: 132
                    47: 95
               default: 132
          }
      56: aload         5
      58: ldc           #130                // String *
      60: invokevirtual #56                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      63: ifne          120
      66: goto          132
      69: aload         5
      71: ldc           #91                 // String +
      73: invokevirtual #56                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      76: ifne          108
      79: goto          132
      82: aload         5
      84: ldc           #128                // String -
      86: invokevirtual #56                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      89: ifne          114
      92: goto          132
      95: aload         5
      97: ldc           #132                // String /
      99: invokevirtual #56                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     102: ifne          126
     105: goto          132
     108: dload_0
     109: dload_2
     110: dadd
     111: goto          133
     114: dload_0
     115: dload_2
     116: dsub
     117: goto          133
     120: dload_0
     121: dload_2
     122: dmul
     123: goto          133
     126: dload_0
     127: dload_2
     128: ddiv
     129: goto          133
     132: dconst_0
     133: dreturn

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