One row, two directions
transcript
A drive is six minutes long. Songs last two, three and four minutes. A song may play once, or repeat. One row of numbers answers both.
Keep one row. Update it for the song of two. Go upwards. Cell two reads cell zero. Cell four reads cell two. That cell changed a step ago. So the song is used twice. Upwards lets a song repeat.
Now go downwards, starting from six. Cell four reads cell two. It is not changed yet. Only cell two reads cell zero. It becomes one. Downwards counts a song once.
Upwards reads cells that include the song. So the song can repeat. Downwards reads cells from before it. So the song counts once.
Downwards, every cell reads a cell from before the song. Upwards, a cell reads a cell the song already changed. The update line is the same in both directions.
Ask one thing: may an item repeat? Yes means upwards. No means downwards. Full breakdown in the lecture.