Code from quiz problem