Beginner
Plan the storage for a vector index
Write bytes_needed(n_vectors, dims, kind) for kind equal to "float32" (4 bytes per number), "int8" (1 byte per number) or "binary" (1 bit per number, so dims // 8 bytes). It returns a whole number of bytes. For any other kind raise ValueError.
Write fits(n_vectors, dims, kind, budget_gb, overhead=1.0): True when the bytes needed, multiplied by overhead (the index adds memory on top of the raw vectors), are at most budget_gb * 1e9.
What Check tests
- float32 uses 4 bytes per number
- int8 uses 1 byte per number
- binary uses 1 bit per number
- An unknown kind raises ValueError
fitsaccounts for the index overhead
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.