I wrote a program to solve this problem: https://www.codewars.com/kata/550f22f4d758534c1100025a/train/c
The program works fine when the function is called with