def jump(inst_ptr, program, direction):
    """Jump the instruction pointer in the program until matching bracket"""
    count = direction
    while count != 0:
        inst_ptr += direction
        char = program[inst_ptr]
        if char == '[':
            count += 1
        elif char == ']':
            count -= 1
        else:
            pass
    return inst_ptr