Pre-Calculus for Programmers
Quality control report
A workshop measures every pin it cuts and logs the length in micrometres, which is why all the numbers are whole. A pin is acceptable if its length is within tol of target, too long and too short counting the same. At the end of a shift somebody wants the list of the ones that failed, so they can be pulled off the line.
Given readings, target and tol, return the readings that failed, in the order they were measured. A reading exactly tol away from the target passes: the specification says within, and within includes the boundary.
Input: readings = [498, 500, 502, 505], target = 500, tol = 2
498: distance |498 - 500| = 2, which is not more than 2, so it passes
500: distance 0, passes
502: distance 2, passes
505: distance 5, which is more than 2, so it fails
Output: [505]Input: readings = [], target = 50, tol = 3 Output: []
Input: readings = [100], target = 100, tol = 0 Output: []
Input: readings = [10, -10, 0], target = 0, tol = 5 Output: [10, -10]readings holds between 0 and 2000 values, each from to .target is from to , and tol is from 0 to .Run your code to see how it does on the examples. Submit also runs the hidden cases.