Intersection X96828


Statement
 

pdf   zip

html

Let a, b, c, d be integers such that ab and cd. Write a function intersection(a, b, c, d) that assuming that intersection of intervals [a, b] and [c, d] is non empty returns the tuple of integers (p, q) such that [p, q] = [a, b] ∩ [c, d] .

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