Twoim zadaniem jest napisanie programu, który, biorąc pod uwagę liczbę i ciąg, dzieli ciąg na fragmenty tego rozmiaru i odwraca je.
Zasady
Twój program otrzyma dodatnią liczbę całkowitą n
, a także ciąg s
o długości co najmniej jeden składający się tylko z drukowalnego ASCII (bez białych znaków). Łańcuch powinien być następnie podzielony na kawałki długości n
, jeśli długość łańcucha nie jest podzielna przezn
resztki na końcu, należy uznać za własny kawałek. Następnie odwróć kolejność kawałków i połącz je ponownie.
Przypadki testowe
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
To jest golf golfowy , więc powinieneś dążyć do jak najmniejszej liczby bajtów.