Mack's LoL Scout
Stretch C

Data Structures sidequest (pick one)

Choose either champion-name autocomplete (Trie) or an in-memory LRU cache to layer on top of disk caching.

Run

Run after each small change. Tiny loops win.

uv run python -m src.scout
You will touch
  • src/scout/ (either autocomplete or caching)
  • data/cache/ (if LRU layer)
  • data/ddragon/champ_lookup.json (if Trie seed)
Time

90–180 minutes

Do this (suggested order)

  1. Pick one option: Trie (autocomplete) or LRU (in-memory cache). Don’t multi-queue.
  2. Implement the tiny core API (Trie: insert + starts_with; LRU: get + put + eviction).
  3. Wire it into something visible (CLI flag for Trie, or fetch layer for LRU).
  4. Add debug logs so you can see behavior (suggestions, hits, evictions).
  5. Demo it with a tiny example and celebrate responsibly.

You’ll practice

  • Trees/tries & prefix search
  • LRU eviction thinking
  • Time/space tradeoffs

Explainers (for context, not homework)

Build

Option C1: Trie
  • Implement TrieNode/Trie with insert + starts_with(prefix, limit=10)
  • --search "ka" prints suggestions
  • Seed with Data Dragon champion list
Option C2: LRU
  • LRUCache(capacity) with get/put + eviction
  • Hook into fetch_json: MEM → DISK → NETWORK
  • Debug logs: MEM HIT / DISK HIT / NETWORK

Check yourself

  • Trie: typing 3 letters returns good suggestions quickly.
  • LRU: Logs show fewer network calls on repeated requests.

If it breaks

  • Trying to build both options at once (pick one!)
  • Forgetting to update recency on get() in LRU
  • Not normalizing strings for trie lookups

Hints (spoilers)

Trie hint: seed it with real words

Seed it with your champion list. Autocomplete is only fun if it knows words.

Two tiny rules

normalize to lowercase
store original spelling for display
LRU hint: make cache behavior visible

Your LRU should log MEM HIT, DISK HIT, and NETWORK. If you can see the cache behavior, you can trust it.

Log vibe

MEM HIT    <cache_key>
DISK HIT   <cache_key>
NETWORK    <url>
EVICT      <cache_key>
Unblock-me: LRU must update recency on get()

A classic bug: you update recency on put, but not on get. Then your LRU evicts hot items and feels “random”.

LRU debug log vibe (what you want)

MEM HIT    <cache_key>
DISK HIT   <cache_key>
NETWORK    <url>

Trie CLI vibe (what you want)

--search "ka"
Karma
Kassadin
Katarina
Kalista