Ad

Refactored for acepting any number basis.

Code
Diff
  • function getIDS(string $number) {
      $number = str_split($number);
      array_walk($number, function($digit) use ($number) {
        return intval($digit); 
      });
      return array_sum($number);
    }
    • function getIDS($number) {
    • return array_sum(str_split($number));
    • function getIDS(string $number) {
    • $number = str_split($number);
    • array_walk($number, function($digit) use ($number) {
    • return intval($digit);
    • });
    • return array_sum($number);
    • }

With parameter int 011, the tests fail.