I think the 2nd example is wrong...
And the solution in APL (Dyalog APL) is:
shift←{(⍴⍵)⍴(-⍺)⌽,⍵}
The left argument is the number of characters to shift and the right argument is the matrix. The approach (read from right to left) is as follows:
Test cases:
1 shift 2 2⍴'hiok' kh io 2 shift 3 4⍴'dudeimcoding' ngdu deim codi 1 shift 4 4⍴'abcd1234codeblah' habc d123 4cod ebla
Yes indeed, the second example is wrong, I just noticed that when doing the unit tests!
pretty esoteric but interesting! 🥴🥴🥴
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I think the 2nd example is wrong...
And the solution in APL (Dyalog APL) is:
The left argument is the number of characters to shift and the right argument is the matrix. The approach (read from right to left) is as follows:
Test cases:
Yes indeed, the second example is wrong, I just noticed that when doing the unit tests!
pretty esoteric but interesting! 🥴🥴🥴