def decode_output(digits, outputs, full=False):
    """Decode output, either by returning frequency of unique digits
    or the full 4 digit number."""
    if full:
        value = ''
        for o in outputs:
            value += str(digits.index(o))
        return int(value)
    
    is_unique = [o in [digits[i] for i in [1, 4, 7, 8]] for o in outputs]
    return is_unique.count(True)