Algoworks interview question

Puzzle , Swift, Coding logic skills