F01 · LOOP BOUNDARIES · 30–45 MINUTES
Why did ten documents become nine?
Ten fictional documents go in, but only nine come out. Before adding a line, predict what happens with zero documents and with just one.
Back to the route / Python bridge →The bug and the local task
def process_documents(documents):
processed = []
for index in range(len(documents) - 1):
processed.append(documents[index]["id"])
return processed
- Implement process_documents(documents). Return the document IDs, exactly once each, in their original order.
- Keep the input list and records, including tags, unchanged. Do not move, open or delete real files.
- Inputs already satisfy the document contract. F01 repairs traversal; validation and real file storage come in later tasks.
This exercise handles fictional metadata, not real documents on your computer.
01 · CONTROLLED MODEL
Predict, then inspect each step
This models only the selected preset. It does not execute your Python draft or read/write computer files. One matching case does not establish correctness for all inputs.
for index in range(n - 1):
processed.append(documents[index]["id"])Range / objects: range(9) · Stop value is excluded
Processed: 0/10 · Current index: — · Unchecked or invalidated
Result IDs: []
Progressive learning hints
Hints are fixed teaching content. Their use is recorded.
Hint 1
List the expected IDs for lengths 0, 1 and 10. Which smallest input reveals the omission?
Hint 2
The stop value of range is excluded. Which indices does range(len(documents) - 1) produce when the length is 1?
Hint 3
Either cover indices 0 through n-1 or iterate over the documents directly. Both implementations should preserve input and pass the same behavior tests.
My Python draft
Save and export your draft here. Code is not executed or synced to the starter. Draft, input or strategy edits invalidate earlier model results and self-reports.
Local learning records
Saved only in this browser; export is available. No cross-device sync or proof of mastery. Earlier F01 and six-task records are preserved through migration.
- F01 opened: —
- Model check: Unchecked or invalidated
- Local tests (self-reported): —
- Highest hint level: 0/3
- Reference viewed: —
- Unaided variant (self-reported): —
02 · Run your own repair locally
Use a computer, Python 3.11+ and a terminal. See VERIFICATION.md for environments actually tested. No third-party dependencies. Extract into a new directory before running.
Download starter (intentional failures)
- Open a terminal in the extracted root. Check the environment, then run demo.py and the public tests. On Windows, try py -3 if python is unavailable; on POSIX, python3 is common.
- Edit process_documents in domain.py. Keep the public tests intact. Try empty and singleton inputs, then verify more records, content and order.
- Rerun tests and record the actual file executed and the before/after difference. The web model does not run these files for you.
python check_environment.py python demo.py python -m unittest tests.test_f01 -v python -m unittest discover -s tests -v
In the starter, four nonempty F01 tests and four nonempty variant tests intentionally fail. Empty-input, input-preservation and contract tests should pass. See EXPECTED_FAILURES.md for the exact list.
03 · Independent variant: a homework reviewer skips someone
A homework reviewer also skips a student. Independently implement review_submissions(submissions): return every student ID once, in order, without changing the input. The starter uses a while skeleton. Supply your own minimal failing input and explanation, then run tests.test_variant.
python -m unittest tests.test_variant -v
Explain why your minimal counterexample reveals the bug, and add an assertion in tests/test_my_counterexample.py. Export your learning record; a self-report is not remote verification.
Reference explanation and answer
Try your own repair first. Opening the explanation or downloading the reference records answer use; this attempt’s variant will no longer be marked unaided.
View reference explanation (records answer use)
range(n - 1) excludes its stop value, so it visits indices 0 through n-2; for n=1 it visits nothing. range(n) or direct iteration covers all records. Public tests inspect actual returned values, order and input preservation; keywords in comments cannot make them pass.
def process_documents(documents):
return [document["id"] for document in documents]Download reference implementation (answer) · Version and source digest
Reference tests show that the materials work; they do not establish your completion or mastery. The reference package includes an equivalent index-based implementation for comparison.