- PHP
Start training on this collection. Each time you skip or complete a kata you will be taken to the next kata in the series. Once you cycle through the items in the collection you will revert back to your normal training routine.
DescriptionEdit
A lighthearted, increasingly wicked journey through PHP fundamentals and algorithms.
Follow Morlin, an over-eager apprentice wizard, as he unlocks spells (concepts), crafts runes (data structures), and eventually duels real enemies (algorithms & state machines).
What this collection is
A curated series of katas with a shared story, escalating difficulty, and a clear learning arc. Each chapter is self-contained but references past “unlocks” so the whole thing feels like a campaign, not random drills.
Who it’s for
- PHP learners who want more than just trivial exercises.
- Experienced devs who enjoy clean specs, tricky edge cases, and a bit of narrative chaos.
- Anyone who’s ever been burned by PHP’s “truthy” surprises and wants stricter thinking.
How it works
Start at Chapter 1 and go in order. Each kata introduces a rule set and a concept you’ll “unlock” for later use.
Read the story (short, fun), then the strict rules. The tests are unforgiving by design.
Sample tests guide; hidden tests hammer edge cases.
Expect occasional gotchas that punish lazy casting and loose comparisons.
Difficulty ladder (multiple katas per tier)
- 8 kyu — Apprentice Orientation: safe casting, string/array basics, input hygiene
- 7 kyu — Runecrafting 101: associative arrays, sorting, normalization
- 6–5 kyu — Arcane Systems: OOP immutability, custom matching, graphs/BFS, generators
- 4–3 kyu — Endgame: DP/memoization, search/backtracking, lightweight AI & combat loops
Unlocks (meta-progression)
You’ll earn “Spell Slots” (array thinking), “Runecrafting” (maps & merges), “Mana Economy” (DP/greedy), “Turn Engine” (queues & priorities), “Status Effects” (state machines), and more. Later katas lean on earlier unlocks conceptually.
Chapters included so far
-
Chapter 1: The Empty Cauldron (8 kyu)
Count only real ingredients under strict rules. Punishes sloppy truthiness.
Signature:countIngredients(array $vals): int
-
Chapter 2: Pocket Pebbles (8 kyu)
Safely coerce scalars to integers. No numeric cosplay allowed.
Signature:toIntSafe($v): int
-
Chapter 3: Loadout Check (8 kyu)
Normalize a fixed-size spell loadout: strict slot parsing, validate/Title-Case/dedup spells, pad with "Cantrip", and reject banned spells.
Signature:normalizeLoadout($slots, array $spells): array
-
Chapter 4: The Mirror Whisper (8 kyu)
Palindrome ward: keep ASCII letters only, case-insensitive, non-empty after cleaning.
Signature:isMirrorWhisper(string $phrase): bool
The 8 kyu tier is complete: input hygiene, safe casting, normalization, and a clean logic puzzle. No sloppy casting. No loose comparisons. No mercy.
- Chapter 5: Rune Backpack (7 kyu) — NEW
Merge multiple rune bags into one inventory. Validate names, collapse spaces, case-insensitive merge, accept integer or integer-valued float quantities, prune totals ≤ 0, output Title-Cased keys, and sort by quantity DESC, then name ASC (case-insensitive).
Signature: mergeRunes(array $bags): array
Coming up next (teasers)
- Rune Backpack (7 kyu): merge inventories, sort by quantity/name.
- Spell Cleaner (7 kyu): regex hygiene for incantations.
- Flickering Portals (5 kyu): shortest paths via BFS.
- Potion of a Thousand Steps (5 kyu): generators & state.
- Mana Economy (4 kyu): DP to hit a target at minimal cost.
- Time-Split Duel (3 kyu): backtracking for optimal sequences.
Style & testing
Tight specs, zero ambiguity; “close enough” fails.
Edge-case heavy (whitespace, signs, zeroes, nulls, booleans, deceptive strings).
PHPUnit tests: readable samples + randomized hidden oracles.
Ground rules
Prefer explicit checks over clever shortcuts.
Treat input like hostile magic: sanitize, validate, then act.
If you solve it on the first try without reading the rules carefully… you probably didn’t. Try again.