Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Validate Idempotent Linux Task Runner

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

Your question is Validate Idempotent Linux Task Runner. 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

Given a list of Linux automation task results, implement a function that determines whether the automation run is safe and repeatable. Each task is represented as a dictionary with keys name, changed, rc, and check_rc, where changed is a boolean indicating whether the task modified the system, rc is the normal execution return code, and check_rc is the dry-run return code. Return True if every task succeeded in both modes and at least one task is idempotent, meaning its dry-run and normal execution agree on whether a change is needed; otherwise return False.

Constraints

  • 1 <= len(tasks) <= 10^4
  • Each task contains keys: name, changed, rc, check_rc
  • rc and check_rc are integers in the range [-255, 255]

Function Signature

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