use inverted ifs in the ruby version
use default parameter in C++ version
Perl implementation