Write a function @inclusion(x1, y1, x2, y2)@ that receives the
dimensions of two rectangles
and
(all four numbers are strictly positive integers) and checks whether the
first fits inside the second, the other way round, or none of both
options. The funcion must return “first inside second”,
“second inside first”, or “none” respectively.
If two rectangles have the same size, are considered as
“first inside second”.
Note that the rectangles may be rotated 90 if that makes the fitting possible
For example, the call inclusion(6,3,4,2) corresponds to
the rectangles with sizes
and
:
+----+ +--+
| | +--+
+----+
and the expected answer is “second inside first”.
The call inclusion(3,6,4,2) corresponds to the
rectangles with sizes
and
:
+-+
| |
| | +--+
| | +--+
| |
+-+
and the expected answer is also “second inside first”,
since it would fit if we turned
90
any of them.
The call inclusion(6,3,7,2) corresponds to the
rectangles with sizes
and
:
+----+ +-----+
| | +-----+
+----+
and the expected answer is “none”, since no rectangle
fits in the other, with or without
90
turn.
Finally, the call inclusion(4,2,3,6) corresponds to the
rectangles with sizes
and
:
+-+
| |
+--+ | |
+--+ | |
| |
+-+
and the expected answer is “first inside second”, since
it would fit after a
90
turn.
>>> inclusion(6,3,4,2) second inside first >>> inclusion(3,6,4,2) second inside first >>> inclusion(6,3,7,2) none >>> inclusion(4,2,3,6) first inside second