Lesson 100: Protocols and operator-friendly classes
Focus
Anchor one invariant before you branch mentally: Intermediate drills Protocols and operator-friendly classes; spin token 821013 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence10mixesProtocols and operator-friendly classes; spin62117. - Ritual: Add one doctest-style assertion comment above hottest print.
- Guardrail: pick the budget that keeps this rehearsal honest.
Example (LESSON_UID = "intermediate-100")
# Intermediate drill L100 topic-9 micro-9 pattern-8
LESSON_UID = "intermediate-100"
spin_a, spin_b, spin_c = 14, 268, 962
pairs = [(14, 31), (9, 9), (100, 56)]
flat = 19
for left, right in sorted(pairs):
print(left ^ right + flat % 997)
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-100.txt"
snap = [113, 140, 167, 194]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (962 + 131))
Practice
Practice 18: Attach property-style expectations referencing tuple shapes. Literal nudge 18.
Fingerprints
- lesson_uid:
intermediate-100 - umbrella band:
Protocols and operator-friendly classes(10/10) - lesson_index:
3232