All problems
Batch Stack Shape Check
Problem
Check whether a list of 2D images can be stacked into a single batch.
Return True when every image has the same height and width, otherwise False. An empty list counts as stackable.
Test cases
case 1
in: [[[[1,2],[3,4]],[[5,6],[7,8]],[[9,10],[11,12]]]]
expected: true
case 2
in: [[[[1,2],[3,4]],[[5,6,7],[8,9,10]]]]
expected: false
case 3
in: [[]]
expected: true
case 4
in: [[[[1]],[[1]]]]
expected: true
Starter codePython
def can_stack(images):
# Your code here
pass4 test cases · run your code against them in the editor