Sliding window 2

Recall that a string (genomic sequence) can be split in words of length 3 (codons) by sliding a window of size 3 over the string, with a step size of 3. More in general, a string can be split in overlapping words of length xx and overlap size xyx-y by sliding a window of size xx and step size yy over the string. For example, sliding a window of size 3 and step size 2 over the string TATAAT gives the overlapping words TAT and TAA.

Write code for the sliding window problem. The program must implement and use the SLIDING-WINDOW function in the pseudocode discussed in class, which is recursive and is not allowed to perform input/output operations. Make one submission with Python code and another submission with C++ code.

Input

The input is a string ss (a genomic sequence) over the alphabet Σ={A,C,G,T}\Sigma=\{A,C,G,T\}, an integer xx (the window size), and an integer yy (the step size).

Output

The output is all substrings of ss of size xx starting at positions 1,1+y,1+2y,1,1+y,1+2y,\ldots

Hint

Notice that there are no “partial” substrings of ss (of size smaller than xx) in the output.

Problem information

Author: Gabriel Valiente

Generation: 2026-01-25T17:43:36.383Z

© Jutge.org, 2006–2026.
https://jutge.org