• + 0 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.