DiacriTech interview question

String manipulation and problem solving in python