def substitute_half_a_bitvector(pattern: str, args: 'List[int]') ->int:
    """
    Helper function for `substitute_bitvector`. Takes an 8-bit pattern and returns a
    single byte.
    """
    ret = 0
    for shift, pattern_bit in enumerate(reversed(pattern)):
        if pattern_bit == '0':
            real_bit = 0
        elif pattern_bit == '1':
            real_bit = 1
        else:
            index = ord(pattern_bit.lower()) - ord('a')
            real_bit = args[index] & 1
            args[index] >>= 1
        ret += real_bit << shift
    return ret
