Exercise: Transpose text
Write a function that receives a string and a number transpose(text, width) and returns a string in which the characters are transposed:
Given this input: “abcdefg”, 2
You can create this intermediate table
ab
cd
ef
g
And then read in the characters column-by-column to return this: “acegbdf”.
Given this input: “abcdefg”, 3
The intermediate table is this:
`` abc def g
And the result is "adgbecf"
<!-- {% embed footer message="Copyright © 2026 • Created with ❤️ by [Gábor Szabó](https://szabgab.com/)" %} -->
<div data-embedify data-app="footer" data-option-message="Copyright © 2026 • Created with ❤️ by [Gábor Szabó](https://szabgab.com/)" style="display:none"></div>
<style>footer { text-align: center; text-wrap: balance; margin-top: 5rem; display: flex; flex-direction: column; justify-content: center; align-items: center; } footer p { margin: 0; }</style><footer><p>Copyright © 2026 • Created with ❤️ by <a href="https://szabgab.com/">Gábor Szabó</a></p></footer>