<gh_stars>1-10
import unittest

from day5 import run, parse


class TestDay5(unittest.TestCase):
    def test_examples(self):
        self.assertEqual(next(run(parse("99"), 1), None), None)

        self.assertEqual(next(run(parse("3,0,4,0,99"), 1)), 1)
        self.assertEqual(next(run(parse("3,0,4,0,99"), 28)), 28)

        self.assertEqual(
            next(run(parse("3,12,6,12,15,1,13,14,13,4,13,99,-1,0,1,9"), 0)), 0
        )
        self.assertEqual(
            next(run(parse("3,12,6,12,15,1,13,14,13,4,13,99,-1,0,1,9"), 1)), 1
        )
        self.assertEqual(
            next(run(parse("3,12,6,12,15,1,13,14,13,4,13,99,-1,0,1,9"), 7)), 1
        )

        self.assertEqual(next(run(parse("3,3,1105,-1,9,1101,0,0,12,4,12,99,1"), 0)), 0)
        self.assertEqual(next(run(parse("3,3,1105,-1,9,1101,0,0,12,4,12,99,1"), 1)), 1)
        self.assertEqual(next(run(parse("3,3,1105,-1,9,1101,0,0,12,4,12,99,1"), 18)), 1)

        self.assertEqual(
            next(
                run(
                    parse(
                        "3,21,1008,21,8,20,1005,20,22,107,8,21,20,1006,20,31,"
                        "1106,0,36,98,0,0,1002,21,125,20,4,20,1105,1,46,104,"
                        "999,1105,1,46,1101,1000,1,20,4,20,1105,1,46,98,99"
                    ),
                    1,
                )
            ),
            999,
        )
        self.assertEqual(
            next(
                run(
                    parse(
                        "3,21,1008,21,8,20,1005,20,22,107,8,21,20,1006,20,31,"
                        "1106,0,36,98,0,0,1002,21,125,20,4,20,1105,1,46,104,"
                        "999,1105,1,46,1101,1000,1,20,4,20,1105,1,46,98,99"
                    ),
                    7,
                )
            ),
            999,
        )
        self.assertEqual(
            next(
                run(
                    parse(
                        "3,21,1008,21,8,20,1005,20,22,107,8,21,20,1006,20,31,"
                        "1106,0,36,98,0,0,1002,21,125,20,4,20,1105,1,46,104,"
                        "999,1105,1,46,1101,1000,1,20,4,20,1105,1,46,98,99"
                    ),
                    8,
                )
            ),
            1000,
        )
        self.assertEqual(
            next(
                run(
                    parse(
                        "3,21,1008,21,8,20,1005,20,22,107,8,21,20,1006,20,31,"
                        "1106,0,36,98,0,0,1002,21,125,20,4,20,1105,1,46,104,"
                        "999,1105,1,46,1101,1000,1,20,4,20,1105,1,46,98,99"
                    ),
                    9,
                )
            ),
            1001,
        )

import unittest

from day5 import run, parse


class TestDay5(unittest.TestCase):
    def test_examples(self):
        self.assertEqual(next(run(parse("99"), 1), None), None)

        self.assertEqual(next(run(parse("3,0,4,0,99"), 1)), 1)
        self.assertEqual(next(run(parse("3,0,4,0,99"), 28)), 28)

        self.assertEqual(
            next(run(parse("3,12,6,12,15,1,13,14,13,4,13,99,-1,0,1,9"), 0)), 0
        )
        self.assertEqual(
            next(run(parse("3,12,6,12,15,1,13,14,13,4,13,99,-1,0,1,9"), 1)), 1
        )
        self.assertEqual(
            next(run(parse("3,12,6,12,15,1,13,14,13,4,13,99,-1,0,1,9"), 7)), 1
        )

        self.assertEqual(next(run(parse("3,3,1105,-1,9,1101,0,0,12,4,12,99,1"), 0)), 0)
        self.assertEqual(next(run(parse("3,3,1105,-1,9,1101,0,0,12,4,12,99,1"), 1)), 1)
        self.assertEqual(next(run(parse("3,3,1105,-1,9,1101,0,0,12,4,12,99,1"), 18)), 1)

        self.assertEqual(
            next(
                run(
                    parse(
                        "3,21,1008,21,8,20,1005,20,22,107,8,21,20,1006,20,31,"
                        "1106,0,36,98,0,0,1002,21,125,20,4,20,1105,1,46,104,"
                        "999,1105,1,46,1101,1000,1,20,4,20,1105,1,46,98,99"
                    ),
                    1,
                )
            ),
            999,
        )
        self.assertEqual(
            next(
                run(
                    parse(
                        "3,21,1008,21,8,20,1005,20,22,107,8,21,20,1006,20,31,"
                        "1106,0,36,98,0,0,1002,21,125,20,4,20,1105,1,46,104,"
                        "999,1105,1,46,1101,1000,1,20,4,20,1105,1,46,98,99"
                    ),
                    7,
                )
            ),
            999,
        )
        self.assertEqual(
            next(
                run(
                    parse(
                        "3,21,1008,21,8,20,1005,20,22,107,8,21,20,1006,20,31,"
                        "1106,0,36,98,0,0,1002,21,125,20,4,20,1105,1,46,104,"
                        "999,1105,1,46,1101,1000,1,20,4,20,1105,1,46,98,99"
                    ),
                    8,
                )
            ),
            1000,
        )
        self.assertEqual(
            next(
                run(
                    parse(
                        "3,21,1008,21,8,20,1005,20,22,107,8,21,20,1006,20,31,"
                        "1106,0,36,98,0,0,1002,21,125,20,4,20,1105,1,46,104,"
                        "999,1105,1,46,1101,1000,1,20,4,20,1105,1,46,98,99"
                    ),
                    9,
                )
            ),
            1001,
        )