def decode_outputs_from_signals(signals_and_outputs) -> int:
    """
    Use signals to decode seven segment wiring and calculate puzzle output

    Args:
        signals_and_outputs (list): input signals and outputs of seven segment displays
    Returns:
        sum of all decoded output numbers
    """

    numbers = ['', '', '', '', '', '', '', '', 'abcdefg', '']
    count = 0
    for pattern in signals_and_outputs:
        output_row = ''

        # 1s, 4s, 7s, and 8s can be determined by length of strings
        for signal in pattern[0].split(" "):
            if len(signal) == 2:
                numbers[1] = signal
            elif len(signal) == 3:
                numbers[7] = signal
            elif len(signal) == 4:
                numbers[4] = signal

        # 0s, 2s, 3s, 5s, 6s, and 9s can be determined by comparing known values
        for signal in pattern[0].split(" "):
            if len(signal) == 5:
                if sum(i in signal for i in numbers[4]) == 2:
                    numbers[2] = signal
                elif sum(i in signal for i in numbers[7]) == 3:
                    numbers[3] = signal
                else:
                    numbers[5] = signal

            if len(signal) == 6:
                if sum(i in signal for i in numbers[1]) == 2 and sum(i in signal for i in numbers[4]) == 3:
                    numbers[0] = signal
                elif sum(i in signal for i in numbers[1]) == 1:
                    numbers[6] = signal
                else:
                    numbers[9] = signal

        # decode and count up outputs
        for output in pattern[1].split(" "):
            for num in range(len(numbers)):
                if all(i in output for i in numbers[num]) and len(output) == len(numbers[num]):
                    output_row = output_row + str(num)
        count += int(output_row)

    return count