Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Debug Combine Login Timeout

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

Your question is Debug Combine Login Timeout. 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

Debug a login flow where updating a @Published property (passwordAttempts) in AuthenticationManager triggered view redraws that interfered with a Combine verification timeout publisher.

Asked in the Technical Assessment (90-min Debugging Test) stage. Task #3 of Speechify's 90-minute screen-shared GitHub repository test.

Task

Implement a login verifier that starts a verification request and fails it if a timeout publisher fires first. Updating passwordAttempts must not cancel, restart, or duplicate the in-flight verification pipeline.

Input

  • events: a list of login events in chronological order, each event is one of:
    • ("attempt", username, password)
    • ("verify_success", username)
    • ("verify_failure", username)
    • ("timeout", username)

Output

Return the final state for each username as a dictionary with:

  • status: one of "idle", "verifying", "success", "failure", "timeout"
  • passwordAttempts: integer count of failed attempts

Constraints

  • 1 <= len(events) <= 10^5
  • Each event is a 3-tuple of the form (kind, username, value)
  • Events are already sorted by time
  • A timeout only applies to the currently active verification
  • Usernames are non-empty strings

Function Signature

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