Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-282

Sliding-Window Tiling

Problem

List the tile origins needed to cover an image with sliding windows.

Origins step by stride from 0 while the tile fits, always appending n - win as the final origin when needed so the last row and column are covered. Return the [top, left] origins row-major.

Test cases

case 1
in: [6,6,4,2]
expected: [[0,0],[0,2],[2,0],[2,2]]
case 2
in: [8,8,4,3]
expected: [[0,0],[0,3],[0,4],[3,0],[3,3],[3,4],[4,0],[4,3],[4,4]]
case 3
in: [4,7,4,1]
expected: [[0,0],[0,1],[0,2],[0,3]]
case 4
in: [5,5,5,2]
expected: [[0,0]]
Starter codePython
def sliding_window_origins(h, w, win, stride):
    # Your code here
    pass

4 test cases · run your code against them in the editor