Print function hackerrank solution