sheet3: exercise 4 code done

needs a LOT of comments to document