problem 6, naive sollution