loading...

Discussion on: Daily Challenge #272 - Printer Errors

Collapse
peter279k profile image
peter279k

Here is the simple solution with PHP and ASCII code function:

function printerError($s) {
  $startChar = ord('a');
  $lastChar = ord('m');

  $index = 0;
  $missedCount = 0;
  for (; $index<strlen($s); $index++) {
    if (ord($s[$index]) > $lastChar && $startChar < ord($s[$index])) {
      $missedCount += 1;
    }
  }

  return $missedCount . '/' . strlen($s);
}