Gamified challenge · Simulation
A banner has rows rows. The painter writes text one letter per column: down from the top row to the bottom row, then diagonally back up to the top, then down again, and so on. With one row, the letters just go left to right.
Write zigzag(text, rows) that returns what you read when you take the banner's rows top to bottom, each row left to right, skipping the gaps. For text = "GRANDOPENING" and rows = 2, row 1 has GADPNN and row 2 has RNOEIG, so the answer is "GADPNNRNOEIG".
rows is at least 1 and may be larger than the text; an empty text gives "".
This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.
Sign in with Google