Lesson 024: Custom iterators and iter() bridges
Focus
Assume a reviewer executes this verbatim: Intermediate drills Custom iterators and iter() bridges; spin token 259226 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence4mixesCustom iterators and iter() bridges; spin38722. - Ritual: Predict the checksum line, then reconcile on mismatch.
- Guardrail: name the surprise that triggered when literals shifted.
Example (LESSON_UID = "intermediate-024")
# Intermediate drill L024 topic-2 micro-3 pattern-5
LESSON_UID = "intermediate-024"
spin_a, spin_b, spin_c = 821, 280, 532
hop = (spin_a % 13) + 3 + 2
total = (spin_b + 24 * spin_c) % 5003
while hop < (130 % 61) + 30:
total += hop
hop = hop * (407 % 5 + 1) % (spin_a % 127 + 3 + 17)
if total % (spin_b % 17 + 3 + 11) == 0:
break
print(total, hop)
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-24.txt"
snap = [37, 865, 702, 539, 376, 213]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (532 + 131))
Practice
Practice 28: Enumerate three pytest markers you'd decorate if this lived in CI. Literal nudge 28.
Fingerprints
- lesson_uid:
intermediate-024 - umbrella band:
Custom iterators and iter() bridges(4/10) - lesson_index:
758