def update_bars():
    for bar in bars:
        old_length = bar.count
        length = random.randint(MIN_BAR_LENGTH, MAX_BAR_LENGTH)
        bar.resize(length)
        vertices = bar.vertices

        # Update new vertices (overwrite old degenerate)
        for i in range((old_length - 1) * 2, length * 2):
            if i & 1: # y
                vertices[i] = BAR_SEGMENT_HEIGHT * (i // 4)
            else: # x
                vertices[i] = vertices[i - 4]

        # Update top degenerate (first degenerate is never modified)
        vertices[-2:] = vertices[-4:-2]

        # Update colors
        if length > old_length:
            bar.colors[old_length*3:length*3] = \
                bar.colors[:3] * (old_length - length)
dataset/ETHPy150Open ardekantur/pyglet/experimental/buffer/bars.py/update_bars/swapped operands of `-`