Skip to main content
πŸ”’ Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial β†’
⚑
← Coursesβ€ΊSystem Design for Python JuniorsModule 3 Β· Databases + storage Β· Recapβ€ΊπŸŽ― Review: System design module 3 recapscenario64 / 105
+80 XP
Task
Build a small `shard_picker(user_id, num_shards)` using simple consistent hashing: ``` shard_index = sum(ord(c) for c in str(user_id)) % num_shards ``` Returns the integer shard index (0-indexed). This is the simplest possible content-addressing scheme β€” production uses MD5/SHA1/Jump-Consistent-Hash but the SHAPE of the decision is identical. Test for 3 known IDs against 4 shards.
✏️ Write your code here
🐍
Loading Python...
One-time download (~1 MB). Then it runs instantly.
πŸ“Š Result
Press Run to see result...

πŸ’¬ Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…