Generating zig-zags

Write a program that, given pairs of positive natural numbers
height, width, where width is an even number, generates zig-zags like
the ones shown in the examples.

Input

An arbitrary number of cases, where each consists of two positive
natural numbers height, width, the width being an even number, in one
line.

Output

For each case, the corresponding zig-zag, followed by a blank line.

Observation

You can write the output character by character or by previously
building strings, as you wish.

Grading up to 10 points:

- Slow solution: 5 points.

- Fast solution: 10 points.

We understand as a fast solution one which is correct, with linear cost
and which passes the public and private tests. We understand as slow
solution one which is not fast, but it is correct and passes the public
tests.

Problem information

Author: PRO1

Generation: 2026-01-25T22:32:21.710Z

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