Solved two uva problems, first one paper then implement and check