Given two intervals A and B, decide if A can be translated and placed into B. You can assume both given interval has some measure(or say length).
aka. Exist d, for all x in A, x+d is in B.
Both extreme points are positive integers but can be either open or close(given in input, flexible form). Moved distance needn't be integer, though.
Test cases:
[1,2], [1,3] => true
[1,2], (1,3) => true (d can't be integer but it's fine)
[1,2], [8,9] => true
[8,9), [1,2) => true
(1,9), (1,9) => true
[1,4], [3,5] => false
(8,9], [1,2) => false (rotating is not allowed)
(7,9), [1,2] => false
Now some simple challenges onto main, CMC isn't quite active
Both extreme points are positive integers
. to avoid float error and simple some languages \$\endgroup\$[n
orn]
would be[n,0]
and instead of(n
orn)
would be[n,1]
be ok (e.g.(8,9], [1,2)
would be input as[[8,1],[9,0]], [[1,0],[2,1]]
)? \$\endgroup\$