History and pages (Real-time Chat)
Messages get ids (1, 2… across all rooms), shown at the start of every message line: 3 [dev] ann: hi - …. history <room [before=<id] [limit=<n] (limit default 3) prints history <room: <shown of <matching and the newest messages before that id, oldest first, as <id <user: <text, then more: before=<id if older ones remain.
Input: As before.
Output: As before.
Difficulty: Medium. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.
Hint
- Filter the room’s messages by id, then take the last limit.