An ugly but full solution to the quickcheck exercise.