Supermarket exercise

My (incomplete) solution to the supermarket exercise.