Question
There are `n` compute nodes with IDs `0` through `n - 1`. A supplied function `test(group)` returns `True` exactly when every node in `group` is healthy. A test group must contain at least two node IDs. Assume at least two nodes are healthy. Implement: ```python def find_faulty_nodes(n: int, test) -> list[int]: ... ``` Return every faulty node ID in ascending order. Minimize unnecessary tests, but prioritize correctness. Do not assume that testing one node is legal. The supplied `run_case` owns fault labels and the `test` callback; implement only `find_faulty_nodes`. Each test must contain at least two distinct valid non-boolean integer IDs. The public safety budget is at most `n*(n-1)//2 + n-1` callback calls; it admits pair discovery followed by classification and is not an optimality claim. Nodes are fixed during a run, and `n` is an integer at least two. Results must be a sorted list of integer IDs. ## Assumption The exact optimization objective was not fully specified. Treat tests as deterministic and sequential for the base problem; discuss total test count and wall-clock rounds separately in follow-ups. ## Design discussion (not graded) 1. Once healthy reference nodes are known, classify remaining nodes efficiently. 2. Run tests in parallel when a node cannot participate in two simultaneous groups. 3. Adapt pooled testing when faults are rare or, conversely, when most nodes are faulty. 4. Handle flaky test outcomes with confidence thresholds and retries.