Files
adventofcode/3/test.py
Jesse Simpson cd541302a5 init
2023-12-03 12:07:26 -05:00

275 lines
5.7 KiB
Python

from script import get_sum
def test_sum():
inputtext = """
467..114..
...*......
..35..633.
......#...
617*......
.....+.58.
..592.....
......755.
...$.*....
.664.598..
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 4361
def test_corner1():
inputtext = """
467..114..
.*........
..........
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 467
def test_corner2():
inputtext = """
467..11444
........*.
..........
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 11444
def test_corner3():
inputtext = """
467..11444
..........
.........$
.........1
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 1
def test_corner4():
inputtext = """
467..11444
..........
&.........
1...1....1
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 1
def test_numbers_dont_duplicate():
inputtext = """
467..11444
..........
&.........
1&..1....1
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 1
def test_diagonal_1():
inputtext = """
..........
.....4....
....*.....
..........
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 4
def test_diagonal_2():
inputtext = """
..........
.....4....
......*...
..........
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 4
def test_diagonal_3():
inputtext = """
......*...
.....4....
..........
..........
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 4
def test_diagonal_4():
inputtext = """
....*.....
.....4....
..........
..........
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 4
def test_right():
inputtext = """
..........
.....4&...
..........
..........
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 4
def test_left():
inputtext = """
..........
....&4....
..........
..........
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 4
def test_up():
inputtext = """
.....*....
.....4....
..........
..........
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 4
def test_down():
inputtext = """
..........
.....4....
.....&....
..........
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 4
def test_symbol_right_end():
inputtext = """
..........
........4$
..........
..........
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 4
def test_left_end_right_symbol():
inputtext = """
..........
617*......
..........
..........
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 617
def test_right_end_left_symbol():
inputtext = """
..........
.......&51
..........
..........
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 51
def test_right_end_left_symbol_by_2():
inputtext = """
..........
......&.51
..........
..........
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 0
def test_right_end_bottom_symbol():
inputtext = """
..........
........51
........&.
..........
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 51
def test_right_end_diagonal_symbol():
inputtext = """
..........
........51
.......&..
..........
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 51
def test_master_of_all_for_elements():
inputtext = """
..........
....=.....
.../1&....
....\\.....
..........
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 1
def test_number_below_number():
inputtext = """
..........
..........
....1.....
....1.....
..........
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 0
def test_corner_corner1():
inputtext = """
1........1
.&......&.
..........
.&......&.
1........1
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 4
def test_corner_corner1():
inputtext = """
1111111111
1111111111
1111111111
1111111111
1111111111
"""
processed_input = inputtext.strip()
processed_input_split = processed_input.split()
assert get_sum(processed_input_split) == 0