Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Automating a Repetitive Task

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

Your question is Automating a Repetitive Task. 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

BetMGM QA engineers may repeatedly review smoke-test results to determine which checks fail most often. Write a function that automates this summary by counting failed executions for each test name.

Formal Specification

Implement summarize_failures(results), where results is a list of dictionaries. Each dictionary contains:

  • test: a non-empty string identifying a BetMGM test case
  • status: either "passed" or "failed"

Return a dictionary mapping each test name that failed at least once to its number of failed executions. Ignore passing results. Preserve the order in which test names first appear in the output. If no test failed, return an empty dictionary.

Constraints

  • 1 <= len(results) <= 10^5
  • Each result contains a non-empty test name and a valid status
  • Test names contain up to 100 characters
  • Each status is either "passed" or "failed"
  • Test names may appear in multiple results

Function Signature

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