Viajes interview question

How to write program in algorithm?