All problems
Resize Target Selection
Problem
Choose a resize target that fixes the short side but caps the long side.
Scale so the short side becomes short_target, then if the long side would exceed max_target scale the result down so the long side equals max_target. Round dimensions to integers and return [new_h, new_w].
Test cases
case 1
in: [100,200,64,256]
expected: [64,128]
case 2
in: [200,100,64,64]
expected: [64,32]
case 3
in: [50,50,100,200]
expected: [100,100]
case 4
in: [300,400,100,150]
expected: [100,133]
Starter codePython
def select_resize_target(h, w, short_target, max_target):
# Your code here
pass4 test cases · run your code against them in the editor