added code for Uva:12279
Merge pull request #23 from rahulroot/12279-code

added code for Uva:12279