All problems
Box Area
Problem
Compute the area of a box in [x1, y1, x2, y2] continuous coordinates.
Return (x2 - x1) * (y2 - y1) rounded to 4 decimal places. Degenerate boxes have area 0.
Test cases
case 1
in: [[0,0,2,3]]
expected: 6
case 2
in: [[1,1,1,5]]
expected: 0
case 3
in: [[2.5,1,4.5,3]]
expected: 4
case 4
in: [[0,0,0,0]]
expected: 0
Starter codePython
def box_area(box):
# Your code here
pass4 test cases · run your code against them in the editor