Ran into a new question.
/* Your task is to build a simple logging tool for an application. The core requirement is that the Logger should support several different log handlers, and it should be easy to add new log handlers in the future without modifying the core Logger class.
Implement these first:
Filter handler: before printing, remove all occurrences of a (configurable) string from the log message.
Truncation handler: before printing, truncate the message to N characters.
Uppercase handler: before printing, convert the message to uppercase.
Array handler: store the log message in an array, without printing it.
Each handler processes the incoming log message independently, with no dependence on the others.
When you call logger.log("hello world") on the main logger, the message is printed to the console multiple times: the filtered version, the truncated version, and the uppercase version, in that order. The message is also stored in an array.
Your design should accommodate future requirements, for example:
A database logger: creates a new database connection every time something is logged.
A logger that sends the message to a remote API endpoint. */
They asked a few questions about how to optimize it, and how to make the handlers flexible about what gets passed in.
They said I could use AI, so I did it in Cursor. I got rejected right after finishing. So even though they say you can use AI, if the code the AI writes is too good, you get failed.
Discussion
Loading comments…