Costello Medical Interview Question

Do this assignment in R