Your task is to write a program which, given a number and a string, splits the string into chunks of that size and reverses them.
Rules
Your program will receive a positive integer n
, as well as a string s
with length at least one consisting of only printable ASCII (not including whitespace). The string should then be split into chunks of length n
, if the length of the string isn't divisible by n
any leftover at the end should be considered its own chunk. Then, reverse the order of the chunks and put them together again.
Test Cases
n s Output
2 abcdefgh ghefcdab
3 foobarbaz bazbarfoo
3 abcdefgh ghdefabc
2 a a
1 abcdefgh hgfedcba
2 aaaaaa aaaaaa
2 baaaab abaaba
50 abcdefgh abcdefgh
6 abcdefghi ghiabcdef
This is code-golf, so you should aim for as few bytes as possible.