Case-based lecture: you attempt, we discuss, then we reveal.
cs-037, cs-038, cs-039, cs-040Usernames valid when: 5-16 chars, letters/digits/underscores only, not starting with a digit, no two consecutive underscores. Audit the batch.
Expected: pass | fail: consecutive underscores | fail: starts with letter check | fail: too short
Cost: O(length) with early exits; the design content is the rule ORDER.
Reverse 'stressed' → 'desserts'; reverse words of 'the quick brown fox'; decide whether 'Never odd or even' is a palindrome.
Expected: desserts | fox brown quick the | True False
Cost: O(n) per operation; lecture 19 replaces slicing with two pointers for the palindrome.
Template 'Dear {name}, your {item} is due {deadline}.' When 'item' is missing, print '[item]' visibly rather than crashing.
Expected: Dear Ada, your [item] is due Friday. | Dear Bo, your book is due Monday.
Cost: O(template + record); accumulate-then-join, not repeated concatenation.
'Dormitory' / 'dirty room!'; 'astronomer' / 'moon starer'; 'hello' / 'world'. Reference: True, True, False.
for name in ("ab1", "abc"):
print(name, name[0].isalpha() and name[-1].isdigit())Expected: True | True | False
Cost: O(n log n) via sorting; counting is O(n) - both honest, the ladder is the transferable part.
Check usernames against rules: length, allowed characters, no consecutive underscores. Walk characters and build verdicts.
**Input:** "ada_2019" ok; "ada__love" fail (consecutive underscores); "9lives" fail; "ok" fail (short)**Output:** verdicts as above; rules: 5-16 chars, letters/digits/underscore only, no consecutive underscores, must start with a letterSolve for the worked instance first. Then ask what would change if onenumber, name, or condition were replaced by something stranger.Pseudocode, flowchart or Python. State one assumption. Compare with your neighbour at minute 4.
Instructor: the reveal, the reasoning section and common wrong turns are in the instructor distribution for cs-037 — not embedded in this deck.
Reverse a word, then a sentence word-by-word (not letter-by-letter), then decide if a phrase is a palindrome ignoring spaces and case.
**Input:** "stressed" -> "desserts"; "the quick brown fox"; "Never odd or even"**Output:** desserts; fox brown quick the; palindrome (ignore case/spaces): yesSolve for the worked instance first. Then ask what would change if onenumber, name, or condition were replaced by something stranger.Pseudocode, flowchart or Python. State one assumption. Compare with your neighbour at minute 4.
Instructor: the reveal, the reasoning section and common wrong turns are in the instructor distribution for cs-038 — not embedded in this deck.
Fill 'Dear {name}, ... {deadline} ...' templates from records, handling missing fields with a fallback. Splitting, joining, and safe replacement.
**Input:** template "Dear {name}, your {item} is due {deadline}."; record missing "item"**Output:** "Dear Ada, your [item] is due Friday." with a visible fallback markerSolve for the worked instance first. Then ask what would change if onenumber, name, or condition were replaced by something stranger.Pseudocode, flowchart or Python. State one assumption. Compare with your neighbour at minute 4.
Instructor: the reveal, the reasoning section and common wrong turns are in the instructor distribution for cs-039 — not embedded in this deck.
Decide if two phrases are anagrams ignoring case, spaces, and punctuation. Normalisation as the key idea; two implementation routes (sort vs count).
**Input:** "Dormitory" / "dirty room!"; "astronomer" / "moon starer"; "hello" / "world"**Output:** True, True, False - after normalising (lowercase, letters only)Solve for the worked instance first. Then ask what would change if onenumber, name, or condition were replaced by something stranger.Pseudocode, flowchart or Python. State one assumption. Compare with your neighbour at minute 4.
Instructor: the reveal, the reasoning section and common wrong turns are in the instructor distribution for cs-040 — not embedded in this deck.