Problem set 3 of CS50x