Add example_system_prompts/ (prose, speeches, coding) and matching example_user_prompts/ (four user prompts per domain, one file each so they run directly via --prompt-file), plus a README mapping the pairs and the run command against the default model. Also refine the three system prompts: separate narrative register from character speech and add a length default (prose); add a duration→word-count rule, spoken-language guidance, a no-invented-evidence rule, and a salutation note (speeches); fix the mangled numbered list and add a language default, a no-invented-APIs rule, and clearer output ordering (coding). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
733 B
733 B
Gegeben ist eine ineffiziente Python-Funktion, die für eine Liste von Wörtern die Häufigkeit jedes Wortes zählt und dabei für jedes Wort erneut die gesamte Liste durchläuft:
def count_words(words):
counts = {}
for w in words:
counts[w] = 0
for x in words:
if x == w:
counts[w] += 1
return counts
Schreibe eine effiziente Variante, erkläre die Verbesserung der Zeitkomplexität und zeige mit einem kleinen Benchmark (z. B. timeit) den Unterschied bei größeren Eingaben.
Behandle dabei sinnvolle Randfälle: leere Liste, Groß-/Kleinschreibung und anhängende Satzzeichen (was soll als „dasselbe Wort" gelten?). Triff dazu eine begründete Annahme.