added code for Uva:12503
Merge pull request #27 from rahulroot/12503-code

added code for Uva:12503