package day5

class Day5 {
    fun getOrganizer(filename: String): CrateOrganizer {
        val readLines = this::class.java.getResourceAsStream(filename).bufferedReader().readLines()

        return CrateOrganizer(readLines)
    }
}

/*
[N]         [C]     [Z]
[Q] [G]     [V]     [S]         [V]
[L] [C]     [M]     [T]     [W] [L]
[S] [H]     [L]     [C] [D] [H] [S]
[C] [V] [F] [D]     [D] [B] [Q] [F]
[Z] [T] [Z] [T] [C] [J] [G] [S] [Q]
[P] [P] [C] [W] [W] [F] [W] [J] [C]
[T] [L] [D] [G] [P] [P] [V] [N] [R]
 1   2   3   4   5   6   7   8   9

stackNumber

1 => 0-2
2 => 4-6
3 => 8-10
4 => 12-14
5 => 16-18
6 => 20-22
7 => 24-26
8 => 28-30
9 => 32-34

 */

data class CrateOrganizer(val input: List<String>) {
    val stackSize: Int
    val stacks: Map<Int, Stack>
    val commands: List<Command>

    init {
        println(input.first { it.startsWith(" 1 ") }.trim().replace("\\s{2,}".toRegex(), " ").split(" "))
        //  1   2   3   4   5   6   7   8   9 ==> 1 2 3 4 5 6 7 8 9 ==> 9
        stackSize = input.first { it.startsWith(" 1 ") }.trim().replace("\\s{2,}".toRegex(), " ").split(" ").size

        val cratesInput = input.takeWhile { !it.startsWith( " 1 ") }
        println(cratesInput)

        stacks = (1..stackSize)
            .map { stackNumber -> cratesInput.map { it.substring((stackNumber-1)*4, (stackNumber-1)*4 + 2) } }
            .map { crateInput -> crateInput.mapNotNull { Crate.fromString(it) }}
            .map { Stack(it) }
            .withIndex().associateBy({it.index + 1}, {it.value})

        commands = input.takeLastWhile { it.startsWith("move") }.map { Command.fromString(it) }
    }

    fun organizeWithCrateMover9000(): Stacks {
        return Stacks(commands.fold(stacks) { acc, command -> performCommand9000(acc, command) })
    }

    fun organizeWithCrateMover9001(): Stacks {
        return Stacks(commands.fold(stacks) { acc, command -> performCommand9001(acc, command) })
    }

    private fun performCommand9000(stacks: Map<Int, Stack>, command: Command): Map<Int, Stack> {
        if (command.repetitions == 0) return stacks
        //println("Moving ${command.repetitions} from ${command.from} to ${command.to}")

        val fromStack = stacks[command.from]!!
        val toStack = stacks[command.to]!!

        val movedCrates = fromStack.crates.take(1)

        val outputStack = stacks.toMutableMap()
        outputStack[command.from] = Stack(fromStack.crates.drop(1))
        outputStack[command.to] = Stack(movedCrates + toStack.crates)
        //println("Operation resulted in $outputStack")
        return performCommand9000(outputStack, Command(repetitions = command.repetitions -1, from = command.from, to = command.to))
    }

    private fun performCommand9001(stacks: Map<Int, Stack>, command: Command): Map<Int, Stack> {
        //println("Moving ${command.repetitions} from ${command.from} to ${command.to}")

        val fromStack = stacks[command.from]!!
        val toStack = stacks[command.to]!!

        val movedCrates = fromStack.crates.take(command.repetitions)

        val outputStack = stacks.toMutableMap()
        outputStack[command.from] = Stack(fromStack.crates.drop(command.repetitions))
        outputStack[command.to] = Stack(movedCrates + toStack.crates)
        //println("Operation resulted in $outputStack")
        return outputStack
    }

}

data class Stacks(val input: Map<Int, Stack>) {
    val topCrates = input.entries.sortedBy { it.key }.map { it.value }.map {it.topCrate()}.map { it.value }.joinToString("")
}

data class Stack(val crates: List<Crate>) {

    fun topCrate(): Crate = crates[0]

    override fun toString(): String {
        return crates.toString()
    }
}

data class Crate(val value: Char) {

    override fun toString(): String {
        return "[$value]"
    }
    companion object {
        fun fromString(input: String): Crate? {
            if (input.isNullOrBlank()) return null
            return Crate(input[1])
        }
    }
}

data class Command(val repetitions: Int, val from: Int, val to: Int) {

    override fun toString(): String {
        return "[repetitions=$repetitions][from=$from][to=$to]"
    }

    companion object {
        fun fromString(input: String): Command {
            val parts = input.split(" ")
            val repetitions = parts[1].toInt()
            val from = parts[3].toInt()
            val to = parts[5].toInt()
            return Command(repetitions, from, to)
        }
    }
}

fun main() {
    val testOrganizer = Day5().getOrganizer("/day5_test.txt")
    val inputOrganizer = Day5().getOrganizer("/day5_input.txt")

    println("Test stacks: ${testOrganizer.stackSize}")
    println("Test stacks: ${testOrganizer.stacks}")
    println("Test stacks: ${testOrganizer.commands}")

    val resultingStacks = testOrganizer.organizeWithCrateMover9000()
    println("Test stacks top crates: ${resultingStacks.topCrates}")
    val inputResultingStacks = inputOrganizer.organizeWithCrateMover9000()
    println("Input stacks top crates: ${inputResultingStacks.topCrates}")

    val resultingStacks9001 = testOrganizer.organizeWithCrateMover9001()
    println("Test stacks top crates: ${resultingStacks9001.topCrates}")
    val inputResultingStacks9001 = inputOrganizer.organizeWithCrateMover9001()
    println("Input stacks top crates: ${inputResultingStacks9001.topCrates}")
}

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

  public final day5.CrateOrganizer getOrganizer(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #15                 // String filename
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #25                 // Method java/lang/Object.getClass:()Ljava/lang/Class;
      10: aload_1
      11: invokevirtual #31                 // Method java/lang/Class.getResourceAsStream:(Ljava/lang/String;)Ljava/io/InputStream;
      14: dup
      15: ldc           #33                 // String getResourceAsStream(...)
      17: invokestatic  #36                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      20: astore_3
      21: getstatic     #42                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      24: astore        4
      26: new           #44                 // class java/io/InputStreamReader
      29: dup
      30: aload_3
      31: aload         4
      33: invokespecial #47                 // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
      36: checkcast     #49                 // class java/io/Reader
      39: astore        5
      41: sipush        8192
      44: istore        6
      46: aload         5
      48: instanceof    #51                 // class java/io/BufferedReader
      51: ifeq          62
      54: aload         5
      56: checkcast     #51                 // class java/io/BufferedReader
      59: goto          73
      62: new           #51                 // class java/io/BufferedReader
      65: dup
      66: aload         5
      68: iload         6
      70: invokespecial #54                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
      73: checkcast     #49                 // class java/io/Reader
      76: invokestatic  #60                 // Method kotlin/io/TextStreamsKt.readLines:(Ljava/io/Reader;)Ljava/util/List;
      79: astore_2
      80: new           #62                 // class day5/CrateOrganizer
      83: dup
      84: aload_2
      85: invokespecial #65                 // Method day5/CrateOrganizer."<init>":(Ljava/util/List;)V
      88: areturn
}

Compiled from "Day5.kt"
public final class day5.Day5Kt {
  public static final void main();
    Code:
       0: new           #8                  // class day5/Day5
       3: dup
       4: invokespecial #11                 // Method day5/Day5."<init>":()V
       7: ldc           #13                 // String /day5_test.txt
       9: invokevirtual #17                 // Method day5/Day5.getOrganizer:(Ljava/lang/String;)Lday5/CrateOrganizer;
      12: astore_0
      13: new           #8                  // class day5/Day5
      16: dup
      17: invokespecial #11                 // Method day5/Day5."<init>":()V
      20: ldc           #19                 // String /day5_input.txt
      22: invokevirtual #17                 // Method day5/Day5.getOrganizer:(Ljava/lang/String;)Lday5/CrateOrganizer;
      25: astore_1
      26: new           #21                 // class java/lang/StringBuilder
      29: dup
      30: invokespecial #22                 // Method java/lang/StringBuilder."<init>":()V
      33: ldc           #24                 // String Test stacks:
      35: invokevirtual #28                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      38: aload_0
      39: invokevirtual #34                 // Method day5/CrateOrganizer.getStackSize:()I
      42: invokevirtual #37                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      45: invokevirtual #41                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      48: getstatic     #47                 // Field java/lang/System.out:Ljava/io/PrintStream;
      51: swap
      52: invokevirtual #53                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      55: new           #21                 // class java/lang/StringBuilder
      58: dup
      59: invokespecial #22                 // Method java/lang/StringBuilder."<init>":()V
      62: ldc           #24                 // String Test stacks:
      64: invokevirtual #28                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      67: aload_0
      68: invokevirtual #57                 // Method day5/CrateOrganizer.getStacks:()Ljava/util/Map;
      71: invokevirtual #60                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      74: invokevirtual #41                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      77: getstatic     #47                 // Field java/lang/System.out:Ljava/io/PrintStream;
      80: swap
      81: invokevirtual #53                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      84: new           #21                 // class java/lang/StringBuilder
      87: dup
      88: invokespecial #22                 // Method java/lang/StringBuilder."<init>":()V
      91: ldc           #24                 // String Test stacks:
      93: invokevirtual #28                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      96: aload_0
      97: invokevirtual #64                 // Method day5/CrateOrganizer.getCommands:()Ljava/util/List;
     100: invokevirtual #60                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     103: invokevirtual #41                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     106: getstatic     #47                 // Field java/lang/System.out:Ljava/io/PrintStream;
     109: swap
     110: invokevirtual #53                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     113: aload_0
     114: invokevirtual #68                 // Method day5/CrateOrganizer.organizeWithCrateMover9000:()Lday5/Stacks;
     117: astore_2
     118: new           #21                 // class java/lang/StringBuilder
     121: dup
     122: invokespecial #22                 // Method java/lang/StringBuilder."<init>":()V
     125: ldc           #70                 // String Test stacks top crates:
     127: invokevirtual #28                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     130: aload_2
     131: invokevirtual #75                 // Method day5/Stacks.getTopCrates:()Ljava/lang/String;
     134: invokevirtual #28                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     137: invokevirtual #41                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     140: getstatic     #47                 // Field java/lang/System.out:Ljava/io/PrintStream;
     143: swap
     144: invokevirtual #53                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     147: aload_1
     148: invokevirtual #68                 // Method day5/CrateOrganizer.organizeWithCrateMover9000:()Lday5/Stacks;
     151: astore_3
     152: new           #21                 // class java/lang/StringBuilder
     155: dup
     156: invokespecial #22                 // Method java/lang/StringBuilder."<init>":()V
     159: ldc           #77                 // String Input stacks top crates:
     161: invokevirtual #28                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     164: aload_3
     165: invokevirtual #75                 // Method day5/Stacks.getTopCrates:()Ljava/lang/String;
     168: invokevirtual #28                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     171: invokevirtual #41                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     174: getstatic     #47                 // Field java/lang/System.out:Ljava/io/PrintStream;
     177: swap
     178: invokevirtual #53                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     181: aload_0
     182: invokevirtual #80                 // Method day5/CrateOrganizer.organizeWithCrateMover9001:()Lday5/Stacks;
     185: astore        4
     187: new           #21                 // class java/lang/StringBuilder
     190: dup
     191: invokespecial #22                 // Method java/lang/StringBuilder."<init>":()V
     194: ldc           #70                 // String Test stacks top crates:
     196: invokevirtual #28                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     199: aload         4
     201: invokevirtual #75                 // Method day5/Stacks.getTopCrates:()Ljava/lang/String;
     204: invokevirtual #28                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     207: invokevirtual #41                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     210: getstatic     #47                 // Field java/lang/System.out:Ljava/io/PrintStream;
     213: swap
     214: invokevirtual #53                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     217: aload_1
     218: invokevirtual #80                 // Method day5/CrateOrganizer.organizeWithCrateMover9001:()Lday5/Stacks;
     221: astore        5
     223: new           #21                 // class java/lang/StringBuilder
     226: dup
     227: invokespecial #22                 // Method java/lang/StringBuilder."<init>":()V
     230: ldc           #77                 // String Input stacks top crates:
     232: invokevirtual #28                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     235: aload         5
     237: invokevirtual #75                 // Method day5/Stacks.getTopCrates:()Ljava/lang/String;
     240: invokevirtual #28                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     243: invokevirtual #41                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     246: getstatic     #47                 // Field java/lang/System.out:Ljava/io/PrintStream;
     249: swap
     250: invokevirtual #53                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     253: return

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


package day7

import day6.Day6

class Day7(input: List<String>) {
    val commands = parseCommands(listOf(), input)

    private val pathMap = buildMap()

    private fun parseCommands(initial: List<Command>, input: List<String>): List<Command> {
        if (input.isEmpty()) return initial
        val line = input.first().split(" ")
        val commandInput = line[1]
        val tail = input.drop(1)
        if (commandInput == "cd") return parseCommands(initial + Command.Cd(line[2]), tail)
        if (commandInput == "ls") {
            val results = tail.takeWhile { !it.startsWith("$") }
            return parseCommands(initial + Command.Ls(results), tail.drop(results.size))
        }
        println("Should not reach this..?")
        return initial
    }

    private fun buildMap(): Map<String, Pair<Int, List<String>>> {
        val resultMap = mutableMapOf<String, Pair<Int, List<String>>>()
        var currentDir: List<String> = listOf()
        commands.forEach {
            when (it) {
                is Command.Cd -> {
                    currentDir = when (it.path) {
                        "/" -> {
                            listOf()
                        }
                        ".." -> {
                            currentDir.dropLast(1)
                        }
                        else -> {
                            currentDir.plus(it.path)
                        }
                    }
                }
                is Command.Ls -> {
                    val currnetPath = computePath(currentDir)
                    val dirs = it.result.filter { c ->  c.startsWith("dir") }.map { c -> c.split(" ")[1] }.map { path -> computePath(currentDir + path) }
                    val size = it.result.filter { c -> !c.startsWith("dir") }.map { c -> c.split(" ")[0].toInt() }.sum()
                    resultMap[currnetPath] = Pair(size, dirs)
                }
            }
        }
        return resultMap
    }

    private fun computePath(currentDir: List<String>): String {
        if (currentDir.isEmpty()) return "/"
        return "/" + currentDir.joinToString("/")
    }

    fun part1(): Int {
        val scoreMap = scoreMap()
        return scoreMap.filter { it.second < 100000 }.sumOf { it.second }
    }

    private fun scoreMap(): List<Pair<String, Int>> {
        return pathMap.keys.map { it to computeScore(it) }
    }

    fun part2(): Int {
        val totalSpace = 70000000
        val neededSpace = 30000000
        val usedSpace = computeScore("/")
        val availableSpace = totalSpace - usedSpace
        val toBeDeleted = neededSpace - availableSpace

        //println("UsedSpace = $usedSpace, toBeDeleted=$toBeDeleted")

        return scoreMap().map { it.second }.filter { it > toBeDeleted }.minBy { it }
    }

    private fun computeScore(path: String): Int {
        val pathScore = pathMap[path]!!
        val dirScore = pathScore.first
        val subdirScore = pathScore.second.sumOf { computeScore(it) }

        return dirScore.plus(subdirScore)
    }
}

sealed class Command {
    data class Cd(val path: String): Command()
    data class Ls(val result: List<String>): Command()
}

    fun main() {
        val testInput = Day6::class.java.getResourceAsStream("/day7_test.txt").bufferedReader().readLines()
        val input = Day6::class.java.getResourceAsStream("/day7_input.txt").bufferedReader().readLines()

        val day7Test = Day7(testInput)
//        println(day7Test.commands)
//        println(day7Test.buildMap())
        println("Part 1 test answer: ${day7Test.part1()}")
        println("Part 2 test answer: ${day7Test.part2()}")

        val day7Input = Day7(input)
//        println(day7Input.commands)
//        println(day7Input.buildMap())
        println("Part 1 answer: ${day7Input.part1()}")
        println("Part 2 answer: ${day7Input.part2()}")
}

Compiled from "Day7.kt"
public final class day7.Day7 {
  private final java.util.List<day7.Command> commands;

  private final java.util.Map<java.lang.String, kotlin.Pair<java.lang.Integer, java.util.List<java.lang.String>>> pathMap;

  public day7.Day7(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #10                 // String input
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #19                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_0
      12: invokestatic  #25                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      15: aload_1
      16: invokespecial #29                 // Method parseCommands:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;
      19: putfield      #33                 // Field commands:Ljava/util/List;
      22: aload_0
      23: aload_0
      24: invokespecial #37                 // Method buildMap:()Ljava/util/Map;
      27: putfield      #41                 // Field pathMap:Ljava/util/Map;
      30: return

  public final java.util.List<day7.Command> getCommands();
    Code:
       0: aload_0
       1: getfield      #33                 // Field commands:Ljava/util/List;
       4: areturn

  private final java.util.List<day7.Command> parseCommands(java.util.List<? extends day7.Command>, java.util.List<java.lang.String>);
    Code:
       0: aload_2
       1: invokeinterface #52,  1           // InterfaceMethod java/util/List.isEmpty:()Z
       6: ifeq          11
       9: aload_1
      10: areturn
      11: aload_2
      12: invokestatic  #56                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      15: checkcast     #58                 // class java/lang/CharSequence
      18: iconst_1
      19: anewarray     #60                 // class java/lang/String
      22: astore        4
      24: aload         4
      26: iconst_0
      27: ldc           #62                 // String
      29: aastore
      30: aload         4
      32: iconst_0
      33: iconst_0
      34: bipush        6
      36: aconst_null
      37: invokestatic  #68                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      40: astore_3
      41: aload_3
      42: iconst_1
      43: invokeinterface #72,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      48: checkcast     #60                 // class java/lang/String
      51: astore        4
      53: aload_2
      54: checkcast     #74                 // class java/lang/Iterable
      57: iconst_1
      58: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
      61: astore        5
      63: aload         4
      65: ldc           #80                 // String cd
      67: invokestatic  #84                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      70: ifeq          104
      73: aload_0
      74: aload_1
      75: checkcast     #86                 // class java/util/Collection
      78: new           #88                 // class day7/Command$Cd
      81: dup
      82: aload_3
      83: iconst_2
      84: invokeinterface #72,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      89: checkcast     #60                 // class java/lang/String
      92: invokespecial #91                 // Method day7/Command$Cd."<init>":(Ljava/lang/String;)V
      95: invokestatic  #95                 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
      98: aload         5
     100: invokespecial #29                 // Method parseCommands:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;
     103: areturn
     104: aload         4
     106: ldc           #97                 // String ls
     108: invokestatic  #84                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     111: ifeq          249
     114: aload         5
     116: checkcast     #74                 // class java/lang/Iterable
     119: astore        7
     121: iconst_0
     122: istore        8
     124: new           #99                 // class java/util/ArrayList
     127: dup
     128: invokespecial #100                // Method java/util/ArrayList."<init>":()V
     131: astore        9
     133: aload         7
     135: invokeinterface #104,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     140: astore        10
     142: aload         10
     144: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     149: ifeq          206
     152: aload         10
     154: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     159: astore        11
     161: aload         11
     163: checkcast     #60                 // class java/lang/String
     166: astore        12
     168: iconst_0
     169: istore        13
     171: aload         12
     173: ldc           #115                // String $
     175: iconst_0
     176: iconst_2
     177: aconst_null
     178: invokestatic  #119                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
     181: ifne          188
     184: iconst_1
     185: goto          189
     188: iconst_0
     189: ifne          195
     192: goto          206
     195: aload         9
     197: aload         11
     199: invokevirtual #123                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     202: pop
     203: goto          142
     206: aload         9
     208: checkcast     #48                 // class java/util/List
     211: astore        6
     213: aload_0
     214: aload_1
     215: checkcast     #86                 // class java/util/Collection
     218: new           #125                // class day7/Command$Ls
     221: dup
     222: aload         6
     224: invokespecial #127                // Method day7/Command$Ls."<init>":(Ljava/util/List;)V
     227: invokestatic  #95                 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     230: aload         5
     232: checkcast     #74                 // class java/lang/Iterable
     235: aload         6
     237: invokeinterface #131,  1          // InterfaceMethod java/util/List.size:()I
     242: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     245: invokespecial #29                 // Method parseCommands:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;
     248: areturn
     249: ldc           #133                // String Should not reach this..?
     251: getstatic     #139                // Field java/lang/System.out:Ljava/io/PrintStream;
     254: swap
     255: invokevirtual #145                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     258: aload_1
     259: areturn

  private final java.util.Map<java.lang.String, kotlin.Pair<java.lang.Integer, java.util.List<java.lang.String>>> buildMap();
    Code:
       0: new           #164                // class java/util/LinkedHashMap
       3: dup
       4: invokespecial #165                // Method java/util/LinkedHashMap."<init>":()V
       7: checkcast     #167                // class java/util/Map
      10: astore_1
      11: aconst_null
      12: astore_2
      13: invokestatic  #25                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      16: astore_2
      17: aload_0
      18: getfield      #33                 // Field commands:Ljava/util/List;
      21: checkcast     #74                 // class java/lang/Iterable
      24: astore_3
      25: iconst_0
      26: istore        4
      28: aload_3
      29: invokeinterface #104,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      34: astore        5
      36: aload         5
      38: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      43: ifeq          799
      46: aload         5
      48: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      53: astore        6
      55: aload         6
      57: checkcast     #169                // class day7/Command
      60: astore        7
      62: iconst_0
      63: istore        8
      65: aload         7
      67: astore        9
      69: aload         9
      71: instanceof    #88                 // class day7/Command$Cd
      74: ifeq          140
      77: aload         7
      79: checkcast     #88                 // class day7/Command$Cd
      82: invokevirtual #173                // Method day7/Command$Cd.getPath:()Ljava/lang/String;
      85: astore        10
      87: aload         10
      89: ldc           #175                // String /
      91: invokestatic  #84                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      94: ifeq          103
      97: invokestatic  #25                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     100: goto          136
     103: aload         10
     105: ldc           #177                // String ..
     107: invokestatic  #84                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     110: ifeq          121
     113: aload_2
     114: iconst_1
     115: invokestatic  #181                // Method kotlin/collections/CollectionsKt.dropLast:(Ljava/util/List;I)Ljava/util/List;
     118: goto          136
     121: aload_2
     122: checkcast     #86                 // class java/util/Collection
     125: aload         7
     127: checkcast     #88                 // class day7/Command$Cd
     130: invokevirtual #173                // Method day7/Command$Cd.getPath:()Ljava/lang/String;
     133: invokestatic  #95                 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     136: astore_2
     137: goto          794
     140: aload         9
     142: instanceof    #125                // class day7/Command$Ls
     145: ifeq          786
     148: aload_0
     149: aload_2
     150: invokespecial #185                // Method computePath:(Ljava/util/List;)Ljava/lang/String;
     153: astore        10
     155: aload         7
     157: checkcast     #125                // class day7/Command$Ls
     160: invokevirtual #188                // Method day7/Command$Ls.getResult:()Ljava/util/List;
     163: checkcast     #74                 // class java/lang/Iterable
     166: astore        11
     168: iconst_0
     169: istore        12
     171: aload         11
     173: astore        13
     175: new           #99                 // class java/util/ArrayList
     178: dup
     179: invokespecial #100                // Method java/util/ArrayList."<init>":()V
     182: checkcast     #86                 // class java/util/Collection
     185: astore        14
     187: iconst_0
     188: istore        15
     190: aload         13
     192: invokeinterface #104,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     197: astore        16
     199: aload         16
     201: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     206: ifeq          254
     209: aload         16
     211: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     216: astore        17
     218: aload         17
     220: checkcast     #60                 // class java/lang/String
     223: astore        18
     225: iconst_0
     226: istore        19
     228: aload         18
     230: ldc           #190                // String dir
     232: iconst_0
     233: iconst_2
     234: aconst_null
     235: invokestatic  #119                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
     238: ifeq          199
     241: aload         14
     243: aload         17
     245: invokeinterface #191,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     250: pop
     251: goto          199
     254: aload         14
     256: checkcast     #48                 // class java/util/List
     259: nop
     260: checkcast     #74                 // class java/lang/Iterable
     263: astore        11
     265: nop
     266: iconst_0
     267: istore        12
     269: aload         11
     271: astore        13
     273: new           #99                 // class java/util/ArrayList
     276: dup
     277: aload         11
     279: bipush        10
     281: invokestatic  #195                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     284: invokespecial #198                // Method java/util/ArrayList."<init>":(I)V
     287: checkcast     #86                 // class java/util/Collection
     290: astore        14
     292: iconst_0
     293: istore        15
     295: aload         13
     297: invokeinterface #104,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     302: astore        16
     304: aload         16
     306: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     311: ifeq          385
     314: aload         16
     316: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     321: astore        17
     323: aload         14
     325: aload         17
     327: checkcast     #60                 // class java/lang/String
     330: astore        18
     332: astore        20
     334: iconst_0
     335: istore        19
     337: aload         18
     339: checkcast     #58                 // class java/lang/CharSequence
     342: iconst_1
     343: anewarray     #60                 // class java/lang/String
     346: astore        21
     348: aload         21
     350: iconst_0
     351: ldc           #62                 // String
     353: aastore
     354: aload         21
     356: iconst_0
     357: iconst_0
     358: bipush        6
     360: aconst_null
     361: invokestatic  #68                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     364: iconst_1
     365: invokeinterface #72,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     370: checkcast     #60                 // class java/lang/String
     373: aload         20
     375: swap
     376: invokeinterface #191,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     381: pop
     382: goto          304
     385: aload         14
     387: checkcast     #48                 // class java/util/List
     390: nop
     391: checkcast     #74                 // class java/lang/Iterable
     394: astore        11
     396: nop
     397: iconst_0
     398: istore        12
     400: aload         11
     402: astore        13
     404: new           #99                 // class java/util/ArrayList
     407: dup
     408: aload         11
     410: bipush        10
     412: invokestatic  #195                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     415: invokespecial #198                // Method java/util/ArrayList."<init>":(I)V
     418: checkcast     #86                 // class java/util/Collection
     421: astore        14
     423: iconst_0
     424: istore        15
     426: aload         13
     428: invokeinterface #104,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     433: astore        16
     435: aload         16
     437: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     442: ifeq          493
     445: aload         16
     447: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     452: astore        17
     454: aload         14
     456: aload         17
     458: checkcast     #60                 // class java/lang/String
     461: astore        18
     463: astore        20
     465: iconst_0
     466: istore        19
     468: aload_0
     469: aload_2
     470: checkcast     #86                 // class java/util/Collection
     473: aload         18
     475: invokestatic  #95                 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     478: invokespecial #185                // Method computePath:(Ljava/util/List;)Ljava/lang/String;
     481: aload         20
     483: swap
     484: invokeinterface #191,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     489: pop
     490: goto          435
     493: aload         14
     495: checkcast     #48                 // class java/util/List
     498: nop
     499: astore        22
     501: aload         7
     503: checkcast     #125                // class day7/Command$Ls
     506: invokevirtual #188                // Method day7/Command$Ls.getResult:()Ljava/util/List;
     509: checkcast     #74                 // class java/lang/Iterable
     512: astore        12
     514: iconst_0
     515: istore        13
     517: aload         12
     519: astore        14
     521: new           #99                 // class java/util/ArrayList
     524: dup
     525: invokespecial #100                // Method java/util/ArrayList."<init>":()V
     528: checkcast     #86                 // class java/util/Collection
     531: astore        15
     533: iconst_0
     534: istore        16
     536: aload         14
     538: invokeinterface #104,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     543: astore        17
     545: aload         17
     547: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     552: ifeq          608
     555: aload         17
     557: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     562: astore        18
     564: aload         18
     566: checkcast     #60                 // class java/lang/String
     569: astore        19
     571: iconst_0
     572: istore        21
     574: aload         19
     576: ldc           #190                // String dir
     578: iconst_0
     579: iconst_2
     580: aconst_null
     581: invokestatic  #119                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
     584: ifne          591
     587: iconst_1
     588: goto          592
     591: iconst_0
     592: ifeq          545
     595: aload         15
     597: aload         18
     599: invokeinterface #191,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     604: pop
     605: goto          545
     608: aload         15
     610: checkcast     #48                 // class java/util/List
     613: nop
     614: checkcast     #74                 // class java/lang/Iterable
     617: astore        12
     619: nop
     620: iconst_0
     621: istore        13
     623: aload         12
     625: astore        14
     627: new           #99                 // class java/util/ArrayList
     630: dup
     631: aload         12
     633: bipush        10
     635: invokestatic  #195                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     638: invokespecial #198                // Method java/util/ArrayList."<init>":(I)V
     641: checkcast     #86                 // class java/util/Collection
     644: astore        15
     646: iconst_0
     647: istore        16
     649: aload         14
     651: invokeinterface #104,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     656: astore        17
     658: aload         17
     660: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     665: ifeq          746
     668: aload         17
     670: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     675: astore        18
     677: aload         15
     679: aload         18
     681: checkcast     #60                 // class java/lang/String
     684: astore        19
     686: astore        20
     688: iconst_0
     689: istore        21
     691: aload         19
     693: checkcast     #58                 // class java/lang/CharSequence
     696: iconst_1
     697: anewarray     #60                 // class java/lang/String
     700: astore        23
     702: aload         23
     704: iconst_0
     705: ldc           #62                 // String
     707: aastore
     708: aload         23
     710: iconst_0
     711: iconst_0
     712: bipush        6
     714: aconst_null
     715: invokestatic  #68                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     718: iconst_0
     719: invokeinterface #72,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     724: checkcast     #60                 // class java/lang/String
     727: invokestatic  #204                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     730: nop
     731: invokestatic  #208                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     734: aload         20
     736: swap
     737: invokeinterface #191,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     742: pop
     743: goto          658
     746: aload         15
     748: checkcast     #48                 // class java/util/List
     751: nop
     752: checkcast     #74                 // class java/lang/Iterable
     755: invokestatic  #212                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     758: istore        11
     760: aload_1
     761: aload         10
     763: new           #214                // class kotlin/Pair
     766: dup
     767: iload         11
     769: invokestatic  #208                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     772: aload         22
     774: invokespecial #217                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     777: invokeinterface #221,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     782: pop
     783: goto          794
     786: new           #223                // class kotlin/NoWhenBranchMatchedException
     789: dup
     790: invokespecial #224                // Method kotlin/NoWhenBranchMatchedException."<init>":()V
     793: athrow
     794: nop
     795: nop
     796: goto          36
     799: nop
     800: aload_1
     801: areturn

  private final java.lang.String computePath(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: invokeinterface #52,  1           // InterfaceMethod java/util/List.isEmpty:()Z
       6: ifeq          12
       9: ldc           #175                // String /
      11: areturn
      12: new           #255                // class java/lang/StringBuilder
      15: dup
      16: invokespecial #256                // Method java/lang/StringBuilder."<init>":()V
      19: bipush        47
      21: invokevirtual #260                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      24: aload_1
      25: checkcast     #74                 // class java/lang/Iterable
      28: ldc           #175                // String /
      30: checkcast     #58                 // class java/lang/CharSequence
      33: aconst_null
      34: aconst_null
      35: iconst_0
      36: aconst_null
      37: aconst_null
      38: bipush        62
      40: aconst_null
      41: invokestatic  #264                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
      44: invokevirtual #267                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      47: invokevirtual #270                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      50: areturn

  public final int part1();
    Code:
       0: aload_0
       1: invokespecial #274                // Method scoreMap:()Ljava/util/List;
       4: astore_1
       5: aload_1
       6: checkcast     #74                 // class java/lang/Iterable
       9: astore_2
      10: iconst_0
      11: istore_3
      12: aload_2
      13: astore        4
      15: new           #99                 // class java/util/ArrayList
      18: dup
      19: invokespecial #100                // Method java/util/ArrayList."<init>":()V
      22: checkcast     #86                 // class java/util/Collection
      25: astore        5
      27: iconst_0
      28: istore        6
      30: aload         4
      32: invokeinterface #104,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        7
      39: aload         7
      41: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          106
      49: aload         7
      51: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        8
      58: aload         8
      60: checkcast     #214                // class kotlin/Pair
      63: astore        9
      65: iconst_0
      66: istore        10
      68: aload         9
      70: invokevirtual #277                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      73: checkcast     #279                // class java/lang/Number
      76: invokevirtual #282                // Method java/lang/Number.intValue:()I
      79: ldc_w         #283                // int 100000
      82: if_icmpge     89
      85: iconst_1
      86: goto          90
      89: iconst_0
      90: ifeq          39
      93: aload         5
      95: aload         8
      97: invokeinterface #191,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     102: pop
     103: goto          39
     106: aload         5
     108: checkcast     #48                 // class java/util/List
     111: nop
     112: checkcast     #74                 // class java/lang/Iterable
     115: astore_2
     116: iconst_0
     117: istore_3
     118: aload_2
     119: invokeinterface #104,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     124: astore        4
     126: aload         4
     128: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     133: ifeq          180
     136: aload         4
     138: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     143: astore        5
     145: iload_3
     146: aload         5
     148: checkcast     #214                // class kotlin/Pair
     151: astore        6
     153: istore        11
     155: iconst_0
     156: istore        7
     158: aload         6
     160: invokevirtual #277                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     163: checkcast     #279                // class java/lang/Number
     166: invokevirtual #282                // Method java/lang/Number.intValue:()I
     169: istore        12
     171: iload         11
     173: iload         12
     175: iadd
     176: istore_3
     177: goto          126
     180: iload_3
     181: ireturn

  private final java.util.List<kotlin.Pair<java.lang.String, java.lang.Integer>> scoreMap();
    Code:
       0: aload_0
       1: getfield      #41                 // Field pathMap:Ljava/util/Map;
       4: invokeinterface #291,  1          // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;
       9: checkcast     #74                 // class java/lang/Iterable
      12: astore_1
      13: iconst_0
      14: istore_2
      15: aload_1
      16: astore_3
      17: new           #99                 // class java/util/ArrayList
      20: dup
      21: aload_1
      22: bipush        10
      24: invokestatic  #195                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      27: invokespecial #198                // Method java/util/ArrayList."<init>":(I)V
      30: checkcast     #86                 // class java/util/Collection
      33: astore        4
      35: iconst_0
      36: istore        5
      38: aload_3
      39: invokeinterface #104,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      44: astore        6
      46: aload         6
      48: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      53: ifeq          105
      56: aload         6
      58: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: astore        7
      65: aload         4
      67: aload         7
      69: checkcast     #60                 // class java/lang/String
      72: astore        8
      74: astore        10
      76: iconst_0
      77: istore        9
      79: aload         8
      81: aload_0
      82: aload         8
      84: invokespecial #294                // Method computeScore:(Ljava/lang/String;)I
      87: invokestatic  #208                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      90: invokestatic  #300                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      93: aload         10
      95: swap
      96: invokeinterface #191,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     101: pop
     102: goto          46
     105: aload         4
     107: checkcast     #48                 // class java/util/List
     110: nop
     111: areturn

  public final int part2();
    Code:
       0: ldc_w         #303                // int 70000000
       3: istore_1
       4: ldc_w         #304                // int 30000000
       7: istore_2
       8: aload_0
       9: ldc           #175                // String /
      11: invokespecial #294                // Method computeScore:(Ljava/lang/String;)I
      14: istore_3
      15: iload_1
      16: iload_3
      17: isub
      18: istore        4
      20: iload_2
      21: iload         4
      23: isub
      24: istore        5
      26: aload_0
      27: invokespecial #274                // Method scoreMap:()Ljava/util/List;
      30: checkcast     #74                 // class java/lang/Iterable
      33: astore        6
      35: iconst_0
      36: istore        7
      38: aload         6
      40: astore        8
      42: new           #99                 // class java/util/ArrayList
      45: dup
      46: aload         6
      48: bipush        10
      50: invokestatic  #195                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      53: invokespecial #198                // Method java/util/ArrayList."<init>":(I)V
      56: checkcast     #86                 // class java/util/Collection
      59: astore        9
      61: iconst_0
      62: istore        10
      64: aload         8
      66: invokeinterface #104,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      71: astore        11
      73: aload         11
      75: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      80: ifeq          132
      83: aload         11
      85: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      90: astore        12
      92: aload         9
      94: aload         12
      96: checkcast     #214                // class kotlin/Pair
      99: astore        13
     101: astore        15
     103: iconst_0
     104: istore        14
     106: aload         13
     108: invokevirtual #277                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     111: checkcast     #279                // class java/lang/Number
     114: invokevirtual #282                // Method java/lang/Number.intValue:()I
     117: invokestatic  #208                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     120: aload         15
     122: swap
     123: invokeinterface #191,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     128: pop
     129: goto          73
     132: aload         9
     134: checkcast     #48                 // class java/util/List
     137: nop
     138: checkcast     #74                 // class java/lang/Iterable
     141: astore        6
     143: nop
     144: iconst_0
     145: istore        7
     147: aload         6
     149: astore        8
     151: new           #99                 // class java/util/ArrayList
     154: dup
     155: invokespecial #100                // Method java/util/ArrayList."<init>":()V
     158: checkcast     #86                 // class java/util/Collection
     161: astore        9
     163: iconst_0
     164: istore        10
     166: aload         8
     168: invokeinterface #104,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     173: astore        11
     175: aload         11
     177: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     182: ifeq          235
     185: aload         11
     187: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     192: astore        12
     194: aload         12
     196: checkcast     #279                // class java/lang/Number
     199: invokevirtual #282                // Method java/lang/Number.intValue:()I
     202: istore        13
     204: iconst_0
     205: istore        14
     207: iload         13
     209: iload         5
     211: if_icmple     218
     214: iconst_1
     215: goto          219
     218: iconst_0
     219: ifeq          175
     222: aload         9
     224: aload         12
     226: invokeinterface #191,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     231: pop
     232: goto          175
     235: aload         9
     237: checkcast     #48                 // class java/util/List
     240: nop
     241: checkcast     #74                 // class java/lang/Iterable
     244: astore        6
     246: nop
     247: iconst_0
     248: istore        7
     250: aload         6
     252: invokeinterface #104,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     257: astore        8
     259: aload         8
     261: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     266: ifne          277
     269: new           #306                // class java/util/NoSuchElementException
     272: dup
     273: invokespecial #307                // Method java/util/NoSuchElementException."<init>":()V
     276: athrow
     277: aload         8
     279: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     284: astore        9
     286: aload         8
     288: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     293: ifne          301
     296: aload         9
     298: goto          371
     301: aload         9
     303: checkcast     #279                // class java/lang/Number
     306: invokevirtual #282                // Method java/lang/Number.intValue:()I
     309: istore        10
     311: iconst_0
     312: istore        11
     314: iload         10
     316: istore        10
     318: aload         8
     320: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     325: astore        11
     327: aload         11
     329: checkcast     #279                // class java/lang/Number
     332: invokevirtual #282                // Method java/lang/Number.intValue:()I
     335: istore        12
     337: iconst_0
     338: istore        13
     340: iload         12
     342: istore        12
     344: iload         10
     346: iload         12
     348: if_icmple     359
     351: aload         11
     353: astore        9
     355: iload         12
     357: istore        10
     359: aload         8
     361: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     366: ifne          318
     369: aload         9
     371: checkcast     #279                // class java/lang/Number
     374: invokevirtual #282                // Method java/lang/Number.intValue:()I
     377: ireturn

  private final int computeScore(java.lang.String);
    Code:
       0: aload_0
       1: getfield      #41                 // Field pathMap:Ljava/util/Map;
       4: aload_1
       5: invokeinterface #326,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      10: dup
      11: invokestatic  #329                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      14: checkcast     #214                // class kotlin/Pair
      17: astore_2
      18: aload_2
      19: invokevirtual #332                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      22: checkcast     #279                // class java/lang/Number
      25: invokevirtual #282                // Method java/lang/Number.intValue:()I
      28: istore_3
      29: aload_2
      30: invokevirtual #277                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      33: checkcast     #74                 // class java/lang/Iterable
      36: astore        5
      38: iconst_0
      39: istore        6
      41: aload         5
      43: invokeinterface #104,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      48: astore        7
      50: aload         7
      52: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      57: ifeq          101
      60: aload         7
      62: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      67: astore        8
      69: iload         6
      71: aload         8
      73: checkcast     #60                 // class java/lang/String
      76: astore        9
      78: istore        11
      80: iconst_0
      81: istore        10
      83: aload_0
      84: aload         9
      86: invokespecial #294                // Method computeScore:(Ljava/lang/String;)I
      89: istore        12
      91: iload         11
      93: iload         12
      95: iadd
      96: istore        6
      98: goto          50
     101: iload         6
     103: istore        4
     105: iload_3
     106: iload         4
     108: iadd
     109: ireturn
}

Compiled from "Day7.kt"
public final class day7.Day7Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // class day6/Day6
       2: ldc           #10                 // String /day7_test.txt
       4: invokevirtual #16                 // Method java/lang/Class.getResourceAsStream:(Ljava/lang/String;)Ljava/io/InputStream;
       7: dup
       8: ldc           #18                 // String getResourceAsStream(...)
      10: invokestatic  #24                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      13: astore_1
      14: getstatic     #30                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      17: astore_2
      18: new           #32                 // class java/io/InputStreamReader
      21: dup
      22: aload_1
      23: aload_2
      24: invokespecial #36                 // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
      27: checkcast     #38                 // class java/io/Reader
      30: astore_3
      31: sipush        8192
      34: istore        4
      36: aload_3
      37: instanceof    #40                 // class java/io/BufferedReader
      40: ifeq          50
      43: aload_3
      44: checkcast     #40                 // class java/io/BufferedReader
      47: goto          60
      50: new           #40                 // class java/io/BufferedReader
      53: dup
      54: aload_3
      55: iload         4
      57: invokespecial #43                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
      60: checkcast     #38                 // class java/io/Reader
      63: invokestatic  #49                 // Method kotlin/io/TextStreamsKt.readLines:(Ljava/io/Reader;)Ljava/util/List;
      66: astore_0
      67: ldc           #8                  // class day6/Day6
      69: ldc           #51                 // String /day7_input.txt
      71: invokevirtual #16                 // Method java/lang/Class.getResourceAsStream:(Ljava/lang/String;)Ljava/io/InputStream;
      74: dup
      75: ldc           #18                 // String getResourceAsStream(...)
      77: invokestatic  #24                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      80: astore_2
      81: getstatic     #30                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      84: astore_3
      85: new           #32                 // class java/io/InputStreamReader
      88: dup
      89: aload_2
      90: aload_3
      91: invokespecial #36                 // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
      94: checkcast     #38                 // class java/io/Reader
      97: astore        4
      99: sipush        8192
     102: istore        5
     104: aload         4
     106: instanceof    #40                 // class java/io/BufferedReader
     109: ifeq          120
     112: aload         4
     114: checkcast     #40                 // class java/io/BufferedReader
     117: goto          131
     120: new           #40                 // class java/io/BufferedReader
     123: dup
     124: aload         4
     126: iload         5
     128: invokespecial #43                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
     131: checkcast     #38                 // class java/io/Reader
     134: invokestatic  #49                 // Method kotlin/io/TextStreamsKt.readLines:(Ljava/io/Reader;)Ljava/util/List;
     137: astore_1
     138: new           #53                 // class day7/Day7
     141: dup
     142: aload_0
     143: invokespecial #56                 // Method day7/Day7."<init>":(Ljava/util/List;)V
     146: astore_2
     147: new           #58                 // class java/lang/StringBuilder
     150: dup
     151: invokespecial #60                 // Method java/lang/StringBuilder."<init>":()V
     154: ldc           #62                 // String Part 1 test answer:
     156: invokevirtual #66                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     159: aload_2
     160: invokevirtual #70                 // Method day7/Day7.part1:()I
     163: invokevirtual #73                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     166: invokevirtual #77                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     169: getstatic     #83                 // Field java/lang/System.out:Ljava/io/PrintStream;
     172: swap
     173: invokevirtual #89                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     176: new           #58                 // class java/lang/StringBuilder
     179: dup
     180: invokespecial #60                 // Method java/lang/StringBuilder."<init>":()V
     183: ldc           #91                 // String Part 2 test answer:
     185: invokevirtual #66                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     188: aload_2
     189: invokevirtual #94                 // Method day7/Day7.part2:()I
     192: invokevirtual #73                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     195: invokevirtual #77                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     198: getstatic     #83                 // Field java/lang/System.out:Ljava/io/PrintStream;
     201: swap
     202: invokevirtual #89                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     205: new           #53                 // class day7/Day7
     208: dup
     209: aload_1
     210: invokespecial #56                 // Method day7/Day7."<init>":(Ljava/util/List;)V
     213: astore_3
     214: new           #58                 // class java/lang/StringBuilder
     217: dup
     218: invokespecial #60                 // Method java/lang/StringBuilder."<init>":()V
     221: ldc           #96                 // String Part 1 answer:
     223: invokevirtual #66                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     226: aload_3
     227: invokevirtual #70                 // Method day7/Day7.part1:()I
     230: invokevirtual #73                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     233: invokevirtual #77                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     236: getstatic     #83                 // Field java/lang/System.out:Ljava/io/PrintStream;
     239: swap
     240: invokevirtual #89                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     243: new           #58                 // class java/lang/StringBuilder
     246: dup
     247: invokespecial #60                 // Method java/lang/StringBuilder."<init>":()V
     250: ldc           #98                 // String Part 2 answer:
     252: invokevirtual #66                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     255: aload_3
     256: invokevirtual #94                 // Method day7/Day7.part2:()I
     259: invokevirtual #73                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     262: invokevirtual #77                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     265: getstatic     #83                 // Field java/lang/System.out:Ljava/io/PrintStream;
     268: swap
     269: invokevirtual #89                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     272: return

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