I have a small script that combines array elements into chains. With bigger arrays javascript is simply way too slow for my purposes so I would like you to convert the script to C or C++. It's three small functions so shouldn't take very long.
The program can't have any external dependencies (for example Boost libraries).