Dataset for Transpose tests

I have been stuck on Transpose for longer than I would like to admit.

My current issue is with test_mixed_line_length. The expected result is made up of rows from the columns of the input, but the some of the rows are trimmed on the right, while others, such as "h ", are not. (See the example below)

I assume that the issue is to trim so no later row is longer. That is, as long as there is a row of length n non-blanks ahead, pad this row to n. Once all later rows can be trimmed, reduce row length.

But the problem statement says:

“In general, all characters from the input should also be present in the transposed output. That means that if a column in the input text contains only spaces on its bottom-most row(s), the corresponding output row should contain the spaces in its right-most column(s).”

I read this to say “Don’t trim on right”.


Here is the expected result:

expected = [
"h “,
" ooi”,
“n e.”,
"ei “,
" .n”,
“l e”,
“i .”,


Basically, you need to trim extra “blanks” from the end, but don’t trim off whitespace that was already present in the input.

To do this, you need to first pad the string with something else, e.g. a “null”. Then you remove all nulls from the end of the list, and then replace all the nulls with whitespace again.

Or compute required line length and padding to that length. Working from the bottom up can help with that.

The insight that helped me: a line is not shorter than the one below it.

Thank you for the insight: I know what to do now.

Is this requirement reflected in the instructions?


Exercism does test-driven development: the requirements are encapsulated in the tests. Not everything is revealed in the instructions.

You called out this requirement yourself :slightly_smiling_face: