lines lines, each width characters wide. The same phrase, the word list words, is shown on it over and over: in order, and after the last word the phrase starts again from the first.
The rules are:
- a word cannot be split across lines; if it does not fit in what is left of a line, it moves to the next one;
- neighbouring words on one line are separated by exactly one space;
- the word order never changes.
How many times is the phrase shown in full?words=["sale", "today"], lines=3, width=10 → 3
The board lines are "sale today", "sale today", "sale today": the whole phrase runs 3 times.
words=["go", "north", "x"], lines=4, width=7 → 2
Lines: "go", "north x", "go", "north x" (north does not fit after go: 2 + 1 + 5 = 8 > 7). The phrase runs 2 times.
words=["welcome"], lines=5, width=6 → 0
The word is longer than a line, so it never fits.
words=["sale", "today"], lines=3, width=10
3
Run checks the first 3 tests in your browser. Submit checks all 101 tests on the server, hidden ones included.