Code

The harness and the tests

Three files in one step, as usual: the harness, the tests, and two new commands in main.go.

algo index builds the index, prints its shape (buckets, load, chains) and then looks up every title — first through the index, then with lesson 1's linear search so the number has a scale.

algo ordered is step 8's question. It measures nothing; it shows what the index does not have.

The tests (hash_test.go) check four things:

test what it requires
TestHashIndexStoresAndFinds finds everything stored, misses what was not
TestDuplicateKeysReplaceRatherThanAccumulate an equal key replaces, does not accumulate
TestResizeKeepsTheLoadFactorBounded load ≤ 1.0 and fewer than 4 comparisons per lookup
TestKeysAreNotInAnyUsefulOrder Keys() is NOT sorted

The last one looks strange — a test demanding that something is not in order. But it guards this lesson's ending the same way lessons 7 and 8 guarded the defects they demonstrated. If you ever change Keys() to return a sorted list, the test will tell you what you lost: the index's promise is not "I will hand these back in order", and you cannot build on accidental luck.