Pregunta de entrevista de Fidelity Investments

Solve a string splicing problem in Java and Python (had to use both languages)