First Topcoder solution