Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Parse 10GB Log and Count PCIe Errors
00:00
5 left

Parse 10GB Log and Count PCIe Errors

EasyPython

Problem

An AMD EPYC system can produce log files too large to load into memory at once. Write a function that streams log lines and counts occurrences of selected PCIe error codes.

Each relevant log entry contains the exact pattern PCIe_ERROR code=CODE, where CODE consists only of uppercase letters, digits, underscores, and hyphens. Ignore lines without this pattern and ignore codes that are not in the requested set. A line contains at most one PCIe error entry.

Formal Specification

Implement count_pcie_errors(lines, error_codes).

  • lines is an iterable of strings, such as a file object. The function must process it incrementally and must not convert the complete input into a list.
  • error_codes is a list of distinct strings identifying codes to count.
  • Return a dictionary mapping every requested code to its frequency, including codes with frequency zero.

Constraints

  • 1 <= len(error_codes) <= 10^4
  • The total log size can be approximately 10 GB
  • Each line contains at most 10^4 characters
  • Error codes are case-sensitive
  • Input lines may contain malformed or unrelated text
  • Each line contains at most one PCIe error entry

Function Signature

def count_pcie_errors(lines, error_codes):
Interviewer

Your question is Parse 10GB Log and Count PCIe Errors. Start with the requirements in the Question tab.

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.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.