LLM Engineering · Exercise 6 of 6 Previous
Advanced
Roll out a prompt to a percentage of users
Write bucket(text): start with h = 0, and for each character do h = (h * 31 + ord(ch)) % 1000003; return h * 7919 % 1000003 % 100.
Write enabled(user_id, flag, percent) that returns True when bucket(flag + ":" + user_id) < percent. The same user must always get the same answer.
What Check tests
bucketmatches the course's hash- Buckets are between 0 and 99
- 0 percent enables nobody and 100 percent everybody
- A higher percentage only adds users
- The answer is the same every time
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.