title
The input is a string str of digits. Cut the string into chunks (a chunk here is a substring of the initial string) of size sz (ignore the last chunk if its size is less than sz).
If a chunk represents an integer such as the sum of the cubes of its digits is divisible by 2, reverse that chunk; otherwise rotate it to the left by one position. Put together these modified chunks and return the result as a string.
If
sz
is <= 0 or ifstr
isempty
return “”sz
is greater(>)
than the length ofstr
it is impossible to take a chunk of sizesz
hence return “”.
example
1 | revrot("123456987654", 6) --> "234561876549" |
My solution
1 | function revrot(str, sz) { |
good solution
one
1 | function revrot(str, sz) { |
two
1 | function revrot(str, sz) { |