How can I code this in Python with only if-statements? (Only allowed to use the built-in functions int(), float(), and str().)
def intervals_relation(A_start, A_end, B_start, B_end)
Description: The function checks whether intervals A and B have an overlap and returns a value that indicates what kind of overlap this is.
Parameters: A_start (int) and A_end (int) are the left and right limits of interval A, while B_start (int) and B_end (int) are the left and right limits of interval B respectively. All values are inclusive (i.e. intervals are closed from both ends). Parameters A_start and A_end are guaranteed to be in order (the same holds for parameters B_start and B_end), but this doesn’t mean that interval A is necessarily positioned before interval B.
Return value: If the two intervals do not overlap you return 0. If one is enclosed entirely by the other you return 1. If there is a partial overlap you return -1. The return value is always an int.
Examples:
intervals_relation(1,8,2,8) → 1
intervals_relation(3,7,-1,2) → 0
intervals_relation(4,5,-2,4) → -1