Master the fundamental concepts of storage fundamentals through this focused micro-challenge.
Disks and SSDs expose storage in sectors or pages, often 4096 bytes. Database engines map a byte offset to (offset / block_size) to find the containing block. SQLite, PostgreSQL, and MySQL buffer managers all start with this arithmetic before reading a page from disk.
Integer division truncates toward zero for non-negative offsets. The remainder tells you where inside the block the byte lives.
cLoading…
Keep the relevant documentation open while you implement. When your output disagrees with the reference, trace one failing case by hand before changing random lines.
You will read a byte offset and block size from stdin and print the block index plus in-block offset. This exercise asks you to implement the mapping every page-oriented storage engine uses.
Read two integers from stdin: a byte offset and a block size.
Print two lines:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github