All problems
Resize Shortest Side
Problem
Compute the new image size when the shortest side is resized to target while preserving the aspect ratio.
scale = target / min(h, w), then round h * scale and w * scale to the nearest integers and return [new_h, new_w].
Test cases
case 1
in: [200,100,50]
expected: [100,50]
case 2
in: [100,300,150]
expected: [150,450]
case 3
in: [64,64,64]
expected: [64,64]
case 4
in: [33,100,50]
expected: [50,152]
Starter codePython
def resize_shortest(h, w, target):
# Your code here
pass4 test cases · run your code against them in the editor