package cz.wrent.advent

import java.util.*

fun main() {
	println(partOne(test))

	val result = partOne(input)
	println("18a: $result")

	println(partTwo(test))
	val resultTwo = partTwo(input)
	println("18b: $resultTwo")
}

private fun partOne(input: String): Int {
	val cubes = input.split("\n")
		.map { it.parseCube() }
		.toSet()
	return cubes.sumOf { it.getArea(cubes) }
}

private fun partTwo(input: String): Int {
	val cubes = input.split("\n")
		.map { it.parseCube() }
		.toSet()
	val maxX = cubes.maxByOrNull { it.x }!!.x
	val maxY = cubes.maxByOrNull { it.y }!!.y
	val maxZ = cubes.maxByOrNull { it.z }!!.z
	val minX = cubes.minByOrNull { it.x }!!.x
	val minY = cubes.minByOrNull { it.y }!!.y
	val minZ = cubes.minByOrNull { it.z }!!.z

	val bigCube = mutableSetOf<Cube>()
	for (i in minX - 1 .. maxX + 1) {
		for (j in minY - 1 .. maxY + 1) {
			for (k in minZ - 1 .. maxZ + 1) {
				bigCube.add(Cube(i, j, k))
			}
		}
	}

	val visited = blowAir(Cube(minX - 1, minY - 1, minZ - 1), bigCube, cubes)

	val inside = bigCube.minus(visited).minus(cubes)
	return cubes.sumOf { it.getArea(cubes) } - inside.sumOf { it.getArea(inside) }
}

private fun blowAir(
	cube: Cube,
	bigCube: Set<Cube>,
	cubes: Set<Cube>,
): Set<Cube> {
	val deque: Deque<Cube> = LinkedList(listOf(cube))
	val visited = mutableSetOf<Cube>()

	while (deque.isNotEmpty()) {
		val next = deque.pop()
		visited.add(next)
		next.getNeighbours(bigCube).forEach {
			if (!(visited.contains(it) || cubes.contains(it))) {
				deque.push(it)
			}
		}
	}

	return visited
}

private fun String.parseCube(): Cube {
	return this.split(",")
		.map { it.toInt() }
		.let {
			Cube(it.get(0), it.get(1), it.get(2))
		}
}

private data class Cube(val x: Int, val y: Int, val z: Int) {
	fun getArea(cubes: Set<Cube>): Int {
		return 6 - getNeighbours(cubes).size
	}

	fun getNeighbours(cubes: Set<Cube>): Set<Cube> {
		return setOf(
			Cube(x + 1, y, z),
			Cube(x - 1, y, z),
			Cube(x, y + 1, z),
			Cube(x, y - 1, z),
			Cube(x, y, z + 1),
			Cube(x, y, z - 1)
		).intersect(cubes)
	}
}

private const val test = """2,2,2
1,2,2
3,2,2
2,1,2
2,3,2
2,2,1
2,2,3
2,2,4
2,2,6
1,2,5
3,2,5
2,1,5
2,3,5"""

private const val input = """1,8,8
12,8,3
13,16,7
8,1,11
7,17,7
14,11,16
13,9,17
5,9,3
6,6,4
15,11,5
3,13,9
17,9,15
12,1,8
4,14,5
9,11,17
13,16,11
7,8,16
13,14,14
16,9,4
9,17,12
3,10,5
8,5,15
7,5,15
13,7,2
9,3,12
4,10,4
13,10,15
11,14,3
6,11,2
15,5,14
14,4,12
16,11,6
12,3,10
12,3,5
12,12,15
10,7,2
8,17,6
13,4,14
11,1,8
10,16,13
11,14,16
4,5,4
8,10,17
15,7,10
12,15,16
4,13,13
14,3,12
8,18,12
7,17,8
15,12,15
15,10,3
13,9,14
11,5,5
9,10,18
12,12,1
6,15,9
10,17,10
11,1,9
7,14,3
10,16,5
3,8,5
19,7,9
16,5,9
15,11,3
2,8,13
16,11,9
2,9,11
4,4,13
13,6,16
3,14,8
9,4,9
4,5,12
12,14,15
1,10,11
16,7,6
16,12,10
6,3,11
14,6,4
8,10,18
12,4,16
11,18,8
3,9,12
17,8,12
13,8,17
10,13,2
10,7,1
9,16,4
9,4,4
8,14,15
10,6,17
12,16,14
8,14,16
17,11,6
12,16,10
15,11,12
14,9,5
11,15,15
15,6,9
3,8,13
8,5,16
17,8,9
2,11,9
16,13,6
10,9,2
14,3,6
12,4,14
3,10,12
8,6,16
4,12,6
10,14,13
17,9,6
3,14,10
14,9,3
9,14,17
16,7,10
9,1,8
12,13,17
13,4,9
15,14,13
12,17,11
7,14,6
11,16,12
11,17,13
16,14,13
9,5,3
6,4,14
13,16,6
6,9,2
15,12,14
9,14,5
10,12,3
3,5,11
17,11,12
2,8,12
5,7,3
15,5,6
10,14,16
12,4,4
16,7,14
13,9,3
11,15,3
10,15,15
2,12,13
8,12,17
6,15,14
12,14,5
14,5,14
8,10,1
11,6,4
8,15,5
17,7,10
9,11,0
5,16,8
10,10,18
11,14,15
4,7,6
8,2,9
16,13,7
8,7,2
15,14,4
12,18,9
17,9,13
11,10,17
15,13,11
13,2,8
3,13,8
11,16,5
16,8,5
12,13,16
9,2,12
8,17,9
7,1,10
16,4,7
9,1,10
16,10,14
16,6,10
16,13,11
3,4,11
3,12,6
3,8,3
14,12,14
10,15,2
12,5,3
11,2,10
10,2,14
6,17,11
15,14,9
6,16,7
14,13,13
4,11,5
11,17,7
3,10,7
5,9,5
6,9,1
14,14,4
9,4,17
9,5,15
3,9,5
13,12,17
13,16,12
7,6,16
11,15,5
8,17,7
8,4,15
13,2,12
10,13,17
4,6,14
4,6,13
5,4,9
7,12,17
5,10,14
17,12,9
10,18,9
9,12,14
7,9,1
14,14,8
7,2,12
3,15,9
4,14,7
2,12,11
13,4,12
3,11,12
2,6,11
6,5,3
5,5,5
4,10,13
11,2,8
10,11,17
16,4,10
16,11,11
9,2,10
15,15,11
15,4,9
4,12,14
6,11,16
12,17,6
15,13,15
7,8,3
14,8,14
7,17,10
4,7,8
9,2,8
13,13,18
10,3,5
3,8,10
9,7,17
14,11,3
16,12,6
1,9,7
16,10,6
12,18,10
12,15,13
9,16,6
9,17,14
8,4,4
12,4,3
6,8,17
3,12,10
7,7,3
7,6,3
4,10,15
15,3,7
6,7,4
8,16,12
16,10,4
14,9,4
12,9,17
16,7,7
3,11,7
14,12,5
17,7,7
12,16,11
9,12,5
14,15,7
7,6,15
13,4,6
14,15,8
11,11,16
16,15,9
3,5,7
6,5,6
3,7,13
14,13,15
5,15,6
7,16,5
10,4,7
7,5,4
7,15,4
8,9,2
11,2,6
15,13,13
17,10,6
8,16,4
13,12,12
5,16,12
10,17,12
5,11,15
16,7,5
8,18,10
16,10,11
15,13,9
15,14,14
5,8,3
9,6,3
4,7,15
4,17,9
15,6,4
7,15,5
6,12,15
10,16,6
9,13,17
11,2,9
5,6,14
5,9,17
14,13,14
9,3,13
5,8,16
16,5,13
11,14,14
10,14,17
14,3,7
15,4,7
15,16,9
7,15,14
9,7,4
9,3,15
7,16,6
3,7,11
7,6,2
10,4,4
14,7,16
9,17,11
14,7,3
15,3,10
8,4,2
11,5,3
13,15,8
12,2,10
13,15,14
13,8,1
15,7,5
4,7,14
13,12,4
5,17,10
4,8,16
6,12,2
3,8,11
7,10,17
5,11,17
2,9,12
7,18,7
9,3,11
5,14,6
4,15,12
5,8,7
2,9,4
8,4,10
12,12,2
12,4,6
14,10,15
13,17,7
10,8,1
16,6,12
16,11,14
14,3,8
15,12,13
5,10,3
14,14,12
16,9,14
3,12,5
13,15,6
7,5,3
12,13,3
5,8,15
17,5,8
8,3,6
17,7,8
8,3,13
12,10,4
12,10,17
15,12,6
10,0,8
6,18,10
14,16,10
9,5,4
6,15,15
9,10,16
12,6,16
10,8,17
5,14,9
6,13,16
11,2,7
2,12,7
11,3,4
7,3,14
16,10,15
6,15,13
12,2,12
7,9,16
12,11,17
8,10,2
5,6,3
11,7,16
13,10,17
12,5,17
15,12,4
14,15,14
4,14,9
2,8,11
8,8,17
7,13,16
15,9,14
16,8,15
11,4,16
14,7,15
4,12,15
4,3,11
15,7,11
12,3,13
11,5,16
10,14,15
17,10,5
14,9,15
4,7,5
13,11,1
14,11,14
3,7,7
3,5,13
4,4,10
2,8,9
5,13,3
3,13,10
5,7,15
9,12,1
18,9,13
16,13,10
5,7,4
11,4,5
3,14,13
14,5,15
2,7,10
12,13,4
9,17,7
6,2,11
10,5,3
11,1,11
6,9,3
13,6,14
12,17,13
5,13,16
3,8,4
8,13,2
13,12,1
16,14,12
9,4,6
10,2,6
4,7,4
9,12,2
12,11,1
6,13,15
8,16,14
10,3,6
16,10,8
12,16,9
6,18,9
8,6,4
14,16,12
11,6,16
3,15,7
4,7,7
3,9,11
4,5,7
17,8,5
9,12,18
7,12,3
3,9,14
14,5,7
10,0,11
15,7,3
8,16,13
8,4,5
18,11,11
12,10,3
3,15,13
17,13,7
2,12,8
16,4,11
13,11,17
11,6,3
3,13,4
12,6,4
12,6,5
3,5,6
5,15,13
16,10,5
9,14,16
18,7,8
7,11,3
4,9,14
7,3,5
16,10,9
8,4,16
16,14,9
15,6,15
6,16,6
11,10,1
7,2,13
8,2,14
6,6,15
14,14,15
17,10,12
5,4,15
17,13,5
3,5,10
2,7,7
15,16,8
3,13,12
5,3,11
17,8,11
10,5,2
14,6,15
8,17,13
10,9,18
2,10,9
14,15,5
15,4,8
10,10,16
16,10,13
9,14,3
10,5,4
4,16,10
14,4,5
2,12,10
5,11,5
17,13,11
2,11,13
17,10,7
17,6,10
8,12,18
16,10,7
7,12,16
5,17,11
11,13,3
9,5,16
10,14,5
13,12,16
16,8,8
2,12,9
7,14,14
4,15,6
8,14,3
2,12,12
4,11,16
6,7,16
9,7,16
10,13,4
16,6,8
10,18,5
3,6,8
8,5,3
11,13,2
10,3,15
10,11,1
13,5,5
1,10,9
9,3,8
9,6,16
5,3,6
9,4,14
12,3,14
4,5,6
13,17,12
18,10,7
7,13,15
17,9,14
4,6,3
9,16,9
10,8,18
11,4,4
17,14,11
13,3,13
10,15,5
2,7,8
11,7,2
6,10,17
16,9,8
13,14,13
13,14,4
9,2,13
2,13,9
14,6,5
4,13,6
15,5,12
15,15,6
9,10,2
16,8,11
15,13,4
2,11,11
7,10,2
16,13,8
13,6,4
6,14,15
6,12,4
17,6,8
5,12,16
5,15,11
4,8,4
14,10,16
11,1,12
15,12,5
11,10,3
5,15,12
15,7,7
10,18,13
10,17,14
9,18,7
9,11,2
12,14,16
13,5,3
18,7,11
13,18,9
6,16,12
5,8,13
7,2,11
15,8,15
15,10,7
10,14,3
16,13,15
4,8,14
9,11,16
12,6,3
11,2,5
7,4,15
7,2,8
13,5,15
6,10,3
4,14,6
18,9,11
1,8,9
7,4,8
12,2,6
14,9,7
12,3,9
2,9,13
1,8,10
3,13,5
16,11,4
10,11,2
5,3,8
8,16,7
13,10,3
17,8,6
17,12,5
11,12,2
7,2,10
4,9,15
10,17,13
3,12,15
10,6,3
16,12,8
15,10,15
9,17,13
11,8,3
9,14,2
12,3,12
11,16,7
3,6,12
9,16,8
11,17,11
6,9,18
13,2,7
4,7,11
15,8,10
8,4,12
2,9,6
6,12,16
11,16,14
4,8,7
12,15,5
9,3,6
12,3,8
15,2,10
1,11,12
17,12,11
5,5,15
17,14,10
4,9,5
14,6,8
13,5,14
8,5,17
1,9,11
3,10,14
16,7,11
15,11,2
11,14,17
7,14,16
4,9,16
15,8,3
3,9,4
6,7,3
8,13,15
5,10,15
17,7,6
3,7,6
7,15,15
17,6,7
11,15,2
14,13,4
4,4,12
8,17,8
9,11,1
16,8,4
18,8,9
11,18,10
3,9,15
5,2,11
5,10,4
12,8,18
7,16,13
12,16,12
5,6,7
7,8,17
16,6,11
12,18,11
14,8,5
15,14,7
17,7,12
5,11,11
8,2,5
12,1,12
3,9,6
15,7,6
13,15,3
7,12,14
10,4,2
13,15,5
2,13,13
14,5,5
16,12,7
5,14,12
12,12,3
16,14,11
2,14,10
14,16,5
15,5,9
4,12,5
19,8,8
16,5,10
6,3,7
10,2,12
11,17,9
8,11,15
9,8,17
6,2,9
9,1,7
9,2,16
9,13,15
17,14,13
3,6,6
5,14,7
7,10,3
17,9,12
10,3,13
14,12,12
7,16,14
8,2,11
8,13,17
5,12,15
9,4,13
3,5,8
2,10,5
4,15,11
13,2,9
3,12,14
3,5,9
8,16,6
3,9,7
14,9,16
13,17,8
10,2,8
6,15,10
5,14,5
16,8,10
5,12,4
14,14,5
3,7,12
4,8,12
15,4,14
4,4,8
14,5,12
12,1,10
13,3,6
4,14,14
8,5,4
14,4,6
11,6,2
6,4,4
9,12,17
4,13,12
8,4,6
5,5,16
2,6,7
15,13,12
6,2,8
16,12,15
16,11,13
10,12,16
7,17,5
11,13,4
10,16,16
10,15,7
12,13,2
4,3,8
7,3,7
13,8,3
11,15,17
13,16,10
11,12,4
16,15,11
1,8,7
3,11,4
6,9,16
10,17,11
6,15,7
12,15,4
6,9,17
7,13,1
14,16,8
3,6,9
4,16,12
5,9,2
15,12,3
5,6,5
9,12,4
7,10,1
6,3,12
10,3,8
14,4,15
5,4,6
7,13,3
17,7,13
15,13,6
6,4,9
4,5,13
8,8,2
3,12,11
13,2,10
15,7,15
0,11,7
17,11,13
17,10,8
4,7,3
2,11,7
11,17,8
7,4,10
6,6,14
8,5,14
15,11,4
14,8,15
4,3,9
10,4,12
14,16,11
2,9,7
15,12,9
5,11,3
10,2,13
9,2,14
5,9,4
3,7,5
15,6,14
5,15,8
7,4,7
6,8,16
2,15,12
16,14,8
9,7,13
8,14,17
13,11,2
4,9,13
14,13,12
7,10,16
11,16,13
13,14,5
2,8,6
15,13,10
15,5,5
18,7,10
17,13,9
6,16,9
4,14,13
11,15,4
15,11,15
15,15,9
14,8,4
10,17,6
15,13,7
6,8,2
10,10,17
5,12,2
10,6,18
17,6,5
4,6,12
8,7,18
6,16,11
4,15,10
9,18,10
3,13,11
16,5,8
12,17,8
11,11,17
9,17,6
8,1,13
13,17,6
9,9,17
2,6,9
12,16,7
17,6,12
10,2,7
15,10,4
8,15,15
14,16,7
16,5,7
3,5,14
11,7,5
7,3,4
13,11,3
2,9,5
11,6,18
10,17,8
3,11,10
10,9,1
7,2,7
16,9,13
8,12,16
4,8,6
8,15,4
4,16,11
3,15,10
16,9,11
8,8,16
5,16,9
17,8,8
12,14,4
6,14,6
16,3,9
11,13,17
9,14,14
7,4,13
9,2,15
8,11,18
17,11,7
7,9,2
8,1,9
11,17,10
8,18,8
14,12,16
16,14,5
3,15,12
11,4,6
9,18,9
15,10,16
3,9,10
5,4,14
8,17,11
5,14,11
15,13,5
16,3,10
10,10,2
9,9,2
16,7,12
10,7,17
10,12,18
11,8,17
10,4,16
14,12,6
11,12,3
3,12,9
4,6,8
11,1,10
4,3,12
13,4,13
8,16,8
10,8,2
13,16,13
8,8,18
11,16,15
5,13,15
13,13,6
5,15,5
10,1,10
14,3,10
13,8,14
7,5,12
16,7,9
15,16,10
6,4,5
5,14,14
16,6,6
15,12,12
18,9,8
1,8,12
5,13,14
17,9,7
12,14,2
4,12,3
7,6,13
11,10,18
10,1,12
15,4,13
8,6,1
12,10,16
7,6,4
6,10,16
17,13,10
12,16,6
15,5,13
6,17,13
9,1,12
9,8,16
10,4,13
11,7,3
18,10,8
11,1,6
6,17,8
16,13,5
13,14,15
14,14,14
16,8,9
3,6,11
4,6,5
6,16,10
11,18,9
7,4,11
5,5,12
3,14,6
10,9,3
3,14,9
8,10,16
9,15,6
8,2,13
7,14,4
13,2,11
12,10,2
8,7,3
3,4,10
2,15,8
14,2,8
7,17,11
4,13,11
7,15,9
13,17,9
15,4,11
13,17,13
2,7,11
8,18,7
14,13,5
3,6,5
10,2,11
9,13,16
11,2,12
7,13,4
10,16,15
7,4,14
11,4,15
4,13,7
15,7,13
13,15,12
6,4,12
11,15,11
16,12,5
18,8,8
4,6,7
13,3,5
6,7,17
15,3,6
9,17,5
8,7,17
8,5,2
3,11,15
10,5,17
5,7,16
17,10,14
3,7,8
7,16,7
7,11,2
15,13,8
2,7,13
11,16,4
4,12,4
9,4,15
4,5,15
12,5,4
13,7,3
9,16,10
5,10,5
4,16,8
4,5,10
7,3,13
16,13,12
15,14,6
13,3,9
11,3,14
1,6,10
15,8,17
4,12,13
8,18,6
14,15,9
10,4,3
9,18,8
2,8,5
16,5,12
3,8,12
15,15,7
9,15,8
15,7,4
3,15,11
17,9,5
16,11,12
13,9,16
11,7,17
6,14,3
9,16,16
11,7,1
16,15,8
11,18,7
9,2,7
5,5,3
16,12,12
13,5,4
12,1,9
7,5,16
6,4,15
17,10,11
2,6,8
5,16,11
5,13,4
5,9,15
6,14,13
14,15,13
4,9,12
16,12,9
6,13,3
10,1,8
13,11,18
14,14,16
1,10,7
14,4,9
3,14,11
3,7,10
8,2,8
2,8,7
7,9,17
3,12,12
14,17,10
9,14,4
3,6,10
6,11,14
16,4,8
7,11,17
14,12,13
11,3,10
7,11,15
12,5,14
11,9,17
12,5,5
8,17,12
17,9,9
3,11,5
2,11,6
10,1,7
4,5,14
8,16,5
17,11,14
7,13,17
17,11,11
9,2,9
9,5,2
11,8,2
3,10,4
11,6,15
12,4,11
5,4,10
10,4,15
17,12,7
4,13,10
14,7,4
16,12,11
7,16,8
10,2,10
14,17,13
9,6,5
15,4,5
3,5,12
15,13,14
8,3,9
9,4,3
3,12,7
6,1,12
8,9,16
15,14,11
15,12,8
15,14,15
1,11,11
6,16,8
12,16,5
16,8,13
8,11,1
11,1,7
4,15,8
18,8,13
13,14,3
3,8,7
15,7,14
4,6,6
10,18,10
5,4,4
6,4,13
1,10,8
7,7,17
13,3,8
14,8,17
6,8,3
14,14,6
3,6,14
13,17,10
12,3,6
14,5,16
17,5,9
17,5,10
16,15,10
2,13,7
8,17,5
18,12,11
8,17,10
16,5,5
9,2,11
5,4,13
14,8,3
16,7,13
11,12,17
17,8,10
4,5,5
13,12,15
16,12,13
8,16,11
4,15,7
10,1,11
2,10,10
9,15,5
9,16,14
7,13,2
17,11,8
12,8,16
6,3,6
2,13,8
6,6,13
17,7,11
8,12,15
5,12,3
16,15,7
5,9,13
6,3,8
9,15,2
6,17,12
9,16,7
15,9,12
12,7,15
7,17,14
10,9,17
8,1,8
9,10,1
11,7,18
3,7,15
5,6,16
6,14,4
4,13,5
9,15,12
7,7,4
7,3,8
11,11,1
8,11,17
11,11,18
14,10,3
10,2,9
6,11,3
2,9,9
8,15,2
3,13,13
9,16,13
8,15,14
16,6,4
16,8,14
6,8,15
15,10,14
15,16,14
9,16,5
2,3,8
5,3,9
13,8,4
12,12,17
4,12,12
9,18,11
5,3,12
2,7,9
5,9,16
14,2,13
16,11,8
6,15,5
16,6,13
12,8,2
6,2,7
8,14,4
4,4,11
1,9,8
10,3,14
10,15,12
2,6,12
15,6,8
3,10,6
14,13,16
2,11,14
14,3,11
9,6,2
4,7,12
2,13,11
6,6,16
5,4,5
2,5,10
14,3,14
7,5,13
11,3,13
5,14,8
12,3,7
5,13,12
7,2,9
16,5,11
12,16,13
7,14,7
4,15,9
9,3,7
16,9,6
6,13,4
13,4,3
4,7,16
3,8,8
11,3,6
3,13,6
8,3,12
11,8,4
10,17,9
4,14,8
16,9,5
5,12,14
9,9,1
4,4,9
17,9,8
7,9,3
15,14,12
6,12,3
10,3,7
7,5,2
11,4,8
8,3,10
5,16,6
17,11,9
12,6,14
12,2,11
6,16,13
6,7,18
2,4,10
8,15,3
14,16,9
6,3,14
16,11,5
12,9,2
13,4,4
15,14,8
8,18,9
18,9,9
13,7,16
8,13,13
16,14,7
13,6,15
18,13,8
15,14,10
13,5,9
15,16,12
6,17,10
13,14,6
4,11,15
4,17,11
8,9,1
4,9,3
10,6,15
15,3,11
14,11,15
6,5,15
4,11,14
12,2,7
10,15,14
6,13,13
4,6,4
14,4,8
15,15,15
11,2,11
7,15,8
3,16,9
13,2,13
2,5,9
10,4,10
8,12,2
10,6,2
14,6,14
11,17,14
8,6,3
16,14,10
9,5,7
15,15,12
2,11,8
8,2,15
2,13,10
6,5,7
14,2,10
5,8,2
8,2,10
9,9,18
6,13,2
10,16,4
14,12,4
12,5,15
2,10,6
5,14,3
5,8,4
9,15,15
13,5,16
15,15,10
5,7,8
12,7,2
3,11,6
11,3,12
4,13,14
15,15,5
14,11,2
7,15,11
8,1,7
13,15,4
13,13,2
17,5,12
11,5,17
7,15,7
6,15,12
9,1,11
9,5,1
7,4,9
9,6,17
10,16,8
12,2,9
18,10,6
3,10,9
5,3,10
16,8,12
7,16,9
14,15,12
13,15,7
16,8,7
14,16,6
5,6,11
8,6,2
13,13,17
5,4,7
7,13,18
16,9,12
1,11,7
13,10,16
18,11,9
13,4,15
15,3,8
6,3,5
10,13,16
18,12,8
6,10,2
3,10,16
10,6,16
11,3,5
11,10,2
4,7,13
1,9,10
11,9,18
13,16,5
11,13,5
4,13,16
3,10,13
11,3,15
16,9,7
5,6,4
1,7,8
13,6,2
15,16,11
12,16,4
13,10,2
2,9,14
2,5,7
4,3,10
10,4,5
9,13,3
9,13,2
11,16,3
11,3,9
17,11,10
13,3,10
11,1,14
10,15,6
7,15,16
6,12,17
13,8,2
2,6,13
11,15,12
12,8,1
15,5,10
4,11,4
8,3,8
1,11,10
18,9,7
5,15,9
10,4,17
8,18,11
10,7,3
9,7,18
7,3,6
11,17,5
14,17,14
7,2,6
13,15,15
3,14,14
14,5,6
13,17,11
15,8,5
11,9,3
3,10,15
6,14,5
4,14,4
5,7,5
15,6,13
12,4,5
14,6,12
7,16,4
3,4,8
7,7,2
15,4,6
14,12,15
15,6,16
9,15,4
13,10,1
15,6,6
8,9,17
16,6,5
4,4,5
13,10,18
3,7,14
7,6,17
7,6,6
12,9,1
2,10,8
7,8,1
12,11,16
11,3,16
5,5,9
11,8,16
14,10,17
14,10,14
5,15,7
2,8,10
10,13,3
6,4,11
14,14,10
4,10,16
5,8,5
4,10,14
9,12,16
16,10,12
16,6,7
12,7,18
13,3,7
11,3,11
1,7,9
3,8,6
9,3,16
9,17,8
5,14,4
5,17,9
18,11,8
5,4,11
10,7,16
7,7,15
6,2,10
16,13,13
13,12,2
16,11,15
12,8,17
17,8,7
16,14,6
4,13,15
2,7,5
5,11,4
6,14,7
12,15,6
11,13,15
4,16,6
6,6,3
14,13,3
11,14,4
4,9,6
16,12,4
7,16,12
7,17,12
9,10,17
15,11,7
9,13,4
11,9,2
10,14,4
4,10,5
15,9,15
3,11,3
12,7,17
3,5,5
7,1,12
8,4,14
2,11,10
8,6,17
18,9,12
7,4,5
11,14,2
3,6,13
15,6,3
6,3,13
7,9,15
6,5,4
17,12,12
14,10,13
4,8,15
13,16,14
11,4,11
4,16,7
10,18,7
7,4,4
5,2,5
14,4,14
5,13,9
7,2,15
13,14,8
6,7,5
13,7,17
15,6,11
10,17,7
17,13,12
4,9,4
7,6,1
15,8,8
17,12,4
16,11,7
4,5,9
11,6,17
14,14,9
4,13,9
9,3,14
6,13,12
11,11,2
15,15,8
4,9,10
12,11,4
9,8,3
12,6,17
5,3,13
15,8,11
2,10,7
5,4,8
11,8,18
16,12,14
8,11,2
4,14,15
12,5,13
1,11,9
13,13,15
1,9,9
6,14,17
7,16,10
4,4,14
16,6,9
1,10,10
4,9,11
16,15,12
16,14,14
9,15,14
9,4,5
12,14,3
13,11,6
15,14,5
3,8,16
9,9,16
12,15,14
11,4,3
6,5,14
4,5,11
15,5,8
18,8,10
6,3,9
7,7,16
12,3,15
14,4,13
15,3,13
15,15,13
8,9,18
12,17,7
1,10,12
9,7,2
5,11,9
15,8,12
13,16,4
10,9,16
18,10,11
12,13,14
1,7,12
13,15,13
17,6,9
2,9,10
8,4,13
15,6,5
5,11,16
3,6,7
4,4,7
4,12,7
14,9,14
7,15,13
8,11,3
15,8,7
5,7,14
3,12,13
11,16,9
13,18,10
6,10,15
11,16,11
7,3,15
12,7,3
14,12,8
6,14,9
10,4,14
1,10,6
3,10,8
7,5,7
14,11,4
11,4,14
13,6,3
4,6,11
3,14,4
17,6,11
18,13,10
2,12,5
8,13,16
17,12,8
9,1,9
15,4,12
11,17,6
10,6,5
14,6,16
17,12,10
18,9,10
4,11,3
2,12,6
7,12,15
10,3,9
12,9,3
11,15,9
5,10,17
8,13,1
9,5,13
12,9,16
15,9,16
13,4,7
6,13,17
10,18,6
6,7,14
10,7,4
13,13,5
8,7,16
17,4,9
8,9,4
9,9,19
4,11,13
13,7,4
13,6,5
6,4,6
5,13,5
15,9,3
10,13,1
10,6,4
4,14,12
6,12,6
5,16,7
4,15,13
12,4,12
10,14,6
9,6,1
15,6,10
7,3,10
8,4,3
13,9,1
5,2,12
14,3,5
7,11,18
14,10,2
4,8,5
6,12,18
7,17,6
9,8,18
3,14,7
12,4,13
14,4,11
15,7,16
14,2,9
8,3,15
5,16,14
14,3,9
12,14,17
17,14,6
5,6,13
7,14,15
4,15,14
14,14,13
5,3,7
8,2,7
13,3,15
8,1,10
4,3,6
17,12,6
6,8,1
14,5,4
17,9,11
13,15,9
11,5,13
3,10,11
17,10,10
15,10,11
13,18,12
14,15,15
16,16,9
14,12,3
11,3,7
18,10,9
13,3,14
4,10,6
3,12,8
2,9,8
14,8,13
13,11,16
5,10,16
9,17,9
14,5,9
13,12,3
5,12,8
7,18,12
9,5,14
5,6,15
0,8,10
16,9,10
8,2,12
17,6,6
14,5,13
3,8,9
5,5,13
8,13,4
15,12,7
14,11,5
14,15,6
18,10,10
9,8,1
5,12,6
10,3,4
10,5,16
7,4,6
13,16,9
6,5,5
10,2,15
4,16,9
4,8,13
11,15,13
5,5,14
9,7,3
6,2,12
11,9,1
15,16,13
15,16,7
10,5,5
14,6,11
14,15,10
2,14,9
8,8,15
10,11,18
12,2,13
12,10,18
10,15,17
17,14,9
12,15,7
7,3,12
12,12,16
6,9,4
1,12,10
13,10,4
14,4,7
10,10,4
13,14,12
2,12,14
8,5,5
14,9,17
8,11,4
7,4,3
10,2,5
8,16,10
10,11,16
18,12,9
17,4,11
14,16,13
11,9,4
18,7,12
7,4,12
13,9,2
13,13,16
8,3,5
6,5,16
1,7,11
7,10,19
14,6,13
15,11,14
14,2,11
14,4,10
8,8,3
15,8,4
14,10,5
3,15,6
17,13,8
11,3,3
10,16,7
17,7,9
6,2,6
14,6,6
17,12,13
14,7,5
13,4,5
4,3,7
13,8,16
3,9,9
2,10,12
16,4,9
1,8,11
10,18,12
10,12,1
16,11,10
15,8,6
10,14,2
13,3,12
18,11,10
18,12,10
6,7,15
7,18,9
12,15,9
6,5,13
13,4,8
2,5,8
5,5,6
10,12,17
15,17,8
10,15,16
7,15,3
8,0,11
4,14,11
15,5,7
3,16,10
8,16,15
15,11,16
6,7,2
12,17,12
4,15,5
15,7,12
6,14,14
18,13,7
4,4,6
6,10,4
10,16,11
11,4,13
4,11,12
10,0,7
6,5,12
16,7,8
9,16,11
14,15,11
16,7,4
12,18,12
17,8,13
2,11,12
2,14,13
8,8,4
6,2,13
9,5,17
11,6,1
2,13,6
3,3,8
12,7,16
7,9,18
11,14,5
15,3,12
14,17,11
14,12,2
16,8,6
15,7,9
10,10,15
3,4,9
6,4,8
5,7,2
15,10,6
9,8,2
9,15,3
5,4,12
16,7,15
9,11,18
13,5,13
2,14,11
12,5,16
4,16,5
14,17,8
5,7,10
12,6,15
13,6,6
2,7,15
11,13,18
7,1,7
15,9,5
5,15,14
8,13,3
10,16,14
4,17,13
13,3,11
16,13,9
2,14,8
7,2,5
11,13,16
12,10,1
4,12,10
5,14,10
4,12,8
6,16,15
18,5,11
7,8,2
14,8,16
7,17,13
13,14,7
10,1,9
2,6,10
12,4,7
4,11,2
9,16,15
8,3,11
6,3,10
11,5,4
4,5,8
9,5,11
1,12,9
15,16,6
10,3,12
4,10,17
10,10,1
8,9,3
15,12,16
15,8,16
13,9,4
7,11,16
4,11,7
9,11,3
5,2,10
10,3,16
11,16,6
5,16,10
11,8,1
13,7,18
11,18,13
9,17,10
8,3,7
4,13,3
12,17,9
10,15,3
6,15,6
17,10,9
13,4,11
9,15,16
13,13,14
5,1,7
11,2,14
8,1,12
10,18,11
4,13,8
2,10,4
14,3,13
17,13,6
1,9,13
2,11,5
6,15,4
8,15,6
17,14,7
12,11,18
11,5,2
9,16,3
2,8,8
3,8,15
14,6,3
5,2,9
12,6,18
18,6,8
3,6,4
10,9,0
16,9,3
6,12,14
7,17,9
7,14,13
7,16,15
10,17,5
12,15,3
3,4,7
9,3,5
5,14,16
7,5,6
6,14,16
13,5,2
5,13,8
7,1,9
17,9,10
8,15,16
6,6,10
7,5,14"""


package cz.wrent.advent

import java.util.*

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

private fun partOne(input: String): String {
	return moveCrates(input) { x, y, z -> moveCrates9000(x, y, z) }
}

private fun partTwo(input: String): String {
	return moveCrates(input) { x, y, z -> moveCrates9001(x, y, z) }
}

private fun moveCrates(input: String, fn: (from: Deque<String>, to: Deque<String>, num: Int) -> Unit): String {
	val (stacksInput, movesInput) = input.split("\n\n")
	val stacks = stacksInput.toStacks()
	val moves = movesInput.toMoves()
	moves.forEach {
		val from = stacks.get(it.from)
		val to = stacks.get(it.to)
		fn(from, to, it.num)
	}
	return stacks.map { it.peek() }.joinToString(separator = "")
}

private fun moveCrates9000(from: Deque<String>, to: Deque<String>, num: Int) {
	repeat(num) {
		val crate = from.pop()
		to.push(crate)
	}
}

private fun moveCrates9001(from: Deque<String>, to: Deque<String>, num: Int) {
	val crates = mutableListOf<String>()
	repeat(num) {
		crates.add(from.pop())
	}
	crates.reversed().forEach { to.push(it) }
}

private fun String.toStacks(): List<Deque<String>> {
	val split = this.split("\n").dropLast(1)
	val cnt = (split.first().length + 1) / 4
	val lists = (0 until cnt).map { mutableListOf<String>() }
	for (row in split) {
		var i = 1
		var j = 0
		while (i < row.length) {
			val char = row[i]
			if (char != ' ') {
				lists.get(j).add(char.toString())
			}
			j++
			i += 4
		}
	}
	return lists.map {
		it.toDeque()
	}
}

private fun List<String>.toDeque(): Deque<String> {
	return LinkedList(this)
}

private data class Move(val num: Int, val from: Int, val to: Int)

private fun String.toMoves(): List<Move> {
	val regex =  Regex("move (\\d+) from (\\d+) to (\\d+)")
	return this.split("\n")
		.map { regex.matchEntire(it) }
		.map { Move(it!!.groupValues.get(1).toInt(), it.groupValues.get(2).toInt() - 1, it.groupValues.get(3).toInt() - 1) }
}

private const val input = """[Q] [J]                         [H]
[G] [S] [Q]     [Z]             [P]
[P] [F] [M]     [F]     [F]     [S]
[R] [R] [P] [F] [V]     [D]     [L]
[L] [W] [W] [D] [W] [S] [V]     [G]
[C] [H] [H] [T] [D] [L] [M] [B] [B]
[T] [Q] [B] [S] [L] [C] [B] [J] [N]
[F] [N] [F] [V] [Q] [Z] [Z] [T] [Q]
 1   2   3   4   5   6   7   8   9

move 1 from 8 to 1
move 1 from 6 to 1
move 3 from 7 to 4
move 3 from 2 to 9
move 11 from 9 to 3
move 1 from 6 to 9
move 15 from 3 to 9
move 5 from 2 to 3
move 3 from 7 to 5
move 6 from 9 to 3
move 6 from 1 to 6
move 2 from 3 to 7
move 5 from 4 to 5
move 7 from 9 to 4
move 2 from 9 to 5
move 10 from 4 to 2
move 6 from 5 to 4
move 2 from 7 to 6
move 10 from 2 to 3
move 21 from 3 to 5
move 1 from 3 to 6
move 3 from 6 to 9
move 1 from 8 to 9
move 5 from 4 to 5
move 4 from 9 to 3
move 17 from 5 to 1
move 1 from 6 to 2
move 16 from 5 to 1
move 3 from 3 to 6
move 6 from 6 to 4
move 1 from 2 to 4
move 4 from 1 to 2
move 2 from 6 to 2
move 28 from 1 to 3
move 1 from 9 to 7
move 1 from 8 to 7
move 1 from 5 to 4
move 1 from 2 to 6
move 1 from 3 to 1
move 3 from 2 to 5
move 1 from 6 to 3
move 4 from 4 to 7
move 5 from 5 to 2
move 1 from 5 to 6
move 6 from 1 to 3
move 1 from 6 to 2
move 26 from 3 to 6
move 2 from 7 to 9
move 4 from 7 to 3
move 19 from 6 to 3
move 6 from 2 to 4
move 5 from 3 to 2
move 1 from 9 to 7
move 26 from 3 to 8
move 6 from 4 to 3
move 1 from 3 to 8
move 1 from 6 to 7
move 6 from 3 to 6
move 6 from 6 to 4
move 1 from 9 to 2
move 2 from 4 to 9
move 22 from 8 to 2
move 2 from 6 to 5
move 1 from 9 to 1
move 1 from 6 to 5
move 1 from 7 to 5
move 3 from 6 to 7
move 2 from 6 to 1
move 1 from 1 to 5
move 3 from 5 to 9
move 4 from 8 to 4
move 2 from 1 to 4
move 18 from 2 to 1
move 2 from 7 to 8
move 3 from 9 to 5
move 8 from 1 to 9
move 5 from 9 to 3
move 1 from 9 to 8
move 2 from 9 to 4
move 2 from 7 to 8
move 5 from 5 to 7
move 1 from 9 to 3
move 4 from 8 to 4
move 1 from 7 to 8
move 4 from 4 to 3
move 2 from 8 to 3
move 1 from 8 to 9
move 2 from 1 to 8
move 3 from 4 to 5
move 1 from 8 to 4
move 1 from 9 to 3
move 1 from 8 to 5
move 8 from 1 to 8
move 11 from 2 to 9
move 12 from 3 to 5
move 1 from 3 to 9
move 1 from 8 to 5
move 11 from 9 to 3
move 4 from 5 to 9
move 3 from 8 to 7
move 3 from 7 to 8
move 1 from 5 to 8
move 7 from 4 to 3
move 1 from 4 to 5
move 1 from 2 to 8
move 3 from 7 to 6
move 3 from 4 to 8
move 1 from 7 to 9
move 2 from 4 to 7
move 5 from 8 to 1
move 3 from 6 to 5
move 2 from 4 to 2
move 1 from 9 to 4
move 1 from 8 to 6
move 1 from 2 to 9
move 1 from 8 to 5
move 3 from 8 to 4
move 3 from 4 to 2
move 4 from 3 to 9
move 17 from 5 to 9
move 9 from 9 to 6
move 1 from 9 to 3
move 5 from 6 to 3
move 3 from 6 to 3
move 8 from 9 to 5
move 2 from 8 to 5
move 1 from 4 to 8
move 1 from 5 to 3
move 1 from 8 to 5
move 3 from 2 to 6
move 3 from 1 to 4
move 7 from 5 to 1
move 1 from 2 to 6
move 13 from 3 to 6
move 2 from 7 to 8
move 13 from 6 to 5
move 3 from 5 to 7
move 6 from 5 to 6
move 1 from 7 to 6
move 2 from 7 to 3
move 1 from 6 to 8
move 13 from 3 to 5
move 9 from 5 to 9
move 7 from 5 to 7
move 17 from 9 to 2
move 3 from 4 to 7
move 9 from 2 to 9
move 10 from 9 to 3
move 8 from 7 to 8
move 2 from 5 to 3
move 4 from 2 to 6
move 11 from 3 to 9
move 9 from 6 to 5
move 5 from 9 to 8
move 1 from 3 to 1
move 3 from 9 to 1
move 2 from 5 to 2
move 1 from 7 to 9
move 2 from 9 to 4
move 2 from 9 to 8
move 13 from 1 to 8
move 3 from 8 to 5
move 27 from 8 to 1
move 10 from 5 to 9
move 1 from 7 to 2
move 2 from 4 to 3
move 10 from 9 to 6
move 1 from 8 to 7
move 15 from 1 to 9
move 13 from 9 to 5
move 15 from 5 to 7
move 5 from 1 to 3
move 8 from 7 to 1
move 7 from 7 to 1
move 16 from 1 to 8
move 4 from 3 to 9
move 4 from 1 to 7
move 4 from 9 to 6
move 5 from 2 to 7
move 15 from 8 to 6
move 1 from 9 to 1
move 3 from 3 to 4
move 1 from 9 to 7
move 1 from 2 to 7
move 1 from 2 to 7
move 1 from 8 to 1
move 3 from 4 to 8
move 3 from 8 to 1
move 8 from 6 to 8
move 7 from 1 to 4
move 11 from 6 to 8
move 14 from 6 to 5
move 13 from 8 to 7
move 4 from 7 to 5
move 15 from 7 to 4
move 6 from 5 to 4
move 2 from 5 to 9
move 1 from 5 to 2
move 3 from 8 to 5
move 19 from 4 to 7
move 10 from 5 to 8
move 2 from 6 to 8
move 1 from 4 to 8
move 2 from 7 to 9
move 9 from 7 to 4
move 6 from 4 to 6
move 11 from 4 to 8
move 2 from 5 to 4
move 5 from 6 to 4
move 1 from 6 to 7
move 3 from 9 to 5
move 3 from 8 to 5
move 3 from 7 to 6
move 11 from 8 to 7
move 1 from 9 to 5
move 1 from 6 to 8
move 1 from 2 to 1
move 5 from 4 to 9
move 2 from 4 to 1
move 2 from 1 to 4
move 1 from 1 to 9
move 4 from 5 to 1
move 1 from 4 to 6
move 17 from 7 to 5
move 9 from 8 to 7
move 6 from 9 to 7
move 3 from 1 to 9
move 12 from 7 to 9
move 12 from 9 to 5
move 5 from 7 to 9
move 17 from 5 to 3
move 7 from 3 to 1
move 5 from 1 to 5
move 5 from 9 to 2
move 4 from 3 to 5
move 1 from 4 to 8
move 5 from 2 to 1
move 22 from 5 to 9
move 3 from 7 to 6
move 6 from 6 to 9
move 2 from 5 to 4
move 1 from 6 to 3
move 2 from 4 to 1
move 3 from 8 to 2
move 1 from 3 to 4
move 24 from 9 to 1
move 4 from 3 to 9
move 2 from 2 to 9
move 2 from 3 to 1
move 1 from 8 to 6
move 1 from 6 to 9
move 1 from 8 to 9
move 2 from 7 to 4
move 1 from 8 to 3
move 1 from 4 to 7
move 3 from 9 to 8
move 1 from 2 to 1
move 9 from 9 to 3
move 1 from 8 to 7
move 1 from 4 to 3
move 2 from 9 to 7
move 1 from 9 to 3
move 2 from 8 to 4
move 12 from 3 to 8
move 2 from 1 to 7
move 1 from 4 to 3
move 30 from 1 to 5
move 6 from 5 to 7
move 12 from 7 to 2
move 1 from 3 to 4
move 2 from 1 to 3
move 1 from 4 to 9
move 10 from 5 to 7
move 10 from 2 to 6
move 8 from 8 to 3
move 3 from 1 to 3
move 5 from 6 to 3
move 2 from 8 to 5
move 1 from 9 to 2
move 2 from 8 to 6
move 4 from 7 to 2
move 3 from 2 to 7
move 2 from 7 to 5
move 1 from 4 to 9
move 11 from 3 to 1
move 7 from 6 to 9
move 3 from 2 to 3
move 10 from 1 to 7
move 14 from 7 to 5
move 3 from 7 to 6
move 5 from 9 to 7
move 29 from 5 to 7
move 6 from 3 to 9
move 2 from 9 to 7
move 15 from 7 to 5
move 11 from 5 to 6
move 5 from 9 to 5
move 10 from 5 to 8
move 1 from 2 to 4
move 1 from 8 to 2
move 2 from 4 to 3
move 2 from 5 to 9
move 8 from 8 to 9
move 11 from 9 to 3
move 1 from 1 to 8
move 18 from 7 to 3
move 1 from 9 to 3
move 28 from 3 to 5
move 12 from 6 to 7
move 1 from 2 to 9
move 15 from 7 to 2
move 1 from 8 to 1
move 10 from 2 to 9
move 10 from 5 to 3
move 2 from 2 to 3
move 18 from 3 to 4
move 6 from 9 to 4
move 1 from 1 to 7
move 1 from 6 to 4
move 1 from 8 to 2
move 1 from 9 to 4
move 2 from 9 to 4
move 19 from 4 to 3
move 1 from 7 to 9
move 1 from 9 to 7
move 1 from 6 to 8
move 3 from 2 to 8
move 2 from 9 to 5
move 15 from 3 to 1
move 7 from 5 to 1
move 3 from 4 to 9
move 1 from 7 to 2
move 3 from 3 to 1
move 6 from 5 to 2
move 3 from 3 to 9
move 4 from 9 to 2
move 5 from 5 to 3
move 1 from 3 to 5
move 3 from 5 to 7
move 3 from 8 to 5
move 1 from 7 to 5
move 4 from 5 to 1
move 4 from 4 to 2
move 2 from 7 to 8
move 12 from 1 to 6
move 1 from 8 to 6
move 6 from 2 to 3
move 9 from 3 to 8
move 1 from 3 to 4
move 3 from 6 to 1
move 2 from 9 to 2
move 1 from 4 to 5
move 2 from 8 to 3
move 10 from 2 to 1
move 2 from 4 to 7
move 12 from 1 to 4
move 1 from 5 to 1
move 7 from 4 to 9
move 2 from 3 to 2
move 6 from 9 to 2
move 1 from 9 to 1
move 1 from 7 to 8
move 5 from 6 to 7
move 3 from 6 to 1
move 6 from 2 to 3
move 2 from 4 to 3
move 1 from 6 to 8
move 1 from 6 to 7
move 8 from 3 to 9
move 2 from 4 to 5
move 3 from 2 to 4
move 10 from 8 to 2
move 22 from 1 to 9
move 9 from 2 to 4
move 1 from 1 to 3
move 1 from 3 to 2
move 3 from 2 to 4
move 2 from 7 to 1
move 14 from 4 to 2
move 2 from 1 to 8
move 2 from 4 to 5
move 4 from 7 to 8
move 24 from 9 to 6
move 3 from 5 to 9
move 1 from 9 to 8
move 1 from 5 to 2
move 1 from 6 to 7
move 6 from 9 to 1
move 1 from 7 to 3
move 5 from 8 to 6
move 9 from 6 to 3
move 4 from 1 to 4
move 2 from 1 to 2
move 11 from 6 to 3
move 13 from 3 to 2
move 2 from 9 to 8
move 8 from 3 to 8
move 2 from 8 to 5
move 1 from 7 to 5
move 3 from 6 to 3
move 11 from 8 to 5
move 13 from 2 to 4
move 10 from 5 to 2
move 2 from 3 to 4
move 2 from 5 to 7
move 15 from 4 to 9
move 2 from 7 to 4
move 2 from 4 to 2
move 2 from 4 to 9
move 2 from 4 to 2
move 1 from 3 to 8
move 1 from 8 to 1
move 1 from 1 to 2
move 1 from 6 to 3
move 7 from 2 to 4
move 1 from 5 to 3
move 7 from 9 to 1
move 7 from 1 to 2
move 4 from 6 to 9
move 12 from 9 to 7
move 6 from 7 to 5
move 1 from 3 to 5
move 7 from 4 to 7
move 3 from 7 to 8
move 3 from 8 to 6
move 18 from 2 to 9
move 7 from 2 to 3
move 15 from 9 to 4
move 3 from 3 to 9
move 1 from 3 to 1
move 3 from 5 to 4
move 1 from 1 to 2
move 1 from 9 to 2
move 2 from 6 to 2
move 5 from 7 to 6
move 5 from 2 to 7
move 3 from 3 to 4
move 5 from 5 to 3
move 6 from 7 to 4
move 9 from 4 to 2
move 18 from 4 to 9
move 6 from 2 to 1
move 1 from 1 to 9
move 4 from 7 to 4
move 7 from 2 to 4
move 1 from 2 to 8
move 1 from 4 to 2
move 4 from 3 to 4
move 16 from 9 to 5
move 9 from 9 to 8
move 1 from 9 to 7
move 4 from 1 to 2
move 2 from 5 to 4
move 10 from 5 to 4
move 4 from 2 to 1
move 5 from 1 to 2
move 1 from 8 to 5
move 1 from 6 to 5
move 4 from 8 to 5
move 2 from 6 to 9
move 3 from 6 to 2
move 2 from 9 to 1
move 1 from 7 to 6
move 1 from 3 to 8
move 9 from 5 to 9
move 4 from 8 to 1
move 2 from 8 to 2
move 1 from 5 to 7
move 9 from 9 to 8
move 1 from 7 to 5
move 9 from 8 to 2
move 6 from 1 to 6
move 6 from 2 to 6
move 10 from 2 to 5
move 5 from 2 to 1
move 1 from 3 to 5
move 8 from 5 to 4
move 5 from 1 to 3
move 10 from 6 to 8
move 3 from 6 to 9
move 4 from 3 to 1
move 5 from 8 to 2
move 4 from 5 to 9
move 1 from 3 to 7
move 1 from 7 to 3
move 1 from 8 to 6
move 1 from 6 to 1
move 15 from 4 to 8
move 5 from 9 to 2
move 1 from 9 to 1
move 1 from 1 to 3
move 6 from 4 to 8
move 12 from 8 to 7
move 1 from 3 to 5
move 3 from 1 to 9
move 13 from 4 to 9
move 5 from 7 to 2
move 1 from 5 to 4
move 8 from 9 to 5
move 6 from 2 to 5
move 2 from 5 to 6"""

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

  public static final void main();
    Code:
       0: ldc           #8                  // String [Q] [J]                         [H]\n[G] [S] [Q]     [Z]             [P]\n[P] [F] [M]     [F]     [F]     [S]\n[R] [R] [P] [F] [V]     [D]     [L]\n[L] [W] [W] [D] [W] [S] [V]     [G]\n[C] [H] [H] [T] [D] [L] [M] [B] [B]\n[T] [Q] [B] [S] [L] [C] [B] [J] [N]\n[F] [N] [F] [V] [Q] [Z] [Z] [T] [Q]\n 1   2   3   4   5   6   7   8   9 \n\nmove 1 from 8 to 1\nmove 1 from 6 to 1\nmove 3 from 7 to 4\nmove 3 from 2 to 9\nmove 11 from 9 to 3\nmove 1 from 6 to 9\nmove 15 from 3 to 9\nmove 5 from 2 to 3\nmove 3 from 7 to 5\nmove 6 from 9 to 3\nmove 6 from 1 to 6\nmove 2 from 3 to 7\nmove 5 from 4 to 5\nmove 7 from 9 to 4\nmove 2 from 9 to 5\nmove 10 from 4 to 2\nmove 6 from 5 to 4\nmove 2 from 7 to 6\nmove 10 from 2 to 3\nmove 21 from 3 to 5\nmove 1 from 3 to 6\nmove 3 from 6 to 9\nmove 1 from 8 to 9\nmove 5 from 4 to 5\nmove 4 from 9 to 3\nmove 17 from 5 to 1\nmove 1 from 6 to 2\nmove 16 from 5 to 1\nmove 3 from 3 to 6\nmove 6 from 6 to 4\nmove 1 from 2 to 4\nmove 4 from 1 to 2\nmove 2 from 6 to 2\nmove 28 from 1 to 3\nmove 1 from 9 to 7\nmove 1 from 8 to 7\nmove 1 from 5 to 4\nmove 1 from 2 to 6\nmove 1 from 3 to 1\nmove 3 from 2 to 5\nmove 1 from 6 to 3\nmove 4 from 4 to 7\nmove 5 from 5 to 2\nmove 1 from 5 to 6\nmove 6 from 1 to 3\nmove 1 from 6 to 2\nmove 26 from 3 to 6\nmove 2 from 7 to 9\nmove 4 from 7 to 3\nmove 19 from 6 to 3\nmove 6 from 2 to 4\nmove 5 from 3 to 2\nmove 1 from 9 to 7\nmove 26 from 3 to 8\nmove 6 from 4 to 3\nmove 1 from 3 to 8\nmove 1 from 6 to 7\nmove 6 from 3 to 6\nmove 6 from 6 to 4\nmove 1 from 9 to 2\nmove 2 from 4 to 9\nmove 22 from 8 to 2\nmove 2 from 6 to 5\nmove 1 from 9 to 1\nmove 1 from 6 to 5\nmove 1 from 7 to 5\nmove 3 from 6 to 7\nmove 2 from 6 to 1\nmove 1 from 1 to 5\nmove 3 from 5 to 9\nmove 4 from 8 to 4\nmove 2 from 1 to 4\nmove 18 from 2 to 1\nmove 2 from 7 to 8\nmove 3 from 9 to 5\nmove 8 from 1 to 9\nmove 5 from 9 to 3\nmove 1 from 9 to 8\nmove 2 from 9 to 4\nmove 2 from 7 to 8\nmove 5 from 5 to 7\nmove 1 from 9 to 3\nmove 4 from 8 to 4\nmove 1 from 7 to 8\nmove 4 from 4 to 3\nmove 2 from 8 to 3\nmove 1 from 8 to 9\nmove 2 from 1 to 8\nmove 3 from 4 to 5\nmove 1 from 8 to 4\nmove 1 from 9 to 3\nmove 1 from 8 to 5\nmove 8 from 1 to 8\nmove 11 from 2 to 9\nmove 12 from 3 to 5\nmove 1 from 3 to 9\nmove 1 from 8 to 5\nmove 11 from 9 to 3\nmove 4 from 5 to 9\nmove 3 from 8 to 7\nmove 3 from 7 to 8\nmove 1 from 5 to 8\nmove 7 from 4 to 3\nmove 1 from 4 to 5\nmove 1 from 2 to 8\nmove 3 from 7 to 6\nmove 3 from 4 to 8\nmove 1 from 7 to 9\nmove 2 from 4 to 7\nmove 5 from 8 to 1\nmove 3 from 6 to 5\nmove 2 from 4 to 2\nmove 1 from 9 to 4\nmove 1 from 8 to 6\nmove 1 from 2 to 9\nmove 1 from 8 to 5\nmove 3 from 8 to 4\nmove 3 from 4 to 2\nmove 4 from 3 to 9\nmove 17 from 5 to 9\nmove 9 from 9 to 6\nmove 1 from 9 to 3\nmove 5 from 6 to 3\nmove 3 from 6 to 3\nmove 8 from 9 to 5\nmove 2 from 8 to 5\nmove 1 from 4 to 8\nmove 1 from 5 to 3\nmove 1 from 8 to 5\nmove 3 from 2 to 6\nmove 3 from 1 to 4\nmove 7 from 5 to 1\nmove 1 from 2 to 6\nmove 13 from 3 to 6\nmove 2 from 7 to 8\nmove 13 from 6 to 5\nmove 3 from 5 to 7\nmove 6 from 5 to 6\nmove 1 from 7 to 6\nmove 2 from 7 to 3\nmove 1 from 6 to 8\nmove 13 from 3 to 5\nmove 9 from 5 to 9\nmove 7 from 5 to 7\nmove 17 from 9 to 2\nmove 3 from 4 to 7\nmove 9 from 2 to 9\nmove 10 from 9 to 3\nmove 8 from 7 to 8\nmove 2 from 5 to 3\nmove 4 from 2 to 6\nmove 11 from 3 to 9\nmove 9 from 6 to 5\nmove 5 from 9 to 8\nmove 1 from 3 to 1\nmove 3 from 9 to 1\nmove 2 from 5 to 2\nmove 1 from 7 to 9\nmove 2 from 9 to 4\nmove 2 from 9 to 8\nmove 13 from 1 to 8\nmove 3 from 8 to 5\nmove 27 from 8 to 1\nmove 10 from 5 to 9\nmove 1 from 7 to 2\nmove 2 from 4 to 3\nmove 10 from 9 to 6\nmove 1 from 8 to 7\nmove 15 from 1 to 9\nmove 13 from 9 to 5\nmove 15 from 5 to 7\nmove 5 from 1 to 3\nmove 8 from 7 to 1\nmove 7 from 7 to 1\nmove 16 from 1 to 8\nmove 4 from 3 to 9\nmove 4 from 1 to 7\nmove 4 from 9 to 6\nmove 5 from 2 to 7\nmove 15 from 8 to 6\nmove 1 from 9 to 1\nmove 3 from 3 to 4\nmove 1 from 9 to 7\nmove 1 from 2 to 7\nmove 1 from 2 to 7\nmove 1 from 8 to 1\nmove 3 from 4 to 8\nmove 3 from 8 to 1\nmove 8 from 6 to 8\nmove 7 from 1 to 4\nmove 11 from 6 to 8\nmove 14 from 6 to 5\nmove 13 from 8 to 7\nmove 4 from 7 to 5\nmove 15 from 7 to 4\nmove 6 from 5 to 4\nmove 2 from 5 to 9\nmove 1 from 5 to 2\nmove 3 from 8 to 5\nmove 19 from 4 to 7\nmove 10 from 5 to 8\nmove 2 from 6 to 8\nmove 1 from 4 to 8\nmove 2 from 7 to 9\nmove 9 from 7 to 4\nmove 6 from 4 to 6\nmove 11 from 4 to 8\nmove 2 from 5 to 4\nmove 5 from 6 to 4\nmove 1 from 6 to 7\nmove 3 from 9 to 5\nmove 3 from 8 to 5\nmove 3 from 7 to 6\nmove 11 from 8 to 7\nmove 1 from 9 to 5\nmove 1 from 6 to 8\nmove 1 from 2 to 1\nmove 5 from 4 to 9\nmove 2 from 4 to 1\nmove 2 from 1 to 4\nmove 1 from 1 to 9\nmove 4 from 5 to 1\nmove 1 from 4 to 6\nmove 17 from 7 to 5\nmove 9 from 8 to 7\nmove 6 from 9 to 7\nmove 3 from 1 to 9\nmove 12 from 7 to 9\nmove 12 from 9 to 5\nmove 5 from 7 to 9\nmove 17 from 5 to 3\nmove 7 from 3 to 1\nmove 5 from 1 to 5\nmove 5 from 9 to 2\nmove 4 from 3 to 5\nmove 1 from 4 to 8\nmove 5 from 2 to 1\nmove 22 from 5 to 9\nmove 3 from 7 to 6\nmove 6 from 6 to 9\nmove 2 from 5 to 4\nmove 1 from 6 to 3\nmove 2 from 4 to 1\nmove 3 from 8 to 2\nmove 1 from 3 to 4\nmove 24 from 9 to 1\nmove 4 from 3 to 9\nmove 2 from 2 to 9\nmove 2 from 3 to 1\nmove 1 from 8 to 6\nmove 1 from 6 to 9\nmove 1 from 8 to 9\nmove 2 from 7 to 4\nmove 1 from 8 to 3\nmove 1 from 4 to 7\nmove 3 from 9 to 8\nmove 1 from 2 to 1\nmove 9 from 9 to 3\nmove 1 from 8 to 7\nmove 1 from 4 to 3\nmove 2 from 9 to 7\nmove 1 from 9 to 3\nmove 2 from 8 to 4\nmove 12 from 3 to 8\nmove 2 from 1 to 7\nmove 1 from 4 to 3\nmove 30 from 1 to 5\nmove 6 from 5 to 7\nmove 12 from 7 to 2\nmove 1 from 3 to 4\nmove 2 from 1 to 3\nmove 1 from 4 to 9\nmove 10 from 5 to 7\nmove 10 from 2 to 6\nmove 8 from 8 to 3\nmove 3 from 1 to 3\nmove 5 from 6 to 3\nmove 2 from 8 to 5\nmove 1 from 9 to 2\nmove 2 from 8 to 6\nmove 4 from 7 to 2\nmove 3 from 2 to 7\nmove 2 from 7 to 5\nmove 1 from 4 to 9\nmove 11 from 3 to 1\nmove 7 from 6 to 9\nmove 3 from 2 to 3\nmove 10 from 1 to 7\nmove 14 from 7 to 5\nmove 3 from 7 to 6\nmove 5 from 9 to 7\nmove 29 from 5 to 7\nmove 6 from 3 to 9\nmove 2 from 9 to 7\nmove 15 from 7 to 5\nmove 11 from 5 to 6\nmove 5 from 9 to 5\nmove 10 from 5 to 8\nmove 1 from 2 to 4\nmove 1 from 8 to 2\nmove 2 from 4 to 3\nmove 2 from 5 to 9\nmove 8 from 8 to 9\nmove 11 from 9 to 3\nmove 1 from 1 to 8\nmove 18 from 7 to 3\nmove 1 from 9 to 3\nmove 28 from 3 to 5\nmove 12 from 6 to 7\nmove 1 from 2 to 9\nmove 15 from 7 to 2\nmove 1 from 8 to 1\nmove 10 from 2 to 9\nmove 10 from 5 to 3\nmove 2 from 2 to 3\nmove 18 from 3 to 4\nmove 6 from 9 to 4\nmove 1 from 1 to 7\nmove 1 from 6 to 4\nmove 1 from 8 to 2\nmove 1 from 9 to 4\nmove 2 from 9 to 4\nmove 19 from 4 to 3\nmove 1 from 7 to 9\nmove 1 from 9 to 7\nmove 1 from 6 to 8\nmove 3 from 2 to 8\nmove 2 from 9 to 5\nmove 15 from 3 to 1\nmove 7 from 5 to 1\nmove 3 from 4 to 9\nmove 1 from 7 to 2\nmove 3 from 3 to 1\nmove 6 from 5 to 2\nmove 3 from 3 to 9\nmove 4 from 9 to 2\nmove 5 from 5 to 3\nmove 1 from 3 to 5\nmove 3 from 5 to 7\nmove 3 from 8 to 5\nmove 1 from 7 to 5\nmove 4 from 5 to 1\nmove 4 from 4 to 2\nmove 2 from 7 to 8\nmove 12 from 1 to 6\nmove 1 from 8 to 6\nmove 6 from 2 to 3\nmove 9 from 3 to 8\nmove 1 from 3 to 4\nmove 3 from 6 to 1\nmove 2 from 9 to 2\nmove 1 from 4 to 5\nmove 2 from 8 to 3\nmove 10 from 2 to 1\nmove 2 from 4 to 7\nmove 12 from 1 to 4\nmove 1 from 5 to 1\nmove 7 from 4 to 9\nmove 2 from 3 to 2\nmove 6 from 9 to 2\nmove 1 from 9 to 1\nmove 1 from 7 to 8\nmove 5 from 6 to 7\nmove 3 from 6 to 1\nmove 6 from 2 to 3\nmove 2 from 4 to 3\nmove 1 from 6 to 8\nmove 1 from 6 to 7\nmove 8 from 3 to 9\nmove 2 from 4 to 5\nmove 3 from 2 to 4\nmove 10 from 8 to 2\nmove 22 from 1 to 9\nmove 9 from 2 to 4\nmove 1 from 1 to 3\nmove 1 from 3 to 2\nmove 3 from 2 to 4\nmove 2 from 7 to 1\nmove 14 from 4 to 2\nmove 2 from 1 to 8\nmove 2 from 4 to 5\nmove 4 from 7 to 8\nmove 24 from 9 to 6\nmove 3 from 5 to 9\nmove 1 from 9 to 8\nmove 1 from 5 to 2\nmove 1 from 6 to 7\nmove 6 from 9 to 1\nmove 1 from 7 to 3\nmove 5 from 8 to 6\nmove 9 from 6 to 3\nmove 4 from 1 to 4\nmove 2 from 1 to 2\nmove 11 from 6 to 3\nmove 13 from 3 to 2\nmove 2 from 9 to 8\nmove 8 from 3 to 8\nmove 2 from 8 to 5\nmove 1 from 7 to 5\nmove 3 from 6 to 3\nmove 11 from 8 to 5\nmove 13 from 2 to 4\nmove 10 from 5 to 2\nmove 2 from 3 to 4\nmove 2 from 5 to 7\nmove 15 from 4 to 9\nmove 2 from 7 to 4\nmove 2 from 4 to 2\nmove 2 from 4 to 9\nmove 2 from 4 to 2\nmove 1 from 3 to 8\nmove 1 from 8 to 1\nmove 1 from 1 to 2\nmove 1 from 6 to 3\nmove 7 from 2 to 4\nmove 1 from 5 to 3\nmove 7 from 9 to 1\nmove 7 from 1 to 2\nmove 4 from 6 to 9\nmove 12 from 9 to 7\nmove 6 from 7 to 5\nmove 1 from 3 to 5\nmove 7 from 4 to 7\nmove 3 from 7 to 8\nmove 3 from 8 to 6\nmove 18 from 2 to 9\nmove 7 from 2 to 3\nmove 15 from 9 to 4\nmove 3 from 3 to 9\nmove 1 from 3 to 1\nmove 3 from 5 to 4\nmove 1 from 1 to 2\nmove 1 from 9 to 2\nmove 2 from 6 to 2\nmove 5 from 7 to 6\nmove 5 from 2 to 7\nmove 3 from 3 to 4\nmove 5 from 5 to 3\nmove 6 from 7 to 4\nmove 9 from 4 to 2\nmove 18 from 4 to 9\nmove 6 from 2 to 1\nmove 1 from 1 to 9\nmove 4 from 7 to 4\nmove 7 from 2 to 4\nmove 1 from 2 to 8\nmove 1 from 4 to 2\nmove 4 from 3 to 4\nmove 16 from 9 to 5\nmove 9 from 9 to 8\nmove 1 from 9 to 7\nmove 4 from 1 to 2\nmove 2 from 5 to 4\nmove 10 from 5 to 4\nmove 4 from 2 to 1\nmove 5 from 1 to 2\nmove 1 from 8 to 5\nmove 1 from 6 to 5\nmove 4 from 8 to 5\nmove 2 from 6 to 9\nmove 3 from 6 to 2\nmove 2 from 9 to 1\nmove 1 from 7 to 6\nmove 1 from 3 to 8\nmove 9 from 5 to 9\nmove 4 from 8 to 1\nmove 2 from 8 to 2\nmove 1 from 5 to 7\nmove 9 from 9 to 8\nmove 1 from 7 to 5\nmove 9 from 8 to 2\nmove 6 from 1 to 6\nmove 6 from 2 to 6\nmove 10 from 2 to 5\nmove 5 from 2 to 1\nmove 1 from 3 to 5\nmove 8 from 5 to 4\nmove 5 from 1 to 3\nmove 10 from 6 to 8\nmove 3 from 6 to 9\nmove 4 from 3 to 1\nmove 5 from 8 to 2\nmove 4 from 5 to 9\nmove 1 from 3 to 7\nmove 1 from 7 to 3\nmove 1 from 8 to 6\nmove 1 from 6 to 1\nmove 15 from 4 to 8\nmove 5 from 9 to 2\nmove 1 from 9 to 1\nmove 1 from 1 to 3\nmove 6 from 4 to 8\nmove 12 from 8 to 7\nmove 1 from 3 to 5\nmove 3 from 1 to 9\nmove 13 from 4 to 9\nmove 5 from 7 to 2\nmove 1 from 5 to 4\nmove 8 from 9 to 5\nmove 6 from 2 to 5\nmove 2 from 5 to 6
       2: invokestatic  #12                 // Method partOne:(Ljava/lang/String;)Ljava/lang/String;
       5: astore_0
       6: new           #14                 // class java/lang/StringBuilder
       9: dup
      10: invokespecial #17                 // Method java/lang/StringBuilder."<init>":()V
      13: ldc           #19                 // String 5a:
      15: invokevirtual #23                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      18: aload_0
      19: invokevirtual #23                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      22: invokevirtual #27                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      25: getstatic     #33                 // Field java/lang/System.out:Ljava/io/PrintStream;
      28: swap
      29: invokevirtual #39                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      32: ldc           #8                  // String [Q] [J]                         [H]\n[G] [S] [Q]     [Z]             [P]\n[P] [F] [M]     [F]     [F]     [S]\n[R] [R] [P] [F] [V]     [D]     [L]\n[L] [W] [W] [D] [W] [S] [V]     [G]\n[C] [H] [H] [T] [D] [L] [M] [B] [B]\n[T] [Q] [B] [S] [L] [C] [B] [J] [N]\n[F] [N] [F] [V] [Q] [Z] [Z] [T] [Q]\n 1   2   3   4   5   6   7   8   9 \n\nmove 1 from 8 to 1\nmove 1 from 6 to 1\nmove 3 from 7 to 4\nmove 3 from 2 to 9\nmove 11 from 9 to 3\nmove 1 from 6 to 9\nmove 15 from 3 to 9\nmove 5 from 2 to 3\nmove 3 from 7 to 5\nmove 6 from 9 to 3\nmove 6 from 1 to 6\nmove 2 from 3 to 7\nmove 5 from 4 to 5\nmove 7 from 9 to 4\nmove 2 from 9 to 5\nmove 10 from 4 to 2\nmove 6 from 5 to 4\nmove 2 from 7 to 6\nmove 10 from 2 to 3\nmove 21 from 3 to 5\nmove 1 from 3 to 6\nmove 3 from 6 to 9\nmove 1 from 8 to 9\nmove 5 from 4 to 5\nmove 4 from 9 to 3\nmove 17 from 5 to 1\nmove 1 from 6 to 2\nmove 16 from 5 to 1\nmove 3 from 3 to 6\nmove 6 from 6 to 4\nmove 1 from 2 to 4\nmove 4 from 1 to 2\nmove 2 from 6 to 2\nmove 28 from 1 to 3\nmove 1 from 9 to 7\nmove 1 from 8 to 7\nmove 1 from 5 to 4\nmove 1 from 2 to 6\nmove 1 from 3 to 1\nmove 3 from 2 to 5\nmove 1 from 6 to 3\nmove 4 from 4 to 7\nmove 5 from 5 to 2\nmove 1 from 5 to 6\nmove 6 from 1 to 3\nmove 1 from 6 to 2\nmove 26 from 3 to 6\nmove 2 from 7 to 9\nmove 4 from 7 to 3\nmove 19 from 6 to 3\nmove 6 from 2 to 4\nmove 5 from 3 to 2\nmove 1 from 9 to 7\nmove 26 from 3 to 8\nmove 6 from 4 to 3\nmove 1 from 3 to 8\nmove 1 from 6 to 7\nmove 6 from 3 to 6\nmove 6 from 6 to 4\nmove 1 from 9 to 2\nmove 2 from 4 to 9\nmove 22 from 8 to 2\nmove 2 from 6 to 5\nmove 1 from 9 to 1\nmove 1 from 6 to 5\nmove 1 from 7 to 5\nmove 3 from 6 to 7\nmove 2 from 6 to 1\nmove 1 from 1 to 5\nmove 3 from 5 to 9\nmove 4 from 8 to 4\nmove 2 from 1 to 4\nmove 18 from 2 to 1\nmove 2 from 7 to 8\nmove 3 from 9 to 5\nmove 8 from 1 to 9\nmove 5 from 9 to 3\nmove 1 from 9 to 8\nmove 2 from 9 to 4\nmove 2 from 7 to 8\nmove 5 from 5 to 7\nmove 1 from 9 to 3\nmove 4 from 8 to 4\nmove 1 from 7 to 8\nmove 4 from 4 to 3\nmove 2 from 8 to 3\nmove 1 from 8 to 9\nmove 2 from 1 to 8\nmove 3 from 4 to 5\nmove 1 from 8 to 4\nmove 1 from 9 to 3\nmove 1 from 8 to 5\nmove 8 from 1 to 8\nmove 11 from 2 to 9\nmove 12 from 3 to 5\nmove 1 from 3 to 9\nmove 1 from 8 to 5\nmove 11 from 9 to 3\nmove 4 from 5 to 9\nmove 3 from 8 to 7\nmove 3 from 7 to 8\nmove 1 from 5 to 8\nmove 7 from 4 to 3\nmove 1 from 4 to 5\nmove 1 from 2 to 8\nmove 3 from 7 to 6\nmove 3 from 4 to 8\nmove 1 from 7 to 9\nmove 2 from 4 to 7\nmove 5 from 8 to 1\nmove 3 from 6 to 5\nmove 2 from 4 to 2\nmove 1 from 9 to 4\nmove 1 from 8 to 6\nmove 1 from 2 to 9\nmove 1 from 8 to 5\nmove 3 from 8 to 4\nmove 3 from 4 to 2\nmove 4 from 3 to 9\nmove 17 from 5 to 9\nmove 9 from 9 to 6\nmove 1 from 9 to 3\nmove 5 from 6 to 3\nmove 3 from 6 to 3\nmove 8 from 9 to 5\nmove 2 from 8 to 5\nmove 1 from 4 to 8\nmove 1 from 5 to 3\nmove 1 from 8 to 5\nmove 3 from 2 to 6\nmove 3 from 1 to 4\nmove 7 from 5 to 1\nmove 1 from 2 to 6\nmove 13 from 3 to 6\nmove 2 from 7 to 8\nmove 13 from 6 to 5\nmove 3 from 5 to 7\nmove 6 from 5 to 6\nmove 1 from 7 to 6\nmove 2 from 7 to 3\nmove 1 from 6 to 8\nmove 13 from 3 to 5\nmove 9 from 5 to 9\nmove 7 from 5 to 7\nmove 17 from 9 to 2\nmove 3 from 4 to 7\nmove 9 from 2 to 9\nmove 10 from 9 to 3\nmove 8 from 7 to 8\nmove 2 from 5 to 3\nmove 4 from 2 to 6\nmove 11 from 3 to 9\nmove 9 from 6 to 5\nmove 5 from 9 to 8\nmove 1 from 3 to 1\nmove 3 from 9 to 1\nmove 2 from 5 to 2\nmove 1 from 7 to 9\nmove 2 from 9 to 4\nmove 2 from 9 to 8\nmove 13 from 1 to 8\nmove 3 from 8 to 5\nmove 27 from 8 to 1\nmove 10 from 5 to 9\nmove 1 from 7 to 2\nmove 2 from 4 to 3\nmove 10 from 9 to 6\nmove 1 from 8 to 7\nmove 15 from 1 to 9\nmove 13 from 9 to 5\nmove 15 from 5 to 7\nmove 5 from 1 to 3\nmove 8 from 7 to 1\nmove 7 from 7 to 1\nmove 16 from 1 to 8\nmove 4 from 3 to 9\nmove 4 from 1 to 7\nmove 4 from 9 to 6\nmove 5 from 2 to 7\nmove 15 from 8 to 6\nmove 1 from 9 to 1\nmove 3 from 3 to 4\nmove 1 from 9 to 7\nmove 1 from 2 to 7\nmove 1 from 2 to 7\nmove 1 from 8 to 1\nmove 3 from 4 to 8\nmove 3 from 8 to 1\nmove 8 from 6 to 8\nmove 7 from 1 to 4\nmove 11 from 6 to 8\nmove 14 from 6 to 5\nmove 13 from 8 to 7\nmove 4 from 7 to 5\nmove 15 from 7 to 4\nmove 6 from 5 to 4\nmove 2 from 5 to 9\nmove 1 from 5 to 2\nmove 3 from 8 to 5\nmove 19 from 4 to 7\nmove 10 from 5 to 8\nmove 2 from 6 to 8\nmove 1 from 4 to 8\nmove 2 from 7 to 9\nmove 9 from 7 to 4\nmove 6 from 4 to 6\nmove 11 from 4 to 8\nmove 2 from 5 to 4\nmove 5 from 6 to 4\nmove 1 from 6 to 7\nmove 3 from 9 to 5\nmove 3 from 8 to 5\nmove 3 from 7 to 6\nmove 11 from 8 to 7\nmove 1 from 9 to 5\nmove 1 from 6 to 8\nmove 1 from 2 to 1\nmove 5 from 4 to 9\nmove 2 from 4 to 1\nmove 2 from 1 to 4\nmove 1 from 1 to 9\nmove 4 from 5 to 1\nmove 1 from 4 to 6\nmove 17 from 7 to 5\nmove 9 from 8 to 7\nmove 6 from 9 to 7\nmove 3 from 1 to 9\nmove 12 from 7 to 9\nmove 12 from 9 to 5\nmove 5 from 7 to 9\nmove 17 from 5 to 3\nmove 7 from 3 to 1\nmove 5 from 1 to 5\nmove 5 from 9 to 2\nmove 4 from 3 to 5\nmove 1 from 4 to 8\nmove 5 from 2 to 1\nmove 22 from 5 to 9\nmove 3 from 7 to 6\nmove 6 from 6 to 9\nmove 2 from 5 to 4\nmove 1 from 6 to 3\nmove 2 from 4 to 1\nmove 3 from 8 to 2\nmove 1 from 3 to 4\nmove 24 from 9 to 1\nmove 4 from 3 to 9\nmove 2 from 2 to 9\nmove 2 from 3 to 1\nmove 1 from 8 to 6\nmove 1 from 6 to 9\nmove 1 from 8 to 9\nmove 2 from 7 to 4\nmove 1 from 8 to 3\nmove 1 from 4 to 7\nmove 3 from 9 to 8\nmove 1 from 2 to 1\nmove 9 from 9 to 3\nmove 1 from 8 to 7\nmove 1 from 4 to 3\nmove 2 from 9 to 7\nmove 1 from 9 to 3\nmove 2 from 8 to 4\nmove 12 from 3 to 8\nmove 2 from 1 to 7\nmove 1 from 4 to 3\nmove 30 from 1 to 5\nmove 6 from 5 to 7\nmove 12 from 7 to 2\nmove 1 from 3 to 4\nmove 2 from 1 to 3\nmove 1 from 4 to 9\nmove 10 from 5 to 7\nmove 10 from 2 to 6\nmove 8 from 8 to 3\nmove 3 from 1 to 3\nmove 5 from 6 to 3\nmove 2 from 8 to 5\nmove 1 from 9 to 2\nmove 2 from 8 to 6\nmove 4 from 7 to 2\nmove 3 from 2 to 7\nmove 2 from 7 to 5\nmove 1 from 4 to 9\nmove 11 from 3 to 1\nmove 7 from 6 to 9\nmove 3 from 2 to 3\nmove 10 from 1 to 7\nmove 14 from 7 to 5\nmove 3 from 7 to 6\nmove 5 from 9 to 7\nmove 29 from 5 to 7\nmove 6 from 3 to 9\nmove 2 from 9 to 7\nmove 15 from 7 to 5\nmove 11 from 5 to 6\nmove 5 from 9 to 5\nmove 10 from 5 to 8\nmove 1 from 2 to 4\nmove 1 from 8 to 2\nmove 2 from 4 to 3\nmove 2 from 5 to 9\nmove 8 from 8 to 9\nmove 11 from 9 to 3\nmove 1 from 1 to 8\nmove 18 from 7 to 3\nmove 1 from 9 to 3\nmove 28 from 3 to 5\nmove 12 from 6 to 7\nmove 1 from 2 to 9\nmove 15 from 7 to 2\nmove 1 from 8 to 1\nmove 10 from 2 to 9\nmove 10 from 5 to 3\nmove 2 from 2 to 3\nmove 18 from 3 to 4\nmove 6 from 9 to 4\nmove 1 from 1 to 7\nmove 1 from 6 to 4\nmove 1 from 8 to 2\nmove 1 from 9 to 4\nmove 2 from 9 to 4\nmove 19 from 4 to 3\nmove 1 from 7 to 9\nmove 1 from 9 to 7\nmove 1 from 6 to 8\nmove 3 from 2 to 8\nmove 2 from 9 to 5\nmove 15 from 3 to 1\nmove 7 from 5 to 1\nmove 3 from 4 to 9\nmove 1 from 7 to 2\nmove 3 from 3 to 1\nmove 6 from 5 to 2\nmove 3 from 3 to 9\nmove 4 from 9 to 2\nmove 5 from 5 to 3\nmove 1 from 3 to 5\nmove 3 from 5 to 7\nmove 3 from 8 to 5\nmove 1 from 7 to 5\nmove 4 from 5 to 1\nmove 4 from 4 to 2\nmove 2 from 7 to 8\nmove 12 from 1 to 6\nmove 1 from 8 to 6\nmove 6 from 2 to 3\nmove 9 from 3 to 8\nmove 1 from 3 to 4\nmove 3 from 6 to 1\nmove 2 from 9 to 2\nmove 1 from 4 to 5\nmove 2 from 8 to 3\nmove 10 from 2 to 1\nmove 2 from 4 to 7\nmove 12 from 1 to 4\nmove 1 from 5 to 1\nmove 7 from 4 to 9\nmove 2 from 3 to 2\nmove 6 from 9 to 2\nmove 1 from 9 to 1\nmove 1 from 7 to 8\nmove 5 from 6 to 7\nmove 3 from 6 to 1\nmove 6 from 2 to 3\nmove 2 from 4 to 3\nmove 1 from 6 to 8\nmove 1 from 6 to 7\nmove 8 from 3 to 9\nmove 2 from 4 to 5\nmove 3 from 2 to 4\nmove 10 from 8 to 2\nmove 22 from 1 to 9\nmove 9 from 2 to 4\nmove 1 from 1 to 3\nmove 1 from 3 to 2\nmove 3 from 2 to 4\nmove 2 from 7 to 1\nmove 14 from 4 to 2\nmove 2 from 1 to 8\nmove 2 from 4 to 5\nmove 4 from 7 to 8\nmove 24 from 9 to 6\nmove 3 from 5 to 9\nmove 1 from 9 to 8\nmove 1 from 5 to 2\nmove 1 from 6 to 7\nmove 6 from 9 to 1\nmove 1 from 7 to 3\nmove 5 from 8 to 6\nmove 9 from 6 to 3\nmove 4 from 1 to 4\nmove 2 from 1 to 2\nmove 11 from 6 to 3\nmove 13 from 3 to 2\nmove 2 from 9 to 8\nmove 8 from 3 to 8\nmove 2 from 8 to 5\nmove 1 from 7 to 5\nmove 3 from 6 to 3\nmove 11 from 8 to 5\nmove 13 from 2 to 4\nmove 10 from 5 to 2\nmove 2 from 3 to 4\nmove 2 from 5 to 7\nmove 15 from 4 to 9\nmove 2 from 7 to 4\nmove 2 from 4 to 2\nmove 2 from 4 to 9\nmove 2 from 4 to 2\nmove 1 from 3 to 8\nmove 1 from 8 to 1\nmove 1 from 1 to 2\nmove 1 from 6 to 3\nmove 7 from 2 to 4\nmove 1 from 5 to 3\nmove 7 from 9 to 1\nmove 7 from 1 to 2\nmove 4 from 6 to 9\nmove 12 from 9 to 7\nmove 6 from 7 to 5\nmove 1 from 3 to 5\nmove 7 from 4 to 7\nmove 3 from 7 to 8\nmove 3 from 8 to 6\nmove 18 from 2 to 9\nmove 7 from 2 to 3\nmove 15 from 9 to 4\nmove 3 from 3 to 9\nmove 1 from 3 to 1\nmove 3 from 5 to 4\nmove 1 from 1 to 2\nmove 1 from 9 to 2\nmove 2 from 6 to 2\nmove 5 from 7 to 6\nmove 5 from 2 to 7\nmove 3 from 3 to 4\nmove 5 from 5 to 3\nmove 6 from 7 to 4\nmove 9 from 4 to 2\nmove 18 from 4 to 9\nmove 6 from 2 to 1\nmove 1 from 1 to 9\nmove 4 from 7 to 4\nmove 7 from 2 to 4\nmove 1 from 2 to 8\nmove 1 from 4 to 2\nmove 4 from 3 to 4\nmove 16 from 9 to 5\nmove 9 from 9 to 8\nmove 1 from 9 to 7\nmove 4 from 1 to 2\nmove 2 from 5 to 4\nmove 10 from 5 to 4\nmove 4 from 2 to 1\nmove 5 from 1 to 2\nmove 1 from 8 to 5\nmove 1 from 6 to 5\nmove 4 from 8 to 5\nmove 2 from 6 to 9\nmove 3 from 6 to 2\nmove 2 from 9 to 1\nmove 1 from 7 to 6\nmove 1 from 3 to 8\nmove 9 from 5 to 9\nmove 4 from 8 to 1\nmove 2 from 8 to 2\nmove 1 from 5 to 7\nmove 9 from 9 to 8\nmove 1 from 7 to 5\nmove 9 from 8 to 2\nmove 6 from 1 to 6\nmove 6 from 2 to 6\nmove 10 from 2 to 5\nmove 5 from 2 to 1\nmove 1 from 3 to 5\nmove 8 from 5 to 4\nmove 5 from 1 to 3\nmove 10 from 6 to 8\nmove 3 from 6 to 9\nmove 4 from 3 to 1\nmove 5 from 8 to 2\nmove 4 from 5 to 9\nmove 1 from 3 to 7\nmove 1 from 7 to 3\nmove 1 from 8 to 6\nmove 1 from 6 to 1\nmove 15 from 4 to 8\nmove 5 from 9 to 2\nmove 1 from 9 to 1\nmove 1 from 1 to 3\nmove 6 from 4 to 8\nmove 12 from 8 to 7\nmove 1 from 3 to 5\nmove 3 from 1 to 9\nmove 13 from 4 to 9\nmove 5 from 7 to 2\nmove 1 from 5 to 4\nmove 8 from 9 to 5\nmove 6 from 2 to 5\nmove 2 from 5 to 6
      34: invokestatic  #42                 // Method partTwo:(Ljava/lang/String;)Ljava/lang/String;
      37: astore_1
      38: new           #14                 // class java/lang/StringBuilder
      41: dup
      42: invokespecial #17                 // Method java/lang/StringBuilder."<init>":()V
      45: ldc           #44                 // String 5b:
      47: invokevirtual #23                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      50: aload_1
      51: invokevirtual #23                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      54: invokevirtual #27                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      57: getstatic     #33                 // Field java/lang/System.out:Ljava/io/PrintStream;
      60: swap
      61: invokevirtual #39                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      64: return

  private static final java.lang.String partOne(java.lang.String);
    Code:
       0: aload_0
       1: invokedynamic #67,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function3;
       6: invokestatic  #71                 // Method moveCrates:(Ljava/lang/String;Lkotlin/jvm/functions/Function3;)Ljava/lang/String;
       9: areturn

  private static final java.lang.String partTwo(java.lang.String);
    Code:
       0: aload_0
       1: invokedynamic #77,  0             // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function3;
       6: invokestatic  #71                 // Method moveCrates:(Ljava/lang/String;Lkotlin/jvm/functions/Function3;)Ljava/lang/String;
       9: areturn

  private static final java.lang.String moveCrates(java.lang.String, kotlin.jvm.functions.Function3<? super java.util.Deque<java.lang.String>, ? super java.util.Deque<java.lang.String>, ? super java.lang.Integer, kotlin.Unit>);
    Code:
       0: aload_0
       1: checkcast     #80                 // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #82                 // class java/lang/String
       8: astore_3
       9: aload_3
      10: iconst_0
      11: ldc           #84                 // String \n\n
      13: aastore
      14: aload_3
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #90                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: astore_2
      24: aload_2
      25: iconst_0
      26: invokeinterface #96,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      31: checkcast     #82                 // class java/lang/String
      34: astore_3
      35: aload_2
      36: iconst_1
      37: invokeinterface #96,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      42: checkcast     #82                 // class java/lang/String
      45: astore        4
      47: aload_3
      48: invokestatic  #100                // Method toStacks:(Ljava/lang/String;)Ljava/util/List;
      51: astore        5
      53: aload         4
      55: invokestatic  #103                // Method toMoves:(Ljava/lang/String;)Ljava/util/List;
      58: astore        6
      60: aload         6
      62: checkcast     #105                // class java/lang/Iterable
      65: astore        7
      67: iconst_0
      68: istore        8
      70: aload         7
      72: invokeinterface #109,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      77: astore        9
      79: aload         9
      81: invokeinterface #115,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      86: ifeq          166
      89: aload         9
      91: invokeinterface #119,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      96: astore        10
      98: aload         10
     100: checkcast     #121                // class cz/wrent/advent/Move
     103: astore        11
     105: iconst_0
     106: istore        12
     108: aload         5
     110: aload         11
     112: invokevirtual #125                // Method cz/wrent/advent/Move.getFrom:()I
     115: invokeinterface #96,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     120: checkcast     #127                // class java/util/Deque
     123: astore        13
     125: aload         5
     127: aload         11
     129: invokevirtual #130                // Method cz/wrent/advent/Move.getTo:()I
     132: invokeinterface #96,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     137: checkcast     #127                // class java/util/Deque
     140: astore        14
     142: aload_1
     143: aload         13
     145: aload         14
     147: aload         11
     149: invokevirtual #133                // Method cz/wrent/advent/Move.getNum:()I
     152: invokestatic  #139                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     155: invokeinterface #143,  4          // InterfaceMethod kotlin/jvm/functions/Function3.invoke:(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     160: pop
     161: nop
     162: nop
     163: goto          79
     166: nop
     167: aload         5
     169: checkcast     #105                // class java/lang/Iterable
     172: astore        7
     174: iconst_0
     175: istore        8
     177: aload         7
     179: astore        9
     181: new           #145                // class java/util/ArrayList
     184: dup
     185: aload         7
     187: bipush        10
     189: invokestatic  #151                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     192: invokespecial #154                // Method java/util/ArrayList."<init>":(I)V
     195: checkcast     #156                // class java/util/Collection
     198: astore        10
     200: iconst_0
     201: istore        11
     203: aload         9
     205: invokeinterface #109,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     210: astore        12
     212: aload         12
     214: invokeinterface #115,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     219: ifeq          267
     222: aload         12
     224: invokeinterface #119,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     229: astore        13
     231: aload         10
     233: aload         13
     235: checkcast     #127                // class java/util/Deque
     238: astore        14
     240: astore        16
     242: iconst_0
     243: istore        15
     245: aload         14
     247: invokeinterface #159,  1          // InterfaceMethod java/util/Deque.peek:()Ljava/lang/Object;
     252: checkcast     #82                 // class java/lang/String
     255: aload         16
     257: swap
     258: invokeinterface #163,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     263: pop
     264: goto          212
     267: aload         10
     269: checkcast     #92                 // class java/util/List
     272: nop
     273: checkcast     #105                // class java/lang/Iterable
     276: ldc           #165                // String
     278: checkcast     #80                 // class java/lang/CharSequence
     281: aconst_null
     282: aconst_null
     283: iconst_0
     284: aconst_null
     285: aconst_null
     286: bipush        62
     288: aconst_null
     289: invokestatic  #169                // 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;
     292: areturn

  private static final void moveCrates9000(java.util.Deque<java.lang.String>, java.util.Deque<java.lang.String>, int);
    Code:
       0: iconst_0
       1: istore_3
       2: iload_3
       3: iload_2
       4: if_icmpge     39
       7: iload_3
       8: istore        4
      10: iconst_0
      11: istore        5
      13: aload_0
      14: invokeinterface #202,  1          // InterfaceMethod java/util/Deque.pop:()Ljava/lang/Object;
      19: checkcast     #82                 // class java/lang/String
      22: astore        6
      24: aload_1
      25: aload         6
      27: invokeinterface #205,  2          // InterfaceMethod java/util/Deque.push:(Ljava/lang/Object;)V
      32: nop
      33: iinc          3, 1
      36: goto          2
      39: return

  private static final void moveCrates9001(java.util.Deque<java.lang.String>, java.util.Deque<java.lang.String>, int);
    Code:
       0: new           #145                // class java/util/ArrayList
       3: dup
       4: invokespecial #210                // Method java/util/ArrayList."<init>":()V
       7: checkcast     #92                 // class java/util/List
      10: astore_3
      11: iconst_0
      12: istore        4
      14: iload         4
      16: iload_2
      17: if_icmpge     53
      20: iload         4
      22: istore        5
      24: iconst_0
      25: istore        6
      27: aload_3
      28: aload_0
      29: invokeinterface #202,  1          // InterfaceMethod java/util/Deque.pop:()Ljava/lang/Object;
      34: dup
      35: ldc           #212                // String pop(...)
      37: invokestatic  #218                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      40: invokeinterface #219,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      45: pop
      46: nop
      47: iinc          4, 1
      50: goto          14
      53: aload_3
      54: checkcast     #105                // class java/lang/Iterable
      57: invokestatic  #223                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
      60: checkcast     #105                // class java/lang/Iterable
      63: astore        4
      65: iconst_0
      66: istore        5
      68: aload         4
      70: invokeinterface #109,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      75: astore        6
      77: aload         6
      79: invokeinterface #115,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      84: ifeq          118
      87: aload         6
      89: invokeinterface #119,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      94: astore        7
      96: aload         7
      98: checkcast     #82                 // class java/lang/String
     101: astore        8
     103: iconst_0
     104: istore        9
     106: aload_1
     107: aload         8
     109: invokeinterface #205,  2          // InterfaceMethod java/util/Deque.push:(Ljava/lang/Object;)V
     114: nop
     115: goto          77
     118: nop
     119: return

  private static final java.util.List<java.util.Deque<java.lang.String>> toStacks(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #80                 // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #82                 // class java/lang/String
       8: astore_2
       9: aload_2
      10: iconst_0
      11: ldc           #229                // String \n
      13: aastore
      14: aload_2
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #90                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: iconst_1
      24: invokestatic  #233                // Method kotlin/collections/CollectionsKt.dropLast:(Ljava/util/List;I)Ljava/util/List;
      27: astore_1
      28: aload_1
      29: invokestatic  #237                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      32: checkcast     #82                 // class java/lang/String
      35: invokevirtual #240                // Method java/lang/String.length:()I
      38: iconst_1
      39: iadd
      40: iconst_4
      41: idiv
      42: istore_2
      43: iconst_0
      44: iload_2
      45: invokestatic  #246                // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      48: checkcast     #105                // class java/lang/Iterable
      51: astore        4
      53: iconst_0
      54: istore        5
      56: aload         4
      58: astore        6
      60: new           #145                // class java/util/ArrayList
      63: dup
      64: aload         4
      66: bipush        10
      68: invokestatic  #151                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      71: invokespecial #154                // Method java/util/ArrayList."<init>":(I)V
      74: checkcast     #156                // class java/util/Collection
      77: astore        7
      79: iconst_0
      80: istore        8
      82: aload         6
      84: invokeinterface #109,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      89: astore        9
      91: aload         9
      93: invokeinterface #115,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      98: ifeq          145
     101: aload         9
     103: checkcast     #248                // class kotlin/collections/IntIterator
     106: invokevirtual #251                // Method kotlin/collections/IntIterator.nextInt:()I
     109: istore        10
     111: aload         7
     113: iload         10
     115: istore        11
     117: astore        13
     119: iconst_0
     120: istore        12
     122: new           #145                // class java/util/ArrayList
     125: dup
     126: invokespecial #210                // Method java/util/ArrayList."<init>":()V
     129: checkcast     #92                 // class java/util/List
     132: nop
     133: aload         13
     135: swap
     136: invokeinterface #163,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     141: pop
     142: goto          91
     145: aload         7
     147: checkcast     #92                 // class java/util/List
     150: nop
     151: astore_3
     152: aload_1
     153: invokeinterface #252,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     158: astore        4
     160: aload         4
     162: invokeinterface #115,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     167: ifeq          245
     170: aload         4
     172: invokeinterface #119,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     177: checkcast     #82                 // class java/lang/String
     180: astore        5
     182: iconst_1
     183: istore        6
     185: iconst_0
     186: istore        7
     188: iload         6
     190: aload         5
     192: invokevirtual #240                // Method java/lang/String.length:()I
     195: if_icmpge     160
     198: aload         5
     200: iload         6
     202: invokevirtual #256                // Method java/lang/String.charAt:(I)C
     205: istore        8
     207: iload         8
     209: bipush        32
     211: if_icmpeq     236
     214: aload_3
     215: iload         7
     217: invokeinterface #96,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     222: checkcast     #92                 // class java/util/List
     225: iload         8
     227: invokestatic  #259                // Method java/lang/String.valueOf:(C)Ljava/lang/String;
     230: invokeinterface #219,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     235: pop
     236: iinc          7, 1
     239: iinc          6, 4
     242: goto          188
     245: aload_3
     246: checkcast     #105                // class java/lang/Iterable
     249: astore        4
     251: iconst_0
     252: istore        5
     254: aload         4
     256: astore        6
     258: new           #145                // class java/util/ArrayList
     261: dup
     262: aload         4
     264: bipush        10
     266: invokestatic  #151                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     269: invokespecial #154                // Method java/util/ArrayList."<init>":(I)V
     272: checkcast     #156                // class java/util/Collection
     275: astore        7
     277: iconst_0
     278: istore        8
     280: aload         6
     282: invokeinterface #109,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     287: astore        9
     289: aload         9
     291: invokeinterface #115,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     296: ifeq          339
     299: aload         9
     301: invokeinterface #119,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     306: astore        10
     308: aload         7
     310: aload         10
     312: checkcast     #92                 // class java/util/List
     315: astore        11
     317: astore        13
     319: iconst_0
     320: istore        12
     322: aload         11
     324: invokestatic  #263                // Method toDeque:(Ljava/util/List;)Ljava/util/Deque;
     327: aload         13
     329: swap
     330: invokeinterface #163,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     335: pop
     336: goto          289
     339: aload         7
     341: checkcast     #92                 // class java/util/List
     344: nop
     345: areturn

  private static final java.util.Deque<java.lang.String> toDeque(java.util.List<java.lang.String>);
    Code:
       0: new           #277                // class java/util/LinkedList
       3: dup
       4: aload_0
       5: checkcast     #156                // class java/util/Collection
       8: invokespecial #280                // Method java/util/LinkedList."<init>":(Ljava/util/Collection;)V
      11: checkcast     #127                // class java/util/Deque
      14: areturn

  private static final java.util.List<cz.wrent.advent.Move> toMoves(java.lang.String);
    Code:
       0: new           #284                // class kotlin/text/Regex
       3: dup
       4: ldc_w         #286                // String move (\\d+) from (\\d+) to (\\d+)
       7: invokespecial #289                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      10: astore_1
      11: aload_0
      12: checkcast     #80                 // class java/lang/CharSequence
      15: iconst_1
      16: anewarray     #82                 // class java/lang/String
      19: astore_2
      20: aload_2
      21: iconst_0
      22: ldc           #229                // String \n
      24: aastore
      25: aload_2
      26: iconst_0
      27: iconst_0
      28: bipush        6
      30: aconst_null
      31: invokestatic  #90                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      34: checkcast     #105                // class java/lang/Iterable
      37: astore_2
      38: nop
      39: iconst_0
      40: istore_3
      41: aload_2
      42: astore        4
      44: new           #145                // class java/util/ArrayList
      47: dup
      48: aload_2
      49: bipush        10
      51: invokestatic  #151                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      54: invokespecial #154                // Method java/util/ArrayList."<init>":(I)V
      57: checkcast     #156                // class java/util/Collection
      60: astore        5
      62: iconst_0
      63: istore        6
      65: aload         4
      67: invokeinterface #109,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      72: astore        7
      74: aload         7
      76: invokeinterface #115,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      81: ifeq          128
      84: aload         7
      86: invokeinterface #119,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      91: astore        8
      93: aload         5
      95: aload         8
      97: checkcast     #82                 // class java/lang/String
     100: astore        9
     102: astore        11
     104: iconst_0
     105: istore        10
     107: aload_1
     108: aload         9
     110: checkcast     #80                 // class java/lang/CharSequence
     113: invokevirtual #293                // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;
     116: aload         11
     118: swap
     119: invokeinterface #163,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     124: pop
     125: goto          74
     128: aload         5
     130: checkcast     #92                 // class java/util/List
     133: nop
     134: checkcast     #105                // class java/lang/Iterable
     137: astore_2
     138: nop
     139: iconst_0
     140: istore_3
     141: aload_2
     142: astore        4
     144: new           #145                // class java/util/ArrayList
     147: dup
     148: aload_2
     149: bipush        10
     151: invokestatic  #151                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     154: invokespecial #154                // Method java/util/ArrayList."<init>":(I)V
     157: checkcast     #156                // class java/util/Collection
     160: astore        5
     162: iconst_0
     163: istore        6
     165: aload         4
     167: invokeinterface #109,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     172: astore        7
     174: aload         7
     176: invokeinterface #115,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     181: ifeq          291
     184: aload         7
     186: invokeinterface #119,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     191: astore        8
     193: aload         5
     195: aload         8
     197: checkcast     #295                // class kotlin/text/MatchResult
     200: astore        9
     202: astore        11
     204: iconst_0
     205: istore        10
     207: new           #121                // class cz/wrent/advent/Move
     210: dup
     211: aload         9
     213: dup
     214: invokestatic  #298                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     217: invokeinterface #302,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     222: iconst_1
     223: invokeinterface #96,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     228: checkcast     #82                 // class java/lang/String
     231: invokestatic  #306                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     234: aload         9
     236: invokeinterface #302,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     241: iconst_2
     242: invokeinterface #96,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     247: checkcast     #82                 // class java/lang/String
     250: invokestatic  #306                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     253: iconst_1
     254: isub
     255: aload         9
     257: invokeinterface #302,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     262: iconst_3
     263: invokeinterface #96,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     268: checkcast     #82                 // class java/lang/String
     271: invokestatic  #306                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     274: iconst_1
     275: isub
     276: invokespecial #309                // Method cz/wrent/advent/Move."<init>":(III)V
     279: aload         11
     281: swap
     282: invokeinterface #163,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     287: pop
     288: goto          174
     291: aload         5
     293: checkcast     #92                 // class java/util/List
     296: nop
     297: areturn

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

  private static final kotlin.Unit partOne$lambda$0(java.util.Deque, java.util.Deque, int);
    Code:
       0: aload_0
       1: ldc_w         #322                // String x
       4: invokestatic  #325                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: ldc_w         #327                // String y
      11: invokestatic  #325                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      14: aload_0
      15: aload_1
      16: iload_2
      17: invokestatic  #329                // Method moveCrates9000:(Ljava/util/Deque;Ljava/util/Deque;I)V
      20: getstatic     #335                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      23: areturn

  private static final kotlin.Unit partTwo$lambda$1(java.util.Deque, java.util.Deque, int);
    Code:
       0: aload_0
       1: ldc_w         #322                // String x
       4: invokestatic  #325                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: ldc_w         #327                // String y
      11: invokestatic  #325                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      14: aload_0
      15: aload_1
      16: iload_2
      17: invokestatic  #338                // Method moveCrates9001:(Ljava/util/Deque;Ljava/util/Deque;I)V
      20: getstatic     #335                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      23: areturn
}