Solution to programming challenges