srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/data/packs/programming.json
diff options
context:
space:
mode:
authorsrdusr <[email protected]>2026-01-14 22:23:00 +0200
committersrdusr <[email protected]>2026-01-14 22:23:00 +0200
commit4933f669f8338ca5e4c64cf0294818c5d15ed122 (patch)
tree979ce6ffed0a4a59f65f47252ce9824a77be760e /data/packs/programming.json
parent695bf0df2ec48e67d716dad25711cdc2e96bf7f4 (diff)
downloadtyperpunk-4933f669f8338ca5e4c64cf0294818c5d15ed122.tar.gz
typerpunk-4933f669f8338ca5e4c64cf0294818c5d15ed122.zip
Make every passage long enough to be worth timing, and credit all of them
The dataset's median passage was 69 characters, about twelve words, which is over in twelve seconds at an ordinary speed. Some packs were worse: shell had a median of 46 and a shortest entry of 17. That is the reason packs felt small. It was not the number of entries, which was 15 to 37 per pack, but the length of each one. Multiplayer had already hit this and worked around it: load_race_texts filters to 120 characters or more. That filter left only 61 of 350 passages eligible, 38 of them from two packs, so races repeated constantly and four packs could never come up at all. Both halves are fixed. Content: 104 longer passages added across every pack. The command packs get whole pipelines rather than single flags, which is how the tools are actually used and what the explanations were always for. Prose packs get passages that run 150 to 320 characters. Selection: a floor of 120 characters. Prose packs draw from their long entries where a pack holds at least five, so no pack is reduced to the same few passages. The command packs chain consecutive entries into one drill, which is the natural shape for them, and the explanations are collected so each line is still described. Measured over 400 draws per pack, every category now runs a median of 146 to 218 characters with a shortest draw of 120. The race pool went from 61 of 350 to 130 of 454. Attribution: 24 passages had none and displayed nothing at all under the text. They now say Unknown, which is the honest answer for a fact written for the pack, and the pangram is credited as one. The results and typing screens both fall back to Unknown rather than rendering an empty line, and the pack name is shown beside the source. Multiplayer results, three fixes: - PB never appeared. A race has no mode of its own, so modeKey was undefined, so recordResult never ran. Races share one key, because the passage is whatever the server dealt and a per-passage best would never be beaten. - Play Again started a solo test. A race carries standings and a solo run does not, so the results screen can tell them apart and now queues for another race. The end screen's own cleanup leaves the old room first. - CONSISTENCY was the longest label on the screen and made the accuracy column wider than the WPM column opposite it. It reads CON. RaceText carries the pack name so the results can show it for a race the same way single player does. 24 Rust tests and 3 browser tests pass.
Diffstat (limited to 'data/packs/programming.json')
-rw-r--r--data/packs/programming.json72
1 files changed, 71 insertions, 1 deletions
diff --git a/data/packs/programming.json b/data/packs/programming.json
index e0bcd72..d8b3f64 100644
--- a/data/packs/programming.json
+++ b/data/packs/programming.json
@@ -257,5 +257,75 @@
"attribution": "SQL",
"explanation": "EXPLAIN ANALYZE runs the query and reports what the planner actually did, not what it guessed it would do.",
"content": "EXPLAIN ANALYZE SELECT * FROM test_results WHERE mode_key = 'time-30' ORDER BY wpm DESC LIMIT 50;"
+ },
+ {
+ "category": "programming",
+ "content": "const grouped = items.reduce((acc, item) => ({ ...acc, [item.type]: [...(acc[item.type] ?? []), item] }), {});",
+ "attribution": "JavaScript",
+ "explanation": "Groups a list by one field. The nullish coalescing operator supplies an empty array the first time a type is seen, so no separate initialisation step is needed.",
+ "language": "javascript"
+ },
+ {
+ "category": "programming",
+ "content": "let counts: HashMap<&str, usize> = text.split_whitespace().fold(HashMap::new(), |mut m, w| { *m.entry(w).or_insert(0) += 1; m });",
+ "attribution": "Rust",
+ "explanation": "entry returns a view into the slot for a key whether or not it exists. or_insert fills it on first sight, and the star dereferences that slot so it can be incremented in place.",
+ "language": "rust"
+ },
+ {
+ "category": "programming",
+ "content": "with open(path, encoding='utf-8') as fh: rows = [line.rstrip('\\n').split('\\t') for line in fh if line.strip()]",
+ "attribution": "Python",
+ "explanation": "The with block closes the file even if the loop raises. Naming the encoding matters: without it Python uses the machine's locale, so the same file can parse differently elsewhere.",
+ "language": "python"
+ },
+ {
+ "category": "programming",
+ "content": "impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, \"{}: {}\", self.kind, self.detail) } }",
+ "attribution": "Rust",
+ "explanation": "Implementing Display is what lets a type be printed with the plain brace form. The formatter carries the width and precision the caller asked for.",
+ "language": "rust"
+ },
+ {
+ "category": "programming",
+ "content": "export const debounce = (fn, ms) => { let t; return (...args) => { clearTimeout(t); t = setTimeout(() => fn(...args), ms); }; };",
+ "attribution": "JavaScript",
+ "explanation": "The timer handle lives in the closure, so every returned function keeps its own. Each call cancels the pending one, and only a pause longer than ms lets the work through.",
+ "language": "javascript"
+ },
+ {
+ "category": "programming",
+ "content": "SELECT u.name, COUNT(o.id) AS orders FROM users u LEFT JOIN orders o ON o.user_id = u.id GROUP BY u.id, u.name HAVING COUNT(o.id) > 5;",
+ "attribution": "SQL",
+ "explanation": "A LEFT JOIN keeps users with no orders, and HAVING filters on the aggregate, which WHERE cannot do because WHERE runs before the grouping.",
+ "language": "clike"
+ },
+ {
+ "category": "programming",
+ "content": "def chunked(seq, n): return [seq[i:i + n] for i in range(0, len(seq), n)]",
+ "attribution": "Python",
+ "explanation": "Slicing past the end of a sequence is not an error in Python, it simply returns what is there, so the final chunk needs no special case.",
+ "language": "python"
+ },
+ {
+ "category": "programming",
+ "content": "match value { Some(n) if n > 0 => n, Some(_) => 0, None => return Err(Error::Missing) }",
+ "attribution": "Rust",
+ "explanation": "The if after a pattern is a match guard. It narrows an arm without a nested conditional, and the compiler still checks that every case is covered.",
+ "language": "rust"
+ },
+ {
+ "category": "programming",
+ "content": "const sorted = [...items].sort((a, b) => a.score - b.score || a.name.localeCompare(b.name));",
+ "attribution": "JavaScript",
+ "explanation": "sort mutates, so the spread makes a copy first. The logical or supplies a second comparison used only when the scores are equal.",
+ "language": "javascript"
+ },
+ {
+ "category": "programming",
+ "content": "async fn fetch_all(urls: Vec<String>) -> Vec<Result<String, Error>> { futures::future::join_all(urls.into_iter().map(fetch)).await }",
+ "attribution": "Rust",
+ "explanation": "join_all drives every future at once on one task and waits for all of them, rather than awaiting each in turn, which would make the requests sequential.",
+ "language": "rust"
}
-] \ No newline at end of file
+]