~macaptain/advent-of-code

21976ab8106e34f00afacb80e4ea25cb602b5329 — Michael Captain 1 year, 7 months ago ce0185c
Use check instead of assert in day 17 solution
1 files changed, 6 insertions(+), 6 deletions(-)

M src/main/advent2019/Day17.kt
M src/main/advent2019/Day17.kt => src/main/advent2019/Day17.kt +6 -6
@@ 29,7 29,7 @@ fun alignmentParameters(camera: List<String>): Int {

fun wakeVacuumRobotProgram(program: String): String {
    val xs = program.toMutableList()
    assert(xs[0] == '1')
    check(xs[0] == '1')
    xs[0] = '2'
    return xs.joinToString("")
}


@@ 204,7 204,7 @@ fun solve17b(program: String): Int {
    val output1 = computer.outputs().map { it.toInt() }.toList()
    val camera1 = asciiOutput(output1).dropLast(1)
    var prompt = asciiOutput(output1).last()
    assert(prompt == "Main:")
    check(prompt == "Main:")
    val instructions = cleaningInstructions(camera1)
    val compressedInstructions = compressInstructions(instructions)



@@ 213,28 213,28 @@ fun solve17b(program: String): Int {
    computer.run()
    val output2 = computer.outputs().map { it.toInt() }.toList()
    prompt = asciiOutput(output2).last()
    assert(prompt == "Function A:")
    check(prompt == "Function A:")

    val aAscii = compressedInstructions.aAscii()
    aAscii.forEach { computer.input(it) }
    computer.run()
    val output3 = computer.outputs().map { it.toInt() }.toList()
    prompt = asciiOutput(output3).last()
    assert(prompt == "Function B:")
    check(prompt == "Function B:")

    val bAscii = compressedInstructions.bAscii()
    bAscii.forEach { computer.input(it) }
    computer.run()
    val output4 = computer.outputs().map { it.toInt() }.toList()
    prompt = asciiOutput(output4).last()
    assert(prompt == "Function C:")
    check(prompt == "Function C:")

    val cAscii = compressedInstructions.cAscii()
    cAscii.forEach { computer.input(it) }
    computer.run()
    val output5 = computer.outputs().map { it.toInt() }.toList()
    prompt = asciiOutput(output5).last()
    assert(prompt == "Continuous video feed?")
    check(prompt == "Continuous video feed?")

    computer.input('n'.code)
    computer.input('\n'.code)