UVA puzzles solution