text into pieces whose length is capped by width. Every piece gets a tag <a/b> appended at its end, where b is the total number of pieces and a is the piece's number, from 1 to b.
The rules:
- every piece, tag included, is exactly width characters long; only the last piece may be shorter (but never longer than width);
- stripping the tags and joining the pieces in order gives back the original text;
- there must be as few pieces as possible.
Return the pieces in order. If the text cannot be cut under these rules, return an empty list.text='see you at noon', width=8 → ['see<1/5>', ' yo<2/5>', 'u a<3/5>', 't n<4/5>', 'oon<5/5>']
Each piece holds 3 characters of text plus a tag like <1/5>, so 15 characters make exactly 5 pieces. Four pieces would fit only 12 characters.
text='hi', width=7 → ['hi<1/1>']
The whole text fits in a single piece: hi<1/1>, exactly 7 long.
text='hello', width=5 → []
The tag <1/k> alone takes 5 characters or more, leaving no room for text, so no split exists.
text consists of lowercase English letters and spacestext='see you at noon', width=8
['see<1/5>', ' yo<2/5>', 'u a<3/5>', 't n<4/5>', 'oon<5/5>']
Run checks the first 3 tests in your browser. Submit checks all 72 tests on the server, hidden ones included.