Add solution for 2012 World Final Problem D.