solved problem set 5 (1.5ms)