Intersection X96828


Statement
 

pdf   zip

Let a,b,c,da, b, c, d be integers such that aba\le b and cdc\le d. Write a function @intersection(a, b, c, d)@ that assuming that intersection of intervals [a,b][a, b] and [c,d][c, d] is non empty returns the tuple of integers (p,q)(p, q) such that [p,q]=[a,b][c,d][p, q] = [a, b] \cap [c, d].

Sample session

Sample session
>>> intersection(1, 5, 3, 7)
(3, 5)
>>> intersection(10, 16, 12, 15)
(12, 15)
>>> intersection(3, 5, 2, 11)
(3, 5)
>>> intersection(1, 4, 4, 6)
(4, 4)
Information
Author
ProAl
Language
English
Official solutions
Python
User solutions
Python