Solution to Baylor ACM/ICPC problem 6282