solve to challenge of pset in CS50 course