Pergunta de entrevista da empresa Block

Python easy problem about strings (does not translate well to R)