script for solving problem 9