All problems
Seeded Random Horizontal Flip
Problem
Randomly flip images horizontally with probability p using a seeded RNG.
Seed the random module, then for each image draw random.random() and flip it (reversing every row) when the draw is less than p. Return the list of resulting images.
Test cases
case 1
in: [[[[1,2],[3,4]],[[5,6],[7,8]],[[9,10],[11,12]],[[13,14],[15,16]]],0.5,1]
expected: [[[2,1],[4,3]],[[5,6],[7,8]],[[9,10],[11,12]],[[14,13],[16,15]]]
case 2
in: [[[[1,2],[3,4]],[[5,6],[7,8]]],1,2]
expected: [[[2,1],[4,3]],[[6,5],[8,7]]]
case 3
in: [[[[1,2],[3,4]],[[5,6],[7,8]]],0,3]
expected: [[[1,2],[3,4]],[[5,6],[7,8]]]
Starter codePython
def random_hflip(images, p, seed):
# Your code here
pass3 test cases · run your code against them in the editor