seed: curriculum content

This commit is contained in:
2026-05-07 14:32:44 +00:00
parent 9258534803
commit ec76f4f56b
100 changed files with 2846 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
---
type: challenge
title: "The Counter"
xp: 75
duration: 30
difficulty: 3
---
# The Counter
> **[INCOMING — Mission Control, Earth]**
>
> Cadet, time to count things in text. Three counts:
>
> - **Total length** — `len(s)`
> - **Word count** — `len(s.split())` (split breaks on whitespace)
> - **`a` count** — `s.lower().count("a")` returns how many `a`s
>
> Implement `count(s)` that returns a dict with three keys:
>
> - `length` — total chars including spaces
> - `words` — word count
> - `a_count` — number of lowercase `a`s after lowercasing
>
> [END TRANSMISSION]
## Your Task
In `starter/starter.py`, build the dict using `len()`, `.split()`,
`.lower()`, `.count()`.
## Objectives
- `count("Hello andromeda")``{"length": 15, "words": 2, "a_count": 2}`
- All three keys present and correct for any sentence

View File

@@ -0,0 +1,16 @@
def count(s):
"""Count three things in a sentence and return a dict.
Keys:
"length" — total characters in s (including spaces)
"words" — number of whitespace-separated words
"a_count" — count of lowercase 'a's after lowercasing s
Helpers:
len(s) — char count
len(s.split()) — word count
s.lower().count("a") — number of 'a's, case-insensitive
count("Hello andromeda") -> {"length": 15, "words": 2, "a_count": 2}
"""
pass

View File

@@ -0,0 +1,21 @@
from solution import count
def test_hello_andromeda():
assert count("Hello andromeda") == {"length": 15, "words": 2, "a_count": 2}
def test_all_systems_nominal():
assert count("All systems nominal") == {"length": 19, "words": 3, "a_count": 2}
def test_caps_with_a():
assert count("MISSION READY ALPHA") == {"length": 19, "words": 3, "a_count": 3}
def test_quick_brown_fox():
assert count("the quick brown fox jumps over") == {
"length": 30,
"words": 6,
"a_count": 0,
}