OpenAIOA #4
ChatApp with Bots
Estimated MediumStatement and editorial — judging is being prepared
Topics (AI-labelled)IteratorsSimulation
Implement a small in-memory chat application that supports multiple channels and extensible bots. Each channel maintains its own message history and any bot state associated with that channel. The design should allow new bot types to be added without modifying the core chat logic. For this problem, process a list of commands:
REGISTER botName ...: register one or more botsSEND channelId userId text...: append the user message to that channel and then append any bot replies triggered by the messagePRINT channelId: emit the full message history for that channel in order Assume two example bots exist:EchoBotreplies with the same text it receives, andHelpBotreplies with a help string when the message text ishelp. Function Description Complete the functionrunChatAppCommandsin the editor below.runChatAppCommandshas the following parameter:String[] commands: the commands to process in order ReturnsString[]: the lines produced by allPRINTcommands, in order.
Constraints
1 ≤ commands.length ≤ 10⁵- The number of channels is at most
10⁴. - The number of registered bots is at most
10². - Commands arrive sequentially; no concurrency handling is required.
Editorial
Loading solution…