re-creation of the ninja gold assignment, made in PHP codeIgniter