FreeExam

Dependency and Rollout Algorithms

Thirty original Python problems on release dependencies, rollout transitions, availability budgets, exact placement, revision races, compatibility, cutover evidence and compensation. Build deterministic witnesses for explicitly supplied finite deployment models.

These problems are original practice. They are not questions from a named employer or a live hiring loop.

  1. 1.Find services whose exact deployment requirements are ready

    Write deployment_frontier(tasks,observed). tasks maps service to [target_revision,requirements_map], dependency->revision. observed maps service to [revision,phase]. Return sorted services not already ready at target whose EVERY requirement is observed at that exact revision with phase "ready". Missing observations never satisfy support. Use one snapshot, including external pins. No mutation.

  2. 2.Order dependent steps across global phase barriers

    Write phase_plan(steps), <=12 names mapping to [phase,parent_names], phase 0/1/2. Every parent must precede its child; EVERY lower-phase step must precede EVERY higher-phase step. Duplicate parents collapse. Return the lexicographically smallest full order, or None for an unknown parent or cycle, including phase-induced cycles. Empty steps returns []. No mutation.

  3. 3.Choose the largest quorum-preserving maintenance set

    Write maintenance_set(hosts,candidates,minimum,zone_caps), <=12 unique known candidates. hosts maps ID to [zone,service_list]; each host counts once per service. Remove a subset of candidates, retaining each service minimum and obeying zone removal caps (absent cap unbounded). Return the largest feasible sorted subset, lexical tie, or None if even empty is infeasible. No mutation.

  4. 4.Place every relocated job within both resource budgets

    Write placement_assignment(jobs,capacity). <=8 jobs [unique_id,CPU,memory,allowed_hosts], nonnegative integers; <=4 hosts map to [CPU,memory] capacity. Allowed hosts are known. Place every job once. Return sorted [job_id,host] pairs for the lexicographically smallest host vector in sorted-job order, or None if infeasible. Empty jobs returns []. No mutation.

  5. 5.Find a shortest availability-preserving replica transition

    Write replica_plan(n,minimum,surge), integers 0<=minimum<=n<=6, 0<=surge<=6. Start with n ready old replicas and no new ones. Implement the exact start/ready/retire transitions in the starter. Return a shortest action list reaching zero old, zero starting and n ready new replicas; ties use action priority start,ready,retire. Return None if unreachable. No mutation.

  6. 6.Redistribute integer traffic through allowed directed links

    Write traffic_moves(start,target,edges). Equal-length nonnegative integer vectors, <=4 entries, equal sum<=8. An allowed [i,j] edge moves ONE unit from i to j when i has traffic; i!=j. Duplicate edges collapse. Return a minimum-length move list, lexicographic tie by [i,j] sequence, or None if unreachable. Equal vectors need []. No mutation.

  7. 7.Build minimum waves with dependency and conflict constraints

    Write rollout_waves(needs,conflicts,parallel). <=9 names map to known prerequisite lists; conflicts are unordered distinct-name pairs; parallel>=1. Each wave has <=parallel names, no conflict, and prerequisites completed in EARLIER waves. Return a minimum-wave plan, lexical tie on lists of sorted names, or None for cycles. Empty needs returns []. No mutation.

  8. 8.Undo applied dependents before their prerequisites

    Write rollback_order(applied,needs). applied is a unique-name list in application order; needs maps names to prerequisites, missing entry means none. Undo only applied names, requiring applied dependents to be undone before their prerequisites. Among eligible names choose the most recently applied. Ignore references outside applied. Return full undo order or None for a cycle. No mutation.

  9. 9.Find an uninterrupted shared credential-validity window

    Write rotation_window(old,new,now,duration). Validity lists contain integer half-open intervals [a,b), a<b; now>=0, duration>0. Coalesce overlap/adjacency separately. Return earliest integer t>=now such that [t,t+duration) is contained in BOTH validity unions, or None. Finishing exactly at an interval end is allowed. Supplied time arithmetic only; no credential operations or mutation.

  10. 10.Audit simultaneous ready-count changes as atomic batches

    Write drain_timeline(initial,events,minimum). initial maps hosts to nonnegative ready counts with total>=minimum>=0. Events [integer_time,host,integer_delta], arbitrary order; unknown hosts start at zero. Apply ALL changes at a timestamp together. Return the earliest [time,sorted_negative_hosts,total_ready] where any host is negative OR total<minimum, otherwise None. No mutation.

  11. 11.Measure peak coexistence with same-time retirement

    Write surge_budget(old,creations,retirements). old>=0 initial replicas at time 0. Rows [time,count] have nonnegative integer time/count. Created replicas persist; retirements remove only old replicas and cumulatively never exceed old. Apply equal-time creation/retirement atomically. Include the initial baseline. Return [peak_total,max(0,peak_total-old),earliest_peak_time]. No mutation.

  12. 12.Require both elapsed readiness and sample support

    Write stability_gate(samples,count,duration,gap). Samples [strictly_increasing_integer_time,status], status True/False/None. count>=1, duration/gap>=0. A run contains consecutive True samples; False/None or adjacent time gap>gap resets it. Return earliest sample index whose run has >=count samples and last_time-first_time>=duration, or None. Exact gap/duration equality passes. No mutation.

  13. 13.Replay revision-checked configuration replacements

    Write revision_cas(state,operations). state maps names to [nonnegative_revision,JSON_value]. Operations [name,expected_revision,new_revision,new_value]; expected None requires absence, otherwise exact revision. Replacements also require new_revision>current; creates allow any nonnegative revision. Reject failed indices, apply others in order. Return [detached_state,rejected_indices]. No mutation.

  14. 14.Find incomparable advertised revision heads

    Write revision_heads(parents,advertised), <=12 revision names. parents maps a name to parent names. Validate only advertised names and their ancestors: missing names/cycles return None; duplicate parent or advertised evidence collapses. Otherwise return [sorted_heads,len(heads)==1], where a head is an advertised revision that is NOT an ancestor of another distinct advertised revision. No mutation.

  15. 15.Search finite compatibility-preserving version changes

    Write compatibility_path(versions,start,target,constraints). versions lists allowed integer versions per component, product size<=128. Constraints [i,j,allowed_pairs] require [state[i],state[j]] in allowed_pairs. Each move changes one component to ANY allowed version. Start/target must be allowed and compatible. Return a shortest [[index,new_version]] list, lexical tie, or None. No mutation.

  16. 16.Report every disjoint old and new quorum pair

    Write quorum_gaps(old,new). Each list contains member-name lists representing supplied quorums; duplicate members collapse. Return [old_index,new_index] for EVERY pair with empty intersection, in index-pair order. An empty quorum intersects nothing. Repeated quorum declarations retain their indices. This checks set intersections only, not a consensus protocol. No mutation.

  17. 17.Reserve full compensation capacity before forward work

    Write forward_reserve(budget,steps), nonnegative integers; steps [forward_cost,undo_cost]. In order, accept a step ONLY if budget can pay its forward cost AND remaining cash can cover the sum of undo costs of ALL accepted steps including this one. Stop before the first failure. Return [accepted_count,remaining_cash,undo_reserve]. No actual payments, undo execution or mutation.

  18. 18.Build a reverse queue of uncompensated application attempts

    Write undo_queue(applied,compensated), rows [string_step,nonnegative_attempt]. A pair denotes one application; duplicate applied evidence retains its FIRST application position. Compensated pairs need no undo; unmatched compensation evidence is ignored. Return remaining distinct pairs in reverse first-application order. Different attempts of one step are separate actions. No mutation.

  19. 19.Choose one checkpoint under a supplied replay-cost model

    Write checkpoint_choice(costs,weights,overhead), equal-length nonnegative integer lists, overhead>=0. Choose k=0..n; k=0 means no checkpoint, otherwise after step k. Use the exact integer score in the starter. Return [lowest_score_k,score], ties smaller k. This is a supplied weighted-scenario score, not an inferred failure distribution or runtime guarantee. No mutation.

  20. 20.Keep phase, zone and revision support together

    Write observation_gaps(required,observed). Required rows [string_phase,string_zone,integer_revision]; observations [phase,zone,revision,success_bool]. A requirement is supported iff an EXACT triple has any successful observation. Failed or different-revision evidence does not qualify. Return distinct unsupported triples sorted lexicographically. Duplicate requirements collapse. No mutation.

  21. 21.Require dependency evidence from strictly earlier timestamps

    Write barrier_completions(events), rows [integer_time,string_id,prerequisite_IDs], arbitrary order. Process each timestamp atomically. Accept iff ID not completed, declared ONCE this timestamp, and all prerequisites completed at STRICTLY earlier timestamps. Reject all duplicate same-tick IDs. Return [accepted_input_indices,sorted_completed_IDs]. Indices retain input order. No mutation.

  22. 22.Allocate new replicas to minimize final zone skew

    Write zone_spread(existing,capacity,additional). Same <=5 zone keys map to nonnegative existing counts and EXTRA capacity; 0<=additional<=8. Choose integer additions 0..capacity summing exactly additional. Minimize max(final)-min(final), then lexical additions vector in sorted-zone order. Return [sorted [zone,addition] pairs,skew], or None. No zones with zero additional gives [[],0]. No mutation.

  23. 23.Assign integer traffic using exact fractional remainders

    Write traffic_apportionment(weights,total), name->nonnegative integer weights, total>=0 integer. Allocate floor(total*w/sum) to each name, then remaining units to largest fractional remainders, ties lexical name. Return sorted [name,units]. Zero total gives all zeros even if weight sum=0. Positive total with zero weight sum returns None. Exact integer arithmetic, no mutation.

  24. 24.Find states that can reach safety using enabled undo actions

    Write undo_reachable(actions,safe). Rows [string_from,string_to,undo_enabled_bool] describe forward actions. An enabled undo permits to->from; disabled actions permit NO undo. Return sorted distinct states that can reach any supplied safe state using only enabled undo edges, including safe states themselves. Duplicate actions collapse in effect; cycles allowed. No mutation.

  25. 25.Extract only ordering pairs shared by every supplied history

    Write unanimous_order(names,histories). names are unique strings; each history is a permutation of all names. Return sorted [a,b] pairs with a!=b where a occurs before b in EVERY supplied history. With no histories return [] because evidence is absent. These are observed ordering relations, not a causal or future-execution guarantee. No mutation.

  26. 26.Select the latest checkpoint shared by required shards

    Write restore_checkpoint(shards,required). shards maps names to lists of nonnegative integer checkpoint IDs. required is a unique-name list. Return the largest ID present in EVERY required shard, ignoring duplicate IDs. Return None for an unknown required shard, empty intersection, or empty required list. Nonrequired shards do not constrain selection. No mutation.

  27. 27.Compare closed integer guards including impossible boxes

    Write guard_implications(metrics,guards). Unique metric names; guards maps ID to metric->[inclusive_low,inclusive_high], integer or None unbounded. Missing metric means unbounded; low>high makes the ENTIRE guard impossible. Return sorted distinct-ID [a,b] pairs where passing a implies passing b for ALL integer assignments. An impossible a implies every b. No mutation.

  28. 28.Find unretained manifest artifacts without deleting anything

    Write artifact_candidates(manifests,kept,leases,now). manifests maps release IDs to artifact-name lists; leases maps artifact to integer expiry. Candidate universe is all manifest artifacts. Retain artifacts of every kept release and leases with expiry>now. Return sorted remaining names, or None if ANY kept release is unknown. Duplicate evidence collapses. No actual deletion or mutation.

  29. 29.Schedule ordered change steps around freeze windows

    Write change_windows(jobs,freezes). Jobs [release_time,positive_duration,deadline], nonnegative integers, fixed order on one nonpreemptive worker. Freezes: integer half-open [a,b), a<b. Start each job earliest >=release and previous finish without ANY freeze overlap. Finish on freeze start/start on freeze end is allowed. Return [start,finish] per job, or None for a missed deadline. No mutation.

  30. 30.Detect quiescence or a repeated notification set

    Write notification_settling(edges,initial), <=10 known nodes. edges maps nodes to known trigger targets; duplicates collapse. Each synchronous round replaces active nodes by the union of their targets. Return ["quiet",round] at first empty set, or ["cycle",first_seen_round,period] at first repeated nonempty set. Initial is round 0. Finite model only; no real-system liveness claim or mutation.