11/28
Part 3 of 6 · The whole pageLearn and do
Go down the rows with one set
Level 1 is place_row in a loop, with one shown set for the whole page.
The order of the rows matters. The top row is placed first, so it keeps its best titles, and each row below gets what's left. That's the right priority for a homepage: the rows near the top are the ones every viewer sees.
Here is the page from the start of the lesson, row by row:
before row 0ABCrow 1BADErow 2CFA
after row 0ABCrow 1DEBArow 2CFA
Row 1 shows D and E on the screen, and B and A move past it. The first two columns are the screen.
Two things a test should check, because both are easy to break:
shownmust be made once. A new set per row only stops a row repeating itself. A set holding only the row above misses rows two apart.- The input must not change. The rows came from a ranker, and some other code may read them after you.
place_rowbuilds new lists, so return those and never write intorows.
In the editor, place_row is given. Write dedup_homepage(rows, width) with one shown set for the page.