All problems
Shift Boxes
Problem
Translate every box in [x1, y1, x2, y2] coordinates by (dx, dy).
Add dx to the x coordinates and dy to the y coordinates, rounding each value to 4 decimal places.
Test cases
case 1
in: [[[1,2,3,4],[5,6,7,8]],10,-1]
expected: [[11,1,13,3],[15,5,17,7]]
case 2
in: [[[0,0,2,2]],0.5,0.5]
expected: [[0.5,0.5,2.5,2.5]]
case 3
in: [[],3,4]
expected: []
Starter codePython
def shift_boxes(boxes, dx, dy):
# Your code here
pass3 test cases · run your code against them in the editor