chapter 5 exercises: permuted index