Wrote code for ACM 4178