Newsletter page layouts
Your task
A newsletter is laid out by cutting its article list into consecutive pages. article_words[i] is the word count of article i, the articles keep the order they are given in, and a page holds one or more consecutive articles: at most max_articles of them, and their word counts must sum to at most page_limit. Return every valid layout as a string, namely the number of articles on each page joined by hyphens, so "2-1-3" puts two articles on the first page, one on the second and three on the third. Produce the layouts by growing the first page from one article upward and recursing on what is left, so every layout beginning with a one article page comes before any layout beginning with a two article page. An empty article list returns an empty list. There are at most 9 articles and every word count is positive.
Examples
split_newsletter_pages(article_words: list[int], page_limit: int, max_articles: int) -> list[str]split_newsletter_pages([120, 80, 200], 300, 2)["1-1-1", "1-2", "2-1"]split_newsletter_pages([100, 100], 250, 2)["1-1", "2"]split_newsletter_pages([500], 400, 3)[]