Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Refactoring in an OOP App

HardPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Refactoring in an OOP App. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Build an OOP app where each stage builds on the last, requiring refactors and careful design.

Implement build_reports(documents) using composable stages for normalization, tokenization, and word-frequency reporting. Each stage must expose a consistent processing interface, and the pipeline must pass one stage's output directly to the next without embedding stage-specific logic.

Input is a list of strings. Return one report per input string, where each report contains the token list and a frequency dictionary. Preserve token order and treat words case-insensitively after trimming and collapsing whitespace.

Constraints

  • 0 <= len(documents) <= 500
  • 0 <= len(documents[i]) <= 1000
  • Documents contain arbitrary whitespace and non-whitespace text
  • Tokens are separated by whitespace only
  • The output contains one report for every input document

Function Signature

def build_reports(documents):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output