Duolingo Interview Question

Design an algorithm to do a task, and code it. Write tests as well.