You are viewing a single comment's thread. Return to all comments →
Wow. The core of the solution is two lines in Ruby (or one line if you don't mind calling a.length three times).
len = a.length queries.collect { |i| a[((len - k) % len + i) % len] }
It may be possible to simplify my expression, but I wasn't able to see how to reduce it.
Circular Array Rotation
You are viewing a single comment's thread. Return to all comments →
Wow. The core of the solution is two lines in Ruby (or one line if you don't mind calling a.length three times).
It may be possible to simplify my expression, but I wasn't able to see how to reduce it.