""" day_02_01.py """

# usage: python3 day_02_01.py


def get(filename):
    """ contents of filename """
    with open(filename, 'r', encoding='utf-8') as infile:
        data = infile.read().strip()

    return data


def test(data, solution):
    """ testing """
    output = solve(data)
    assert output == solution


def solve(data):
    """ solve the puzzle """
    rows = [list(map(int, row.split())) for row in data.split('\n')]
    return sum(map(max, rows)) - sum(map(min, rows))


if __name__ == '__main__':
    test(get('example01'), 18)

    puzzle = get('input')
    x = solve(puzzle)

    print(x)
