The Book-shelver's Problem

UVA - 10239