perl, python and ruby solution added for problem 16