def flip_bit(v: int, d: int, i: int):
    """ Given an integer v (with d binary bits), flip its value on the i-th largest dimension (zero-based). """
    fmt = f'0{d}b'  # 'b' for binary numbers, 'd' for total amount of bits, '0' for adding 0s to fill the prefix
    vb = list(format(v, fmt))
    mapping = {
        '0': '1',
        '1': '0'
    }
    vb[i] = mapping[vb[i]]
    vb = ''.join(vb)
    return int(vb, 2)