# oduvan/checkio-mission-rectangles-union

simple description

oduvan committed Oct 17, 2018
Showing with 19 additions and 23 deletions.
 @@ -1,16 +1,18 @@

Sum two passed ints Your mission is to calculate the area covered by a union of rectangles. The rectangles can have a non-empty intersection, which means that a simple sum of given rectangle areas doesn't work. Every rectangle is represented as 4 integers. The first two integers are the coordinates of a left-top corner, and the next two - of a bottom right corner.

Input: Two arguments. Both are int Input: {% if interpreter.slug == "js-node" %} Array of arrays. {% else %} Iterable with tuples. {% endif %}

@@ -25,25 +27,19 @@

{% if interpreter.slug == "js-node" %}
sumTwo(2, 3) == 5
sumTwo(5, 7) == 12

rectanglesUnion([
(6, 3, 8, 10),
(4, 8, 11, 10),
(16, 8, 19, 11)
]) == 33

{% else %}
sum_two(2, 3) == 5
sum_two(5, 7) == 12

rectangles_union([
(6, 3, 8, 10),
(4, 8, 11, 10),
(16, 8, 19, 11)
]) == 33

{% endif %}

How it is used: (math is used everywhere)

Precondition: both given ints should be between -1000 and 1000