For this task, you will write two validators.
- Shift Validator: Determines if each element is translated (added or subtracted) by a constant.
- Multiple Validator: Determines if each element is multiplied by a positive or negative constant.
A few examples to illustrate these respective functions:
is_shifted([1, 2, 3], [2, 3, 4]) ➞ True
# Each element is shifted +1
is_shifted([1, 2, 3], [-9, -8, -7]) ➞ True
# Each element is shifted -10
is_multiplied([1, 2, 3], [10, 20, 30]) ➞ True
# Each element is multiplied by 10
is_multiplied([1, 2, 3], [-0.5, -1, -1.5]) ➞ True
# Each element is multiplied by -1/2
is_multiplied([1, 2, 3], [0, 0, 0]) ➞ True
# Each element is multiplied by 0
- Keep in mind one special case: if the second list is a list of only zeroes, then the first list can be anything (the multiplier will be
0
).