Solution for daily programmer 6-18-2014