passes given example, fails UVa with wrong answer