Ejemplo n.º 1
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        aunt = 'Sue {0}: {1}: {2}, {3}: {4}, {5}: {6}'
        input1 = (aunt.format(1, 'akitas', 0, 'cars', 2, 'cats', 7), )
        input2 = (
            aunt.format(1, 'akitas', 0, 'cars', 2, 'cats', 8),
            aunt.format(2, 'children', 3, 'goldfish', 5, 'perfumes', 1),
        )
        input3 = (
            aunt.format(1, 'cats', 8, 'goldfish', 4, 'pomeranians', 2),
            aunt.format(2, 'akitas', 10, 'perfumes', 10, 'children', 5),
            aunt.format(3, 'cars', 2, 'pomeranians', 3, 'vizslas', 0),
            aunt.format(4, 'goldfish', 5, 'children', 8, 'perfumes', 3),
            aunt.format(5, 'vizslas', 2, 'akitas', 7, 'perfumes', 6),
            aunt.format(6, 'vizslas', 0, 'akitas', 1, 'perfumes', 2),
            aunt.format(7, 'perfumes', 8, 'cars', 4, 'goldfish', 10),
            aunt.format(8, 'perfumes', 7, 'children', 2, 'cats', 1),
            aunt.format(9, 'pomeranians', 3, 'goldfish', 10, 'trees', 10),
            aunt.format(10, 'akitas', 7, 'trees', 8, 'pomeranians', 4),
        )
        test_cases = (
            solver.TestCase('\n'.join(input1), 'Sue 1', 'Sue 1'),
            solver.TestCase('\n'.join(input2), 'Sue 2', 'Sue 1'),
            solver.TestCase('\n'.join(input3), 'Sue 3', 'Sue 1'),
        )
        for test_case in test_cases:
            self._run_test_case(test_case)
Ejemplo n.º 2
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        input1 = (
            'Alice would gain 54 happiness units by sitting next to Bob.',
            'Alice would lose 79 happiness units by sitting next to Carol.',
            'Alice would lose 2 happiness units by sitting next to David.',
            'Bob would gain 83 happiness units by sitting next to Alice.',
            'Bob would lose 7 happiness units by sitting next to Carol.',
            'Bob would lose 63 happiness units by sitting next to David.',
            'Carol would lose 62 happiness units by sitting next to Alice.',
            'Carol would gain 60 happiness units by sitting next to Bob.',
            'Carol would gain 55 happiness units by sitting next to David.',
            'David would gain 46 happiness units by sitting next to Alice.',
            'David would lose 7 happiness units by sitting next to Bob.',
            'David would gain 41 happiness units by sitting next to Carol.',
        )
        input2 = input1[0:2] + input1[3:5] + input1[6:8]
        input3 = (input1[0], input1[1].replace('Carol', 'Bob'))
        test_cases = (
            solver.TestCase('\n'.join(input1), 330, 286),
            solver.TestCase('\n'.join(input2), 49, 190),
            solver.TestCase('\n'.join(input3), -25, -25),
        )
        for test_case in test_cases:
            self._run_test_case(test_case)
Ejemplo n.º 3
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        test_input1 = 'inc a'
        test_input2 = 'inc b'
        self._run_test_case(solver.TestCase(test_input1, 0, 0))
        self._run_test_case(solver.TestCase(test_input2, 1, 1))
Ejemplo n.º 4
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        test_input1 = '60'
        test_input2 = '120'
        test_input3 = '150'
        self._run_test_case(solver.TestCase(test_input1, 4, 4))
        self._run_test_case(solver.TestCase(test_input2, 6, 6))
        self._run_test_case(solver.TestCase(test_input3, 8, 8))
Ejemplo n.º 5
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        test_cases = (
            solver.TestCase('abcdef', 609043, 6742839),
            solver.TestCase('pqrstuv', 1048970, 5714438),
        )
        for test_case in test_cases:
            self._run_test_case(test_case)
Ejemplo n.º 6
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        test_cases = (
            solver.TestCase('2x3x4', 58, 34),
            solver.TestCase('1x1x10', 43, 14),
        )
        for test_case in test_cases:
            self._run_test_case(test_case)
Ejemplo n.º 7
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        test_cases = (
            solver.TestCase('>', 2, 2),
            solver.TestCase('^v', 2, 3),
            solver.TestCase('^>v<', 4, 3),
            solver.TestCase('^v^v^v^v^v', 2, 11),
        )
        for test_case in test_cases:
            self._run_test_case(test_case)
Ejemplo n.º 8
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        test_input1 = '\n'.join(('Hit Points: 1', 'Damage: 100'))
        test_input2 = '\n'.join(('Hit Points: 5', 'Damage: 49'))
        test_input3 = '\n'.join(('Hit Points: 50', 'Damage: 1'))
        test_input4 = '\n'.join(('Hit Points: 50', 'Damage: 8'))
        self._run_test_case(solver.TestCase(test_input1, 53, 53))
        self._run_test_case(solver.TestCase(test_input2, 106, 126))
        self._run_test_case(solver.TestCase(test_input3, 787, 787))
        self._run_test_case(solver.TestCase(test_input4, 787, 900))
Ejemplo n.º 9
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        test_cases = (
            solver.TestCase('1', 82350, 1166642),
            solver.TestCase('2', 95798, 1355550),
            solver.TestCase('3', 95798, 1355550),
            solver.TestCase('11', 107312, 1520986),
            solver.TestCase('111', 149642, 2121256),
        )
        for test_case in test_cases:
            self._run_test_case(test_case)
Ejemplo n.º 10
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        test_input = '\n'.join(('120', '90', '60', '30', '30'))
        self._run_test_case(solver.TestCase(test_input, 4, 3))
Ejemplo n.º 11
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        input1 = '\n'.join((
            'e => H',
            'e => O',
            'H => HO',
            'H => OH',
            'O => HH',
            '',
            'HOH',
        ))
        input2 = input1.replace('HOH', 'HOHOHO')
        self._run_test_case(solver.TestCase(input1, 4, 3))
        self._run_test_case(solver.TestCase(input2, 7, 6))
Ejemplo n.º 12
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        input_range = tuple(range(1, 6)) + tuple(range(7, 12))
        test_input = '\n'.join(str(num) for num in input_range)
        self._run_test_case(solver.TestCase(test_input, 99, 44))
Ejemplo n.º 13
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        item = '{0}: capacity {1}, durability {2}, flavor {3}'
        item += ', texture {4}, calories {5}'
        input1 = (
            item.format('Butterscotch', -1, -2, 6, 3, 8),
            item.format('Cinnamon', 2, 3, -2, -1, 3),
        )
        input2 = input1 + (item.format('Sugar', 1, 1, 1, 1, 1), )
        input3 = input1 + (item.format('Boogers', 2, 2, 2, 2, 2), )
        test_cases = (
            solver.TestCase('\n'.join(input1), 62842880, 57600000),
            solver.TestCase('\n'.join(input2), 105187500, 65014560),
            solver.TestCase('\n'.join(input3), 1600000000, 130975000),
        )
        for test_case in test_cases:
            self._run_test_case(test_case)
Ejemplo n.º 14
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        input1 = '\n'.join((
            'London to Dublin = 464',
            'London to Belfast = 518',
            'Dublin to Belfast = 141',
        ))
        test_cases = (solver.TestCase(input1, 605, 982),)
        for test_case in test_cases:
            self._run_test_case(test_case)
Ejemplo n.º 15
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        test_input1 = '\n'.join((
            'Hit Points: 1',
            'Damage: 1000',
            'Armor: 1',
        ))
        test_input2 = '\n'.join((
            'Hit Points: 1',
            'Damage: 1',
            'Armor: 1000',
        ))
        test_input3 = '\n'.join((
            'Hit Points: 1000',
            'Damage: 1000',
            'Armor: 1000',
        ))
        test_input4 = '\n'.join((
            'Hit Points: 200',
            'Damage: 0',
            'Armor: 3',
        ))
        test_input5 = '\n'.join((
            'Hit Points: 150',
            'Damage: 7',
            'Armor: 2',
        ))
        self._run_test_case(solver.TestCase(test_input1, 8, -1))
        self._run_test_case(solver.TestCase(test_input2, 8, -1))
        self._run_test_case(solver.TestCase(test_input3, sys.maxsize, 356))
        self._run_test_case(solver.TestCase(test_input4, 10, 230))
        self._run_test_case(solver.TestCase(test_input5, 101, 189))
Ejemplo n.º 16
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        test_input = '\n'.join((
            '.#.#.#',
            '...##.',
            '#....#',
            '..#...',
            '#.#..#',
            '####..',
        ))
        self._run_test_case(solver.TestCase(test_input, 4, 7))
Ejemplo n.º 17
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        test_input1 = 'row 2, column 1'
        test_input2 = 'row 6, column 1'
        test_input3 = 'row 6, column 2'
        test_input4 = 'row 6, column 3'
        test_input5 = 'row 6, column 4'
        test_input6 = 'row 6, column 5'
        test_input7 = 'row 6, column 6'
        self._run_test_case(solver.TestCase(test_input1, 31916031, None))
        self._run_test_case(solver.TestCase(test_input2, 33071741, None))
        self._run_test_case(solver.TestCase(test_input3, 6796745, None))
        self._run_test_case(solver.TestCase(test_input4, 25397450, None))
        self._run_test_case(solver.TestCase(test_input5, 24659492, None))
        self._run_test_case(solver.TestCase(test_input6, 1534922, None))
        self._run_test_case(solver.TestCase(test_input7, 27995004, None))
Ejemplo n.º 18
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        input1 = 'turn on 0,0 through 999,999'
        input2 = 'toggle 0,0 through 999,0'
        input3 = '\n'.join((input1, input2))
        input4 = 'turn off 499,499 through 500,500'
        input5 = '\n'.join((input1, input4))
        input6 = 'turn on 0,0 through 0,0'
        input7 = 'toggle 0,0 through 999,999'
        test_cases = (
            solver.TestCase(input1, '1000000', '1000000'),
            solver.TestCase(input2, '1000', '2000'),
            solver.TestCase(input3, '999000', '1002000'),
            solver.TestCase(input4, '0', '0'),
            solver.TestCase(input5, '999996', '999996'),
            solver.TestCase(input6, '1', '1'),
            solver.TestCase(input7, '1000000', '2000000'),
        )
        for test_case in test_cases:
            self._run_test_case(test_case)
Ejemplo n.º 19
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        input1 = ('123 -> a', )
        input2 = ('123 -> a', '321 -> a')
        input3 = ('123 -> b', '456 -> c', 'b AND c -> a')
        input4 = ('123 -> b', '456 -> c', 'b OR c -> a')
        input5 = ('123 -> b', 'NOT b -> a')
        input6 = ('123 -> b', 'b LSHIFT 2 -> a')
        input7 = ('123 -> b', 'b RSHIFT 2 -> a')
        test_cases = (
            solver.TestCase('\n'.join(input1), 123, 123),
            solver.TestCase('\n'.join(input2), 321, 321),
            solver.TestCase('\n'.join(input3), 72, 72),
            solver.TestCase('\n'.join(input4), 507, 507),
            solver.TestCase('\n'.join(input5), 65412, 123),
            solver.TestCase('\n'.join(input6), 492, 1968),
            solver.TestCase('\n'.join(input7), 30, 7),
        )
        for test_case in test_cases:
            self._run_test_case(test_case)
Ejemplo n.º 20
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        test_cases = (
            solver.TestCase('[1,2,3]', 6, 6),
            solver.TestCase('{"a":2,"b":4}', 6, 6),
            solver.TestCase('[[[3]]]', 3, 3),
            solver.TestCase('{"a":{"b":4},"c":-1}', 3, 3),
            solver.TestCase('{"a":[-1,1]}', 0, 0),
            solver.TestCase('[-1,{"a":1}]', 0, 0),
            solver.TestCase('[]', 0, 0),
            solver.TestCase('{}', 0, 0),
            solver.TestCase('[1,{"c":"red","b":2},3]', 6, 4),
            solver.TestCase('{"d":"red","e":[1,2,3,4],"f":5}', 15, 0),
            solver.TestCase('[1,"red",5]', 6, 6),
            solver.TestCase('["a", {"red":1}]', 1, 1),  # "red" keys are ok
        )
        for test_case in test_cases:
            self._run_test_case(test_case)
Ejemplo n.º 21
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        test_cases = (
            solver.TestCase('ugknbfddgicrmopn', 1, 0),
            solver.TestCase('aaa', 1, 0),
            solver.TestCase('jchzalrnumimnmhp', 0, 0),
            solver.TestCase('haegwjzuvuyypxyu', 0, 0),
            solver.TestCase('dvszwmarrgswjxmb', 0, 0),
            solver.TestCase('xyxy', 0, 1),
            solver.TestCase('aabcdefgaa', 0, 0),
            solver.TestCase('qjhvhtzxzqqjkmpb', 0, 1),
            solver.TestCase('xxyxx', 0, 1),
            solver.TestCase('uurcxstgmygtbstg', 0, 0),
            solver.TestCase('ieodomkazucvgmuy', 0, 0),
            solver.TestCase('aaccacc', 1, 1),
        )
        for test_case in test_cases:
            self._run_test_case(test_case)
Ejemplo n.º 22
0
    def run_test_cases(self):
        """Runs a series of inputs and compares against expected outputs

        Args: None
        Returns: None
        """
        test_cases = (
            solver.TestCase('(())', 0, 0),
            solver.TestCase('()()', 0, 0),
            solver.TestCase('(((', 3, 0),
            solver.TestCase('(()(()(', 3, 0),
            solver.TestCase('))(((((', 3, 1),
            solver.TestCase('())', -1, 3),
            solver.TestCase('))(', -1, 1),
            solver.TestCase(')))', -3, 1),
            solver.TestCase(')())())', -3, 1),
            solver.TestCase(')', -1, 1),
            solver.TestCase('()())', -1, 5),
        )
        for test_case in test_cases:
            self._run_test_case(test_case)