Click4Ai

338.

Easy

### IoU Calculation

The Intersection over Union (IoU) is a metric used to evaluate the accuracy of object detection models. It measures the ratio of the intersection area to the union area between two bounding boxes.

**Example:** Given two bounding boxes, we want to calculate their IoU.

**Constraints:** The input boxes are represented as (x, y, w, h) tuples.

### Solution

Write a function iou that takes two bounding boxes and returns their IoU.

Test Cases

Test Case 1
Input: [(1, 1, 2, 2), (2, 2, 3, 3)]
Expected: 0.5
Test Case 2
Input: [(1, 1, 2, 2), (1, 1, 1, 1)]
Expected: 0.75
+ 3 hidden test cases