Pregunta de entrevista de Affirm

How would you make this code more generic?