chrisjacksonn/interview-sim / skills/sim
sim
VerifiedRun a timed coding assessment simulation in the terminal. Use for OA practice, GCA or ICA mocks, mock interviews, pairing rounds, take-homes, and pasted job postings.
questions/gca/build-order/problem.md
View on GitHub# Build Order
A build system runs tasks, some of which must wait for others. You are given the
task names and a list of `(before, after)` pairs meaning `before` must run at
some point before `after`.
Write `solve(tasks, requirements)` that returns a list containing every task in a
valid order, or an empty list if no such order exists.
## Ties
Several orders are usually valid, so the answer must be pinned down: whenever
more than one task is ready to run, take the one that sorts first
alphabetically.
## Rules
- Every task in `tasks` appears exactly once in the result.
- A requirement mentioning a task not in `tasks` is ignored.
- Duplicate requirements are allowed and mean nothing extra.
- If the requirements contain a cycle, return `[]`.
- A task that requires itself is a cycle.
## Examples
```python
solve(["a", "b", "c"], [("a", "b"), ("b", "c")])
# ["a", "b", "c"]
solve(["a", "b", "c"], [])
# ["a", "b", "c"]
# Nothing is blocked, so it is purely alphabetical.
solve(["build", "test", "lint"], [("build", "test")])
# ["build", "lint", "test"]
# At the start, build and lint are both ready. "build" sorts first. Then lint
# and test are both ready, and "lint" sorts first.
solve(["a", "b"], [("a", "b"), ("b", "a")])
# []
solve([], [])
# []
```
## Constraints
- `0 <= len(tasks) <= 20_000`
- `0 <= len(requirements) <= 100_000`
- Task names are non-empty, case-sensitive strings, and `tasks` has no duplicates.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |