Write a programExercise 4/4Intermediate30 XP

A rectangle around points

Task

Write a function obal(body) that gets a non-empty list of points as tuples (x, y) and returns the smallest axis-aligned rectangle containing all of them. Return the rectangle as a pair of corners ((x_min, y_min), (x_max, y_max)).

For example obal([(1, 5), (4, 2), (3, 8)]) returns ((1, 2), (4, 8)).

Examples

  • Call

    print(obal([(1, 5), (4, 2), (3, 8)]))

    Expected output

    ((1, 2), (4, 8))

After you submit, 5 hidden tests will also check your solution: one point, negative coordinates, points on one line, decimal coordinates, min x and min y from different points.

Python starts the first time you run code.

Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.

Input (stdin)

Each line = one call to input().

Output

Hints

Try it yourself first. Each hint reveals a little more - and lowers the reward a little.

Signed out, hints are free - but no XP is awarded either.

Solution

The solution unlocks after the last hint.