package cz.wrent.advent

fun main() {
	println(partOne(test))
	val result = partOne(input)
	println("12a: $result")
	println(partTwo(test))
	println("12b: ${partTwo(input)}")
}

private fun partOne(input: String): Int {
	val map = input.parse()
	val start = map.entries.find { it.value.specialArea == SpecialArea.START }!!.key
	map[start]!!.steps = 0
	process(map, start) {
		(0..it + 1)
	}
	return map.entries.find { it.value.specialArea == SpecialArea.END }!!.value.steps
}

private fun partTwo(input: String): Int {
	val map = input.parse()
	val start = map.entries.find { it.value.specialArea == SpecialArea.END }!!.key
	map[start]!!.steps = 0
	process(map, start) {
		it - 1..Int.MAX_VALUE
	}
	return map.entries.filter { it.value.height == 'a'.code }.minByOrNull { it.value.steps }!!.value.steps
}

private fun process(map: Map<Pair<Int, Int>, Area>, start: Pair<Int, Int>, moveRange: (Int) -> IntRange) {
	var next = listOf(start)
	while (next.isNotEmpty()) {
		val n = next.last()
		next = next.dropLast(1)

		val neighbours = n.toNeighbours()

		neighbours.forEach { neighbour ->
			if (map[neighbour] != null && map[neighbour]!!.height in moveRange(map[n]!!.height) && map [neighbour]!!.steps > map[n]!!.steps + 1) {
				map[neighbour]!!.steps = map[n]!!.steps + 1
				next = next + neighbour
			}
		}
	}
}

fun Pair<Int, Int>.toNeighbours(): Set<Pair<Int, Int>> {
	return setOf(
		this.first to this.second + 1,
		this.first to this.second - 1,
		this.first + 1 to this.second,
		this.first - 1 to this.second
	)
}

private fun String.parse(): Map<Pair<Int, Int>, Area> {
	val lines = this.split("\n")
	val map = mutableMapOf<Pair<Int, Int>, Area>()
	lines.forEachIndexed { j, line ->
		line.toCharArray().map { it.code }
			.forEachIndexed { i, height ->
				if (height == 'S'.code) {
					map[i to j] = Area('a'.code, specialArea = SpecialArea.START)
				} else if (height == 'E'.code) {
					map[i to j] = Area('z'.code, specialArea = SpecialArea.END)
				} else {
					map[i to j] = Area(height)
				}
			}
	}
	return map
}

private data class Area(
	val height: Int,
	var steps: Int = Int.MAX_VALUE,
	val specialArea: SpecialArea? = null
)

private enum class SpecialArea {
	START,
	END
}

private const val test = """Sabqponm
abcryxxl
accszExk
acctuvwj
abdefghi
"""

private const val input =
	"""abcccccccaaaaaaaaccccccccccaaaaaaccccccaccaaaaaaaccccccaacccccccccaaaaaaaaaaccccccccccccccccccccccccccccccccaaaaa
abcccccccaaaaaaaaacccccccccaaaaaacccccaaacaaaaaaaaaaaccaacccccccccccaaaaaaccccccccccccccccccccccccccccccccccaaaaa
abcccccccaaaaaaaaaaccccccccaaaaaacaaacaaaaaaaaaaaaaaaaaaccccccccccccaaaaaaccccccccccccccaaacccccccccccccccccaaaaa
abaaacccccccaaaaaaacccccccccaaacccaaaaaaaaaaaaaaaaaaaaaaaaacccccccccaaaaaaccccccccccccccaaacccccccccccccccccaaaaa
abaaaaccccccaaaccccccccccccccccccccaaaaaaaaacaaaacacaaaaaacccccccccaaaaaaaacccccccccccccaaaaccaaacccccccccccaccaa
abaaaaccccccaaccccaaccccccccccccccccaaaaaaacaaaaccccaaaaaccccccccccccccccacccccccccccccccaaaaaaaaacccccccccccccca
abaaaaccccccccccccaaaacccccccccaacaaaaaaaacccaaacccaaacaacccccccccccccccccccccccccccciiiiaaaaaaaacccccccccccccccc
abaaacccccccccccaaaaaacccccccccaaaaaaaaaaacccaaacccccccaacccccccccccaacccccccccccccciiiiiiijaaaaccccccccaaccccccc
abaaaccccccccccccaaaacccccccccaaaaaaaacaaacccaaaccccccccccccccccccccaaacaaacccccccciiiiiiiijjjacccccccccaaacccccc
abcccccaacaacccccaaaaaccccccccaaaaaacccccacaacccccccccccccccccccccccaaaaaaaccccccciiiinnnoijjjjjjjjkkkaaaaaaacccc
abcccccaaaaacccccaacaaccccccccccaaaacccaaaaaaccccccccccccccccccccccccaaaaaaccccccciiinnnnooojjjjjjjkkkkaaaaaacccc
abccccaaaaacccccccccccccccccccccaccccccaaaaaaaccccccccccccccccccccaaaaaaaaccccccchhinnnnnoooojjooopkkkkkaaaaccccc
abccccaaaaaaccccccccccccccccccccccccccccaaaaaaacccccccccccccccccccaaaaaaaaacccccchhhnnntttuooooooopppkkkaaaaccccc
abccccccaaaaccccccccccacccccccccccccccccaaaaaaacccaaccccccccccccccaaaaaaaaaaccccchhhnnttttuuoooooppppkkkaaaaccccc
abccccccaccccccccccccaaaacaaaccccccccccaaaaaacaaccaacccaaccccccccccccaaacaaacccchhhnnnttttuuuuuuuuupppkkccaaccccc
abccccccccccccccaaccccaaaaaaaccccccccccaaaaaacaaaaaacccaaaaaaccccccccaaacccccccchhhnnntttxxxuuuuuuupppkkccccccccc
abcccccccccccccaaaacccaaaaaaacccaccccccccccaaccaaaaaaacaaaaaaccccccccaacccaaccchhhhnnnttxxxxuuyyyuupppkkccccccccc
abcccccccccccccaaaaccaaaaaaaaacaaacccccccccccccaaaaaaaaaaaaaccccccccccccccaaachhhhmnnnttxxxxxxyyyuvppkkkccccccccc
abcccccccccccccaaaacaaaaaaaaaaaaaaccccccccccccaaaaaacaaaaaaaccccccccccccccaaaghhhmmmttttxxxxxyyyyvvpplllccccccccc
abccacccccccccccccccaaaaaaaaaaaaaaccccccccccccaaaaaacccaaaaaacccaacaacccaaaaagggmmmttttxxxxxyyyyvvppplllccccccccc
SbaaaccccccccccccccccccaaacaaaaaaaacccccccccccccccaacccaaccaacccaaaaacccaaaagggmmmsttxxxEzzzzyyvvvppplllccccccccc
abaaaccccccccccccccccccaaaaaaaaaaaaacaaccccccccccccccccaaccccccccaaaaaccccaagggmmmsssxxxxxyyyyyyvvvqqqlllcccccccc
abaaacccccccccccccccccccaaaaaaaaaaaaaaaaacccccccccccccccccccccccaaaaaaccccaagggmmmsssxxxwywyyyyyyvvvqqlllcccccccc
abaaaaacccccccccccccccccccaacaaaccaaaaaaacccccccccccccccccccccccaaaaccccccaagggmmmssswwwwwyyyyyyyvvvqqqllcccccccc
abaaaaaccccccccccccccccccccccaaaccccaaaacccccccccccccccccaaccaacccaaccccccccgggmmmmssssswwyywwvvvvvvqqqlllccccccc
abaaaaacccccccccccccaccacccccaaaccccaaaacccccccccccccccccaaaaaacccccccccccaaggggmllllsssswwywwwvvvvqqqqlllccccccc
abaaccccccccccccccccaaaaccccccccccccaccaccccccccccccccccccaaaaacccccccccccaaagggglllllssswwwwwrrqqqqqqmmllccccccc
abaaccccccccccccccccaaaaaccccccaaccaaccccccccccccccccccccaaaaaaccaacccccccaaaaggfffllllsswwwwrrrrqqqqqmmmcccccccc
abacaaaccccccccccccaaaaaaccccccaaaaaaccccccaacccccccccccaaaaaaaacaaacaaccccaaaaffffflllsrrwwwrrrmmmmmmmmmcccccccc
abaaaaaccccccccccccaaaaaaccccccaaaaaccccccaaaaccccccccccaaaaaaaacaaaaaaccccaaaaccfffflllrrrrrrkkmmmmmmmccccaccccc
abaaaacccccccccccccccaaccccccccaaaaaacccccaaaacccccccccccccaaccaaaaaaaccccccccccccffflllrrrrrkkkmmmmmccccccaccccc
abaaacccccccccccccccccccccccccaaaaaaaaccccaaaacccccccccccccaaccaaaaaaacccccccccccccfffllkrrrkkkkmddddcccccaaacccc
abaaacccccccccccccccccccccccccaaaaaaaacccccccccccccccccccccccccccaaaaaaccccccccccccfffllkkkkkkkdddddddcaaaaaacccc
abaaaacccccccccccccccccccccccccccaaccccccccccccccccccccccccccccccaacaaacccccccccccccfeekkkkkkkddddddcccaaaccccccc
abcaaacccccccccccaaaccccccccaacccaaccccaaaaaccccaaaccccccccccccccaaccccccccccccccccceeeeekkkkdddddccccccaaccccccc
abccccccccccccccaaaaaaccccccaaacaaccacaaaaaaaccaaaaccccccccccaccaaccccccccccccccccccceeeeeeeedddacccccccccccccccc
abccccccccccccccaaaaaacccccccaaaaacaaaaaccaaaaaaaacccccccccccaaaaacccccccccccccccccccceeeeeeedaaacccccccccccccaaa
abccccccaaacccccaaaaacccccccaaaaaacaaaaaaaaaaaaaaaccccccccccccaaaaaccccccccccccccccccccceeeeecaaacccccccccccccaaa
abccccccaaaccccccaaaaacccccaaaaaaaaccaaaaacaaaaaaccccccccccccaaaaaacccccccccccccccccccccaaaccccaccccccccccccccaaa
abccccaacaaaaacccaaaaacccccaaaaaaaacaaaaaaaaaaaaaaaccccaaaaccaaaacccccccccccccccccccccccaccccccccccccccccccaaaaaa
abccccaaaaaaaaccccccccccccccccaaccccaacaaaaaaaaaaaaaaccaaaaccccaaacccccccccccccccccccccccccccccccccccccccccaaaaaa"""

Compiled from "Day12.kt"
public final class cz.wrent.advent.Day12Kt {
  private static final java.lang.String test;

  private static final java.lang.String input;

  public static final void main();
    Code:
       0: ldc           #8                  // String Sabqponm\nabcryxxl\naccszExk\nacctuvwj\nabdefghi\n
       2: invokestatic  #12                 // Method partOne:(Ljava/lang/String;)I
       5: istore_0
       6: getstatic     #18                 // Field java/lang/System.out:Ljava/io/PrintStream;
       9: iload_0
      10: invokevirtual #24                 // Method java/io/PrintStream.println:(I)V
      13: ldc           #26                 // String abcccccccaaaaaaaaccccccccccaaaaaaccccccaccaaaaaaaccccccaacccccccccaaaaaaaaaaccccccccccccccccccccccccccccccccaaaaa\nabcccccccaaaaaaaaacccccccccaaaaaacccccaaacaaaaaaaaaaaccaacccccccccccaaaaaaccccccccccccccccccccccccccccccccccaaaaa\nabcccccccaaaaaaaaaaccccccccaaaaaacaaacaaaaaaaaaaaaaaaaaaccccccccccccaaaaaaccccccccccccccaaacccccccccccccccccaaaaa\nabaaacccccccaaaaaaacccccccccaaacccaaaaaaaaaaaaaaaaaaaaaaaaacccccccccaaaaaaccccccccccccccaaacccccccccccccccccaaaaa\nabaaaaccccccaaaccccccccccccccccccccaaaaaaaaacaaaacacaaaaaacccccccccaaaaaaaacccccccccccccaaaaccaaacccccccccccaccaa\nabaaaaccccccaaccccaaccccccccccccccccaaaaaaacaaaaccccaaaaaccccccccccccccccacccccccccccccccaaaaaaaaacccccccccccccca\nabaaaaccccccccccccaaaacccccccccaacaaaaaaaacccaaacccaaacaacccccccccccccccccccccccccccciiiiaaaaaaaacccccccccccccccc\nabaaacccccccccccaaaaaacccccccccaaaaaaaaaaacccaaacccccccaacccccccccccaacccccccccccccciiiiiiijaaaaccccccccaaccccccc\nabaaaccccccccccccaaaacccccccccaaaaaaaacaaacccaaaccccccccccccccccccccaaacaaacccccccciiiiiiiijjjacccccccccaaacccccc\nabcccccaacaacccccaaaaaccccccccaaaaaacccccacaacccccccccccccccccccccccaaaaaaaccccccciiiinnnoijjjjjjjjkkkaaaaaaacccc\nabcccccaaaaacccccaacaaccccccccccaaaacccaaaaaaccccccccccccccccccccccccaaaaaaccccccciiinnnnooojjjjjjjkkkkaaaaaacccc\nabccccaaaaacccccccccccccccccccccaccccccaaaaaaaccccccccccccccccccccaaaaaaaaccccccchhinnnnnoooojjooopkkkkkaaaaccccc\nabccccaaaaaaccccccccccccccccccccccccccccaaaaaaacccccccccccccccccccaaaaaaaaacccccchhhnnntttuooooooopppkkkaaaaccccc\nabccccccaaaaccccccccccacccccccccccccccccaaaaaaacccaaccccccccccccccaaaaaaaaaaccccchhhnnttttuuoooooppppkkkaaaaccccc\nabccccccaccccccccccccaaaacaaaccccccccccaaaaaacaaccaacccaaccccccccccccaaacaaacccchhhnnnttttuuuuuuuuupppkkccaaccccc\nabccccccccccccccaaccccaaaaaaaccccccccccaaaaaacaaaaaacccaaaaaaccccccccaaacccccccchhhnnntttxxxuuuuuuupppkkccccccccc\nabcccccccccccccaaaacccaaaaaaacccaccccccccccaaccaaaaaaacaaaaaaccccccccaacccaaccchhhhnnnttxxxxuuyyyuupppkkccccccccc\nabcccccccccccccaaaaccaaaaaaaaacaaacccccccccccccaaaaaaaaaaaaaccccccccccccccaaachhhhmnnnttxxxxxxyyyuvppkkkccccccccc\nabcccccccccccccaaaacaaaaaaaaaaaaaaccccccccccccaaaaaacaaaaaaaccccccccccccccaaaghhhmmmttttxxxxxyyyyvvpplllccccccccc\nabccacccccccccccccccaaaaaaaaaaaaaaccccccccccccaaaaaacccaaaaaacccaacaacccaaaaagggmmmttttxxxxxyyyyvvppplllccccccccc\nSbaaaccccccccccccccccccaaacaaaaaaaacccccccccccccccaacccaaccaacccaaaaacccaaaagggmmmsttxxxEzzzzyyvvvppplllccccccccc\nabaaaccccccccccccccccccaaaaaaaaaaaaacaaccccccccccccccccaaccccccccaaaaaccccaagggmmmsssxxxxxyyyyyyvvvqqqlllcccccccc\nabaaacccccccccccccccccccaaaaaaaaaaaaaaaaacccccccccccccccccccccccaaaaaaccccaagggmmmsssxxxwywyyyyyyvvvqqlllcccccccc\nabaaaaacccccccccccccccccccaacaaaccaaaaaaacccccccccccccccccccccccaaaaccccccaagggmmmssswwwwwyyyyyyyvvvqqqllcccccccc\nabaaaaaccccccccccccccccccccccaaaccccaaaacccccccccccccccccaaccaacccaaccccccccgggmmmmssssswwyywwvvvvvvqqqlllccccccc\nabaaaaacccccccccccccaccacccccaaaccccaaaacccccccccccccccccaaaaaacccccccccccaaggggmllllsssswwywwwvvvvqqqqlllccccccc\nabaaccccccccccccccccaaaaccccccccccccaccaccccccccccccccccccaaaaacccccccccccaaagggglllllssswwwwwrrqqqqqqmmllccccccc\nabaaccccccccccccccccaaaaaccccccaaccaaccccccccccccccccccccaaaaaaccaacccccccaaaaggfffllllsswwwwrrrrqqqqqmmmcccccccc\nabacaaaccccccccccccaaaaaaccccccaaaaaaccccccaacccccccccccaaaaaaaacaaacaaccccaaaaffffflllsrrwwwrrrmmmmmmmmmcccccccc\nabaaaaaccccccccccccaaaaaaccccccaaaaaccccccaaaaccccccccccaaaaaaaacaaaaaaccccaaaaccfffflllrrrrrrkkmmmmmmmccccaccccc\nabaaaacccccccccccccccaaccccccccaaaaaacccccaaaacccccccccccccaaccaaaaaaaccccccccccccffflllrrrrrkkkmmmmmccccccaccccc\nabaaacccccccccccccccccccccccccaaaaaaaaccccaaaacccccccccccccaaccaaaaaaacccccccccccccfffllkrrrkkkkmddddcccccaaacccc\nabaaacccccccccccccccccccccccccaaaaaaaacccccccccccccccccccccccccccaaaaaaccccccccccccfffllkkkkkkkdddddddcaaaaaacccc\nabaaaacccccccccccccccccccccccccccaaccccccccccccccccccccccccccccccaacaaacccccccccccccfeekkkkkkkddddddcccaaaccccccc\nabcaaacccccccccccaaaccccccccaacccaaccccaaaaaccccaaaccccccccccccccaaccccccccccccccccceeeeekkkkdddddccccccaaccccccc\nabccccccccccccccaaaaaaccccccaaacaaccacaaaaaaaccaaaaccccccccccaccaaccccccccccccccccccceeeeeeeedddacccccccccccccccc\nabccccccccccccccaaaaaacccccccaaaaacaaaaaccaaaaaaaacccccccccccaaaaacccccccccccccccccccceeeeeeedaaacccccccccccccaaa\nabccccccaaacccccaaaaacccccccaaaaaacaaaaaaaaaaaaaaaccccccccccccaaaaaccccccccccccccccccccceeeeecaaacccccccccccccaaa\nabccccccaaaccccccaaaaacccccaaaaaaaaccaaaaacaaaaaaccccccccccccaaaaaacccccccccccccccccccccaaaccccaccccccccccccccaaa\nabccccaacaaaaacccaaaaacccccaaaaaaaacaaaaaaaaaaaaaaaccccaaaaccaaaacccccccccccccccccccccccaccccccccccccccccccaaaaaa\nabccccaaaaaaaaccccccccccccccccaaccccaacaaaaaaaaaaaaaaccaaaaccccaaacccccccccccccccccccccccccccccccccccccccccaaaaaa
      15: invokestatic  #12                 // Method partOne:(Ljava/lang/String;)I
      18: istore_0
      19: new           #28                 // class java/lang/StringBuilder
      22: dup
      23: invokespecial #31                 // Method java/lang/StringBuilder."<init>":()V
      26: ldc           #33                 // String 12a:
      28: invokevirtual #37                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      31: iload_0
      32: invokevirtual #40                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      35: invokevirtual #44                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      38: getstatic     #18                 // Field java/lang/System.out:Ljava/io/PrintStream;
      41: swap
      42: invokevirtual #47                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      45: ldc           #8                  // String Sabqponm\nabcryxxl\naccszExk\nacctuvwj\nabdefghi\n
      47: invokestatic  #50                 // Method partTwo:(Ljava/lang/String;)I
      50: istore_1
      51: getstatic     #18                 // Field java/lang/System.out:Ljava/io/PrintStream;
      54: iload_1
      55: invokevirtual #24                 // Method java/io/PrintStream.println:(I)V
      58: new           #28                 // class java/lang/StringBuilder
      61: dup
      62: invokespecial #31                 // Method java/lang/StringBuilder."<init>":()V
      65: ldc           #52                 // String 12b:
      67: invokevirtual #37                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      70: ldc           #26                 // String abcccccccaaaaaaaaccccccccccaaaaaaccccccaccaaaaaaaccccccaacccccccccaaaaaaaaaaccccccccccccccccccccccccccccccccaaaaa\nabcccccccaaaaaaaaacccccccccaaaaaacccccaaacaaaaaaaaaaaccaacccccccccccaaaaaaccccccccccccccccccccccccccccccccccaaaaa\nabcccccccaaaaaaaaaaccccccccaaaaaacaaacaaaaaaaaaaaaaaaaaaccccccccccccaaaaaaccccccccccccccaaacccccccccccccccccaaaaa\nabaaacccccccaaaaaaacccccccccaaacccaaaaaaaaaaaaaaaaaaaaaaaaacccccccccaaaaaaccccccccccccccaaacccccccccccccccccaaaaa\nabaaaaccccccaaaccccccccccccccccccccaaaaaaaaacaaaacacaaaaaacccccccccaaaaaaaacccccccccccccaaaaccaaacccccccccccaccaa\nabaaaaccccccaaccccaaccccccccccccccccaaaaaaacaaaaccccaaaaaccccccccccccccccacccccccccccccccaaaaaaaaacccccccccccccca\nabaaaaccccccccccccaaaacccccccccaacaaaaaaaacccaaacccaaacaacccccccccccccccccccccccccccciiiiaaaaaaaacccccccccccccccc\nabaaacccccccccccaaaaaacccccccccaaaaaaaaaaacccaaacccccccaacccccccccccaacccccccccccccciiiiiiijaaaaccccccccaaccccccc\nabaaaccccccccccccaaaacccccccccaaaaaaaacaaacccaaaccccccccccccccccccccaaacaaacccccccciiiiiiiijjjacccccccccaaacccccc\nabcccccaacaacccccaaaaaccccccccaaaaaacccccacaacccccccccccccccccccccccaaaaaaaccccccciiiinnnoijjjjjjjjkkkaaaaaaacccc\nabcccccaaaaacccccaacaaccccccccccaaaacccaaaaaaccccccccccccccccccccccccaaaaaaccccccciiinnnnooojjjjjjjkkkkaaaaaacccc\nabccccaaaaacccccccccccccccccccccaccccccaaaaaaaccccccccccccccccccccaaaaaaaaccccccchhinnnnnoooojjooopkkkkkaaaaccccc\nabccccaaaaaaccccccccccccccccccccccccccccaaaaaaacccccccccccccccccccaaaaaaaaacccccchhhnnntttuooooooopppkkkaaaaccccc\nabccccccaaaaccccccccccacccccccccccccccccaaaaaaacccaaccccccccccccccaaaaaaaaaaccccchhhnnttttuuoooooppppkkkaaaaccccc\nabccccccaccccccccccccaaaacaaaccccccccccaaaaaacaaccaacccaaccccccccccccaaacaaacccchhhnnnttttuuuuuuuuupppkkccaaccccc\nabccccccccccccccaaccccaaaaaaaccccccccccaaaaaacaaaaaacccaaaaaaccccccccaaacccccccchhhnnntttxxxuuuuuuupppkkccccccccc\nabcccccccccccccaaaacccaaaaaaacccaccccccccccaaccaaaaaaacaaaaaaccccccccaacccaaccchhhhnnnttxxxxuuyyyuupppkkccccccccc\nabcccccccccccccaaaaccaaaaaaaaacaaacccccccccccccaaaaaaaaaaaaaccccccccccccccaaachhhhmnnnttxxxxxxyyyuvppkkkccccccccc\nabcccccccccccccaaaacaaaaaaaaaaaaaaccccccccccccaaaaaacaaaaaaaccccccccccccccaaaghhhmmmttttxxxxxyyyyvvpplllccccccccc\nabccacccccccccccccccaaaaaaaaaaaaaaccccccccccccaaaaaacccaaaaaacccaacaacccaaaaagggmmmttttxxxxxyyyyvvppplllccccccccc\nSbaaaccccccccccccccccccaaacaaaaaaaacccccccccccccccaacccaaccaacccaaaaacccaaaagggmmmsttxxxEzzzzyyvvvppplllccccccccc\nabaaaccccccccccccccccccaaaaaaaaaaaaacaaccccccccccccccccaaccccccccaaaaaccccaagggmmmsssxxxxxyyyyyyvvvqqqlllcccccccc\nabaaacccccccccccccccccccaaaaaaaaaaaaaaaaacccccccccccccccccccccccaaaaaaccccaagggmmmsssxxxwywyyyyyyvvvqqlllcccccccc\nabaaaaacccccccccccccccccccaacaaaccaaaaaaacccccccccccccccccccccccaaaaccccccaagggmmmssswwwwwyyyyyyyvvvqqqllcccccccc\nabaaaaaccccccccccccccccccccccaaaccccaaaacccccccccccccccccaaccaacccaaccccccccgggmmmmssssswwyywwvvvvvvqqqlllccccccc\nabaaaaacccccccccccccaccacccccaaaccccaaaacccccccccccccccccaaaaaacccccccccccaaggggmllllsssswwywwwvvvvqqqqlllccccccc\nabaaccccccccccccccccaaaaccccccccccccaccaccccccccccccccccccaaaaacccccccccccaaagggglllllssswwwwwrrqqqqqqmmllccccccc\nabaaccccccccccccccccaaaaaccccccaaccaaccccccccccccccccccccaaaaaaccaacccccccaaaaggfffllllsswwwwrrrrqqqqqmmmcccccccc\nabacaaaccccccccccccaaaaaaccccccaaaaaaccccccaacccccccccccaaaaaaaacaaacaaccccaaaaffffflllsrrwwwrrrmmmmmmmmmcccccccc\nabaaaaaccccccccccccaaaaaaccccccaaaaaccccccaaaaccccccccccaaaaaaaacaaaaaaccccaaaaccfffflllrrrrrrkkmmmmmmmccccaccccc\nabaaaacccccccccccccccaaccccccccaaaaaacccccaaaacccccccccccccaaccaaaaaaaccccccccccccffflllrrrrrkkkmmmmmccccccaccccc\nabaaacccccccccccccccccccccccccaaaaaaaaccccaaaacccccccccccccaaccaaaaaaacccccccccccccfffllkrrrkkkkmddddcccccaaacccc\nabaaacccccccccccccccccccccccccaaaaaaaacccccccccccccccccccccccccccaaaaaaccccccccccccfffllkkkkkkkdddddddcaaaaaacccc\nabaaaacccccccccccccccccccccccccccaaccccccccccccccccccccccccccccccaacaaacccccccccccccfeekkkkkkkddddddcccaaaccccccc\nabcaaacccccccccccaaaccccccccaacccaaccccaaaaaccccaaaccccccccccccccaaccccccccccccccccceeeeekkkkdddddccccccaaccccccc\nabccccccccccccccaaaaaaccccccaaacaaccacaaaaaaaccaaaaccccccccccaccaaccccccccccccccccccceeeeeeeedddacccccccccccccccc\nabccccccccccccccaaaaaacccccccaaaaacaaaaaccaaaaaaaacccccccccccaaaaacccccccccccccccccccceeeeeeedaaacccccccccccccaaa\nabccccccaaacccccaaaaacccccccaaaaaacaaaaaaaaaaaaaaaccccccccccccaaaaaccccccccccccccccccccceeeeecaaacccccccccccccaaa\nabccccccaaaccccccaaaaacccccaaaaaaaaccaaaaacaaaaaaccccccccccccaaaaaacccccccccccccccccccccaaaccccaccccccccccccccaaa\nabccccaacaaaaacccaaaaacccccaaaaaaaacaaaaaaaaaaaaaaaccccaaaaccaaaacccccccccccccccccccccccaccccccccccccccccccaaaaaa\nabccccaaaaaaaaccccccccccccccccaaccccaacaaaaaaaaaaaaaaccaaaaccccaaacccccccccccccccccccccccccccccccccccccccccaaaaaa
      72: invokestatic  #50                 // Method partTwo:(Ljava/lang/String;)I
      75: invokevirtual #40                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      78: invokevirtual #44                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      81: getstatic     #18                 // Field java/lang/System.out:Ljava/io/PrintStream;
      84: swap
      85: invokevirtual #47                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      88: return

  private static final int partOne(java.lang.String);
    Code:
       0: aload_0
       1: invokestatic  #58                 // Method parse:(Ljava/lang/String;)Ljava/util/Map;
       4: astore_1
       5: aload_1
       6: invokeinterface #64,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
      11: checkcast     #66                 // class java/lang/Iterable
      14: astore_3
      15: aload_3
      16: invokeinterface #70,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      21: astore        4
      23: aload         4
      25: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      30: ifeq          84
      33: aload         4
      35: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      40: astore        5
      42: aload         5
      44: checkcast     #82                 // class java/util/Map$Entry
      47: astore        6
      49: iconst_0
      50: istore        7
      52: aload         6
      54: invokeinterface #85,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
      59: checkcast     #87                 // class cz/wrent/advent/Area
      62: invokevirtual #91                 // Method cz/wrent/advent/Area.getSpecialArea:()Lcz/wrent/advent/SpecialArea;
      65: getstatic     #97                 // Field cz/wrent/advent/SpecialArea.START:Lcz/wrent/advent/SpecialArea;
      68: if_acmpne     75
      71: iconst_1
      72: goto          76
      75: iconst_0
      76: ifeq          23
      79: aload         5
      81: goto          85
      84: aconst_null
      85: dup
      86: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      89: checkcast     #82                 // class java/util/Map$Entry
      92: invokeinterface #105,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
      97: checkcast     #107                // class kotlin/Pair
     100: astore_2
     101: aload_1
     102: aload_2
     103: invokeinterface #111,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     108: dup
     109: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     112: checkcast     #87                 // class cz/wrent/advent/Area
     115: iconst_0
     116: invokevirtual #114                // Method cz/wrent/advent/Area.setSteps:(I)V
     119: aload_1
     120: aload_2
     121: invokedynamic #133,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     126: invokestatic  #137                // Method process:(Ljava/util/Map;Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)V
     129: aload_1
     130: invokeinterface #64,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     135: checkcast     #66                 // class java/lang/Iterable
     138: astore_3
     139: aload_3
     140: invokeinterface #70,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     145: astore        4
     147: aload         4
     149: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     154: ifeq          208
     157: aload         4
     159: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     164: astore        5
     166: aload         5
     168: checkcast     #82                 // class java/util/Map$Entry
     171: astore        6
     173: iconst_0
     174: istore        7
     176: aload         6
     178: invokeinterface #85,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     183: checkcast     #87                 // class cz/wrent/advent/Area
     186: invokevirtual #91                 // Method cz/wrent/advent/Area.getSpecialArea:()Lcz/wrent/advent/SpecialArea;
     189: getstatic     #140                // Field cz/wrent/advent/SpecialArea.END:Lcz/wrent/advent/SpecialArea;
     192: if_acmpne     199
     195: iconst_1
     196: goto          200
     199: iconst_0
     200: ifeq          147
     203: aload         5
     205: goto          209
     208: aconst_null
     209: dup
     210: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     213: checkcast     #82                 // class java/util/Map$Entry
     216: invokeinterface #85,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     221: checkcast     #87                 // class cz/wrent/advent/Area
     224: invokevirtual #144                // Method cz/wrent/advent/Area.getSteps:()I
     227: ireturn

  private static final int partTwo(java.lang.String);
    Code:
       0: aload_0
       1: invokestatic  #58                 // Method parse:(Ljava/lang/String;)Ljava/util/Map;
       4: astore_1
       5: aload_1
       6: invokeinterface #64,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
      11: checkcast     #66                 // class java/lang/Iterable
      14: astore        4
      16: aload         4
      18: invokeinterface #70,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      23: astore        5
      25: aload         5
      27: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      32: ifeq          86
      35: aload         5
      37: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      42: astore        6
      44: aload         6
      46: checkcast     #82                 // class java/util/Map$Entry
      49: astore        7
      51: iconst_0
      52: istore        8
      54: aload         7
      56: invokeinterface #85,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
      61: checkcast     #87                 // class cz/wrent/advent/Area
      64: invokevirtual #91                 // Method cz/wrent/advent/Area.getSpecialArea:()Lcz/wrent/advent/SpecialArea;
      67: getstatic     #140                // Field cz/wrent/advent/SpecialArea.END:Lcz/wrent/advent/SpecialArea;
      70: if_acmpne     77
      73: iconst_1
      74: goto          78
      77: iconst_0
      78: ifeq          25
      81: aload         6
      83: goto          87
      86: aconst_null
      87: dup
      88: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      91: checkcast     #82                 // class java/util/Map$Entry
      94: invokeinterface #105,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
      99: checkcast     #107                // class kotlin/Pair
     102: astore_2
     103: aload_1
     104: aload_2
     105: invokeinterface #111,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     110: dup
     111: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     114: checkcast     #87                 // class cz/wrent/advent/Area
     117: iconst_0
     118: invokevirtual #114                // Method cz/wrent/advent/Area.setSteps:(I)V
     121: aload_1
     122: aload_2
     123: invokedynamic #161,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
     128: invokestatic  #137                // Method process:(Ljava/util/Map;Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)V
     131: aload_1
     132: invokeinterface #64,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     137: checkcast     #66                 // class java/lang/Iterable
     140: astore_3
     141: iconst_0
     142: istore        4
     144: aload_3
     145: astore        5
     147: new           #163                // class java/util/ArrayList
     150: dup
     151: invokespecial #164                // Method java/util/ArrayList."<init>":()V
     154: checkcast     #166                // class java/util/Collection
     157: astore        6
     159: iconst_0
     160: istore        7
     162: aload         5
     164: invokeinterface #70,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     169: astore        8
     171: aload         8
     173: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     178: ifeq          239
     181: aload         8
     183: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     188: astore        9
     190: aload         9
     192: checkcast     #82                 // class java/util/Map$Entry
     195: astore        10
     197: iconst_0
     198: istore        11
     200: aload         10
     202: invokeinterface #85,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     207: checkcast     #87                 // class cz/wrent/advent/Area
     210: invokevirtual #169                // Method cz/wrent/advent/Area.getHeight:()I
     213: bipush        97
     215: if_icmpne     222
     218: iconst_1
     219: goto          223
     222: iconst_0
     223: ifeq          171
     226: aload         6
     228: aload         9
     230: invokeinterface #173,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     235: pop
     236: goto          171
     239: aload         6
     241: checkcast     #175                // class java/util/List
     244: nop
     245: checkcast     #66                 // class java/lang/Iterable
     248: astore_3
     249: nop
     250: iconst_0
     251: istore        4
     253: aload_3
     254: invokeinterface #70,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     259: astore        5
     261: aload         5
     263: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     268: ifne          275
     271: aconst_null
     272: goto          385
     275: aload         5
     277: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     282: astore        6
     284: aload         5
     286: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     291: ifne          299
     294: aload         6
     296: goto          385
     299: aload         6
     301: checkcast     #82                 // class java/util/Map$Entry
     304: astore        7
     306: iconst_0
     307: istore        8
     309: aload         7
     311: invokeinterface #85,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     316: checkcast     #87                 // class cz/wrent/advent/Area
     319: invokevirtual #144                // Method cz/wrent/advent/Area.getSteps:()I
     322: istore        7
     324: aload         5
     326: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     331: astore        8
     333: aload         8
     335: checkcast     #82                 // class java/util/Map$Entry
     338: astore        9
     340: iconst_0
     341: istore        10
     343: aload         9
     345: invokeinterface #85,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     350: checkcast     #87                 // class cz/wrent/advent/Area
     353: invokevirtual #144                // Method cz/wrent/advent/Area.getSteps:()I
     356: istore        9
     358: iload         7
     360: iload         9
     362: if_icmple     373
     365: aload         8
     367: astore        6
     369: iload         9
     371: istore        7
     373: aload         5
     375: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     380: ifne          324
     383: aload         6
     385: dup
     386: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     389: checkcast     #82                 // class java/util/Map$Entry
     392: invokeinterface #85,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     397: checkcast     #87                 // class cz/wrent/advent/Area
     400: invokevirtual #144                // Method cz/wrent/advent/Area.getSteps:()I
     403: ireturn

  private static final void process(java.util.Map<kotlin.Pair<java.lang.Integer, java.lang.Integer>, cz.wrent.advent.Area>, kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.jvm.functions.Function1<? super java.lang.Integer, kotlin.ranges.IntRange>);
    Code:
       0: aconst_null
       1: astore_3
       2: aload_1
       3: invokestatic  #202                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
       6: astore_3
       7: aload_3
       8: checkcast     #166                // class java/util/Collection
      11: invokeinterface #205,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      16: ifne          23
      19: iconst_1
      20: goto          24
      23: iconst_0
      24: ifeq          298
      27: aload_3
      28: invokestatic  #209                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
      31: checkcast     #107                // class kotlin/Pair
      34: astore        4
      36: aload_3
      37: iconst_1
      38: invokestatic  #213                // Method kotlin/collections/CollectionsKt.dropLast:(Ljava/util/List;I)Ljava/util/List;
      41: astore_3
      42: aload         4
      44: invokestatic  #217                // Method toNeighbours:(Lkotlin/Pair;)Ljava/util/Set;
      47: astore        5
      49: aload         5
      51: checkcast     #66                 // class java/lang/Iterable
      54: astore        6
      56: iconst_0
      57: istore        7
      59: aload         6
      61: invokeinterface #70,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      66: astore        8
      68: aload         8
      70: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      75: ifeq          294
      78: aload         8
      80: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      85: astore        9
      87: aload         9
      89: checkcast     #107                // class kotlin/Pair
      92: astore        10
      94: iconst_0
      95: istore        11
      97: aload_0
      98: aload         10
     100: invokeinterface #111,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     105: ifnull        289
     108: aload_2
     109: aload_0
     110: aload         4
     112: invokeinterface #111,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     117: dup
     118: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     121: checkcast     #87                 // class cz/wrent/advent/Area
     124: invokevirtual #169                // Method cz/wrent/advent/Area.getHeight:()I
     127: invokestatic  #223                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     130: invokeinterface #227,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     135: checkcast     #229                // class kotlin/ranges/IntRange
     138: astore        12
     140: aload         12
     142: invokevirtual #232                // Method kotlin/ranges/IntRange.getFirst:()I
     145: istore        13
     147: aload         12
     149: invokevirtual #235                // Method kotlin/ranges/IntRange.getLast:()I
     152: istore        14
     154: aload_0
     155: aload         10
     157: invokeinterface #111,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     162: dup
     163: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     166: checkcast     #87                 // class cz/wrent/advent/Area
     169: invokevirtual #169                // Method cz/wrent/advent/Area.getHeight:()I
     172: istore        15
     174: iload         13
     176: iload         15
     178: if_icmpgt     196
     181: iload         15
     183: iload         14
     185: if_icmpgt     192
     188: iconst_1
     189: goto          197
     192: iconst_0
     193: goto          197
     196: iconst_0
     197: ifeq          289
     200: aload_0
     201: aload         10
     203: invokeinterface #111,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     208: dup
     209: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     212: checkcast     #87                 // class cz/wrent/advent/Area
     215: invokevirtual #144                // Method cz/wrent/advent/Area.getSteps:()I
     218: aload_0
     219: aload         4
     221: invokeinterface #111,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     226: dup
     227: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     230: checkcast     #87                 // class cz/wrent/advent/Area
     233: invokevirtual #144                // Method cz/wrent/advent/Area.getSteps:()I
     236: iconst_1
     237: iadd
     238: if_icmple     289
     241: aload_0
     242: aload         10
     244: invokeinterface #111,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     249: dup
     250: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     253: checkcast     #87                 // class cz/wrent/advent/Area
     256: aload_0
     257: aload         4
     259: invokeinterface #111,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     264: dup
     265: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     268: checkcast     #87                 // class cz/wrent/advent/Area
     271: invokevirtual #144                // Method cz/wrent/advent/Area.getSteps:()I
     274: iconst_1
     275: iadd
     276: invokevirtual #114                // Method cz/wrent/advent/Area.setSteps:(I)V
     279: aload_3
     280: checkcast     #166                // class java/util/Collection
     283: aload         10
     285: invokestatic  #239                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     288: astore_3
     289: nop
     290: nop
     291: goto          68
     294: nop
     295: goto          7
     298: return

  public static final java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>> toNeighbours(kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #255                // String <this>
       3: invokestatic  #259                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_4
       7: anewarray     #107                // class kotlin/Pair
      10: astore_1
      11: aload_1
      12: iconst_0
      13: aload_0
      14: invokevirtual #261                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      17: aload_0
      18: invokevirtual #264                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      21: checkcast     #266                // class java/lang/Number
      24: invokevirtual #269                // Method java/lang/Number.intValue:()I
      27: iconst_1
      28: iadd
      29: invokestatic  #223                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      32: invokestatic  #275                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      35: aastore
      36: aload_1
      37: iconst_1
      38: aload_0
      39: invokevirtual #261                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      42: aload_0
      43: invokevirtual #264                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      46: checkcast     #266                // class java/lang/Number
      49: invokevirtual #269                // Method java/lang/Number.intValue:()I
      52: iconst_1
      53: isub
      54: invokestatic  #223                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      57: invokestatic  #275                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      60: aastore
      61: aload_1
      62: iconst_2
      63: aload_0
      64: invokevirtual #261                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      67: checkcast     #266                // class java/lang/Number
      70: invokevirtual #269                // Method java/lang/Number.intValue:()I
      73: iconst_1
      74: iadd
      75: invokestatic  #223                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      78: aload_0
      79: invokevirtual #264                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      82: invokestatic  #275                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      85: aastore
      86: aload_1
      87: iconst_3
      88: aload_0
      89: invokevirtual #261                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      92: checkcast     #266                // class java/lang/Number
      95: invokevirtual #269                // Method java/lang/Number.intValue:()I
      98: iconst_1
      99: isub
     100: invokestatic  #223                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     103: aload_0
     104: invokevirtual #264                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     107: invokestatic  #275                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     110: aastore
     111: aload_1
     112: invokestatic  #281                // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;
     115: areturn

  private static final java.util.Map<kotlin.Pair<java.lang.Integer, java.lang.Integer>, cz.wrent.advent.Area> parse(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #285                // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #156                // class java/lang/String
       8: astore_2
       9: aload_2
      10: iconst_0
      11: ldc_w         #287                // String \n
      14: aastore
      15: aload_2
      16: iconst_0
      17: iconst_0
      18: bipush        6
      20: aconst_null
      21: invokestatic  #293                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      24: astore_1
      25: new           #295                // class java/util/LinkedHashMap
      28: dup
      29: invokespecial #296                // Method java/util/LinkedHashMap."<init>":()V
      32: checkcast     #60                 // class java/util/Map
      35: astore_2
      36: aload_1
      37: checkcast     #66                 // class java/lang/Iterable
      40: astore_3
      41: iconst_0
      42: istore        4
      44: iconst_0
      45: istore        5
      47: aload_3
      48: invokeinterface #70,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      53: astore        6
      55: aload         6
      57: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      62: ifeq          425
      65: aload         6
      67: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      72: astore        7
      74: iload         5
      76: iinc          5, 1
      79: istore        8
      81: iload         8
      83: ifge          89
      86: invokestatic  #299                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      89: iload         8
      91: aload         7
      93: checkcast     #156                // class java/lang/String
      96: astore        9
      98: istore        10
     100: iconst_0
     101: istore        11
     103: aload         9
     105: invokevirtual #303                // Method java/lang/String.toCharArray:()[C
     108: dup
     109: ldc_w         #305                // String toCharArray(...)
     112: invokestatic  #308                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     115: astore        12
     117: nop
     118: iconst_0
     119: istore        13
     121: aload         12
     123: astore        14
     125: new           #163                // class java/util/ArrayList
     128: dup
     129: aload         12
     131: arraylength
     132: invokespecial #310                // Method java/util/ArrayList."<init>":(I)V
     135: checkcast     #166                // class java/util/Collection
     138: astore        15
     140: iconst_0
     141: istore        16
     143: iconst_0
     144: istore        17
     146: aload         14
     148: arraylength
     149: istore        18
     151: iload         17
     153: iload         18
     155: if_icmpge     197
     158: aload         14
     160: iload         17
     162: caload
     163: istore        19
     165: aload         15
     167: iload         19
     169: istore        20
     171: astore        21
     173: iconst_0
     174: istore        22
     176: iload         20
     178: nop
     179: invokestatic  #223                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     182: aload         21
     184: swap
     185: invokeinterface #173,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     190: pop
     191: iinc          17, 1
     194: goto          151
     197: aload         15
     199: checkcast     #175                // class java/util/List
     202: nop
     203: checkcast     #66                 // class java/lang/Iterable
     206: astore        12
     208: nop
     209: iconst_0
     210: istore        13
     212: iconst_0
     213: istore        14
     215: aload         12
     217: invokeinterface #70,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     222: astore        15
     224: aload         15
     226: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     231: ifeq          419
     234: aload         15
     236: invokeinterface #80,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     241: astore        16
     243: iload         14
     245: iinc          14, 1
     248: istore        17
     250: iload         17
     252: ifge          258
     255: invokestatic  #299                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     258: iload         17
     260: aload         16
     262: checkcast     #266                // class java/lang/Number
     265: invokevirtual #269                // Method java/lang/Number.intValue:()I
     268: istore        18
     270: istore        19
     272: iconst_0
     273: istore        20
     275: iload         18
     277: lookupswitch  { // 2
                    69: 342
                    83: 304
               default: 380
          }
     304: aload_2
     305: iload         19
     307: invokestatic  #223                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     310: iload         10
     312: invokestatic  #223                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     315: invokestatic  #275                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     318: new           #87                 // class cz/wrent/advent/Area
     321: dup
     322: bipush        97
     324: iconst_0
     325: getstatic     #97                 // Field cz/wrent/advent/SpecialArea.START:Lcz/wrent/advent/SpecialArea;
     328: iconst_2
     329: aconst_null
     330: invokespecial #313                // Method cz/wrent/advent/Area."<init>":(IILcz/wrent/advent/SpecialArea;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
     333: invokeinterface #317,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     338: pop
     339: goto          414
     342: aload_2
     343: iload         19
     345: invokestatic  #223                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     348: iload         10
     350: invokestatic  #223                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     353: invokestatic  #275                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     356: new           #87                 // class cz/wrent/advent/Area
     359: dup
     360: bipush        122
     362: iconst_0
     363: getstatic     #140                // Field cz/wrent/advent/SpecialArea.END:Lcz/wrent/advent/SpecialArea;
     366: iconst_2
     367: aconst_null
     368: invokespecial #313                // Method cz/wrent/advent/Area."<init>":(IILcz/wrent/advent/SpecialArea;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
     371: invokeinterface #317,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     376: pop
     377: goto          414
     380: aload_2
     381: iload         19
     383: invokestatic  #223                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     386: iload         10
     388: invokestatic  #223                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     391: invokestatic  #275                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     394: new           #87                 // class cz/wrent/advent/Area
     397: dup
     398: iload         18
     400: iconst_0
     401: aconst_null
     402: bipush        6
     404: aconst_null
     405: invokespecial #313                // Method cz/wrent/advent/Area."<init>":(IILcz/wrent/advent/SpecialArea;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
     408: invokeinterface #317,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     413: pop
     414: nop
     415: nop
     416: goto          224
     419: nop
     420: nop
     421: nop
     422: goto          55
     425: nop
     426: aload_2
     427: areturn

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

  private static final kotlin.ranges.IntRange partOne$lambda$1(int);
    Code:
       0: new           #229                // class kotlin/ranges/IntRange
       3: dup
       4: iconst_0
       5: iload_0
       6: iconst_1
       7: iadd
       8: invokespecial #347                // Method kotlin/ranges/IntRange."<init>":(II)V
      11: areturn

  private static final kotlin.ranges.IntRange partTwo$lambda$4(int);
    Code:
       0: new           #229                // class kotlin/ranges/IntRange
       3: dup
       4: iload_0
       5: iconst_1
       6: isub
       7: ldc_w         #348                // int 2147483647
      10: invokespecial #347                // Method kotlin/ranges/IntRange."<init>":(II)V
      13: areturn
}


package cz.wrent.advent

fun main() {
	val result = partOne(input, 20, 3)
	println("10a: $result")
	println(result == 51075L)
	println("10b: ${partOne(input, 10000, 1)}")
}

private fun partOne(input: String, rounds: Int, divisor: Long): Long {
	val monkeys = input.split("\n\n").map { it.parseMonkey() }
	val allMod = monkeys.map { it.testDivisor }.reduce { acc, l -> acc * l }
	for (i in 1..rounds) {
		monkeys.forEach { it.turn(monkeys, divisor, allMod) }
	}
	val sortedMonkeys = monkeys.sortedByDescending { it.inspections }
	return (sortedMonkeys.get(0).inspections * sortedMonkeys.get(1).inspections)
}

private class Monkey(
	val operation: (Long) -> Long,
	val testDivisor: Long,
	val trueMonkey: Int,
	val falseMonkey: Int,
) {
	val items = mutableListOf<Long>()
	var inspections = 0L

	fun add(item: Long) {
		items.add(item)
	}

	fun turn(monkeys: List<Monkey>, divisor: Long, allMod: Long?) {
		items.forEach {
			val worry = (operation(it) / divisor).let { w -> if (allMod != null) w % allMod else w }
			if (worry % testDivisor == 0L) {
				monkeys[trueMonkey].add(worry)
			} else {
				monkeys[falseMonkey].add(worry)
			}
			inspections++
		}
		items.clear()
	}
}

private fun String.parseMonkey(): Monkey {
	val lines = this.split("\n")
	val startingItems = lines.get(1).replace("  Starting items: ", "").split(", ").map { it.toLong() }
	val operationData = lines.get(2).replace("  Operation: new = old ", "").split(" ")
	val operationNum = if (operationData.get(1) == "old") null else operationData.get(1).toLong()
	val operation: (Long) -> Long = if (operationData.first() == "*") {
		{ it * (operationNum ?: it) }
	} else {
		{ it + (operationNum ?: it) }
	}
	val testDivisor = lines.get(3).replace("  Test: divisible by ", "").toLong()
	val trueMonkey = lines.get(4).replace("    If true: throw to monkey ", "").toInt()
	val falseMonkey = lines.get(5).replace("    If false: throw to monkey ", "").toInt()
	val monkey = Monkey(operation, testDivisor, trueMonkey, falseMonkey)
	startingItems.forEach { monkey.add(it) }
	return monkey
}

private const val input = """Monkey 0:
  Starting items: 66, 79
  Operation: new = old * 11
  Test: divisible by 7
    If true: throw to monkey 6
    If false: throw to monkey 7

Monkey 1:
  Starting items: 84, 94, 94, 81, 98, 75
  Operation: new = old * 17
  Test: divisible by 13
    If true: throw to monkey 5
    If false: throw to monkey 2

Monkey 2:
  Starting items: 85, 79, 59, 64, 79, 95, 67
  Operation: new = old + 8
  Test: divisible by 5
    If true: throw to monkey 4
    If false: throw to monkey 5

Monkey 3:
  Starting items: 70
  Operation: new = old + 3
  Test: divisible by 19
    If true: throw to monkey 6
    If false: throw to monkey 0

Monkey 4:
  Starting items: 57, 69, 78, 78
  Operation: new = old + 4
  Test: divisible by 2
    If true: throw to monkey 0
    If false: throw to monkey 3

Monkey 5:
  Starting items: 65, 92, 60, 74, 72
  Operation: new = old + 7
  Test: divisible by 11
    If true: throw to monkey 3
    If false: throw to monkey 4

Monkey 6:
  Starting items: 77, 91, 91
  Operation: new = old * old
  Test: divisible by 17
    If true: throw to monkey 1
    If false: throw to monkey 7

Monkey 7:
  Starting items: 76, 58, 57, 55, 67, 77, 54, 99
  Operation: new = old + 6
  Test: divisible by 3
    If true: throw to monkey 2
    If false: throw to monkey 1"""

Compiled from "Comparisons.kt"
public final class cz.wrent.advent.Day11Kt$partOne$$inlined$sortedByDescending$1<T> implements java.util.Comparator {
  public cz.wrent.advent.Day11Kt$partOne$$inlined$sortedByDescending$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

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

Compiled from "Day11.kt"
public final class cz.wrent.advent.Day11Kt {
  private static final java.lang.String input;

  public static final void main();
    Code:
       0: ldc           #8                  // String Monkey 0:\n  Starting items: 66, 79\n  Operation: new = old * 11\n  Test: divisible by 7\n    If true: throw to monkey 6\n    If false: throw to monkey 7\n\nMonkey 1:\n  Starting items: 84, 94, 94, 81, 98, 75\n  Operation: new = old * 17\n  Test: divisible by 13\n    If true: throw to monkey 5\n    If false: throw to monkey 2\n\nMonkey 2:\n  Starting items: 85, 79, 59, 64, 79, 95, 67\n  Operation: new = old + 8\n  Test: divisible by 5\n    If true: throw to monkey 4\n    If false: throw to monkey 5\n\nMonkey 3:\n  Starting items: 70\n  Operation: new = old + 3\n  Test: divisible by 19\n    If true: throw to monkey 6\n    If false: throw to monkey 0\n\nMonkey 4:\n  Starting items: 57, 69, 78, 78\n  Operation: new = old + 4\n  Test: divisible by 2\n    If true: throw to monkey 0\n    If false: throw to monkey 3\n\nMonkey 5:\n  Starting items: 65, 92, 60, 74, 72\n  Operation: new = old + 7\n  Test: divisible by 11\n    If true: throw to monkey 3\n    If false: throw to monkey 4\n\nMonkey 6:\n  Starting items: 77, 91, 91\n  Operation: new = old * old\n  Test: divisible by 17\n    If true: throw to monkey 1\n    If false: throw to monkey 7\n\nMonkey 7:\n  Starting items: 76, 58, 57, 55, 67, 77, 54, 99\n  Operation: new = old + 6\n  Test: divisible by 3\n    If true: throw to monkey 2\n    If false: throw to monkey 1
       2: bipush        20
       4: ldc2_w        #9                  // long 3l
       7: invokestatic  #14                 // Method partOne:(Ljava/lang/String;IJ)J
      10: lstore_0
      11: new           #16                 // class java/lang/StringBuilder
      14: dup
      15: invokespecial #19                 // Method java/lang/StringBuilder."<init>":()V
      18: ldc           #21                 // String 10a:
      20: invokevirtual #25                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      23: lload_0
      24: invokevirtual #28                 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
      27: invokevirtual #32                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      30: getstatic     #38                 // Field java/lang/System.out:Ljava/io/PrintStream;
      33: swap
      34: invokevirtual #44                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      37: lload_0
      38: ldc2_w        #45                 // long 51075l
      41: lcmp
      42: ifne          49
      45: iconst_1
      46: goto          50
      49: iconst_0
      50: istore_2
      51: getstatic     #38                 // Field java/lang/System.out:Ljava/io/PrintStream;
      54: iload_2
      55: invokevirtual #49                 // Method java/io/PrintStream.println:(Z)V
      58: new           #16                 // class java/lang/StringBuilder
      61: dup
      62: invokespecial #19                 // Method java/lang/StringBuilder."<init>":()V
      65: ldc           #51                 // String 10b:
      67: invokevirtual #25                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      70: ldc           #8                  // String Monkey 0:\n  Starting items: 66, 79\n  Operation: new = old * 11\n  Test: divisible by 7\n    If true: throw to monkey 6\n    If false: throw to monkey 7\n\nMonkey 1:\n  Starting items: 84, 94, 94, 81, 98, 75\n  Operation: new = old * 17\n  Test: divisible by 13\n    If true: throw to monkey 5\n    If false: throw to monkey 2\n\nMonkey 2:\n  Starting items: 85, 79, 59, 64, 79, 95, 67\n  Operation: new = old + 8\n  Test: divisible by 5\n    If true: throw to monkey 4\n    If false: throw to monkey 5\n\nMonkey 3:\n  Starting items: 70\n  Operation: new = old + 3\n  Test: divisible by 19\n    If true: throw to monkey 6\n    If false: throw to monkey 0\n\nMonkey 4:\n  Starting items: 57, 69, 78, 78\n  Operation: new = old + 4\n  Test: divisible by 2\n    If true: throw to monkey 0\n    If false: throw to monkey 3\n\nMonkey 5:\n  Starting items: 65, 92, 60, 74, 72\n  Operation: new = old + 7\n  Test: divisible by 11\n    If true: throw to monkey 3\n    If false: throw to monkey 4\n\nMonkey 6:\n  Starting items: 77, 91, 91\n  Operation: new = old * old\n  Test: divisible by 17\n    If true: throw to monkey 1\n    If false: throw to monkey 7\n\nMonkey 7:\n  Starting items: 76, 58, 57, 55, 67, 77, 54, 99\n  Operation: new = old + 6\n  Test: divisible by 3\n    If true: throw to monkey 2\n    If false: throw to monkey 1
      72: sipush        10000
      75: lconst_1
      76: invokestatic  #14                 // Method partOne:(Ljava/lang/String;IJ)J
      79: invokevirtual #28                 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
      82: invokevirtual #32                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      85: getstatic     #38                 // Field java/lang/System.out:Ljava/io/PrintStream;
      88: swap
      89: invokevirtual #44                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      92: return

  private static final long partOne(java.lang.String, int, long);
    Code:
       0: aload_0
       1: checkcast     #55                 // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #57                 // class java/lang/String
       8: astore        5
      10: aload         5
      12: iconst_0
      13: ldc           #59                 // String \n\n
      15: aastore
      16: aload         5
      18: iconst_0
      19: iconst_0
      20: bipush        6
      22: aconst_null
      23: invokestatic  #65                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      26: checkcast     #67                 // class java/lang/Iterable
      29: astore        5
      31: iconst_0
      32: istore        6
      34: aload         5
      36: astore        7
      38: new           #69                 // class java/util/ArrayList
      41: dup
      42: aload         5
      44: bipush        10
      46: invokestatic  #75                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      49: invokespecial #78                 // Method java/util/ArrayList."<init>":(I)V
      52: checkcast     #80                 // class java/util/Collection
      55: astore        8
      57: iconst_0
      58: istore        9
      60: aload         7
      62: invokeinterface #84,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      67: astore        10
      69: aload         10
      71: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      76: ifeq          119
      79: aload         10
      81: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      86: astore        11
      88: aload         8
      90: aload         11
      92: checkcast     #57                 // class java/lang/String
      95: astore        12
      97: astore        16
      99: iconst_0
     100: istore        13
     102: aload         12
     104: invokestatic  #98                 // Method parseMonkey:(Ljava/lang/String;)Lcz/wrent/advent/Monkey;
     107: aload         16
     109: swap
     110: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     115: pop
     116: goto          69
     119: aload         8
     121: checkcast     #104                // class java/util/List
     124: nop
     125: astore        4
     127: aload         4
     129: checkcast     #67                 // class java/lang/Iterable
     132: astore        7
     134: iconst_0
     135: istore        8
     137: aload         7
     139: astore        9
     141: new           #69                 // class java/util/ArrayList
     144: dup
     145: aload         7
     147: bipush        10
     149: invokestatic  #75                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     152: invokespecial #78                 // Method java/util/ArrayList."<init>":(I)V
     155: checkcast     #80                 // class java/util/Collection
     158: astore        10
     160: iconst_0
     161: istore        11
     163: aload         9
     165: invokeinterface #84,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     170: astore        12
     172: aload         12
     174: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     179: ifeq          225
     182: aload         12
     184: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     189: astore        13
     191: aload         10
     193: aload         13
     195: checkcast     #106                // class cz/wrent/advent/Monkey
     198: astore        14
     200: astore        16
     202: iconst_0
     203: istore        15
     205: aload         14
     207: invokevirtual #110                // Method cz/wrent/advent/Monkey.getTestDivisor:()J
     210: invokestatic  #116                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     213: aload         16
     215: swap
     216: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     221: pop
     222: goto          172
     225: aload         10
     227: checkcast     #104                // class java/util/List
     230: nop
     231: checkcast     #67                 // class java/lang/Iterable
     234: astore        7
     236: nop
     237: iconst_0
     238: istore        8
     240: aload         7
     242: invokeinterface #84,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     247: astore        9
     249: aload         9
     251: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     256: ifne          269
     259: new           #118                // class java/lang/UnsupportedOperationException
     262: dup
     263: ldc           #120                // String Empty collection can\'t be reduced.
     265: invokespecial #123                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     268: athrow
     269: aload         9
     271: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     276: astore        10
     278: aload         9
     280: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     285: ifeq          329
     288: aload         10
     290: aload         9
     292: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     297: checkcast     #125                // class java/lang/Number
     300: invokevirtual #128                // Method java/lang/Number.longValue:()J
     303: lstore        11
     305: checkcast     #125                // class java/lang/Number
     308: invokevirtual #128                // Method java/lang/Number.longValue:()J
     311: lstore        13
     313: iconst_0
     314: istore        15
     316: lload         13
     318: lload         11
     320: lmul
     321: invokestatic  #116                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     324: astore        10
     326: goto          278
     329: aload         10
     331: checkcast     #125                // class java/lang/Number
     334: invokevirtual #128                // Method java/lang/Number.longValue:()J
     337: lstore        5
     339: iconst_1
     340: istore        7
     342: iload         7
     344: iload_1
     345: if_icmpgt     426
     348: aload         4
     350: checkcast     #67                 // class java/lang/Iterable
     353: astore        8
     355: iconst_0
     356: istore        9
     358: aload         8
     360: invokeinterface #84,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     365: astore        10
     367: aload         10
     369: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     374: ifeq          413
     377: aload         10
     379: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     384: astore        11
     386: aload         11
     388: checkcast     #106                // class cz/wrent/advent/Monkey
     391: astore        12
     393: iconst_0
     394: istore        13
     396: aload         12
     398: aload         4
     400: lload_2
     401: lload         5
     403: invokestatic  #116                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     406: invokevirtual #132                // Method cz/wrent/advent/Monkey.turn:(Ljava/util/List;JLjava/lang/Long;)V
     409: nop
     410: goto          367
     413: nop
     414: iload         7
     416: iload_1
     417: if_icmpeq     426
     420: iinc          7, 1
     423: goto          348
     426: aload         4
     428: checkcast     #67                 // class java/lang/Iterable
     431: astore        8
     433: iconst_0
     434: istore        9
     436: aload         8
     438: new           #134                // class cz/wrent/advent/Day11Kt$partOne$$inlined$sortedByDescending$1
     441: dup
     442: invokespecial #135                // Method cz/wrent/advent/Day11Kt$partOne$$inlined$sortedByDescending$1."<init>":()V
     445: checkcast     #137                // class java/util/Comparator
     448: invokestatic  #141                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
     451: astore        7
     453: aload         7
     455: iconst_0
     456: invokeinterface #145,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     461: checkcast     #106                // class cz/wrent/advent/Monkey
     464: invokevirtual #148                // Method cz/wrent/advent/Monkey.getInspections:()J
     467: aload         7
     469: iconst_1
     470: invokeinterface #145,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     475: checkcast     #106                // class cz/wrent/advent/Monkey
     478: invokevirtual #148                // Method cz/wrent/advent/Monkey.getInspections:()J
     481: lmul
     482: lreturn

  private static final cz.wrent.advent.Monkey parseMonkey(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #55                 // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #57                 // class java/lang/String
       8: astore_2
       9: aload_2
      10: iconst_0
      11: ldc           #187                // String \n
      13: aastore
      14: aload_2
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #65                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: astore_1
      24: aload_1
      25: iconst_1
      26: invokeinterface #145,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      31: checkcast     #57                 // class java/lang/String
      34: ldc           #189                // String   Starting items:
      36: ldc           #191                // String
      38: iconst_0
      39: iconst_4
      40: aconst_null
      41: invokestatic  #195                // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
      44: checkcast     #55                 // class java/lang/CharSequence
      47: iconst_1
      48: anewarray     #57                 // class java/lang/String
      51: astore_3
      52: aload_3
      53: iconst_0
      54: ldc           #197                // String ,
      56: aastore
      57: aload_3
      58: iconst_0
      59: iconst_0
      60: bipush        6
      62: aconst_null
      63: invokestatic  #65                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      66: checkcast     #67                 // class java/lang/Iterable
      69: astore_3
      70: iconst_0
      71: istore        4
      73: aload_3
      74: astore        5
      76: new           #69                 // class java/util/ArrayList
      79: dup
      80: aload_3
      81: bipush        10
      83: invokestatic  #75                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      86: invokespecial #78                 // Method java/util/ArrayList."<init>":(I)V
      89: checkcast     #80                 // class java/util/Collection
      92: astore        6
      94: iconst_0
      95: istore        7
      97: aload         5
      99: invokeinterface #84,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     104: astore        8
     106: aload         8
     108: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     113: ifeq          160
     116: aload         8
     118: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     123: astore        9
     125: aload         6
     127: aload         9
     129: checkcast     #57                 // class java/lang/String
     132: astore        10
     134: astore        18
     136: iconst_0
     137: istore        11
     139: aload         10
     141: invokestatic  #201                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     144: nop
     145: invokestatic  #116                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     148: aload         18
     150: swap
     151: invokeinterface #102,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     156: pop
     157: goto          106
     160: aload         6
     162: checkcast     #104                // class java/util/List
     165: nop
     166: astore_2
     167: aload_1
     168: iconst_2
     169: invokeinterface #145,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     174: checkcast     #57                 // class java/lang/String
     177: ldc           #203                // String   Operation: new = old
     179: ldc           #191                // String
     181: iconst_0
     182: iconst_4
     183: aconst_null
     184: invokestatic  #195                // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
     187: checkcast     #55                 // class java/lang/CharSequence
     190: iconst_1
     191: anewarray     #57                 // class java/lang/String
     194: astore        4
     196: aload         4
     198: iconst_0
     199: ldc           #205                // String
     201: aastore
     202: aload         4
     204: iconst_0
     205: iconst_0
     206: bipush        6
     208: aconst_null
     209: invokestatic  #65                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     212: astore_3
     213: aload_3
     214: iconst_1
     215: invokeinterface #145,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     220: ldc           #207                // String old
     222: invokestatic  #213                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     225: ifeq          232
     228: aconst_null
     229: goto          248
     232: aload_3
     233: iconst_1
     234: invokeinterface #145,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     239: checkcast     #57                 // class java/lang/String
     242: invokestatic  #201                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     245: invokestatic  #116                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     248: astore        4
     250: aload_3
     251: invokestatic  #217                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     254: ldc           #219                // String *
     256: invokestatic  #213                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     259: ifeq          272
     262: aload         4
     264: invokedynamic #239,  0            // InvokeDynamic #0:invoke:(Ljava/lang/Long;)Lkotlin/jvm/functions/Function1;
     269: goto          279
     272: aload         4
     274: invokedynamic #244,  0            // InvokeDynamic #1:invoke:(Ljava/lang/Long;)Lkotlin/jvm/functions/Function1;
     279: astore        5
     281: aload_1
     282: iconst_3
     283: invokeinterface #145,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     288: checkcast     #57                 // class java/lang/String
     291: ldc           #246                // String   Test: divisible by
     293: ldc           #191                // String
     295: iconst_0
     296: iconst_4
     297: aconst_null
     298: invokestatic  #195                // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
     301: invokestatic  #201                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     304: lstore        6
     306: aload_1
     307: iconst_4
     308: invokeinterface #145,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     313: checkcast     #57                 // class java/lang/String
     316: ldc           #248                // String     If true: throw to monkey
     318: ldc           #191                // String
     320: iconst_0
     321: iconst_4
     322: aconst_null
     323: invokestatic  #195                // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
     326: invokestatic  #254                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     329: istore        8
     331: aload_1
     332: iconst_5
     333: invokeinterface #145,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     338: checkcast     #57                 // class java/lang/String
     341: ldc_w         #256                // String     If false: throw to monkey
     344: ldc           #191                // String
     346: iconst_0
     347: iconst_4
     348: aconst_null
     349: invokestatic  #195                // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
     352: invokestatic  #254                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     355: istore        9
     357: new           #106                // class cz/wrent/advent/Monkey
     360: dup
     361: aload         5
     363: lload         6
     365: iload         8
     367: iload         9
     369: invokespecial #259                // Method cz/wrent/advent/Monkey."<init>":(Lkotlin/jvm/functions/Function1;JII)V
     372: astore        10
     374: aload_2
     375: checkcast     #67                 // class java/lang/Iterable
     378: astore        11
     380: iconst_0
     381: istore        12
     383: aload         11
     385: invokeinterface #84,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     390: astore        13
     392: aload         13
     394: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     399: ifeq          435
     402: aload         13
     404: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     409: astore        14
     411: aload         14
     413: checkcast     #125                // class java/lang/Number
     416: invokevirtual #128                // Method java/lang/Number.longValue:()J
     419: lstore        15
     421: iconst_0
     422: istore        17
     424: aload         10
     426: lload         15
     428: invokevirtual #262                // Method cz/wrent/advent/Monkey.add:(J)V
     431: nop
     432: goto          392
     435: nop
     436: aload         10
     438: areturn

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

  private static final long parseMonkey$lambda$6(java.lang.Long, long);
    Code:
       0: lload_1
       1: aload_0
       2: dup
       3: ifnull        12
       6: invokevirtual #285                // Method java/lang/Long.longValue:()J
       9: goto          14
      12: pop
      13: lload_1
      14: lmul
      15: lreturn

  private static final long parseMonkey$lambda$7(java.lang.Long, long);
    Code:
       0: lload_1
       1: aload_0
       2: dup
       3: ifnull        12
       6: invokevirtual #285                // Method java/lang/Long.longValue:()J
       9: goto          14
      12: pop
      13: lload_1
      14: ladd
      15: lreturn
}