You are viewing a single comment's thread. Return to all comments →
what is the starting value of your i? (i dont know ruby). d=2, n = 10. Because if it is 0, it would be (0+2)%10 = 2. What am I getting wrong?
The starting value of the i is 0. Looks like correct calculation to me. What result are you expecting?
ha, yeah i wasn't understanding right! I made it this way, that's why I was confused. rotated[(n+i-d)%n] = a[i]. Which is analogous to yours, but calculating the index in destination. Yours is more clear I think. Thanks!
are you a mathematician? because i came out with a bit similar answer