Google interview question

basic coding and simulation setup.