All problems
Pad Image to Square
Problem
Pad a 2D image to a square with a constant value.
Extra rows are added at the bottom and extra columns at the right until height equals width, all filled with value. An already square image is returned unchanged.
Test cases
case 1
in: [[[1,2],[3,4],[5,6]],0]
expected: [[1,2,0],[3,4,0],[5,6,0]]
case 2
in: [[[1,2,3],[4,5,6]],9]
expected: [[1,2,3],[4,5,6],[9,9,9]]
case 3
in: [[[1,2],[3,4]],0]
expected: [[1,2],[3,4]]
Starter codePython
def pad_to_square(image, value):
# Your code here
pass3 test cases · run your code against them in the editor